Added clang-format/tidy for additional rules. Adjusted inbranch cpp files.
This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
---
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: 0
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignOperands: Align
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
ColumnLimit: 80
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentWidth: 4
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
Language: Cpp
|
||||||
|
MaxEmptyLinesToKeep: 2
|
||||||
|
NamespaceIndentation: None
|
||||||
|
PenaltyBreakAssignment: 10
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 100
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyExcessCharacter: 100
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: c++20
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Always
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
Checks: >
|
||||||
|
-*,
|
||||||
|
bugprone-*,
|
||||||
|
clang-analyzer-*,
|
||||||
|
modernize-*,
|
||||||
|
-modernize-use-trailing-return-type,
|
||||||
|
performance-*,
|
||||||
|
readability-braces-around-statements,
|
||||||
|
readability-else-after-return,
|
||||||
|
readability-identifier-naming,
|
||||||
|
readability-redundant-*,
|
||||||
|
readability-simplify-*,
|
||||||
|
CheckOptions:
|
||||||
|
readability-identifier-naming.ClassCase: CamelCase
|
||||||
|
readability-identifier-naming.EnumCase: CamelCase
|
||||||
|
readability-identifier-naming.FunctionCase: camelBack
|
||||||
|
readability-identifier-naming.MemberCase: camelBack
|
||||||
|
readability-identifier-naming.MemberPrefix: m_
|
||||||
|
readability-identifier-naming.MethodCase: camelBack
|
||||||
|
readability-identifier-naming.NamespaceCase: lower_case
|
||||||
|
readability-identifier-naming.ParameterCase: camelBack
|
||||||
|
readability-identifier-naming.PrivateMemberPrefix: m_
|
||||||
|
readability-identifier-naming.StaticConstantCase: UPPER_CASE
|
||||||
|
readability-identifier-naming.StaticConstantPrefix: k
|
||||||
|
readability-identifier-naming.VariableCase: camelBack
|
||||||
|
WarningsAsErrors: "*"
|
||||||
|
HeaderFilterRegex: ".*"
|
||||||
|
FormatStyle: file
|
||||||
|
|
||||||
|
...
|
||||||
@@ -25,6 +25,9 @@ add_compile_options(
|
|||||||
|
|
||||||
if("plugin" IN_LIST ENABLE_MODULES)
|
if("plugin" IN_LIST ENABLE_MODULES)
|
||||||
add_subdirectory(Plugins)
|
add_subdirectory(Plugins)
|
||||||
|
|
||||||
|
add_custom_target(fix-cc
|
||||||
|
COMMAND sed -i "s/-mno-direct-extern-access/-fno-direct-access-external-data/g" "${CMAKE_BINARY_DIR}/compile_commands.json")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("shell" IN_LIST ENABLE_MODULES)
|
if("shell" IN_LIST ENABLE_MODULES)
|
||||||
|
|||||||
@@ -12,12 +12,10 @@ namespace ZShell {
|
|||||||
static constexpr auto kLogin1Service = "org.freedesktop.login1";
|
static constexpr auto kLogin1Service = "org.freedesktop.login1";
|
||||||
static constexpr auto kLogin1Path = "/org/freedesktop/login1";
|
static constexpr auto kLogin1Path = "/org/freedesktop/login1";
|
||||||
static constexpr auto kLogin1Interface = "org.freedesktop.login1.Manager";
|
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)
|
LidWatcher::LidWatcher(QObject* parent) : QObject(parent), m_available(false) {
|
||||||
: QObject(parent)
|
|
||||||
, m_available(false)
|
|
||||||
, m_state(Opened) {
|
|
||||||
QDBusConnection bus = QDBusConnection::systemBus();
|
QDBusConnection bus = QDBusConnection::systemBus();
|
||||||
m_available = bus.isConnected();
|
m_available = bus.isConnected();
|
||||||
|
|
||||||
@@ -27,8 +25,13 @@ LidWatcher::LidWatcher(QObject* parent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ok = bus.connect(kLogin1Service, kLogin1Path, kDBusPropertiesInterface, "PropertiesChanged",
|
const auto ok = bus.connect(
|
||||||
this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
|
kLogin1Service,
|
||||||
|
kLogin1Path,
|
||||||
|
kDBusPropertiesInterface,
|
||||||
|
"PropertiesChanged",
|
||||||
|
this,
|
||||||
|
SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
|
||||||
|
|
||||||
m_available = ok;
|
m_available = ok;
|
||||||
emit availableChanged();
|
emit availableChanged();
|
||||||
@@ -49,24 +52,30 @@ LidWatcher::LidState LidWatcher::state() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LidWatcher::queryInitialState() {
|
void LidWatcher::queryInitialState() {
|
||||||
auto msg = QDBusMessage::createMethodCall(
|
auto msg = QDBusMessage::createMethodCall(kLogin1Service,
|
||||||
kLogin1Service, kLogin1Path,
|
kLogin1Path,
|
||||||
kDBusPropertiesInterface, "Get");
|
kDBusPropertiesInterface,
|
||||||
|
"Get");
|
||||||
msg << kLogin1Interface << "LidClosed";
|
msg << kLogin1Interface << "LidClosed";
|
||||||
const QDBusReply<QVariant> reply = QDBusConnection::systemBus().call(msg);
|
const QDBusReply<QVariant> reply = QDBusConnection::systemBus().call(msg);
|
||||||
if (!reply.isValid()) {
|
if (!reply.isValid()) {
|
||||||
qCWarning(lcLidWatcher) << "cannot query LidClosed:" << reply.error().message();
|
qCWarning(lcLidWatcher)
|
||||||
|
<< "cannot query LidClosed:" << reply.error().message();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_state = reply.value().toBool() ? Closed : Opened;
|
m_state = reply.value().toBool() ? Closed : Opened;
|
||||||
emit stateChanged();
|
emit stateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LidWatcher::onPropertiesChanged(const QString& interface, const QVariantMap& changed, const QStringList& /*invalidated*/) {
|
void LidWatcher::onPropertiesChanged(const QString& interface,
|
||||||
if (interface != kLogin1Interface)
|
const QVariantMap& changed,
|
||||||
|
const QStringList& ) {
|
||||||
|
if (interface != kLogin1Interface) {
|
||||||
return;
|
return;
|
||||||
if (!changed.contains("LidClosed"))
|
}
|
||||||
|
if (!changed.contains("LidClosed")) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
m_state = changed.value("LidClosed").toBool() ? Closed : Opened;
|
m_state = changed.value("LidClosed").toBool() ? Closed : Opened;
|
||||||
emit stateChanged();
|
emit stateChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
#include <cstdint>
|
||||||
#include <qqmlintegration.h>
|
#include <qqmlintegration.h>
|
||||||
|
|
||||||
namespace ZShell {
|
namespace ZShell {
|
||||||
@@ -16,10 +17,7 @@ class LidWatcher : public QObject {
|
|||||||
Q_PROPERTY(LidState state READ state NOTIFY stateChanged)
|
Q_PROPERTY(LidState state READ state NOTIFY stateChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum LidState {
|
enum LidState : std::uint8_t{ Opened, Closed };
|
||||||
Opened,
|
|
||||||
Closed
|
|
||||||
};
|
|
||||||
Q_ENUM(LidState)
|
Q_ENUM(LidState)
|
||||||
|
|
||||||
explicit LidWatcher(QObject* parent = nullptr);
|
explicit LidWatcher(QObject* parent = nullptr);
|
||||||
@@ -33,8 +31,11 @@ private:
|
|||||||
bool m_available;
|
bool m_available;
|
||||||
LidState m_state = Opened;
|
LidState m_state = Opened;
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void onPropertiesChanged(const QString& interface, const QVariantMap& changed, const QStringList& invalidated);
|
void extracted();
|
||||||
|
void onPropertiesChanged(const QString& interface,
|
||||||
|
const QVariantMap& changed,
|
||||||
|
const QStringList& invalidated);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void availableChanged();
|
void availableChanged();
|
||||||
|
|||||||
Reference in New Issue
Block a user