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

fix: availableSizes not work on Qt6 #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -271,6 +271,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;
int N = m_info.entries.size();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto N

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,11 +33,12 @@

#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

static QThemeIconInfo loadIcon(const QString &iconName, uint key);

Check warning on line 41 in src/util/private/dbuiltiniconengine_p.h

View workflow job for this annotation

GitHub Actions / check_job / DOXYGEN_CHECK

function QThemeIconInfo Dtk::Gui::DBuiltinIconEngine::loadIcon is not documented!

private:
bool hasIcon() const;
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();

auto availableSizes = m_dciIcon.availableSizes(dciTheme(), DDciIcon::Normal);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto

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