2016-06-14 03:52:17 +03:00
|
|
|
#include "mainwindow.h"
|
2016-06-17 16:49:49 +03:00
|
|
|
//#include "ui_mainwindow.h"
|
|
|
|
#include <QMessageBox>
|
2016-06-24 22:37:59 +03:00
|
|
|
#include <QTimer>
|
2016-06-14 03:52:17 +03:00
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
2016-06-17 16:49:49 +03:00
|
|
|
QMainWindow(parent)/*,
|
|
|
|
ui(new Ui::MainWindow)*/
|
2016-06-14 03:52:17 +03:00
|
|
|
{
|
2016-06-17 16:49:49 +03:00
|
|
|
//ui->setupUi(this);
|
|
|
|
if (objectName().isEmpty())
|
|
|
|
setObjectName(QStringLiteral("MainWindow"));
|
|
|
|
resize(800, 480);
|
|
|
|
centralWidget = new QWidget(this);
|
|
|
|
centralWidget->setObjectName(QStringLiteral("centralWidget"));
|
|
|
|
verticalLayoutWidget = new QWidget(centralWidget);
|
|
|
|
verticalLayoutWidget->setObjectName(QStringLiteral("verticalLayoutWidget"));
|
|
|
|
//verticalLayoutWidget->setGeometry(QRect(10, 20, 771, 441));
|
|
|
|
verticalLayout1 = new QVBoxLayout(verticalLayoutWidget);
|
|
|
|
verticalLayout1->setSpacing(6);
|
|
|
|
verticalLayout1->setContentsMargins(11, 11, 11, 11);
|
|
|
|
verticalLayout1->setObjectName(QStringLiteral("verticalLayout1"));
|
|
|
|
verticalLayout1->setContentsMargins(0, 0, 0, 0);
|
|
|
|
quitButton = new QPushButton(verticalLayoutWidget);
|
|
|
|
quitButton->setObjectName(QStringLiteral("quitButton"));
|
2016-06-24 22:37:59 +03:00
|
|
|
QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
|
|
|
sizePolicy.setHorizontalStretch(1);
|
|
|
|
//sizePolicy.setVerticalStretch(1);
|
2016-06-17 16:49:49 +03:00
|
|
|
sizePolicy.setHeightForWidth(quitButton->sizePolicy().hasHeightForWidth());
|
|
|
|
quitButton->setSizePolicy(sizePolicy);
|
|
|
|
verticalLayout1->addWidget(quitButton);
|
2016-06-24 22:37:59 +03:00
|
|
|
gracefulQuitButton = new QPushButton(verticalLayoutWidget);
|
|
|
|
gracefulQuitButton->setObjectName(QStringLiteral("gracefulQuitButton"));
|
|
|
|
QSizePolicy sizePolicy2(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
|
|
|
sizePolicy2.setHorizontalStretch(1);
|
|
|
|
//sizePolicy2.setVerticalStretch(1);
|
|
|
|
sizePolicy2.setHeightForWidth(gracefulQuitButton->sizePolicy().hasHeightForWidth());
|
|
|
|
gracefulQuitButton->setSizePolicy(sizePolicy2);
|
|
|
|
verticalLayout1->addWidget(gracefulQuitButton);
|
2016-06-17 16:49:49 +03:00
|
|
|
|
|
|
|
setCentralWidget(centralWidget);
|
|
|
|
|
|
|
|
setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
|
|
|
|
quitButton->setText(QApplication::translate("MainWindow", "Quit", 0));
|
2016-06-24 22:37:59 +03:00
|
|
|
gracefulQuitButton->setText(QApplication::translate("MainWindow", "Graceful Quit", 0));
|
2016-06-17 16:49:49 +03:00
|
|
|
|
|
|
|
QObject::connect(quitButton, SIGNAL(released()), this, SLOT(handleQuitButton()));
|
2016-06-24 22:37:59 +03:00
|
|
|
QObject::connect(gracefulQuitButton, SIGNAL(released()), this, SLOT(handleGracefulQuitButton()));
|
2016-06-17 16:49:49 +03:00
|
|
|
|
|
|
|
//QMetaObject::connectSlotsByName(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::handleQuitButton() {
|
|
|
|
qDebug("Quit pressed. Hiding the main window");
|
|
|
|
close();
|
|
|
|
QApplication::instance()->quit();
|
2016-06-14 03:52:17 +03:00
|
|
|
}
|
|
|
|
|
2016-06-24 22:37:59 +03:00
|
|
|
void MainWindow::handleGracefulQuitButton() {
|
|
|
|
qDebug("Graceful Quit pressed.");
|
|
|
|
gracefulQuitButton->setText(QApplication::translate("MainWindow", "Graceful quit is in progress", 0));
|
|
|
|
gracefulQuitButton->setEnabled(false);
|
|
|
|
gracefulQuitButton->adjustSize();
|
|
|
|
verticalLayoutWidget->adjustSize();
|
|
|
|
//here, the code to stop tunnels
|
|
|
|
QTimer::singleShot(10*60*1000/*millis*/, this, SLOT(handleGracefulQuitTimerEvent()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::handleGracefulQuitTimerEvent() {
|
|
|
|
qDebug("Hiding the main window");
|
|
|
|
close();
|
|
|
|
qDebug("Performing quit");
|
|
|
|
QApplication::instance()->quit();
|
|
|
|
}
|
|
|
|
|
2016-06-14 03:52:17 +03:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
2016-06-17 16:49:49 +03:00
|
|
|
qDebug("Destroying main window");
|
|
|
|
//QMessageBox::information(0, "Debug", "mw destructor 1");
|
|
|
|
//delete ui;
|
|
|
|
//QMessageBox::information(0, "Debug", "mw destructor 2");
|
2016-06-14 03:52:17 +03:00
|
|
|
}
|