Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show All 16 Lines | |||||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "SpectacleCore.h" | 20 | #include "SpectacleCore.h" | ||
21 | #include "spectacle_core_debug.h" | 21 | #include "spectacle_core_debug.h" | ||
22 | 22 | | |||
23 | #include "Config.h" | 23 | #include "Config.h" | ||
24 | 24 | | |||
25 | #include <KGlobalAccel> | ||||
25 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
26 | #include <KMessageBox> | 27 | #include <KMessageBox> | ||
27 | #include <KNotification> | 28 | #include <KNotification> | ||
28 | #include <KRun> | 29 | #include <KRun> | ||
29 | #include <KWindowSystem> | 30 | #include <KWindowSystem> | ||
30 | 31 | | |||
31 | #include <QApplication> | 32 | #include <QApplication> | ||
32 | #include <QClipboard> | 33 | #include <QClipboard> | ||
33 | #include <QDebug> | 34 | #include <QDebug> | ||
34 | #include <QDir> | 35 | #include <QDir> | ||
35 | #include <QDrag> | 36 | #include <QDrag> | ||
37 | #include <QKeySequence> | ||||
36 | #include <QMimeData> | 38 | #include <QMimeData> | ||
37 | #include <QProcess> | 39 | #include <QProcess> | ||
38 | #include <QTimer> | 40 | #include <QTimer> | ||
39 | 41 | | |||
40 | SpectacleCore::SpectacleCore(StartMode theStartMode, | 42 | SpectacleCore::SpectacleCore(StartMode theStartMode, | ||
41 | Spectacle::CaptureMode theCaptureMode, | 43 | Spectacle::CaptureMode theCaptureMode, | ||
42 | QString &theSaveFileName, | 44 | QString &theSaveFileName, | ||
43 | qint64 theDelayMsec, | 45 | qint64 theDelayMsec, | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 101 | QTimer::singleShot(lMsec, [ this, lCaptureMode, lShutterMode, lIncludePointer, lIncludeDecorations ]() { | |||
100 | mPlatform->doGrab(lShutterMode, lCaptureMode, lIncludePointer, lIncludeDecorations); | 102 | mPlatform->doGrab(lShutterMode, lCaptureMode, lIncludePointer, lIncludeDecorations); | ||
101 | }); | 103 | }); | ||
102 | } | 104 | } | ||
103 | break; | 105 | break; | ||
104 | case StartMode::Gui: | 106 | case StartMode::Gui: | ||
105 | initGui(lGuiConfig.readEntry("includePointer", true), lGuiConfig.readEntry("includeDecorations", true)); | 107 | initGui(lGuiConfig.readEntry("includePointer", true), lGuiConfig.readEntry("includeDecorations", true)); | ||
106 | break; | 108 | break; | ||
107 | } | 109 | } | ||
110 | setUpShortcuts(); | ||||
111 | } | ||||
112 | | ||||
113 | void SpectacleCore::setUpShortcuts() | ||||
114 | { | ||||
115 | SpectacleConfig* config = SpectacleConfig::instance(); | ||||
116 | | ||||
117 | QAction* openAction = config->shortCutActions->action(QStringLiteral("_launch")); | ||||
118 | KGlobalAccel::self()->setGlobalShortcut(openAction, Qt::Key_Print); | ||||
119 | | ||||
120 | QAction* fullScreenAction = config->shortCutActions->action(QStringLiteral("FullScreenScreenShot")); | ||||
121 | KGlobalAccel::self()->setGlobalShortcut(fullScreenAction, Qt::SHIFT + Qt::Key_Print); | ||||
122 | | ||||
123 | QAction* activeWindowAction = config->shortCutActions->action(QStringLiteral("ActiveWindowScreenShot")); | ||||
124 | KGlobalAccel::self()->setGlobalShortcut(activeWindowAction, Qt::META + Qt::Key_Print); | ||||
125 | | ||||
126 | QAction* regionAction = config->shortCutActions->action(QStringLiteral("RectangularRegionScreenShot")); | ||||
127 | KGlobalAccel::self()->setGlobalShortcut(regionAction, Qt::META + Qt::SHIFT + Qt::Key_Print); | ||||
108 | } | 128 | } | ||
davidedmundson: these lines | |||||
109 | 129 | | |||
110 | QString SpectacleCore::filename() const | 130 | QString SpectacleCore::filename() const | ||
111 | { | 131 | { | ||
112 | return mFileNameString; | 132 | return mFileNameString; | ||
113 | } | 133 | } | ||
114 | 134 | | |||
115 | void SpectacleCore::setFilename(const QString &filename) | 135 | void SpectacleCore::setFilename(const QString &filename) | ||
116 | { | 136 | { | ||
Show All 22 Lines | 158 | case Actions::TakeNewScreenshot: { | |||
139 | auto lShutterMode = mPlatform->supportedShutterModes().testFlag(Platform::ShutterMode::Immediate) ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 159 | auto lShutterMode = mPlatform->supportedShutterModes().testFlag(Platform::ShutterMode::Immediate) ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
140 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | 160 | auto lGrabMode = toPlatformGrabMode(ExportManager::instance()->captureMode()); | ||
141 | QTimer::singleShot(KWindowSystem::compositingActive() ? 200 : 50, [this, lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations]() { | 161 | QTimer::singleShot(KWindowSystem::compositingActive() ? 200 : 50, [this, lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations]() { | ||
142 | mPlatform->doGrab(lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations); | 162 | mPlatform->doGrab(lShutterMode, lGrabMode, lIncludePointer, lIncludeDecorations); | ||
143 | }); | 163 | }); | ||
144 | break; | 164 | break; | ||
145 | } | 165 | } | ||
146 | case Actions::FocusWindow: | 166 | case Actions::FocusWindow: | ||
147 | KWindowSystem::forceActiveWindow(mMainWindow->winId()); | 167 | if (mMainWindow->isMinimized()) { | ||
168 | mMainWindow->setWindowState(mMainWindow->windowState() & ~Qt::WindowMinimized); | ||||
169 | } | ||||
170 | mMainWindow->activateWindow(); | ||||
148 | break; | 171 | break; | ||
149 | case Actions::StartNewInstance: | 172 | case Actions::StartNewInstance: | ||
150 | QProcess newInstance; | 173 | QProcess newInstance; | ||
151 | newInstance.setProgram(QStringLiteral("spectacle")); | 174 | newInstance.setProgram(QStringLiteral("spectacle")); | ||
152 | newInstance.startDetached(); | 175 | newInstance.startDetached(); | ||
153 | break; | 176 | break; | ||
154 | } | 177 | } | ||
155 | } | 178 | } | ||
▲ Show 20 Lines • Show All 223 Lines • Show Last 20 Lines |
these lines