Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show All 21 Lines | |||||
22 | 22 | | |||
23 | #include "Config.h" | 23 | #include "Config.h" | ||
24 | #include "PlatformBackends/DummyImageGrabber.h" | 24 | #include "PlatformBackends/DummyImageGrabber.h" | ||
25 | #ifdef XCB_FOUND | 25 | #ifdef XCB_FOUND | ||
26 | #include "PlatformBackends/X11ImageGrabber.h" | 26 | #include "PlatformBackends/X11ImageGrabber.h" | ||
27 | #endif | 27 | #endif | ||
28 | #include "PlatformBackends/KWinWaylandImageGrabber.h" | 28 | #include "PlatformBackends/KWinWaylandImageGrabber.h" | ||
29 | 29 | | |||
30 | #include <KGlobalAccel> | ||||
30 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
31 | #include <KMessageBox> | 32 | #include <KMessageBox> | ||
32 | #include <KNotification> | 33 | #include <KNotification> | ||
33 | #include <KRun> | 34 | #include <KRun> | ||
34 | #include <KWindowSystem> | 35 | #include <KWindowSystem> | ||
35 | 36 | | |||
36 | #include <QClipboard> | 37 | #include <QClipboard> | ||
37 | #include <QDebug> | 38 | #include <QDebug> | ||
38 | #include <QDir> | 39 | #include <QDir> | ||
39 | #include <QDrag> | 40 | #include <QDrag> | ||
41 | #include <QKeySequence> | ||||
40 | #include <QMimeData> | 42 | #include <QMimeData> | ||
41 | #include <QProcess> | 43 | #include <QProcess> | ||
42 | #include <QTimer> | 44 | #include <QTimer> | ||
43 | 45 | | |||
44 | SpectacleCore::SpectacleCore(StartMode startMode, ImageGrabber::GrabMode grabMode, QString &saveFileName, | 46 | SpectacleCore::SpectacleCore(StartMode startMode, ImageGrabber::GrabMode grabMode, QString &saveFileName, | ||
45 | qint64 delayMsec, bool notifyOnGrab, QObject *parent) : | 47 | qint64 delayMsec, bool notifyOnGrab, QObject *parent) : | ||
46 | QObject(parent), | 48 | QObject(parent), | ||
47 | mExportManager(ExportManager::instance()), | 49 | mExportManager(ExportManager::instance()), | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 108 | case BackgroundMode: { | |||
107 | int msec = (KWindowSystem::compositingActive() ? 200 : 50) + delayMsec; | 109 | int msec = (KWindowSystem::compositingActive() ? 200 : 50) + delayMsec; | ||
108 | QTimer::singleShot(msec, mImageGrabber, &ImageGrabber::doImageGrab); | 110 | QTimer::singleShot(msec, mImageGrabber, &ImageGrabber::doImageGrab); | ||
109 | } | 111 | } | ||
110 | break; | 112 | break; | ||
111 | case GuiMode: | 113 | case GuiMode: | ||
112 | initGui(); | 114 | initGui(); | ||
113 | break; | 115 | break; | ||
114 | } | 116 | } | ||
117 | | ||||
118 | setUpShortcuts(); | ||||
119 | } | ||||
120 | | ||||
121 | void SpectacleCore::setUpShortcuts() | ||||
122 | { | ||||
123 | SpectacleConfig* config = SpectacleConfig::instance(); | ||||
124 | | ||||
125 | QAction* openAction = config->shortCutActions->action(QStringLiteral("_launch")); | ||||
126 | KGlobalAccel::self()->setGlobalShortcut(openAction, Qt::Key_Print); | ||||
127 | | ||||
128 | QAction* fullScreenAction = config->shortCutActions->action(QStringLiteral("FullScreenScreenShot")); | ||||
129 | KGlobalAccel::self()->setGlobalShortcut(fullScreenAction, Qt::SHIFT + Qt::Key_Print); | ||||
130 | | ||||
131 | QAction* currentScreenAction = config->shortCutActions->action(QStringLiteral("CurrentMonitorScreenShot")); | ||||
132 | KGlobalAccel::self()->setGlobalShortcut(currentScreenAction, Qt::SHIFT + Qt::ALT + Qt::Key_Print); | ||||
133 | | ||||
134 | QAction* activeWindowAction = config->shortCutActions->action(QStringLiteral("ActiveWindowScreenShot")); | ||||
135 | KGlobalAccel::self()->setGlobalShortcut(activeWindowAction, Qt::META + Qt::Key_Print); | ||||
davidedmundson: these lines | |||||
136 | | ||||
137 | QAction* regionAction = config->shortCutActions->action(QStringLiteral("RectangularRegionScreenShot")); | ||||
138 | KGlobalAccel::self()->setGlobalShortcut(regionAction, Qt::META + Qt::SHIFT + Qt::Key_Print); | ||||
115 | } | 139 | } | ||
116 | 140 | | |||
117 | SpectacleCore::~SpectacleCore() | 141 | SpectacleCore::~SpectacleCore() | ||
118 | { | 142 | { | ||
119 | if (mMainWindow) { | 143 | if (mMainWindow) { | ||
120 | delete mMainWindow; | 144 | delete mMainWindow; | ||
121 | } | 145 | } | ||
122 | delete mImageGrabber; | 146 | delete mImageGrabber; | ||
Show All 33 Lines | 178 | if (!(mStartMode == GuiMode)) { | |||
156 | initGui(); | 180 | initGui(); | ||
157 | } else { | 181 | } else { | ||
158 | using Actions = SpectacleConfig::PrintKeyActionRunning; | 182 | using Actions = SpectacleConfig::PrintKeyActionRunning; | ||
159 | switch (SpectacleConfig::instance()->printKeyActionRunning()) { | 183 | switch (SpectacleConfig::instance()->printKeyActionRunning()) { | ||
160 | case Actions::TakeNewScreenshot: | 184 | case Actions::TakeNewScreenshot: | ||
161 | QTimer::singleShot(KWindowSystem::compositingActive() ? 200 : 50, mImageGrabber, &ImageGrabber::doImageGrab); | 185 | QTimer::singleShot(KWindowSystem::compositingActive() ? 200 : 50, mImageGrabber, &ImageGrabber::doImageGrab); | ||
162 | break; | 186 | break; | ||
163 | case Actions::FocusWindow: | 187 | case Actions::FocusWindow: | ||
164 | KWindowSystem::forceActiveWindow(mMainWindow->winId());; | 188 | if (mMainWindow->isMinimized()) { | ||
189 | mMainWindow->setWindowState(mMainWindow->windowState() & ~Qt::WindowMinimized); | ||||
190 | } | ||||
191 | mMainWindow->activateWindow(); | ||||
165 | break; | 192 | break; | ||
166 | case Actions::StartNewInstance: | 193 | case Actions::StartNewInstance: | ||
167 | QProcess newInstance; | 194 | QProcess newInstance; | ||
168 | newInstance.setProgram(QStringLiteral("spectacle")); | 195 | newInstance.setProgram(QStringLiteral("spectacle")); | ||
169 | newInstance.startDetached(); | 196 | newInstance.startDetached(); | ||
170 | break; | 197 | break; | ||
171 | } | 198 | } | ||
172 | } | 199 | } | ||
▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines |
these lines