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