Commit 595f5ca6 authored by Nate Graham's avatar Nate Graham
Browse files

Use Kirigami.Icon for icons, rather than Image

This allows various icons to change their color instantly in response
to changes in the active color scheme, and removes a lot of code that
becomes unnecessary after the port is done.

BUG: 446446
FIXED-IN: 21.12.1
parent 399c507c
Pipeline #108891 passed with stage
in 17 seconds
......@@ -61,14 +61,6 @@ enum FilterType {
Q_ENUM_NS(FilterType)
enum IconUseColorOverlay
{
UseColorOverlay = true,
DoNotUseColorOverlay = false,
};
Q_ENUM_NS(IconUseColorOverlay)
}
#endif // ELISAUTILS_H
......@@ -36,7 +36,6 @@ QHash<int, QByteArray> ViewsModel::roleNames() const
auto result = QAbstractListModel::roleNames();
result[ImageNameRole] = "image";
result[UseColorOverlayRole] = "useColorOverlay";
result[DatabaseIdRole] = "databaseId";
result[UseSecondTitleRole] = "useSecondTitle";
result[SecondTitleRole] = "secondTitle";
......@@ -87,9 +86,6 @@ QVariant ViewsModel::data(const QModelIndex &index, int role) const
case ColumnRoles::ImageNameRole:
result = d->mViewsData->iconUrl(index.row());
break;
case ColumnRoles::UseColorOverlayRole:
result = d->mViewsData->iconUseColorOverlay(index.row());
break;
case ColumnRoles::DatabaseIdRole:
result = d->mViewsData->databaseId(index.row());
break;
......
......@@ -32,7 +32,6 @@ public:
UseSecondTitleRole,
DatabaseIdRole,
EntryTypeRole,
UseColorOverlayRole,
EntryCategoryRole,
};
......
......@@ -73,17 +73,12 @@ Kirigami.Page {
onClicked: mainWindow.globalDrawer.open()
}
Image {
Kirigami.Icon {
id: mainIcon
source: elisaTheme.nowPlayingIcon
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
sourceSize.height: Layout.preferredHeight
sourceSize.width: Layout.preferredWidth
fillMode: Image.PreserveAspectFit
asynchronous: true
visible: !Kirigami.Settings.isMobile
}
Kirigami.Heading {
......
......@@ -99,13 +99,10 @@ Window {
spacing: Kirigami.Units.largeSpacing
Image {
Kirigami.Icon {
Layout.preferredWidth: fileNameLabel.height
Layout.preferredHeight: fileNameLabel.height
sourceSize.width: fileNameLabel.height
sourceSize.height: fileNameLabel.height
source: elisaTheme.folderIcon
}
......
......@@ -194,7 +194,7 @@ Item {
icon.name: (Qt.application.layoutDirection == Qt.RightToLeft) ? "go-next" : "go-previous"
onClicked: goBack()
},
Image {
Kirigami.Icon {
id: mainIcon
visible: image.toString().length > 0 && !Kirigami.Settings.isMobile // on mobile, we want more header space
source: image
......@@ -202,12 +202,6 @@ Item {
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
sourceSize.height: Layout.preferredHeight
sourceSize.width: Layout.preferredWidth
fillMode: Image.PreserveAspectFit
asynchronous: true
},
ColumnLayout {
id: authorAndAlbumLayout
......
......@@ -82,7 +82,7 @@ BasePlayListDelegate {
Layout.leftMargin: !LayoutMirroring.enabled ? Kirigami.Units.smallSpacing : 0
Layout.rightMargin: LayoutMirroring.enabled ? Kirigami.Units.smallSpacing : 0
Image {
Kirigami.Icon {
id: playIcon
anchors.centerIn: parent
......@@ -92,16 +92,6 @@ BasePlayListDelegate {
width: Kirigami.Units.iconSizes.smallMedium
height: Kirigami.Units.iconSizes.smallMedium
sourceSize.width: Kirigami.Units.iconSizes.smallMedium
sourceSize.height: Kirigami.Units.iconSizes.smallMedium
fillMode: Image.PreserveAspectFit
mirror: LayoutMirroring.enabled
layer.enabled: simpleMode
layer.effect: ColorOverlay {
cached: true
color: Kirigami.Theme.textColor
}
visible: isPlaying === MediaPlayList.IsPlaying || isPlaying === MediaPlayList.IsPaused
}
......
......@@ -33,13 +33,10 @@ Row {
height: Kirigami.Units.iconSizes.small
width: Kirigami.Units.iconSizes.small
Image {
Kirigami.Icon {
width: Kirigami.Units.iconSizes.small
height: Kirigami.Units.iconSizes.small
anchors.centerIn: parent
sourceSize.width: Kirigami.Units.iconSizes.small
sourceSize.height: Kirigami.Units.iconSizes.small
fillMode: Image.PreserveAspectFit
layer.enabled: hoveredRating >= ratingThreshold
......
......@@ -60,7 +60,6 @@ FocusScope {
isSelected: viewModeView.currentIndex === index
colorizeIcon: model.useColorOverlay
image: model.image
title: model.display
secondTitle: model.secondTitle
......
......@@ -13,7 +13,6 @@ FocusScope {
id: rootItem
property bool isSelected
property alias colorizeIcon: viewIcon.colorizeIcon
property string title
property alias image: viewIcon.source
property int databaseId
......@@ -85,11 +84,9 @@ FocusScope {
}
}
Image {
Kirigami.Icon {
id: viewIcon
property bool colorizeIcon
z: 1
anchors {
......@@ -100,16 +97,6 @@ FocusScope {
height: Kirigami.Units.iconSizes.smallMedium
width: Kirigami.Units.iconSizes.smallMedium
sourceSize {
width: Kirigami.Units.iconSizes.smallMedium
height: Kirigami.Units.iconSizes.smallMedium
}
layer.enabled: viewIcon.colorizeIcon
layer.effect: ColorOverlay {
color: nameLabel.color
}
}
LabelWithToolTip {
......@@ -146,7 +133,8 @@ FocusScope {
}
PropertyChanges {
target: viewIcon
opacity: 1
active: false
selected: false
}
PropertyChanges {
target: nameLabel
......@@ -170,7 +158,8 @@ FocusScope {
}
PropertyChanges {
target: viewIcon
opacity: 0.4
active: true
selected: false
}
PropertyChanges {
target: nameLabel
......@@ -194,7 +183,8 @@ FocusScope {
}
PropertyChanges {
target: viewIcon
opacity: 1
active: false
selected: true
}
PropertyChanges {
target: nameLabel
......@@ -218,7 +208,8 @@ FocusScope {
}
PropertyChanges {
target: viewIcon
opacity: 1.
active: false
selected: true
}
PropertyChanges {
target: nameLabel
......
......@@ -98,13 +98,10 @@ Kirigami.ScrollablePage {
spacing: Kirigami.Units.largeSpacing
Image {
Kirigami.Icon {
Layout.preferredWidth: fileNameLabel.height
Layout.preferredHeight: fileNameLabel.height
sourceSize.width: fileNameLabel.height
sourceSize.height: fileNameLabel.height
source: elisaTheme.folderIcon
}
......
......@@ -118,12 +118,12 @@ public:
ViewManager::ViewHideRating,
ViewManager::IsFlatModel},
{{i18nc("Title of the file browser view", "Files")},
QUrl{QStringLiteral("image://icon/folder")},
QUrl{QStringLiteral("image://icon/document-open-folder")},
ViewManager::GridView,
ViewManager::FileBrowserModel,
ElisaUtils::NoFilter,
ElisaUtils::FileName,
QUrl{QStringLiteral("image://icon/folder")},
QUrl{QStringLiteral("image://icon/document-open-folder")},
ViewManager::DelegateWithoutSecondaryText,
ViewManager::ViewHideRating,
ViewManager::IsFlatModel,
......@@ -205,11 +205,6 @@ const QUrl &ViewsListData::iconUrl(int index) const
return d->mViewsParameters[index].mMainImage;
}
ElisaUtils::IconUseColorOverlay ViewsListData::iconUseColorOverlay(int index) const
{
return d->mViewsParameters[index].mIconUseColorOverlay;
}
qulonglong ViewsListData::databaseId(int index) const
{
return d->mViewsParameters[index].mDataFilter.databaseId();
......@@ -371,11 +366,9 @@ void ViewsListData::albumsAdded(const DataTypes::ListAlbumDataType &newData)
Q_EMIT dataAboutToBeAdded(d->mViewsParameters.size(), d->mViewsParameters.size() + newData.size() - 1);
for (const auto &oneAlbum : newData) {
ElisaUtils::IconUseColorOverlay useColorOverlay = ElisaUtils::DoNotUseColorOverlay;
auto coverImage = oneAlbum.albumArtURI();
if (!coverImage.isValid()) {
coverImage = d->mDefaultIcons[d->mEmbeddedCategory];
useColorOverlay = ElisaUtils::UseColorOverlay;
}
d->mViewsParameters.push_back({oneAlbum.title(),
......@@ -393,8 +386,7 @@ void ViewsListData::albumsAdded(const DataTypes::ListAlbumDataType &newData)
{QStringLiteral("A-Z"), QStringLiteral("Z-A")},
ViewManager::SingleAlbum,
ViewManager::DiscHeaders,
ViewManager::IsTrack,
useColorOverlay});
ViewManager::IsTrack});
}
Q_EMIT dataAdded();
......@@ -432,10 +424,8 @@ void ViewsListData::albumModified(const DataTypes::AlbumDataType &modifiedAlbum)
data.mMainTitle = modifiedAlbum.title();
if (modifiedAlbum.albumArtURI().isValid()) {
data.mMainImage = modifiedAlbum.albumArtURI();
data.mIconUseColorOverlay = ElisaUtils::DoNotUseColorOverlay;
} else {
data.mMainImage = d->mDefaultIcons[d->mEmbeddedCategory];
data.mIconUseColorOverlay = ElisaUtils::UseColorOverlay;
}
data.mSecondaryTitle = modifiedAlbum.artist();
......
......@@ -176,8 +176,7 @@ public:
Qt::SortOrder sortOrder, QVector<QString> sortOrderNames,
ViewManager::AlbumCardinality albumCardinality,
ViewManager::AlbumViewStyle albumViewStyle,
ViewManager::RadioSpecificStyle radioSpecificStyle,
ElisaUtils::IconUseColorOverlay iconUseColorOverlay)
ViewManager::RadioSpecificStyle radioSpecificStyle)
: mMainTitle(std::move(mainTitle))
, mMainImage(std::move(mainImage))
, mViewPresentationType(viewPresentationType)
......@@ -193,7 +192,6 @@ public:
, mAlbumCardinality(albumCardinality)
, mAlbumViewStyle(albumViewStyle)
, mRadioSpecificStyle(radioSpecificStyle)
, mIconUseColorOverlay(iconUseColorOverlay)
, mIsValid(true)
{
mDataFilter = {{DataTypes::DatabaseIdRole, databaseId}};
......@@ -269,8 +267,6 @@ public:
DataTypes::MusicDataType mDataFilter;
ElisaUtils::IconUseColorOverlay mIconUseColorOverlay = ElisaUtils::UseColorOverlay;
bool mUseSecondTitle = false;
bool mIsValid = false;
......@@ -318,8 +314,6 @@ public:
[[nodiscard]] bool useSecondTitle(int index) const;
[[nodiscard]] ElisaUtils::IconUseColorOverlay iconUseColorOverlay(int index) const;
[[nodiscard]] qulonglong databaseId(int index) const;
[[nodiscard]] bool defaultEntry(int index) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment