rm -f bin/modules/lognet
rm -f bin/lognet
-bin_logker_SOURCES = src/kernel/kernel.cpp src/kernel/kernel.moc.cpp
+bin_logker_SOURCES = \
+ src/kernel/kernel.cpp \
+ src/kernel/kernel.moc.cpp \
+ src/kernel/lock.cpp
bin_logker_CPPFLAGS = $(bin_logker_CFLAGS)
bin_logker_LDADD = $(bin_logker_LIBS)
bin_logkerdir = src/kernel
bin_logker_HEADERS = \
- src/kernel/kernel.h
-src/kernel/kernel.moc.cpp: src/kernel/kernel.h src/kernel/kernelwindow.h
+ src/kernel/kernel.h \
+ src/kernel/lock.h
+src/kernel/kernel.moc.cpp: src/kernel/kernel.h src/kernel/kernelwindow.h src/kernel/lock_dialog.h
moc-qt4 src/kernel/kernel.h -o src/kernel/kernel.moc.cpp
# $(MOC) -i src/kernel/kernel.cpp -o src/kernel/kernel.moc
src/kernel/kernelwindow.h:
uic src/kernel/kernelwindow.ui -o src/kernel/kernelwindow.h
+src/kernel/lock_dialog.h:
+ uic src/kernel/lock_dialog.ui -o src/kernel/lock_dialog.h
+
clean-logker-extra:
rm -f src/kernel/*.moc
rm -f src/kernel/kernelwindow.h
+ rm -f src/kernel/lock_dialog.h
rm -f bin/logker
bin_logint_SOURCES = \
#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, "");
--- /dev/null
+#include <QtGui/QDialog>
+
+#include "lock.h"
+
+LockDialog::LockDialog(QWidget * parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+}
+
+LockDialog::~LockDialog()
+{
+}
+
+QString LockDialog::getPassword()
+{
+ return lineEdit->text();
+}
+
+void LockDialog::retype()
+{
+ label->setText("Retype");
+ lineEdit->setText("");
+}
--- /dev/null
+#ifndef _VLP_KERNEL_LOCKDIALOG_H
+#define _VLP_KERNEL_LOCKDIALOG_H
+
+#include <QtGui/QDialog>
+
+#include "lock_dialog.h"
+
+/**
+ * Lock Dialog class
+ */
+class LockDialog : public QDialog, private Ui::LockDialog {
+public:
+ LockDialog(QWidget * parent = 0);
+ ~LockDialog();
+
+ QString getPassword();
+ void retype();
+};
+
+#endif /* _VLP_KERNEL_LOCKDIALOG_H */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LockDialog</class>
+ <widget class="QDialog" name="LockDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>275</width>
+ <height>90</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Lock console</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
+ <property name="leftMargin">
+ <number>3</number>
+ </property>
+ <property name="topMargin">
+ <number>3</number>
+ </property>
+ <property name="rightMargin">
+ <number>3</number>
+ </property>
+ <property name="bottomMargin">
+ <number>3</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>LockDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>LockDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>