Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: from linuxdeepin/dtkgui #61

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/util/private/dbuiltiniconengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,26 @@ QString DBuiltinIconEngine::iconName()
return m_iconName;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QList<QSize> DBuiltinIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
{
ensureLoaded();

QList<QSize> sizes;
const int N = m_info.entries.size();
sizes.reserve(N);

// Gets all sizes from the DirectoryInfo entries
for (int i = 0; i < N; ++i) {
const auto& entry = m_info.entries.at(i);
int size = entry->dir.size;
sizes.append(QSize(size, size));
}

return sizes;
}
#endif

QThemeIconInfo DBuiltinIconEngine::loadIcon(const QString &iconName, uint key)
{
QThemeIconInfo info;
Expand Down
1 change: 1 addition & 0 deletions src/util/private/dbuiltiniconengine_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Q_DECL_HIDDEN DBuiltinIconEngine : public QIconEngine

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QString iconName() override;
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) override;
#else
QString iconName() const override;
#endif
Expand Down
16 changes: 16 additions & 0 deletions src/util/private/dciiconengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ const
return m_iconName;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QList<QSize> DDciIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
{
ensureIconTheme();

const auto availableSizes = m_dciIcon.availableSizes(dciTheme(), DDciIcon::Normal);
QList<QSize> sizes;
sizes.reserve(availableSizes.size());

for (int size : availableSizes)
sizes.append(QSize(size, size));

return sizes;
}
#endif

void DDciIconEngine::virtual_hook(int id, void *data)
{
ensureIconTheme();
Expand Down
1 change: 1 addition & 0 deletions src/util/private/dciiconengine_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Q_DECL_HIDDEN DDciIconEngine : public QIconEngine

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QString iconName() override;
QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) override;
#else
QString iconName() const override;
#endif
Expand Down
Loading