Moved connect dialog layout code into separate ui file
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Mon, 25 Jan 2016 01:30:33 +0000 (02:30 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Mon, 25 Jan 2016 01:30:33 +0000 (02:30 +0100)
Makefile.am
src/kernel/connect_dialog.cpp [new file with mode: 0644]
src/kernel/connect_dialog.h [new file with mode: 0644]
src/kernel/kernel.cpp
src/kernel/ui/connect_dialog.ui [new file with mode: 0644]

index c8f536ac5411859c30c8e780488bfd59ef9d8654..46d0bebbbd966e958e21758f7e8cfa7db3e54d28 100644 (file)
@@ -69,7 +69,8 @@ bin_logker_SOURCES = \
        src/kernel/lock.cpp \
        src/kernel/options.cpp \
        src/kernel/options.moc.cpp \
-       src/kernel/kill_interpreter_dialog.cpp
+       src/kernel/kill_interpreter_dialog.cpp \
+       src/kernel/connect_dialog.cpp
 bin_logker_CPPFLAGS = $(bin_logker_CFLAGS)
 bin_logker_LDADD = $(bin_logker_LIBS) -lconfig++ -lX11
 bin_logkerdir = src/kernel
@@ -77,8 +78,15 @@ bin_logker_HEADERS = \
        src/kernel/kernel.h \
        src/kernel/lock.h \
        src/kernel/options.h \
-       src/kernel/kill_interpreter_dialog.h
-src/kernel/kernel.moc.cpp: src/kernel/kernel.h src/kernel/ui/kernelwindow.h src/kernel/ui/lock_dialog.h src/kernel/ui/optionsdialog.h src/kernel/ui/kill_dialog.h
+       src/kernel/kill_interpreter_dialog.h \
+       src/kernel/connect_dialog.h
+src/kernel/kernel.moc.cpp: \
+               src/kernel/kernel.h \
+               src/kernel/ui/kernelwindow.h \
+               src/kernel/ui/lock_dialog.h \
+               src/kernel/ui/optionsdialog.h \
+               src/kernel/ui/kill_dialog.h \
+               src/kernel/ui/connect_dialog.h
        moc-qt4 src/kernel/kernel.h -o src/kernel/kernel.moc.cpp
        moc-qt4 src/kernel/options.h -o src/kernel/options.moc.cpp
 #      $(MOC) -i src/kernel/kernel.cpp -o src/kernel/kernel.moc
@@ -95,6 +103,9 @@ src/kernel/ui/optionsdialog.h:
 src/kernel/ui/kill_dialog.h:
        uic src/kernel/ui/kill_dialog.ui -o src/kernel/ui/kill_dialog.h
 
+src/kernel/ui/connect_dialog.h:
+       uic src/kernel/ui/connect_dialog.ui -o src/kernel/ui/connect_dialog.h
+
 
 clean-logker-extra:
        rm -f src/kernel/*.moc
@@ -102,6 +113,8 @@ clean-logker-extra:
        rm -f src/kernel/ui/kernelwindow.h
        rm -f src/kernel/ui/lock_dialog.h
        rm -f src/kernel/ui/optionsdialog.h
+       rm -f src/kernel/ui/kill_dialog.h
+       rm -f src/kernel/ui/connect_dialog.h
        rm -f bin/logker
        
 bin_logint_SOURCES = \
diff --git a/src/kernel/connect_dialog.cpp b/src/kernel/connect_dialog.cpp
new file mode 100644 (file)
index 0000000..9df1a65
--- /dev/null
@@ -0,0 +1,18 @@
+#include <QtGui/QDialog>
+
+#include "connect_dialog.h"
+
+ConnectDialog::ConnectDialog(QWidget * parent)
+       : QDialog(parent, Qt::Dialog)
+{
+       setupUi(this);
+}
+
+ConnectDialog::~ConnectDialog()
+{
+}
+
+QString ConnectDialog::getAddress()
+{
+       return address->text();
+}
diff --git a/src/kernel/connect_dialog.h b/src/kernel/connect_dialog.h
new file mode 100644 (file)
index 0000000..99d1ace
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _VLP_KERNEL_CONNECTDIALOG_H
+#define _VLP_KERNEL_CONNECTDIALOG_H
+
+#include <QtGui/QDialog>
+#include <QtCore/QString>
+
+#include "ui/connect_dialog.h"
+
+/**
+ * Kill Interpreter Dialog class
+ */
+class ConnectDialog : public QDialog, private Ui::ConnectDialog {
+public:
+       ConnectDialog(QWidget * parent = 0);
+       ~ConnectDialog();
+
+       QString getAddress();
+};
+
+#endif /* _VLP_KERNEL_CONNECTDIALOG_H */
index 2052fed9a47536a9de7512e551592b34ecf9ed77..578498c4774bbb3a65c6482a1470efcb955d998e 100644 (file)
@@ -69,6 +69,7 @@
 #include "lock.h"
 #include "options.h"
 #include "kill_interpreter_dialog.h"
+#include "connect_dialog.h"
 
 /* File resides in top directory (where are Makefiles)*/
 #include "../../config.h"
@@ -462,30 +463,16 @@ void QKernel::RunNetModule()
  */
 void QKernel::on_actionConnect_triggered()
 {
-       QDialog d(this, Qt::Dialog);
-       QLabel lab("IP Address:", &d);
-       QLineEdit ed("", &d);
-       QPushButton ob("", &d);
-       QPushButton cb("", &d);
        MESSAGE m;
 
-       ob.setGeometry(30, 60, 80, 30);
-       ob.setText("Ok");
-       ob.setDefault(TRUE);
-       lab.setGeometry(10, 10, 60, 30);
-       lab.setText("Address");
-       ed.setGeometry(70, 10, 140, 30);
-       cb.setGeometry(130, 60, 80, 30);
-       cb.setText("Cancel");
-       d.resize(240, 100);
-
-       connect(&ob, SIGNAL(clicked()), &d, SLOT(accept()));
-       connect(&cb, SIGNAL(clicked()), &d, SLOT(reject()));
-       if (d.exec()) {
+       ConnectDialog dialog(this);
+       dialog.setWindowTitle("IP Address:");
+
+       if (dialog.exec()) {
                m.msg_type = MSG_NET;
                m.param.pword[0] = NET_CONNECT_TO;
-               strcpy(m.param.pstr, ed.text().toAscii().data());
-               write(net_sock, &m, sizeof(MESSAGE)); 
+               strcpy(m.param.pstr, dialog.getAddress().toStdString().c_str());
+               write(net_sock, &m, sizeof(MESSAGE));
        }
 }
 
diff --git a/src/kernel/ui/connect_dialog.ui b/src/kernel/ui/connect_dialog.ui
new file mode 100644 (file)
index 0000000..46bf16f
--- /dev/null
@@ -0,0 +1,78 @@
+<?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>185</width>
+    <height>70</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</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="address"/>
+     </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>ConnectDialog</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>ConnectDialog</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>