mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
Ref T447, allow to set "on top" flag for floating dock widgets
This commit is contained in:
@@ -249,8 +249,9 @@ namespace BlackGui
|
|||||||
void CDockWidget::toggleFloating()
|
void CDockWidget::toggleFloating()
|
||||||
{
|
{
|
||||||
const bool floating = !this->isFloating();
|
const bool floating = !this->isFloating();
|
||||||
if (!floating) { this->setFrameless(false); }
|
if (!floating) { this->setFrameless(false); } // remove frameless if not floating
|
||||||
this->setFloating(floating);
|
this->setFloating(floating);
|
||||||
|
this->setAlwaysOnTop(m_alwaysOnTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::toggleVisibility()
|
void CDockWidget::toggleVisibility()
|
||||||
@@ -267,13 +268,28 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDockWidget::toggleFrameless()
|
void CDockWidget::toggleFrameless()
|
||||||
{
|
{
|
||||||
if (this->isFrameless())
|
const bool frameless = this->isFrameless();
|
||||||
|
this->setFrameless(!frameless);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDockWidget::toggleAlwaysOnTop()
|
||||||
|
{
|
||||||
|
m_alwaysOnTop = !m_alwaysOnTop;
|
||||||
|
if (this->isFloating())
|
||||||
{
|
{
|
||||||
this->setFrameless(false);
|
this->setAlwaysOnTopFlag(m_alwaysOnTop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDockWidget::setAlwaysOnTopFlag(bool onTop)
|
||||||
|
{
|
||||||
|
if (onTop)
|
||||||
|
{
|
||||||
|
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setFrameless(true);
|
this->setWindowFlags(this->windowFlags() & ~Qt::WindowStaysOnTopHint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,16 +352,13 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (this->isFloating())
|
if (this->isFloating())
|
||||||
{
|
{
|
||||||
|
const bool frameless = this->isFrameless();
|
||||||
|
const bool onTop = this->windowFlags() | Qt::WindowStaysOnTopHint;
|
||||||
|
|
||||||
contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating);
|
contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating);
|
||||||
if (this->isFrameless())
|
contextMenu->addAction(CIcons::tableSheet16(), frameless ? "Normal window" : "Frameless", this, &CDockWidget::toggleFrameless);
|
||||||
{
|
contextMenu->addAction(CIcons::dockTop16(), onTop ? "Not on top" : "Always on top", this, &CDockWidget::toggleAlwaysOnTop);
|
||||||
contextMenu->addAction(CIcons::tableSheet16(), "Normal window", this, &CDockWidget::toggleFrameless);
|
contextMenu->addAction(CIcons::refresh16(), "Redraw", this, QOverload<>::of(&CDockWidget::update));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
contextMenu->addAction(CIcons::tableSheet16(), "Frameless", this, &CDockWidget::toggleFrameless);
|
|
||||||
}
|
|
||||||
contextMenu->addAction(CIcons::refresh16(), "Redraw", this, SLOT(update()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ namespace BlackGui
|
|||||||
//! Toggle frameless mode (EXPERIMENTAL)
|
//! Toggle frameless mode (EXPERIMENTAL)
|
||||||
void toggleFrameless();
|
void toggleFrameless();
|
||||||
|
|
||||||
|
//! Toggle always on top
|
||||||
|
void toggleAlwaysOnTop();
|
||||||
|
|
||||||
|
//! Set always on top
|
||||||
|
void setAlwaysOnTop(bool onTop) { m_alwaysOnTop = onTop; }
|
||||||
|
|
||||||
//! Restore from settings
|
//! Restore from settings
|
||||||
bool restoreFromSettings();
|
bool restoreFromSettings();
|
||||||
|
|
||||||
@@ -181,7 +187,10 @@ namespace BlackGui
|
|||||||
//! Margins when docked
|
//! Margins when docked
|
||||||
QMargins getMarginsWhenDocked() const;
|
QMargins getMarginsWhenDocked() const;
|
||||||
|
|
||||||
//! Override close event
|
//! Set the on top flag
|
||||||
|
void setAlwaysOnTopFlag(bool onTop);
|
||||||
|
|
||||||
|
//! \copydoc QWidget::closeEvent
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
//! \copydoc QWidget::paintEvent
|
//! \copydoc QWidget::paintEvent
|
||||||
@@ -219,6 +228,7 @@ namespace BlackGui
|
|||||||
bool m_selected = false; //!< selected when tabbed
|
bool m_selected = false; //!< selected when tabbed
|
||||||
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
||||||
bool m_wasFrameless = false; //!< frameless when last floating
|
bool m_wasFrameless = false; //!< frameless when last floating
|
||||||
|
bool m_alwaysOnTop = false; //!< only effective if floating
|
||||||
CManagedStatusBar m_statusBar; //!< status bar when floating
|
CManagedStatusBar m_statusBar; //!< status bar when floating
|
||||||
QString m_windowTitleBackup; //!< original title, even if the widget title is deleted for layout purposes
|
QString m_windowTitleBackup; //!< original title, even if the widget title is deleted for layout purposes
|
||||||
QSize m_preferredSizeWhenFloating; //!< preferred size when floating 1st time
|
QSize m_preferredSizeWhenFloating; //!< preferred size when floating 1st time
|
||||||
|
|||||||
Reference in New Issue
Block a user