diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 1408415b07..0bae50f681 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -14,7 +14,6 @@ #include "src/utils/globalvalues.h" #include "src/utils/pathinfo.h" #include -#include #include #include #include @@ -22,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index 9a4d4530be..a9e5b14b5e 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -47,13 +47,14 @@ GeneralConf::GeneralConf(QWidget* parent) initUploadWithoutConfirmation(); initUseJpgForClipboard(); initSaveAfterCopy(); - inituploadHistoryMax(); + initUploadHistoryMax(); initUndoLimit(); initAllowMultipleGuiInstances(); #if !defined(Q_OS_WIN) initAutoCloseIdleDaemon(); #endif initPredefinedColorPaletteLarge(); + initCopyOnDoubleClick(); m_layout->addStretch(); @@ -395,6 +396,16 @@ void GeneralConf::initPredefinedColorPaletteLarge() ConfigHandler().setPredefinedColorPaletteLarge(checked); }); } +void GeneralConf::initCopyOnDoubleClick() +{ + m_copyOnDoubleClick = new QCheckBox(tr("Copy on double click"), this); + m_copyOnDoubleClick->setToolTip(tr("Enable Copy on Double Click")); + m_scrollAreaLayout->addWidget(m_copyOnDoubleClick); + + connect(m_copyOnDoubleClick, &QCheckBox::clicked, [](bool checked) { + ConfigHandler().setCopyOnDoubleClick(checked); + }); +} void GeneralConf::initCopyAndCloseAfterUpload() { @@ -484,7 +495,7 @@ void GeneralConf::historyConfirmationToDelete(bool checked) ConfigHandler().setHistoryConfirmationToDelete(checked); } -void GeneralConf::inituploadHistoryMax() +void GeneralConf::initUploadHistoryMax() { auto* box = new QGroupBox(tr("Latest Uploads Max Size")); box->setFlat(true); diff --git a/src/config/generalconf.h b/src/config/generalconf.h index 1c8c2cf1fa..787abb6580 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -46,29 +46,30 @@ private slots: private: const QString chooseFolder(const QString currentPath = ""); - void initScrollArea(); - void initShowHelp(); - void initShowSidePanelButton(); - void initShowDesktopNotification(); - void initShowTrayIcon(); - void initHistoryConfirmationToDelete(); - void inituploadHistoryMax(); - void initUndoLimit(); - void initConfigButtons(); - void initCheckForUpdates(); void initAllowMultipleGuiInstances(); + void initAntialiasingPinZoom(); void initAutoCloseIdleDaemon(); void initAutostart(); - void initShowStartupLaunchMessage(); + void initCheckForUpdates(); + void initConfigButtons(); void initCopyAndCloseAfterUpload(); - void initSaveAfterCopy(); + void initCopyOnDoubleClick(); void initCopyPathAfterSave(); - void initAntialiasingPinZoom(); - void initUseJpgForClipboard(); - void initUploadWithoutConfirmation(); + void initHistoryConfirmationToDelete(); void initPredefinedColorPaletteLarge(); + void initSaveAfterCopy(); + void initScrollArea(); + void initShowDesktopNotification(); + void initShowHelp(); void initShowMagnifier(); + void initShowSidePanelButton(); + void initShowStartupLaunchMessage(); + void initShowTrayIcon(); void initSquareMagnifier(); + void initUndoLimit(); + void initUploadWithoutConfirmation(); + void initUseJpgForClipboard(); + void initUploadHistoryMax(); void _updateComponents(bool allowEmptySavePath); @@ -104,4 +105,5 @@ private slots: QCheckBox* m_predefinedColorPaletteLarge; QCheckBox* m_showMagnifier; QCheckBox* m_squareMagnifier; + QCheckBox* m_copyOnDoubleClick; }; diff --git a/src/config/shortcutswidget.cpp b/src/config/shortcutswidget.cpp index ffe57b3432..39acc28012 100644 --- a/src/config/shortcutswidget.cpp +++ b/src/config/shortcutswidget.cpp @@ -162,8 +162,10 @@ void ShortcutsWidget::loadShortcuts() QString shortcutName = QVariant::fromValue(t).toString(); appendShortcut(shortcutName, tool->description()); if (shortcutName == "TYPE_COPY") { - m_shortcuts << (QStringList() << "" << tool->description() - << "Left Double-click"); + if (m_config.copyOnDoubleClick()) { + m_shortcuts << (QStringList() << "" << tool->description() + << "Left Double-click"); + } } delete tool; } diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 64fe0a215d..b8a707661b 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -122,6 +122,7 @@ static QMap> OPTION("predefinedColorPaletteLarge", Bool ( PREDEFINED_COLOR_PALETTE_LARGE )), // NOTE: If another tool size is added besides drawThickness and // drawFontSize, remember to update ConfigHandler::toolSize + OPTION("copyOnDoubleClick" ,Bool ( false )), }; static QMap> recognizedShortcuts = { diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 00248b19b9..5e80868a36 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -117,6 +117,7 @@ class ConfigHandler : public QObject CONFIG_GETTER_SETTER(buttons, setButtons, QList) CONFIG_GETTER_SETTER(showMagnifier, setShowMagnifier, bool) CONFIG_GETTER_SETTER(squareMagnifier, setSquareMagnifier, bool) + CONFIG_GETTER_SETTER(copyOnDoubleClick, setCopyOnDoubleClick, bool) // SPECIAL CASES bool startupLaunch(); diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 642445ae3d..1e86fbf329 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -673,13 +673,16 @@ void CaptureWidget::mouseDoubleClickEvent(QMouseEvent* event) m_panel->setToolWidget(m_activeTool->configurationWidget()); } } else if (m_selection->geometry().contains(event->pos())) { - CopyTool copyTool; - connect(©Tool, - &CopyTool::requestAction, - this, - &CaptureWidget::handleToolSignal); - copyTool.pressed(m_context); - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + if ((event->button() == Qt::LeftButton) && + (m_config.copyOnDoubleClick())) { + CopyTool copyTool; + connect(©Tool, + &CopyTool::requestAction, + this, + &CaptureWidget::handleToolSignal); + copyTool.pressed(m_context); + qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + } } }