From 866cea542ec3dd87f761ec76844b156c4b770cf3 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Thu, 30 Nov 2023 22:05:23 +0100 Subject: [PATCH] library/GUI: fix track background color, add delegate for Played column + some small improvements for the table view Shade --- CMakeLists.txt | 1 + res/skins/Deere/style.qss | 9 +++-- res/skins/LateNight/style.qss | 5 +++ res/skins/LateNight/style_classic.qss | 29 ++++++--------- res/skins/LateNight/style_palemoon.qss | 26 +++++-------- .../Shade/btn/btn_lib_bpm_unlocked_black.svg | 1 + .../Shade/btn/btn_lib_bpm_unlocked_white.svg | 1 + res/skins/Shade/style.qss | 34 +++++++++-------- res/skins/Shade/style_dark.qss | 14 +++---- res/skins/Shade/style_summer_sunset.qss | 4 ++ res/skins/Tango/style.qss | 21 ++++++----- src/library/basetracktablemodel.cpp | 3 ++ src/library/bpmdelegate.cpp | 11 ++++++ src/library/playcountdelegate.cpp | 37 +++++++++++++++++++ src/library/playcountdelegate.h | 19 ++++++++++ 15 files changed, 144 insertions(+), 71 deletions(-) create mode 100644 res/skins/Shade/btn/btn_lib_bpm_unlocked_black.svg create mode 100644 res/skins/Shade/btn/btn_lib_bpm_unlocked_white.svg create mode 100644 src/library/playcountdelegate.cpp create mode 100644 src/library/playcountdelegate.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4711dfe0663..4888d9be9bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -884,6 +884,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL src/library/parsercsv.cpp src/library/parserm3u.cpp src/library/parserpls.cpp + src/library/playcountdelegate.cpp src/library/playlisttablemodel.cpp src/library/previewbuttondelegate.cpp src/library/proxytrackmodel.cpp diff --git a/res/skins/Deere/style.qss b/res/skins/Deere/style.qss index 8e9e5213e10..58d47532f55 100644 --- a/res/skins/Deere/style.qss +++ b/res/skins/Deere/style.qss @@ -223,7 +223,7 @@ WLibrarySidebar { } /* Prevent OS-style checkbox from being rendered underneath the custom style. */ -WTrackTableView::item, +#LibraryPlayedCheckbox::item, #LibraryBPMButton::item { border: 0px; } @@ -231,7 +231,8 @@ WTrackTableView::item, /* Selected rows in Tree and Tracks table */ WTrackTableView::item:selected, WLibrarySidebar::item:selected, -#LibraryBPMButton::item:selected { +#LibraryBPMButton::item:selected, +#LibraryPlayedCheckbox::item:selected { color: #D6D6D6; background-color: #006596; } @@ -279,10 +280,10 @@ WBeatSpinBox, } /* checkbox in library "Played" column */ -WTrackTableView::indicator:unchecked { +#LibraryPlayedCheckbox::indicator:unchecked { image: url(skin:/../Deere/icon/ic_library_checkbox.svg); } -WTrackTableView::indicator:checked { +#LibraryPlayedCheckbox::indicator:checked { image: url(skin:/../Deere/icon/ic_library_checkbox_checked.svg); } diff --git a/res/skins/LateNight/style.qss b/res/skins/LateNight/style.qss index 0892c091fc6..16f4eccfb9a 100644 --- a/res/skins/LateNight/style.qss +++ b/res/skins/LateNight/style.qss @@ -301,6 +301,11 @@ WTrackTableViewHeader::item { padding: 0 0.15em; } +/* Prevent OS-style checkbox from being rendered underneath the custom style. */ +#LibraryBPMButton::item, +#LibraryPlayedCheckbox::item { + border: 0px; +} #HotcueButton { /* ronso0 diff --git a/res/skins/LateNight/style_classic.qss b/res/skins/LateNight/style_classic.qss index 3c3694b03e7..5bb7e741cac 100644 --- a/res/skins/LateNight/style_classic.qss +++ b/res/skins/LateNight/style_classic.qss @@ -1099,10 +1099,10 @@ WSearchLineEdit QAbstractScrollArea, #SkinSettingsLabelButton, #SkinSettingsNumToggleHeader[displayValue="1"], WSearchLineEdit, +WTrackTableView, #LibraryBPMSpinBox, #LibraryBPMButton::item, -WTrackTableView, -WTrackTableView::indicator, +#LibraryPlayedCheckbox::item, WLibraryTextBrowser, WLibrarySidebar, #LibraryFeatureControls QLabel, @@ -2065,15 +2065,11 @@ WLibraryTextBrowser:focus { border: 1px solid #d09300; } -/* Prevent OS-style checkbox from being rendered underneath the custom style. */ -WTrackTableView::item, -#LibraryBPMButton::item { - border: 0px; -} /* Selected rows in Tree and Tracks table */ WLibrarySidebar::item:selected, WTrackTableView::item:selected, -#LibraryBPMButton::item:selected { +#LibraryBPMButton::item:selected, +#LibraryPlayedCheckbox::item:selected { color: #fff; background-color: #5e4507; } @@ -2088,7 +2084,7 @@ WLibrarySidebar::item:!selected:focus { /* Use the native focus decoration */ /* This is for all cells including Played and Location */ WTrackTableView, -/* This is for the BPM cell */ +/* This is for the BPM and play count cells */ WTrackTableView QCheckBox:focus { outline: 1px solid #fff; } @@ -2143,6 +2139,12 @@ WLibrary QPlainTextEdit, #LibraryBPMSpinBox::down-button { image: url(skin:../LateNight/classic/buttons/btn__lib_bpm_down.svg) no-repeat; } +#LibraryPlayedCheckbox::indicator:checked { + image: url(skin:../LateNight/classic/buttons/btn__lib_checkbox_checked.svg); +} +#LibraryPlayedCheckbox::indicator:unchecked { + image: url(skin:../LateNight/classic/buttons/btn__lib_checkbox.svg); +} WCueMenuPopup QPushButton:focus { outline: none; @@ -2596,15 +2598,6 @@ QPlainTextEdit QMenu::item:disabled { image: url(skin:../LateNight/classic/style/menu_arrow_white.svg); } -/* This is the only way to select the 'Played' checkbox. - Note that this also selects the BPM lock. */ - WTrackTableView::indicator:checked { - image: url(skin:../LateNight/classic/buttons/btn__lib_checkbox_checked.svg); - } - WTrackTableView::indicator:unchecked { - image: url(skin:../LateNight/classic/buttons/btn__lib_checkbox.svg); - } - #MainMenu QMenu::separator, WLibrarySidebar QMenu::separator, WTrackTableViewHeader QMenu::separator, diff --git a/res/skins/LateNight/style_palemoon.qss b/res/skins/LateNight/style_palemoon.qss index 29dbf10fe2d..f723055c132 100644 --- a/res/skins/LateNight/style_palemoon.qss +++ b/res/skins/LateNight/style_palemoon.qss @@ -1189,10 +1189,9 @@ WEffectChainPresetSelector, WSearchLineEdit, WTime, #PreviewDeckTextBox, #PreviewTitle, #PreviewBPM, -#LibraryBPMSpinBox, -#LibraryBPMButton::item, WTrackTableView, -WTrackTableView::indicator, +#LibraryBPMButton::item, +#LibraryPlayedCheckbox::item, WLibraryTextBrowser, WLibrarySidebar, #LibraryFeatureControls QLabel, @@ -2549,15 +2548,11 @@ WLibrarySidebar { WLibrarySidebar { outline: none; } -/* Prevent OS-style checkbox from being rendered underneath the custom style. */ -WTrackTableView::item, -#LibraryBPMButton::item { - border: 0px; -} /* Selected rows in Tree and Tracks table */ WLibrarySidebar::item:selected, WTrackTableView::item:selected, -#LibraryBPMButton::item:selected { +#LibraryBPMButton::item:selected, +#LibraryPlayedCheckbox::item:selected { color: #fff; background-color: #2c454f; } @@ -2582,7 +2577,7 @@ WLibrarySidebar { /* Use the native focus decoration */ /* This is for all cells including Played and Location */ WTrackTableView, -/* This is for the BPM cell */ +/* This is for the BPM and play count cells */ WTrackTableView QCheckBox:focus { outline: 1px solid #fff; } @@ -2630,6 +2625,10 @@ WLibrary QPlainTextEdit, image: url(skin:../LateNight/palemoon/buttons/btn__lib_spinbox_down.svg) no-repeat center center; } +#LibraryPlayedCheckbox::indicator:unchecked { + image: url(skin:../LateNight/palemoon/buttons/btn__lib_checkbox.svg); +} + /* Button in library "Preview" column */ #LibraryPreviewButton { margin: 0px; @@ -3070,14 +3069,9 @@ QPlainTextEdit QMenu::item:disabled { image: url(skin:../LateNight/palemoon/buttons/btn__menu_checkbox.svg); } - /* This is the only way to select the 'Played' checkbox. - Note that this also selects the BPM lock, so style that afterwards. */ - WTrackTableView::indicator:unchecked { - image: url(skin:../LateNight/palemoon/buttons/btn__lib_checkbox.svg); - } WLibrarySidebar QMenu::indicator:checked, WTrackTableViewHeader QMenu::indicator:checked, - WTrackTableView::indicator:checked, + #LibraryPlayedCheckbox::indicator:checked, WTrackMenu QMenu QCheckBox::indicator:checked, WEffectChainPresetButton QMenu QCheckBox::indicator:checked { image: url(skin:../LateNight/palemoon/buttons/btn__lib_checkmark_blue.svg); diff --git a/res/skins/Shade/btn/btn_lib_bpm_unlocked_black.svg b/res/skins/Shade/btn/btn_lib_bpm_unlocked_black.svg new file mode 100644 index 00000000000..4dbd8b59ebc --- /dev/null +++ b/res/skins/Shade/btn/btn_lib_bpm_unlocked_black.svg @@ -0,0 +1 @@ + diff --git a/res/skins/Shade/btn/btn_lib_bpm_unlocked_white.svg b/res/skins/Shade/btn/btn_lib_bpm_unlocked_white.svg new file mode 100644 index 00000000000..0999412a8c0 --- /dev/null +++ b/res/skins/Shade/btn/btn_lib_bpm_unlocked_white.svg @@ -0,0 +1 @@ + diff --git a/res/skins/Shade/style.qss b/res/skins/Shade/style.qss index 55298598cb6..f40edf2a2b0 100644 --- a/res/skins/Shade/style.qss +++ b/res/skins/Shade/style.qss @@ -443,7 +443,6 @@ WLibraryTextBrowser, WLibrarySidebar { border: 1px solid #585858; font-weight: normal; - color: #9e9e9e; background-color: #0f0f0f; alternate-background-color: #1a1a1a; /* In selected library rows this sets the color of @@ -457,9 +456,18 @@ WLibraryTextBrowser { padding-left: 10px; } +WTrackTableView, +WLibraryTextBrowser, +WLibrarySidebar, +#LibraryBPMButton::item, +#LibraryPlayedCheckbox::item { + color: #9e9e9e; +} + + /* Prevent OS-style checkbox from being rendered underneath the custom style. */ -WTrackTableView::item, -#LibraryBPMButton::item { +#LibraryBPMButton::item, +#LibraryPlayedCheckbox::item { border: 0px; } @@ -468,7 +476,8 @@ WSearchLineEdit::item:selected, WSearchLineEdit::item:checked, WLibrarySidebar::item:selected, WLibrarySidebar::branch:selected, -#LibraryBPMButton::item:selected { +#LibraryBPMButton::item:selected, +#LibraryPlayedCheckbox::item:selected { color: #fff; background-color: #656d75; } @@ -497,7 +506,7 @@ WLibrarySidebar::item:!selected:focus { /* Use the native focus decoration */ /* This is for all cells including Played and Location */ WTrackTableView, -/* This is for the BPM cell */ +/* This is for the BPM and play count cells */ WTrackTableView QCheckBox:focus { outline: 1px solid #c9c9c9; } @@ -526,9 +535,9 @@ WTrackTableView { #LibraryBPMButton::indicator:unchecked { image: url(skin:/btn/btn_lib_bpm_unlocked.svg); } - #LibraryBPMButton::item { - color: #cfcfcf; - } + #LibraryBPMButton::indicator:unchecked:selected { + image: url(skin:/btn/btn_lib_bpm_unlocked_black.svg); + } WLibrary > QCheckBox { text-align: right; alignment: right; @@ -576,15 +585,10 @@ WTrackTableView { /* checkbox in library "Played" column */ - WTrackTableView::indicator { - margin: 0px; - padding: 0px; - border: 0px; - } - WTrackTableView::indicator:unchecked { + #LibraryPlayedCheckbox::indicator:unchecked { image: url(skin:/btn/btn_lib_checkbox.svg); } - WTrackTableView::indicator:checked { + #LibraryPlayedCheckbox::indicator:checked { image: url(skin:/btn/btn_lib_checkbox_checked.svg); } diff --git a/res/skins/Shade/style_dark.qss b/res/skins/Shade/style_dark.qss index 44af859279f..cec47d2e024 100644 --- a/res/skins/Shade/style_dark.qss +++ b/res/skins/Shade/style_dark.qss @@ -147,6 +147,7 @@ WEffectSelector::indicator:unchecked:selected, WTrackTableView, WLibrarySidebar { + selection-color: #000; /* background of Color delegate in selected row */ selection-background-color: #666; /*outline: 1px solid yellow;*/ @@ -165,16 +166,11 @@ WSearchLineEdit QToolButton:focus { image: url(skin:/btn/btn_lib_clear_search_focus_green.svg); } -/* Prevent OS-style checkbox from being rendered underneath the custom style. */ -WTrackTableView::item, -#LibraryBPMButton::item { - border: 0px; -} - WLibrarySidebar::item:selected, WTrackTableView::item:selected, WLibrarySidebar::branch:selected, -#LibraryBPMButton::item:selected { +#LibraryBPMButton::item:selected, +#LibraryPlayedCheckbox::item:selected { color: #000; selection-color: #000; background-color: #666; @@ -186,7 +182,7 @@ WLibrarySidebar::item:focus { /* Use the native focus decoration */ /* This is for all cells including Played and Location */ WTrackTableView, -/* This is for the BPM cell */ +/* This is for the BPM and play count cells */ WTrackTableView QCheckBox:focus { outline: 1px solid #ccc; } @@ -213,7 +209,7 @@ WTrackTableView { } /* checkbox in library "Played" column */ -WTrackTableView::indicator:unchecked:selected { +#LibraryPlayedCheckbox::indicator:unchecked:selected { background: none; color: #cfcfcf; border: 1px solid #000; diff --git a/res/skins/Shade/style_summer_sunset.qss b/res/skins/Shade/style_summer_sunset.qss index b6d449a02d8..d65995600a2 100644 --- a/res/skins/Shade/style_summer_sunset.qss +++ b/res/skins/Shade/style_summer_sunset.qss @@ -147,6 +147,10 @@ WSearchLineEdit:focus { border-color: #78C70B; } +#LibraryBPMButton::indicator:unchecked:selected { + image: url(skin:/btn/btn_lib_bpm_unlocked_white.svg); +} + #LibraryFeatureControls QPushButton:enabled { background-color: #998A3C; border: 1px solid #998A3C; diff --git a/res/skins/Tango/style.qss b/res/skins/Tango/style.qss index ec1a9efc5a1..484ead296cb 100644 --- a/res/skins/Tango/style.qss +++ b/res/skins/Tango/style.qss @@ -2546,7 +2546,6 @@ WLibraryTextBrowser, WLibrarySidebar { border: 2px solid #585858; /* font-weight: normal; */ - color: #9e9e9e; background-color: #0f0f0f; alternate-background-color: #1a1a1a; /* In selected library rows this sets the color of @@ -2557,16 +2556,24 @@ WLibrarySidebar { /* background of Color delegate in selected row */ selection-background-color: #555; } +WTrackTableView, +WLibraryTextBrowser, +WLibrarySidebar, +#LibraryBPMButton::item, +#LibraryPlayedCheckbox::item { + color: #9e9e9e; +} /* Prevent OS-style checkbox from being rendered underneath the custom style. */ -WTrackTableView::item, +#LibraryPlayedCheckbox::item, #LibraryBPMButton::item { border: 0px; } /* selected table row */ WTrackTableView::item:selected, -#LibraryBPMButton::item:selected { +#LibraryBPMButton::item:selected, +#LibraryPlayedCheckbox::item:selected { color: #fff; background-color: #555; } @@ -3013,10 +3020,6 @@ QPushButton#pushButtonRepeatPlaylist:!checked { #LibraryBPMButton::indicator:unchecked { image: url(skin:/../Tango/buttons/btn_lib_bpm_unlocked.svg); } - /* BPM value */ - #LibraryBPMButton::item { - color: #cfcfcf; - } #LibraryBPMSpinBox { padding: 0px; @@ -3069,10 +3072,10 @@ QPushButton#pushButtonRepeatPlaylist:!checked { }*/ /* checkbox in library "Played" column */ - WTrackTableView::indicator:checked { + #LibraryPlayedCheckbox::indicator:checked { image: url(skin:/../Tango/buttons/btn_lib_checkbox_checked.svg); } - WTrackTableView::indicator:unchecked { + #LibraryPlayedCheckbox::indicator:unchecked { image: url(skin:/../Tango/buttons/btn_lib_checkbox.svg); } diff --git a/src/library/basetracktablemodel.cpp b/src/library/basetracktablemodel.cpp index 575e2dd4028..6256cb114d4 100644 --- a/src/library/basetracktablemodel.cpp +++ b/src/library/basetracktablemodel.cpp @@ -10,6 +10,7 @@ #include "library/dao/trackschema.h" #include "library/locationdelegate.h" #include "library/multilineeditdelegate.h" +#include "library/playcountdelegate.h" #include "library/previewbuttondelegate.h" #include "library/stardelegate.h" #include "library/starrating.h" @@ -399,6 +400,8 @@ QAbstractItemDelegate* BaseTrackTableModel::delegateForColumn( return new StarDelegate(pTableView); } else if (index == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM)) { return new BPMDelegate(pTableView); + } else if (index == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_TIMESPLAYED)) { + return new PlayCountDelegate(pTableView); } else if (PlayerManager::numPreviewDecks() > 0 && index == fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PREVIEW)) { return new PreviewButtonDelegate(pTableView, index); diff --git a/src/library/bpmdelegate.cpp b/src/library/bpmdelegate.cpp index 695aac99835..fb0fc360d03 100644 --- a/src/library/bpmdelegate.cpp +++ b/src/library/bpmdelegate.cpp @@ -79,6 +79,17 @@ void BPMDelegate::paintItem(QPainter* painter,const QStyleOptionViewItem &option // #LibraryBPMButton::indicator:unchecked { // image: url(:/images/library/ic_library_unlocked.svg); // } + + // Actually QAbstractTableModel::data(index, BackgroundRole) provides the + // correct custom background color (track color). + // Though, since Qt6 the above style rules would not apply for some reason, + // (see bug #11630) which can be fixed by also setting + // #LibraryBPMButton::item { border: 0px;} + // This however enables some default styles and clears the custom background + // color (track color), see bug #12355 ¯\_(ツ)_/¯ Qt is fun! + // Fix that by setting the bg color explicitly here. + paintItemBackground(painter, option, index); + QStyleOptionViewItem opt = option; initStyleOption(&opt, index); diff --git a/src/library/playcountdelegate.cpp b/src/library/playcountdelegate.cpp new file mode 100644 index 00000000000..06d3e77e39b --- /dev/null +++ b/src/library/playcountdelegate.cpp @@ -0,0 +1,37 @@ +#include "library/playcountdelegate.h" + +#include +#include +#include + +#include "moc_playcountdelegate.cpp" + +PlayCountDelegate::PlayCountDelegate(QTableView* pTableView) + : TableItemDelegate(pTableView), + m_pTableView(pTableView), + m_pCheckBox(new QCheckBox(m_pTableView)) { + m_pCheckBox->setObjectName("LibraryPlayedCheckbox"); + // NOTE(rryan): Without ensurePolished the first render of the QTableView + // shows the checkbox unstyled. Not sure why -- but this fixes it. + m_pCheckBox->ensurePolished(); + m_pCheckBox->hide(); +} + +void PlayCountDelegate::paintItem(QPainter* painter, + const QStyleOptionViewItem& option, + const QModelIndex& index) const { + // NOTE(ronso0): For details why we need checkbox delegates, how to style + // them and why we need paintItemBackground() here, see bpmdelegate.cpp + + QStyleOptionViewItem opt = option; + initStyleOption(&opt, index); + + paintItemBackground(painter, option, index); + + if (m_pTableView != nullptr) { + QStyle* style = m_pTableView->style(); + if (style != nullptr) { + style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, m_pCheckBox); + } + } +} diff --git a/src/library/playcountdelegate.h b/src/library/playcountdelegate.h new file mode 100644 index 00000000000..87f3705ed57 --- /dev/null +++ b/src/library/playcountdelegate.h @@ -0,0 +1,19 @@ +#pragma once + +#include "library/tableitemdelegate.h" + +class QCheckBox; + +class PlayCountDelegate : public TableItemDelegate { + Q_OBJECT + public: + explicit PlayCountDelegate(QTableView* pTableView); + + void paintItem(QPainter* painter, + const QStyleOptionViewItem& option, + const QModelIndex& index) const override; + + private: + QTableView* m_pTableView; + QCheckBox* m_pCheckBox; +};