Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Print Manager
Commits
a514c1c2
Commit
a514c1c2
authored
Sep 11, 2020
by
Nicolas Fella
Browse files
[add-printer] Partly port away from KIconLoader
Use QIcon API instead. Improves the looks on highDPI screens
parent
effeb603
Changes
6
Hide whitespace changes
Inline
Side-by-side
add-printer/PageAddPrinter.cpp
View file @
a514c1c2
...
...
@@ -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
(
"[^/#
\\
]*"
));
...
...
add-printer/PageChoosePrinters.cpp
View file @
a514c1c2
...
...
@@ -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
,
p
ixmap
);
ui
->
printerL
->
setPixmap
(
i
con
);
const
QPoint
startPoint
=
QPoint
(
printerSize
-
overlaySize
-
2
,
printerSize
-
overlaySize
-
2
);
painter
.
drawPixmap
(
startPoint
,
p
referencesIcon
);
ui
->
printerL
->
setPixmap
(
printerI
con
);
connect
(
ui
->
membersLV
,
static_cast
<
void
(
ClassListWidget
::*
)
(
bool
)
>
(
&
ClassListWidget
::
changed
),
this
,
&
PageChoosePrinters
::
allowProceed
);
...
...
printer-manager-kcm/CMakeLists.txt
View file @
a514c1c2
...
...
@@ -16,7 +16,6 @@ target_link_libraries(kcm_printer_manager
Qt5::Widgets
KF5::CoreAddons
KF5::I18n
KF5::IconThemes
KF5::KCMUtils
kcupslib
)
...
...
printer-manager-kcm/PrintKCM.cpp
View file @
a514c1c2
...
...
@@ -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"
),
...
...
printer-manager-kcm/PrinterDelegate.cpp
View file @
a514c1c2
...
...
@@ -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
...
...
printer-manager-kcm/PrinterDescription.cpp
View file @
a514c1c2
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment