mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Some CDockWidget improvements
* save original dock areas * init dw_InfoBarStatus as it is not part of an info area (which does that)
This commit is contained in:
committed by
Mat Sutcliffe
parent
2f1e3f47f9
commit
e8786f9794
@@ -53,6 +53,7 @@ namespace BlackGui
|
|||||||
// init settings
|
// init settings
|
||||||
this->onStyleSheetsChanged();
|
this->onStyleSheetsChanged();
|
||||||
this->initTitleBarWidgets();
|
this->initTitleBarWidgets();
|
||||||
|
m_originalAreas = this->allowedAreas();
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
m_input = new CMarginsInput(this);
|
m_input = new CMarginsInput(this);
|
||||||
@@ -257,24 +258,29 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDockWidget::toggleFloating()
|
void CDockWidget::toggleFloating()
|
||||||
{
|
{
|
||||||
const bool floating = !this->isFloating();
|
const bool changeToFloating = !this->isFloating();
|
||||||
if (!floating) { this->setFrameless(false); } // remove frameless if not floating
|
if (!changeToFloating) { this->setFrameless(false); } // remove frameless if not floating
|
||||||
|
|
||||||
|
// disable the interactive docking
|
||||||
|
if (changeToFloating)
|
||||||
|
{
|
||||||
|
m_originalAreas = this->allowedAreas();
|
||||||
|
this->setAllowedAreas(Qt::NoDockWidgetArea);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->setAllowedAreas(m_originalAreas);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setAlwaysOnTop(m_alwaysOnTop && changeToFloating);
|
||||||
|
this->setFloating(changeToFloating);
|
||||||
|
|
||||||
const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers();
|
const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers();
|
||||||
const bool shift = km.testFlag(Qt::ShiftModifier);
|
const bool shift = km.testFlag(Qt::ShiftModifier);
|
||||||
|
|
||||||
this->setFloating(floating);
|
|
||||||
this->setAlwaysOnTop(m_alwaysOnTop && floating);
|
|
||||||
|
|
||||||
// disable the interactive docking
|
|
||||||
if (floating)
|
|
||||||
{
|
|
||||||
this->setAllowedAreas(Qt::NoDockWidgetArea);
|
|
||||||
}
|
|
||||||
|
|
||||||
// with shift ALWAYS reset
|
// with shift ALWAYS reset
|
||||||
if (shift && floating) { this->resetPosition(); }
|
if (shift && changeToFloating) { this->resetPosition(); }
|
||||||
if (floating)
|
if (changeToFloating)
|
||||||
{
|
{
|
||||||
// check where we are, otherwise reset if NOT appropriate
|
// check where we are, otherwise reset if NOT appropriate
|
||||||
const QPoint p = this->rect().topLeft();
|
const QPoint p = this->rect().topLeft();
|
||||||
@@ -392,7 +398,7 @@ namespace BlackGui
|
|||||||
});
|
});
|
||||||
**/
|
**/
|
||||||
|
|
||||||
event->setAccepted(false); // refuse -> do not close
|
event->setAccepted(false); // refuse -> do not close (otherwise crash)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Top level has changed for given widget
|
//! Top level has changed for given widget
|
||||||
void widgetTopLevelChanged(BlackGui::CDockWidget *, bool topLevel);
|
void widgetTopLevelChanged(CDockWidget *, bool topLevel);
|
||||||
|
|
||||||
//! Font size signals @{
|
//! Font size signals @{
|
||||||
void fontSizePlus();
|
void fontSizePlus();
|
||||||
@@ -242,6 +242,7 @@ namespace BlackGui
|
|||||||
QSize m_lastFloatingSize; //!< last floating position
|
QSize m_lastFloatingSize; //!< last floating position
|
||||||
QPoint m_offsetWhenFloating; //!< initial offset to main window when floating first time
|
QPoint m_offsetWhenFloating; //!< initial offset to main window when floating first time
|
||||||
QPoint m_lastFloatingPosition; //!< last floating position
|
QPoint m_lastFloatingPosition; //!< last floating position
|
||||||
|
Qt::DockWidgetAreas m_originalAreas; //!< areas before floating
|
||||||
|
|
||||||
BlackMisc::CSetting<BlackGui::Settings::TDockWidget> m_settings { this, &CDockWidget::settingsChanged };
|
BlackMisc::CSetting<BlackGui::Settings::TDockWidget> m_settings { this, &CDockWidget::settingsChanged };
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using namespace BlackGui::Components;
|
|||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
CDockWidgetInfoBar::CDockWidgetInfoBar(QWidget *parent) : CDockWidget(parent)
|
CDockWidgetInfoBar::CDockWidgetInfoBar(QWidget *parent) : CDockWidget(false, parent)
|
||||||
{
|
{
|
||||||
this->setWindowTitle("Info status bar");
|
this->setWindowTitle("Info status bar");
|
||||||
this->setWindowIcon(CIcons::swift24());
|
this->setWindowIcon(CIcons::swift24());
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ namespace BlackGui
|
|||||||
//! Force an reload
|
//! Force an reload
|
||||||
void reloadStyleSheet() { this->onStyleSheetsChanged(); }
|
void reloadStyleSheet() { this->onStyleSheetsChanged(); }
|
||||||
|
|
||||||
|
//! \copydoc CDockWidget::initialFloating
|
||||||
|
//! \remark special case to allow init
|
||||||
|
virtual void initialFloating() override { CDockWidget::initialFloating(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Contribute to menu
|
//! Contribute to menu
|
||||||
virtual void addToContextMenu(QMenu *contextMenu) const override;
|
virtual void addToContextMenu(QMenu *contextMenu) const override;
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ void SwiftGuiStd::init()
|
|||||||
|
|
||||||
if (m_init) { return; }
|
if (m_init) { return; }
|
||||||
|
|
||||||
|
ui->dw_InfoBarStatus->initialFloating();
|
||||||
|
|
||||||
this->setVisible(false); // hide all, so no flashing windows during init
|
this->setVisible(false); // hide all, so no flashing windows during init
|
||||||
m_mwaStatusBar = &m_statusBar;
|
m_mwaStatusBar = &m_statusBar;
|
||||||
m_mwaOverlayFrame = ui->fr_CentralFrameInside;
|
m_mwaOverlayFrame = ui->fr_CentralFrameInside;
|
||||||
|
|||||||
Reference in New Issue
Block a user