From 14100659b9c0fd6f0e122d5c169ce402a8c1a6f0 Mon Sep 17 00:00:00 2001 From: vozdeckyl <55758629+vozdeckyl@users.noreply.github.com> Date: Mon, 23 May 2022 16:06:24 +0100 Subject: [PATCH 01/10] Fix missing icon on snap (#2616) * defined FLAMESHOT_ICON variable * print statements * remove print statements * adding FLAMESHOT_ICON to snap yaml file * code format; comment --- snapcraft.yaml | 7 ++++--- src/CMakeLists.txt | 4 ++++ src/utils/systemnotification.cpp | 10 +++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index 03ad90df..75e2b9e9 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -46,9 +46,10 @@ parts: - kde-frameworks-5-qt-5-15-core20 source: https://github.com/flameshot-org/flameshot.git plugin: cmake - # This cannot be enabled until the KF5 toolkit in the snap is updated - #cmake-parameters: - # - -DUSE_WAYLAND_CLIPBOARD=1 + cmake-parameters: + - -DFLAMESHOT_ICON=/snap/flameshot/current/usr/local/share/icons/hicolor/scalable/apps/flameshot.svg + # This cannot be enabled until the KF5 toolkit in the snap is updated + #- -DUSE_WAYLAND_CLIPBOARD=1 source-type: git override-pull: | snapcraftctl pull diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06bcd396..2dd49c32 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,6 +65,10 @@ endif () add_executable(Flameshot::flameshot ALIAS flameshot) +if(FLAMESHOT_ICON) + target_compile_definitions(flameshot PUBLIC FLAMESHOT_ICON="${FLAMESHOT_ICON}") +endif() + if (WIN32) set_property(TARGET flameshot PROPERTY WIN32_EXECUTABLE true) if (MSVC) diff --git a/src/utils/systemnotification.cpp b/src/utils/systemnotification.cpp index 16c19efa..f593464a 100644 --- a/src/utils/systemnotification.cpp +++ b/src/utils/systemnotification.cpp @@ -12,6 +12,13 @@ #include "src/core/flameshotdaemon.h" #endif +// work-around for snap, which cannot install icons into +// the system folder, so instead the absolute path to the +// icon (saved somwhere in /snap/flameshot/...) is passed +#ifndef FLAMESHOT_ICON +#define FLAMESHOT_ICON "flameshot" +#endif + SystemNotification::SystemNotification(QObject* parent) : QObject(parent) , m_interface(nullptr) @@ -61,9 +68,10 @@ void SystemNotification::sendMessage(const QString& text, hintsMap[QStringLiteral("x-kde-urls")] = QStringList({ fullPath.toString() }); } + args << (qAppName()) // appname << static_cast(0) // id - << "flameshot" // icon + << FLAMESHOT_ICON // icon << title // summary << text // body << QStringList() // actions From 1b97fb51e4c44f6cb90dde6eda4cdc0527795daf Mon Sep 17 00:00:00 2001 From: "Weblate (bot)" Date: Mon, 23 May 2022 17:06:40 +0200 Subject: [PATCH 02/10] Translations update from Hosted Weblate (#2592) * Translated using Weblate (French) Currently translated at 99.7% (380 of 381 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/fr/ * Translated using Weblate (Dutch) Currently translated at 100.0% (381 of 381 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/nl/ * Translated using Weblate (Chinese (Simplified)) Currently translated at 93.7% (357 of 381 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/zh_Hans/ * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (381 of 381 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/zh_Hans/ * Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (381 of 381 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/zh_Hans/ * Translated using Weblate (French) Currently translated at 99.4% (379 of 381 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/fr/ * Translated using Weblate (Spanish) Currently translated at 100.0% (381 of 381 strings) Translation: Flameshot/Flameshot Translate-URL: https://hosted.weblate.org/projects/flameshot/flameshot/es/ Co-authored-by: paulbqnt Co-authored-by: Farhaz Hofman Co-authored-by: Alaskra <958328065@qq.com> Co-authored-by: Eric Co-authored-by: Mathieu B Co-authored-by: Luiz Carlos Lucasv --- data/translations/Internationalization_es.ts | 12 +-- data/translations/Internationalization_fr.ts | 36 ++++---- .../Internationalization_nl_NL.ts | 56 ++++++------ .../Internationalization_zh_CN.ts | 90 +++++++++---------- 4 files changed, 97 insertions(+), 97 deletions(-) diff --git a/data/translations/Internationalization_es.ts b/data/translations/Internationalization_es.ts index 685626f7..9d6c4be8 100644 --- a/data/translations/Internationalization_es.ts +++ b/data/translations/Internationalization_es.ts @@ -173,7 +173,7 @@ TextLabel - + Etiqueta de texto @@ -395,7 +395,7 @@ Presiona Espacio para abrir el panel lateral. Select preset using the spinbox - + Seleccione preestablecido usando el cuadro de número @@ -1061,7 +1061,7 @@ Por favor, resuélvelos manualmente en el archivo de configuración. Use fixed path for screenshots to save - Utiliza ruta fija para guardar las capturas de pantalla + Usar ubicación fija para guardar las capturas @@ -2430,14 +2430,14 @@ Puede ser que necesites preceder el símbolo "#" con "\", co Form - + Forma TextLabel - + Etiqueta de texto @@ -2612,7 +2612,7 @@ Puede ser que necesites preceder el símbolo "#" con "\", co Palette Image (%1) - Paleta de Imagen (%1) + Imagen de paleta (%1) diff --git a/data/translations/Internationalization_fr.ts b/data/translations/Internationalization_fr.ts index 6a45b3b0..56bfd14a 100644 --- a/data/translations/Internationalization_fr.ts +++ b/data/translations/Internationalization_fr.ts @@ -173,7 +173,7 @@ TextLabel - + Étiquette de texte @@ -205,7 +205,7 @@ Select screenshot area - + Sélectionner la zone de capture d'écran @@ -968,7 +968,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Use large predefined color palette - + Utiliser une large palette de couleurs prédéfinies @@ -1076,7 +1076,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Undo limit - Undo limit + Annuler la limite @@ -1097,12 +1097,12 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Anti-aliasing image when zoom the pinned image - + Anticrénelage de l'image lors du zoom de l'image épinglée After zooming the pinned image, should the image get smoothened or stay pixelated - + Après avoir zoomé sur l'image épinglée, l'image doit-elle être lissée ou rester pixelisée ? @@ -1192,18 +1192,18 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Upload Confirmation - + Confirmation du téléversement Do you want to upload this capture? - + Voulez-vous téléverser cette capture ? Upload without confirmation - + Téléverser sans confirmation @@ -1282,7 +1282,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. URL copied to clipboard. - + URL copiée dans le presse-papiers. @@ -1310,7 +1310,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Upload the selection - + Téléverser la sélection @@ -1492,7 +1492,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Invert - + Inverser @@ -1633,7 +1633,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Path copied to clipboard as - + Chemin d'accès copié dans le presse-papiers en tant que Saving canceled @@ -1694,7 +1694,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Existing directory or new file to save to - + Dossier existant ou nouveau fichier à sauvegarder dans @@ -1719,7 +1719,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Screenshot region to select - + Zone de capture d'écran à sélectionner @@ -1729,7 +1729,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Accept capture as soon as a selection is made - + Accepter la capture d'écran dès qu'une sélection est faite @@ -1744,7 +1744,7 @@ Veuillez résoudre ce problème manuellement depuis le fichier de configuration. Check the configuration for errors - + Vérifiez l'absence d'erreurs dans la configuration @@ -2425,7 +2425,7 @@ Vous devrez probablement remplacer le signe '#' par '\#FFF'< TextLabel - + étiquette de texte diff --git a/data/translations/Internationalization_nl_NL.ts b/data/translations/Internationalization_nl_NL.ts index da4e3a9b..889b670f 100644 --- a/data/translations/Internationalization_nl_NL.ts +++ b/data/translations/Internationalization_nl_NL.ts @@ -166,21 +166,21 @@ Capture Launcher - + Opname starter TextLabel - + TekstLabel Capture Mode - + Opname mode @@ -200,12 +200,12 @@ Mouse - + Muis Select screenshot area - Selecteer screenshot gebied + Selecteer schermopname gebied @@ -220,7 +220,7 @@ Right Click - Rechtsklikken + Rechterklik @@ -317,7 +317,7 @@ Druk op spatie om het zijpaneel te openen. Hue - Kleurtje + Tint @@ -331,7 +331,7 @@ Druk op spatie om het zijpaneel te openen. Blue - + Blauw @@ -345,7 +345,7 @@ Druk op spatie om het zijpaneel te openen. Green - + Groen @@ -359,7 +359,7 @@ Druk op spatie om het zijpaneel te openen. Red - + Rood @@ -390,17 +390,17 @@ Druk op spatie om het zijpaneel te openen. Select Preset: - + Voorinstelling selecteren: Select preset using the spinbox - + Selecteer de voorinstelling met de draaischijf Delete - + Verwijder @@ -410,7 +410,7 @@ Druk op spatie om het zijpaneel te openen. Add Preset: - + Voorinstelling toevoegen: @@ -420,7 +420,7 @@ Druk op spatie om het zijpaneel te openen. Add - + Toevoegen @@ -431,7 +431,7 @@ Druk op spatie om het zijpaneel te openen. Error - + Fout @@ -1392,7 +1392,7 @@ Los ze alstublieft handmatig op in het configuratiebestand. GPLv3+ - + GPLv3+ @@ -1406,14 +1406,14 @@ Los ze alstublieft handmatig op in het configuratiebestand. Flameshot v - + Flameshot versie OS Info - + Besturingssysteem info @@ -2346,7 +2346,7 @@ Mogelijk moet je het '#'-teken insluiten. Voorbeeld: '\#FFF' Select a Button to modify it - Kies een te bewerken knop + Selecteer een knop om deze te bewerken @@ -2417,7 +2417,7 @@ Mogelijk moet je het '#'-teken insluiten. Voorbeeld: '\#FFF' Screenshots history is empty - Er zijn nog geen schermfoto's gemaakt + Schermopname geschiedenis is leeg @@ -2434,14 +2434,14 @@ Mogelijk moet je het '#'-teken insluiten. Voorbeeld: '\#FFF' TextLabel - + TekstLabel Copy URL - URL kopiëren + Kopieer URL @@ -2453,12 +2453,12 @@ Mogelijk moet je het '#'-teken insluiten. Voorbeeld: '\#FFF' Confirm to delete - Verwijderen bevestigen + Bevestig om te verwijderen Are you sure you want to delete a screenshot from the latest uploads and server? - Weet je zeker dat je de schermfoto wilt verwijderen uit de recentste uploads en van de server? + Weet je zeker dat je de schermopname wilt verwijderen uit de recentste uploads en van de server? @@ -2484,12 +2484,12 @@ Mogelijk moet je het '#'-teken insluiten. Voorbeeld: '\#FFF' UI Color Editor - Kleurenschemabewerker + Gebruikersomgeving kleur bewerker Colorpicker Editor - Kleurkiezer Editor + Kleurkiezer bewerker @@ -2635,7 +2635,7 @@ Mogelijk moet je het '#'-teken insluiten. Voorbeeld: '\#FFF' Add Color - + Kleur toevoegen diff --git a/data/translations/Internationalization_zh_CN.ts b/data/translations/Internationalization_zh_CN.ts index ad8d039b..9eb93f03 100644 --- a/data/translations/Internationalization_zh_CN.ts +++ b/data/translations/Internationalization_zh_CN.ts @@ -166,21 +166,21 @@ Capture Launcher - + 捕获启动器 TextLabel - + 文本标签 Capture Mode - + 捕获模式 @@ -391,42 +391,42 @@ Press Space to open the side panel. Select Preset: - + 选择预设: Select preset using the spinbox - + 使用spinbox选择预设 Delete - + 刪除 Press button to delete the selected preset - + 按下按钮删除选定的预设 Add Preset: - + 添加预设: Enter color manually or select it using the color-wheel - + 手动输入颜色或使用色轮选择颜色 Add - + 添加 Press button to add preset - + 按下按钮添加预设 @@ -437,12 +437,12 @@ Press Space to open the side panel. Unable to add preset. Maximum limit reached. - + 无法添加预设。达到最大限度。 Unable to remove preset. Minimum limit reached. - + 无法删除预设。已达到最低限制。 @@ -1040,62 +1040,62 @@ Please solve them manually in the configuration file. Show the help message at the beginning in the capture mode - + 在捕获之前显示帮助信息 Show the side panel toggle button in the capture mode - + 在捕获模式下显示侧边栏切换按钮 Enable desktop notifications - + 启用桌面通知 Show icon in the system tray - + 在系统托盘中显示图标 Ask for confirmation to delete screenshot from the latest uploads - + 从最近的上传历史中删除屏幕截图需要进行确认 Check for updates automatically - + 自动检查更新 This allows you to take screenshots of Flameshot itself for example - + 例如,这允许您截取 Flameshot 本身作为屏幕截图 Launch Flameshot daemon when computer is booted - + 开机自启动 Show the welcome message box in the middle of the screen while taking a screenshot - + 在截取屏幕截图时在屏幕中间显示欢迎消息框 Use a large predefined color palette - + 使用一个大的预定义调色板 Copy URL and close window after uploading was successful - + 上传成功后复制 URL 并关闭窗口 After copying the screenshot, save it to a file as well - + 复制屏幕截图后,也将其保存到文件中 @@ -1141,7 +1141,7 @@ Please solve them manually in the configuration file. Copy the file path to clipboard after the file is saved - + 文件保存后将文件路径复制到剪贴板上 @@ -1172,22 +1172,22 @@ Please solve them manually in the configuration file. Show magnifier - + 显示放大镜 Enable a magnifier while selecting the screenshot area - + 选择屏幕截图区域时启用放大镜 Square shaped magnifier - + 方形放大镜 Make the magnifier to be square-shaped - + 使放大镜呈方形 @@ -1317,7 +1317,7 @@ Please solve them manually in the configuration file. Save image - + 保存图片 @@ -1337,12 +1337,12 @@ Please solve them manually in the configuration file. Unable to save the screenshot to disk. - + 无法将屏幕截图保存到磁盘。 Screenshot saved. - + 截图已保存。 @@ -1423,49 +1423,49 @@ Please solve them manually in the configuration file. Icon - + 图标 License - + 许可证 GPLv3+ - + GPLv3+ Version - + 版本 Flameshot v - + Flameshot v OS Info - + 操作系统信息 Copy Info - + 复制信息 SPACEBAR @@ -2464,7 +2464,7 @@ You may need to escape the '#' sign as in '\#FFF' Upload History - + 上传历史记录 @@ -2479,14 +2479,14 @@ You may need to escape the '#' sign as in '\#FFF' Form - + 表单 TextLabel - + 文本标签 @@ -2500,7 +2500,7 @@ You may need to escape the '#' sign as in '\#FFF' Open In Browser - + 在浏览器中打开 @@ -2541,7 +2541,7 @@ You may need to escape the '#' sign as in '\#FFF' Colorpicker Editor - + 拾色器编辑器 From 0116740e54d3a6f612b0762be790ab5ac4da63d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Gu=C5=A1i=C4=87?= Date: Tue, 31 May 2022 16:56:52 +0200 Subject: [PATCH 03/10] Fix selection offset (#2630) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Haris Gušić --- src/widgets/capture/selectionwidget.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widgets/capture/selectionwidget.cpp b/src/widgets/capture/selectionwidget.cpp index 51cfc102..13919d6f 100644 --- a/src/widgets/capture/selectionwidget.cpp +++ b/src/widgets/capture/selectionwidget.cpp @@ -203,14 +203,17 @@ void SelectionWidget::parentMouseMoveEvent(QMouseEvent* e) mouseSide = getMouseSide(e->pos()); } + QPoint pos; + if (!isVisible() || !mouseSide) { show(); - m_dragStartPos = e->pos(); m_activeSide = TOPLEFT_SIDE; - setGeometry({ e->pos(), e->pos() }); + pos = m_dragStartPos; + setGeometry({ pos, pos }); + } else { + pos = e->pos(); } - QPoint pos = e->pos(); auto geom = geometry(); bool symmetryMod = qApp->keyboardModifiers() & Qt::ShiftModifier; @@ -280,7 +283,7 @@ void SelectionWidget::parentMouseMoveEvent(QMouseEvent* e) setGeometry(geom.normalized()); m_activeSide = getProperSide(m_activeSide, geom); } - m_dragStartPos = pos; + m_dragStartPos = e->pos(); } void SelectionWidget::paintEvent(QPaintEvent*) From 2582f063ccabaf5f469594699e396e4f89243fbd Mon Sep 17 00:00:00 2001 From: greenfoo <42691086+greenfoo@users.noreply.github.com> Date: Tue, 31 May 2022 16:58:39 +0200 Subject: [PATCH 04/10] Suggest setting XDG_CURRENT_DESKTOP if DE cannot be detected (#2634) --- src/utils/screengrabber.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/screengrabber.cpp b/src/utils/screengrabber.cpp index b2857fd5..d0d1bec8 100644 --- a/src/utils/screengrabber.cpp +++ b/src/utils/screengrabber.cpp @@ -108,6 +108,12 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok) } default: ok = false; + AbstractLogger::error() + << tr("Unable to detect desktop environment (GNOME? KDE? " + "Sway? ...)"); + AbstractLogger::error() + << tr("Hint: try setting the XDG_CURRENT_DESKTOP environment " + "variable."); break; } if (!ok) { From 46801d933a5bf9e0ee4f9bd921875f3663ceb103 Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Wed, 1 Jun 2022 09:18:54 -0500 Subject: [PATCH 05/10] Added the ability to cache the last region (#2615) * Added the ability to cache the last region * adding cli option * addressed typo comments and applied clang-format --- src/config/CMakeLists.txt | 13 +++--- src/config/cacheutils.cpp | 49 ++++++++++++++++++++++ src/config/cacheutils.h | 14 +++++++ src/config/generalconf.cpp | 20 +++++++++ src/config/generalconf.h | 3 ++ src/core/capturerequest.cpp | 13 +++--- src/core/flameshot.cpp | 27 +++++-------- src/core/flameshot.h | 2 +- src/main.cpp | 16 ++++++-- src/utils/confighandler.cpp | 3 +- src/utils/confighandler.h | 2 +- src/widgets/capture/capturewidget.cpp | 5 ++- src/widgets/capturelauncher.cpp | 58 ++++----------------------- src/widgets/capturelauncher.h | 4 -- src/widgets/trayicon.cpp | 8 ++-- 15 files changed, 144 insertions(+), 93 deletions(-) create mode 100644 src/config/cacheutils.cpp create mode 100644 src/config/cacheutils.h diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index 6e0c2507..eb9ae901 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -1,19 +1,20 @@ target_sources( flameshot PRIVATE buttonlistview.cpp + cacheutils.cpp clickablelabel.cpp - configwindow.cpp - configresolver.cpp + colorpickereditmode.cpp + colorpickereditor.cpp configerrordetails.cpp + configresolver.cpp + configwindow.cpp extendedslider.cpp filenameeditor.cpp generalconf.cpp + setshortcutwidget.cpp + shortcutswidget.cpp strftimechooserwidget.cpp styleoverride.cpp uicoloreditor.cpp - colorpickereditor.cpp visualseditor.cpp - shortcutswidget.cpp - setshortcutwidget.cpp - colorpickereditmode.cpp ) diff --git a/src/config/cacheutils.cpp b/src/config/cacheutils.cpp new file mode 100644 index 00000000..b84ead9c --- /dev/null +++ b/src/config/cacheutils.cpp @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 Jeremy Borgman + +#include "cacheutils.h" +#include +#include +#include +#include +#include +#include + +QString getCachePath() +{ + auto cachePath = + QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + if (!QDir(cachePath).exists()) { + QDir().mkpath(cachePath); + } + return cachePath; +} + +void setLastRegion(QRect const& newRegion) +{ + auto cachePath = getCachePath() + "/region.txt"; + + QFile file(cachePath); + if (file.open(QIODevice::WriteOnly)) { + QDataStream out(&file); + out << newRegion; + file.close(); + } +} + +QRect getLastRegion() +{ + auto cachePath = getCachePath() + "/region.txt"; + QFile file(cachePath); + + QRect lastRegion; + if (file.open(QIODevice::ReadOnly)) { + QDataStream input(&file); + input >> lastRegion; + file.close(); + } else { + lastRegion = QRect(0, 0, 0, 0); + } + + return lastRegion; +} \ No newline at end of file diff --git a/src/config/cacheutils.h b/src/config/cacheutils.h new file mode 100644 index 00000000..ad82ca4a --- /dev/null +++ b/src/config/cacheutils.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-FileCopyrightText: 2021 Jeremy Borgman + +#ifndef FLAMESHOT_CACHEUTILS_H +#define FLAMESHOT_CACHEUTILS_H + +class QString; +class QRect; + +QString getCachePath(); +QRect getLastRegion(); +void setLastRegion(QRect const& newRegion); + +#endif // FLAMESHOT_CACHEUTILS_H \ No newline at end of file diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index 69613689..448f2979 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -33,6 +33,7 @@ GeneralConf::GeneralConf(QWidget* parent) initScrollArea(); initShowHelp(); + initSaveLastRegion(); initShowSidePanelButton(); initShowDesktopNotification(); initShowTrayIcon(); @@ -84,6 +85,7 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath) m_allowMultipleGuiInstances->setChecked(config.allowMultipleGuiInstances()); m_showMagnifier->setChecked(config.showMagnifier()); m_squareMagnifier->setChecked(config.squareMagnifier()); + m_saveLastRegion->setChecked(config.saveLastRegion()); #if !defined(Q_OS_WIN) m_autoCloseIdleDaemon->setChecked(config.autoCloseIdleDaemon()); @@ -109,6 +111,11 @@ void GeneralConf::updateComponents() _updateComponents(false); } +void GeneralConf::saveLastRegion(bool checked) +{ + ConfigHandler().setSaveLastRegion(checked); +} + void GeneralConf::showHelpChanged(bool checked) { ConfigHandler().setShowHelp(checked); @@ -235,6 +242,19 @@ void GeneralConf::initShowHelp() m_helpMessage, &QCheckBox::clicked, this, &GeneralConf::showHelpChanged); } +void GeneralConf::initSaveLastRegion() +{ + m_saveLastRegion = new QCheckBox(tr("Use last region"), this); + m_saveLastRegion->setToolTip(tr("Uses the last region as the default " + "selection for the next screenshot")); + m_scrollAreaLayout->addWidget(m_saveLastRegion); + + connect(m_saveLastRegion, + &QCheckBox::clicked, + this, + &GeneralConf::saveLastRegion); +} + void GeneralConf::initShowSidePanelButton() { m_sidePanelButton = new QCheckBox(tr("Show the side panel button"), this); diff --git a/src/config/generalconf.h b/src/config/generalconf.h index a2449881..a1178cf5 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -25,6 +25,7 @@ public slots: private slots: void showHelpChanged(bool checked); + void saveLastRegion(bool checked); void showSidePanelButtonChanged(bool checked); void showDesktopNotificationChanged(bool checked); void checkForUpdatesChanged(bool checked); @@ -72,6 +73,7 @@ private: void initUseJpgForClipboard(); void initUploadHistoryMax(); void initUploadClientSecret(); + void initSaveLastRegion(); void _updateComponents(bool allowEmptySavePath); @@ -91,6 +93,7 @@ private: QCheckBox* m_copyAndCloseAfterUpload; QCheckBox* m_copyPathAfterSave; QCheckBox* m_antialiasingPinZoom; + QCheckBox* m_saveLastRegion; QCheckBox* m_uploadWithoutConfirmation; QPushButton* m_importButton; QPushButton* m_exportButton; diff --git a/src/core/capturerequest.cpp b/src/core/capturerequest.cpp index eec0ceb0..2c58c5b0 100644 --- a/src/core/capturerequest.cpp +++ b/src/core/capturerequest.cpp @@ -3,16 +3,13 @@ #include "capturerequest.h" #include "confighandler.h" -#include "flameshot.h" #include "imgupload/imguploadermanager.h" #include "pinwidget.h" +#include "src/config/cacheutils.h" #include "src/utils/screenshotsaver.h" -#include "src/widgets/imguploaddialog.h" -#include "systemnotification.h" #include #include #include -#include #include #include @@ -24,7 +21,13 @@ CaptureRequest::CaptureRequest(CaptureRequest::CaptureMode mode, , m_delay(delay) , m_tasks(tasks) , m_data(std::move(data)) -{} +{ + + ConfigHandler config; + if (config.saveLastRegion()) { + setInitialSelection(getLastRegion()); + } +} CaptureRequest::CaptureMode CaptureRequest::captureMode() const { diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index 196e8789..26e95b94 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -3,7 +3,6 @@ #include "flameshot.h" #include "flameshotdaemon.h" - #if defined(Q_OS_MACOS) #include "external/QHotkey/QHotkey" #endif @@ -25,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -115,8 +113,6 @@ CaptureWidget* Flameshot::gui(const CaptureRequest& req) } m_captureWindow = new CaptureWidget(req); - // m_captureWindow = new CaptureWidget(req, false); // - // debug #ifdef Q_OS_WIN m_captureWindow->show(); @@ -138,20 +134,16 @@ CaptureWidget* Flameshot::gui(const CaptureRequest& req) void Flameshot::screen(CaptureRequest req, const int screenNumber) { - if (!resolveAnyConfigErrors()) + if (!resolveAnyConfigErrors()) { return; + } bool ok = true; QScreen* screen; if (screenNumber < 0) { QPoint globalCursorPos = QCursor::pos(); -#if QT_VERSION > QT_VERSION_CHECK(5, 10, 0) screen = qApp->screenAt(globalCursorPos); -#else - screen = - qApp->screens()[qApp->desktop()->screenNumber(globalCursorPos)]; -#endif } else if (screenNumber >= qApp->screens().count()) { AbstractLogger() << QObject::tr( "Requested screen exceeds screen count"); @@ -184,8 +176,9 @@ void Flameshot::screen(CaptureRequest req, const int screenNumber) void Flameshot::full(const CaptureRequest& req) { - if (!resolveAnyConfigErrors()) + if (!resolveAnyConfigErrors()) { return; + } bool ok = true; QPixmap p(ScreenGrabber().grabEntireDesktop(ok)); @@ -203,10 +196,11 @@ void Flameshot::full(const CaptureRequest& req) void Flameshot::launcher() { - if (!resolveAnyConfigErrors()) + if (!resolveAnyConfigErrors()) { return; + } - if (!m_launcherWindow) { + if (m_launcherWindow == nullptr) { m_launcherWindow = new CaptureLauncher(); } m_launcherWindow->show(); @@ -218,10 +212,11 @@ void Flameshot::launcher() void Flameshot::config() { - if (!resolveAnyConfigErrors()) + if (!resolveAnyConfigErrors()) { return; + } - if (!m_configWindow) { + if (m_configWindow == nullptr) { m_configWindow = new ConfigWindow(); m_configWindow->show(); #if defined(Q_OS_MACOS) @@ -233,7 +228,7 @@ void Flameshot::config() void Flameshot::info() { - if (!m_infoWindow) { + if (m_infoWindow == nullptr) { m_infoWindow = new InfoWindow(); #if defined(Q_OS_MACOS) m_infoWindow->activateWindow(); diff --git a/src/core/flameshot.h b/src/core/flameshot.h index c738a737..ec8ce98c 100644 --- a/src/core/flameshot.h +++ b/src/core/flameshot.h @@ -34,7 +34,7 @@ public: public slots: CaptureWidget* gui( const CaptureRequest& req = CaptureRequest::GRAPHICAL_MODE); - void screen(CaptureRequest req, const int screenNumber = -1); + void screen(CaptureRequest req, int const screenNumber = -1); void full(const CaptureRequest& req); void launcher(); void config(); diff --git a/src/main.cpp b/src/main.cpp index 1d4ddd1b..86d7a1c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,7 @@ #include "abstractlogger.h" #include "src/cli/commandlineparser.h" +#include "src/config/cacheutils.h" #include "src/config/styleoverride.h" #include "src/core/capturerequest.h" #include "src/core/flameshot.h" @@ -23,7 +24,6 @@ #include #include #include - #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) #include "abstractlogger.h" #include "src/core/flameshotdbusadapter.h" @@ -176,6 +176,11 @@ int main(int argc, char* argv[]) CommandOption delayOption({ "d", "delay" }, QObject::tr("Delay time in milliseconds"), QStringLiteral("milliseconds")); + + CommandOption useLastRegionOption( + "last-region", + QObject::tr("Repeat screenshot with previously selected region")); + CommandOption regionOption("region", QObject::tr("Screenshot region to select"), QStringLiteral("WxH+X+Y or string")); @@ -272,6 +277,7 @@ int main(int argc, char* argv[]) mainColorOption.addChecker(colorChecker, colorErr); delayOption.addChecker(numericChecker, delayErr); regionOption.addChecker(regionChecker, regionErr); + useLastRegionOption.addChecker(booleanChecker, booleanErr); pathOption.addChecker(pathChecker, pathErr); trayOption.addChecker(booleanChecker, booleanErr); autostartOption.addChecker(booleanChecker, booleanErr); @@ -290,6 +296,7 @@ int main(int argc, char* argv[]) clipboardOption, delayOption, regionOption, + useLastRegionOption, rawImageOption, selectionOption, uploadOption, @@ -359,6 +366,7 @@ int main(int argc, char* argv[]) } int delay = parser.value(delayOption).toInt(); QString region = parser.value(regionOption); + bool useLastRegion = parser.isSet(useLastRegionOption); bool clipboard = parser.isSet(clipboardOption); bool raw = parser.isSet(rawImageOption); bool printGeometry = parser.isSet(selectionOption); @@ -367,7 +375,10 @@ int main(int argc, char* argv[]) bool acceptOnSelect = parser.isSet(acceptOnSelectOption); CaptureRequest req(CaptureRequest::GRAPHICAL_MODE, delay, path); if (!region.isEmpty()) { - req.setInitialSelection(Region().value(region).toRect()); + auto selectionRegion = Region().value(region).toRect(); + req.setInitialSelection(selectionRegion); + } else if (useLastRegion) { + req.setInitialSelection(getLastRegion()); } if (clipboard) { req.addTask(CaptureRequest::COPY); @@ -394,7 +405,6 @@ int main(int argc, char* argv[]) req.addSaveTask(); } } - requestCaptureAndWait(req); } else if (parser.isSet(fullArgument)) { // FULL // Recreate the application as a QApplication diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 2e7a5987..8f53cba9 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -101,9 +101,10 @@ static QMap> OPTION("savePath" ,ExistingDir ( )), OPTION("savePathFixed" ,Bool ( false )), OPTION("saveAsFileExtension" ,SaveFileExtension ( )), + OPTION("saveLastRegion" ,Bool (false )), OPTION("uploadHistoryMax" ,LowerBoundedInt (0, 25 )), OPTION("undoLimit" ,BoundedInt (0, 999, 100 )), - // Interface tab + // Interface tab OPTION("uiColor" ,Color ( {116, 0, 150} )), OPTION("contrastUiColor" ,Color ( {39, 0, 50} )), OPTION("contrastOpacity" ,BoundedInt ( 0, 255, 190 )), diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 3e8322d2..3be5953a 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -119,7 +119,7 @@ public: CONFIG_GETTER_SETTER(squareMagnifier, setSquareMagnifier, bool) CONFIG_GETTER_SETTER(copyOnDoubleClick, setCopyOnDoubleClick, bool) CONFIG_GETTER_SETTER(uploadClientSecret, setUploadClientSecret, QString) - + CONFIG_GETTER_SETTER(saveLastRegion, setSaveLastRegion, bool) // SPECIAL CASES bool startupLaunch(); void setStartupLaunch(const bool); diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 8dfbe03e..e436dc99 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -12,6 +12,7 @@ #include "capturewidget.h" #include "abstractlogger.h" #include "copytool.h" +#include "src/config/cacheutils.h" #include "src/core/flameshot.h" #include "src/core/qguiappcurrentscreen.h" #include "src/tools/toolfactory.h" @@ -259,6 +260,8 @@ CaptureWidget::~CaptureWidget() } #endif if (m_captureDone) { + auto lastRegion = m_selection->geometry(); + setLastRegion(lastRegion); QRect geometry(m_context.selection); geometry.setTopLeft(geometry.topLeft() + m_context.widgetOffset); Flameshot::instance()->exportCapture( @@ -1700,7 +1703,7 @@ void CaptureWidget::redo() QRect CaptureWidget::extendedSelection() const { - if (!m_selection->isVisible()) { + if (m_selection == nullptr) { return {}; } QRect r = m_selection->geometry(); diff --git a/src/widgets/capturelauncher.cpp b/src/widgets/capturelauncher.cpp index 121bdfb8..39a6d7c0 100644 --- a/src/widgets/capturelauncher.cpp +++ b/src/widgets/capturelauncher.cpp @@ -3,15 +3,14 @@ #include "capturelauncher.h" #include "./ui_capturelauncher.h" +#include "src/config/cacheutils.h" #include "src/core/flameshot.h" #include "src/utils/globalvalues.h" #include "src/utils/screengrabber.h" #include "src/utils/screenshotsaver.h" #include "src/widgets/imagelabel.h" -#include -#include #include -#include + // https://github.com/KDE/spectacle/blob/941c1a517be82bed25d1254ebd735c29b0d2951c/src/Gui/KSWidget.cpp // https://github.com/KDE/spectacle/blob/941c1a517be82bed25d1254ebd735c29b0d2951c/src/Gui/KSMainWindow.cpp @@ -80,51 +79,18 @@ CaptureLauncher::CaptureLauncher(QDialog* parent) } }); - auto last_region = getLastRegion(); - ui->screenshotX->setText(QString::number(last_region.x())); - ui->screenshotY->setText(QString::number(last_region.y())); - ui->screenshotWidth->setText(QString::number(last_region.width())); - ui->screenshotHeight->setText(QString::number(last_region.height())); + auto lastRegion = getLastRegion(); + ui->screenshotX->setText(QString::number(lastRegion.x())); + ui->screenshotY->setText(QString::number(lastRegion.y())); + ui->screenshotWidth->setText(QString::number(lastRegion.width())); + ui->screenshotHeight->setText(QString::number(lastRegion.height())); show(); } -void CaptureLauncher::setLastRegion() -{ - auto cachePath = getCachePath() + "/region.txt"; - - QFile file(cachePath); - if (file.open(QIODevice::WriteOnly)) { - auto newRegion = QRect(ui->screenshotX->text().toInt(), - ui->screenshotY->text().toInt(), - ui->screenshotWidth->text().toInt(), - ui->screenshotHeight->text().toInt()); - QDataStream out(&file); - out << newRegion; - file.close(); - } -} - -QRect CaptureLauncher::getLastRegion() -{ - auto cachePath = getCachePath() + "/region.txt"; - QFile file(cachePath); - - QRect lastRegion; - if (file.open(QIODevice::ReadOnly)) { - QDataStream in(&file); - in >> lastRegion; - file.close(); - } else { - lastRegion = QRect(0, 0, 0, 0); - } - - return lastRegion; -} // HACK: // https://github.com/KDE/spectacle/blob/fa1e780b8bf3df3ac36c410b9ece4ace041f401b/src/Gui/KSMainWindow.cpp#L70 void CaptureLauncher::startCapture() { - setLastRegion(); ui->launchButton->setEnabled(false); hide(); @@ -205,13 +171,3 @@ CaptureLauncher::~CaptureLauncher() { delete ui; } - -QString getCachePath() -{ - auto cachePath = - QStandardPaths::writableLocation(QStandardPaths::CacheLocation); - if (!QDir(cachePath).exists()) { - QDir().mkpath(cachePath); - } - return cachePath; -} diff --git a/src/widgets/capturelauncher.h b/src/widgets/capturelauncher.h index ce273483..0e0baf03 100644 --- a/src/widgets/capturelauncher.h +++ b/src/widgets/capturelauncher.h @@ -23,13 +23,9 @@ private: Ui::CaptureLauncher* ui; void connectCaptureSlots() const; void disconnectCaptureSlots() const; - void setLastRegion(); - QRect getLastRegion(); private slots: void startCapture(); void onCaptureTaken(QPixmap const& p); void onCaptureFailed(); }; - -QString getCachePath(); \ No newline at end of file diff --git a/src/widgets/trayicon.cpp b/src/widgets/trayicon.cpp index 9d1137a7..3221118f 100644 --- a/src/widgets/trayicon.cpp +++ b/src/widgets/trayicon.cpp @@ -95,7 +95,7 @@ void TrayIcon::initMenu() { m_menu = new QMenu(); - QAction* captureAction = new QAction(tr("&Take Screenshot"), this); + auto* captureAction = new QAction(tr("&Take Screenshot"), this); connect(captureAction, &QAction::triggered, this, [this]() { #if defined(Q_OS_MACOS) auto currentMacOsVersion = QOperatingSystemVersion::current(); @@ -113,17 +113,17 @@ void TrayIcon::initMenu() }); #endif }); - QAction* launcherAction = new QAction(tr("&Open Launcher"), this); + auto* launcherAction = new QAction(tr("&Open Launcher"), this); connect(launcherAction, &QAction::triggered, Flameshot::instance(), &Flameshot::launcher); - QAction* configAction = new QAction(tr("&Configuration"), this); + auto* configAction = new QAction(tr("&Configuration"), this); connect(configAction, &QAction::triggered, Flameshot::instance(), &Flameshot::config); - QAction* infoAction = new QAction(tr("&About"), this); + auto* infoAction = new QAction(tr("&About"), this); connect( infoAction, &QAction::triggered, Flameshot::instance(), &Flameshot::info); From 7a57268ca333fb28d39245aea07e79f72d4ac037 Mon Sep 17 00:00:00 2001 From: vozdeckyl <55758629+vozdeckyl@users.noreply.github.com> Date: Thu, 2 Jun 2022 01:29:25 +0100 Subject: [PATCH 06/10] Dev bubble pointers (#2638) * adding a simple line as a test * replacing line with pointer * remove commented out lines * code format * fixed the 'QPainterPath path' error * make pointers more pointy * comment and variable name Co-authored-by: Mehrad Mahmoudian --- src/tools/circlecount/circlecounttool.cpp | 44 ++++++++++++++++++++--- src/widgets/capture/capturewidget.cpp | 12 ++----- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/tools/circlecount/circlecounttool.cpp b/src/tools/circlecount/circlecounttool.cpp index 7d0458e7..ee238c9a 100644 --- a/src/tools/circlecount/circlecounttool.cpp +++ b/src/tools/circlecount/circlecounttool.cpp @@ -4,6 +4,7 @@ #include "circlecounttool.h" #include "colorutils.h" #include +#include namespace { #define PADDING_VALUE 2 @@ -46,10 +47,20 @@ QRect CircleCountTool::boundingRect() const return {}; } int bubble_size = size() + THICKNESS_OFFSET + PADDING_VALUE; - return { points().first.x() - bubble_size, - points().first.y() - bubble_size, - bubble_size * 2, - bubble_size * 2 }; + + int line_pos_min_x = + std::min(points().first.x() - bubble_size, points().second.x()); + int line_pos_min_y = + std::min(points().first.y() - bubble_size, points().second.y()); + int line_pos_max_x = + std::max(points().first.x() + bubble_size, points().second.x()); + int line_pos_max_y = + std::max(points().first.y() + bubble_size, points().second.y()); + + return { line_pos_min_x, + line_pos_min_y, + line_pos_max_x - line_pos_min_x, + line_pos_max_y - line_pos_min_y }; } QString CircleCountTool::name() const @@ -96,6 +107,30 @@ void CircleCountTool::process(QPainter& painter, const QPixmap& pixmap) ColorUtils::colorIsDark(color()) ? Qt::black : Qt::white; int bubble_size = size() + THICKNESS_OFFSET; + + QLineF line(points().first, points().second); + // if the mouse is outside of the bubble, draw the pointer + if (line.length() > bubble_size) { + painter.setPen(QPen(color(), 0)); + painter.setBrush(color()); + + int middleX = points().first.x(); + int middleY = points().first.y(); + + QLineF normal = line.normalVector(); + normal.setLength(bubble_size); + QPoint p1 = normal.p2().toPoint(); + QPoint p2(middleX - (p1.x() - middleX), middleY - (p1.y() - middleY)); + + QPainterPath path; + path.moveTo(points().first); + path.lineTo(p1); + path.lineTo(points().second); + path.lineTo(p2); + path.lineTo(points().first); + painter.drawPath(path); + } + painter.setPen(contrastColor); painter.setBrush(antiContrastColor); painter.drawEllipse( @@ -131,7 +166,6 @@ void CircleCountTool::process(QPainter& painter, const QPixmap& pixmap) // Draw text painter.setPen(contrastColor); painter.drawText(textRect, Qt::AlignCenter, QString::number(count())); - // restore original font, brush, and pen painter.setFont(orig_font); painter.setBrush(orig_brush); diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index e436dc99..4b691332 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -562,19 +562,11 @@ bool CaptureWidget::startDrawObjectTool(const QPoint& pos) m_context.mousePos = pos; m_activeTool->drawStart(m_context); // TODO this is the wrong place to do this + if (m_activeTool->type() == CaptureTool::TYPE_CIRCLECOUNT) { - // While it is based on AbstractTwoPointTool it has the only one - // point and shouldn't wait for second point and move event - m_activeTool->drawEnd(m_context.mousePos); - m_activeTool->setCount(m_context.circleCount++); - - m_captureToolObjectsBackup = m_captureToolObjects; - m_captureToolObjects.append(m_activeTool); - pushObjectsStateToUndoStack(); - releaseActiveTool(); - m_mouseIsClicked = false; } + return true; } return false; From 65e3a013605c9aacaecfaffc65423311d41b2a7f Mon Sep 17 00:00:00 2001 From: borgmanJeremy <46930769+borgmanJeremy@users.noreply.github.com> Date: Thu, 2 Jun 2022 08:38:31 -0500 Subject: [PATCH 07/10] Print info messages to stdout instead of stderr (#2639) --- src/cli/commandlineparser.cpp | 2 +- src/utils/abstractlogger.cpp | 6 ++++++ src/utils/abstractlogger.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cli/commandlineparser.cpp b/src/cli/commandlineparser.cpp index 298c239b..8c5ef697 100644 --- a/src/cli/commandlineparser.cpp +++ b/src/cli/commandlineparser.cpp @@ -14,7 +14,7 @@ CommandLineParser::CommandLineParser() namespace { AbstractLogger out = - AbstractLogger::info(AbstractLogger::Stderr).enableMessageHeader(false); + AbstractLogger::info(AbstractLogger::Stdout).enableMessageHeader(false); AbstractLogger err = AbstractLogger::error(AbstractLogger::Stderr); auto versionOption = diff --git a/src/utils/abstractlogger.cpp b/src/utils/abstractlogger.cpp index 083d0fcd..3de73e28 100644 --- a/src/utils/abstractlogger.cpp +++ b/src/utils/abstractlogger.cpp @@ -63,6 +63,12 @@ AbstractLogger& AbstractLogger::sendMessage(QString msg, Channel channel) QTextStream stream(stderr); stream << messageHeader(channel, Stderr) << msg << "\n"; } + + if (m_targets & Stdout) { + QTextStream stream(stdout); + stream << messageHeader(channel, Stdout) << msg << "\n"; + } + return *this; } diff --git a/src/utils/abstractlogger.h b/src/utils/abstractlogger.h index c38c6d5b..05ce8af5 100644 --- a/src/utils/abstractlogger.h +++ b/src/utils/abstractlogger.h @@ -15,6 +15,7 @@ public: Stderr = 0x02, LogFile = 0x08, String = 0x10, + Stdout = 0x20, Default = Notification | LogFile | Stderr, }; From 98c1b029e3783357aafb52cad76da48e1c5546e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Gu=C5=A1i=C4=87?= Date: Fri, 3 Jun 2022 19:27:54 +0200 Subject: [PATCH 08/10] Fix CloseOnLastWindow caused by tool change (#2645) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Haris Gušić --- src/tools/text/texttool.cpp | 4 ++-- src/widgets/capture/capturewidget.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tools/text/texttool.cpp b/src/tools/text/texttool.cpp index 415451a8..798688a3 100644 --- a/src/tools/text/texttool.cpp +++ b/src/tools/text/texttool.cpp @@ -114,12 +114,12 @@ QWidget* TextTool::widget() void TextTool::closeEditor() { if (!m_widget.isNull()) { - m_widget->close(); + m_widget->hide(); delete m_widget; m_widget = nullptr; } if (!m_confW.isNull()) { - m_confW->close(); + m_confW->hide(); delete m_confW; m_confW = nullptr; } diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 4b691332..1f2bc24a 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -439,7 +439,7 @@ void CaptureWidget::deleteToolWidgetOrClose() m_panel->hide(); } else if (m_toolWidget) { // delete toolWidget if exists - m_toolWidget->close(); + m_toolWidget->hide(); delete m_toolWidget; m_toolWidget = nullptr; } else if (m_colorPicker && m_colorPicker->isVisible()) { @@ -466,7 +466,7 @@ void CaptureWidget::releaseActiveTool() m_activeTool = nullptr; } if (m_toolWidget) { - m_toolWidget->close(); + m_toolWidget->hide(); delete m_toolWidget; m_toolWidget = nullptr; } @@ -1180,7 +1180,7 @@ void CaptureWidget::handleToolSignal(CaptureTool::Request r) break; } if (m_toolWidget) { - m_toolWidget->close(); + m_toolWidget->hide(); delete m_toolWidget; m_toolWidget = nullptr; } From dd9fc451083476a5768b0c6024dd9c117d06671d Mon Sep 17 00:00:00 2001 From: Boyuan Yang Date: Tue, 7 Jun 2022 16:48:48 -0400 Subject: [PATCH 09/10] README.md: Replace qt5-default build-dep with qtbase5-dev (#2649) Package qt5-default is not available in newer deb-based Linux distributions. Users are encouraged to use qtbase5-dev instead. closes: #2635 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62ac0a8f..1da42658 100644 --- a/README.md +++ b/README.md @@ -418,7 +418,7 @@ Also you can open and build/debug the project in a C++ IDE. For example, in Qt C ```shell # Compile-time -apt install g++ cmake build-essential qt5-default qttools5-dev-tools libqt5svg5-dev qttools5-dev +apt install g++ cmake build-essential qtbase5-dev qttools5-dev-tools libqt5svg5-dev qttools5-dev # Run-time apt install libqt5dbus5 libqt5network5 libqt5core5a libqt5widgets5 libqt5gui5 libqt5svg5 From fb42ad5c25a3a095e3816112ef4a2921bb953631 Mon Sep 17 00:00:00 2001 From: Alaskra <958328065@qq.com> Date: Fri, 10 Jun 2022 21:46:21 +0800 Subject: [PATCH 10/10] fix unexpected close when launch external app (#2617) * fix unexpected close when launch external app * update --- src/core/flameshot.cpp | 6 ++++++ src/main.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp index 26e95b94..cf112d79 100644 --- a/src/core/flameshot.cpp +++ b/src/core/flameshot.cpp @@ -411,6 +411,12 @@ void Flameshot::exportCapture(QPixmap capture, if (!(tasks & CR::UPLOAD)) { emit captureTaken(capture); } + // hacks: close a window to trigger qt's quitOnLastWindowClose + // if not create tmp_window and close, the `flameshot gui` won't exit after + // click copy button + QWidget* tmp = new QWidget(); + tmp->show(); + tmp->close(); } // STATIC ATTRIBUTES diff --git a/src/main.cpp b/src/main.cpp index 86d7a1c5..62d75b61 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,12 +49,14 @@ void requestCaptureAndWait(const CaptureRequest& req) { Flameshot* flameshot = Flameshot::instance(); flameshot->requestCapture(req); - QObject::connect(flameshot, &Flameshot::captureTaken, [&](QPixmap) { - // Only useful on MacOS because each instance hosts its own widgets +#if defined(Q_OS_MACOS) + // Only useful on MacOS because each instance hosts its own widgets + QObject::connect(flameshot, &Flameshot::captureTaken, [&](const QPixmap&) { if (!FlameshotDaemon::isThisInstanceHostingWidgets()) { qApp->exit(0); } }); +#endif QObject::connect(flameshot, &Flameshot::captureFailed, []() { AbstractLogger::info() << "Screenshot aborted."; qApp->exit(1);