Commit 2cbb688d authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Port away from KIconThemes

Use QIcon API instead.

Fixes quite a few highDPI issues.
parent dc97890c
......@@ -35,7 +35,6 @@ find_package(KF5 REQUIRED COMPONENTS
ConfigWidgets
DocTools
GuiAddons
IconThemes
ItemViews
NotifyConfig
NewStuff
......
......@@ -77,7 +77,6 @@ target_link_libraries(kwordquiz
Qt5::PrintSupport
Qt5::Widgets
KF5::Crash
KF5::IconThemes
KF5::ConfigCore
KF5::I18n
KF5::ItemViews
......
......@@ -23,7 +23,6 @@
#include <QVBoxLayout>
#include <KConfigGroup>
#include <KIconLoader>
#include <KLocalizedString>
#include "kwqtablemodel.h"
......@@ -47,8 +46,9 @@ DlgLanguage::DlgLanguage(KWQTableModel *model, QWidget *parent): QDialog(parent)
setupUi(mainWidget);
column1Picture -> setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("question"), KIconLoader::Panel));
column2Picture -> setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("answer"), KIconLoader::Panel));
const int iconSize = style()->pixelMetric(QStyle::PixelMetric::PM_LargeIconSize);
column1Picture->setPixmap(QIcon::fromTheme(QStringLiteral("question")).pixmap(iconSize));
column2Picture->setPixmap(QIcon::fromTheme(QStringLiteral("answer")).pixmap(iconSize));
#if 0 // FIXME KF5: Use QCompleter for this
column1TitleLineEdit->completionObject(true)->setItems(Prefs::columnTitles1());
......
......@@ -18,7 +18,7 @@
#include "kwqscorewidget.h"
#include <KIconLoader>
#include <QIcon>
KWQScoreWidget::KWQScoreWidget(QWidget *parent) : QWidget(parent)
{
......@@ -141,24 +141,24 @@ void KWQScoreWidget::update()
QString s;
s = s.setNum(m_questionCount, 10);
lblScoreCount->setText(s);
picCount->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("kwordquiz"), KIconLoader::Panel));
picCount->setPixmap(QIcon::fromTheme(QStringLiteral("kwordquiz")).pixmap(32));
s = answerText();
lblScoreAnswered->setText(s);
if (!s.isEmpty())
picAnswered->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("question"), KIconLoader::Panel));
picAnswered->setPixmap(QIcon::fromTheme(QStringLiteral("question")).pixmap(32));
s = correctText();
lblScoreCorrect->setText(s);
if (!s.isEmpty())
picCorrect->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("answer-correct"), KIconLoader::Panel));
picCorrect->setPixmap(QIcon::fromTheme(QStringLiteral("answer-correct")).pixmap(32));
s = errorText();
lblScoreError->setText(s);
if (s.isEmpty())
picError->setPixmap(QPixmap());
else
picError->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("error"), KIconLoader::Panel));
picError->setPixmap(QIcon::fromTheme(QStringLiteral("error")).pixmap(32));
}
void KWQScoreWidget::swapCount()
......
......@@ -26,7 +26,6 @@
#include <KActionCollection>
#include <KConfigGroup>
#include <KIconLoader>
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardAction>
......
......@@ -32,6 +32,7 @@
static const char *description = I18N_NOOP("A powerful flashcard and vocabulary learning program");
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
QApplication app(argc, argv);
KCrash::initialize();
......
......@@ -23,7 +23,6 @@
#include <QButtonGroup>
#include <KActionCollection>
#include <KIconLoader>
#include <KLocalizedString>
#include <KNotification>
......@@ -104,7 +103,7 @@ void MultipleView::slotCheck()
if (fIsCorrect)
{
picYourAnswer->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("answer-correct"), KIconLoader::Panel));
picYourAnswer->setPixmap(QIcon::fromTheme(QStringLiteral("answer-correct")).pixmap(32));
lblCorrectHeader->clear();
picCorrectAnswer->clear();
lblCorrect->clear();
......@@ -113,9 +112,9 @@ void MultipleView::slotCheck()
}
else
{
picYourAnswer->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("error"), KIconLoader::Panel));
picYourAnswer->setPixmap(QIcon::fromTheme(QStringLiteral("error")).pixmap(32));
lblCorrect->setText(m_quiz->answer());
picCorrectAnswer->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("answer-correct"), KIconLoader::Panel));
picCorrectAnswer->setPixmap(QIcon::fromTheme(QStringLiteral("answer-correct")).pixmap(32));
lblCorrectHeader->setText(i18n("Correct Answer"));
score->countIncrement(KWQScoreWidget::cdError);
KNotification::event(QStringLiteral("QuizError"), i18n("Your answer was incorrect."));
......@@ -123,7 +122,7 @@ void MultipleView::slotCheck()
lblPreviousQuestionHeader->setText(i18n("Previous Question"));
lblPreviousQuestion->setText(m_quiz->question());
picPrevious->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("question"), KIconLoader::Panel));
picPrevious->setPixmap(QIcon::fromTheme(QStringLiteral("question")).pixmap(32));
lblYourAnswerHeader->setText(i18n("Your Answer"));
lblYourAnswer->setText(m_quiz->yourAnswer(ans));
......@@ -150,7 +149,7 @@ void MultipleView::slotCheck()
opt1->hide();
opt2->hide();
opt3->hide();
picQuestion->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("kwordquiz"), KIconLoader::Panel));
picQuestion->setPixmap(QIcon::fromTheme(QStringLiteral("kwordquiz")).pixmap(32));
picAnswer->clear();
}
}
......@@ -176,7 +175,7 @@ void MultipleView::showQuestion()
lblQuestionLanguage->setText(m_quiz ->langQuestion());
lblQuestion->setText(m_quiz ->question());
picQuestion->setPixmap(KIconLoader::global()->loadIcon(m_quiz->quizIcon(KWQQuizModel::IconLeftCol), KIconLoader::Panel));
picQuestion->setPixmap(QIcon::fromTheme(m_quiz->quizIcon(KWQQuizModel::IconLeftCol)).pixmap(32));
lblAnswerLanguage->setText(m_quiz ->langAnswer());
......@@ -192,7 +191,7 @@ void MultipleView::showQuestion()
opt3->setChecked(false);
m_choicesButtons->setExclusive(true);
setFocus();
picAnswer->setPixmap(KIconLoader::global()->loadIcon(m_quiz->quizIcon(KWQQuizModel::IconRightCol), KIconLoader::Panel));
picAnswer->setPixmap(QIcon::fromTheme(m_quiz->quizIcon(KWQQuizModel::IconRightCol)).pixmap(32));
}
void MultipleView::slotApplySettings()
......
......@@ -23,7 +23,6 @@
#include <QDBusInterface>
#include <QUrl>
#include <KIconLoader>
#include <KLocalizedString>
#include <KNotification>
......@@ -137,7 +136,7 @@ void QAView::slotCheck()
if (fIsCorrect)
{
picYourAnswer->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("answer-correct"), KIconLoader::Panel));
picYourAnswer->setPixmap(QIcon::fromTheme(QStringLiteral("answer-correct")).pixmap(32));
lblYourAnswer->setText(m_quiz->yourAnswer(txtAnswer->text()));
lblCorrectHeader->clear();
picCorrectAnswer->clear();
......@@ -148,10 +147,10 @@ void QAView::slotCheck()
}
else
{
picYourAnswer->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("error"), KIconLoader::Panel));
picYourAnswer->setPixmap(QIcon::fromTheme(QStringLiteral("error")).pixmap(32));
lblYourAnswer->setText(highlightError(m_quiz->answer(), m_quiz->yourAnswer(txtAnswer->text())));
lblCorrect->setText(m_quiz->answer());
picCorrectAnswer->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("answer-correct"), KIconLoader::Panel));
picCorrectAnswer->setPixmap(QIcon::fromTheme(QStringLiteral("answer-correct")).pixmap(32));
lblCorrectHeader->setText(i18n("Correct Answer"));
score->countIncrement(KWQScoreWidget::cdError);
KNotification::event(QStringLiteral("QuizError"), i18n("Your answer was incorrect."));
......@@ -163,7 +162,7 @@ void QAView::slotCheck()
lblPreviousQuestionHeader->setText(i18n("Previous Question"));
lblPreviousQuestion->setText(m_quiz->question());
//lblPreviousQuestion->setFont(m_quiz->fontQuestion(m_question));
picPrevious->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("question"), KIconLoader::Panel));
picPrevious->setPixmap(QIcon::fromTheme(QStringLiteral("question")).pixmap(32));
lblYourAnswerHeader->setText(i18n("Your Answer"));
......@@ -186,7 +185,7 @@ void QAView::slotCheck()
lblAnswerLanguage->clear();
lblAnswerBlank->hide();
txtAnswer->hide();
picQuestion->setPixmap(KIconLoader::global()->loadIcon(QStringLiteral("kwordquiz"), KIconLoader::Panel));
picQuestion->setPixmap(QIcon::fromTheme(QStringLiteral("kwordquiz")).pixmap(32));
picAnswer->clear();
}
}
......@@ -230,7 +229,7 @@ void QAView::showQuestion()
lblQuestion->setText(m_quiz ->question());
//audioPlayQuestion();
picQuestion->setPixmap(KIconLoader::global()->loadIcon(m_quiz->quizIcon(KWQQuizModel::IconLeftCol), KIconLoader::Panel));
picQuestion->setPixmap(QIcon::fromTheme(m_quiz->quizIcon(KWQQuizModel::IconLeftCol)).pixmap(32));
lblAnswerLanguage->setText(m_quiz ->langAnswer());
......@@ -244,7 +243,7 @@ void QAView::showQuestion()
txtAnswer->setText(QLatin1String(""));
picAnswer->setPixmap(KIconLoader::global()->loadIcon(m_quiz->quizIcon(KWQQuizModel::IconRightCol), KIconLoader::Panel));
picAnswer->setPixmap(QIcon::fromTheme(m_quiz->quizIcon(KWQQuizModel::IconRightCol)).pixmap(32));
QString layout = m_quiz->kbAnswer();
if (!layout.isEmpty()) {
......
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