Commit 1ee2ad23 authored by Projects's avatar Projects Committed by Grzegorz Daniluk

GUI demo: moved the main dialog to a separate class

parent 71f1f8f9
......@@ -18,9 +18,9 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input
HEADERS += controller.h diot_crate.h
HEADERS += controller.h diot_crate.h diot_dialog.h
#FORMS += dialog.ui main_win.ui
SOURCES += main.cpp controller.cpp diot_crate.cpp
SOURCES += main.cpp controller.cpp diot_crate.cpp diot_dialog.cpp
# enable C++11
CONFIG += c++11
......
/*
* Copyright (C) 2018 CERN
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <QBoxLayout>
#include "diot_dialog.h"
DIOT_Dialog::DIOT_Dialog(int address, int slots_nr)
: hw(address, slots_nr)
{
QVBoxLayout *mainLayout = new QVBoxLayout();
DiotIOController *controller = new DiotIOController(this, hw, slots_nr);
mainLayout->addWidget(controller);
DiotDiag *diag = new DiotDiag(this, hw);
mainLayout->addWidget(diag);
setLayout(mainLayout);
hw.Start();
}
/*
* Copyright (C) 2018 CERN
* Author: Maciej Suminski <maciej.suminski@cern.ch>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef DIOT_DIALOG_H
#define DIOT_DIALOG_H
#include <QDialog>
#include "controller.h"
class DIOT_Dialog : public QDialog
{
public:
DIOT_Dialog(int address, int slots_nr);
protected:
DiotHardware hw;
};
#endif /* DIOT_DIALOG_H */
......@@ -18,9 +18,7 @@
#include <iostream>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QBoxLayout>
#include "controller.h"
#include "diot_dialog.h"
// Argument values
constexpr int ADDRESS_DEFAULT = 1;
......@@ -40,7 +38,6 @@ static void usage() {
int main( int argc, char **argv ) {
QApplication a( argc, argv );
QDialog w;
// Process arguments
int address = ADDRESS_DEFAULT;
......@@ -69,18 +66,7 @@ int main( int argc, char **argv ) {
return 0;
}
DiotHardware hw(address, slots_nr);
QVBoxLayout *mainLayout = new QVBoxLayout();
DiotIOController *controller = new DiotIOController(&w, hw, slots_nr);
mainLayout->addWidget(controller);
DiotDiag *diag = new DiotDiag(&w, hw);
mainLayout->addWidget(diag);
w.setLayout(mainLayout);
DIOT_Dialog w(address, slots_nr);
w.show();
hw.Start();
return a.exec();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment