Track slider fixes

This commit is contained in:
Jonas Kvinge 2018-11-17 03:25:21 +01:00
parent 9972dc192b
commit 6129ad1f4d
3 changed files with 11 additions and 6 deletions

View File

@ -1184,8 +1184,6 @@ void MainWindow::UpdateTrackPosition() {
if (length <= 0) {
// Probably a stream that we don't know the length of
//ui_->track_slider->SetStopped();
//tray_icon_->SetProgress(0);
return;
}

View File

@ -100,7 +100,10 @@ void TrackSlider::SetValue(int elapsed, int total) {
setting_value_ = true; // This is so we don't emit from QAbstractSlider::valueChanged
ui_->slider->setMaximum(total);
ui_->slider->setValue(elapsed);
if (!ui_->slider->isSliderDown()) {
ui_->slider->setValue(elapsed);
}
setting_value_ = false;
UpdateTimes(elapsed / kMsecPerSec);
@ -116,7 +119,7 @@ void TrackSlider::UpdateTimes(int elapsed) {
}
else {
// Check if slider maximum value is changed before updating
if (slider_maximum_value_ != ui_->slider->maximum()) {
if (slider_maximum_value_ != ui_->slider->maximum() || !ui_->slider->isEnabled()) {
slider_maximum_value_ = ui_->slider->maximum();
ui_->remaining->setText(Utilities::PrettyTime((ui_->slider->maximum() / kMsecPerSec)));
}

View File

@ -111,7 +111,11 @@ void TrackSliderSlider::enterEvent(QEvent* e) {
void TrackSliderSlider::leaveEvent(QEvent* e) {
QSlider::leaveEvent(e);
popup_->hide();
// On some (but not all) systems, displaying the TrackSliderPopup
// generates a leaveEvent. Ensure that this leaveEvent is genuine.
if (!geometry().contains(mapFromGlobal(QCursor::pos()))) {
popup_->hide();
}
}
void TrackSliderSlider::keyPressEvent(QKeyEvent* event) {
@ -130,7 +134,7 @@ void TrackSliderSlider::keyPressEvent(QKeyEvent* event) {
void TrackSliderSlider::UpdateDeltaTime() {
if (popup_->isVisible()) {
int delta_seconds = mouse_hover_seconds_ - value();
int delta_seconds = mouse_hover_seconds_ - (value() / kMsecPerSec);
popup_->SetSmallText(Utilities::PrettyTimeDelta(delta_seconds));
}
}