#include "kernel.h"
#include "kernelwindow.h"
+#include "lock.h"
/* File resides in top directory (where are Makefiles)*/
#include "../../config.h"
*/
void QKernel::on_actionLock_console_triggered()
{
- QDialog d(this, Qt::Dialog);
- d.setWindowTitle("Lock console");
-
- QPushButton ob("Ok", &d);
- ob.setGeometry(30, 60, 80, 30);
- ob.setDefault(TRUE);
- connect(&ob, SIGNAL(clicked()), &d, SLOT(accept()));
-
- QLabel lab("Password:", &d);
- lab.setGeometry(10, 10, 60, 30);
+ LockDialog lockDialog(this);
- QLineEdit ed("", &d);
- ed.setGeometry(70, 10, 140, 30);
- ed.setEchoMode(QLineEdit::Password);
+ if (lockDialog.exec()) {
+ QString password = lockDialog.getPassword();
+ if (lockDialog.getPassword().size() > 0) {
+ strcpy(LockPasswd, password.toAscii().data());
+ lockDialog.retype();
- QPushButton cb("Cancel", &d);
- cb.setGeometry(130, 60, 80, 30);
- connect(&cb, SIGNAL(clicked()), &d, SLOT(reject()));
-
- d.resize(240, 100);
-
- if (d.exec()) {
- if (strcmp(ed.text().toAscii().data(), "") != 0) {
- strcpy(LockPasswd, ed.text().toAscii().data());
- lab.setText("Retype:");
- ed.setText("");
- /*
- * Following exec(), could produce error:
- * X Error: BadWindow (invalid Window parameter) 3
- * Major opcode: 3 (X_GetWindowAttributes)
- *
- * This is not error in our code. Basing on:
- * https://bugreports.qt-project.org/browse/QTBUG-1782
- * this happens only on Qt 4.3 - 4.4.
- */
- if (d.exec()) {
- if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
+ if (lockDialog.exec()) {
+ password = lockDialog.getPassword();
+ if (password == LockPasswd) {
setLocked(TRUE);
WriteMessage("CONSOLE LOCKED");
} else {
msg.setText("Not matching!");
msg.setButtonText(0, "Close");
msg.show();
+ strcpy(LockPasswd, "");
}
} else {
strcpy(LockPasswd, "");