vlp-27 Moving kernel to use QtDesigner files. Important note: need to use uic-qt4...
authorRafał Długołęcki <kontakt@dlugolecki.net.pl>
Tue, 29 Oct 2013 20:38:09 +0000 (21:38 +0100)
committerRafał Długołęcki <kontakt@dlugolecki.net.pl>
Tue, 29 Oct 2013 20:38:09 +0000 (21:38 +0100)
Makefile.am
configure.ac
data/kernel/dialogs/connect.ui [new file with mode: 0644]
data/kernel/dialogs/kill-interpreter.ui [new file with mode: 0644]
data/kernel/dialogs/options.ui [new file with mode: 0644]
data/kernel/dialogs/send-message.ui [new file with mode: 0644]
data/kernel/main-window.ui [new file with mode: 0644]
src/kernel/kernel.cpp
src/kernel/kernel.h
src/kernel/send-message.h [new file with mode: 0644]

index 782199dad86ff50a309081978228acf91952971b..1dd212bb2e7acf7345c94f50db75436e4dceeb5b 100644 (file)
@@ -65,10 +65,32 @@ clean-lognet-extra:
 bin_logker_SOURCES = src/kernel/kernel.cpp src/kernel/kernel.moc.cpp
 bin_logker_CPPFLAGS = $(bin_logker_CFLAGS)
 bin_logker_LDADD = $(bin_logker_LIBS)
-bin_logkerdir = src/kernel
+bin_logkerdir = src/kernel src/kernel/ui src/kernel/ui/dialogs
 bin_logker_HEADERS = \
-       src/kernel/kernel.h
-src/kernel/kernel.moc.cpp: src/kernel/kernel.h
+       src/kernel/kernel.h \
+       src/kernel/ui/main-window.h \
+       src/kernel/ui/dialogs/connect.h \
+       src/kernel/ui/dialogs/options.h \
+       src/kernel/ui/dialogs/kill-interpreter.h \
+       src/kernel/ui/dialogs/send-message.h
+
+src/kernel/ui/main-window.h: data/kernel/main-window.ui
+       if [ ! -d src/kernel/ui ]; then mkdir -p src/kernel/ui; fi
+       uic-qt4 data/kernel/main-window.ui -o src/kernel/ui/main-window.h
+src/kernel/ui/dialogs/connect.h: data/kernel/dialogs/connect.ui
+       if [ ! -d src/kernel/ui/dialogs ]; then mkdir -p src/kernel/ui/dialogs; fi
+       uic-qt4 data/kernel/dialogs/connect.ui -o src/kernel/ui/dialogs/connect.h
+src/kernel/ui/dialogs/options.h: data/kernel/dialogs/options.ui
+       if [ ! -d src/kernel/ui/dialogs ]; then mkdir -p src/kernel/ui/dialogs; fi
+       uic-qt4 data/kernel/dialogs/options.ui -o src/kernel/ui/dialogs/options.h
+src/kernel/ui/dialogs/kill-interpreter.h: data/kernel/dialogs/kill-interpreter.ui
+       if [ ! -d src/kernel/ui/dialogs ]; then mkdir -p src/kernel/ui/dialogs; fi
+       uic-qt4 data/kernel/dialogs/kill-interpreter.ui -o src/kernel/ui/dialogs/kill-interpreter.h
+src/kernel/ui/dialogs/send-message.h: data/kernel/dialogs/send-message.ui
+       if [ ! -d src/kernel/ui/dialogs ]; then mkdir -p src/kernel/ui/dialogs; fi
+       uic-qt4 data/kernel/dialogs/send-message.ui -o src/kernel/ui/dialogs/send-message.h
+
+src/kernel/kernel.moc.cpp: $(bin_logker_HEADERS)
        moc-qt4 src/kernel/kernel.h -o src/kernel/kernel.moc.cpp
 #      $(MOC) -i src/kernel/kernel.cpp -o src/kernel/kernel.moc
        
index 859f94e9173d06220112a9f70b2de2f330718ec1..01ebe59cc960e630410cc2632d35996a8a8546a8 100644 (file)
@@ -13,7 +13,7 @@ AC_CONFIG_FILES([Makefile])
 # qt3-dev-tools:i386
 PKG_CHECK_MODULES([bin_loggraph], [qt-mt < 4.0])
 PKG_CHECK_MODULES([bin_lognet], [qt-mt < 4.0 libconfig])
-PKG_CHECK_MODULES([bin_logker], [QtCore >= 4.0 QtGui >= 4.0 libconfig])
+PKG_CHECK_MODULES([bin_logker], [QtCore >= 4.0 QtGui >= 4.0 QtUiTools libconfig])
 #PKG_CHECK_MODULES([bin_logint], [qt-mt < 4.0])
 PKG_CHECK_MODULES([bin_logedit], [QtCore >= 4.0 QtGui >= 4.0 ])
 PKG_CHECK_MODULES([bin_lgconfig], [qt-mt < 4.0 libconfig])
diff --git a/data/kernel/dialogs/connect.ui b/data/kernel/dialogs/connect.ui
new file mode 100644 (file)
index 0000000..f05d882
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>connectDialog</class>
+ <widget class="QDialog" name="connectDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>259</width>
+    <height>105</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Connect</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Address</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEdit"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/data/kernel/dialogs/kill-interpreter.ui b/data/kernel/dialogs/kill-interpreter.ui
new file mode 100644 (file)
index 0000000..433b023
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>killInterpreterDialog</class>
+ <widget class="QDialog" name="killInterpreterDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>383</width>
+    <height>45</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle">
+   <string>Kill interpreter</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout_2">
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Interp. ID</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLineEdit" name="lineEdit"/>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/data/kernel/dialogs/options.ui b/data/kernel/dialogs/options.ui
new file mode 100644 (file)
index 0000000..af16c99
--- /dev/null
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>optionsDialog</class>
+ <widget class="QDialog" name="optionsDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>412</width>
+    <height>308</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Options</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_8">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Programs directory</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEdit"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="Line" name="line">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Virtual Processor properties</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_7">
+      <item>
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_3">
+          <item>
+           <layout class="QHBoxLayout" name="horizontalLayout_3">
+            <item>
+             <widget class="QLabel" name="label_3">
+              <property name="text">
+               <string>Node number:</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QLineEdit" name="lineEdit_2"/>
+            </item>
+           </layout>
+          </item>
+          <item>
+           <widget class="QGroupBox" name="groupBox_2">
+            <property name="inputMethodHints">
+             <set>Qt::ImhExclusiveInputMask</set>
+            </property>
+            <property name="title">
+             <string>GroupBox</string>
+            </property>
+            <layout class="QVBoxLayout" name="verticalLayout_6">
+             <item>
+              <widget class="QRadioButton" name="explicit_2">
+               <property name="text">
+                <string>Explicit</string>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QRadioButton" name="registration">
+               <property name="text">
+                <string>Registration</string>
+               </property>
+              </widget>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_4">
+          <item>
+           <widget class="QLabel" name="label_4">
+            <property name="text">
+             <string>Connection list:</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QListView" name="listView"/>
+          </item>
+         </layout>
+        </item>
+        <item>
+         <layout class="QVBoxLayout" name="verticalLayout_5">
+          <item>
+           <widget class="QPushButton" name="addConnection">
+            <property name="text">
+             <string>Add</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="deleteConnection">
+            <property name="text">
+             <string>Del</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/data/kernel/dialogs/send-message.ui b/data/kernel/dialogs/send-message.ui
new file mode 100644 (file)
index 0000000..7238898
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>sendMessageDialog</class>
+ <widget class="QDialog" name="sendMessageDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>385</width>
+    <height>270</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Send message to node</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Node number</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="nodeNumber"/>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_2">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Message</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPlainTextEdit" name="message"/>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/data/kernel/main-window.ui b/data/kernel/main-window.ui
new file mode 100644 (file)
index 0000000..816ebb8
--- /dev/null
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>386</width>
+    <height>217</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <property name="enabled">
+    <bool>true</bool>
+   </property>
+   <property name="sizePolicy">
+    <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+     <horstretch>0</horstretch>
+     <verstretch>0</verstretch>
+    </sizepolicy>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <property name="spacing">
+     <number>0</number>
+    </property>
+    <property name="margin">
+     <number>0</number>
+    </property>
+    <item>
+     <widget class="QTextEdit" name="desktop">
+      <property name="enabled">
+       <bool>true</bool>
+      </property>
+      <property name="acceptDrops">
+       <bool>false</bool>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="acceptRichText">
+       <bool>false</bool>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>386</width>
+     <height>20</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuProgram">
+    <property name="title">
+     <string>Program</string>
+    </property>
+    <addaction name="actionExecute"/>
+    <addaction name="actionKill"/>
+   </widget>
+   <widget class="QMenu" name="menuMachine">
+    <property name="title">
+     <string>Machine</string>
+    </property>
+    <addaction name="actionMessage"/>
+    <addaction name="separator"/>
+    <addaction name="actionConnect"/>
+    <addaction name="actionDisconnect"/>
+    <addaction name="actionInfo"/>
+   </widget>
+   <widget class="QMenu" name="menuTools">
+    <property name="title">
+     <string>Tools</string>
+    </property>
+    <addaction name="actionEditor"/>
+    <addaction name="actionHelp"/>
+    <addaction name="separator"/>
+    <addaction name="actionOptions"/>
+    <addaction name="actionInfo_messages"/>
+    <addaction name="separator"/>
+    <addaction name="actionLock_Console"/>
+    <addaction name="actionUnlock_console"/>
+   </widget>
+   <addaction name="menuProgram"/>
+   <addaction name="menuMachine"/>
+   <addaction name="menuTools"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionExecute">
+   <property name="text">
+    <string>Execute</string>
+   </property>
+  </action>
+  <action name="actionKill">
+   <property name="text">
+    <string>Kill</string>
+   </property>
+  </action>
+  <action name="actionConnect">
+   <property name="text">
+    <string>Connect</string>
+   </property>
+  </action>
+  <action name="actionDisconnect">
+   <property name="text">
+    <string>Disconnect</string>
+   </property>
+  </action>
+  <action name="actionInfo">
+   <property name="text">
+    <string>Info</string>
+   </property>
+  </action>
+  <action name="actionEditor">
+   <property name="text">
+    <string>Editor</string>
+   </property>
+  </action>
+  <action name="actionHelp">
+   <property name="text">
+    <string>Help</string>
+   </property>
+  </action>
+  <action name="actionOptions">
+   <property name="text">
+    <string>Options</string>
+   </property>
+  </action>
+  <action name="actionInfo_messages">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="checked">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Info messages</string>
+   </property>
+  </action>
+  <action name="actionLock_Console">
+   <property name="text">
+    <string>Lock console</string>
+   </property>
+  </action>
+  <action name="actionUnlock_console">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="text">
+    <string>Unlock console</string>
+   </property>
+  </action>
+  <action name="actionMessage">
+   <property name="text">
+    <string>Message</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index d2521abafcf342c3e570cd9918c8a96c2417bccd..6c0f27c72c413cb164865d2671dcc2e667bc618c 100644 (file)
@@ -64,6 +64,7 @@
 #include <libconfig.h>
 
 #include "kernel.h"
+#include "send-message.h"
 
 /* File resides in top directory (where are Makefiles)*/
 #include "../../config.h"
@@ -91,27 +92,29 @@ void QKernel::setLocked(bool locked)
 {
        LOCKED = locked;
 
-       quitAction->setDisabled(locked);
-       programExecuteAction->setDisabled(locked);
-       programKillAction->setDisabled(locked);
-       machineMessageAction->setDisabled(locked);
-       machineConnectAction->setDisabled(locked);
-       machineDisconnectAction->setDisabled(locked);
-       machineInfoAction->setDisabled(locked);
+       actionExecute->setDisabled(locked);
+       actionKill->setDisabled(locked);
+       actionConnect->setDisabled(locked);
+       actionDisconnect->setDisabled(locked);
+       actionInfo_messages->setDisabled(locked);
+       actionMessage->setDisabled(locked);
 
        /* Enable only menu entry for unlocking */
-       toolsEditorAction->setDisabled(locked);
-       toolsOptionsAction->setDisabled(locked);
-       toolsLockAction->setDisabled(locked);
-       toolsUnlockAction->setEnabled(locked);
+       actionEditor->setDisabled(locked);
+       actionOptions->setDisabled(locked);
+       actionLock_Console->setDisabled(locked);
+       actionUnlock_console->setEnabled(locked);
 }
 
 /**
  * Kernel program constructor.
  * Prepares everything to work.
  */
-QKernel::QKernel()
+QKernel::QKernel(QWidget *parent)
+       : QMainWindow(parent)
 {
+       setupUi(this);
+
        QDir q(REMOTE_PATH);
        char ss[255];
 
@@ -125,45 +128,7 @@ QKernel::QKernel()
 
        setWindowTitle(PACKAGE_NAME);
 
-       QMenu * programMenu = NULL;
-       programMenu = menuBar()->addMenu("&Program");
-       programExecuteAction = programMenu->addAction("Execute", this, SLOT(Run_Prog()));
-       programKillAction = programMenu->addAction("Kill", this, SLOT(KillInterpreter()));
-
-       machineMenu = menuBar()->addMenu("&Machine");
-       machineMessageAction = machineMenu->addAction("Message", this, SLOT(MessageToNode()));
-       machineMenu->addSeparator();
-       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");
-       toolsEditorAction = toolsMenu->addAction("Editor", this, SLOT(Edit()));
-       toolsMenu->addAction("Help", this, SLOT(Help()));
-       toolsMenu->addSeparator(); 
-       toolsOptionsAction = toolsMenu->addAction("Options", this, SLOT(SetOptions()));
-       toolsInfoAction = toolsMenu->addAction("Info messages", this, SLOT(SetMessages()));
-       toolsInfoAction->setCheckable(TRUE);
-       toolsInfoAction->setChecked(TRUE);
-       toolsMenu->addSeparator();
-       toolsLockAction = toolsMenu->addAction("Lock console", this, SLOT(LockConsole()));
-       toolsUnlockAction = toolsMenu->addAction("Unlock console", this, 
-                                                       SLOT(UnlockConsole()));
-       toolsUnlockAction->setDisabled(TRUE);
        LOCKED = FALSE;
-
-       quitAction = menuBar()->addAction("&Quit", this, SLOT(QuitProc()));
-
-       desktop = new QTextEdit(this);
-       desktop->setReadOnly(TRUE);
-       QVBoxLayout * layout = new QVBoxLayout();
-       layout->setContentsMargins (3, 0, 3, 0);
-       layout->addWidget(desktop);
-       QWidget *window = new QWidget();
-       window->setLayout(layout);
-       setCentralWidget(window);
-
-       resize(400, 200);
        Tasks = 0;
        freeINTid = 1;
        ActiveConnections = 0;
@@ -175,18 +140,6 @@ QKernel::QKernel()
        connect(Net_Notify, SIGNAL(activated(int)), this, SLOT(NetMessage()));
 }
 
-/**
- * Event invoked on resizing kernel application window.
- * @copydoc QWidget::resizeEvent(QResizeEvent*)
- */
-void QKernel::resizeEvent(QResizeEvent *ev)
-{
-//     QFrame::resizeEvent(ev);
-//     if (desktop)
-//             desktop->setGeometry(0, bar->height(), width(), 
-//                                             height() - bar->height());
-}
-
 /**
  * Displays window with information about not implemented functionality.
  */
@@ -303,7 +256,7 @@ void QKernel::LoadConfig(char * fname)
  * Executes program.
  * Additional window id displayed to set which code to execute.
  */
-void QKernel::Run_Prog()
+void QKernel::on_actionExecute_triggered()
 {
        int i;
        QString s = QFileDialog::getOpenFileName(this, "Execute", progdir, "*.log");
@@ -321,7 +274,7 @@ void QKernel::Run_Prog()
 /**
  * Invokes editor program
  */
-void QKernel::Edit()
+void QKernel::on_actionEditor_triggered()
 {
        char cmd[255];
        sprintf(cmd, "%s/modules/logedit %s %s %s %s %s %s &", HomeDir, HomeDir, 
@@ -332,7 +285,7 @@ void QKernel::Edit()
 /**
  * Invokes help program
  */
-void QKernel::Help()
+void QKernel::on_actionHelp_triggered()
 {
        char cmd[255];
        sprintf(cmd, "%s/modules/loghelp %s/doc %s %s %s %s %s &", HomeDir,
@@ -405,7 +358,7 @@ void QKernel::RunNetModule()
  * Connects to the specified address
  * Additional window is displayed to connect to the specified address
  */
-void QKernel::Connect()
+void QKernel::on_actionConnect_triggered()
 {
        QDialog d(this, Qt::Dialog);
        QLabel lab("IP Address:", &d);
@@ -437,7 +390,7 @@ void QKernel::Connect()
 /**
  * Disconnects from virtual machine
  */
-void QKernel::Disconnect()
+void QKernel::on_actionDisconnect_triggered()
 {
        MESSAGE msg;
 
@@ -526,50 +479,20 @@ void QKernel::DelAddress()
  * Additional window is displayed to set Node Number of node where send message,
  * and textfield to enter message.
  */
-void QKernel::MessageToNode()
+void QKernel::on_actionMessage_triggered()
 {
-       QDialog *dlg;
-       QLineEdit *nodenr;
        MESSAGE m;
-
-       dlg = new QDialog(this, Qt::Dialog);
-       dlg->setWindowTitle("Send message to node");
-
-       nodenr = new QLineEdit("number", dlg);
-       nodenr->setGeometry(90, 10, 50, 30);
-       nodenr->setText("");
-
-       QLabel *tmpQLabel;
-       tmpQLabel = new QLabel("Node number:", dlg);
-       tmpQLabel->setGeometry(10, 10, 77, 30);
-
-       tmpQLabel = new QLabel("Message:", dlg);
-       tmpQLabel->setGeometry(10, 50, 70, 30);
-
-       QLineEdit *msg;
-       msg = new QLineEdit("", dlg);
-       msg->setGeometry(80, 60, 330, 30);
-
-       QPushButton *ob;
-       ob = new QPushButton("Send", dlg);
-       ob->setGeometry(230, 10, 80, 30);
-       ob->setDefault(TRUE);
-       
-       QPushButton *cb;
-       cb = new QPushButton("Cancel", dlg);
-       cb->setGeometry(330, 10, 80, 30);
-       dlg->resize(430, 110);
-       connect(ob, SIGNAL(clicked()), dlg, SLOT(accept()));
-       connect(cb, SIGNAL(clicked()), dlg, SLOT(reject()));
+       SendMessageDialog *dlg;
+       dlg = new SendMessageDialog(this);
 
        if (dlg->exec()) {
                m.msg_type = MSG_NET;
                m.param.pword[0] = NET_PROPAGATE;
                m.param.pword[1] = MSG_VLP;
                m.param.pword[2] = NodeNumber;
-               m.param.pword[4] = atoi(nodenr->text().toAscii().data());
+               m.param.pword[4] = dlg->getNodeNumber();
                m.param.pword[6] = VLP_WRITE;
-               strcpy(m.param.pstr, msg->text().toAscii().data());
+               strcpy(m.param.pstr, dlg->getMessage().toAscii().data());
                write(net_sock, &m, sizeof(MESSAGE));
        }
 }
@@ -579,7 +502,7 @@ void QKernel::MessageToNode()
  * Additional window is displayed to get ID of interpreter which should be
  * killed.
  */
-void QKernel::KillInterpreter()
+void QKernel::on_actionKill_triggered()
 {
        QDialog *dlg;
        QLineEdit *nodenr;
@@ -840,15 +763,11 @@ void QKernel::WriteMessage(char *msg)
  * Adds checkbox to menu item. If it is checked additional info messages are
  * shown.
  */
-void QKernel::SetMessages()
+void QKernel::on_actionInfo_messages_triggered()
 {
-       if (toolsMenu != NULL) {
-               toolsInfoAction->setChecked(!toolsInfoAction->isChecked());
-//             toolsInfoAction->toggle();
-               info_messages = toolsInfoAction->isChecked();
-               fprintf(stderr, "Info is checked? %s\n", toolsInfoAction->isChecked() ? "yes" : "no");
+       if (menuTools != NULL) {
+               info_messages = actionInfo_messages->isChecked();
        }
-//     menuBar()->repaint();
 }
 
 /**
@@ -856,7 +775,7 @@ void QKernel::SetMessages()
  * Additional window is displayed to set kernel options which are saved in 
  * vlp.cfg file in kernel executable directory.
  */
-void QKernel::SetOptions()
+void QKernel::on_actionOptions_triggered()
 {
        QDialog dlg(this, Qt::Dialog);
        dlg.setWindowTitle("Options");
@@ -995,7 +914,7 @@ void QKernel::SetOptions()
  * Additional window is displayed to enter password and retype it. If both are
  * same kernel window is locked.
  */
-void QKernel::LockConsole()
+void QKernel::on_actionLock_Console_triggered()
 {
        QDialog d(this, Qt::Dialog);
        d.setWindowTitle("Lock console");
@@ -1054,7 +973,7 @@ void QKernel::LockConsole()
  * Additional window is displayed to enter password. If it is correct, kernel 
  * window is unlocked
  */
-void QKernel::UnlockConsole()
+void QKernel::on_actionUnlock_console_triggered()
 {
        QDialog d(this, Qt::Dialog);
        d.setWindowTitle("Enter password");
@@ -1346,7 +1265,7 @@ void QKernel::CloseInstances(InterpEntry *e)
 /**
  * Displays information about virtual machine
  */
-void QKernel::Info()
+void QKernel::on_actionInfo_triggered()
 {
        MESSAGE m;
 
@@ -1376,7 +1295,9 @@ int main(int argc, char **argv)
        }
 
        QApplication * app = new QApplication(argc, argv);
+       
        QKernel kernel;
+
        kernel.show();
        kernel.InitMessage();
        
index 168777c1631efb92c7b7132affc23f2c8151936b..a95a6f98b99e1436a6d9b85e36658dd5c64eda0b 100644 (file)
@@ -38,6 +38,7 @@
 #include <QtCore/QSocketNotifier>
 
 #include "comm.h"
+#include "ui/main-window.h"
 
 #define GPATH "loggr"
 #define IPATH "logi"
@@ -90,44 +91,37 @@ public:
 /**
  * Kernel class
  */
-class QKernel : public QMainWindow {
+class QKernel : public QMainWindow, private Ui::MainWindow {
        Q_OBJECT
 public:
-       QTextEdit *desktop;
-       QMenuBar *bar;
-       QMenu *programMenu;
-       QMenu *machineMenu;
-       QMenu *toolsMenu;
        char progdir[256];
        int NodeNumber;
        int ConType;
 
-       QKernel();
-
-       virtual void resizeEvent(QResizeEvent *ev);
+       QKernel(QWidget *parent = 0);
 
        void WriteMessage(char* msg);
        void InitMessage();
 
 public slots:
        void n_impl();
-       void Run_Prog();
-       void Edit();
-       void Help();
-       void SetOptions();
+       void on_actionExecute_triggered();
+       void on_actionEditor_triggered();
+       void on_actionHelp_triggered();
+       void on_actionOptions_triggered();
        void AddAddress();
        void DelAddress();
-       void LockConsole();
-       void UnlockConsole();
-       void MessageToNode();
+       void on_actionLock_Console_triggered();
+       void on_actionUnlock_console_triggered();
+       void on_actionMessage_triggered();
        void QuitProc();
        void NetMessage();
        void IntMessage(int);
-       void KillInterpreter();
-       void Disconnect();
-       void SetMessages();
-       void Connect();
-       void Info();
+       void on_actionKill_triggered();
+       void on_actionDisconnect_triggered();
+       void on_actionInfo_messages_triggered();
+       void on_actionConnect_triggered();
+       void on_actionInfo_triggered();
 
 protected:
        virtual void closeEvent (QCloseEvent * e);
@@ -154,18 +148,6 @@ private:
        bool synchro;
        bool wait_for_info;
        char LockPasswd[25];
-       QAction * toolsEditorAction;
-       QAction * toolsOptionsAction;
-       QAction * toolsInfoAction;
-       QAction * programExecuteAction;
-       QAction * programKillAction;
-       QAction * machineMessageAction;
-       QAction * machineConnectAction;
-       QAction * machineDisconnectAction;
-       QAction * machineInfoAction;
-       QAction * toolsLockAction;
-       QAction * toolsUnlockAction;
-       QAction * quitAction;
        
        int net_sock;
        int freeINTid;
diff --git a/src/kernel/send-message.h b/src/kernel/send-message.h
new file mode 100644 (file)
index 0000000..2653a0f
--- /dev/null
@@ -0,0 +1,77 @@
+/**************************************************************
+
+  Copyright (C) 2013  Rafał Długołęcki
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, 
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+
+
+
+ NOTE: This software is using the free software license of 
+       the QT library v.1.30 from Troll Tech AS.
+       See the file LICENSE.QT.
+
+************************************************************/
+
+#ifndef VLP_SEND_MESSAGE_H
+#define VLP_SEND_MESSAGE_H
+
+#include <QtGui/QDialog>
+#include <QtCore/QString>
+#include <stdlib.h>
+
+#include "ui/dialogs/send-message.h"
+
+/**
+ * Class responsible for displaying dialog for sending messages
+ */
+class SendMessageDialog : public QDialog, private Ui::sendMessageDialog {
+public:
+       /**
+        * Constructs a SendMessageDialog with parent 'parent'.
+        * The widget flags f are passed on to the QWidget constructor.
+        *
+        * @param parent parent widget of this dialog
+        * @param flags QDialog flags of this dialog
+        */
+       SendMessageDialog(QWidget * parent = 0, Qt::WindowFlags flags = 0 ) :
+               QDialog(parent, flags)
+       {
+               setupUi(this);
+               connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+               connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+       }
+       
+       /**
+        * Returns entered in dialog node number
+        * @return node number from this dialog textfield
+        */
+       int getNodeNumber()
+       {
+               return atoi(nodeNumber->text().toAscii().data());
+       }
+       
+       /**
+        * Returns entered in dialog message
+        * @return message from this dialog textarea
+        */
+       QString getMessage()
+       {
+               return message->toPlainText();
+       }
+};
+
+
+#endif /* VLP_SEND_MESSAGE_H */