1 /* 2 * SPDX-FileCopyrightText: 2019 David Redondo <kde@david-redondo.de> 3 * 4 * SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #include "ShortcutActions.h" 8 9 #include <QGuiApplication> 10 11 #include <KLocalizedString> 12 self()13ShortcutActions *ShortcutActions::self() 14 { 15 static ShortcutActions self; 16 return &self; 17 } 18 ShortcutActions()19ShortcutActions::ShortcutActions() 20 : mActions{nullptr, QString()} 21 { 22 // everything here is named to match the jumplist actions in our .desktop file 23 mActions.setComponentName(componentName()); 24 // qdbus org.kde.kglobalaccel /component/org_kde_spectacle_desktop org.kde.kglobalaccel.Component.shortcutNames 25 // ActiveWindowScreenShot 26 // WindowUnderCursorScreenShot 27 // CurrentMonitorScreenShot 28 // RectangularRegionScreenShot 29 // FullScreenScreenShot 30 // OpenWithoutScreenshot 31 // _launch 32 { 33 QAction *action = new QAction(i18n("Launch Spectacle")); 34 action->setObjectName(QStringLiteral("_launch")); 35 mActions.addAction(action->objectName(), action); 36 } 37 { 38 QAction *action = new QAction(i18n("Capture Entire Desktop")); 39 action->setObjectName(QStringLiteral("FullScreenScreenShot")); 40 mActions.addAction(action->objectName(), action); 41 } 42 { 43 QAction *action = new QAction(i18n("Capture Current Monitor")); 44 action->setObjectName(QStringLiteral("CurrentMonitorScreenShot")); 45 mActions.addAction(action->objectName(), action); 46 } 47 { 48 QAction *action = new QAction(i18n("Capture Active Window")); 49 action->setObjectName(QStringLiteral("ActiveWindowScreenShot")); 50 mActions.addAction(action->objectName(), action); 51 } 52 { 53 QAction *action = new QAction(i18n("Capture Rectangular Region")); 54 action->setObjectName(QStringLiteral("RectangularRegionScreenShot")); 55 mActions.addAction(action->objectName(), action); 56 } 57 { 58 QAction *action = new QAction(i18n("Capture Window Under Cursor")); 59 action->setObjectName(QStringLiteral("WindowUnderCursorScreenShot")); 60 mActions.addAction(action->objectName(), action); 61 } 62 { 63 QAction *action = new QAction(i18n("Launch Spectacle without capturing")); 64 action->setObjectName(QStringLiteral("OpenWithoutScreenshot")); 65 mActions.addAction(action->objectName(), action); 66 } 67 } 68 shortcutActions()69KActionCollection *ShortcutActions::shortcutActions() 70 { 71 return &mActions; 72 } 73 componentName() const74QString ShortcutActions::componentName() const 75 { 76 return QGuiApplication::desktopFileName().append(QStringLiteral(".desktop")); 77 } 78 openAction() const79QAction *ShortcutActions::openAction() const 80 { 81 return mActions.action(0); 82 } 83 fullScreenAction() const84QAction *ShortcutActions::fullScreenAction() const 85 { 86 return mActions.action(1); 87 } 88 currentScreenAction() const89QAction *ShortcutActions::currentScreenAction() const 90 { 91 return mActions.action(2); 92 } 93 activeWindowAction() const94QAction *ShortcutActions::activeWindowAction() const 95 { 96 return mActions.action(3); 97 } 98 regionAction() const99QAction *ShortcutActions::regionAction() const 100 { 101 return mActions.action(4); 102 } 103 windowUnderCursorAction() const104QAction *ShortcutActions::windowUnderCursorAction() const 105 { 106 return mActions.action(5); 107 } 108 openWithoutScreenshotAction() const109QAction *ShortcutActions::openWithoutScreenshotAction() const 110 { 111 return mActions.action(6); 112 } 113