Skip to content

Commit c33dddb

Browse files
set title bar and title toggle view action
1 parent 653f475 commit c33dddb

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/DockWidget.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ struct DockWidgetPrivate
6262
CDockWidget* _this;
6363
QBoxLayout* Layout;
6464
QWidget* Widget = nullptr;
65-
CDockWidgetTab* TabWidget;
65+
CDockWidgetTab* TabWidget = nullptr;
6666
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
6767
CDockManager* DockManager = nullptr;
6868
CDockAreaWidget* DockArea = nullptr;
69-
QAction* ToggleViewAction;
69+
QAction* ToggleViewAction = nullptr;
7070
bool Closed = false;
7171
QScrollArea* ScrollArea = nullptr;
7272
QToolBar* ToolBar = nullptr;
@@ -497,7 +497,16 @@ bool CDockWidget::event(QEvent *e)
497497
{
498498
if (e->type() == QEvent::WindowTitleChange)
499499
{
500-
emit titleChanged(windowTitle());
500+
const auto title = windowTitle();
501+
if (d->TabWidget)
502+
{
503+
d->TabWidget->setText(title);
504+
}
505+
if (d->ToggleViewAction)
506+
{
507+
d->ToggleViewAction->setText(title);
508+
}
509+
emit titleChanged(title);
501510
}
502511
return QFrame::event(e);
503512
}

src/DockWidgetTab.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ void CDockWidgetTab::setVisible(bool visible)
466466
}
467467

468468

469+
//============================================================================
470+
void CDockWidgetTab::setText(const QString& title)
471+
{
472+
d->TitleLabel->setText(title);
473+
}
474+
475+
476+
469477
//============================================================================
470478
bool CDockWidgetTab::isClosable() const
471479
{

src/DockWidgetTab.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,20 @@ private slots:
125125
*/
126126
QString text() const;
127127

128+
129+
/**
130+
* Sets the tab text
131+
*/
132+
void setText(const QString& title);
133+
128134
/**
129135
* This function returns true if the assigned dock widget is closeable
130136
*/
131137
bool isClosable() const;
132138

133139
public slots:
134140
virtual void setVisible(bool visible);
141+
135142

136143
signals:
137144
void activeTabChanged();

0 commit comments

Comments
 (0)