Move main lgconfig layout code into separate ui file
authorRafał Długołęcki <rafal@dlugolecki.net.pl>
Fri, 29 Jan 2016 22:05:44 +0000 (23:05 +0100)
committerRafał Długołęcki <rafal@dlugolecki.net.pl>
Fri, 29 Jan 2016 22:05:44 +0000 (23:05 +0100)
.gitignore
Makefile.am
configure.ac
src/lgconfig/lgconfig.cpp
src/lgconfig/lgconfig.h [new file with mode: 0644]
src/lgconfig/ui/VLPConfigWindow.ui [new file with mode: 0644]

index 4d027404964f0b5c931ae5e9ab8e2c1df7219470..cc1bfb6da6335cf5361e7430845400ac17410591 100644 (file)
@@ -22,3 +22,7 @@ missing
 stamp-h1
 .directory
 depcomp
+*.moc.cpp
+
+src/*/ui/*.h
+src/*/ui/dialogs/*.h
index 410de45e6cf49017855ee125901676c830d96bf4..39e86b7911121d951a6daaf4f0228fe87d95418f 100644 (file)
@@ -36,7 +36,7 @@ BUILT_SOURCES = \
   src/net/lognet.moc.cpp \
   src/kernel/kernel.moc.cpp \
   src/edit/editor.moc.cpp \
-  src/lgconfig/lgconfig.moc \
+  src/lgconfig/lgconfig.moc.cpp \
   src/preproc/prep.moc.cpp \
   src/help/help.moc
 
@@ -102,8 +102,8 @@ src/kernel/kernel.moc.cpp: \
                src/kernel/ui/dialogs/KillDialog.h \
                src/kernel/ui/dialogs/ConnectDialog.h \
                src/kernel/ui/dialogs/MessageDialog.h
-       moc-qt4 src/kernel/kernel.h -o src/kernel/kernel.moc.cpp
-       moc-qt4 src/kernel/OptionsDialog.h -o src/kernel/OptionsDialog.moc.cpp
+       $(MOC) src/kernel/kernel.h -o src/kernel/kernel.moc.cpp
+       $(MOC) src/kernel/OptionsDialog.h -o src/kernel/OptionsDialog.moc.cpp
 #      $(MOC) -i src/kernel/kernel.cpp -o src/kernel/kernel.moc
 
 src/kernel/ui/KernelWindow.h:
@@ -203,8 +203,7 @@ src/edit/editor.moc.cpp: \
                src/edit/ui/dialogs/UnitStructureDialog.h \
                src/edit/ui/dialogs/PreferencesDialog.h \
                src/edit/ui/dialogs/FindDialog.h
-       moc-qt4 src/edit/editor.h -o src/edit/editor.moc.cpp
-#      $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp
+       $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp
 
 src/edit/ui/editor.h:
        uic src/edit/ui/editor.ui -o src/edit/ui/editor.h
@@ -229,14 +228,25 @@ clean-logedit-extra:
        rm -f bin/modules/logedit
        rm -f bin/logedit
 
-bin_lgconfig_SOURCES = src/lgconfig/lgconfig.cpp src/lgconfig/lgconfig.moc
+bin_lgconfig_SOURCES = \
+       src/lgconfig/lgconfig.cpp \
+       src/lgconfig/lgconfig.moc.cpp
 bin_lgconfig_CPPFLAGS = $(bin_lgconfig_CFLAGS)
 bin_lgconfig_LDADD = $(bin_lgconfig_LIBS) -lconfig++
-src/lgconfig/lgconfig.moc:
-       $(MOC) -i src/lgconfig/lgconfig.cpp -o src/lgconfig/lgconfig.moc
+bin_logedit_HEADERS = \
+       src/lgconfig/lgconfig.h \
+       src/lgconfig/ui/VLPConfigWindow.h
+
+src/lgconfig/lgconfig.moc.cpp: \
+               src/lgconfig/ui/VLPConfigWindow.h
+       $(MOC) src/lgconfig/lgconfig.h -o src/lgconfig/lgconfig.moc.cpp
+
+src/lgconfig/ui/VLPConfigWindow.h:
+       uic src/lgconfig/ui/VLPConfigWindow.ui -o src/lgconfig/ui/VLPConfigWindow.h
 
 clean-lgconfig-extra:
-       rm -f src/lgconfig/*.moc
+       rm -f src/lgconfig/*.moc.cpp
+       rm -f src/lgconfig/ui/*.h
        rm -f bin/lgconfig
 
 bin_logcomp_SOURCES = src/preproc/prep.cpp src/preproc/prep.moc.cpp
index 1acdf864f96190c0a408c5ab9dc4720bc28ab589..f298dd2ecb23323eec4fe0123e0702697d97ffa0 100644 (file)
@@ -24,7 +24,7 @@ AC_ARG_WITH([moc-compiler-name],
   [AS_HELP_STRING([--with-moc-compiler-name=NAME],
     [filename of MOC compiler, defaults to: moc])],
   [MOCNAME="$withval"],
-  [MOCNAME='moc'])
+  [MOCNAME='moc-qt4'])
 AC_SUBST([MOCNAME])
 
 AC_ARG_WITH([moc-compiler-dir],
index 7c7fcb2ef49ebf1a7fc6253e091a3086bd1c7fc6..91baba33ff75ec40f21a4d0526f59e1f49caffd1 100644 (file)
 
 #include <libconfig.h>
 
-class VLPEntry {
-public:
-       int ID;
-       char addr[255];
-       /** 0 - explicit */
-       int type;
-       char progdir[255];
-       char homedir[255];
-       char item[255];
-};
-
-class QInstall: public QMainWindow {
-       Q_OBJECT
-public:
-       QMenuBar *bar;
-       Q3ListBox *nodelist;
-       QPushButton *infob;
-       QList<VLPEntry*> Nodes;
-
-       QInstall();
-       bool check_id(int);
-       bool check_addr(char*);
-
-public slots:
-       void SetOptions();
-       void AddNode();
-       void DelNode();
-       void Info();
-};
-
+#include "lgconfig.h"
 
 QApplication *app;
 
 QInstall::QInstall()
 {
-       QFont f("Helvetica", 12, QFont::Bold);
-       QPixmap mp;
-
-//     infob = new QPushButton(this);
-
-       setWindowTitle("VLP Configuration Tool");
-
-       QMenu * programMenu = NULL;
-       programMenu = menuBar()->addMenu("&Program");
-       programMenu->addAction("Configure", this, SLOT(SetOptions()));
-       programMenu->addAction("Quit", app, SLOT(quit()));
-
-//     bar = new QMenuBar(this);
-//     bar->insertItem("Configure", this, SLOT(SetOptions()));
-//     bar->insertItem("Quit", app, SLOT(quit()));
-//     bar->setFont(f);
-//     infob->setGeometry(0, bar->height(), 200, 30);
-       if (mp.load("logo.bmp")) {
-//             infob->setPixmap(mp);
-//             infob->resize(mp.width(), mp.height());
-       }
-//     resize(infob->width(), infob->height() + bar->height());
+       setupUi(this);
+
        Nodes.clear();
 }
 
@@ -109,13 +60,6 @@ bool QInstall::check_addr(char *addr)
        return TRUE;
 }
 
-/**
- * @attention Currently not in use
- */
-void QInstall::Info()
-{
-}
-
 void QInstall::AddNode()
 {
        QDialog dlg(this);
@@ -229,7 +173,7 @@ void QInstall::DelNode()
        }
 }
 
-void QInstall::SetOptions()
+void QInstall::on_actionConfigure_triggered()
 {
        QDialog dlg(this);
        QLabel *tmpQLabel;
@@ -329,7 +273,12 @@ void QInstall::SetOptions()
        }
 }
 
-#include "lgconfig.moc"
+
+void QInstall::on_actionQuit_triggered()
+{
+       QApplication::instance()->quit();
+}
+
 
 int main(int argc, char **argv)
 {
diff --git a/src/lgconfig/lgconfig.h b/src/lgconfig/lgconfig.h
new file mode 100644 (file)
index 0000000..700af05
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _VLP_LGCONFIG_H
+#define _VLP_LGCONFIG_H
+
+#include <QtGui/QMainWindow>
+#include <QtGui/QPushButton>
+#include <QtCore/QList>
+#include <QtGui/QMenuBar>
+
+#include <Qt3Support/Q3ListBox>
+
+#include "ui/VLPConfigWindow.h"
+
+class VLPEntry {
+public:
+       int ID;
+       char addr[255];
+       /** 0 - explicit */
+       int type;
+       char progdir[255];
+       char homedir[255];
+       char item[255];
+};
+
+class QInstall: public QMainWindow, private Ui::VLPConfigWindow {
+       Q_OBJECT
+public:
+       QMenuBar *bar;
+       Q3ListBox *nodelist;
+       QPushButton *infob;
+       QList<VLPEntry*> Nodes;
+
+       QInstall();
+       bool check_id(int);
+       bool check_addr(char*);
+
+public slots:
+       void AddNode();
+       void DelNode();
+
+private slots:
+       void on_actionConfigure_triggered();
+       void on_actionQuit_triggered();
+};
+
+#endif /* _VLP_LGCONFIG_H */
diff --git a/src/lgconfig/ui/VLPConfigWindow.ui b/src/lgconfig/ui/VLPConfigWindow.ui
new file mode 100644 (file)
index 0000000..1dd8dc6
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>VLPConfigWindow</class>
+ <widget class="QMainWindow" name="VLPConfigWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>VLP Configuration Tool</string>
+  </property>
+  <widget class="QWidget" name="centralwidget"/>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>19</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuProgram">
+    <property name="title">
+     <string>Program</string>
+    </property>
+    <addaction name="actionConfigure"/>
+    <addaction name="actionQuit"/>
+   </widget>
+   <addaction name="menuProgram"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionConfigure">
+   <property name="text">
+    <string>Configure</string>
+   </property>
+  </action>
+  <action name="actionQuit">
+   <property name="text">
+    <string>Quit</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>