Changeset View
Changeset View
Standalone View
Standalone View
src/ShortcutActions.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 David Redondo <kde@david-redondo.de> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License along | ||||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
17 | */ | ||||
18 | | ||||
19 | #include "ShortcutActions.h" | ||||
20 | | ||||
21 | #include <QGuiApplication> | ||||
22 | | ||||
23 | #include <KLocalizedString> | ||||
24 | | ||||
25 | ShortcutActions* ShortcutActions::self() | ||||
26 | { | ||||
27 | static ShortcutActions self; | ||||
28 | return &self; | ||||
29 | } | ||||
30 | | ||||
31 | ShortcutActions::ShortcutActions() : mActions{nullptr, QString()} | ||||
32 | { | ||||
33 | //everything here is named to match the jumplist actions in our .desktop file | ||||
34 | mActions.setComponentName(componentName()); | ||||
35 | //qdbus org.kde.kglobalaccel /component/org_kde_spectacle_desktop org.kde.kglobalaccel.Component.shortcutNames | ||||
36 | // ActiveWindowScreenShot | ||||
37 | // CurrentMonitorScreenShot | ||||
38 | // RectangularRegionScreenShot | ||||
39 | // FullScreenScreenShot | ||||
40 | // _launch | ||||
41 | { | ||||
42 | QAction *action = new QAction(i18n("Launch Spectacle")); | ||||
43 | action->setObjectName(QStringLiteral("_launch")); | ||||
44 | mActions.addAction(action->objectName(), action); | ||||
45 | } | ||||
46 | { | ||||
47 | QAction *action = new QAction(i18n("Capture Entire Desktop")); | ||||
48 | action->setObjectName(QStringLiteral("FullScreenScreenShot")); | ||||
49 | mActions.addAction(action->objectName(), action); | ||||
50 | } | ||||
51 | { | ||||
52 | QAction *action = new QAction(i18n("Capture Current Monitor")); | ||||
53 | action->setObjectName(QStringLiteral("CurrentMonitorScreenShot")); | ||||
54 | mActions.addAction(action->objectName(), action); | ||||
55 | } | ||||
56 | { | ||||
57 | QAction *action = new QAction(i18n("Capture Active Window")); | ||||
58 | action->setObjectName(QStringLiteral("ActiveWindowScreenShot")); | ||||
59 | mActions.addAction(action->objectName(), action); | ||||
60 | } | ||||
61 | { | ||||
62 | QAction *action = new QAction(i18n("Capture Rectangular Region")); | ||||
63 | action->setObjectName(QStringLiteral("RectangularRegionScreenShot")); | ||||
64 | mActions.addAction(action->objectName(), action); | ||||
65 | } | ||||
66 | } | ||||
67 | | ||||
68 | KActionCollection* ShortcutActions::shortcutActions() | ||||
69 | { | ||||
70 | return &mActions; | ||||
71 | } | ||||
72 | | ||||
73 | QString ShortcutActions::componentName() const | ||||
74 | { | ||||
75 | return QGuiApplication::desktopFileName().append(QStringLiteral(".desktop")); | ||||
76 | } | ||||
77 | | ||||
78 | QAction* ShortcutActions::openAction() const | ||||
79 | { | ||||
80 | return mActions.action(0); | ||||
81 | } | ||||
82 | | ||||
83 | QAction* ShortcutActions::fullScreenAction() const | ||||
84 | { | ||||
85 | return mActions.action(1); | ||||
86 | } | ||||
87 | | ||||
88 | QAction* ShortcutActions::currentScreenAction() const | ||||
89 | { | ||||
90 | return mActions.action(2); | ||||
91 | } | ||||
92 | | ||||
93 | QAction* ShortcutActions::activeWindowAction() const | ||||
94 | { | ||||
95 | return mActions.action(3); | ||||
96 | } | ||||
97 | | ||||
98 | QAction* ShortcutActions::regionAction() const | ||||
99 | { | ||||
100 | return mActions.action(4); | ||||
101 | } |