From 3189de11349eab7ce9e3318441c1ce9fb6ecc03a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Mon, 25 Jan 2016 02:30:33 +0100 Subject: [PATCH] Moved connect dialog layout code into separate ui file --- Makefile.am | 19 ++++++-- src/kernel/connect_dialog.cpp | 18 ++++++++ src/kernel/connect_dialog.h | 20 +++++++++ src/kernel/kernel.cpp | 27 +++--------- src/kernel/ui/connect_dialog.ui | 78 +++++++++++++++++++++++++++++++++ 5 files changed, 139 insertions(+), 23 deletions(-) create mode 100644 src/kernel/connect_dialog.cpp create mode 100644 src/kernel/connect_dialog.h create mode 100644 src/kernel/ui/connect_dialog.ui diff --git a/Makefile.am b/Makefile.am index c8f536a..46d0beb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 0000000..9df1a65 --- /dev/null +++ b/src/kernel/connect_dialog.cpp @@ -0,0 +1,18 @@ +#include + +#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 index 0000000..99d1ace --- /dev/null +++ b/src/kernel/connect_dialog.h @@ -0,0 +1,20 @@ +#ifndef _VLP_KERNEL_CONNECTDIALOG_H +#define _VLP_KERNEL_CONNECTDIALOG_H + +#include +#include + +#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 */ diff --git a/src/kernel/kernel.cpp b/src/kernel/kernel.cpp index 2052fed..578498c 100644 --- a/src/kernel/kernel.cpp +++ b/src/kernel/kernel.cpp @@ -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 index 0000000..46bf16f --- /dev/null +++ b/src/kernel/ui/connect_dialog.ui @@ -0,0 +1,78 @@ + + + ConnectDialog + + + + 0 + 0 + 185 + 70 + + + + Dialog + + + + + + + + Address + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ConnectDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ConnectDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- 2.30.2