Configurable global autotype start delay

This commit is contained in:
Jonathan White 2018-05-05 23:29:25 -04:00 committed by Janek Bevendorff
parent 48295efe0d
commit 9ed2a74421
13 changed files with 47 additions and 35 deletions

View File

@ -220,7 +220,7 @@ void AutoType::executeAutoTypeActions(const Entry* entry, QWidget* hideWindow, c
#endif
}
Tools::wait(m_plugin->initialTimeout());
Tools::wait(qMax(100, config()->get("AutoTypeStartDelay", 500).toInt()));
if (!window) {
window = m_plugin->activeWindow();
@ -365,7 +365,7 @@ bool AutoType::parseActions(const QString& actionSequence, const Entry* entry, Q
{
QString tmpl;
bool inTmpl = false;
m_autoTypeDelay = config()->get("AutoTypeDelay").toInt();
m_autoTypeDelay = qMax(config()->get("AutoTypeDelay").toInt(), 0);
QString sequence = actionSequence;
sequence.replace("{{}", "{LEFTBRACE}");

View File

@ -33,7 +33,6 @@ public:
virtual bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) = 0;
virtual void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) = 0;
virtual int platformEventFilter(void* event) = 0;
virtual int initialTimeout() = 0;
virtual bool raiseWindow(WId window) = 0;
virtual void unload() {}

View File

@ -154,11 +154,6 @@ AutoTypeExecutor* AutoTypePlatformMac::createExecutor()
return new AutoTypeExecutorMac(this);
}
int AutoTypePlatformMac::initialTimeout()
{
return 500;
}
//
// Activate window by process id
//

View File

@ -42,7 +42,6 @@ public:
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
int platformEventFilter(void* event) override;
int initialTimeout() override;
bool raiseWindow(WId pid) override;
AutoTypeExecutor* createExecutor() override;

View File

@ -103,11 +103,6 @@ void AutoTypePlatformTest::addActionKey(AutoTypeKey* action)
m_actionChars.append(keyToString(action->key));
}
int AutoTypePlatformTest::initialTimeout()
{
return 0;
}
bool AutoTypePlatformTest::raiseWindow(WId window)
{
Q_UNUSED(window);

View File

@ -42,7 +42,6 @@ public:
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
int platformEventFilter(void* event) override;
int initialTimeout() override;
bool raiseWindow(WId window) override;
AutoTypeExecutor* createExecutor() override;

View File

@ -109,11 +109,6 @@ AutoTypeExecutor* AutoTypePlatformWin::createExecutor()
return new AutoTypeExecutorWin(this);
}
int AutoTypePlatformWin::initialTimeout()
{
return 500;
}
//
// Set foreground window
//

View File

@ -39,7 +39,6 @@ public:
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
int platformEventFilter(void* event) override;
int initialTimeout() override;
bool raiseWindow(WId window) override;
AutoTypeExecutor* createExecutor() override;

View File

@ -844,12 +844,6 @@ void AutoTypeExecutorX11::execClearField(AutoTypeClearField* action = nullptr)
nanosleep(&ts, nullptr);
}
int AutoTypePlatformX11::initialTimeout()
{
return 500;
}
bool AutoTypePlatformX11::raiseWindow(WId window)
{
if (m_atomNetActiveWindow == None) {

View File

@ -51,7 +51,6 @@ public:
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) override;
int platformEventFilter(void* event) override;
int initialTimeout() override;
bool raiseWindow(WId window) override;
AutoTypeExecutor* createExecutor() override;

View File

@ -135,6 +135,7 @@ void Config::init(const QString& fileName)
m_defaults.insert("AutoTypeEntryTitleMatch", true);
m_defaults.insert("AutoTypeEntryURLMatch", true);
m_defaults.insert("AutoTypeDelay", 25);
m_defaults.insert("AutoTypeStartDelay", 500);
m_defaults.insert("UseGroupIconOnEntryCreation", true);
m_defaults.insert("IgnoreGroupExpansion", true);
m_defaults.insert("security/clearclipboard", true);

View File

@ -152,6 +152,7 @@ void SettingsWidget::loadSettings()
}
m_generalUi->autoTypeShortcutWidget->setAttribute(Qt::WA_MacShowFocusRect, true);
m_generalUi->autoTypeDelaySpinBox->setValue(config()->get("AutoTypeDelay").toInt());
m_generalUi->autoTypeStartDelaySpinBox->setValue(config()->get("AutoTypeStartDelay").toInt());
}
@ -227,6 +228,7 @@ void SettingsWidget::saveSettings()
config()->set("GlobalAutoTypeModifiers",
static_cast<int>(m_generalUi->autoTypeShortcutWidget->modifiers()));
config()->set("AutoTypeDelay", m_generalUi->autoTypeDelaySpinBox->value());
config()->set("AutoTypeStartDelay", m_generalUi->autoTypeStartDelaySpinBox->value());
}
config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked());
config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value());

View File

@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="generalSettingsTabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="title">
@ -404,7 +404,7 @@
<number>10</number>
</property>
<item row="1" column="0">
<widget class="QLabel" name="autoTypeShortcutLabel_2">
<widget class="QLabel" name="autoTypeShortcutLabel">
<property name="text">
<string>Global Auto-Type shortcut</string>
</property>
@ -420,14 +420,14 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="autoTypeDelayLabel_2">
<item row="3" column="0">
<widget class="QLabel" name="autoTypeDelayLabel">
<property name="text">
<string>Auto-Type delay</string>
<string>Auto-Type typing delay</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QSpinBox" name="autoTypeDelaySpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@ -442,13 +442,48 @@
<string/>
</property>
<property name="maximum">
<number>999</number>
<number>1000</number>
</property>
<property name="value">
<number>25</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="autoTypeStartDelayLabel">
<property name="text">
<string>Auto-Type start delay</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="autoTypeStartDelaySpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string comment="Milliseconds"> ms</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>500</number>
</property>
</widget>
</item>
</layout>
</item>
<item>