From b75f396432fe4070829b3229b45b5e89f8654c8e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Fri, 29 Jan 2016 23:05:44 +0100 Subject: [PATCH] Move main lgconfig layout code into separate ui file --- .gitignore | 4 ++ Makefile.am | 28 ++++++++---- configure.ac | 2 +- src/lgconfig/lgconfig.cpp | 71 +++++------------------------- src/lgconfig/lgconfig.h | 45 +++++++++++++++++++ src/lgconfig/ui/VLPConfigWindow.ui | 49 +++++++++++++++++++++ 6 files changed, 128 insertions(+), 71 deletions(-) create mode 100644 src/lgconfig/lgconfig.h create mode 100644 src/lgconfig/ui/VLPConfigWindow.ui diff --git a/.gitignore b/.gitignore index 4d02740..cc1bfb6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ missing stamp-h1 .directory depcomp +*.moc.cpp + +src/*/ui/*.h +src/*/ui/dialogs/*.h diff --git a/Makefile.am b/Makefile.am index 410de45..39e86b7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 1acdf86..f298dd2 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/src/lgconfig/lgconfig.cpp b/src/lgconfig/lgconfig.cpp index 7c7fcb2..91baba3 100644 --- a/src/lgconfig/lgconfig.cpp +++ b/src/lgconfig/lgconfig.cpp @@ -23,63 +23,14 @@ #include -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 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 index 0000000..700af05 --- /dev/null +++ b/src/lgconfig/lgconfig.h @@ -0,0 +1,45 @@ +#ifndef _VLP_LGCONFIG_H +#define _VLP_LGCONFIG_H + +#include +#include +#include +#include + +#include + +#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 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 index 0000000..1dd8dc6 --- /dev/null +++ b/src/lgconfig/ui/VLPConfigWindow.ui @@ -0,0 +1,49 @@ + + + VLPConfigWindow + + + + 0 + 0 + 800 + 600 + + + + VLP Configuration Tool + + + + + + 0 + 0 + 800 + 19 + + + + + Program + + + + + + + + + + Configure + + + + + Quit + + + + + + -- 2.30.2