mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
MeterWidgets must move / hide when main window is moved / minimized (#3458)
When the main window is minimized on Linux, the MeterWidgets stay on the desktop. A signal were added to the main window for state changes. The VideoWindow connects to that signal and hide/shows the MeterWidgets accordingly. Currently, when you move the main window, the MeterWidgets do not follow and become out of place. On every Telemetry update, check if the real position on screen of the video window has changed in order to update the position of the meter widgets. The Video Window can move for several reasons like when scrolled or when the Main Window is moved. The Meter Widgets are not clipped like the Video Window by its scroll area parent though.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 *);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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<MeterWidget*> m_metersWidget;
|
||||
QPoint prevPosition;
|
||||
|
||||
#ifdef GC_VIDEO_VLC
|
||||
|
||||
|
||||
Reference in New Issue
Block a user