mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-17 13:02:49 -05:00
Fix icon selection highlights
- Change QListView mode to ListMode - Increase custom icon size - Reduce grid spacing - Improve selected icon state composite
This commit is contained in:
parent
3dcac2c46c
commit
5f9b640da1
@ -193,13 +193,13 @@ QPixmap Metadata::customIconPixmap(const QUuid& uuid) const
|
||||
|
||||
if (!QPixmapCache::find(cacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(m_customIcons.value(uuid));
|
||||
cacheKey = QPixmapCache::insert(pixmap);
|
||||
QPixmapCache::insert(pixmap);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmap Metadata::customIconScaledPixmap(const QUuid& uuid) const
|
||||
QPixmap Metadata::customIconScaledPixmap(const QUuid& uuid, const QSize& size) const
|
||||
{
|
||||
QPixmap pixmap;
|
||||
|
||||
@ -207,13 +207,8 @@ QPixmap Metadata::customIconScaledPixmap(const QUuid& uuid) const
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmapCache::Key& cacheKey = m_customIconScaledCacheKeys[uuid];
|
||||
|
||||
if (!QPixmapCache::find(cacheKey, &pixmap)) {
|
||||
QImage image = m_customIcons.value(uuid).scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
pixmap = QPixmap::fromImage(image);
|
||||
cacheKey = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
QImage image = m_customIcons.value(uuid).scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
pixmap = QPixmap::fromImage(image);
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
@ -228,12 +223,12 @@ QHash<QUuid, QImage> Metadata::customIcons() const
|
||||
return m_customIcons;
|
||||
}
|
||||
|
||||
QHash<QUuid, QPixmap> Metadata::customIconsScaledPixmaps() const
|
||||
QHash<QUuid, QPixmap> Metadata::customIconsScaledPixmaps(const QSize& size) const
|
||||
{
|
||||
QHash<QUuid, QPixmap> result;
|
||||
|
||||
for (const QUuid& uuid : m_customIconsOrder) {
|
||||
result.insert(uuid, customIconScaledPixmap(uuid));
|
||||
result.insert(uuid, customIconScaledPixmap(uuid, size));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPointer>
|
||||
#include <QSize>
|
||||
#include <QUuid>
|
||||
|
||||
#include "core/CustomData.h"
|
||||
@ -82,12 +83,12 @@ public:
|
||||
bool protectNotes() const;
|
||||
QImage customIcon(const QUuid& uuid) const;
|
||||
QPixmap customIconPixmap(const QUuid& uuid) const;
|
||||
QPixmap customIconScaledPixmap(const QUuid& uuid) const;
|
||||
QPixmap customIconScaledPixmap(const QUuid& uuid, const QSize& size = {16, 16}) const;
|
||||
bool containsCustomIcon(const QUuid& uuid) const;
|
||||
QHash<QUuid, QImage> customIcons() const;
|
||||
QList<QUuid> customIconsOrder() const;
|
||||
bool recycleBinEnabled() const;
|
||||
QHash<QUuid, QPixmap> customIconsScaledPixmaps() const;
|
||||
QHash<QUuid, QPixmap> customIconsScaledPixmaps(const QSize& size = {16, 16}) const;
|
||||
Group* recycleBin();
|
||||
const Group* recycleBin() const;
|
||||
QDateTime recycleBinChanged() const;
|
||||
|
@ -132,7 +132,7 @@ void EditWidgetIcons::load(const QUuid& currentUuid,
|
||||
m_currentUuid = currentUuid;
|
||||
setUrl(url);
|
||||
|
||||
m_customIconModel->setIcons(database->metadata()->customIconsScaledPixmaps(),
|
||||
m_customIconModel->setIcons(database->metadata()->customIconsScaledPixmaps({24, 24}),
|
||||
database->metadata()->customIconsOrder());
|
||||
|
||||
QUuid iconUuid = iconStruct.uuid;
|
||||
@ -294,7 +294,7 @@ bool EditWidgetIcons::addCustomIcon(const QImage& icon)
|
||||
if (uuid.isNull()) {
|
||||
uuid = QUuid::createUuid();
|
||||
m_db->metadata()->addCustomIcon(uuid, scaledicon);
|
||||
m_customIconModel->setIcons(m_db->metadata()->customIconsScaledPixmaps(),
|
||||
m_customIconModel->setIcons(m_db->metadata()->customIconsScaledPixmaps({24, 24}),
|
||||
m_db->metadata()->customIconsOrder());
|
||||
added = true;
|
||||
}
|
||||
@ -378,7 +378,7 @@ void EditWidgetIcons::removeCustomIcon()
|
||||
|
||||
// Remove the icon from the database
|
||||
m_db->metadata()->removeCustomIcon(iconUuid);
|
||||
m_customIconModel->setIcons(m_db->metadata()->customIconsScaledPixmaps(),
|
||||
m_customIconModel->setIcons(m_db->metadata()->customIconsScaledPixmaps({24, 24}),
|
||||
m_db->metadata()->customIconsOrder());
|
||||
|
||||
// Reset the current icon view
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>437</width>
|
||||
<height>300</height>
|
||||
<height>316</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -48,10 +48,10 @@
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>8</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
<enum>QListView::ListMode</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -80,10 +80,10 @@
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>8</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
<enum>QListView::ListMode</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -101,7 +101,6 @@ QModelIndex CustomIconModel::indexFromUuid(const QUuid& uuid) const
|
||||
int idx = m_iconsOrder.indexOf(uuid);
|
||||
if (idx > -1) {
|
||||
return index(idx, 0);
|
||||
} else {
|
||||
return QModelIndex();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -4511,6 +4511,22 @@ QStyle::SubControl BaseStyle::hitTestComplexControl(ComplexControl cc,
|
||||
|
||||
QPixmap BaseStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap, const QStyleOption* opt) const
|
||||
{
|
||||
// Default icon highlight is way too subtle
|
||||
if (iconMode == QIcon::Selected) {
|
||||
QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
QPainter painter(&img);
|
||||
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
|
||||
|
||||
QColor color =
|
||||
Phantom::DeriveColors::adjustLightness(opt->palette.color(QPalette::Normal, QPalette::Highlight), .25);
|
||||
color.setAlphaF(0.25);
|
||||
painter.fillRect(0, 0, img.width(), img.height(), color);
|
||||
|
||||
painter.end();
|
||||
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
||||
return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user