#include <qfile.h>
#include <qcursor.h>
#include <QtCore/QSocketNotifier>
+#include <QtGui/QCloseEvent>
#include <qdir.h>
#include <stdio.h>
QAction * qid;
QAction * cwid;
QAction * optid;
- QAction * prid;
- QAction * mid;
+ QAction * programExecuteAction;
+ QAction * programKillAction;
+ QAction * machineMessageAction;
+ QAction * machineConnectAction;
+ QAction * machineDisconnectAction;
+ QAction * machineInfoAction;
QAction * msgid;
- QAction * toolsid;
QAction * hid;
int net_sock;
*/
void QKernel::closeEvent(QCloseEvent * e)
{
- QuitProc();
+ e->ignore();
+
+ if (!LOCKED) {
+ QuitProc();
+ }
}
/**
QMenu * programMenu = NULL;
programMenu = menuBar()->addMenu("&Program");
- programMenu->addAction("Execute", this, SLOT(Run_Prog()));
- programMenu->addAction("Kill", this, SLOT(KillInterpreter()));
-
+ programExecuteAction = programMenu->addAction("Execute", this, SLOT(Run_Prog()));
+ programKillAction = programMenu->addAction("Kill", this, SLOT(KillInterpreter()));
machineMenu = menuBar()->addMenu("&Machine");
- machineMenu->addAction("Message", this, SLOT(MessageToNode()));
+ machineMessageAction = machineMenu->addAction("Message", this, SLOT(MessageToNode()));
machineMenu->addSeparator();
- machineMenu->addAction("Connect", this, SLOT(Connect()));
- machineMenu->addAction("Disconnect", this, SLOT(Disconnect()));
- machineMenu->addAction("Info", this, SLOT(Info()));
+ machineConnectAction = machineMenu->addAction("Connect", this, SLOT(Connect()));
+ machineDisconnectAction = machineMenu->addAction("Disconnect", this, SLOT(Disconnect()));
+ machineInfoAction = machineMenu->addAction("Info", this, SLOT(Info()));
toolsMenu = menuBar()->addMenu("&Tools");
cwid = toolsMenu->addAction("Editor", this, SLOT(Edit()));
{
MESSAGE msg;
- if (QMessageBox::question(this, "Close VLP", "Terminate VLP ?",
- QMessageBox::Yes, QMessageBox::No, 0) == QMessageBox::No) {
+ QMessageBox::StandardButton response;
+ response = QMessageBox::question(this, "Close VLP", "Terminate VLP ?",
+ QMessageBox::Ok | QMessageBox::Cancel);
+
+
+ if (response == QMessageBox::Cancel) {
return;
}
-
- if (!LOCKED) {
- /*
- msg.msg_type = MSG_NET;
- msg.param.pword[0] = NET_DISCONNECT;
- write(net_sock, &msg, sizeof(MESSAGE));*/
- delete Net_Notify;
-
- msg.msg_type = MSG_NET;
- msg.param.pword[0] = NET_EXIT;
- write(net_sock, &msg, sizeof(MESSAGE));
- /* ::close(net_sock);*/
- app->quit();
- }
+ /*
+ msg.msg_type = MSG_NET;
+ msg.param.pword[0] = NET_DISCONNECT;
+ write(net_sock, &msg, sizeof(MESSAGE));*/
+ delete Net_Notify;
+
+ msg.msg_type = MSG_NET;
+ msg.param.pword[0] = NET_EXIT;
+ write(net_sock, &msg, sizeof(MESSAGE));
+ /* ::close(net_sock);*/
+ app->quit();
}
/**
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) {
- qid->setEnabled(FALSE);
- prid->setEnabled(FALSE);
- mid->setEnabled(FALSE);
+ if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
+ qid->setDisabled(TRUE);
+ programExecuteAction->setDisabled(TRUE);
+ programKillAction->setDisabled(TRUE);
+ machineMessageAction->setDisabled(TRUE);
+ machineConnectAction->setDisabled(TRUE);
+ machineDisconnectAction->setDisabled(TRUE);
+ machineInfoAction->setDisabled(TRUE);
+
unlockid->setEnabled(TRUE);
- lockid->setEnabled(FALSE);
- cwid->setEnabled(FALSE);
- optid->setEnabled(FALSE);
+ lockid->setDisabled(TRUE);
+ cwid->setDisabled(TRUE);
+ optid->setDisabled(TRUE);
WriteMessage("CONSOLE LOCKED");
LOCKED = TRUE;
} else {
if (d.exec()) {
if (strcmp(ed.text().toAscii().data(), LockPasswd) == 0) {
qid->setEnabled(TRUE);
- prid->setEnabled(TRUE);
- mid->setEnabled(TRUE);
+ programExecuteAction->setEnabled(TRUE);
+ programKillAction->setEnabled(TRUE);
+ machineMessageAction->setEnabled(TRUE);
+ machineConnectAction->setEnabled(TRUE);
+ machineDisconnectAction->setEnabled(TRUE);
+ machineInfoAction->setEnabled(TRUE);
unlockid->setEnabled(FALSE);
lockid->setEnabled(TRUE);
cwid->setEnabled(TRUE);
len = strlen(svr.sun_path)+sizeof(svr.sun_family);
bind(sock, (struct sockaddr*)&svr, len);
listen(sock, 5);
- system(cmd);
+ system(cmd);
newINT->sock = accept(sock, (struct sockaddr*)0, (unsigned int *)0);
//::close(sock);
O_NONBLOCK|fcntl(newINT->sock, F_GETFL, 0));
on=1;
setsockopt(newINT->sock, IPPROTO_TCP, TCP_NODELAY, (char*)&on,
- sizeof(on));
+ sizeof(on));
if (r)
newINT->remote = 1;
else
interp->RInstances[on] = m.param.pword[7];
break;
}
- read(net_sock, &m, sizeof(MESSAGE));
+ read(net_sock, &m, sizeof(MESSAGE));
}
Net_Notify->setEnabled(TRUE);