Drop to background on copy feature

This commit is contained in:
Balazs Gyurak 2019-06-09 19:15:02 +01:00 committed by Jonathan White
parent d49e74c1f4
commit 8e248bbde6
9 changed files with 116 additions and 14 deletions

View File

@ -5,6 +5,7 @@
- Rework the Entry Preview panel [#3306]
- Move notes to General tab on Group Preview Panel [#3336]
- Add 'Monospaced font' option to the Notes field [#3321]
- Drop to background when copy feature [#3253]
2.4.3 (2019-06-12)
=========================

View File

@ -5,7 +5,9 @@ OpenPreviousDatabasesOnStartup=true
AutoSaveAfterEveryChange=false
AutoSaveOnExit=false
AutoReloadOnChange=true
MinimizeOnCopy=false
HideWindowOnCopy=false
MinimizeOnCopy=true
DropToBackgroundOnCopy=false
MinimizeOnOpenUrl=false
UseGroupIconOnEntryCreation=true
IgnoreGroupExpansion=false

View File

@ -106,6 +106,12 @@ void Config::upgrade()
if (m_settings->value("AutoSaveAfterEveryChange").toBool()) {
m_settings->setValue("AutoSaveOnExit", true);
}
// Setting defaults for 'hide window on copy' behavior, keeping the user's original setting
if (m_settings->value("HideWindowOnCopy").isNull()) {
m_settings->setValue("HideWindowOnCopy", m_settings->value("MinimizeOnCopy").toBool());
m_settings->setValue("MinimizeOnCopy", true);
}
}
Config::Config(const QString& fileName, QObject* parent)
@ -177,8 +183,11 @@ void Config::init(const QString& fileName)
m_defaults.insert("BackupBeforeSave", false);
m_defaults.insert("UseAtomicSaves", true);
m_defaults.insert("SearchLimitGroup", false);
m_defaults.insert("MinimizeOnCopy", false);
m_defaults.insert("MinimizeOnOpenUrl", false);
m_defaults.insert("HideWindowOnCopy", false);
m_defaults.insert("MinimizeOnCopy", true);
m_defaults.insert("DropToBackgroundOnCopy", false);
m_defaults.insert("UseGroupIconOnEntryCreation", false);
m_defaults.insert("AutoTypeEntryTitleMatch", true);
m_defaults.insert("AutoTypeEntryURLMatch", true);
m_defaults.insert("AutoTypeDelay", 25);

View File

@ -80,6 +80,7 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
// clang-format off
connect(m_generalUi->autoSaveAfterEveryChangeCheckBox, SIGNAL(toggled(bool)), SLOT(autoSaveToggled(bool)));
connect(m_generalUi->hideWindowOnCopyCheckBox, SIGNAL(toggled(bool)), SLOT(hideWindowOnCopyCheckBoxToggled(bool)));
connect(m_generalUi->systrayShowCheckBox, SIGNAL(toggled(bool)), SLOT(systrayToggled(bool)));
connect(m_generalUi->toolbarHideCheckBox, SIGNAL(toggled(bool)), SLOT(toolbarSettingsToggled(bool)));
connect(m_generalUi->rememberLastDatabasesCheckBox, SIGNAL(toggled(bool)), SLOT(rememberDatabasesToggled(bool)));
@ -147,13 +148,19 @@ void ApplicationSettingsWidget::loadSettings()
m_generalUi->backupBeforeSaveCheckBox->setChecked(config()->get("BackupBeforeSave").toBool());
m_generalUi->useAtomicSavesCheckBox->setChecked(config()->get("UseAtomicSaves").toBool());
m_generalUi->autoReloadOnChangeCheckBox->setChecked(config()->get("AutoReloadOnChange").toBool());
m_generalUi->minimizeOnCopyCheckBox->setChecked(config()->get("MinimizeOnCopy").toBool());
m_generalUi->minimizeOnOpenUrlCheckBox->setChecked(config()->get("MinimizeOnOpenUrl").toBool());
m_generalUi->hideWindowOnCopyCheckBox->setChecked(config()->get("HideWindowOnCopy").toBool());
m_generalUi->minimizeOnCopyRadioButton->setChecked(config()->get("MinimizeOnCopy").toBool());
m_generalUi->dropToBackgroundOnCopyRadioButton->setChecked(config()->get("DropToBackgroundOnCopy").toBool());
m_generalUi->useGroupIconOnEntryCreationCheckBox->setChecked(config()->get("UseGroupIconOnEntryCreation").toBool());
m_generalUi->autoTypeEntryTitleMatchCheckBox->setChecked(config()->get("AutoTypeEntryTitleMatch").toBool());
m_generalUi->autoTypeEntryURLMatchCheckBox->setChecked(config()->get("AutoTypeEntryURLMatch").toBool());
m_generalUi->ignoreGroupExpansionCheckBox->setChecked(config()->get("IgnoreGroupExpansion").toBool());
if (!m_generalUi->hideWindowOnCopyCheckBox->isChecked()) {
hideWindowOnCopyCheckBoxToggled(false);
}
m_generalUi->languageComboBox->clear();
QList<QPair<QString, QString>> languages = Translator::availableLanguages();
for (const auto& language : languages) {
@ -248,8 +255,10 @@ void ApplicationSettingsWidget::saveSettings()
config()->set("BackupBeforeSave", m_generalUi->backupBeforeSaveCheckBox->isChecked());
config()->set("UseAtomicSaves", m_generalUi->useAtomicSavesCheckBox->isChecked());
config()->set("AutoReloadOnChange", m_generalUi->autoReloadOnChangeCheckBox->isChecked());
config()->set("MinimizeOnCopy", m_generalUi->minimizeOnCopyCheckBox->isChecked());
config()->set("MinimizeOnOpenUrl", m_generalUi->minimizeOnOpenUrlCheckBox->isChecked());
config()->set("HideWindowOnCopy", m_generalUi->hideWindowOnCopyCheckBox->isChecked());
config()->set("MinimizeOnCopy", m_generalUi->minimizeOnCopyRadioButton->isChecked());
config()->set("DropToBackgroundOnCopy", m_generalUi->dropToBackgroundOnCopyRadioButton->isChecked());
config()->set("UseGroupIconOnEntryCreation", m_generalUi->useGroupIconOnEntryCreationCheckBox->isChecked());
config()->set("IgnoreGroupExpansion", m_generalUi->ignoreGroupExpansionCheckBox->isChecked());
config()->set("AutoTypeEntryTitleMatch", m_generalUi->autoTypeEntryTitleMatchCheckBox->isChecked());
@ -338,6 +347,12 @@ void ApplicationSettingsWidget::autoSaveToggled(bool checked)
m_generalUi->autoSaveOnExitCheckBox->setEnabled(!checked);
}
void ApplicationSettingsWidget::hideWindowOnCopyCheckBoxToggled(bool checked)
{
m_generalUi->minimizeOnCopyRadioButton->setEnabled(checked);
m_generalUi->dropToBackgroundOnCopyRadioButton->setEnabled(checked);
}
void ApplicationSettingsWidget::systrayToggled(bool checked)
{
m_generalUi->systrayDarkIconCheckBox->setEnabled(checked);

View File

@ -54,6 +54,7 @@ private slots:
void saveSettings();
void reject();
void autoSaveToggled(bool checked);
void hideWindowOnCopyCheckBoxToggled(bool checked);
void systrayToggled(bool checked);
void toolbarSettingsToggled(bool checked);
void rememberDatabasesToggled(bool checked);

View File

@ -249,9 +249,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="minimizeOnCopyCheckBox">
<widget class="QCheckBox" name="previewHideCheckBox">
<property name="text">
<string>Minimize when copying to clipboard</string>
<string>Hide the entry preview panel</string>
</property>
</widget>
</item>
@ -263,12 +263,72 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="previewHideCheckBox">
<widget class="QCheckBox" name="hideWindowOnCopyCheckBox">
<property name="text">
<string>Hide the entry preview panel</string>
<string>Hide window when copying to clipboard</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hideWindowLayout_1">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="hideWindowSpacer_1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="minimizeOnCopyRadioButton">
<property name="text">
<string>Minimize</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="hideWindowLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="hideWindowSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="dropToBackgroundOnCopyRadioButton">
<property name="text">
<string>Drop to background</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>

View File

@ -625,8 +625,12 @@ void DatabaseWidget::showTotpKeyQrCode()
void DatabaseWidget::setClipboardTextAndMinimize(const QString& text)
{
clipboard()->setText(text);
if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized();
if (config()->get("HideWindowOnCopy").toBool()) {
if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized();
} else if (config()->get("DropToBackgroundOnCopy").toBool()) {
window()->lower();
}
}
}

View File

@ -59,8 +59,13 @@ TotpDialog::~TotpDialog()
void TotpDialog::copyToClipboard()
{
clipboard()->setText(m_entry->totp());
if (config()->get("MinimizeOnCopy").toBool()) {
qobject_cast<DatabaseWidget*>(parent())->window()->showMinimized();
if (config()->get("HideWindowOnCopy").toBool()) {
if (config()->get("MinimizeOnCopy").toBool()) {
qobject_cast<DatabaseWidget*>(parent())->window()->showMinimized();
} else if (config()->get("DropToBackgroundOnCopy").toBool()) {
qobject_cast<DatabaseWidget*>(parent())->window()->lower();
window()->lower();
}
}
}

View File

@ -99,8 +99,13 @@ TotpExportSettingsDialog::TotpExportSettingsDialog(DatabaseWidget* parent, Entry
void TotpExportSettingsDialog::copyToClipboard()
{
clipboard()->setText(m_totpUri);
if (config()->get("MinimizeOnCopy").toBool()) {
static_cast<DatabaseWidget*>(parent())->window()->showMinimized();
if (config()->get("HideWindowOnCopy").toBool()) {
if (config()->get("MinimizeOnCopy").toBool()) {
static_cast<DatabaseWidget*>(parent())->window()->showMinimized();
} else if (config()->get("DropToBackgroundOnCopy").toBool()) {
static_cast<DatabaseWidget*>(parent())->window()->lower();
window()->lower();
}
}
}