diff --git a/src/trackslider.cpp b/src/trackslider.cpp
index 885df055b..6e016c8e2 100644
--- a/src/trackslider.cpp
+++ b/src/trackslider.cpp
@@ -10,10 +10,25 @@ TrackSlider::TrackSlider(QWidget* parent)
ui_.elapsed->setFont(font);
ui_.remaining->setFont(font);
+ UpdateLabelWidth();
+
connect(ui_.slider, SIGNAL(sliderMoved(int)), SIGNAL(ValueChanged(int)));
connect(ui_.slider, SIGNAL(valueChanged(int)), SLOT(ValueMaybeChanged(int)));
}
+void TrackSlider::UpdateLabelWidth() {
+ // We set the label's minimum size so it won't resize itself when the user
+ // is dragging the slider.
+ QString old_text = ui_.elapsed->text();
+ ui_.elapsed->setText("0:00:00");
+ ui_.elapsed->setMinimumWidth(0);
+ int width = ui_.elapsed->sizeHint().width();
+ ui_.elapsed->setText(old_text);
+
+ ui_.elapsed->setMinimumWidth(width);
+ ui_.remaining->setMinimumWidth(width);
+}
+
QSize TrackSlider::sizeHint() const {
int width = 500;
width += ui_.elapsed->sizeHint().width();
@@ -75,3 +90,13 @@ void TrackSlider::ValueMaybeChanged(int value) {
UpdateTimes(value);
emit ValueChanged(value);
}
+
+bool TrackSlider::event(QEvent* e) {
+ switch (e->type()) {
+ case QEvent::ApplicationFontChange:
+ case QEvent::StyleChange:
+ UpdateLabelWidth();
+ break;
+ }
+ return false;
+}
diff --git a/src/trackslider.h b/src/trackslider.h
index 79cbcfc76..6ac4c21bf 100644
--- a/src/trackslider.h
+++ b/src/trackslider.h
@@ -14,6 +14,9 @@ class TrackSlider : public QWidget {
// QWidget
QSize sizeHint() const;
+ // QObject
+ bool event(QEvent *);
+
static QString PrettyTime(int seconds);
public slots:
@@ -29,6 +32,7 @@ class TrackSlider : public QWidget {
private:
void UpdateTimes(int elapsed);
+ void UpdateLabelWidth();
private:
Ui::TrackSlider ui_;
diff --git a/src/trackslider.ui b/src/trackslider.ui
index 2fe56ca0b..ddfe9adfb 100644
--- a/src/trackslider.ui
+++ b/src/trackslider.ui
@@ -25,6 +25,9 @@
0:00:00
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
-