Skip to content

Commit

Permalink
fix: work for qss repaint in hidpi
Browse files Browse the repository at this point in the history
Change-Id: I3018513ed1cb0d4f2b47af94877b5b20821cba1d
  • Loading branch information
Iceyer committed Dec 15, 2017
1 parent e158581 commit 49f5b1b
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion music-player/resource/theme/dark/InfoDialog.theme
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
color: black;
}
#InfoSplit{
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-top: 1px solid rgba(0, 0, 0, 10%);
}
#InfoKey{
border: 1px solid transparent;
Expand Down
2 changes: 1 addition & 1 deletion music-player/resource/theme/dark/LyricWidget.theme
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#LyricWidget {
background-color: rgba(0,0,0,50%);
qproperty-backgroundColor: rgba(0,0,0,50%);
qproperty-defaultCover: ":/common/image/cover_max.svg";
}

Expand Down
2 changes: 1 addition & 1 deletion music-player/resource/theme/dark/PlaylistWidget.theme
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#PlaylistWidget{
border: 1px solid rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 10%);
border-top: none;
background-color: rgba(37, 37, 37, 0.9);
}
Expand Down
2 changes: 1 addition & 1 deletion music-player/resource/theme/light/InfoDialog.theme
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
qproperty-alignment: AlignCenter;
}
#InfoSplit{
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-top: 1px solid rgba(0, 0, 0, 10%);
}
#InfoKey{
border: 1px solid transparent;
Expand Down
2 changes: 1 addition & 1 deletion music-player/resource/theme/light/LyricWidget.theme
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#LyricWidget {
background-color: rgba(0,0,0,30%);
qproperty-backgroundColor: rgba(0,0,0,30%);
qproperty-defaultCover: ":/common/image/cover_max.svg";
}

Expand Down
2 changes: 1 addition & 1 deletion music-player/resource/theme/light/PlaylistWidget.theme
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#PlaylistWidget{
border: 1px solid rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 10%);
border-top: none;
background-color: rgba(255, 255, 255, 0.9);
}
Expand Down
2 changes: 1 addition & 1 deletion music-player/resource/theme/light/SearchEdit.theme
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Dtk--Widget--DSearchEdit {
border-radius: 4.0px;
padding: 1px;
padding-bottom: 0px;
background: rgba(0, 0, 0, 0.1);
background: rgba(0, 0, 0, 10%);
}

Dtk--Widget--DSearchEdit #SearchIcon {
Expand Down
2 changes: 1 addition & 1 deletion music-player/resource/theme/light/SearchResult.theme
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SearchResult{
border: 1px solid rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 10%);
border-radius: 4px;
background-color: rgba(255, 255,255, 1);
}
Expand Down
22 changes: 21 additions & 1 deletion music-player/view/lyricwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class LyricWidgetPrivate
QStringListModel *m_model = nullptr;

QString defaultCover;
QColor backgroundColor;

LyricWidget *q_ptr;
Q_DECLARE_PUBLIC(LyricWidget)
Expand Down Expand Up @@ -137,7 +138,7 @@ void LyricWidgetPrivate::setLyricLines(QString str)
m_model->setStringList(lyric);
lyricview->setModel(m_model);

QModelIndex index = m_model->index(emptyLineOffset , 0, lyricview->rootIndex());
QModelIndex index = m_model->index(emptyLineOffset, 0, lyricview->rootIndex());
lyricview->selectionModel()->clearSelection();
lyricview->selectionModel()->select(index, QItemSelectionModel::Select);
lyricview->scrollTo(index, QListView::PositionAtCenter);
Expand Down Expand Up @@ -336,6 +337,12 @@ void LyricWidget::checkHiddenSearch(QPoint mousePos)
}
}

QColor LyricWidget::backgroundColor() const
{
Q_D(const LyricWidget);
return d->backgroundColor;
}


void LyricWidget::paintEvent(QPaintEvent *e)
{
Expand Down Expand Up @@ -419,6 +426,13 @@ void LyricWidget::onMusicStop(PlaylistPtr /*playlist*/, const MetaPtr /*meta*/)
void LyricWidget::onProgressChanged(qint64 value, qint64 /*length*/)
{
Q_D(LyricWidget);

qDebug() << d->backgroundColor;
QPalette p = palette();
p.setColor(QPalette::Background, d->backgroundColor);
setPalette(p);


auto len = d->m_lyriclist.m_lyricElements.length();

if (!d->m_lyriclist.hasTime) {
Expand Down Expand Up @@ -491,6 +505,12 @@ void LyricWidget::onUpdateMetaCodec(const MetaPtr /*meta*/)
// }
}

void LyricWidget::setBackgroundColor(QColor backgroundColor)
{
Q_D(LyricWidget);
d->backgroundColor = backgroundColor;
}

void LyricWidget::onContextSearchFinished(const QString &context, const QList<DMusic::SearchMeta> &metalist)
{
Q_D(LyricWidget);
Expand Down
4 changes: 4 additions & 0 deletions music-player/view/lyricwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ class LyricWidget : public QFrame
{
Q_OBJECT
Q_PROPERTY(QString defaultCover READ defaultCover WRITE setDefaultCover)
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)

public:
explicit LyricWidget(QWidget *parent = 0);
~LyricWidget();

void updateUI();
QString defaultCover() const;
QColor backgroundColor() const;
void checkHiddenSearch(QPoint mousePos);


signals:
void toggleLyricView();
void requestContextSearch(const QString &context);
Expand All @@ -61,6 +64,7 @@ public slots:
const QList<DMusic::SearchMeta> &metalist);

void setDefaultCover(QString defaultCover);
void setBackgroundColor(QColor backgroundColor);
void onUpdateMetaCodec(const MetaPtr meta);

protected:
Expand Down

0 comments on commit 49f5b1b

Please sign in to comment.