Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 46e95531 authored by Henrik Fehlauer's avatar Henrik Fehlauer

Fix icon colors of inline context buttons also in full screen mode

Summary:
In the darker full screen mode, the icons of the mouse-over overlays
were still hard to see against the similarly coloured background. This
was because when switching to full screen mode, we would miss to reset
the icon (except for `mToggleSelectionButton`). The root cause is
`QAbstractButton`, which just holds onto a pixmap and has no way of
knowing `KIconLoader` would return a differently coloured icon when the
colour palette changes (as is the case for colour-aware icon sets like
"Breeze").

To fix this, we simply use `QIcon::fromTheme` instead of `SmallIcon`,
which returns a proper `QIcon` instead of a `QPixmap` and automatically
adapts to colour palette changes.

(This is a followup patch to D7988.)

CCBUG: 383059
FIXED-IN: 17.08.2

Test Plan:
Overlay icons perfectly visible against the background color in standard
and full screen mode. Tested with "Breeze" and "Breeze Dark" colour
schemes as well as "Breeze", "Oxygen" and "Fusion" widget styles.
("Fusion" does not allow to customize the size for small icons, though.)

Reviewers: #kde_applications, broulik, ngraham

Reviewed By: broulik

Differential Revision: https://phabricator.kde.org/D8031
parent 4333b095
......@@ -83,7 +83,7 @@ DateWidget::DateWidget(QWidget* parent)
d->mPreviousButton = new StatusBarToolButton;
d->mPreviousButton->setGroupPosition(StatusBarToolButton::GroupLeft);
// FIXME: RTL
d->mPreviousButton->setIcon(SmallIcon("go-previous"));
d->mPreviousButton->setIcon(QIcon::fromTheme("go-previous"));
connect(d->mPreviousButton, &StatusBarToolButton::clicked, this, &DateWidget::goToPrevious);
d->mDateButton = new StatusBarToolButton;
......@@ -92,7 +92,7 @@ DateWidget::DateWidget(QWidget* parent)
d->mNextButton = new StatusBarToolButton;
d->mNextButton->setGroupPosition(StatusBarToolButton::GroupRight);
d->mNextButton->setIcon(SmallIcon("go-next"));
d->mNextButton->setIcon(QIcon::fromTheme("go-next"));
connect(d->mNextButton, &StatusBarToolButton::clicked, this, &DateWidget::goToNext);
QHBoxLayout* layout = new QHBoxLayout(this);
......
......@@ -537,7 +537,7 @@ struct PreviewItemDelegatePrivate
void updateToggleSelectionButton()
{
mToggleSelectionButton->setIcon(SmallIcon(
mToggleSelectionButton->setIcon(QIcon::fromTheme(
mView->selectionModel()->isSelected(mIndexUnderCursor) ? "list-remove" : "list-add"
));
}
......@@ -611,19 +611,19 @@ PreviewItemDelegate::PreviewItemDelegate(ThumbnailView* view)
d->mContextBar->hide();
d->mToggleSelectionButton = new QToolButton;
d->mToggleSelectionButton->setIcon(SmallIcon("list-add"));
d->mToggleSelectionButton->setIcon(QIcon::fromTheme("list-add"));
connect(d->mToggleSelectionButton, &QToolButton::clicked, this, &PreviewItemDelegate::slotToggleSelectionClicked);
d->mFullScreenButton = new QToolButton;
d->mFullScreenButton->setIcon(SmallIcon("view-fullscreen"));
d->mFullScreenButton->setIcon(QIcon::fromTheme("view-fullscreen"));
connect(d->mFullScreenButton, &QToolButton::clicked, this, &PreviewItemDelegate::slotFullScreenClicked);
d->mRotateLeftButton = new QToolButton;
d->mRotateLeftButton->setIcon(SmallIcon("object-rotate-left"));
d->mRotateLeftButton->setIcon(QIcon::fromTheme("object-rotate-left"));
connect(d->mRotateLeftButton, &QToolButton::clicked, this, &PreviewItemDelegate::slotRotateLeftClicked);
d->mRotateRightButton = new QToolButton;
d->mRotateRightButton->setIcon(SmallIcon("object-rotate-right"));
d->mRotateRightButton->setIcon(QIcon::fromTheme("object-rotate-right"));
connect(d->mRotateRightButton, &QToolButton::clicked, this, &PreviewItemDelegate::slotRotateRightClicked);
QHBoxLayout* layout = new QHBoxLayout(d->mContextBar);
......@@ -636,7 +636,7 @@ PreviewItemDelegate::PreviewItemDelegate(ThumbnailView* view)
// Save button
d->mSaveButton = new QToolButton(d->mView->viewport());
d->mSaveButton->setIcon(SmallIcon("document-save"));
d->mSaveButton->setIcon(QIcon::fromTheme("document-save"));
d->mSaveButton->hide();
connect(d->mSaveButton, &QToolButton::clicked, this, &PreviewItemDelegate::slotSaveClicked);
}
......
......@@ -81,7 +81,7 @@ struct ThumbnailBarItemDelegatePrivate
void setupToggleSelectionButton()
{
mToggleSelectionButton = new QToolButton(mView->viewport());
mToggleSelectionButton->setIcon(SmallIcon("list-add"));
mToggleSelectionButton->setIcon(QIcon::fromTheme("list-add"));
mToggleSelectionButton->hide();
QObject::connect(mToggleSelectionButton, &QToolButton::clicked, q, &ThumbnailBarItemDelegate::toggleSelection);
}
......@@ -140,7 +140,7 @@ struct ThumbnailBarItemDelegatePrivate
void updateToggleSelectionButton()
{
bool isSelected = mView->selectionModel()->isSelected(mIndexUnderCursor);
mToggleSelectionButton->setIcon(SmallIcon(isSelected ? "list-remove" : "list-add"));
mToggleSelectionButton->setIcon(QIcon::fromTheme(isSelected ? "list-remove" : "list-add"));
}
};
......
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