|
|
|
@ -8,31 +8,56 @@ namespace i2p
@@ -8,31 +8,56 @@ namespace i2p
|
|
|
|
|
{ |
|
|
|
|
namespace util |
|
|
|
|
{ |
|
|
|
|
std::unique_ptr<QApplication> app; |
|
|
|
|
bool DaemonQT::init(int argc, char* argv[]) |
|
|
|
|
class DaemonQTImpl: public std::enable_shared_from_this<DaemonQTImpl> |
|
|
|
|
{ |
|
|
|
|
app.reset (new QApplication (argc, argv)); |
|
|
|
|
return Daemon_Singleton::init(argc, argv); |
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
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 () |
|
|
|
|
{ |
|
|
|
|
MainWindow w; |
|
|
|
|
w.show (); |
|
|
|
|
if (app) |
|
|
|
|
if (m_Impl) |
|
|
|
|
{ |
|
|
|
|
app->exec(); |
|
|
|
|
app.reset (nullptr); |
|
|
|
|
m_Impl->Run (); |
|
|
|
|
m_Impl = nullptr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|