Changeset View
Changeset View
Standalone View
Standalone View
daemon/actions/bundled/handlebuttonevents.cpp
Show All 37 Lines | |||||
38 | #include <KScreen/GetConfigOperation> | 38 | #include <KScreen/GetConfigOperation> | ||
39 | #include <KScreen/Output> | 39 | #include <KScreen/Output> | ||
40 | 40 | | |||
41 | #include <kglobalaccel.h> | 41 | #include <kglobalaccel.h> | ||
42 | 42 | | |||
43 | namespace PowerDevil { | 43 | namespace PowerDevil { | ||
44 | namespace BundledActions { | 44 | namespace BundledActions { | ||
45 | 45 | | |||
46 | static const QString s_globalAccelComponent = QStringLiteral("kded5"); | | |||
47 | | ||||
48 | HandleButtonEvents::HandleButtonEvents(QObject *parent) | 46 | HandleButtonEvents::HandleButtonEvents(QObject *parent) | ||
49 | : Action(parent) | 47 | : Action(parent) | ||
50 | , m_screenConfiguration(nullptr) | 48 | , m_screenConfiguration(nullptr) | ||
51 | { | 49 | { | ||
52 | new HandleButtonEventsAdaptor(this); | 50 | new HandleButtonEventsAdaptor(this); | ||
53 | // We enforce no policies here - after all, we just call other actions - which have their policies. | 51 | // We enforce no policies here - after all, we just call other actions - which have their policies. | ||
54 | setRequiredPolicies(PowerDevil::PolicyAgent::None); | 52 | setRequiredPolicies(PowerDevil::PolicyAgent::None); | ||
55 | connect(backend(), SIGNAL(buttonPressed(PowerDevil::BackendInterface::ButtonType)), | 53 | connect(backend(), SIGNAL(buttonPressed(PowerDevil::BackendInterface::ButtonType)), | ||
56 | this, SLOT(onButtonPressed(PowerDevil::BackendInterface::ButtonType))); | 54 | this, SLOT(onButtonPressed(PowerDevil::BackendInterface::ButtonType))); | ||
57 | 55 | | |||
58 | KActionCollection* actionCollection = new KActionCollection( this ); | 56 | KActionCollection* actionCollection = new KActionCollection( this ); | ||
59 | actionCollection->setComponentDisplayName(i18nc("Name for powerdevil shortcuts category", "Power Management")); | 57 | actionCollection->setComponentDisplayName(i18nc("Name for powerdevil shortcuts category", "Power Management")); | ||
60 | 58 | | |||
61 | KGlobalAccel *accel = KGlobalAccel::self(); | 59 | KGlobalAccel *accel = KGlobalAccel::self(); | ||
62 | 60 | | |||
63 | QAction *globalAction = actionCollection->addAction("Sleep"); | 61 | QAction *globalAction = actionCollection->addAction("Sleep"); | ||
64 | globalAction->setText(i18nc("@action:inmenu Global shortcut", "Suspend")); | 62 | globalAction->setText(i18nc("@action:inmenu Global shortcut", "Suspend")); | ||
65 | globalAction->setProperty("componentName", s_globalAccelComponent); | | |||
66 | accel->setGlobalShortcut(globalAction, Qt::Key_Sleep); | 63 | accel->setGlobalShortcut(globalAction, Qt::Key_Sleep); | ||
67 | connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToRam())); | 64 | connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToRam())); | ||
68 | 65 | | |||
69 | globalAction = actionCollection->addAction("Hibernate"); | 66 | globalAction = actionCollection->addAction("Hibernate"); | ||
70 | globalAction->setText(i18nc("@action:inmenu Global shortcut", "Hibernate")); | 67 | globalAction->setText(i18nc("@action:inmenu Global shortcut", "Hibernate")); | ||
71 | globalAction->setProperty("componentName", s_globalAccelComponent); | | |||
72 | accel->setGlobalShortcut(globalAction, Qt::Key_Hibernate); | 68 | accel->setGlobalShortcut(globalAction, Qt::Key_Hibernate); | ||
73 | connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToDisk())); | 69 | connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToDisk())); | ||
74 | 70 | | |||
75 | globalAction = actionCollection->addAction("PowerOff"); | 71 | globalAction = actionCollection->addAction("PowerOff"); | ||
76 | globalAction->setText(i18nc("@action:inmenu Global shortcut", "Power Off")); | 72 | globalAction->setText(i18nc("@action:inmenu Global shortcut", "Power Off")); | ||
77 | globalAction->setProperty("componentName", s_globalAccelComponent); | | |||
78 | accel->setGlobalShortcut(globalAction, Qt::Key_PowerOff); | 73 | accel->setGlobalShortcut(globalAction, Qt::Key_PowerOff); | ||
79 | connect(globalAction, SIGNAL(triggered(bool)), SLOT(powerOffButtonTriggered())); | 74 | connect(globalAction, SIGNAL(triggered(bool)), SLOT(powerOffButtonTriggered())); | ||
80 | 75 | | |||
81 | connect(new KScreen::GetConfigOperation(KScreen::GetConfigOperation::NoEDID), &KScreen::ConfigOperation::finished, | 76 | connect(new KScreen::GetConfigOperation(KScreen::GetConfigOperation::NoEDID), &KScreen::ConfigOperation::finished, | ||
82 | this, [this](KScreen::ConfigOperation *op) { | 77 | this, [this](KScreen::ConfigOperation *op) { | ||
83 | m_screenConfiguration = qobject_cast<KScreen::GetConfigOperation *>(op)->config(); | 78 | m_screenConfiguration = qobject_cast<KScreen::GetConfigOperation *>(op)->config(); | ||
84 | checkOutputs(); | 79 | checkOutputs(); | ||
85 | 80 | | |||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |