|
|
|
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
|
|
|
|
#include "mainwindow.h" |
|
|
|
|
//#include "ui_mainwindow.h"
|
|
|
|
|
#include <QMessageBox> |
|
|
|
|
#include <QTimer> |
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : |
|
|
|
|
QMainWindow(parent)/*,
|
|
|
|
@ -22,20 +23,29 @@ MainWindow::MainWindow(QWidget *parent) :
@@ -22,20 +23,29 @@ MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
|
verticalLayout1->setContentsMargins(0, 0, 0, 0); |
|
|
|
|
quitButton = new QPushButton(verticalLayoutWidget); |
|
|
|
|
quitButton->setObjectName(QStringLiteral("quitButton")); |
|
|
|
|
QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
|
|
|
|
sizePolicy.setHorizontalStretch(0); |
|
|
|
|
sizePolicy.setVerticalStretch(0); |
|
|
|
|
QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); |
|
|
|
|
sizePolicy.setHorizontalStretch(1); |
|
|
|
|
//sizePolicy.setVerticalStretch(1);
|
|
|
|
|
sizePolicy.setHeightForWidth(quitButton->sizePolicy().hasHeightForWidth()); |
|
|
|
|
quitButton->setSizePolicy(sizePolicy); |
|
|
|
|
|
|
|
|
|
verticalLayout1->addWidget(quitButton); |
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
setCentralWidget(centralWidget); |
|
|
|
|
|
|
|
|
|
setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0)); |
|
|
|
|
quitButton->setText(QApplication::translate("MainWindow", "Quit", 0)); |
|
|
|
|
gracefulQuitButton->setText(QApplication::translate("MainWindow", "Graceful Quit", 0)); |
|
|
|
|
|
|
|
|
|
QObject::connect(quitButton, SIGNAL(released()), this, SLOT(handleQuitButton())); |
|
|
|
|
QObject::connect(gracefulQuitButton, SIGNAL(released()), this, SLOT(handleGracefulQuitButton())); |
|
|
|
|
|
|
|
|
|
//QMetaObject::connectSlotsByName(this);
|
|
|
|
|
} |
|
|
|
@ -46,6 +56,23 @@ void MainWindow::handleQuitButton() {
@@ -46,6 +56,23 @@ void MainWindow::handleQuitButton() {
|
|
|
|
|
QApplication::instance()->quit(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow() |
|
|
|
|
{ |
|
|
|
|
qDebug("Destroying main window"); |
|
|
|
|