From 3118d7bede949167cb06e6ea4859e0c616447066 Mon Sep 17 00:00:00 2001 From: hypnosis-i2p Date: Fri, 28 Jul 2017 11:59:45 +0800 Subject: [PATCH] restart button now has a handler --- qt/i2pd_qt/DaemonQT.cpp | 1 + qt/i2pd_qt/mainwindow.cpp | 15 +++++++++++++++ qt/i2pd_qt/mainwindow.h | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/qt/i2pd_qt/DaemonQT.cpp b/qt/i2pd_qt/DaemonQT.cpp index accd69b1..582ad0f3 100644 --- a/qt/i2pd_qt/DaemonQT.cpp +++ b/qt/i2pd_qt/DaemonQT.cpp @@ -161,6 +161,7 @@ namespace qt { i2p::qt::Controller daemonQtController(daemon); + w.setI2PController(&daemonQtController); qDebug("Starting the daemon..."); emit daemonQtController.startDaemon(); //daemon.start (); diff --git a/qt/i2pd_qt/mainwindow.cpp b/qt/i2pd_qt/mainwindow.cpp index 8abffba7..ff2061e9 100644 --- a/qt/i2pd_qt/mainwindow.cpp +++ b/qt/i2pd_qt/mainwindow.cpp @@ -17,6 +17,8 @@ #include +#include "DaemonQT.h" + std::string programOptionsWriterCurrentSection; MainWindow::MainWindow(QWidget *parent) : @@ -25,6 +27,7 @@ MainWindow::MainWindow(QWidget *parent) : ,quitting(false) #endif ,ui(new Ui::MainWindow) + ,i2pController(nullptr) ,configItems() ,datadir() ,confpath() @@ -75,6 +78,8 @@ MainWindow::MainWindow(QWidget *parent) : QObject::connect(ui->fastQuitPushButton, SIGNAL(released()), this, SLOT(handleQuitButton())); QObject::connect(ui->gracefulQuitPushButton, SIGNAL(released()), this, SLOT(handleGracefulQuitButton())); + QObject::connect(ui->doRestartI2PDPushButton, SIGNAL(released()), this, SLOT(handleDoRestartButton())); + # define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option)) initFileChooser( OPTION("","conf",[](){return "";}), ui->configFileLineEdit, ui->configFileBrowsePushButton); @@ -326,6 +331,12 @@ void MainWindow::handleGracefulQuitButton() { , this, SLOT(handleGracefulQuitTimerEvent())); } +void MainWindow::handleDoRestartButton() { + qDebug()<<"Do Restart pressed."; + emit i2pController->restartDaemon(); +} + + void MainWindow::handleGracefulQuitTimerEvent() { qDebug("Hiding the main window"); #ifndef ANDROID @@ -614,3 +625,7 @@ void MainWindow::addServerTunnelPushButtonReleased() { void MainWindow::addClientTunnelPushButtonReleased() { CreateDefaultClientTunnel(); } + +void MainWindow::setI2PController(i2p::qt::Controller* controller_) { + this->i2pController = controller_; +} diff --git a/qt/i2pd_qt/mainwindow.h b/qt/i2pd_qt/mainwindow.h index 03057f2e..77699f28 100644 --- a/qt/i2pd_qt/mainwindow.h +++ b/qt/i2pd_qt/mainwindow.h @@ -51,6 +51,8 @@ #include "TunnelsPageUpdateListener.h" +#include "DaemonQT.h" + template bool isType(boost::any& a) { return @@ -311,6 +313,10 @@ using namespace i2p::client; class TunnelPane; +using namespace i2p::qt; + +class Controller; + class MainWindow : public QMainWindow { Q_OBJECT @@ -318,6 +324,8 @@ public: explicit MainWindow(QWidget *parent=0); ~MainWindow(); + void setI2PController(i2p::qt::Controller* controller_); + //typedef std::function DefaultValueGetter; //#ifndef ANDROID @@ -327,6 +335,7 @@ public: private slots: void handleQuitButton(); void handleGracefulQuitButton(); + void handleDoRestartButton(); void handleGracefulQuitTimerEvent(); #ifndef ANDROID void setIcon(); @@ -351,6 +360,8 @@ private: Ui::MainWindow* ui; + i2p::qt::Controller* i2pController; + protected: #ifndef ANDROID void closeEvent(QCloseEvent *event);