Skip to content

Commit e393e8e

Browse files
committed
service/polkit: align code style
1 parent e87903d commit e393e8e

File tree

5 files changed

+31
-71
lines changed

5 files changed

+31
-71
lines changed

src/services/polkit/agentimpl.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,9 @@ class PolkitAgentImpl
5858

5959
std::deque<AuthRequest*> queuedRequests;
6060

61-
Q_OBJECT_BINDABLE_PROPERTY(
62-
PolkitAgentImpl,
63-
AuthFlow*,
64-
bActiveFlow,
65-
&PolkitAgentImpl::activeFlowChanged
66-
);
67-
Q_OBJECT_BINDABLE_PROPERTY(
68-
PolkitAgentImpl,
69-
bool,
70-
bIsRegistered,
71-
&PolkitAgentImpl::isRegisteredChanged
72-
);
61+
// clang-format off
62+
Q_OBJECT_BINDABLE_PROPERTY(PolkitAgentImpl, AuthFlow*, bActiveFlow, &PolkitAgentImpl::activeFlowChanged);
63+
Q_OBJECT_BINDABLE_PROPERTY(PolkitAgentImpl, bool, bIsRegistered, &PolkitAgentImpl::isRegisteredChanged);
64+
// clang-format on
7365
};
7466
} // namespace qs::service::polkit

src/services/polkit/flow.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ const QString& AuthFlow::actionId() const { return this->mRequest->actionId; }
4242
const QString& AuthFlow::cookie() const { return this->mRequest->cookie; }
4343
const QList<Identity*>& AuthFlow::identities() const { return this->mIdentities; }
4444

45-
QBindable<Identity*> AuthFlow::selectedIdentity() { return &this->bSelectedIdentity; }
46-
4745
void AuthFlow::setSelectedIdentity(Identity* identity) {
4846
if (this->bSelectedIdentity.value() == identity) return;
4947
if (!identity) {
@@ -55,14 +53,6 @@ void AuthFlow::setSelectedIdentity(Identity* identity) {
5553
this->setupSession();
5654
}
5755

58-
QBindable<bool> AuthFlow::isResponseRequired() { return &this->bIsResponseRequired; }
59-
QBindable<QString> AuthFlow::inputPrompt() { return &this->bInputPrompt; }
60-
QBindable<bool> AuthFlow::responseVisible() { return &this->bResponseVisible; }
61-
QBindable<QString> AuthFlow::supplementaryMessage() { return &this->bSupplementaryMessage; }
62-
QBindable<bool> AuthFlow::supplementaryIsError() { return &this->bSupplementaryIsError; }
63-
QBindable<bool> AuthFlow::isCompleted() { return &this->bIsCompleted; }
64-
QBindable<bool> AuthFlow::isSuccessful() { return &this->bIsSuccessful; }
65-
QBindable<bool> AuthFlow::isCancelled() { return &this->bIsCancelled; }
6656
AuthRequest* AuthFlow::authRequest() const { return this->mRequest; }
6757

6858
void AuthFlow::cancelFromAgent() {
@@ -86,7 +76,7 @@ void AuthFlow::submit(const QString& value) {
8676
this->currentSession->respond(value);
8777

8878
this->bIsResponseRequired = false;
89-
this->bInputPrompt = QString {};
79+
this->bInputPrompt = QString();
9080
this->bResponseVisible = false;
9181
}
9282

src/services/polkit/flow.hpp

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ class AuthFlow
9999
[[nodiscard]] const QString& cookie() const;
100100
[[nodiscard]] const QList<Identity*>& identities() const;
101101

102-
[[nodiscard]] QBindable<Identity*> selectedIdentity();
102+
[[nodiscard]] QBindable<Identity*> selectedIdentity() { return &this->bSelectedIdentity; };
103103
void setSelectedIdentity(Identity* identity);
104104

105-
[[nodiscard]] QBindable<bool> isResponseRequired();
106-
[[nodiscard]] QBindable<QString> inputPrompt();
107-
[[nodiscard]] QBindable<bool> responseVisible();
105+
[[nodiscard]] QBindable<bool> isResponseRequired() { return &this->bIsResponseRequired; };
106+
[[nodiscard]] QBindable<QString> inputPrompt() { return &this->bInputPrompt; };
107+
[[nodiscard]] QBindable<bool> responseVisible() { return &this->bResponseVisible; };
108108

109-
[[nodiscard]] QBindable<QString> supplementaryMessage();
110-
[[nodiscard]] QBindable<bool> supplementaryIsError();
109+
[[nodiscard]] QBindable<QString> supplementaryMessage() { return &this->bSupplementaryMessage; };
110+
[[nodiscard]] QBindable<bool> supplementaryIsError() { return &this->bSupplementaryIsError; };
111111

112-
[[nodiscard]] QBindable<bool> isCompleted();
113-
[[nodiscard]] QBindable<bool> isSuccessful();
114-
[[nodiscard]] QBindable<bool> isCancelled();
112+
[[nodiscard]] QBindable<bool> isCompleted() { return &this->bIsCompleted; };
113+
[[nodiscard]] QBindable<bool> isSuccessful() { return &this->bIsSuccessful; };
114+
[[nodiscard]] QBindable<bool> isCancelled() { return &this->bIsCancelled; };
115115

116116
[[nodiscard]] AuthRequest* authRequest() const;
117117

@@ -160,34 +160,16 @@ private slots:
160160
AuthRequest* mRequest = nullptr;
161161
QList<Identity*> mIdentities;
162162

163-
Q_OBJECT_BINDABLE_PROPERTY(
164-
AuthFlow,
165-
Identity*,
166-
bSelectedIdentity,
167-
&AuthFlow::selectedIdentityChanged
168-
);
169-
Q_OBJECT_BINDABLE_PROPERTY(
170-
AuthFlow,
171-
bool,
172-
bIsResponseRequired,
173-
&AuthFlow::isResponseRequiredChanged
174-
);
163+
// clang-format off
164+
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, Identity*, bSelectedIdentity, &AuthFlow::selectedIdentityChanged);
165+
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, bool, bIsResponseRequired, &AuthFlow::isResponseRequiredChanged);
175166
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, QString, bInputPrompt, &AuthFlow::inputPromptChanged);
176167
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, bool, bResponseVisible, &AuthFlow::responseVisibleChanged);
177-
Q_OBJECT_BINDABLE_PROPERTY(
178-
AuthFlow,
179-
QString,
180-
bSupplementaryMessage,
181-
&AuthFlow::supplementaryMessageChanged
182-
);
183-
Q_OBJECT_BINDABLE_PROPERTY(
184-
AuthFlow,
185-
bool,
186-
bSupplementaryIsError,
187-
&AuthFlow::supplementaryIsErrorChanged
188-
);
168+
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, QString, bSupplementaryMessage, &AuthFlow::supplementaryMessageChanged);
169+
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, bool, bSupplementaryIsError, &AuthFlow::supplementaryIsErrorChanged);
189170
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, bool, bIsCompleted, &AuthFlow::isCompletedChanged);
190171
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, bool, bIsSuccessful, &AuthFlow::isSuccessfulChanged);
191172
Q_OBJECT_BINDABLE_PROPERTY(AuthFlow, bool, bIsCancelled, &AuthFlow::isCancelledChanged);
173+
// clang-format on
192174
};
193175
} // namespace qs::service::polkit

src/services/polkit/qml.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "../../core/logcat.hpp"
77
#include "agentimpl.hpp"
8-
#include "flow.hpp"
98

109
namespace {
1110
QS_LOGGING_CATEGORY(logPolkit, "quickshell.service.polkit");
@@ -28,9 +27,9 @@ void PolkitAgent::componentComplete() {
2827

2928
impl->setPath(this->mPath);
3029

31-
this->bFlow.setBinding([impl]() -> AuthFlow* { return impl->activeFlow().value(); });
32-
this->bIsActive.setBinding([impl]() -> bool { return impl->activeFlow().value() != nullptr; });
33-
this->bIsRegistered.setBinding([impl]() -> bool { return impl->isRegistered().value(); });
30+
this->bFlow.setBinding([impl]() { return impl->activeFlow().value(); });
31+
this->bIsActive.setBinding([impl]() { return impl->activeFlow().value() != nullptr; });
32+
this->bIsRegistered.setBinding([impl]() { return impl->isRegistered().value(); });
3433
}
3534

3635
QString PolkitAgent::path() const { return this->mPath; }
@@ -42,8 +41,4 @@ void PolkitAgent::setPath(const QString& path) {
4241
qCWarning(logPolkit) << "cannot change path after it has been set.";
4342
}
4443
}
45-
46-
QBindable<AuthFlow*> PolkitAgent::flow() { return &this->bFlow; }
47-
QBindable<bool> PolkitAgent::isActive() { return &this->bIsActive; }
48-
QBindable<bool> PolkitAgent::isRegistered() { return &this->bIsRegistered; }
4944
} // namespace qs::service::polkit

src/services/polkit/qml.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "../../core/reload.hpp"
1414
#include "../../core/retainable.hpp"
1515

16+
#include "flow.hpp"
17+
1618
// The reserved identifier is exactly the struct I mean.
1719
using PolkitIdentity = struct _PolkitIdentity; // NOLINT(bugprone-reserved-identifier)
1820
using QsPolkitAgent = struct _QsPolkitAgent;
@@ -34,11 +36,10 @@ class PolkitAgent
3436
Q_INTERFACES(QQmlParserStatus);
3537
Q_DISABLE_COPY_MOVE(PolkitAgent);
3638

37-
// clang-format off
38-
/// The D-Bus path that this agent listener will use.
39+
/// The D-Bus path that this agent listener will use.
3940
///
4041
/// If not set, a default of /org/quickshell/Polkit will be used.
41-
Q_PROPERTY(QString path READ path WRITE setPath);
42+
Q_PROPERTY(QString path READ path WRITE setPath);
4243

4344
/// Indicates whether the agent registered successfully and is in use.
4445
Q_PROPERTY(bool isRegistered READ default NOTIFY isRegisteredChanged BINDABLE isRegistered);
@@ -50,9 +51,9 @@ class PolkitAgent
5051
Q_PROPERTY(bool isActive READ default NOTIFY isActiveChanged BINDABLE isActive);
5152

5253
/// The current authentication state if an authentication request is active.
54+
///
5355
/// Null when no authentication request is active.
5456
Q_PROPERTY(AuthFlow* flow READ default NOTIFY flowChanged BINDABLE flow);
55-
// clang-format on
5657

5758
public:
5859
explicit PolkitAgent(QObject* parent = nullptr);
@@ -64,9 +65,9 @@ class PolkitAgent
6465
[[nodiscard]] QString path() const;
6566
void setPath(const QString& path);
6667

67-
[[nodiscard]] QBindable<AuthFlow*> flow();
68-
[[nodiscard]] QBindable<bool> isActive();
69-
[[nodiscard]] QBindable<bool> isRegistered();
68+
[[nodiscard]] QBindable<AuthFlow*> flow() { return &this->bFlow; };
69+
[[nodiscard]] QBindable<bool> isActive() { return &this->bIsActive; };
70+
[[nodiscard]] QBindable<bool> isRegistered() { return &this->bIsRegistered; };
7071

7172
signals:
7273
/// Emitted when an application makes a request that requires authentication.

0 commit comments

Comments
 (0)