Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSMainWindow.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | #include <KLocalizedString> | 49 | #include <KLocalizedString> | ||
50 | #include <KStandardAction> | 50 | #include <KStandardAction> | ||
51 | #include <KWindowSystem> | 51 | #include <KWindowSystem> | ||
52 | 52 | | |||
53 | static const int DEFAULT_WINDOW_HEIGHT = 420; | 53 | static const int DEFAULT_WINDOW_HEIGHT = 420; | ||
54 | static const int DEFAULT_WINDOW_WIDTH = 840; | 54 | static const int DEFAULT_WINDOW_WIDTH = 840; | ||
55 | static const int MAXIMUM_WINDOW_WIDTH = 1000; | 55 | static const int MAXIMUM_WINDOW_WIDTH = 1000; | ||
56 | 56 | | |||
57 | KSMainWindow::KSMainWindow(const Platform::GrabModes &theGrabModes, const Platform::ShutterModes &theShutterModes, QWidget *parent) : | 57 | KSMainWindow::KSMainWindow(const CaptureModes &theCaptureModes, const ShutterModes &theShutterModes, QWidget *parent) : | ||
58 | QDialog(parent), | 58 | QDialog(parent), | ||
59 | mKSWidget(new KSWidget(theGrabModes, this)), | 59 | mKSWidget(new KSWidget(theCaptureModes, this)), | ||
60 | mDivider(new QFrame(this)), | 60 | mDivider(new QFrame(this)), | ||
61 | mDialogButtonBox(new QDialogButtonBox(this)), | 61 | mDialogButtonBox(new QDialogButtonBox(this)), | ||
62 | mConfigureButton(new QToolButton(this)), | 62 | mConfigureButton(new QToolButton(this)), | ||
63 | mToolsButton(new QPushButton(this)), | 63 | mToolsButton(new QPushButton(this)), | ||
64 | mSendToButton(new QPushButton(this)), | 64 | mSendToButton(new QPushButton(this)), | ||
65 | mClipboardButton(new QToolButton(this)), | 65 | mClipboardButton(new QToolButton(this)), | ||
66 | mSaveButton(new QToolButton(this)), | 66 | mSaveButton(new QToolButton(this)), | ||
67 | mSaveMenu(new QMenu(this)), | 67 | mSaveMenu(new QMenu(this)), | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | 115 | { | |||
203 | layout->addWidget(mDialogButtonBox); | 203 | layout->addWidget(mDialogButtonBox); | ||
204 | mMessageWidget->hide(); | 204 | mMessageWidget->hide(); | ||
205 | 205 | | |||
206 | // populate our send-to actions | 206 | // populate our send-to actions | ||
207 | mSendToButton->setMenu(mExportMenu); | 207 | mSendToButton->setMenu(mExportMenu); | ||
208 | connect(mExportMenu, &ExportMenu::imageShared, this, &KSMainWindow::showImageSharedFeedback); | 208 | connect(mExportMenu, &ExportMenu::imageShared, this, &KSMainWindow::showImageSharedFeedback); | ||
209 | 209 | | |||
210 | // lock down the onClick mode depending on available shutter modes | 210 | // lock down the onClick mode depending on available shutter modes | ||
211 | if (!mShutterModes.testFlag(Platform::ShutterMode::OnClick)) { | 211 | if (!mShutterModes.testFlag(ShutterMode::OnClick)) { | ||
212 | mKSWidget->lockOnClickDisabled(); | 212 | mKSWidget->lockOnClickDisabled(); | ||
213 | } else if (!mShutterModes.testFlag(Platform::ShutterMode::Immediate)) { | 213 | } else if (!mShutterModes.testFlag(ShutterMode::Immediate)) { | ||
214 | mKSWidget->lockOnClickEnabled(); | 214 | mKSWidget->lockOnClickEnabled(); | ||
215 | } | 215 | } | ||
216 | resize(QSize(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT).expandedTo(minimumSize())); | 216 | resize(QSize(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT).expandedTo(minimumSize())); | ||
217 | 217 | | |||
218 | // Allow Ctrl+Q to quit the app | 218 | // Allow Ctrl+Q to quit the app | ||
219 | QAction *actionQuit = KStandardAction::quit(qApp, &QApplication::quit, this); | 219 | QAction *actionQuit = KStandardAction::quit(qApp, &QApplication::quit, this); | ||
220 | actionQuit->setShortcut(QKeySequence::Quit); | 220 | actionQuit->setShortcut(QKeySequence::Quit); | ||
221 | addAction(actionQuit); | 221 | addAction(actionQuit); | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 263 | { | |||
266 | KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | 266 | KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("spectaclerc")); | ||
267 | KConfigGroup guiConfig(config, "GuiConfig"); | 267 | KConfigGroup guiConfig(config, "GuiConfig"); | ||
268 | 268 | | |||
269 | guiConfig.writeEntry("window-position", pos()); | 269 | guiConfig.writeEntry("window-position", pos()); | ||
270 | guiConfig.sync(); | 270 | guiConfig.sync(); | ||
271 | } | 271 | } | ||
272 | 272 | | |||
273 | // slots | 273 | // slots | ||
274 | void KSMainWindow::captureScreenshot(Spectacle::CaptureMode theCaptureMode, int theTimeout, bool theIncludePointer, bool theIncludeDecorations) | 274 | void KSMainWindow::captureScreenshot(CaptureMode theCaptureMode, int theTimeout, bool theIncludePointer, bool theIncludeDecorations) | ||
275 | { | 275 | { | ||
276 | if (theTimeout < 0) { // OnClick is checked (always the case on Wayland) | 276 | if (theTimeout < 0) { // OnClick is checked (always the case on Wayland) | ||
277 | hide(); | 277 | hide(); | ||
278 | emit newScreenshotRequest(theCaptureMode, theTimeout, theIncludePointer, theIncludeDecorations); | 278 | emit newScreenshotRequest(theCaptureMode, theTimeout, theIncludePointer, theIncludeDecorations); | ||
279 | return; | 279 | return; | ||
280 | } | 280 | } | ||
281 | 281 | | |||
282 | showMinimized(); | 282 | showMinimized(); | ||
Show All 36 Lines | |||||
319 | 319 | | |||
320 | 320 | | |||
321 | unityUpdate({ {QStringLiteral("progress-visible"), true}, | 321 | unityUpdate({ {QStringLiteral("progress-visible"), true}, | ||
322 | {QStringLiteral("progress"), 0 } }); | 322 | {QStringLiteral("progress"), 0 } }); | ||
323 | timer->start(); | 323 | timer->start(); | ||
324 | delayAnimation->start(); | 324 | delayAnimation->start(); | ||
325 | } | 325 | } | ||
326 | 326 | | |||
327 | void KSMainWindow::setCaptureModes(const CaptureModes &theCaptureModes) | ||||
328 | { | ||||
329 | mKSWidget->initComboBox(theCaptureModes); | ||||
330 | } | ||||
331 | | ||||
332 | void KSMainWindow::setShutterModes(const ShutterModes &theShutterModes) | ||||
333 | { | ||||
334 | mShutterModes = theShutterModes; | ||||
335 | if (!mShutterModes.testFlag(ShutterMode::OnClick)) { | ||||
336 | mKSWidget->lockOnClickDisabled(); | ||||
337 | } else if (!mShutterModes.testFlag(ShutterMode::Immediate)) { | ||||
338 | mKSWidget->lockOnClickEnabled(); | ||||
339 | } | ||||
340 | } | ||||
341 | | ||||
327 | void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap) | 342 | void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap) | ||
328 | { | 343 | { | ||
329 | if (!pixmap.isNull()) { | 344 | if (!pixmap.isNull()) { | ||
330 | mKSWidget->setScreenshotPixmap(pixmap); | 345 | mKSWidget->setScreenshotPixmap(pixmap); | ||
331 | mExportMenu->imageUpdated(); | 346 | mExportMenu->imageUpdated(); | ||
332 | setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]")); | 347 | setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]")); | ||
333 | setWindowModified(true); | 348 | setWindowModified(true); | ||
334 | } else { | 349 | } else { | ||
▲ Show 20 Lines • Show All 183 Lines • Show Last 20 Lines |