mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T747, window to top/back
This commit is contained in:
@@ -870,6 +870,19 @@ namespace BlackGui
|
||||
this->toggleStayOnTop();
|
||||
});
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
|
||||
a = menu.addAction("Toggle to front or back");
|
||||
c = connect(a, &QAction::triggered, this, &CGuiApplication::windowToFrontBackToggle);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed");
|
||||
|
||||
a = menu.addAction("Window to front");
|
||||
c = connect(a, &QAction::triggered, this, &CGuiApplication::windowToFront);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed");
|
||||
|
||||
a = menu.addAction("Window to back");
|
||||
c = connect(a, &QAction::triggered, this, &CGuiApplication::windowToBack);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "connect failed");
|
||||
|
||||
Q_UNUSED(c)
|
||||
}
|
||||
|
||||
@@ -894,7 +907,7 @@ namespace BlackGui
|
||||
dialog.exec();
|
||||
});
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
Q_UNUSED(c);
|
||||
Q_UNUSED(c)
|
||||
|
||||
// https://joekuan.wordpress.com/2015/09/23/list-of-qt-icons/
|
||||
a = menu.addAction(QApplication::style()->standardIcon(QStyle::SP_TitleBarMenuButton), "About Qt");
|
||||
@@ -903,7 +916,7 @@ namespace BlackGui
|
||||
QApplication::aboutQt();
|
||||
});
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
|
||||
Q_UNUSED(c);
|
||||
Q_UNUSED(c)
|
||||
}
|
||||
|
||||
void CGuiApplication::showHelp(const QString &context) const
|
||||
@@ -1149,9 +1162,47 @@ namespace BlackGui
|
||||
const bool onTop = CGuiUtility::toggleStayOnTop(w);
|
||||
CLogMessage(w).info(onTop ? QStringLiteral("Window on top") : QStringLiteral("Window not always on top"));
|
||||
emit this->alwaysOnTop(onTop);
|
||||
m_frontBack = onTop;
|
||||
return onTop;
|
||||
}
|
||||
|
||||
void CGuiApplication::windowToFront()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
QMainWindow *w = sGui->mainApplicationWindow();
|
||||
if (!w) { return; }
|
||||
m_frontBack = true;
|
||||
w->showNormal(); //bring window to top on OSX
|
||||
w->raise(); //bring window from minimized state on OSX
|
||||
w->activateWindow(); //bring window to front/unminimize on windows
|
||||
}
|
||||
|
||||
void CGuiApplication::windowToBack()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
m_frontBack = false;
|
||||
QMainWindow *w = this->mainApplicationWindow();
|
||||
if (!w) { return; }
|
||||
w->lower();
|
||||
}
|
||||
|
||||
void CGuiApplication::windowToFrontBackToggle()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
QMainWindow *w = sGui->mainApplicationWindow();
|
||||
if (!w) { return; }
|
||||
if (w->isMinimized()) { this->windowToFront(); return; }
|
||||
if (w->isMaximized()) { this->windowToBack(); return; }
|
||||
if (m_frontBack)
|
||||
{
|
||||
this->windowToBack();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->windowToFront();
|
||||
}
|
||||
}
|
||||
|
||||
void CGuiApplication::triggerNewVersionCheck(int delayedMs)
|
||||
{
|
||||
if (!m_updateSetting.get()) { return; }
|
||||
|
||||
@@ -230,6 +230,12 @@ namespace BlackGui
|
||||
//! Toggle stay on top
|
||||
bool toggleStayOnTop();
|
||||
|
||||
//! Window to front/back @{
|
||||
void windowToFront();
|
||||
void windowToBack();
|
||||
void windowToFrontBackToggle();
|
||||
//! @}
|
||||
|
||||
//! Save the main widget state?
|
||||
void setSaveMainWidgetState(bool save) { m_saveMainWidgetState = save; }
|
||||
|
||||
@@ -335,7 +341,8 @@ namespace BlackGui
|
||||
CStyleSheetUtility m_styleSheetUtility {{}, this}; //!< style sheet utility
|
||||
bool m_uiSetupCompleted = false; //!< ui setup completed
|
||||
bool m_saveMainWidgetState = true; //!< save/restore main widget's state
|
||||
QScopedPointer<CSplashScreen> m_splashScreen; //!< splash screen
|
||||
bool m_frontBack = true;
|
||||
QScopedPointer<CSplashScreen> m_splashScreen; //!< splash screen
|
||||
Components::CUpdateInfoDialog *m_updateDialog = nullptr; //!< software installation dialog
|
||||
Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent)
|
||||
BlackMisc::CSettingReadOnly<Settings::TGeneralGui> m_guiSettings { this, &CGuiApplication::settingsChanged };
|
||||
|
||||
Reference in New Issue
Block a user