Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSMainWindow.cpp
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | * | 18 | * | ||
19 | * SPDX-License-Identifier: LGPL-2.0-or-later | 19 | * SPDX-License-Identifier: LGPL-2.0-or-later | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "KSMainWindow.h" | 22 | #include "KSMainWindow.h" | ||
23 | | ||||
23 | #include "Config.h" | 24 | #include "Config.h" | ||
25 | #include "Gui/TimerProgress.h" | ||||
24 | #include "SettingsDialog/SettingsDialog.h" | 26 | #include "SettingsDialog/SettingsDialog.h" | ||
25 | 27 | | |||
26 | #include <QApplication> | 28 | #include <QApplication> | ||
27 | #include <QClipboard> | 29 | #include <QClipboard> | ||
28 | #include <QDesktopServices> | 30 | #include <QDesktopServices> | ||
29 | #include <QJsonArray> | 31 | #include <QJsonArray> | ||
30 | #include <QPrintDialog> | 32 | #include <QPrintDialog> | ||
31 | #include <QPushButton> | 33 | #include <QPushButton> | ||
▲ Show 20 Lines • Show All 232 Lines • ▼ Show 20 Line(s) | 260 | { | |||
264 | guiConfig.writeEntry("window-position", pos()); | 266 | guiConfig.writeEntry("window-position", pos()); | ||
265 | guiConfig.sync(); | 267 | guiConfig.sync(); | ||
266 | } | 268 | } | ||
267 | 269 | | |||
268 | // slots | 270 | // slots | ||
269 | 271 | | |||
270 | void KSMainWindow::captureScreenshot(Spectacle::CaptureMode theCaptureMode, int theTimeout, bool theIncludePointer, bool theIncludeDecorations) | 272 | void KSMainWindow::captureScreenshot(Spectacle::CaptureMode theCaptureMode, int theTimeout, bool theIncludePointer, bool theIncludeDecorations) | ||
271 | { | 273 | { | ||
272 | hide(); | 274 | showMinimized(); | ||
273 | mMessageWidget->hide(); | 275 | mMessageWidget->hide(); | ||
276 | QTimer* timer = new QTimer(this); | ||||
broulik: While this `QTimer` is parented to the `KSMainWindow` unless it gets deleted you pile up timers… | |||||
277 | timer->setSingleShot(true); | ||||
278 | timer->setInterval(theTimeout); | ||||
279 | TimerProgress::fromTimer(timer, 50); | ||||
280 | connect(timer, &QTimer::timeout, this, &QWidget::hide); | ||||
281 | timer->start(); | ||||
274 | emit newScreenshotRequest(theCaptureMode, theTimeout, theIncludePointer, theIncludeDecorations); | 282 | emit newScreenshotRequest(theCaptureMode, theTimeout, theIncludePointer, theIncludeDecorations); | ||
275 | } | 283 | } | ||
276 | 284 | | |||
277 | void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap) | 285 | void KSMainWindow::setScreenshotAndShow(const QPixmap &pixmap) | ||
278 | { | 286 | { | ||
279 | mKSWidget->setScreenshotPixmap(pixmap); | 287 | mKSWidget->setScreenshotPixmap(pixmap); | ||
280 | mExportMenu->imageUpdated(); | 288 | mExportMenu->imageUpdated(); | ||
I think deleting an object from within a slot is dangerous, probably should be using timer->deleteLater() broulik: I think deleting an object from within a slot is dangerous, probably should be using `timer… | |||||
281 | 289 | | |||
A delay is needed to give the task bar time to remove the spectacle entry from view. On my setup 50 ms was enough but this is probably hardware dependent. Maybe we should even keep the old 200 ms delay. Imo: felixernst: A delay is needed to give the task bar time to remove the spectacle entry from view. On my… | |||||
282 | setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]")); | 290 | setWindowTitle(i18nc("@title:window Unsaved Screenshot", "Unsaved[*]")); | ||
283 | setWindowModified(true); | 291 | setWindowModified(true); | ||
284 | 292 | | |||
285 | show(); | 293 | show(); | ||
294 | activateWindow(); | ||||
286 | 295 | | |||
287 | resize(QSize(windowWidth(pixmap), DEFAULT_WINDOW_HEIGHT)); | 296 | resize(QSize(windowWidth(pixmap), DEFAULT_WINDOW_HEIGHT)); | ||
288 | } | 297 | } | ||
289 | 298 | | |||
290 | void KSMainWindow::showPrintDialog() | 299 | void KSMainWindow::showPrintDialog() | ||
291 | { | 300 | { | ||
292 | QPrinter *printer = new QPrinter(QPrinter::HighResolution); | 301 | QPrinter *printer = new QPrinter(QPrinter::HighResolution); | ||
293 | QPrintDialog printDialog(printer, this); | 302 | QPrintDialog printDialog(printer, this); | ||
▲ Show 20 Lines • Show All 152 Lines • Show Last 20 Lines |
While this QTimer is parented to the KSMainWindow unless it gets deleted you pile up timers, if user takes a couple of screenshots in a row.