Fix icon not showing on Windows

For some reason QIcon::fromTheme(QStringLiteral("okular")) doesn't
return the proper icon on WelcomeScreen construction, i'm guessing
that's a bit too early, though haven't investigated why
This commit is contained in:
Albert Astals Cid 2023-05-03 18:20:32 +02:00
parent e83c4f56a4
commit 137cfec205
2 changed files with 12 additions and 2 deletions

View file

@ -113,8 +113,6 @@ WelcomeScreen::WelcomeScreen(QWidget *parent)
setupUi(this);
appIcon->setPixmap(QIcon::fromTheme(QStringLiteral("okular")).pixmap(KIconLoader::SizeEnormous));
connect(openButton, &QPushButton::clicked, this, &WelcomeScreen::openClicked);
connect(closeButton, &QPushButton::clicked, this, &WelcomeScreen::closeClicked);
@ -151,6 +149,15 @@ WelcomeScreen::~WelcomeScreen()
delete m_recentsItemDelegate;
}
void WelcomeScreen::showEvent(QShowEvent *e)
{
if (appIcon->pixmap(Qt::ReturnByValue).isNull()) {
appIcon->setPixmap(QIcon::fromTheme(QStringLiteral("okular")).pixmap(KIconLoader::SizeEnormous));
}
QWidget::showEvent(e);
}
void WelcomeScreen::loadRecents()
{
m_recentsModel->loadEntries(KSharedConfig::openConfig()->group("Recent Files"));

View file

@ -33,6 +33,9 @@ Q_SIGNALS:
void forgetAllRecents();
void forgetRecentItem(QUrl const &url);
protected:
void showEvent(QShowEvent *e) override;
private Q_SLOTS:
void recentsItemActivated(QModelIndex const &index);
void recentListChanged();