| 467 | } |
| 468 | |
| 469 | void LightscreenWindow::screenshotAction(Screenshot::Mode mode) |
| 470 | { |
| 471 | int delayms = -1; |
| 472 | |
| 473 | bool optionsHide = settings()->value("options/hide").toBool(); // Option cache, used a couple of times. |
| 474 | |
| 475 | if (!mHideTrigger) { |
| 476 | mWasVisible = isVisible(); |
| 477 | mHideTrigger = true; |
| 478 | } |
| 479 | |
| 480 | // Applying pre-screenshot settings |
| 481 | if (optionsHide) { |
| 482 | hide(); |
| 483 | |
| 484 | #ifndef Q_OS_LINUX // X is not quick enough and the notification ends up everywhere but in the icon |
| 485 | if (mTrayIcon) { |
| 486 | mTrayIcon->hide(); |
| 487 | } |
| 488 | #endif |
| 489 | } |
| 490 | |
| 491 | // Screenshot delay |
| 492 | delayms = settings()->value("options/delay", 0).toInt(); |
| 493 | delayms = delayms * 1000; // Converting the delay to milliseconds. |
| 494 | |
| 495 | delayms += 400; |
| 496 | |
| 497 | if (optionsHide && mPreviewDialog) { |
| 498 | if (mPreviewDialog->count() >= 1) { |
| 499 | mPreviewDialog->hide(); |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | // The delayed functions works using the static variable lastMode |
| 504 | // which keeps the argument so a QTimer can call this function again. |
| 505 | if (delayms > 0) { |
| 506 | if (mLastMode == Screenshot::None) { |
| 507 | mLastMode = mode; |
| 508 | |
| 509 | QTimer::singleShot(delayms, this, [&] { |
| 510 | screenshotAction(mLastMode); |
| 511 | }); |
| 512 | return; |
| 513 | } else { |
| 514 | mode = mLastMode; |
| 515 | mLastMode = Screenshot::None; |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | static Screenshot::Options options; |
| 520 | |
| 521 | if (!mDoCache) { |
| 522 | // Populating the option object that will then be passed to the screenshot engine (sounds fancy huh?) |
| 523 | options.file = settings()->value("file/enabled").toBool(); |
| 524 | options.format = (Screenshot::Format) settings()->value("file/format").toInt(); |
| 525 | options.prefix = settings()->value("file/prefix").toString(); |
| 526 | |