mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kcontrol: load preview icons in SVG/SVGZ format as any other format
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
9fcbe100a1
commit
21d5aaf376
2 changed files with 5 additions and 16 deletions
|
@ -12,7 +12,7 @@ set(kcm_icons_PART_SRCS
|
|||
|
||||
kde4_add_plugin(kcm_icons ${kcm_icons_PART_SRCS})
|
||||
|
||||
target_link_libraries(kcm_icons ${KDE4_KIO_LIBS} ${QT_QTSVG_LIBRARY})
|
||||
target_link_libraries(kcm_icons ${KDE4_KIO_LIBS} ${QT_QTGUI_LIBRARY})
|
||||
|
||||
########### install files ###############
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QTreeWidget>
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kapplication.h>
|
||||
|
@ -109,7 +107,7 @@ IconThemesConfig::IconThemesConfig(const KComponentData &inst, QWidget *parent)
|
|||
connect(m_removeButton,SIGNAL(clicked()),SLOT(removeSelectedTheme()));
|
||||
|
||||
topLayout->addWidget(
|
||||
new QLabel(i18n("Select the icon theme you want to use:"), this));
|
||||
new QLabel(i18n("Select the icon theme you want to use:"), this));
|
||||
topLayout->addWidget(m_preview);
|
||||
topLayout->addWidget(m_iconThemes);
|
||||
QHBoxLayout *lg = new QHBoxLayout();
|
||||
|
@ -370,7 +368,6 @@ void IconThemesConfig::updateRemoveButton()
|
|||
void loadPreview(QLabel *label, KIconTheme& icontheme, const QStringList& iconnames)
|
||||
{
|
||||
const int size = qMin(48, icontheme.defaultSize(KIconLoader::Desktop));
|
||||
QSvgRenderer renderer;
|
||||
foreach(const QString &iconthemename, QStringList() << icontheme.internalName() << icontheme.inherits()) {
|
||||
foreach(const QString &name, iconnames) {
|
||||
K3Icon icon = KIconTheme(iconthemename).iconPath(QString("%1.png").arg(name), size, KIconLoader::MatchBest);
|
||||
|
@ -379,19 +376,11 @@ void loadPreview(QLabel *label, KIconTheme& icontheme, const QStringList& iconna
|
|||
return;
|
||||
}
|
||||
icon = KIconTheme(iconthemename).iconPath(QString("%1.svg").arg(name), size, KIconLoader::MatchBest);
|
||||
if( ! icon.isValid() ) {
|
||||
if(!icon.isValid() ) {
|
||||
icon = KIconTheme(iconthemename).iconPath(QString("%1.svgz").arg(name), size, KIconLoader::MatchBest);
|
||||
if( ! icon.isValid() ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (renderer.load(icon.path)) {
|
||||
QPixmap pix(size, size);
|
||||
pix.fill(label->palette().color(QPalette::Background));
|
||||
QPainter p(&pix);
|
||||
p.setViewport(0, 0, size, size);
|
||||
renderer.render(&p);
|
||||
label->setPixmap(pix.scaled(size, size));
|
||||
if (icon.isValid()) {
|
||||
label->setPixmap(QPixmap(icon.path).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue