mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
generic: replace QLabel with the new KPixmapWidget class
or how to optimize painting of pixmaps and icons Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
23479d802a
commit
66f6104da4
15 changed files with 93 additions and 92 deletions
|
@ -289,11 +289,11 @@ KateVSStatusBar::KateVSStatusBar ( KateViewSpace *parent)
|
|||
addWidget( m_charsLabel, 0 );
|
||||
m_charsLabel->installEventFilter( this );
|
||||
|
||||
m_modifiedLabel = new QLabel( this );
|
||||
m_modifiedLabel->setFixedSize( 16, 16 );
|
||||
addWidget( m_modifiedLabel, 0 );
|
||||
m_modifiedLabel->setAlignment( Qt::AlignCenter );
|
||||
m_modifiedLabel->installEventFilter( this );
|
||||
m_modifiedWidget = new KPixmapWidget( this );
|
||||
m_modifiedWidget->setFixedSize( 16, 16 );
|
||||
addWidget( m_modifiedWidget, 0 );
|
||||
m_modifiedWidget->setAlignment( Qt::AlignCenter );
|
||||
m_modifiedWidget->installEventFilter( this );
|
||||
|
||||
m_selectModeLabel = new QLabel( i18n(" LINE "), this );
|
||||
addWidget( m_selectModeLabel, 0 );
|
||||
|
@ -430,7 +430,7 @@ void KateVSStatusBar::modifiedChanged()
|
|||
|
||||
bool modOnHD = info && info->modifiedOnDisc;
|
||||
|
||||
m_modifiedLabel->setPixmap(
|
||||
m_modifiedWidget->setPixmap(
|
||||
mod ?
|
||||
info && modOnHD ?
|
||||
m_modmodPm :
|
||||
|
|
|
@ -32,14 +32,15 @@
|
|||
#include <QPixmap>
|
||||
#include <QLabel>
|
||||
#include <QEvent>
|
||||
#include <QStackedWidget>
|
||||
#include <KStatusBar>
|
||||
#include <KVBox>
|
||||
#include <KPixmapWidget>
|
||||
|
||||
class KConfigBase;
|
||||
class KSqueezedTextLabel;
|
||||
class KateViewManager;
|
||||
class KateViewSpace;
|
||||
#include <QStackedWidget>
|
||||
|
||||
class KateVSStatusBar : public KStatusBar
|
||||
{
|
||||
|
@ -83,7 +84,7 @@ class KateVSStatusBar : public KStatusBar
|
|||
private:
|
||||
QLabel* m_lineColLabel;
|
||||
QLabel* m_charsLabel;
|
||||
QLabel* m_modifiedLabel;
|
||||
KPixmapWidget* m_modifiedWidget;
|
||||
QLabel* m_insertModeLabel;
|
||||
QLabel* m_selectModeLabel;
|
||||
QLabel* m_encodingLabel;
|
||||
|
|
|
@ -20,10 +20,11 @@
|
|||
#include <KGlobal>
|
||||
#include <KLocale>
|
||||
#include <KUrl>
|
||||
#include <netwm.h>
|
||||
#include <KShortcut>
|
||||
#include <kwindowsystem.h>
|
||||
#include <KWindowSystem>
|
||||
#include <KPixmapWidget>
|
||||
#include <kkeyserver.h>
|
||||
#include <netwm.h>
|
||||
|
||||
#include <X11/XKBlib.h>
|
||||
#define XK_MISCELLANY
|
||||
|
@ -595,13 +596,13 @@ void KAccessApp::createDialogContents() {
|
|||
QHBoxLayout * lay = new QHBoxLayout(contents);
|
||||
lay->setSpacing(KDialog::spacingHint());
|
||||
|
||||
QLabel *label1 = new QLabel( contents);
|
||||
KPixmapWidget *pixmap1 = new KPixmapWidget( contents);
|
||||
QPixmap pixmap = KIconLoader::global()->loadIcon("dialog-warning", KIconLoader::NoGroup, KIconLoader::SizeMedium, KIconLoader::DefaultState, QStringList(), 0, true);
|
||||
if (pixmap.isNull())
|
||||
pixmap = QMessageBox::standardIcon(QMessageBox::Warning);
|
||||
label1->setPixmap(pixmap);
|
||||
pixmap1->setPixmap(pixmap);
|
||||
|
||||
lay->addWidget( label1, 0, Qt::AlignCenter );
|
||||
lay->addWidget( pixmap1, 0, Qt::AlignCenter );
|
||||
lay->addSpacing(KDialog::spacingHint());
|
||||
|
||||
QVBoxLayout * vlay = new QVBoxLayout();
|
||||
|
|
|
@ -52,21 +52,48 @@
|
|||
|
||||
static const int ThemeNameRole = Qt::UserRole + 1;
|
||||
|
||||
static void loadPreview(KPixmapWidget *widget, KIconTheme& icontheme, const QStringList& iconnames)
|
||||
{
|
||||
const int size = qMin(48, icontheme.defaultSize(KIconLoader::Desktop));
|
||||
const QStringList iconthemenames = QStringList()
|
||||
<< icontheme.internalName()
|
||||
<< icontheme.inherits();
|
||||
foreach(const QString &iconthemename, iconthemenames) {
|
||||
foreach(const QString &name, iconnames) {
|
||||
KIconTheme kicontheme(iconthemename);
|
||||
QString icon = kicontheme.iconPath(QString("%1.png").arg(name), size, KIconLoader::MatchBest);
|
||||
if (!icon.isEmpty()) {
|
||||
widget->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
icon = kicontheme.iconPath(QString("%1.svg").arg(name), size, KIconLoader::MatchBest);
|
||||
if (icon.isEmpty() ) {
|
||||
icon = kicontheme.iconPath(QString("%1.svgz").arg(name), size, KIconLoader::MatchBest);
|
||||
}
|
||||
if (!icon.isEmpty()) {
|
||||
widget->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
widget->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
IconThemesConfig::IconThemesConfig(const KComponentData &inst, QWidget *parent)
|
||||
: KCModule(inst, parent)
|
||||
{
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
|
||||
QFrame *m_preview=new QFrame(this);
|
||||
QFrame *m_preview = new QFrame(this);
|
||||
m_preview->setMinimumHeight(80);
|
||||
|
||||
QHBoxLayout *lh2=new QHBoxLayout( m_preview );
|
||||
QHBoxLayout *lh2 = new QHBoxLayout( m_preview );
|
||||
lh2->setSpacing(0);
|
||||
m_previewExec=new QLabel(m_preview);
|
||||
m_previewExec = new KPixmapWidget(m_preview);
|
||||
m_previewExec->setPixmap(DesktopIcon("system-run"));
|
||||
m_previewFolder=new QLabel(m_preview);
|
||||
m_previewFolder = new KPixmapWidget(m_preview);
|
||||
m_previewFolder->setPixmap(DesktopIcon("folder"));
|
||||
m_previewDocument=new QLabel(m_preview);
|
||||
m_previewDocument=new KPixmapWidget(m_preview);
|
||||
m_previewDocument->setPixmap(DesktopIcon("document"));
|
||||
|
||||
lh2->addStretch(10);
|
||||
|
@ -364,33 +391,6 @@ void IconThemesConfig::updateRemoveButton()
|
|||
m_removeButton->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void loadPreview(QLabel *label, KIconTheme& icontheme, const QStringList& iconnames)
|
||||
{
|
||||
const int size = qMin(48, icontheme.defaultSize(KIconLoader::Desktop));
|
||||
const QStringList iconthemenames = QStringList()
|
||||
<< icontheme.internalName()
|
||||
<< icontheme.inherits();
|
||||
foreach(const QString &iconthemename, iconthemenames) {
|
||||
foreach(const QString &name, iconnames) {
|
||||
KIconTheme kicontheme(iconthemename);
|
||||
QString icon = kicontheme.iconPath(QString("%1.png").arg(name), size, KIconLoader::MatchBest);
|
||||
if (!icon.isEmpty()) {
|
||||
label->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
icon = kicontheme.iconPath(QString("%1.svg").arg(name), size, KIconLoader::MatchBest);
|
||||
if (icon.isEmpty() ) {
|
||||
icon = kicontheme.iconPath(QString("%1.svgz").arg(name), size, KIconLoader::MatchBest);
|
||||
}
|
||||
if (!icon.isEmpty()) {
|
||||
label->setPixmap(QPixmap(icon).scaled(size, size));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
label->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
void IconThemesConfig::themeSelected(QTreeWidgetItem *item)
|
||||
{
|
||||
if (!item) {
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#include <kcmodule.h>
|
||||
#include <kpushbutton.h>
|
||||
#include <kpixmapwidget.h>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QStringList>
|
||||
#include <QTreeWidget>
|
||||
#include <QTreeWidgetItem>
|
||||
|
@ -59,9 +59,9 @@ private:
|
|||
QTreeWidget *m_iconThemes;
|
||||
KPushButton *m_removeButton;
|
||||
|
||||
QLabel *m_previewExec;
|
||||
QLabel *m_previewFolder;
|
||||
QLabel *m_previewDocument;
|
||||
KPixmapWidget *m_previewExec;
|
||||
KPixmapWidget *m_previewFolder;
|
||||
KPixmapWidget *m_previewDocument;
|
||||
QTreeWidgetItem *m_defaultTheme;
|
||||
bool m_bChanged;
|
||||
};
|
||||
|
|
|
@ -102,12 +102,12 @@ void InfoPanel::setBottomInfo(QVListLayout *lay)
|
|||
setBottomWidgetLayout(lay);
|
||||
}
|
||||
|
||||
QLabel *InfoPanel::setDevicesIcon(const QIcon &deviceIcon)
|
||||
KPixmapWidget *InfoPanel::setDevicesIcon(const QIcon &deviceIcon)
|
||||
{
|
||||
QLabel *iconLabel = new QLabel();
|
||||
KPixmapWidget *iconWidget = new KPixmapWidget();
|
||||
|
||||
iconLabel->setPixmap(deviceIcon.pixmap(QSize(70,50)));
|
||||
return iconLabel;
|
||||
iconWidget->setPixmap(deviceIcon.pixmap(QSize(70,50)));
|
||||
return iconWidget;
|
||||
}
|
||||
|
||||
void InfoPanel::setTopInfo(const QIcon &deviceIcon, Solid::Device *device)
|
||||
|
|
|
@ -23,19 +23,18 @@
|
|||
#ifndef INFOPANEL
|
||||
#define INFOPANEL
|
||||
|
||||
// QT
|
||||
// Katie
|
||||
#include <QWidget>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
|
||||
//Solid
|
||||
#include <solid/device.h>
|
||||
#include <solid/deviceinterface.h>
|
||||
|
||||
//KDE
|
||||
#include <kicon.h>
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kpixmapwidget.h>
|
||||
#include <solid/device.h>
|
||||
#include <solid/deviceinterface.h>
|
||||
|
||||
//Local
|
||||
#include "qvlistlayout.h"
|
||||
|
@ -63,7 +62,7 @@ class InfoPanel : public QGroupBox
|
|||
void removeItems(QWidget *);
|
||||
void setDefaultText();
|
||||
|
||||
QLabel *setDevicesIcon(const QIcon &);
|
||||
KPixmapWidget *setDevicesIcon(const QIcon &);
|
||||
QVBoxLayout *setAlignedLayout(QWidget *parent, const int & = 0);
|
||||
|
||||
QWidget *top;
|
||||
|
|
|
@ -36,9 +36,9 @@ DefaultBoxWidget::DefaultBoxWidget()
|
|||
|
||||
void DefaultBoxWidget::createDisplay()
|
||||
{
|
||||
m_iconLabel = new QLabel();
|
||||
m_iconLabel->setAlignment(Qt::AlignCenter);
|
||||
m_iconLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
m_iconWidget = new KPixmapWidget();
|
||||
m_iconWidget->setAlignment(Qt::AlignCenter);
|
||||
m_iconWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
|
||||
QFont bFont;
|
||||
bFont.setBold(true);
|
||||
|
@ -61,7 +61,7 @@ void DefaultBoxWidget::createDisplay()
|
|||
m_info2NameLabel = new QLabel();
|
||||
m_info2NameLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
|
||||
m_layout->addWidget(m_iconLabel,1,1,3,1,Qt::AlignCenter);
|
||||
m_layout->addWidget(m_iconWidget,1,1,3,1,Qt::AlignCenter);
|
||||
|
||||
m_layout->addWidget(m_info0Label,1,2,1,1);
|
||||
m_layout->addWidget(m_info0NameLabel,1,3,1,1);
|
||||
|
@ -82,7 +82,7 @@ void DefaultBoxWidget::setLabelTitles(const QString &first, const QString &secon
|
|||
|
||||
void DefaultBoxWidget::setIcon(const KIcon &icon)
|
||||
{
|
||||
m_iconLabel->setPixmap(icon.pixmap(64));
|
||||
m_iconWidget->setPixmap(icon.pixmap(64));
|
||||
}
|
||||
|
||||
void DefaultBoxWidget::setLabelOne(const QString &info)
|
||||
|
|
|
@ -23,13 +23,14 @@
|
|||
#ifndef DEFAULTBOXWIDGET
|
||||
#define DEFAULTBOXWIDGET
|
||||
|
||||
//QT
|
||||
// Katie
|
||||
#include <QGroupBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
|
||||
//KDE
|
||||
// KDE
|
||||
#include <KIcon>
|
||||
#include <KPixmapWidget>
|
||||
|
||||
class DefaultBoxWidget : public QGroupBox
|
||||
{
|
||||
|
@ -48,7 +49,7 @@ class DefaultBoxWidget : public QGroupBox
|
|||
void createDisplay();
|
||||
|
||||
QGridLayout *m_layout;
|
||||
QLabel *m_iconLabel;
|
||||
KPixmapWidget *m_iconWidget;
|
||||
|
||||
QLabel *m_info0Label;
|
||||
QLabel *m_info0NameLabel;
|
||||
|
|
|
@ -38,9 +38,9 @@ ProgressBoxWidget::ProgressBoxWidget()
|
|||
|
||||
void ProgressBoxWidget::createDisplay()
|
||||
{
|
||||
m_iconLabel = new QLabel();
|
||||
m_iconLabel->setAlignment(Qt::AlignCenter);
|
||||
m_iconLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
m_iconWidget = new KPixmapWidget();
|
||||
m_iconWidget->setAlignment(Qt::AlignCenter);
|
||||
m_iconWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
|
||||
|
||||
QFont bFont;
|
||||
bFont.setBold(true);
|
||||
|
@ -56,7 +56,7 @@ void ProgressBoxWidget::createDisplay()
|
|||
m_info1Label->setFont(bFont);
|
||||
m_progressBar = new QProgressBar();
|
||||
|
||||
m_layout->addWidget(m_iconLabel,1,1,2,1,Qt::AlignCenter);
|
||||
m_layout->addWidget(m_iconWidget,1,1,2,1,Qt::AlignCenter);
|
||||
|
||||
m_layout->addWidget(m_info0Label,1,2,1,1);
|
||||
m_layout->addWidget(m_info0NameLabel,1,3,1,1);
|
||||
|
@ -73,7 +73,7 @@ void ProgressBoxWidget::setLabelTitles(const QString &first, const QString &seco
|
|||
|
||||
void ProgressBoxWidget::setIcon(const KIcon &icon)
|
||||
{
|
||||
m_iconLabel->setPixmap(icon.pixmap(64));
|
||||
m_iconWidget->setPixmap(icon.pixmap(64));
|
||||
}
|
||||
|
||||
void ProgressBoxWidget::setLabelOne(const QString &info)
|
||||
|
|
|
@ -23,14 +23,15 @@
|
|||
#ifndef PROGRESSBOXWIDGET
|
||||
#define PROGRESSBOXWIDGET
|
||||
|
||||
//QT
|
||||
// Katie
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
|
||||
//KDE
|
||||
// KDE
|
||||
#include <KIcon>
|
||||
#include <KPixmapWidget>
|
||||
|
||||
class ProgressBoxWidget : public QFrame
|
||||
{
|
||||
|
@ -49,7 +50,7 @@ class ProgressBoxWidget : public QFrame
|
|||
void createDisplay();
|
||||
|
||||
QGridLayout *m_layout;
|
||||
QLabel *m_iconLabel;
|
||||
KPixmapWidget *m_iconWidget;
|
||||
|
||||
QLabel *m_info0Label;
|
||||
QLabel *m_info0NameLabel;
|
||||
|
|
|
@ -18,10 +18,8 @@
|
|||
*******************************************************************************/
|
||||
|
||||
#include "tooltipmanager.h"
|
||||
|
||||
#include "kcmtreeitem.h"
|
||||
#include "sidepanel.h"
|
||||
|
||||
#include "ktooltip.h"
|
||||
|
||||
#include <QRect>
|
||||
|
@ -41,6 +39,7 @@
|
|||
|
||||
#include <KIcon>
|
||||
#include <KColorScheme>
|
||||
#include <KPixmapWidget>
|
||||
|
||||
class ToolTipManager::Private
|
||||
{
|
||||
|
@ -219,13 +218,13 @@ QLayout * ToolTipManager::generateToolTipLine( const QModelIndex & item, QWidget
|
|||
|
||||
// Get icon
|
||||
KIcon icon( menuItem->icon() );
|
||||
QLabel * iconLabel = new QLabel( toolTip );
|
||||
iconLabel->setPixmap( icon.pixmap(iconSize) );
|
||||
iconLabel->setMaximumSize( iconSize );
|
||||
KPixmapWidget * iconWidget = new KPixmapWidget( toolTip );
|
||||
iconWidget->setPixmap( icon.pixmap(iconSize) );
|
||||
iconWidget->setMaximumSize( iconSize );
|
||||
|
||||
// Generate layout
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
layout->addWidget( iconLabel );
|
||||
layout->addWidget( iconWidget );
|
||||
layout->addWidget( textLabel );
|
||||
|
||||
return layout;
|
||||
|
|
|
@ -19,17 +19,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*********************************************************************/
|
||||
#include "main.h"
|
||||
|
||||
// Qt
|
||||
#include <QtDBus/QtDBus>
|
||||
// Katie
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusConnection>
|
||||
#include <QDesktopWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QDebug>
|
||||
|
||||
// KDE
|
||||
#include <KAction>
|
||||
#include <KActionCollection>
|
||||
#include <KCModuleProxy>
|
||||
//#include <KLocalizedString>
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginInfo>
|
||||
#include <KPluginLoader>
|
||||
|
|
|
@ -40,7 +40,7 @@ QIconItem::~QIconItem()
|
|||
|
||||
void QIconItem::setIcon(const QVariant &icon)
|
||||
{
|
||||
if(icon.canConvert<QIcon>()) {
|
||||
if (icon.canConvert<QIcon>()) {
|
||||
m_icon = icon.value<QIcon>();
|
||||
} else if(icon.canConvert<QString>()) {
|
||||
m_icon = KIcon(icon.toString());
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
*******************************************************************************/
|
||||
|
||||
#include "tooltipmanager.h"
|
||||
|
||||
#include "MenuItem.h"
|
||||
|
||||
#include "ktooltip.h"
|
||||
|
||||
#include <QRect>
|
||||
|
@ -41,6 +39,7 @@
|
|||
#include <KIcon>
|
||||
#include <KIconLoader>
|
||||
#include <KColorScheme>
|
||||
#include <KPixmapWidget>
|
||||
|
||||
class ToolTipManager::Private
|
||||
{
|
||||
|
@ -234,13 +233,13 @@ QLayout * ToolTipManager::generateToolTipLine( QModelIndex * item, QWidget * too
|
|||
|
||||
// Get icon
|
||||
KIcon icon( menuItem->service()->icon() );
|
||||
QLabel * iconLabel = new QLabel( toolTip );
|
||||
iconLabel->setPixmap( icon.pixmap(iconSize) );
|
||||
iconLabel->setMaximumSize( iconSize );
|
||||
KPixmapWidget * iconWidget = new KPixmapWidget( toolTip );
|
||||
iconWidget->setPixmap( icon.pixmap(iconSize) );
|
||||
iconWidget->setMaximumSize( iconSize );
|
||||
|
||||
// Generate layout
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
layout->addWidget( iconLabel );
|
||||
layout->addWidget( iconWidget );
|
||||
layout->addWidget( textLabel );
|
||||
|
||||
return layout;
|
||||
|
|
Loading…
Add table
Reference in a new issue