mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
separate DaemonQT and DaemonQTImpl
This commit is contained in:
parent
14c85fa975
commit
eb96edbd31
2 changed files with 50 additions and 21 deletions
|
@ -8,32 +8,57 @@ namespace i2p
|
|||
{
|
||||
namespace util
|
||||
{
|
||||
std::unique_ptr<QApplication> app;
|
||||
class DaemonQTImpl: public std::enable_shared_from_this<DaemonQTImpl>
|
||||
{
|
||||
public:
|
||||
|
||||
DaemonQTImpl (int argc, char* argv[]):
|
||||
m_App (argc, argv)
|
||||
{
|
||||
}
|
||||
|
||||
void Run ()
|
||||
{
|
||||
MainWindow w;
|
||||
w.show ();
|
||||
m_App.exec();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void StartDaemon ()
|
||||
{
|
||||
Daemon.start ();
|
||||
}
|
||||
|
||||
void StopDaemon ()
|
||||
{
|
||||
Daemon.stop ();
|
||||
}
|
||||
|
||||
bool IsRunning () const
|
||||
{
|
||||
return Daemon.running;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
QApplication m_App;
|
||||
};
|
||||
|
||||
bool DaemonQT::init(int argc, char* argv[])
|
||||
{
|
||||
app.reset (new QApplication (argc, argv));
|
||||
m_Impl = std::make_shared<DaemonQTImpl> (argc, argv);
|
||||
return Daemon_Singleton::init(argc, argv);
|
||||
}
|
||||
|
||||
bool DaemonQT::start()
|
||||
{
|
||||
return Daemon_Singleton::start();
|
||||
}
|
||||
|
||||
bool DaemonQT::stop()
|
||||
{
|
||||
return Daemon_Singleton::stop();
|
||||
}
|
||||
|
||||
void DaemonQT::run ()
|
||||
{
|
||||
MainWindow w;
|
||||
w.show ();
|
||||
if (app)
|
||||
{
|
||||
app->exec();
|
||||
app.reset (nullptr);
|
||||
}
|
||||
if (m_Impl)
|
||||
{
|
||||
m_Impl->Run ();
|
||||
m_Impl = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue