From 35a0f25b5702a13696aec4bc679d0c25b576ca17 Mon Sep 17 00:00:00 2001 From: selsta Date: Mon, 1 Jul 2019 11:44:33 +0200 Subject: PasswordDialog: merge components and bug fixes This commit merges PasswordDialog, PassphraseDialog and NewPasswordDialog. Also the following bugs were fixed: - Wizard pages still being active when opening a wallet from wizard. - Capslock detection was buggy when copy pasting password, I replaced it with native implementations for each platform. - isAlpha could throw errors when using special characters. --- oshelper.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'oshelper.cpp') diff --git a/oshelper.cpp b/oshelper.cpp index 36a3c866..d3e4d063 100644 --- a/oshelper.cpp +++ b/oshelper.cpp @@ -31,6 +31,20 @@ #include #include #include +#ifdef Q_OS_MAC +#include "qt/macoshelper.h" +#endif +#ifdef Q_OS_WIN32 +#include +#endif +#ifdef Q_OS_LINUX +#include +#undef KeyPress +#undef KeyRelease +#undef FocusIn +#undef FocusOut +// #undef those Xlib #defines that conflict with QEvent::Type enum +#endif OSHelper::OSHelper(QObject *parent) : QObject(parent) { @@ -58,6 +72,27 @@ bool OSHelper::removeTemporaryWallet(const QString &fileName) const return cache_deleted && address_deleted && keys_deleted; } +// https://stackoverflow.com/a/3006934 +bool OSHelper::isCapsLock() const +{ + // platform dependent method of determining if CAPS LOCK is on +#if defined(Q_OS_WIN32) // MS Windows version + return GetKeyState(VK_CAPITAL) == 1; +#elif defined(Q_OS_LINUX) // X11 version + Display * d = XOpenDisplay((char*)0); + bool caps_state = false; + if (d) { + unsigned n; + XkbGetIndicatorState(d, XkbUseCoreKbd, &n); + caps_state = (n & 0x01) == 1; + } + return caps_state; +#elif defined(Q_OS_MAC) + return MacOSHelper::isCapsLock(); +#endif + return false; +} + QString OSHelper::temporaryPath() const { return QDir::tempPath(); -- cgit v1.2.3