Added clang-format/tidy for additional rules. Adjusted inbranch cpp files.
This commit is contained in:
@@ -12,12 +12,10 @@ namespace ZShell {
|
||||
static constexpr auto kLogin1Service = "org.freedesktop.login1";
|
||||
static constexpr auto kLogin1Path = "/org/freedesktop/login1";
|
||||
static constexpr auto kLogin1Interface = "org.freedesktop.login1.Manager";
|
||||
static constexpr auto kDBusPropertiesInterface = "org.freedesktop.DBus.Properties";
|
||||
static constexpr auto kDBusPropertiesInterface =
|
||||
"org.freedesktop.DBus.Properties";
|
||||
|
||||
LidWatcher::LidWatcher(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_available(false)
|
||||
, m_state(Opened) {
|
||||
LidWatcher::LidWatcher(QObject* parent) : QObject(parent), m_available(false) {
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
m_available = bus.isConnected();
|
||||
|
||||
@@ -27,8 +25,13 @@ LidWatcher::LidWatcher(QObject* parent)
|
||||
return;
|
||||
}
|
||||
|
||||
const auto ok = bus.connect(kLogin1Service, kLogin1Path, kDBusPropertiesInterface, "PropertiesChanged",
|
||||
this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
|
||||
const auto ok = bus.connect(
|
||||
kLogin1Service,
|
||||
kLogin1Path,
|
||||
kDBusPropertiesInterface,
|
||||
"PropertiesChanged",
|
||||
this,
|
||||
SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
|
||||
|
||||
m_available = ok;
|
||||
emit availableChanged();
|
||||
@@ -49,24 +52,30 @@ LidWatcher::LidState LidWatcher::state() const {
|
||||
}
|
||||
|
||||
void LidWatcher::queryInitialState() {
|
||||
auto msg = QDBusMessage::createMethodCall(
|
||||
kLogin1Service, kLogin1Path,
|
||||
kDBusPropertiesInterface, "Get");
|
||||
auto msg = QDBusMessage::createMethodCall(kLogin1Service,
|
||||
kLogin1Path,
|
||||
kDBusPropertiesInterface,
|
||||
"Get");
|
||||
msg << kLogin1Interface << "LidClosed";
|
||||
const QDBusReply<QVariant> reply = QDBusConnection::systemBus().call(msg);
|
||||
if (!reply.isValid()) {
|
||||
qCWarning(lcLidWatcher) << "cannot query LidClosed:" << reply.error().message();
|
||||
qCWarning(lcLidWatcher)
|
||||
<< "cannot query LidClosed:" << reply.error().message();
|
||||
return;
|
||||
}
|
||||
m_state = reply.value().toBool() ? Closed : Opened;
|
||||
emit stateChanged();
|
||||
}
|
||||
|
||||
void LidWatcher::onPropertiesChanged(const QString& interface, const QVariantMap& changed, const QStringList& /*invalidated*/) {
|
||||
if (interface != kLogin1Interface)
|
||||
void LidWatcher::onPropertiesChanged(const QString& interface,
|
||||
const QVariantMap& changed,
|
||||
const QStringList& ) {
|
||||
if (interface != kLogin1Interface) {
|
||||
return;
|
||||
if (!changed.contains("LidClosed"))
|
||||
}
|
||||
if (!changed.contains("LidClosed")) {
|
||||
return;
|
||||
}
|
||||
m_state = changed.value("LidClosed").toBool() ? Closed : Opened;
|
||||
emit stateChanged();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user