aboutsummaryrefslogtreecommitdiff
path: root/oshelper.cpp
diff options
context:
space:
mode:
authorselsta <selsta@sent.at>2019-07-01 11:44:33 +0200
committerselsta <selsta@sent.at>2019-07-15 00:05:10 +0200
commit35a0f25b5702a13696aec4bc679d0c25b576ca17 (patch)
treee96eb040cbba6b8177e86a6d92d458116b6eaf30 /oshelper.cpp
parentc7956f76ead2c82a320c830a63ffa97d55a10bb6 (diff)
downloadmonzero-gui-35a0f25b5702a13696aec4bc679d0c25b576ca17.tar.gz
monzero-gui-35a0f25b5702a13696aec4bc679d0c25b576ca17.tar.xz
monzero-gui-35a0f25b5702a13696aec4bc679d0c25b576ca17.zip
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.
Diffstat (limited to 'oshelper.cpp')
-rw-r--r--oshelper.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/oshelper.cpp b/oshelper.cpp
index 36a3c866..d3e4d063 100644
--- a/oshelper.cpp
+++ b/oshelper.cpp
@@ -31,6 +31,20 @@
#include <QDir>
#include <QDebug>
#include <QString>
+#ifdef Q_OS_MAC
+#include "qt/macoshelper.h"
+#endif
+#ifdef Q_OS_WIN32
+#include <windows.h>
+#endif
+#ifdef Q_OS_LINUX
+#include <X11/XKBlib.h>
+#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();