Commit a514c1c2 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[add-printer] Partly port away from KIconLoader

Use QIcon API instead. Improves the looks on highDPI screens
parent effeb603
......@@ -29,8 +29,6 @@
#include <QRegExpValidator>
#include <QDebug>
#include <KIconLoader>
PageAddPrinter::PageAddPrinter(QWidget *parent) :
GenericPage(parent),
ui(new Ui::PageAddPrinter)
......@@ -40,26 +38,21 @@ PageAddPrinter::PageAddPrinter(QWidget *parent) :
// setup default options
setWindowTitle(i18nc("@title:window", "Select a Printer to Add"));
// loads the standard key icon
QPixmap pixmap;
pixmap = KIconLoader::global()->loadIcon(QLatin1String("printer"),
KIconLoader::NoGroup,
KIconLoader::SizeEnormous, // a not so huge icon
KIconLoader::DefaultState);
QPixmap icon(pixmap);
QPainter painter(&icon);
pixmap = KIconLoader::global()->loadIcon(QLatin1String("dialog-information"),
KIconLoader::NoGroup,
KIconLoader::SizeLarge, // a not so huge icon
KIconLoader::DefaultState);
// the emblem icon to size 32
int overlaySize = KIconLoader::SizeLarge;
const int printerSize = 128;
const int overlaySize = 48;
QPixmap printerIcon = QIcon::fromTheme(QStringLiteral("printer")).pixmap(printerSize);
const QPixmap preferencesIcon = QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(overlaySize);
QPainter painter(&printerIcon);
// bottom right corner
const QPoint startPoint = QPoint(KIconLoader::SizeEnormous - overlaySize - 2,
KIconLoader::SizeEnormous - overlaySize - 2);
painter.drawPixmap(startPoint, pixmap);
ui->printerL->setPixmap(icon);
const QPoint startPoint = QPoint(printerSize - overlaySize - 2,
printerSize - overlaySize - 2);
painter.drawPixmap(startPoint, preferencesIcon);
ui->printerL->setPixmap(printerIcon);
// May contain any printable characters except "/", "#", and space
QRegExp rx(QLatin1String("[^/#\\ ]*"));
......
......@@ -28,8 +28,6 @@
#include <QPainter>
#include <KIconLoader>
PageChoosePrinters::PageChoosePrinters(const QVariantHash &args, QWidget *parent) :
GenericPage(parent),
ui(new Ui::PageChoosePrinters)
......@@ -39,25 +37,20 @@ PageChoosePrinters::PageChoosePrinters(const QVariantHash &args, QWidget *parent
// setup default options
setWindowTitle(i18nc("@title:window", "Select a Printer to Add"));
// loads the standard key icon
QPixmap pixmap;
pixmap = KIconLoader::global()->loadIcon(QLatin1String("printer"),
KIconLoader::NoGroup,
KIconLoader::SizeEnormous, // a not so huge icon
KIconLoader::DefaultState);
QPixmap icon(pixmap);
QPainter painter(&icon);
pixmap = KIconLoader::global()->loadIcon(QLatin1String("preferences-other"),
KIconLoader::NoGroup,
KIconLoader::SizeLarge, // a not so huge icon
KIconLoader::DefaultState);
// the emblem icon to size 32
const int overlaySize = KIconLoader::SizeLarge;
const int printerSize = 128;
const int overlaySize = 48;
QPixmap printerIcon = QIcon::fromTheme(QStringLiteral("printer")).pixmap(printerSize);
const QPixmap preferencesIcon = QIcon::fromTheme(QStringLiteral("preferences-other")).pixmap(overlaySize);
QPainter painter(&printerIcon);
// bottom right corner
const QPoint startPoint = QPoint(KIconLoader::SizeEnormous - overlaySize - 2,
KIconLoader::SizeEnormous - overlaySize - 2);
painter.drawPixmap(startPoint, pixmap);
ui->printerL->setPixmap(icon);
const QPoint startPoint = QPoint(printerSize - overlaySize - 2,
printerSize - overlaySize - 2);
painter.drawPixmap(startPoint, preferencesIcon);
ui->printerL->setPixmap(printerIcon);
connect(ui->membersLV, static_cast<void (ClassListWidget::*) (bool)>(&ClassListWidget::changed),
this, &PageChoosePrinters::allowProceed);
......
......@@ -16,7 +16,6 @@ target_link_libraries(kcm_printer_manager
Qt5::Widgets
KF5::CoreAddons
KF5::I18n
KF5::IconThemes
KF5::KCMUtils
kcupslib
)
......
......@@ -32,7 +32,6 @@
#include <KMessageBox>
#include <KAboutData>
#include <KToolInvocation>
#include <KIconLoader>
#include <QIcon>
#include <QMenu>
......@@ -63,7 +62,7 @@ PrintKCM::PrintKCM(QWidget *parent, const QVariantList &args) :
// The printer list needs to increase in width according to the icon sizes
// default dialog icon size is 32, this times 6 is 192 which is roughly the original width
ui->printersTV->setMinimumWidth(IconSize(KIconLoader::Dialog) * 6);
ui->printersTV->setMinimumWidth(192);
auto addMenu = new QMenu(this);
addMenu->addAction(i18nc("@action:intoolbar","Add a Printer Class"),
......
......@@ -26,12 +26,10 @@
#include <QPainter>
#include <QStyleOption>
#include <KIconLoader>
PrinterDelegate::PrinterDelegate(QObject *parent)
: QStyledItemDelegate(parent)
{
m_mainIconSize = IconSize(KIconLoader::Dialog); // 32
m_mainIconSize = 32;
m_favIconSize = m_mainIconSize * 0.75; // 24
m_emblemIconSize = m_mainIconSize / 4; // 8
m_universalPadding = m_mainIconSize / 8; // 4
......
......@@ -30,7 +30,6 @@
#include <QMenu>
#include <QProcess>
#include <KIconLoader>
#include <KToolInvocation>
#define PRINTER_ICON_SIZE 128
......@@ -44,10 +43,7 @@ PrinterDescription::PrinterDescription(QWidget *parent) :
m_layoutEnd = ui->formLayout->count();
// loads the standard key icon
m_printerIcon = KIconLoader::global()->loadIcon(QLatin1String("printer"),
KIconLoader::NoGroup,
PRINTER_ICON_SIZE, // a not so huge icon
KIconLoader::DefaultState);
m_printerIcon = QIcon::fromTheme(QStringLiteral("printer")).pixmap(PRINTER_ICON_SIZE);
ui->iconL->setPixmap(m_printerIcon);
auto menu = new QMenu(ui->maintenancePB);
......
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