From b1a28fa3604517dff407deac40e29348ca070950 Mon Sep 17 00:00:00 2001 From: Craig Drummond Date: Thu, 7 Sep 2017 22:51:08 +0100 Subject: [PATCH] Fix time slider border --- widgets/nowplayingwidget.cpp | 15 ++++++--------- widgets/nowplayingwidget.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/widgets/nowplayingwidget.cpp b/widgets/nowplayingwidget.cpp index 8182f351c..adecea895 100644 --- a/widgets/nowplayingwidget.cpp +++ b/widgets/nowplayingwidget.cpp @@ -157,11 +157,10 @@ PosSlider::PosSlider(QWidget *p) int h=qMax((int)(fontMetrics().height()*0.5), 8); setMinimumHeight(h); setMaximumHeight(h); - updateStyleSheet(); setMouseTracking(true); } -void PosSlider::updateStyleSheet() +void PosSlider::updateStyleSheet(const QColor &col) { int lineWidth=maximumHeight()>12 ? 2 : 1; @@ -174,17 +173,15 @@ void PosSlider::updateStyleSheet() "border-radius: %1px; margin: %2px} ")+ QLatin1String("QSlider::")+QLatin1String(isRightToLeft() ? "add" : "sub")+ QLatin1String("-page:horizontal:disabled {border: 0px; background: solid rgba(0, 0, 0, 0)}"); - QLabel lbl(parentWidget()); - lbl.ensurePolished(); - QColor textColor=lbl.palette().color(QPalette::Active, QPalette::Text); + #ifdef Q_OS_MAC QColor fillColor=OSXStyle::self()->viewPalette().highlight().color(); #else - QColor fillColor=lbl.palette().highlight().color(); + QColor fillColor=qApp->palette().highlight().color(); #endif - int alpha=textColor.value()<32 ? 96 : 64; + int alpha=col.value()<32 ? 96 : 64; - setStyleSheet(boderFormat.arg(lineWidth).arg(textColor.red()).arg(textColor.green()).arg(textColor.blue()).arg(alpha) + setStyleSheet(boderFormat.arg(lineWidth).arg(col.red()).arg(col.green()).arg(col.blue()).arg(alpha) .arg(alpha/4).arg(lineWidth*2)+ fillFormat.arg(lineWidth).arg(lineWidth*2).arg(fillColor.red()).arg(fillColor.green()).arg(fillColor.blue())); } @@ -451,6 +448,6 @@ void NowPlayingWidget::initColors() track->setPalette(btn.palette()); artist->setPalette(btn.palette()); time->setPalette(btn.palette()); - slider->updateStyleSheet(); + slider->updateStyleSheet(track->palette().windowText().color()); ratingWidget->setColor(Utils::clampColor(track->palette().text().color())); } diff --git a/widgets/nowplayingwidget.h b/widgets/nowplayingwidget.h index ebb8e8f66..84bd6db8f 100644 --- a/widgets/nowplayingwidget.h +++ b/widgets/nowplayingwidget.h @@ -42,7 +42,7 @@ public: PosSlider(QWidget *p); virtual ~PosSlider() { } - void updateStyleSheet(); + void updateStyleSheet(const QColor &col); void mouseMoveEvent(QMouseEvent *e); void wheelEvent(QWheelEvent *ev); void setRange(int min, int max);