UI: Restore window's visibility on restart.

This commit is contained in:
Nodir Temirkhodjaev 2019-02-09 00:25:01 +05:00
parent a9f08fa4a4
commit 4137092e97
4 changed files with 23 additions and 1 deletions

View File

@ -41,6 +41,7 @@
FortManager::FortManager(FortSettings *fortSettings,
QObject *parent) :
QObject(parent),
m_exiting(false),
m_trayIcon(new QSystemTrayIcon(this)),
m_engine(nullptr),
m_appWindow(nullptr),
@ -216,6 +217,16 @@ void FortManager::closeEngine()
}
}
void FortManager::launch()
{
showTrayIcon();
if (m_fortSettings->graphWindowEnabled()
&& m_fortSettings->graphWindowVisible()) {
showGraphWindow();
}
}
void FortManager::showTrayIcon()
{
m_trayIcon->show();
@ -318,6 +329,8 @@ void FortManager::switchGraphWindow()
void FortManager::exit(int retcode)
{
m_exiting = true;
closeGraphWindow();
closeWindow();
@ -527,6 +540,7 @@ void FortManager::restoreWindowState()
void FortManager::saveGraphWindowState()
{
m_fortSettings->setGraphWindowVisible(m_exiting);
m_fortSettings->setGraphWindowGeometry(m_graphWindowState->geometry());
m_fortSettings->setGraphWindowMaximized(m_graphWindowState->maximized());
}

View File

@ -47,6 +47,8 @@ signals:
void firewallConfToEditChanged();
public slots:
void launch();
void showTrayIcon();
void showTrayMessage(const QString &message);
void showTrayMenu(QMouseEvent *event);
@ -131,6 +133,8 @@ private:
const QObject *receiver = nullptr, const char *member = nullptr);
private:
uint m_exiting : 1;
MainWindow m_window; // dummy window for tray icon
QSystemTrayIcon *m_trayIcon;

View File

@ -51,6 +51,10 @@ public:
void setWindowMaximized(bool on) { setIniValue("window/maximized", on); }
bool graphWindowEnabled() const { return iniBool("graphWindow/enabled"); }
void setGraphWindowEnabled(bool on) { setIniValue("graphWindow/enabled", on); }
bool graphWindowVisible() const { return iniBool("graphWindow/visible"); }
void setGraphWindowVisible(bool on) { setIniValue("graphWindow/visible", on); }
QRect graphWindowGeometry() const { return iniValue("graphWindow/geometry").toRect(); }
void setGraphWindowGeometry(const QRect &v) { setIniValue("graphWindow/geometry", v); }

View File

@ -59,7 +59,7 @@ int main(int argc, char *argv[])
return FORT_ERROR_DEVICE;
}
fortManager.showTrayIcon();
fortManager.launch();
// Process control requests from clients
if (!controlManager.listen(&fortManager)) {