mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-23 07:50:13 +01:00
Show the time remaining as negative, like amarok
This commit is contained in:
parent
ee5facbd01
commit
427e24dece
@ -19,14 +19,18 @@ TrackSlider::TrackSlider(QWidget* parent)
|
||||
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);
|
||||
UpdateLabelWidth(ui_.elapsed, "0:00:00");
|
||||
UpdateLabelWidth(ui_.remaining, "-0:00:00");
|
||||
}
|
||||
|
||||
ui_.elapsed->setMinimumWidth(width);
|
||||
ui_.remaining->setMinimumWidth(width);
|
||||
void TrackSlider::UpdateLabelWidth(QLabel* label, const QString& text) {
|
||||
QString old_text = label->text();
|
||||
label->setText(text);
|
||||
label->setMinimumWidth(0);
|
||||
int width = label->sizeHint().width();
|
||||
label->setText(old_text);
|
||||
|
||||
label->setMinimumWidth(width);
|
||||
}
|
||||
|
||||
QSize TrackSlider::sizeHint() const {
|
||||
@ -50,7 +54,7 @@ void TrackSlider::SetValue(int elapsed, int total) {
|
||||
|
||||
void TrackSlider::UpdateTimes(int elapsed) {
|
||||
ui_.elapsed->setText(PrettyTime(elapsed));
|
||||
ui_.remaining->setText(PrettyTime(ui_.slider->maximum() - elapsed));
|
||||
ui_.remaining->setText("-" + PrettyTime(ui_.slider->maximum() - elapsed));
|
||||
|
||||
setEnabled(true);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ class TrackSlider : public QWidget {
|
||||
private:
|
||||
void UpdateTimes(int elapsed);
|
||||
void UpdateLabelWidth();
|
||||
void UpdateLabelWidth(QLabel* label, const QString& text);
|
||||
|
||||
private:
|
||||
Ui::TrackSlider ui_;
|
||||
|
Loading…
Reference in New Issue
Block a user