From 129e446322cddde9adb7eca2d29704de8d40afe6 Mon Sep 17 00:00:00 2001 From: Steffen Baranowsky Date: Thu, 1 Sep 2016 10:24:25 +0200 Subject: [PATCH] Window title will be changed on rename track, now --- include/SubWindow.h | 2 ++ src/gui/SubWindow.cpp | 25 +++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/SubWindow.h b/include/SubWindow.h index 3a00ecf16..1169517ac 100644 --- a/include/SubWindow.h +++ b/include/SubWindow.h @@ -64,6 +64,7 @@ protected: virtual void moveEvent( QMoveEvent * event ); virtual void resizeEvent( QResizeEvent * event ); virtual void paintEvent( QPaintEvent * pe ); + virtual void changeEvent( QEvent * event ); private: const QSize m_buttonSize; @@ -82,6 +83,7 @@ private: static void elideText( QLabel *label, QString text ); bool isMaximized(); + void adjustTitleBar(); }; #endif diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 88eb1489f..ec4217579 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -121,6 +121,20 @@ void SubWindow::paintEvent( QPaintEvent * ) +void SubWindow::changeEvent( QEvent *event ) +{ + QMdiSubWindow::changeEvent( event ); + + if( event->type() == QEvent::WindowTitleChange ) + { + adjustTitleBar(); + } + +} + + + + void SubWindow::elideText( QLabel *label, QString text ) { QFontMetrics metrix( label->font() ); @@ -219,7 +233,7 @@ void SubWindow::moveEvent( QMoveEvent * event ) -void SubWindow::resizeEvent( QResizeEvent * event ) +void SubWindow::adjustTitleBar() { // button adjustments m_minimizeBtn->hide(); @@ -280,12 +294,19 @@ void SubWindow::resizeEvent( QResizeEvent * event ) elideText( m_windowTitle, widget()->windowTitle() ); m_windowTitle->setTextInteractionFlags( Qt::NoTextInteraction ); m_windowTitle->adjustSize(); +} + + + +void SubWindow::resizeEvent( QResizeEvent * event ) +{ + adjustTitleBar(); QMdiSubWindow::resizeEvent( event ); // if the window was resized and ISN'T minimized/maximized/fullscreen, // then save the current size - if( !isMax && !isMin && !isFullScreen() ) + if( !isMaximized() && !isMinimized() && !isFullScreen() ) { m_trackedNormalGeom.setSize( event->size() ); }