Add URL double-click action option to Settings (#12322)

* Closes #4717

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: juzu-o <3142026+juzu-o@users.noreply.github.com>
Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Juzu-O 2025-11-02 19:32:11 +02:00 committed by GitHub
parent a709f14cf3
commit 592d553ff8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 139 additions and 20 deletions

View file

@ -580,10 +580,6 @@
<source>Export settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open browser on double clicking URL field in entry view</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Font size:</source>
<translation type="unfinished"></translation>
@ -596,6 +592,26 @@
<source>Skip confirmation for main window Auto-Type actions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Double-click action for URL:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Double-click action for URL field</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Edit entry</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Open entry URL in browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Copy entry URL to clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Auto-generate password for new entries</source>
<translation type="unfinished"></translation>

View file

@ -67,6 +67,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::SearchLimitGroup,{QS("SearchLimitGroup"), Roaming, false}},
{Config::MinimizeOnOpenUrl,{QS("MinimizeOnOpenUrl"), Roaming, false}},
{Config::OpenURLOnDoubleClick, {QS("OpenURLOnDoubleClick"), Roaming, true}},
{Config::URLDoubleClickAction, {QS("URLDoubleClickAction"), Roaming, 0}},
{Config::HideWindowOnCopy,{QS("HideWindowOnCopy"), Roaming, false}},
{Config::MinimizeOnCopy,{QS("MinimizeOnCopy"), Roaming, true}},
{Config::AutoGeneratePasswordForNewEntries,{QS("AutoGeneratePasswordForNewEntries"), Roaming, false}},
@ -492,6 +493,15 @@ void Config::migrate()
remove(GUI_ListViewState);
}
// Migrate from boolean OpenURLOnDoubleClick to enum URLDoubleClickAction
if (m_settings->contains(configStrings[OpenURLOnDoubleClick].name)
&& !m_settings->contains(configStrings[URLDoubleClickAction].name)) {
bool openUrlOnDoubleClick = get(OpenURLOnDoubleClick).toBool();
// Convert: true (open browser) -> 0, false (edit entry) -> 2
set(URLDoubleClickAction, openUrlOnDoubleClick ? 0 : 2);
// Keep the old setting for now for compatibility
}
m_settings->setValue("ConfigVersion", CONFIG_VERSION);
sync();
}

View file

@ -50,6 +50,7 @@ public:
SearchLimitGroup,
MinimizeOnOpenUrl,
OpenURLOnDoubleClick,
URLDoubleClickAction,
HideWindowOnCopy,
MinimizeOnCopy,
MinimizeAfterUnlock,

View file

@ -211,7 +211,7 @@ void ApplicationSettingsWidget::loadSettings()
m_generalUi->autoReloadOnChangeCheckBox->setChecked(config()->get(Config::AutoReloadOnChange).toBool());
m_generalUi->minimizeAfterUnlockCheckBox->setChecked(config()->get(Config::MinimizeAfterUnlock).toBool());
m_generalUi->minimizeOnOpenUrlCheckBox->setChecked(config()->get(Config::MinimizeOnOpenUrl).toBool());
m_generalUi->openUrlOnDoubleClick->setChecked(config()->get(Config::OpenURLOnDoubleClick).toBool());
m_generalUi->urlDoubleClickComboBox->setCurrentIndex(config()->get(Config::URLDoubleClickAction).toInt());
m_generalUi->hideWindowOnCopyCheckBox->setChecked(config()->get(Config::HideWindowOnCopy).toBool());
hideWindowOnCopyCheckBoxToggled(m_generalUi->hideWindowOnCopyCheckBox->isChecked());
m_generalUi->minimizeOnCopyRadioButton->setChecked(config()->get(Config::MinimizeOnCopy).toBool());
@ -389,7 +389,7 @@ void ApplicationSettingsWidget::saveSettings()
config()->set(Config::AutoReloadOnChange, m_generalUi->autoReloadOnChangeCheckBox->isChecked());
config()->set(Config::MinimizeAfterUnlock, m_generalUi->minimizeAfterUnlockCheckBox->isChecked());
config()->set(Config::MinimizeOnOpenUrl, m_generalUi->minimizeOnOpenUrlCheckBox->isChecked());
config()->set(Config::OpenURLOnDoubleClick, m_generalUi->openUrlOnDoubleClick->isChecked());
config()->set(Config::URLDoubleClickAction, m_generalUi->urlDoubleClickComboBox->currentIndex());
config()->set(Config::HideWindowOnCopy, m_generalUi->hideWindowOnCopyCheckBox->isChecked());
config()->set(Config::MinimizeOnCopy, m_generalUi->minimizeOnCopyRadioButton->isChecked());
config()->set(Config::DropToBackgroundOnCopy, m_generalUi->dropToBackgroundOnCopyRadioButton->isChecked());

View file

@ -554,14 +554,59 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="openUrlOnDoubleClick">
<property name="text">
<string>Open browser on double clicking URL field in entry view</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<layout class="QHBoxLayout" name="urlDoubleClickLayout">
<item>
<widget class="QLabel" name="urlDoubleClickLabel">
<property name="text">
<string>Double-click action for URL:</string>
</property>
<property name="buddy">
<cstring>urlDoubleClickComboBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="urlDoubleClickComboBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="accessibleName">
<string>Double-click action for URL field</string>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Open entry URL in browser</string>
</property>
</item>
<item>
<property name="text">
<string>Copy entry URL to clipboard</string>
</property>
</item>
<item>
<property name="text">
<string>Edit entry</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="urlDoubleClickSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="useGroupIconOnEntryCreationCheckBox">
@ -1439,7 +1484,7 @@
<tabstop>alternativeSaveComboBox</tabstop>
<tabstop>ConfirmMoveEntryToRecycleBinCheckBox</tabstop>
<tabstop>EnableCopyOnDoubleClickCheckBox</tabstop>
<tabstop>openUrlOnDoubleClick</tabstop>
<tabstop>urlDoubleClickComboBox</tabstop>
<tabstop>useGroupIconOnEntryCreationCheckBox</tabstop>
<tabstop>minimizeOnOpenUrlCheckBox</tabstop>
<tabstop>hideWindowOnCopyCheckBox</tabstop>

View file

@ -1583,12 +1583,21 @@ void DatabaseWidget::entryActivationSignalReceived(Entry* entry, EntryModel::Mod
// case EntryModel::Attachments:
// break;
case EntryModel::Url:
if (!entry->url().isEmpty() && config()->get(Config::OpenURLOnDoubleClick).toBool()) {
openUrlForEntry(entry);
break;
if (!entry->url().isEmpty()) {
switch (config()->get(Config::URLDoubleClickAction).toInt()) {
case 2: // Edit entry
switchToEntryEdit(entry);
break;
case 1: // Copy entry URL to clipboard
setClipboardTextAndMinimize(entry->resolveMultiplePlaceholders(entry->url()));
break;
case 0: // Open entry URL in browser (default)
default:
openUrlForEntry(entry);
break;
}
}
// Note, order matters here. We want to fall into the default case.
[[fallthrough]];
break;
default:
switchToEntryEdit(entry);
}

View file

@ -17,6 +17,7 @@
#include "TestConfig.h"
#include <QSettings>
#include <QTest>
#include "config-keepassx-tests.h"
@ -40,3 +41,39 @@ void TestConfig::testUpgrade()
tempFile.remove();
}
void TestConfig::testURLDoubleClickMigration()
{
// Test migration from OpenURLOnDoubleClick to URLDoubleClickAction
TemporaryFile tempFile;
tempFile.open();
// Create a config with old setting = true (open browser)
QSettings oldConfig(tempFile.fileName(), QSettings::IniFormat);
oldConfig.setValue("OpenURLOnDoubleClick", true);
oldConfig.sync();
tempFile.close();
Config::createConfigFromFile(tempFile.fileName());
// Should migrate to URLDoubleClickAction = 0 (open browser)
QCOMPARE(config()->get(Config::URLDoubleClickAction).toInt(), 0);
tempFile.remove();
// Test migration from OpenURLOnDoubleClick = false (edit entry)
TemporaryFile tempFile2;
tempFile2.open();
QSettings oldConfig2(tempFile2.fileName(), QSettings::IniFormat);
oldConfig2.setValue("OpenURLOnDoubleClick", false);
oldConfig2.sync();
tempFile2.close();
Config::createConfigFromFile(tempFile2.fileName());
// Should migrate to URLDoubleClickAction = 2 (edit entry)
QCOMPARE(config()->get(Config::URLDoubleClickAction).toInt(), 2);
tempFile2.remove();
}

View file

@ -25,6 +25,7 @@ class TestConfig : public QObject
Q_OBJECT
private slots:
void testUpgrade();
void testURLDoubleClickMigration();
};
#endif // KEEPASSX_TESTCONFIG_H