Move initial auto-type timeout to plugins.

This commit is contained in:
Florian Geyer 2012-11-02 15:33:39 +01:00
parent 9144765d56
commit bd90ba9326
8 changed files with 18 additions and 6 deletions

View File

@ -34,7 +34,6 @@ AutoType* AutoType::m_instance = Q_NULLPTR;
AutoType::AutoType(QObject* parent, bool test)
: QObject(parent)
, m_test(test)
, m_inAutoType(false)
, m_pluginLoader(new QPluginLoader(this))
, m_plugin(Q_NULLPTR)
@ -133,9 +132,7 @@ void AutoType::performAutoType(const Entry* entry, QWidget* hideWindow, const QS
hideWindow->showMinimized();
}
if (!m_test) {
Tools::wait(500);
}
Tools::wait(m_plugin->initialTimeout());
if (!window) {
window = m_plugin->activeWindow();

View File

@ -69,7 +69,6 @@ private:
QString autoTypeSequence(const Entry* entry, const QString& windowTitle = QString());
bool windowMatches(const QString& windowTitle, const QString& windowPattern);
bool m_test;
bool m_inAutoType;
Qt::Key m_currentGlobalKey;
Qt::KeyboardModifiers m_currentGlobalModifiers;

View File

@ -32,6 +32,7 @@ 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 AutoTypeExecutor* createExecutor() = 0;

View File

@ -98,6 +98,10 @@ void AutoTypePlatformTest::addActionKey(AutoTypeKey* action)
m_actionChars.append(keyToString(action->key));
}
int AutoTypePlatformTest::initialTimeout()
{
return 0;
}
AutoTypeExecturorTest::AutoTypeExecturorTest(AutoTypePlatformTest* platform)
: m_platform(platform)

View File

@ -41,6 +41,7 @@ public:
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
int platformEventFilter(void* event);
int initialTimeout();
AutoTypeExecutor* createExecutor();
void setActiveWindowTitle(const QString& title);

View File

@ -798,4 +798,9 @@ void AutoTypeExecturorX11::execKey(AutoTypeKey* action)
m_platform->SendKeyPressedEvent(m_platform->keyToKeySym(action->key));
}
int AutoTypePlatformX11::initialTimeout()
{
return 500;
}
Q_EXPORT_PLUGIN2(keepassx-autotype-x11, AutoTypePlatformX11)

View File

@ -45,6 +45,7 @@ public:
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
int platformEventFilter(void* event);
int initialTimeout();
AutoTypeExecutor* createExecutor();
KeySym charToKeySym(const QChar& ch);

View File

@ -178,7 +178,11 @@ void sleep(int ms)
void wait(int ms)
{
Q_ASSERT(ms > 0);
Q_ASSERT(ms >= 0);
if (ms == 0) {
return;
}
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
QElapsedTimer timer;