restart button now has a handler

This commit is contained in:
hypnosis-i2p 2017-07-28 11:59:45 +08:00
parent a83be187f3
commit 3118d7bede
3 changed files with 27 additions and 0 deletions

View File

@ -161,6 +161,7 @@ namespace qt
{ {
i2p::qt::Controller daemonQtController(daemon); i2p::qt::Controller daemonQtController(daemon);
w.setI2PController(&daemonQtController);
qDebug("Starting the daemon..."); qDebug("Starting the daemon...");
emit daemonQtController.startDaemon(); emit daemonQtController.startDaemon();
//daemon.start (); //daemon.start ();

View File

@ -17,6 +17,8 @@
#include <fstream> #include <fstream>
#include "DaemonQT.h"
std::string programOptionsWriterCurrentSection; std::string programOptionsWriterCurrentSection;
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
@ -25,6 +27,7 @@ MainWindow::MainWindow(QWidget *parent) :
,quitting(false) ,quitting(false)
#endif #endif
,ui(new Ui::MainWindow) ,ui(new Ui::MainWindow)
,i2pController(nullptr)
,configItems() ,configItems()
,datadir() ,datadir()
,confpath() ,confpath()
@ -75,6 +78,8 @@ MainWindow::MainWindow(QWidget *parent) :
QObject::connect(ui->fastQuitPushButton, SIGNAL(released()), this, SLOT(handleQuitButton())); QObject::connect(ui->fastQuitPushButton, SIGNAL(released()), this, SLOT(handleQuitButton()));
QObject::connect(ui->gracefulQuitPushButton, SIGNAL(released()), this, SLOT(handleGracefulQuitButton())); 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)) # define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option))
initFileChooser( OPTION("","conf",[](){return "";}), ui->configFileLineEdit, ui->configFileBrowsePushButton); initFileChooser( OPTION("","conf",[](){return "";}), ui->configFileLineEdit, ui->configFileBrowsePushButton);
@ -326,6 +331,12 @@ void MainWindow::handleGracefulQuitButton() {
, this, SLOT(handleGracefulQuitTimerEvent())); , this, SLOT(handleGracefulQuitTimerEvent()));
} }
void MainWindow::handleDoRestartButton() {
qDebug()<<"Do Restart pressed.";
emit i2pController->restartDaemon();
}
void MainWindow::handleGracefulQuitTimerEvent() { void MainWindow::handleGracefulQuitTimerEvent() {
qDebug("Hiding the main window"); qDebug("Hiding the main window");
#ifndef ANDROID #ifndef ANDROID
@ -614,3 +625,7 @@ void MainWindow::addServerTunnelPushButtonReleased() {
void MainWindow::addClientTunnelPushButtonReleased() { void MainWindow::addClientTunnelPushButtonReleased() {
CreateDefaultClientTunnel(); CreateDefaultClientTunnel();
} }
void MainWindow::setI2PController(i2p::qt::Controller* controller_) {
this->i2pController = controller_;
}

View File

@ -51,6 +51,8 @@
#include "TunnelsPageUpdateListener.h" #include "TunnelsPageUpdateListener.h"
#include "DaemonQT.h"
template<typename ValueType> template<typename ValueType>
bool isType(boost::any& a) { bool isType(boost::any& a) {
return return
@ -311,6 +313,10 @@ using namespace i2p::client;
class TunnelPane; class TunnelPane;
using namespace i2p::qt;
class Controller;
class MainWindow : public QMainWindow { class MainWindow : public QMainWindow {
Q_OBJECT Q_OBJECT
@ -318,6 +324,8 @@ public:
explicit MainWindow(QWidget *parent=0); explicit MainWindow(QWidget *parent=0);
~MainWindow(); ~MainWindow();
void setI2PController(i2p::qt::Controller* controller_);
//typedef std::function<QString ()> DefaultValueGetter; //typedef std::function<QString ()> DefaultValueGetter;
//#ifndef ANDROID //#ifndef ANDROID
@ -327,6 +335,7 @@ public:
private slots: private slots:
void handleQuitButton(); void handleQuitButton();
void handleGracefulQuitButton(); void handleGracefulQuitButton();
void handleDoRestartButton();
void handleGracefulQuitTimerEvent(); void handleGracefulQuitTimerEvent();
#ifndef ANDROID #ifndef ANDROID
void setIcon(); void setIcon();
@ -351,6 +360,8 @@ private:
Ui::MainWindow* ui; Ui::MainWindow* ui;
i2p::qt::Controller* i2pController;
protected: protected:
#ifndef ANDROID #ifndef ANDROID
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);