mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
refs #335, updated dock widget
* removed unused methods * added toggleVisibility * renamed slot
This commit is contained in:
committed by
Roland Winklmeier
parent
3617fcdfec
commit
6e332683b1
@@ -24,7 +24,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
// connect
|
// connect
|
||||||
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::ps_onTopLevelChanged);
|
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::ps_onTopLevelChanged);
|
||||||
connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged);
|
connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CDockWidget::ps_onStyleSheetsChanged);
|
||||||
|
connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::ps_onVisibilityChanged);
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
@@ -74,6 +75,18 @@ namespace BlackGui
|
|||||||
this->setFloating(!this->isFloating());
|
this->setFloating(!this->isFloating());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDockWidget::toggleVisibility()
|
||||||
|
{
|
||||||
|
if (this->isVisible())
|
||||||
|
{
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CDockWidget::closeEvent(QCloseEvent *event)
|
void CDockWidget::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
if (this->isFloating())
|
if (this->isFloating())
|
||||||
@@ -93,18 +106,6 @@ namespace BlackGui
|
|||||||
CStyleSheetUtility::useStyleSheetInDerivedWidget(this);
|
CStyleSheetUtility::useStyleSheetInDerivedWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::hideEvent(QHideEvent *event)
|
|
||||||
{
|
|
||||||
// qDebug() << "hide" << this->objectName() << "v:" << isVisible() << "h:" << isHidden();
|
|
||||||
QDockWidget::hideEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDockWidget::showEvent(QShowEvent *event)
|
|
||||||
{
|
|
||||||
// qDebug() << "show" << this->objectName() << "v:" << isVisible() << "h:" << isHidden();
|
|
||||||
QDockWidget::showEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDockWidget::addToContextMenu(QMenu *contextMenu) const
|
void CDockWidget::addToContextMenu(QMenu *contextMenu) const
|
||||||
{
|
{
|
||||||
if (this->isFloating())
|
if (this->isFloating())
|
||||||
@@ -180,7 +181,12 @@ namespace BlackGui
|
|||||||
Q_UNUSED(selectedItem);
|
Q_UNUSED(selectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::onStyleSheetsChanged()
|
void CDockWidget::ps_onVisibilityChanged(bool visible)
|
||||||
|
{
|
||||||
|
this->m_dockWidgetVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDockWidget::ps_onStyleSheetsChanged()
|
||||||
{
|
{
|
||||||
// void, for further extensions
|
// void, for further extensions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ namespace BlackGui
|
|||||||
//! Selected when tabbed
|
//! Selected when tabbed
|
||||||
bool isSelected() const { return this->m_selected; }
|
bool isSelected() const { return this->m_selected; }
|
||||||
|
|
||||||
|
//! Is widget visible? Not to be confused with \sa QWidget::isVisbible
|
||||||
|
//! \remarks Logical vsibility as in \sa QDockWidget::visibilityChanged
|
||||||
|
bool isWidgetVisible() const { return this->m_dockWidgetVisible && this->isVisible(); }
|
||||||
|
|
||||||
//! Show the window title when docked
|
//! Show the window title when docked
|
||||||
void showTitleWhenDocked(bool show);
|
void showTitleWhenDocked(bool show);
|
||||||
|
|
||||||
@@ -83,6 +87,9 @@ namespace BlackGui
|
|||||||
//! Toggle floating
|
//! Toggle floating
|
||||||
void toggleFloating();
|
void toggleFloating();
|
||||||
|
|
||||||
|
//! Toggle visibility
|
||||||
|
void toggleVisibility();
|
||||||
|
|
||||||
//! Set title and internally keep a backup
|
//! Set title and internally keep a backup
|
||||||
void setWindowTitle(const QString &title);
|
void setWindowTitle(const QString &title);
|
||||||
|
|
||||||
@@ -100,12 +107,6 @@ namespace BlackGui
|
|||||||
//! \copydoc QWidget::paintEvent
|
//! \copydoc QWidget::paintEvent
|
||||||
virtual void paintEvent(QPaintEvent *event) override;
|
virtual void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
//! \copydoc QWidget::hideEvent
|
|
||||||
void hideEvent(QHideEvent *event) override;
|
|
||||||
|
|
||||||
//! \copydoc QWidget::showEvent
|
|
||||||
void showEvent(QShowEvent *event) override;
|
|
||||||
|
|
||||||
//! Contribute to menu
|
//! Contribute to menu
|
||||||
virtual void addToContextMenu(QMenu *contextMenu) const;
|
virtual void addToContextMenu(QMenu *contextMenu) const;
|
||||||
|
|
||||||
@@ -125,6 +126,9 @@ namespace BlackGui
|
|||||||
//! Context menu
|
//! Context menu
|
||||||
virtual void ps_showContextMenu(const QPoint &pos);
|
virtual void ps_showContextMenu(const QPoint &pos);
|
||||||
|
|
||||||
|
//! Visibility has changed
|
||||||
|
virtual void ps_onVisibilityChanged(bool visible);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_emptyTitleBar = nullptr; //!< replacing default title bar
|
QWidget *m_emptyTitleBar = nullptr; //!< replacing default title bar
|
||||||
QWidget *m_titleBarOriginal = nullptr; //!< the original title bar
|
QWidget *m_titleBarOriginal = nullptr; //!< the original title bar
|
||||||
@@ -136,9 +140,11 @@ namespace BlackGui
|
|||||||
bool m_windowTitleWhenDocked = true;
|
bool m_windowTitleWhenDocked = true;
|
||||||
bool m_wasAlreadyFloating = false;
|
bool m_wasAlreadyFloating = false;
|
||||||
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()
|
||||||
|
|
||||||
//! Empty widget with no size
|
//! Empty widget with no size
|
||||||
void initTitleBarWidgets();
|
void initTitleBarWidgets();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user