From 5d7060121bc8fb1f5ef9ee78937c342058459d7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20D=C5=82ugo=C5=82=C4=99cki?= Date: Wed, 30 Oct 2013 23:19:00 +0100 Subject: [PATCH] vlp-27 Made Editor Properties dialog using QtDesigner files. --- Makefile.am | 8 ++- data/editor/editor-properties-dialog.ui | 56 +++++++++++++++ src/edit/editor-properties.h | 93 +++++++++++++++++++++++++ src/edit/editor.cpp | 55 ++------------- 4 files changed, 163 insertions(+), 49 deletions(-) create mode 100644 data/editor/editor-properties-dialog.ui create mode 100644 src/edit/editor-properties.h diff --git a/Makefile.am b/Makefile.am index f716d46..bc7d223 100644 --- a/Makefile.am +++ b/Makefile.am @@ -160,12 +160,18 @@ bin_logeditdir = src/edit bin_logedit_HEADERS =\ src/edit/editor.h \ src/edit/my_edit.h \ - src/edit/ui/editor-window.h + src/edit/editor-properties.h \ + src/edit/ui/editor-window.h \ + src/edit/ui/editor-properties-dialog.h src/edit/ui/editor-window.h: data/editor/editor-window.ui if [ ! -d src/edit/ui ]; then mkdir -p src/edit/ui; fi uic-qt4 data/editor/editor-window.ui -o src/edit/ui/editor-window.h +src/edit/ui/editor-properties-dialog.h: data/editor/editor-properties-dialog.ui + if [ ! -d src/edit/ui ]; then mkdir -p src/edit/ui; fi + uic-qt4 data/editor/editor-properties-dialog.ui -o src/edit/ui/editor-properties-dialog.h + src/edit/editor.moc.cpp: $(bin_logedit_HEADERS) moc-qt4 src/edit/editor.h -o src/edit/editor.moc.cpp # $(MOC) src/edit/editor.h -o src/edit/editor.moc.cpp diff --git a/data/editor/editor-properties-dialog.ui b/data/editor/editor-properties-dialog.ui new file mode 100644 index 0000000..54afc9f --- /dev/null +++ b/data/editor/editor-properties-dialog.ui @@ -0,0 +1,56 @@ + + + EditorProperties + + + + 0 + 0 + 332 + 136 + + + + Dialog + + + + + + + + Path to files + + + + + + + + + + + + + + Path to compiler + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/src/edit/editor-properties.h b/src/edit/editor-properties.h new file mode 100644 index 0000000..e90013b --- /dev/null +++ b/src/edit/editor-properties.h @@ -0,0 +1,93 @@ +/************************************************************** + + 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 +#include +#include + +#include "ui/editor-properties-dialog.h" + +/** + * Class responsible for displaying dialog with editor properties + */ +class EditorProperties : public QDialog, private Ui::EditorProperties { +public: + /** + * Constructs an EditorProperties with parent 'parent'. + * The widget flags flags are passed on to the QDialog constructor. + * + * @param parent parent widget of this dialog + * @param flags QDialog flags of this dialog + */ + EditorProperties(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 Compiler Path + * @return Compiler Path from this dialog textfield + */ + QString getCompilerPath() + { + return compilerPath->text(); + } + + /** + * Returns entered in dialog Files Path + * @return Files Path from this dialog textfield + */ + QString getFilesPath() + { + return filesPath->text(); + } + + /** + * Sets default value for Compiler Path textfield + */ + void setDefaultCompilerPath(QString path) + { + compilerPath->setText(path); + } + + /** + * Sets default value for Files Path textfield + */ + void setDefaultFilesPath(QString path) + { + filesPath->setText(path); + } +}; + + +#endif /* VLP_SEND_MESSAGE_H */ diff --git a/src/edit/editor.cpp b/src/edit/editor.cpp index f6808a4..b57a59b 100644 --- a/src/edit/editor.cpp +++ b/src/edit/editor.cpp @@ -14,6 +14,7 @@ #include "editor.h" #include "my_edit.h" +#include "editor-properties.h" #define TYPENUM 5 @@ -327,27 +328,10 @@ void Editor::compile(int mode) */ void Editor::on_actionProperties_triggered() { - QDialog dlg(this, Qt::Dialog); - - QLineEdit *files; - files = new QLineEdit(&dlg); - files->setGeometry(130, 20, 250, 30); - files->setText(file_path); - files->setMaxLength(32767); - files->setEchoMode(QLineEdit::Normal); - files->setFrame(TRUE); - - QLabel *tmpQLabel; - tmpQLabel = new QLabel("Path to files:", &dlg); - tmpQLabel->setGeometry(10, 20, 100, 30); - tmpQLabel->setAlignment(Qt::AlignLeft); - tmpQLabel->setMargin(-1); - - tmpQLabel = new QLabel("Path to compiler:", &dlg); - tmpQLabel->setGeometry(10, 60, 100, 30); - tmpQLabel->setAlignment(Qt::AlignLeft); - tmpQLabel->setMargin(-1); + EditorProperties *dlg = new EditorProperties(this, Qt::Dialog); + dlg->setDefaultCompilerPath(compiler_path); + dlg->setDefaultFilesPath(file_path); /* tmpQLabel = new QLabel(&dlg, "Label_3"); tmpQLabel->setGeometry(10, 100, 100, 30); @@ -356,13 +340,6 @@ void Editor::on_actionProperties_triggered() tmpQLabel->setMargin(-1); */ - QLineEdit *compp; - compp = new QLineEdit(compiler_path, &dlg); - compp->setGeometry(130, 60, 250, 30); - compp->setMaxLength(32767); - compp->setEchoMode(QLineEdit::Normal); - compp->setFrame(TRUE); - /* QLineEdit* genp; genp = new QLineEdit(&dlg, "g_path"); @@ -373,28 +350,10 @@ void Editor::on_actionProperties_triggered() genp->setFrame(TRUE); */ - QPushButton* tmpQPushButton; - tmpQPushButton = new QPushButton("Ok", &dlg); - tmpQPushButton->setGeometry(90, 100, 70, 30); - tmpQPushButton->setAutoRepeat(FALSE); -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - tmpQPushButton->setAutoResize(FALSE); -*/ - connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(accept())); - - tmpQPushButton = new QPushButton("Cancel", &dlg); - tmpQPushButton->setGeometry(180, 100, 70, 30); - tmpQPushButton->setAutoRepeat(FALSE); -/*TODO: Does not exists in Qt4. Use layout and set the size policy (https://qt-project.org/forums/viewthread/2112) - tmpQPushButton->setAutoResize(FALSE); -*/ - connect(tmpQPushButton,SIGNAL(clicked()), &dlg, SLOT(reject())); - dlg.resize(400, 140); - - if (dlg.exec()) { - compiler_path.sprintf("%s", compp->text().toAscii().data()); + if (dlg->exec()) { + compiler_path.sprintf("%s", dlg->getCompilerPath().toAscii().data()); /* gen_path.sprintf("%s",genp->text()); */ - file_path.sprintf("%s", files->text().toAscii().data()); + file_path.sprintf("%s", dlg->getFilesPath().toAscii().data()); }; } -- 2.30.2