generic: replace QLabel with the new KPixmapWidget class

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-30 16:42:48 +03:00
parent 8f5db4efad
commit bef4cece61
16 changed files with 107 additions and 234 deletions

View file

@ -55,12 +55,14 @@ Module::Module(QWidget *parent, const QVariantList &args) :
KCModule(KcmAboutDistroFactory::componentData(), parent, args),
ui(new Ui_Module)
{
KAboutData *about = new KAboutData("kcm-about-distro", 0,
ki18n("About Distribution"),
"1.2.0",
KLocalizedString(),
KAboutData::License_GPL_V3,
ki18n("Copyright 2012-2014 Harald Sitter\nCopyright 2021 Ivailo Monev"));
KAboutData *about = new KAboutData(
"kcm-about-distro", 0,
ki18n("About Distribution"),
"1.2.0",
KLocalizedString(),
KAboutData::License_GPL_V3,
ki18n("Copyright 2012-2014 Harald Sitter\nCopyright 2021 Ivailo Monev")
);
about->addAuthor(ki18n("Harald Sitter"), ki18n("Author"), "apachelogger@ubuntu.com");
about->addAuthor(ki18n("Ivailo Monev"), ki18n("Current maintainer"), "xakepa10@gmail.com");
@ -89,7 +91,7 @@ void Module::load()
OSRelease os;
QPixmap logoPixmap = KIcon(os.logo).pixmap(128, 128);
ui->logoLabel->setPixmap(logoPixmap);
ui->logoWidget->setPixmap(logoPixmap);
ui->nameVersionLabel->setText(os.prettyName);

View file

@ -289,9 +289,24 @@
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="logoLabel">
<property name="text">
<string notr="true">{LogoLabel}</string>
<widget class="KPixmapWidget" name="logoWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
</widget>
</item>
@ -316,5 +331,12 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KPixmapWidget</class>
<extends>QWidget</extends>
<header>kpixmapwidget.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -34,6 +34,7 @@
#include <KPushButton>
#include <KRun>
#include <KIO/NetAccess>
#include <KPixmapWidget>
#include <QHBoxLayout>
#include <QFile>
@ -193,10 +194,10 @@ bool ArkViewer::viewInInternalViewer(const QString& fileName, const KMimeType::P
QFrame *header = new QFrame(m_widget);
QHBoxLayout *headerLayout = new QHBoxLayout(header);
QLabel *iconLabel = new QLabel(header);
headerLayout->addWidget(iconLabel);
iconLabel->setPixmap(KIconLoader::global()->loadMimeTypeIcon(mimeType->iconName(), KIconLoader::Desktop));
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
KPixmapWidget *iconWidget = new KPixmapWidget(header);
headerLayout->addWidget(iconWidget);
iconWidget->setPixmap(KIconLoader::global()->loadMimeTypeIcon(mimeType->iconName(), KIconLoader::Desktop));
iconWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
KVBox *headerRight = new KVBox(header);
headerLayout->addWidget(headerRight);

View file

@ -60,7 +60,7 @@ InfoPanel::~InfoPanel()
void InfoPanel::updateWithDefaults()
{
iconLabel->setPixmap(KIconLoader::global()->loadIcon(QLatin1String( "utilities-file-archiver" ), KIconLoader::Desktop, KIconLoader::SizeHuge));
iconWidget->setPixmap(KIconLoader::global()->loadIcon(QLatin1String( "utilities-file-archiver" ), KIconLoader::Desktop, KIconLoader::SizeHuge));
const QString currentFileName = prettyFileName();
@ -107,7 +107,7 @@ void InfoPanel::setIndex(const QModelIndex& index)
mimeType = KMimeType::findByPath(entry[ FileName ].toString(), 0, true);
}
iconLabel->setPixmap(getMimeIcon(mimeType->iconName()));
iconWidget->setPixmap(getMimeIcon(mimeType->iconName()));
if (entry[ IsDirectory ].toBool()) {
int dirs;
int files;
@ -140,7 +140,7 @@ void InfoPanel::setIndexes(const QModelIndexList &list)
} else if (list.size() == 1) {
setIndex(list[ 0 ]);
} else {
iconLabel->setPixmap(KIconLoader::global()->loadIcon(QLatin1String( "utilities-file-archiver" ), KIconLoader::Desktop, KIconLoader::SizeHuge));
iconWidget->setPixmap(KIconLoader::global()->loadIcon(QLatin1String( "utilities-file-archiver" ), KIconLoader::Desktop, KIconLoader::SizeHuge));
fileName->setText(i18np("One file selected", "%1 files selected", list.size()));
quint64 totalSize = 0;
foreach(const QModelIndex& index, list) {

View file

@ -21,10 +21,7 @@
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="iconLabel" >
<property name="text" >
<string/>
</property>
<widget class="KPixmapWidget" name="iconWidget" >
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
@ -120,6 +117,11 @@
<extends>QLabel</extends>
<header>ksqueezedtextlabel.h</header>
</customwidget>
<customwidget>
<class>KPixmapWidget</class>
<extends>QWidget</extends>
<header>kpixmapwidget.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Self
#include "moc_savebar.cpp"
// Qt
// Katie
#include <QHBoxLayout>
#include <QLabel>
#include <QToolButton>
@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <KIconLoader>
#include <KLocale>
#include <KUrl>
#include <KPixmapWidget>
// Local
#include "lib/document/documentfactory.h"
@ -73,13 +74,13 @@ struct SaveBarPrivate
void createTooManyChangesFrame()
{
mTooManyChangesFrame = new QFrame;
mTooManyChangesFrame = new QFrame();
// Icon
QLabel* iconLabel = new QLabel;
KPixmapWidget* iconWidget = new KPixmapWidget();
QPixmap pix = KIconLoader::global()->loadIcon(
"dialog-warning", KIconLoader::Dialog, KIconLoader::SizeSmall);
iconLabel->setPixmap(pix);
iconWidget->setPixmap(pix);
// Text label
QLabel* textLabel = new QLabel;
@ -92,7 +93,7 @@ struct SaveBarPrivate
// Layout
QHBoxLayout* layout = new QHBoxLayout(mTooManyChangesFrame);
layout->setMargin(0);
layout->addWidget(iconLabel);
layout->addWidget(iconWidget);
layout->addWidget(textLabel);
layout->addWidget(mSaveAllFullScreenButton);
mTooManyChangesFrame->hide();
@ -237,7 +238,7 @@ SaveBar::SaveBar(QWidget* parent, KActionCollection* actionCollection)
d->mSaveBarWidget->setObjectName(QLatin1String("saveBarWidget"));
d->applyNormalStyleSheet();
d->mMessageLabel = new QLabel;
d->mMessageLabel = new QLabel();
d->mMessageLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
d->mUndoButton = createToolButton();
@ -246,14 +247,14 @@ SaveBar::SaveBar(QWidget* parent, KActionCollection* actionCollection)
d->mSaveAsButton = createToolButton();
d->mSaveAllButton = createToolButton();
d->mActionsLabel = new QLabel;
d->mActionsLabel = new QLabel();
d->mActionsLabel->setAlignment(Qt::AlignCenter);
d->mActionsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
d->createTooManyChangesFrame();
// Setup top row
d->mTopRowWidget = new QWidget;
d->mTopRowWidget = new QWidget();
QHBoxLayout* rowLayout = new QHBoxLayout(d->mTopRowWidget);
rowLayout->addWidget(d->mMessageLabel);
rowLayout->addWidget(d->mUndoButton);
@ -265,7 +266,7 @@ SaveBar::SaveBar(QWidget* parent, KActionCollection* actionCollection)
rowLayout->setMargin(0);
// Setup bottom row
QHBoxLayout* bottomRowLayout = new QHBoxLayout;
QHBoxLayout* bottomRowLayout = new QHBoxLayout();
bottomRowLayout->addStretch();
bottomRowLayout->addWidget(d->mTooManyChangesFrame);
bottomRowLayout->addStretch();

View file

@ -26,26 +26,25 @@
#include <QBitmap>
#include <QGridLayout>
#include <QLabel>
#include <QtGui/qevent.h>
#include <QPaintEvent>
#include <QPainter>
#include <QPalette>
#include <QTextDocument>
#include <QPropertyAnimation>
#include <QtGui/qtextobject.h>
#include <QToolButton>
#ifdef Q_WS_X11
#include <QX11Info>
#include <netwm.h>
#endif
#include <kdebug.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <kwindowsystem.h>
#include <KDebug>
#include <KGlobal>
#include <KGlobalSettings>
#include <KWindowSystem>
#include <KIcon>
#include <KIconLoader>
#include <KIconEffect>
#include <KPixmapWidget>
#include <plasma/plasma.h>
#include <plasma/paintutils.h>
#include <plasma/theme.h>
@ -213,7 +212,7 @@ class ToolTipPrivate
public:
ToolTipPrivate()
: text(0),
imageLabel(0),
imageWidget(0),
preview(0),
direction(Plasma::Up),
autohide(true),
@ -221,7 +220,7 @@ public:
{ }
TipTextWidget *text;
QLabel *imageLabel;
KPixmapWidget *imageWidget;
WindowPreview *preview;
FrameSvg *background;
QWeakPointer<QObject> source;
@ -246,8 +245,8 @@ ToolTip::ToolTip(QWidget *parent)
setWindowFlags(Qt::ToolTip);
d->preview = new WindowPreview(this);
d->text = new TipTextWidget(this);
d->imageLabel = new QLabel(this);
d->imageLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
d->imageWidget = new KPixmapWidget(this);
d->imageWidget->setAlignment(Qt::AlignTop | Qt::AlignLeft);
d->animation = new QPropertyAnimation(this, "pos", this);
d->animation->setEasingCurve(QEasingCurve::InOutQuad);
@ -266,8 +265,8 @@ ToolTip::ToolTip(QWidget *parent)
previewHBoxLayout->addWidget(d->preview);
QHBoxLayout *iconTextHBoxLayout = new QHBoxLayout;
iconTextHBoxLayout->addWidget(d->imageLabel);
iconTextHBoxLayout->setAlignment(d->imageLabel, Qt::AlignCenter);
iconTextHBoxLayout->addWidget(d->imageWidget);
iconTextHBoxLayout->setAlignment(d->imageWidget, Qt::AlignCenter);
iconTextHBoxLayout->addWidget(d->text);
iconTextHBoxLayout->setAlignment(d->text, Qt::AlignLeft | Qt::AlignVCenter);
iconTextHBoxLayout->setStretchFactor(d->text, 1);
@ -394,12 +393,12 @@ void ToolTip::setContent(QObject *tipper, const ToolTipContent &data)
if (data.windowsToPreview().size()) {
d->text->setVisible(false);
d->imageLabel->setVisible(false);
d->imageWidget->setVisible(false);
} else {
d->text->setVisible(true);
d->imageLabel->setVisible(true);
d->imageWidget->setVisible(true);
d->text->setContent(data);
d->imageLabel->setPixmap(data.image());
d->imageWidget->setPixmap(data.image());
}
if (!data.playState().isEmpty()) {

View file

@ -52,6 +52,7 @@
#include <KToggleAction>
#include <KToggleFullScreenAction>
#include <KServiceTypeTrader>
#include <KPixmapWidget>
#include <QClipboard>
#include <QDockWidget>
@ -1036,12 +1037,12 @@ QWidget* MainWindow::newConnectionWidget()
QLabel *headerLabel = new QLabel(m_newConnectionWidget);
headerLabel->setText(i18n("<h1>KDE Remote Desktop Client</h1><br />Enter or select the address of the desktop you would like to connect to."));
QLabel *headerIconLabel = new QLabel(m_newConnectionWidget);
headerIconLabel->setPixmap(KIcon("krdc").pixmap(80));
KPixmapWidget *headerIconWidget = new KPixmapWidget(m_newConnectionWidget);
headerIconWidget->setPixmap(KIcon("krdc").pixmap(80));
QHBoxLayout *headerLayout = new QHBoxLayout;
headerLayout->addWidget(headerLabel, 1, Qt::AlignTop);
headerLayout->addWidget(headerIconLabel);
headerLayout->addWidget(headerIconWidget);
startLayout->addLayout(headerLayout);
QSortFilterProxyModel *remoteDesktopsModelProxy = new QSortFilterProxyModel(this);

View file

@ -42,7 +42,7 @@ ConnectionDialog<UI>::ConnectionDialog(QWidget *parent)
m_connectWidget = new QWidget(this);
m_ui.setupUi(m_connectWidget);
m_ui.pixmapLabel->setPixmap(KIcon("krfb").pixmap(128));
m_ui.pixmapWidget->setPixmap(KIcon("krfb").pixmap(128));
KGuiItem accept = KStandardGuiItem::ok();
accept.setText(i18n("Accept Connection"));

View file

@ -11,7 +11,7 @@
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="pixmapLabel" >
<widget class="KPixmapWidget" name="pixmapWidget" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
@ -144,5 +144,12 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KPixmapWidget</class>
<extends>QWidget</extends>
<header>kpixmapwidget.h</header>
</customwidget>
</customwidgets>
<connections/>
</ui>

View file

@ -1,170 +0,0 @@
<ui version="4.0" >
<class>InviteWidget</class>
<widget class="QWidget" name="InviteWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>603</width>
<height>364</height>
</rect>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="pixmapLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>128</width>
<height>128</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="TextLabel2" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Welcome to KDE Desktop Sharing</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="helpLabel" >
<property name="text" >
<string>KDE Desktop Sharing allows you to invite somebody at a remote location to watch and possibly control your desktop. &lt;a href="whatsthis">More about invitations...&lt;/a></string>
</property>
<property name="textFormat" >
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
<property name="textInteractionFlags" >
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::NoTextInteraction</set>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>215</width>
<height>101</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>90</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QPushButton" name="btnCreateInvite" >
<property name="toolTip" >
<string/>
</property>
<property name="whatsThis" >
<string>Create a new invitation and display the connection data. Use this option if you want to invite somebody personally, for example, to give the connection data over the phone.</string>
</property>
<property name="text" >
<string>Create &amp;Personal Invitation...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnEmailInvite" >
<property name="whatsThis" >
<string>This button will start your email application with a pre-configured text that explains to the recipient how to connect to your computer. </string>
</property>
<property name="text" >
<string>Invite via &amp;Email...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnManageInvite" >
<property name="text" >
<string>&amp;Manage Invitations (%1)...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>90</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<connections/>
</ui>

View file

@ -30,7 +30,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="krfbIconLabel">
<widget class="KPixmapWidget" name="krfbIconWidget">
<property name="minimumSize">
<size>
<width>128</width>
@ -43,9 +43,6 @@
<height>128</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
@ -491,6 +488,11 @@
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
<customwidget>
<class>KPixmapWidget</class>
<extends>QWidget</extends>
<header>kpixmapwidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>enableSharingCheckBox</tabstop>

View file

@ -58,7 +58,7 @@ MainWindow::MainWindow(QWidget *parent)
QWidget *mainWidget = new QWidget;
m_ui.setupUi(mainWidget);
m_ui.krfbIconLabel->setPixmap(KIcon("krfb").pixmap(128));
m_ui.krfbIconWidget->setPixmap(KIcon("krfb").pixmap(128));
m_ui.enableUnattendedCheckBox->setChecked(
InvitationsRfbServer::instance->allowUnattendedAccess());

View file

@ -25,8 +25,8 @@ DlgPerformance::DlgPerformance( QWidget * parent )
labelFont.setBold( true );
m_dlg->descLabel->setFont( labelFont );
m_dlg->cpuLabel->setPixmap( BarIcon( "cpu", 32 ) );
// m_dlg->memoryLabel->setPixmap( BarIcon( "kcmmemory", 32 ) ); // TODO: enable again when proper icon is available
m_dlg->cpuWidget->setPixmap( BarIcon( "cpu", 32 ) );
// m_dlg->memoryWidget->setPixmap( BarIcon( "memory", 32 ) ); // TODO: enable again when proper icon is available
connect( m_dlg->kcfg_MemoryLevel, SIGNAL(changed(int)), this, SLOT(radioGroup_changed(int)) );
}

View file

@ -63,7 +63,7 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="cpuLabel">
<widget class="KPixmapWidget" name="cpuWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -162,7 +162,7 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="memoryLabel">
<widget class="KPixmapWidget" name="memoryWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -265,6 +265,11 @@
<header>kbuttongroup.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KPixmapWidget</class>
<extends>QWidget</extends>
<header>kpixmapwidget.h</header>
</customwidget>
</customwidgets>
<includes>
<include location="global">kiconloader.h</include>

View file

@ -9,7 +9,7 @@
#include "propertiesdialog.h"
// qt/kde includes
// Katie/KDE includes
#include <qfile.h>
#include <qlayout.h>
#include <qformlayout.h>
@ -30,6 +30,7 @@
#include <kmessagebox.h>
#include <ksqueezedtextlabel.h>
#include <kurl.h>
#include <kpixmapwidget.h>
// local includes
#include "core/document.h"
@ -118,9 +119,9 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
KSqueezedTextLabel *squeezed;
if (!mimeType.isNull()) {
/// retrieve icon and place it in a QLabel
QLabel *pixmapLabel = new QLabel( value );
hboxLayout->addWidget( pixmapLabel, 0 );
pixmapLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), KIconLoader::Small ) );
KPixmapWidget *pixmapWidget = new KPixmapWidget( value );
hboxLayout->addWidget( pixmapWidget, 0 );
pixmapWidget->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), KIconLoader::Small ) );
/// mime type's name and label
squeezed = new KSqueezedTextLabel( i18nc( "mimetype information, example: \"PDF Document (application/pdf)\"", "%1 (%2)", mimeType->comment(), valueString ), value );
} else {