|
|
@ -8,31 +8,56 @@ namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
namespace util |
|
|
|
namespace util |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::unique_ptr<QApplication> app; |
|
|
|
class DaemonQTImpl: public std::enable_shared_from_this<DaemonQTImpl> |
|
|
|
bool DaemonQT::init(int argc, char* argv[]) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
app.reset (new QApplication (argc, argv)); |
|
|
|
public: |
|
|
|
return Daemon_Singleton::init(argc, argv); |
|
|
|
|
|
|
|
|
|
|
|
DaemonQTImpl (int argc, char* argv[]): |
|
|
|
|
|
|
|
m_App (argc, argv) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Run () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MainWindow w; |
|
|
|
|
|
|
|
w.show (); |
|
|
|
|
|
|
|
m_App.exec(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StartDaemon () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Daemon.start (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool DaemonQT::start() |
|
|
|
void StopDaemon () |
|
|
|
{ |
|
|
|
{ |
|
|
|
return Daemon_Singleton::start(); |
|
|
|
Daemon.stop (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool DaemonQT::stop() |
|
|
|
bool IsRunning () const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return Daemon_Singleton::stop(); |
|
|
|
return Daemon.running; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QApplication m_App; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool DaemonQT::init(int argc, char* argv[]) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_Impl = std::make_shared<DaemonQTImpl> (argc, argv); |
|
|
|
|
|
|
|
return Daemon_Singleton::init(argc, argv); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void DaemonQT::run () |
|
|
|
void DaemonQT::run () |
|
|
|
{ |
|
|
|
{ |
|
|
|
MainWindow w; |
|
|
|
if (m_Impl) |
|
|
|
w.show (); |
|
|
|
|
|
|
|
if (app) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
app->exec(); |
|
|
|
m_Impl->Run (); |
|
|
|
app.reset (nullptr); |
|
|
|
m_Impl = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|