summaryrefslogtreecommitdiffstats
path: root/src/loginform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/loginform.cpp')
-rw-r--r--src/loginform.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/src/loginform.cpp b/src/loginform.cpp
index b8db5cf..5faa617 100644
--- a/src/loginform.cpp
+++ b/src/loginform.cpp
@@ -7,6 +7,18 @@
* It is distributed under the LGPL 2.1 or later license.
* Please refer to the LICENSE file for a copy of the license.
*/
+
+#include "loginform.h"
+#include "ui_loginform.h"
+#include "settings.h"
+#include "global.h"
+#include "namereplace.h"
+#include "x11util.h"
+#undef KeyPress
+#undef KeyRelease
+#undef FocusIn
+#undef FocusOut
+
#include <QAbstractListModel>
#include <QModelIndex>
#include <QPixmap>
@@ -15,19 +27,15 @@
#include <QMenu>
#include <QListView>
#include <QSvgRenderer>
+#include <QX11Info>
#include <iostream>
-#include "loginform.h"
-#include "ui_loginform.h"
-#include "settings.h"
-#include "global.h"
-#include "namereplace.h"
-
LoginForm::LoginForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::LoginForm),
- clearMsg(false)
+ clearMsg(false),
+ capsOn(-1)
{
ui->setupUi(this);
initialize();
@@ -101,6 +109,24 @@ void LoginForm::initialize()
ui->leaveComboBox->setDisabled(ui->leaveComboBox->count() <= 1);
ui->passwordInput->clear();
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
+ this->installEventFilter(this);
+ checkCaps();
+}
+
+void LoginForm::checkCaps()
+{
+ unsigned int mask = getKeyMask(QX11Info::display());
+ int caps = (mask & 1) == 1;
+ if (caps != capsOn) {
+ capsOn = caps;
+ QString message(tr("!! CAPS LOCK ACTIVE !!"));
+ if (caps) {
+ ui->messageLabel->setProperty("caps", message);
+ showMessage(message, false);
+ } else if (ui->messageLabel->property("caps").toString() == message) {
+ hideMessage();
+ }
+ }
}
void LoginForm::startAuthentication()
@@ -241,3 +267,10 @@ void LoginForm::keyPressEvent(QKeyEvent *event)
QWidget::keyPressEvent(event);
}
+bool LoginForm::eventFilter(QObject *object, QEvent *event)
+{
+ if (event->type() == QEvent::KeyRelease) {
+ checkCaps();
+ }
+ return false;
+}