diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index eb031f127..d5196143e 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1037,6 +1037,17 @@ MainWindow::closeEvent(QCloseEvent* event) appsettings->setValue(GC_SETTINGS_MAIN_STATE, saveState()); } +void +MainWindow::changeEvent(QEvent *event) +{ + if(event->type() != QEvent::WindowStateChange) return; + + // Some overlay Widgets (Meter) are top level windows + // and need to follow the MainWindow state + Qt::WindowStates states = windowState(); + emit mainWindowStateChanged(states & Qt::WindowMinimized, isVisible()); +} + MainWindow::~MainWindow() { // aside from the tabs, we may need to clean diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index 50d1f9252..6feac7b3c 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -94,6 +94,9 @@ class MainWindow : public QMainWindow // currently selected tab Tab *athleteTab() { return currentTab; } + signals: + void mainWindowStateChanged(bool minimized, bool visible); + protected: // used by ChooseCyclistDialog to see which athletes @@ -104,6 +107,7 @@ class MainWindow : public QMainWindow virtual void resizeEvent(QResizeEvent*); virtual void moveEvent(QMoveEvent*); virtual void closeEvent(QCloseEvent*); + virtual void changeEvent(QEvent *); virtual void dragEnterEvent(QDragEnterEvent *); virtual void dropEvent(QDropEvent *); diff --git a/src/Train/VideoWindow.cpp b/src/Train/VideoWindow.cpp index 7635bd85a..238642f37 100644 --- a/src/Train/VideoWindow.cpp +++ b/src/Train/VideoWindow.cpp @@ -163,6 +163,7 @@ VideoWindow::VideoWindow(Context *context) : connect(context, SIGNAL(seek(long)), this, SLOT(seekPlayback(long))); connect(context, SIGNAL(unpause()), this, SLOT(resumePlayback())); connect(context, SIGNAL(mediaSelected(QString)), this, SLOT(mediaSelected(QString))); + connect(this->window(), SIGNAL(mainWindowStateChanged(bool, bool)), this, SLOT(mainWindowStateChanged(bool, bool))); } } @@ -201,6 +202,13 @@ void VideoWindow::resizeEvent(QResizeEvent * ) { foreach(MeterWidget* p_meterWidget , m_metersWidget) p_meterWidget->AdjustSizePos(); + prevPosition = mapToGlobal(pos()); +} + +void VideoWindow::mainWindowStateChanged(bool minimized, bool visible) +{ + if(minimized) foreach(MeterWidget* p, m_metersWidget) p->hide(); + else if(visible && isVisible()) foreach(MeterWidget* p, m_metersWidget) p->show(); } void VideoWindow::startPlayback() @@ -246,6 +254,7 @@ void VideoWindow::startPlayback() p_meterWidget->raise(); p_meterWidget->show(); } + prevPosition = mapToGlobal(pos()); } void VideoWindow::stopPlayback() @@ -416,6 +425,10 @@ void VideoWindow::telemetryUpdate(RealtimeData rtd) } } + // The Meter Widgets need to follow the Video Window when it moves + // (main window moves, scrolling...), we check the position at every update + if(mapToGlobal(pos()) != prevPosition) resizeEvent(NULL); + foreach(MeterWidget* p_meterWidget , m_metersWidget) p_meterWidget->update(); diff --git a/src/Train/VideoWindow.h b/src/Train/VideoWindow.h index b11b6833e..b105e3db0 100644 --- a/src/Train/VideoWindow.h +++ b/src/Train/VideoWindow.h @@ -176,6 +176,7 @@ class VideoWindow : public GcChartWindow void telemetryUpdate(RealtimeData rtd); void seekPlayback(long ms); void mediaSelected(QString filename); + void mainWindowStateChanged(bool minimized, bool visible); protected: @@ -192,6 +193,7 @@ class VideoWindow : public GcChartWindow bool m_MediaChanged; QList m_metersWidget; + QPoint prevPosition; #ifdef GC_VIDEO_VLC