Changeset View
Changeset View
Standalone View
Standalone View
daemon/actions/dpms/powerdevildpmsaction.cpp
Context not available. | |||||
28 | #include <powerdevilcore.h> | 28 | #include <powerdevilcore.h> | ||
---|---|---|---|---|---|
29 | #include <powerdevil_debug.h> | 29 | #include <powerdevil_debug.h> | ||
30 | 30 | | |||
31 | #include <QAction> | ||||
31 | #include <QGuiApplication> | 32 | #include <QGuiApplication> | ||
32 | #include <QX11Info> | 33 | #include <QX11Info> | ||
33 | #include <QDebug> | 34 | #include <QDebug> | ||
34 | 35 | | |||
36 | #include <KActionCollection> | ||||
35 | #include <KConfigGroup> | 37 | #include <KConfigGroup> | ||
38 | #include <KLocalizedString> | ||||
36 | #include <KPluginFactory> | 39 | #include <KPluginFactory> | ||
37 | #include <KSharedConfig> | 40 | #include <KSharedConfig> | ||
38 | 41 | | |||
42 | #include <kglobalaccel.h> | ||||
broulik: Use `#include <KGlobalAccel>` and sort it correctly into the other includes | |||||
43 | | ||||
39 | K_PLUGIN_FACTORY(PowerDevilDPMSActionFactory, registerPlugin<PowerDevilDPMSAction>(); ) | 44 | K_PLUGIN_FACTORY(PowerDevilDPMSActionFactory, registerPlugin<PowerDevilDPMSAction>(); ) | ||
40 | 45 | | |||
41 | PowerDevilDPMSAction::PowerDevilDPMSAction(QObject* parent, const QVariantList &args) | 46 | PowerDevilDPMSAction::PowerDevilDPMSAction(QObject* parent, const QVariantList &args) | ||
Context not available. | |||||
67 | 72 | | |||
68 | // inhibitions persist over kded module unload/load | 73 | // inhibitions persist over kded module unload/load | ||
69 | m_inhibitScreen = PowerDevil::PolicyAgent::instance()->unavailablePolicies() & PowerDevil::PolicyAgent::ChangeScreenSettings; | 74 | m_inhibitScreen = PowerDevil::PolicyAgent::instance()->unavailablePolicies() & PowerDevil::PolicyAgent::ChangeScreenSettings; | ||
75 | | ||||
76 | KGlobalAccel *accel = KGlobalAccel::self(); | ||||
77 | | ||||
78 | KActionCollection* actionCollection = new KActionCollection( this ); | ||||
broulik: Coding style: `KActionCollection *actionCollection` (asterisk after space) | |||||
79 | actionCollection->setComponentDisplayName(i18nc("Name for powerdevil shortcuts category", "Power Management")); | ||||
80 | | ||||
81 | QAction *globalAction = actionCollection->addAction(QLatin1String("Turn Off Screen")); | ||||
82 | globalAction->setText(i18nc("@action:inmenu Global shortcut", "Turn Off Screen")); | ||||
83 | accel->setGlobalShortcut(globalAction, QList<QKeySequence>()); | ||||
I suppose there's no Qt::Key_ enum for that, given laptops typically bypass the operating system here anyway. broulik: I suppose there's no `Qt::Key_` enum for that, given laptops typically bypass the operating… | |||||
I couldn't find any appropriate Qt::Key_ so I'm leaving it up to the user to choose one mblumenstingl: I couldn't find any appropriate `Qt::Key_` so I'm leaving it up to the user to choose one | |||||
84 | connect(globalAction, SIGNAL(triggered(bool)), SLOT(turnOffScreen())); | ||||
Use new style connect, you can probably just use a lambda connect(globalAction, &QAction::triggered, this, [this] { if (m_helper) { m_helper->trigger(QStringLiteral("TurnOff")); } }); broulik: Use new style connect, you can probably just use a lambda
```
connect(globalAction, &QAction… | |||||
that if (m_helper) is probably the overloaded != nullptr from https://doc.qt.io/qt-5/qscopedpointer.html#operator-not-eq-1 mblumenstingl: that if (m_helper) is probably the overloaded != nullptr from https://doc.qt.io/qt… | |||||
70 | } | 85 | } | ||
71 | 86 | | |||
72 | PowerDevilDPMSAction::~PowerDevilDPMSAction() = default; | 87 | PowerDevilDPMSAction::~PowerDevilDPMSAction() = default; | ||
Context not available. | |||||
185 | } | 200 | } | ||
186 | } | 201 | } | ||
187 | 202 | | |||
203 | void PowerDevilDPMSAction::turnOffScreen() | ||||
204 | { | ||||
205 | if (m_helper.isNull()) { | ||||
206 | return; | ||||
207 | } | ||||
208 | m_helper->trigger(QStringLiteral("TurnOff")); | ||||
209 | } | ||||
210 | | ||||
188 | #include "powerdevildpmsaction.moc" | 211 | #include "powerdevildpmsaction.moc" | ||
Context not available. |
Use #include <KGlobalAccel> and sort it correctly into the other includes