diff options
Diffstat (limited to 'oshelper.cpp')
| -rw-r--r-- | oshelper.cpp | 35 |
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(); |
