Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSMainWindow.cpp
| Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 111 | { | |||
|---|---|---|---|---|---|
| 115 | // window properties | 115 | // window properties | ||
| 116 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | 116 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | ||
| 117 | 117 | | |||
| 118 | QPoint location = guiConfig.readEntry("window-position", QPoint(50, 50)); | 118 | QPoint location = guiConfig.readEntry("window-position", QPoint(50, 50)); | ||
| 119 | move(location); | 119 | move(location); | ||
| 120 | 120 | | |||
| 121 | // change window title on save | 121 | // change window title on save | ||
| 122 | 122 | | |||
| 123 | connect(ExportManager::instance(), &ExportManager::imageSaved, this, &KSMainWindow::setScreenshotWindowTitle); | 123 | connect(ExportManager::instance(), &ExportManager::imageSaved, this, &KSMainWindow::imageSaved); | ||
| 124 | 124 | | |||
| 125 | // the KSGWidget | 125 | // the KSGWidget | ||
| 126 | 126 | | |||
| 127 | connect(mKSWidget, &KSWidget::newScreenshotRequest, this, &KSMainWindow::captureScreenshot); | 127 | connect(mKSWidget, &KSWidget::newScreenshotRequest, this, &KSMainWindow::captureScreenshot); | ||
| 128 | connect(mKSWidget, &KSWidget::dragInitiated, this, &KSMainWindow::dragAndDropRequest); | 128 | connect(mKSWidget, &KSWidget::dragInitiated, this, &KSMainWindow::dragAndDropRequest); | ||
| 129 | 129 | | |||
| 130 | // the Button Bar | 130 | // the Button Bar | ||
| 131 | 131 | | |||
| ▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Line(s) | 331 | if (quitBehavior == QuitBehavior::QuitImmediately) { | |||
| 334 | QTimer::singleShot(250, qApp, &QApplication::quit); | 334 | QTimer::singleShot(250, qApp, &QApplication::quit); | ||
| 335 | } | 335 | } | ||
| 336 | // TODO for else case: | 336 | // TODO for else case: | ||
| 337 | // Currently it is expected that you emit forceNotify, and finally quit | 337 | // Currently it is expected that you emit forceNotify, and finally quit | ||
| 338 | // via a callback through KNotification::action1Activated. However, that | 338 | // via a callback through KNotification::action1Activated. However, that | ||
| 339 | // is not working quite right, see Bug #389694 which needs fixing. | 339 | // is not working quite right, see Bug #389694 which needs fixing. | ||
| 340 | } | 340 | } | ||
| 341 | 341 | | |||
| 342 | void KSMainWindow::showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, const MessageDuration messageDuration) | 342 | void KSMainWindow::showInlineMessage(const QString& message, const KMessageWidget::MessageType messageType, | ||
| 343 | const MessageDuration messageDuration, const QList<QAction*>& actions) | ||||
| 343 | { | 344 | { | ||
| 345 | for (QAction* action: mMessageWidget->actions()) { | ||||
| 346 | mMessageWidget->removeAction(action); | ||||
| 347 | } | ||||
| 348 | for (QAction* action : actions) { | ||||
| 349 | mMessageWidget->addAction(action); | ||||
| 350 | } | ||||
| 344 | mMessageWidget->setText(message); | 351 | mMessageWidget->setText(message); | ||
| 345 | mMessageWidget->setMessageType(messageType); | 352 | mMessageWidget->setMessageType(messageType); | ||
| 346 | 353 | | |||
| 347 | switch (messageType) { | 354 | switch (messageType) { | ||
| 348 | case KMessageWidget::Error: | 355 | case KMessageWidget::Error: | ||
| 349 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | 356 | mMessageWidget->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); | ||
| 350 | break; | 357 | break; | ||
| 351 | case KMessageWidget::Warning: | 358 | case KMessageWidget::Warning: | ||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
| 393 | } | 400 | } | ||
| 394 | 401 | | |||
| 395 | void KSMainWindow::showPreferencesDialog() | 402 | void KSMainWindow::showPreferencesDialog() | ||
| 396 | { | 403 | { | ||
| 397 | SettingsDialog prefDialog(this); | 404 | SettingsDialog prefDialog(this); | ||
| 398 | prefDialog.exec(); | 405 | prefDialog.exec(); | ||
| 399 | } | 406 | } | ||
| 400 | 407 | | |||
| 401 | void KSMainWindow::setScreenshotWindowTitle(const QUrl &location) | 408 | void KSMainWindow::imageSaved(const QUrl &location) | ||
| 402 | { | 409 | { | ||
| 403 | setWindowTitle(location.fileName()); | 410 | setWindowTitle(location.fileName()); | ||
| 404 | setWindowModified(false); | 411 | setWindowModified(false); | ||
| 412 | QAction* openContaining = new QAction(i18n("Open Containing Folder"), mMessageWidget); | ||||
| 413 | connect(openContaining, &QAction::triggered, [=] { KIO::highlightInFileManager({location});}); | ||||
| 414 | showInlineMessage(i18n("The screenshot was saved as <a href=\"%1\">%2</a>", | ||||
| 415 | location.toLocalFile(), location.fileName()), KMessageWidget::Positive, | ||||
| 416 | MessageDuration::AutoHide, {openContaining}); | ||||
| 405 | } | 417 | } | ||
| 406 | 418 | | |||
| 407 | void KSMainWindow::save() | 419 | void KSMainWindow::save() | ||
| 408 | { | 420 | { | ||
| 409 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::Save); | 421 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::Save); | ||
| 410 | setDefaultSaveAction(); | 422 | setDefaultSaveAction(); | ||
| 411 | 423 | | |||
| 412 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | 424 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | ||
| Show All 16 Lines | |||||