From c33dddbd4751402d6cac2e3e8e9c3f776850a257 Mon Sep 17 00:00:00 2001 From: Yozka Date: Wed, 16 Jan 2019 16:23:07 +0500 Subject: [PATCH] set title bar and title toggle view action --- src/DockWidget.cpp | 15 ++++++++++++--- src/DockWidgetTab.cpp | 8 ++++++++ src/DockWidgetTab.h | 7 +++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 7dc5b2a..bf6afd9 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -62,11 +62,11 @@ struct DockWidgetPrivate CDockWidget* _this; QBoxLayout* Layout; QWidget* Widget = nullptr; - CDockWidgetTab* TabWidget; + CDockWidgetTab* TabWidget = nullptr; CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures; CDockManager* DockManager = nullptr; CDockAreaWidget* DockArea = nullptr; - QAction* ToggleViewAction; + QAction* ToggleViewAction = nullptr; bool Closed = false; QScrollArea* ScrollArea = nullptr; QToolBar* ToolBar = nullptr; @@ -497,7 +497,16 @@ bool CDockWidget::event(QEvent *e) { if (e->type() == QEvent::WindowTitleChange) { - emit titleChanged(windowTitle()); + const auto title = windowTitle(); + if (d->TabWidget) + { + d->TabWidget->setText(title); + } + if (d->ToggleViewAction) + { + d->ToggleViewAction->setText(title); + } + emit titleChanged(title); } return QFrame::event(e); } diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index b99288b..3ee3898 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -466,6 +466,14 @@ void CDockWidgetTab::setVisible(bool visible) } +//============================================================================ +void CDockWidgetTab::setText(const QString& title) +{ + d->TitleLabel->setText(title); +} + + + //============================================================================ bool CDockWidgetTab::isClosable() const { diff --git a/src/DockWidgetTab.h b/src/DockWidgetTab.h index 692d940..0642cc9 100644 --- a/src/DockWidgetTab.h +++ b/src/DockWidgetTab.h @@ -125,6 +125,12 @@ public: */ QString text() const; + + /** + * Sets the tab text + */ + void setText(const QString& title); + /** * This function returns true if the assigned dock widget is closeable */ @@ -132,6 +138,7 @@ public: public slots: virtual void setVisible(bool visible); + signals: void activeTabChanged();