Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSMainWindow.cpp
Show First 20 Lines • Show All 321 Lines • ▼ Show 20 Line(s) | 321 | if (!exportManager->isFileExists(location)) { | |||
---|---|---|---|---|---|
322 | location = cfgManager->lastSaveAsLocation(); | 322 | location = cfgManager->lastSaveAsLocation(); | ||
323 | } | 323 | } | ||
324 | break; | 324 | break; | ||
325 | } | 325 | } | ||
326 | 326 | | |||
327 | KIO::highlightInFileManager({location}); | 327 | KIO::highlightInFileManager({location}); | ||
328 | } | 328 | } | ||
329 | 329 | | |||
330 | void KSMainWindow::quit(const QuitBehavior quitBehavior) | | |||
331 | { | | |||
332 | qApp->setQuitOnLastWindowClosed(false); | | |||
333 | hide(); | | |||
334 | | ||||
335 | if (quitBehavior == QuitBehavior::QuitImmediately) { | | |||
336 | // Allow some time for clipboard content to transfer | | |||
337 | // TODO: Find better solution | | |||
338 | QTimer::singleShot(250, qApp, &QApplication::quit); | | |||
339 | } | | |||
340 | // TODO for else case: | | |||
341 | // Currently it is expected that you emit forceNotify, and finally quit | | |||
342 | // via a callback through KNotification::action1Activated. However, that | | |||
343 | // is not working quite right, see Bug #389694 which needs fixing. | | |||
344 | } | | |||
345 | | ||||
346 | void KSMainWindow::showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, const MessageDuration messageDuration) | 330 | void KSMainWindow::showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, const MessageDuration messageDuration) | ||
347 | { | 331 | { | ||
348 | mMessageWidget->setText(message); | 332 | mMessageWidget->setText(message); | ||
349 | mMessageWidget->setMessageType(messageType); | 333 | mMessageWidget->setMessageType(messageType); | ||
350 | 334 | | |||
351 | switch (messageType) { | 335 | switch (messageType) { | ||
352 | case KMessageWidget::Error: | 336 | case KMessageWidget::Error: | ||
353 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | 337 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | ||
Show All 30 Lines | 367 | showInlineMessage(i18n("The shared image link (<a href=\"%1\">%1</a>) has been copied to the clipboard.", message), | |||
384 | KMessageWidget::Positive, MessageDuration::Persistent); | 368 | KMessageWidget::Positive, MessageDuration::Persistent); | ||
385 | QApplication::clipboard()->setText(message); | 369 | QApplication::clipboard()->setText(message); | ||
386 | } | 370 | } | ||
387 | } | 371 | } | ||
388 | } | 372 | } | ||
389 | 373 | | |||
390 | void KSMainWindow::sendToClipboard() | 374 | void KSMainWindow::sendToClipboard() | ||
391 | { | 375 | { | ||
392 | bool notify = false; | 376 | ExportManager::instance()->doCopyToClipboard(); | ||
393 | ExportManager::instance()->doCopyToClipboard(notify); | 377 | if (!SpectacleConfig::instance()->quitAfterSaveOrCopyChecked()) { | ||
394 | 378 | showInlineMessage(i18n("The screenshot has been copied to the clipboard."), | |||
395 | SpectacleConfig::instance()->quitAfterSaveOrCopyChecked() | | |||
396 | ? quit() | | |||
397 | : showInlineMessage(i18n("The screenshot has been copied to the clipboard."), | | |||
398 | KMessageWidget::Information); | 379 | KMessageWidget::Information); | ||
399 | } | 380 | } | ||
381 | } | ||||
400 | 382 | | |||
401 | void KSMainWindow::showPreferencesDialog() | 383 | void KSMainWindow::showPreferencesDialog() | ||
402 | { | 384 | { | ||
403 | SettingsDialog prefDialog(this); | 385 | SettingsDialog prefDialog(this); | ||
404 | prefDialog.exec(); | 386 | prefDialog.exec(); | ||
405 | } | 387 | } | ||
406 | 388 | | |||
407 | void KSMainWindow::setScreenshotWindowTitle(const QUrl &location) | 389 | void KSMainWindow::setScreenshotWindowTitle(const QUrl &location) | ||
408 | { | 390 | { | ||
409 | setWindowTitle(location.fileName()); | 391 | setWindowTitle(location.fileName()); | ||
410 | setWindowModified(false); | 392 | setWindowModified(false); | ||
411 | } | 393 | } | ||
412 | 394 | | |||
413 | void KSMainWindow::save() | 395 | void KSMainWindow::save() | ||
414 | { | 396 | { | ||
415 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::Save); | 397 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::Save); | ||
416 | setDefaultSaveAction(); | 398 | setDefaultSaveAction(); | ||
417 | 399 | ExportManager::instance()->doSave(QUrl()); | |||
418 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | | |||
419 | ExportManager::instance()->doSave(QUrl(), /* notify */ quitChecked); | | |||
420 | if (quitChecked) { | | |||
421 | quit(QuitBehavior::QuitExternally); | | |||
422 | } | | |||
423 | } | 400 | } | ||
424 | 401 | | |||
425 | void KSMainWindow::saveAs() | 402 | void KSMainWindow::saveAs() | ||
426 | { | 403 | { | ||
427 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::SaveAs); | 404 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::SaveAs); | ||
428 | setDefaultSaveAction(); | 405 | setDefaultSaveAction(); | ||
429 | 406 | ExportManager::instance()->doSaveAs(this); | |||
430 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | | |||
431 | if (ExportManager::instance()->doSaveAs(this, /* notify */ quitChecked) && quitChecked) { | | |||
432 | quit(QuitBehavior::QuitExternally); | | |||
433 | } | | |||
434 | } | 407 | } |