Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSMainWindow.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 115 | { | |||
---|---|---|---|---|---|
117 | KConfigGroup guiConfig(config, "GuiConfig"); | 117 | KConfigGroup guiConfig(config, "GuiConfig"); | ||
118 | 118 | | |||
119 | // window properties | 119 | // window properties | ||
120 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | 120 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); | ||
121 | 121 | | |||
122 | QPoint location = guiConfig.readEntry("window-position", QPoint(50, 50)); | 122 | QPoint location = guiConfig.readEntry("window-position", QPoint(50, 50)); | ||
123 | move(location); | 123 | move(location); | ||
124 | 124 | | |||
125 | // change window title on save | 125 | // change window title on save and on autosave | ||
126 | 126 | | |||
127 | connect(ExportManager::instance(), &ExportManager::imageSaved, this, &KSMainWindow::imageSaved); | 127 | connect(ExportManager::instance(), &ExportManager::imageSaved, this, &KSMainWindow::imageSaved); | ||
128 | connect(ExportManager::instance(), &ExportManager::imageAutoSaved, this, &KSMainWindow::showSavedAndCopiedFeedback); | ||||
aprcela: already connected signal | |||||
128 | 129 | | |||
129 | // the KSGWidget | 130 | // the KSGWidget | ||
130 | 131 | | |||
131 | connect(mKSWidget, &KSWidget::newScreenshotRequest, this, &KSMainWindow::captureScreenshot); | 132 | connect(mKSWidget, &KSWidget::newScreenshotRequest, this, &KSMainWindow::captureScreenshot); | ||
132 | connect(mKSWidget, &KSWidget::dragInitiated, this, &KSMainWindow::dragAndDropRequest); | 133 | connect(mKSWidget, &KSWidget::dragInitiated, this, &KSMainWindow::dragAndDropRequest); | ||
133 | 134 | | |||
134 | // the Button Bar | 135 | // the Button Bar | ||
135 | 136 | | |||
▲ Show 20 Lines • Show All 337 Lines • ▼ Show 20 Line(s) | 472 | { | |||
473 | prefDialog.exec(); | 474 | prefDialog.exec(); | ||
474 | } | 475 | } | ||
475 | 476 | | |||
476 | void KSMainWindow::imageSaved(const QUrl &location) | 477 | void KSMainWindow::imageSaved(const QUrl &location) | ||
477 | { | 478 | { | ||
478 | setWindowTitle(location.fileName()); | 479 | setWindowTitle(location.fileName()); | ||
479 | setWindowModified(false); | 480 | setWindowModified(false); | ||
480 | QAction* openContaining = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("Open Containing Folder"), mMessageWidget); | 481 | QAction* openContaining = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("Open Containing Folder"), mMessageWidget); | ||
481 | connect(openContaining, &QAction::triggered, [=] { KIO::highlightInFileManager({location});}); | 482 | connect(openContaining, &QAction::triggered, [=] { KIO::highlightInFileManager({location});}); | ||
davidre: We can also move and unify the connect calls into `init`. | |||||
Took me a while to understand this, as I never worked with lambdas before.. What about the variable location? aprcela: Took me a while to understand this, as I never worked with lambdas before..
What about the… | |||||
482 | showInlineMessage(i18n("The screenshot was saved as <a href=\"%1\">%2</a>", | 483 | showInlineMessage(i18n("The screenshot was saved as <a href=\"%1\">%2</a>", | ||
davidre: Sorry, I totally missed that but good idea to use `lastSaveFile()`. | |||||
483 | location.toString(), location.fileName()), KMessageWidget::Positive, | 484 | location.toString(), location.fileName()), KMessageWidget::Positive, | ||
484 | MessageDuration::AutoHide, {openContaining}); | 485 | MessageDuration::AutoHide, {openContaining}); | ||
485 | } | 486 | } | ||
486 | 487 | | |||
488 | void KSMainWindow::showSavedAndCopiedFeedback(const QUrl &location) | ||||
489 | { | ||||
490 | setWindowTitle(location.fileName()); | ||||
491 | setWindowModified(false); | ||||
492 | QAction* openContaining = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("Open Containing Folder"), mMessageWidget); | ||||
We can make this action a member variable to reduce code duplication and use it here and in imageSaved. davidre: We can make this action a member variable to reduce code duplication and use it here and in… | |||||
aprcela: Changed.
Gets set in `init()`
Name: `mOpenContaining` | |||||
493 | connect(openContaining, &QAction::triggered, [=] { KIO::highlightInFileManager({location});}); | ||||
494 | showInlineMessage(i18n("The screenshot was copied to the clipboard and saved as <a href=\"%1\">%2</a>", | ||||
495 | location.toString(), location.fileName()), KMessageWidget::Positive, | ||||
496 | MessageDuration::AutoHide, {openContaining}); | ||||
497 | } | ||||
498 | | ||||
487 | void KSMainWindow::save() | 499 | void KSMainWindow::save() | ||
488 | { | 500 | { | ||
489 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::Save); | 501 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::Save); | ||
490 | setDefaultSaveAction(); | 502 | setDefaultSaveAction(); | ||
491 | 503 | | |||
492 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | 504 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | ||
493 | ExportManager::instance()->doSave(QUrl(), /* notify */ quitChecked); | 505 | ExportManager::instance()->doSave(QUrl(), /* notify */ quitChecked); | ||
494 | if (quitChecked) { | 506 | if (quitChecked) { | ||
Show All 23 Lines |
already connected signal