Changeset View
Standalone View
src/Gui/KSMainWindow.cpp
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Line(s) | 275 | { | |||
---|---|---|---|---|---|
303 | }); | 303 | }); | ||
304 | connect(timer, &QTimer::timeout, this, [=] { | 304 | connect(timer, &QTimer::timeout, this, [=] { | ||
305 | this->hide(); | 305 | this->hide(); | ||
306 | timer->deleteLater(); | 306 | timer->deleteLater(); | ||
307 | unityUpdate({ {QStringLiteral("progress-visible"), false} }); | 307 | unityUpdate({ {QStringLiteral("progress-visible"), false} }); | ||
308 | emit newScreenshotRequest(theCaptureMode, 0, theIncludePointer, theIncludeDecorations); | 308 | emit newScreenshotRequest(theCaptureMode, 0, theIncludePointer, theIncludeDecorations); | ||
309 | }); | 309 | }); | ||
310 | 310 | | |||
311 | connect(mKSWidget, &KSWidget::screenshotCanceled, timer, [=] { | ||||
312 | timer->stop(); | ||||
313 | timer->deleteLater(); | ||||
314 | restoreWindowTitle(); | ||||
315 | unityUpdate({ {QStringLiteral("progress-visible"), false} }); | ||||
316 | }); | ||||
317 | | ||||
318 | | ||||
311 | unityUpdate({ {QStringLiteral("progress-visible"), true}, | 319 | unityUpdate({ {QStringLiteral("progress-visible"), true}, | ||
312 | {QStringLiteral("progress"), 0 } }); | 320 | {QStringLiteral("progress"), 0 } }); | ||
313 | timer->start(); | 321 | timer->start(); | ||
314 | delayAnimation->start(); | 322 | delayAnimation->start(); | ||
315 | } | 323 | } | ||
316 | 324 | | |||
317 | void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap) | 325 | void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap) | ||
318 | { | 326 | { | ||
327 | if (!pixmap.isNull()) { | ||||
319 | mKSWidget->setScreenshotPixmap(pixmap); | 328 | mKSWidget->setScreenshotPixmap(pixmap); | ||
320 | mExportMenu->imageUpdated(); | 329 | mExportMenu->imageUpdated(); | ||
321 | | ||||
322 | setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]")); | 330 | setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]")); | ||
broulik: Can't you just call `restoreWindowTitle()` in any case? | |||||
No because if you saved a screenshot and then take a new one we want to the title to be "Unsaved" and not the filename of the previous saved file. davidre: No because if you saved a screenshot and then take a new one we want to the title to be… | |||||
323 | setWindowModified(true); | 331 | setWindowModified(true); | ||
324 | 332 | } else { | |||
333 | restoreWindowTitle(); | ||||
334 | } | ||||
335 | mKSWidget->setButtonState(KSWidget::State::TakeNewScreenshot); | ||||
325 | show(); | 336 | show(); | ||
326 | activateWindow(); | 337 | activateWindow(); | ||
327 | 338 | /* NOTE windowWidth only produces the right result if it is called after the window is visible. | |||
339 | * Because of this the call is not moved into the if above */ | ||||
340 | if(!pixmap.isNull()) { | ||||
328 | resize(QSize(windowWidth(pixmap), DEFAULT_WINDOW_HEIGHT)); | 341 | resize(QSize(windowWidth(pixmap), DEFAULT_WINDOW_HEIGHT)); | ||
329 | } | 342 | } | ||
What is this supposed to do? Do you mean pixmap.isNull() or pixmap.size().isEmpty()? Looks unrelated to the patch, though. broulik: What is this supposed to do? Do you mean `pixmap.isNull()` or `pixmap.size().isEmpty()`? Looks… | |||||
In this patch I also changed that we go through this function if the region selection is canceled (to reset title and and button). davidre: In this patch I also changed that we go through this function if the region selection is… | |||||
343 | } | ||||
330 | 344 | | |||
331 | void KSMainWindow::showPrintDialog() | 345 | void KSMainWindow::showPrintDialog() | ||
332 | { | 346 | { | ||
333 | QPrinter *printer = new QPrinter(QPrinter::HighResolution); | 347 | QPrinter *printer = new QPrinter(QPrinter::HighResolution); | ||
334 | QPrintDialog printDialog(printer, this); | 348 | QPrintDialog printDialog(printer, this); | ||
335 | if (printDialog.exec() == QDialog::Accepted) { | 349 | if (printDialog.exec() == QDialog::Accepted) { | ||
336 | ExportManager::instance()->doPrint(printer); | 350 | ExportManager::instance()->doPrint(printer); | ||
337 | return; | 351 | return; | ||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Line(s) | 498 | { | |||
485 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::SaveAs); | 499 | SpectacleConfig::instance()->setLastUsedSaveMode(SaveMode::SaveAs); | ||
486 | setDefaultSaveAction(); | 500 | setDefaultSaveAction(); | ||
487 | 501 | | |||
488 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | 502 | const bool quitChecked = SpectacleConfig::instance()->quitAfterSaveOrCopyChecked(); | ||
489 | if (ExportManager::instance()->doSaveAs(this, /* notify */ quitChecked) && quitChecked) { | 503 | if (ExportManager::instance()->doSaveAs(this, /* notify */ quitChecked) && quitChecked) { | ||
490 | quit(QuitBehavior::QuitExternally); | 504 | quit(QuitBehavior::QuitExternally); | ||
491 | } | 505 | } | ||
492 | } | 506 | } | ||
507 | | ||||
508 | void KSMainWindow::restoreWindowTitle() | ||||
509 | { | ||||
510 | if (isWindowModified()) { | ||||
Can you perhaps move the setWindowModified() handling into this method, too? broulik: Can you perhaps move the `setWindowModified()` handling into this method, too? | |||||
Do you think of making this a general method to handle windowModified and title setting? Because otherwise I see no need because windowModified doesn't change when we restore the title. davidre: Do you think of making this a general method to handle windowModified and title setting? | |||||
511 | setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]")); | ||||
512 | } else { | ||||
513 | setWindowTitle(SpectacleConfig::instance()->lastSaveFile().fileName()); | ||||
514 | } | ||||
515 | } |
Can't you just call restoreWindowTitle() in any case?