mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add global shortcut widget to SettingsWidget and register shortcut on startup.
This commit is contained in:
parent
d3af39a7ae
commit
288fa732ca
@ -21,6 +21,7 @@
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
@ -52,6 +53,7 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int)));
|
||||
connect(this, SIGNAL(currentChanged(int)), SLOT(emitEntrySelectionChanged()));
|
||||
connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType()));
|
||||
}
|
||||
|
||||
DatabaseTabWidget::~DatabaseTabWidget()
|
||||
@ -604,3 +606,8 @@ void DatabaseTabWidget::connectDatabase(Database* newDb, Database* oldDb)
|
||||
connect(newDb, SIGNAL(modified()), SLOT(modified()));
|
||||
newDb->setEmitModified(true);
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::performGlobalAutoType()
|
||||
{
|
||||
autoType()->performGlobalAutoType(m_dbList.keys());
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ public Q_SLOTS:
|
||||
void deleteGroup();
|
||||
void toggleSearch();
|
||||
bool readOnly(int index = -1);
|
||||
void performGlobalAutoType();
|
||||
|
||||
Q_SIGNALS:
|
||||
void entrySelectionChanged(bool singleEntrySelected);
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include <QtGui/QCloseEvent>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/DataPath.h"
|
||||
#include "core/Metadata.h"
|
||||
@ -37,6 +39,13 @@ MainWindow::MainWindow()
|
||||
toggleViewAction->setText(tr("Show toolbar"));
|
||||
m_ui->menuView->addAction(toggleViewAction);
|
||||
|
||||
Qt::Key globalAutoTypeKey = static_cast<Qt::Key>(config()->get("GlobalAutoTypeKey").toInt());
|
||||
Qt::KeyboardModifiers globalAutoTypeModifiers = static_cast<Qt::KeyboardModifiers>(
|
||||
config()->get("GlobalAutoTypeModifiers").toInt());
|
||||
if (globalAutoTypeKey > 0 && globalAutoTypeModifiers > 0) {
|
||||
autoType()->registerGlobalShortcut(globalAutoTypeKey, globalAutoTypeModifiers);
|
||||
}
|
||||
|
||||
setShortcut(m_ui->actionDatabaseOpen, QKeySequence::Open, Qt::CTRL + Qt::Key_O);
|
||||
setShortcut(m_ui->actionDatabaseSave, QKeySequence::Save, Qt::CTRL + Qt::Key_S);
|
||||
setShortcut(m_ui->actionDatabaseSaveAs, QKeySequence::SaveAs);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ui_SettingsWidgetGeneral.h"
|
||||
#include "ui_SettingsWidgetSecurity.h"
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Config.h"
|
||||
|
||||
SettingsWidget::SettingsWidget(QWidget* parent)
|
||||
@ -55,6 +56,13 @@ void SettingsWidget::loadSettings()
|
||||
m_generalUi->modifiedExpandedChangedCheckBox->setChecked(config()->get("ModifiedOnExpandedStateChanges").toBool());
|
||||
m_generalUi->autoSaveAfterEveryChangeCheckBox->setChecked(config()->get("AutoSaveAfterEveryChange").toBool());
|
||||
m_generalUi->autoSaveOnExitCheckBox->setChecked(config()->get("AutoSaveOnExit").toBool());
|
||||
|
||||
m_globalAutoTypeKey = static_cast<Qt::Key>(config()->get("GlobalAutoTypeKey").toInt());
|
||||
m_globalAutoTypeModifiers = static_cast<Qt::KeyboardModifiers>(config()->get("GlobalAutoTypeModifiers").toInt());
|
||||
if (m_globalAutoTypeKey > 0 && m_globalAutoTypeModifiers > 0) {
|
||||
m_generalUi->autoTypeShortcutWidget->setShortcut(m_globalAutoTypeKey, m_globalAutoTypeModifiers);
|
||||
}
|
||||
|
||||
m_secUi->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool());
|
||||
m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt());
|
||||
|
||||
@ -67,6 +75,8 @@ void SettingsWidget::saveSettings()
|
||||
config()->set("ModifiedOnExpandedStateChanges", m_generalUi->modifiedExpandedChangedCheckBox->isChecked());
|
||||
config()->set("AutoSaveAfterEveryChange", m_generalUi->autoSaveAfterEveryChangeCheckBox->isChecked());
|
||||
config()->set("AutoSaveOnExit", m_generalUi->autoSaveOnExitCheckBox->isChecked());
|
||||
config()->set("GlobalAutoTypeKey", m_generalUi->autoTypeShortcutWidget->key());
|
||||
config()->set("GlobalAutoTypeModifiers", static_cast<int>(m_generalUi->autoTypeShortcutWidget->modifiers()));
|
||||
config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked());
|
||||
config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value());
|
||||
|
||||
@ -75,6 +85,11 @@ void SettingsWidget::saveSettings()
|
||||
|
||||
void SettingsWidget::reject()
|
||||
{
|
||||
// register the old key again as it might have changed
|
||||
if (m_globalAutoTypeKey > 0 && m_globalAutoTypeModifiers > 0) {
|
||||
autoType()->registerGlobalShortcut(m_globalAutoTypeKey, m_globalAutoTypeModifiers);
|
||||
}
|
||||
|
||||
Q_EMIT editFinished(false);
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ private:
|
||||
QWidget* const m_generalWidget;
|
||||
const QScopedPointer<Ui::SettingsWidgetSecurity> m_secUi;
|
||||
const QScopedPointer<Ui::SettingsWidgetGeneral> m_generalUi;
|
||||
Qt::Key m_globalAutoTypeKey;
|
||||
Qt::KeyboardModifiers m_globalAutoTypeModifiers;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_SETTINGSWIDGET_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>354</width>
|
||||
<height>104</height>
|
||||
<width>456</width>
|
||||
<height>146</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
@ -45,8 +45,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Global Auto-Type shortcut</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="ShortcutWidget" name="autoTypeShortcutWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ShortcutWidget</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>autotype/ShortcutWidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user