mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kdeui: new KPixmapWidget
the idea for QImage/QPixmap-optimized widget occurred to me while writing kimageviewer (see the kde-playground repo), unlike the widget I wrote for kimageviewer this one supports drag-n-drop tho and is drop-in replacement for QLabel when showing only a pixmap is required. the widget also shows a small image while dragging ala ksnapshot Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7cb0785160
commit
88598523d0
15 changed files with 462 additions and 169 deletions
|
@ -202,6 +202,7 @@ install(
|
||||||
KPasswordDialog
|
KPasswordDialog
|
||||||
KPasteTextAction
|
KPasteTextAction
|
||||||
KPixmap
|
KPixmap
|
||||||
|
KPixmapWidget
|
||||||
KPluginFactory
|
KPluginFactory
|
||||||
KPluginInfo
|
KPluginInfo
|
||||||
KPluginLoader
|
KPluginLoader
|
||||||
|
|
1
includes/KPixmapWidget
Normal file
1
includes/KPixmapWidget
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "../kpixmapwidget.h"
|
|
@ -217,6 +217,7 @@ set(kdeui_LIB_SRCS
|
||||||
widgets/kmessagewidget.cpp
|
widgets/kmessagewidget.cpp
|
||||||
widgets/kmultitabbar.cpp
|
widgets/kmultitabbar.cpp
|
||||||
widgets/knuminput.cpp
|
widgets/knuminput.cpp
|
||||||
|
widgets/kpixmapwidget.cpp
|
||||||
widgets/kpushbutton.cpp
|
widgets/kpushbutton.cpp
|
||||||
widgets/kratingpainter.cpp
|
widgets/kratingpainter.cpp
|
||||||
widgets/kratingwidget.cpp
|
widgets/kratingwidget.cpp
|
||||||
|
@ -514,6 +515,7 @@ install(
|
||||||
widgets/kmessagewidget.h
|
widgets/kmessagewidget.h
|
||||||
widgets/kmultitabbar.h
|
widgets/kmultitabbar.h
|
||||||
widgets/knuminput.h
|
widgets/knuminput.h
|
||||||
|
widgets/kpixmapwidget.h
|
||||||
widgets/kpushbutton.h
|
widgets/kpushbutton.h
|
||||||
widgets/kratingpainter.h
|
widgets/kratingpainter.h
|
||||||
widgets/kratingwidget.h
|
widgets/kratingwidget.h
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "ktextedit.h"
|
#include "ktextedit.h"
|
||||||
#include "ksqueezedtextlabel.h"
|
#include "ksqueezedtextlabel.h"
|
||||||
#include "kwindowsystem.h"
|
#include "kwindowsystem.h"
|
||||||
|
#include "kpixmapwidget.h"
|
||||||
|
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
@ -176,17 +177,17 @@ int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon,
|
||||||
hLayout->setSpacing(-1); // use default spacing
|
hLayout->setSpacing(-1); // use default spacing
|
||||||
mainLayout->addLayout(hLayout,5);
|
mainLayout->addLayout(hLayout,5);
|
||||||
|
|
||||||
QLabel *iconLabel = new QLabel(mainWidget);
|
KPixmapWidget *iconWidget = new KPixmapWidget(mainWidget);
|
||||||
|
|
||||||
if (!icon.isNull()) {
|
if (!icon.isNull()) {
|
||||||
QStyleOption option;
|
QStyleOption option;
|
||||||
option.initFrom(mainWidget);
|
option.initFrom(mainWidget);
|
||||||
iconLabel->setPixmap(icon.pixmap(mainWidget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, mainWidget)));
|
iconWidget->setPixmap(icon.pixmap(mainWidget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, mainWidget)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVBoxLayout *iconLayout = new QVBoxLayout();
|
QVBoxLayout *iconLayout = new QVBoxLayout();
|
||||||
iconLayout->addStretch(1);
|
iconLayout->addStretch(1);
|
||||||
iconLayout->addWidget(iconLabel);
|
iconLayout->addWidget(iconWidget);
|
||||||
iconLayout->addStretch(5);
|
iconLayout->addStretch(5);
|
||||||
|
|
||||||
hLayout->addLayout(iconLayout,0);
|
hLayout->addLayout(iconLayout,0);
|
||||||
|
@ -301,12 +302,12 @@ int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon,
|
||||||
dialog->setMainWidget(mainWidget);
|
dialog->setMainWidget(mainWidget);
|
||||||
if (!usingListWidget && !usingScrollArea && !usingSqueezedTextLabel && details.isEmpty())
|
if (!usingListWidget && !usingScrollArea && !usingSqueezedTextLabel && details.isEmpty())
|
||||||
dialog->setFixedSize(dialog->sizeHint() + QSize( 10, 10 ));
|
dialog->setFixedSize(dialog->sizeHint() + QSize( 10, 10 ));
|
||||||
else if (!details.isEmpty() && dialog->minimumHeight()<iconLabel->sizeHint().height()*2)//strange bug...
|
else if (!details.isEmpty() && dialog->minimumHeight()<iconWidget->sizeHint().height()*2)//strange bug...
|
||||||
{
|
{
|
||||||
if (!usingScrollArea)
|
if (!usingScrollArea)
|
||||||
dialog->setMinimumSize(300,qMax(150,qMax(iconLabel->sizeHint().height(),messageLabel->sizeHint().height())));
|
dialog->setMinimumSize(300,qMax(150,qMax(iconWidget->sizeHint().height(),messageLabel->sizeHint().height())));
|
||||||
else
|
else
|
||||||
dialog->setMinimumSize(300,qMax(150,iconLabel->sizeHint().height()));
|
dialog->setMinimumSize(300,qMax(150,iconWidget->sizeHint().height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,31 +22,31 @@
|
||||||
// I (espen) prefer that header files are included alphabetically
|
// I (espen) prefer that header files are included alphabetically
|
||||||
|
|
||||||
#include "khelpmenu.h"
|
#include "khelpmenu.h"
|
||||||
|
#include "kaboutapplicationdialog.h"
|
||||||
|
#include "kaboutdata.h"
|
||||||
|
#include "kaboutkdedialog_p.h"
|
||||||
|
#include "kaction.h"
|
||||||
|
#include "kactioncollection.h"
|
||||||
|
#include "kapplication.h"
|
||||||
|
#include "kdialog.h"
|
||||||
|
#include "kguiitem.h"
|
||||||
|
#include "khbox.h"
|
||||||
|
#include "kiconloader.h"
|
||||||
|
#include "klocale.h"
|
||||||
|
#include "kmenu.h"
|
||||||
|
#include "kstandardshortcut.h"
|
||||||
|
#include "kstandardaction.h"
|
||||||
|
#include "kstandardguiitem.h"
|
||||||
|
#include "kswitchlanguagedialog_p.h"
|
||||||
|
#include "ktoolinvocation.h"
|
||||||
|
#include "kstandarddirs.h"
|
||||||
|
#include "kpixmapwidget.h"
|
||||||
|
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QWhatsThis>
|
#include <QtGui/QWhatsThis>
|
||||||
|
|
||||||
#include <kaboutapplicationdialog.h>
|
|
||||||
#include <kaboutdata.h>
|
|
||||||
#include <kaboutkdedialog_p.h>
|
|
||||||
#include <kaction.h>
|
|
||||||
#include <kactioncollection.h>
|
|
||||||
#include <kapplication.h>
|
|
||||||
#include <kdialog.h>
|
|
||||||
#include <kguiitem.h>
|
|
||||||
#include <khbox.h>
|
|
||||||
#include <kiconloader.h>
|
|
||||||
#include <klocale.h>
|
|
||||||
#include <kmenu.h>
|
|
||||||
#include <kstandardshortcut.h>
|
|
||||||
#include <kstandardaction.h>
|
|
||||||
#include <kstandardguiitem.h>
|
|
||||||
#include <kswitchlanguagedialog_p.h>
|
|
||||||
#include <ktoolinvocation.h>
|
|
||||||
#include <kstandarddirs.h>
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include <QtGui/qx11embed_x11.h>
|
#include <QtGui/qx11embed_x11.h>
|
||||||
|
@ -271,10 +271,10 @@ void KHelpMenu::aboutApplication()
|
||||||
hbox->setSpacing(KDialog::spacingHint() * 3);
|
hbox->setSpacing(KDialog::spacingHint() * 3);
|
||||||
hbox->setMargin(KDialog::marginHint() * 1);
|
hbox->setMargin(KDialog::marginHint() * 1);
|
||||||
|
|
||||||
QLabel *label1 = new QLabel(hbox);
|
KPixmapWidget *pixmap1 = new KPixmapWidget(hbox);
|
||||||
|
|
||||||
int size = IconSize(KIconLoader::Dialog);
|
int size = IconSize(KIconLoader::Dialog);
|
||||||
label1->setPixmap(qApp->windowIcon().pixmap(size,size));
|
pixmap1->setPixmap(qApp->windowIcon().pixmap(size,size));
|
||||||
QLabel *label2 = new QLabel(hbox);
|
QLabel *label2 = new QLabel(hbox);
|
||||||
label2->setText(d->mAboutAppText);
|
label2->setText(d->mAboutAppText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
* 02110-1301 USA
|
* 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
#include "kmessagewidget.h"
|
#include "kmessagewidget.h"
|
||||||
|
#include "kaction.h"
|
||||||
#include <kaction.h>
|
#include "kcolorscheme.h"
|
||||||
#include <kcolorscheme.h>
|
#include "kicon.h"
|
||||||
#include <kdebug.h>
|
#include "kiconloader.h"
|
||||||
#include <kicon.h>
|
#include "kstandardaction.h"
|
||||||
#include <kiconloader.h>
|
#include "kpixmapwidget.h"
|
||||||
#include <kstandardaction.h>
|
#include "kdebug.h"
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
@ -42,7 +42,7 @@ public:
|
||||||
void init(KMessageWidget *q_ptr);
|
void init(KMessageWidget *q_ptr);
|
||||||
|
|
||||||
KMessageWidget* q;
|
KMessageWidget* q;
|
||||||
QLabel* iconLabel;
|
KPixmapWidget* iconWidget;
|
||||||
QLabel* textLabel;
|
QLabel* textLabel;
|
||||||
QToolButton* closeButton;
|
QToolButton* closeButton;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
@ -58,9 +58,9 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
|
||||||
|
|
||||||
q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||||
|
|
||||||
iconLabel = new QLabel(q);
|
iconWidget = new KPixmapWidget(q);
|
||||||
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
iconWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
iconLabel->hide();
|
iconWidget->hide();
|
||||||
|
|
||||||
textLabel = new QLabel(q);
|
textLabel = new QLabel(q);
|
||||||
textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
|
@ -104,7 +104,7 @@ void KMessageWidgetPrivate::updateLayout()
|
||||||
if (textLabel->wordWrap()) {
|
if (textLabel->wordWrap()) {
|
||||||
QGridLayout* layout = new QGridLayout(q);
|
QGridLayout* layout = new QGridLayout(q);
|
||||||
// Set alignment to make sure icon does not move down if text wraps
|
// Set alignment to make sure icon does not move down if text wraps
|
||||||
layout->addWidget(iconLabel, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
|
layout->addWidget(iconWidget, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
|
||||||
layout->addWidget(textLabel, 0, 1);
|
layout->addWidget(textLabel, 0, 1);
|
||||||
|
|
||||||
QHBoxLayout* buttonLayout = new QHBoxLayout();
|
QHBoxLayout* buttonLayout = new QHBoxLayout();
|
||||||
|
@ -121,7 +121,7 @@ void KMessageWidgetPrivate::updateLayout()
|
||||||
layout->addItem(buttonLayout, 1, 0, 1, 2);
|
layout->addItem(buttonLayout, 1, 0, 1, 2);
|
||||||
} else {
|
} else {
|
||||||
QHBoxLayout* layout = new QHBoxLayout(q);
|
QHBoxLayout* layout = new QHBoxLayout(q);
|
||||||
layout->addWidget(iconLabel);
|
layout->addWidget(iconWidget);
|
||||||
layout->addWidget(textLabel);
|
layout->addWidget(textLabel);
|
||||||
|
|
||||||
Q_FOREACH(QToolButton* button, buttons) {
|
Q_FOREACH(QToolButton* button, buttons) {
|
||||||
|
@ -316,11 +316,11 @@ void KMessageWidget::setIcon(const QIcon& icon)
|
||||||
{
|
{
|
||||||
d->icon = icon;
|
d->icon = icon;
|
||||||
if (d->icon.isNull()) {
|
if (d->icon.isNull()) {
|
||||||
d->iconLabel->hide();
|
d->iconWidget->hide();
|
||||||
} else {
|
} else {
|
||||||
const int size = KIconLoader::global()->currentSize(KIconLoader::MainToolbar);
|
const int size = KIconLoader::global()->currentSize(KIconLoader::MainToolbar);
|
||||||
d->iconLabel->setPixmap(d->icon.pixmap(size));
|
d->iconWidget->setPixmap(d->icon.pixmap(size));
|
||||||
d->iconLabel->show();
|
d->iconWidget->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
209
kdeui/widgets/kpixmapwidget.cpp
Normal file
209
kdeui/widgets/kpixmapwidget.cpp
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
/* This file is part of the KDE libraries
|
||||||
|
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License version 2, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kpixmapwidget.h"
|
||||||
|
#include "kmimetype.h"
|
||||||
|
#include "kimageio.h"
|
||||||
|
#include "kglobalsettings.h"
|
||||||
|
#include "kdebug.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QStyleOption>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
static bool kCheckMimeData(const QMimeData *mimedata)
|
||||||
|
{
|
||||||
|
if (!mimedata) {
|
||||||
|
return false;
|
||||||
|
} else if (mimedata->hasImage()) {
|
||||||
|
return true;
|
||||||
|
} else if (mimedata->hasUrls()) {
|
||||||
|
const QList<QUrl> mimedataurls = mimedata->urls();
|
||||||
|
foreach (const QUrl &mimedataurl, mimedataurls) {
|
||||||
|
const KMimeType::Ptr mimetype = KMimeType::findByPath(mimedataurl.toLocalFile());
|
||||||
|
if (mimetype && KImageIO::isSupported(mimetype->name())) {
|
||||||
|
// atleast one supported image
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
class KPixmapWidgetPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KPixmapWidgetPrivate();
|
||||||
|
|
||||||
|
QPixmap pixmap;
|
||||||
|
Qt::Alignment alignment;
|
||||||
|
bool dragenabled;
|
||||||
|
QPoint dragstartpos;
|
||||||
|
};
|
||||||
|
|
||||||
|
KPixmapWidgetPrivate::KPixmapWidgetPrivate()
|
||||||
|
: alignment(Qt::AlignHCenter | Qt::AlignVCenter),
|
||||||
|
dragenabled(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KPixmapWidget::KPixmapWidget(QWidget *parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
d(new KPixmapWidgetPrivate())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KPixmapWidget::~KPixmapWidget()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::setPixmap(const QPixmap &pixmap)
|
||||||
|
{
|
||||||
|
d->pixmap = pixmap;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap KPixmapWidget::pixmap() const
|
||||||
|
{
|
||||||
|
return d->pixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::setAlignment(Qt::Alignment alignment)
|
||||||
|
{
|
||||||
|
d->alignment = alignment;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Alignment KPixmapWidget::alignment() const
|
||||||
|
{
|
||||||
|
return d->alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KPixmapWidget::dragEnabled() const
|
||||||
|
{
|
||||||
|
return d->dragenabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::setDragEnabled(const bool enable)
|
||||||
|
{
|
||||||
|
d->dragenabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize KPixmapWidget::sizeHint() const
|
||||||
|
{
|
||||||
|
return minimumSizeHint();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize KPixmapWidget::minimumSizeHint() const
|
||||||
|
{
|
||||||
|
const QSize pixmapsize = d->pixmap.size();
|
||||||
|
return pixmapsize.expandedTo(QWidget::minimumSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
if (Q_LIKELY(!d->pixmap.isNull())) {
|
||||||
|
QPainter painter(this);
|
||||||
|
QStyle *style = QWidget::style();
|
||||||
|
const int alignment = QStyle::visualAlignment(layoutDirection(), d->alignment);
|
||||||
|
if (!isEnabled()) {
|
||||||
|
QStyleOption styleoptions;
|
||||||
|
styleoptions.initFrom(this);
|
||||||
|
style->drawItemPixmap(
|
||||||
|
&painter, contentsRect(), alignment,
|
||||||
|
style->generatedIconPixmap(QIcon::Disabled, d->pixmap, &styleoptions)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
style->drawItemPixmap(
|
||||||
|
&painter, contentsRect(), alignment, d->pixmap
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QWidget::paintEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (d->dragenabled) {
|
||||||
|
d->dragstartpos = event->pos();
|
||||||
|
}
|
||||||
|
QWidget::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (d->dragenabled &&
|
||||||
|
event->buttons() & Qt::LeftButton &&
|
||||||
|
(event->pos() - d->dragstartpos).manhattanLength() > KGlobalSettings::dndEventDelay())
|
||||||
|
{
|
||||||
|
QDrag* drag = new QDrag(this);
|
||||||
|
QMimeData* mimedata = new QMimeData();
|
||||||
|
mimedata->setImageData(d->pixmap.toImage());
|
||||||
|
drag->setMimeData(mimedata);
|
||||||
|
if (!d->pixmap.isNull()) {
|
||||||
|
drag->setPixmap(d->pixmap.scaled(QSize(96, 96), Qt::KeepAspectRatio));
|
||||||
|
// same as the one in KColorMimeData
|
||||||
|
drag->setHotSpot(QPoint(-5,-7));
|
||||||
|
}
|
||||||
|
drag->start();
|
||||||
|
}
|
||||||
|
// don't propagate
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::dragEnterEvent(QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
if (kCheckMimeData(event->mimeData())) {
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
{
|
||||||
|
if (kCheckMimeData(event->mimeData())) {
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KPixmapWidget::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
|
const QMimeData* mimedata = event->mimeData();
|
||||||
|
if (!mimedata) {
|
||||||
|
return;
|
||||||
|
} else if (mimedata->hasImage()) {
|
||||||
|
// images are QPixmap-convertable
|
||||||
|
setPixmap(qvariant_cast<QPixmap>(mimedata->imageData()));
|
||||||
|
} else if (mimedata->hasUrls()) {
|
||||||
|
const QList<QUrl> mimedataurls = mimedata->urls();
|
||||||
|
foreach (const QUrl &mimedataurl, mimedataurls) {
|
||||||
|
const QString mimedataurlpath = mimedataurl.toLocalFile();
|
||||||
|
const KMimeType::Ptr mimetype = KMimeType::findByPath(mimedataurlpath);
|
||||||
|
if (mimetype && KImageIO::isSupported(mimetype->name())) {
|
||||||
|
const QPixmap mimedataurlpixmap = QPixmap(mimedataurlpath);
|
||||||
|
if (!mimedataurlpixmap.isNull()) {
|
||||||
|
// the last pixmap wins
|
||||||
|
setPixmap(mimedataurlpixmap.scaled(QWidget::size(), Qt::KeepAspectRatio));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_kpixmapwidget.cpp"
|
75
kdeui/widgets/kpixmapwidget.h
Normal file
75
kdeui/widgets/kpixmapwidget.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/* This file is part of the KDE libraries
|
||||||
|
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License version 2, as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public License
|
||||||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||||||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KPIXMAPWIDGET_H
|
||||||
|
#define KPIXMAPWIDGET_H
|
||||||
|
|
||||||
|
#include <kdeui_export.h>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
class KPixmapWidgetPrivate;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Class to show a pixmap with drag-n-drop support.
|
||||||
|
|
||||||
|
@note neither drag nor drop is enabled by default, call @p setDragEnabled and
|
||||||
|
@p setAcceptDrops to enable the features
|
||||||
|
@since 4.24
|
||||||
|
@warning the API is subject to change
|
||||||
|
*/
|
||||||
|
class KDEUI_EXPORT KPixmapWidget: public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
|
||||||
|
public:
|
||||||
|
KPixmapWidget(QWidget *parent = nullptr);
|
||||||
|
~KPixmapWidget();
|
||||||
|
|
||||||
|
void setPixmap(const QPixmap &pixmap);
|
||||||
|
QPixmap pixmap() const;
|
||||||
|
|
||||||
|
Qt::Alignment alignment() const;
|
||||||
|
void setAlignment(Qt::Alignment);
|
||||||
|
|
||||||
|
bool dragEnabled() const;
|
||||||
|
void setDragEnabled(const bool enable);
|
||||||
|
|
||||||
|
// QWidget reimplementations
|
||||||
|
virtual QSize sizeHint() const;
|
||||||
|
virtual QSize minimumSizeHint() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// QWidget reimplementations
|
||||||
|
virtual void paintEvent(QPaintEvent *event);
|
||||||
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *event);
|
||||||
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
virtual void dragMoveEvent(QDragMoveEvent *event);
|
||||||
|
virtual void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(KPixmapWidget);
|
||||||
|
KPixmapWidgetPrivate *d;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KPIXMAPWIDGET_H
|
|
@ -18,6 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ktitlewidget.h"
|
#include "ktitlewidget.h"
|
||||||
|
#include "kicon.h"
|
||||||
|
#include "kiconloader.h"
|
||||||
|
#include "kpixmapwidget.h"
|
||||||
|
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtGui/qevent.h>
|
#include <QtGui/qevent.h>
|
||||||
|
@ -26,9 +29,6 @@
|
||||||
#include <QtGui/QLayout>
|
#include <QtGui/QLayout>
|
||||||
#include <QtGui/QTextDocument>
|
#include <QtGui/QTextDocument>
|
||||||
|
|
||||||
#include <kicon.h>
|
|
||||||
#include <kiconloader.h>
|
|
||||||
|
|
||||||
class KTitleWidget::Private
|
class KTitleWidget::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -48,9 +48,9 @@ public:
|
||||||
|
|
||||||
void updateCommentWidget() const
|
void updateCommentWidget() const
|
||||||
{
|
{
|
||||||
// FIXME: we need the usability color styles to implement different
|
// FIXME: need the usability color styles to implement different
|
||||||
// yet palette appropriate colours for the different use cases!
|
// yet palette appropriate colours for the different use cases!
|
||||||
// also .. should we include an icon here, perhaps using the imageLabel?
|
// also .. should an icon be included here, perhaps using the pixmapWidget?
|
||||||
switch (messageType) {
|
switch (messageType) {
|
||||||
case InfoMessage:
|
case InfoMessage:
|
||||||
case WarningMessage:
|
case WarningMessage:
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
|
|
||||||
KTitleWidget* q;
|
KTitleWidget* q;
|
||||||
QGridLayout *headerLayout;
|
QGridLayout *headerLayout;
|
||||||
QLabel *imageLabel;
|
KPixmapWidget *pixmapWidget;
|
||||||
QLabel *textLabel;
|
QLabel *textLabel;
|
||||||
QLabel *commentLabel;
|
QLabel *commentLabel;
|
||||||
int autoHideTimeout;
|
int autoHideTimeout;
|
||||||
|
@ -130,11 +130,11 @@ KTitleWidget::KTitleWidget(QWidget *parent)
|
||||||
d->textLabel->setVisible(false);
|
d->textLabel->setVisible(false);
|
||||||
d->textLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
d->textLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
|
||||||
|
|
||||||
d->imageLabel = new QLabel(titleFrame);
|
d->pixmapWidget = new KPixmapWidget(titleFrame);
|
||||||
d->imageLabel->setVisible(false);
|
d->pixmapWidget->setVisible(false);
|
||||||
|
|
||||||
d->headerLayout->addWidget(d->textLabel, 0, 0);
|
d->headerLayout->addWidget(d->textLabel, 0, 0);
|
||||||
d->headerLayout->addWidget(d->imageLabel, 0, 1, 1, 2);
|
d->headerLayout->addWidget(d->pixmapWidget, 0, 1, 1, 2);
|
||||||
|
|
||||||
d->commentLabel = new QLabel(titleFrame);
|
d->commentLabel = new QLabel(titleFrame);
|
||||||
d->commentLabel->setVisible(false);
|
d->commentLabel->setVisible(false);
|
||||||
|
@ -186,9 +186,9 @@ QString KTitleWidget::comment() const
|
||||||
return d->commentLabel->text();
|
return d->commentLabel->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap *KTitleWidget::pixmap() const
|
QPixmap KTitleWidget::pixmap() const
|
||||||
{
|
{
|
||||||
return d->imageLabel->pixmap();
|
return d->pixmapWidget->pixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KTitleWidget::setBuddy(QWidget *buddy)
|
void KTitleWidget::setBuddy(QWidget *buddy)
|
||||||
|
@ -237,15 +237,15 @@ void KTitleWidget::setComment(const QString &comment, MessageType type)
|
||||||
|
|
||||||
void KTitleWidget::setPixmap(const QPixmap &pixmap, ImageAlignment alignment)
|
void KTitleWidget::setPixmap(const QPixmap &pixmap, ImageAlignment alignment)
|
||||||
{
|
{
|
||||||
d->imageLabel->setVisible(!pixmap.isNull());
|
d->pixmapWidget->setVisible(!pixmap.isNull());
|
||||||
|
|
||||||
d->headerLayout->removeWidget(d->textLabel);
|
d->headerLayout->removeWidget(d->textLabel);
|
||||||
d->headerLayout->removeWidget(d->commentLabel);
|
d->headerLayout->removeWidget(d->commentLabel);
|
||||||
d->headerLayout->removeWidget(d->imageLabel);
|
d->headerLayout->removeWidget(d->pixmapWidget);
|
||||||
|
|
||||||
if (alignment == ImageLeft) {
|
if (alignment == ImageLeft) {
|
||||||
// swap the text and image labels around
|
// swap the text and image labels around
|
||||||
d->headerLayout->addWidget(d->imageLabel, 0, 0, 2, 1);
|
d->headerLayout->addWidget(d->pixmapWidget, 0, 0, 2, 1);
|
||||||
d->headerLayout->addWidget(d->textLabel, 0, 1);
|
d->headerLayout->addWidget(d->textLabel, 0, 1);
|
||||||
d->headerLayout->addWidget(d->commentLabel, 1, 1);
|
d->headerLayout->addWidget(d->commentLabel, 1, 1);
|
||||||
d->headerLayout->setColumnStretch(0, 0);
|
d->headerLayout->setColumnStretch(0, 0);
|
||||||
|
@ -253,12 +253,12 @@ void KTitleWidget::setPixmap(const QPixmap &pixmap, ImageAlignment alignment)
|
||||||
} else {
|
} else {
|
||||||
d->headerLayout->addWidget(d->textLabel, 0, 0);
|
d->headerLayout->addWidget(d->textLabel, 0, 0);
|
||||||
d->headerLayout->addWidget(d->commentLabel, 1, 0);
|
d->headerLayout->addWidget(d->commentLabel, 1, 0);
|
||||||
d->headerLayout->addWidget(d->imageLabel, 0, 1, 2, 1);
|
d->headerLayout->addWidget(d->pixmapWidget, 0, 1, 2, 1);
|
||||||
d->headerLayout->setColumnStretch(1, 0);
|
d->headerLayout->setColumnStretch(1, 0);
|
||||||
d->headerLayout->setColumnStretch(0, 1);
|
d->headerLayout->setColumnStretch(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->imageLabel->setPixmap(pixmap);
|
d->pixmapWidget->setPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
* @return the pixmap displayed in the title
|
* @return the pixmap displayed in the title
|
||||||
* @see setPixmap()
|
* @see setPixmap()
|
||||||
*/
|
*/
|
||||||
const QPixmap *pixmap() const;
|
QPixmap pixmap() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets this label's buddy to buddy.
|
* Sets this label's buddy to buddy.
|
||||||
|
|
|
@ -276,6 +276,10 @@ ToolTip=Title box with label and icon
|
||||||
WhatsThis=A styled frame to be used in title positions in dialogs and other widgets
|
WhatsThis=A styled frame to be used in title positions in dialogs and other widgets
|
||||||
Group=Display (KDE)
|
Group=Display (KDE)
|
||||||
|
|
||||||
|
[KPixmapWidget]
|
||||||
|
ToolTip=QPixmap-optimized widget with drag-n-drop support
|
||||||
|
Group=Display (KDE)
|
||||||
|
|
||||||
[KTreeWidgetSearchLine]
|
[KTreeWidgetSearchLine]
|
||||||
ToolTip=QTreeWidget Search Line (KDE)
|
ToolTip=QTreeWidget Search Line (KDE)
|
||||||
Group=Input (KDE)
|
Group=Input (KDE)
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <kfileitem.h>
|
#include <kfileitem.h>
|
||||||
#include <kpixmapsequenceoverlaypainter.h>
|
#include <kpixmapsequenceoverlaypainter.h>
|
||||||
#include <kio/previewjob.h>
|
#include <kio/previewjob.h>
|
||||||
|
#include <kpixmapwidget.h>
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
|
|
||||||
#include <config-kfile.h>
|
#include <config-kfile.h>
|
||||||
|
@ -56,13 +57,13 @@ public:
|
||||||
void _k_slotFailed(const KFileItem &item);
|
void _k_slotFailed(const KFileItem &item);
|
||||||
|
|
||||||
KUrl lastShownURL;
|
KUrl lastShownURL;
|
||||||
QLabel *imageLabel;
|
KPixmapWidget *pixmapWidget;
|
||||||
KPixmapSequenceOverlayPainter *busyPainter;
|
KPixmapSequenceOverlayPainter *busyPainter;
|
||||||
KIO::PreviewJob *m_job;
|
KIO::PreviewJob *m_job;
|
||||||
};
|
};
|
||||||
|
|
||||||
KImageFilePreviewPrivate::KImageFilePreviewPrivate()
|
KImageFilePreviewPrivate::KImageFilePreviewPrivate()
|
||||||
: imageLabel(nullptr),
|
: pixmapWidget(nullptr),
|
||||||
busyPainter(nullptr),
|
busyPainter(nullptr),
|
||||||
m_job(nullptr)
|
m_job(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -76,11 +77,11 @@ void KImageFilePreviewPrivate::_k_slotFailed(const KFileItem &item)
|
||||||
{
|
{
|
||||||
busyPainter->stop();
|
busyPainter->stop();
|
||||||
if (item.isDir()) {
|
if (item.isDir()) {
|
||||||
imageLabel->setPixmap(
|
pixmapWidget->setPixmap(
|
||||||
DesktopIcon("inode-directory", KIconLoader::SizeEnormous, KIconLoader::DisabledState)
|
DesktopIcon("inode-directory", KIconLoader::SizeEnormous, KIconLoader::DisabledState)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
imageLabel->setPixmap(
|
pixmapWidget->setPixmap(
|
||||||
SmallIcon("image-missing", KIconLoader::SizeEnormous, KIconLoader::DisabledState)
|
SmallIcon("image-missing", KIconLoader::SizeEnormous, KIconLoader::DisabledState)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -103,13 +104,13 @@ KImageFilePreview::KImageFilePreview(QWidget *parent)
|
||||||
QVBoxLayout *vb = new QVBoxLayout(this);
|
QVBoxLayout *vb = new QVBoxLayout(this);
|
||||||
vb->setMargin(0);
|
vb->setMargin(0);
|
||||||
|
|
||||||
d->imageLabel = new QLabel(this);
|
d->pixmapWidget = new KPixmapWidget(this);
|
||||||
d->imageLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
d->pixmapWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
d->imageLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
d->pixmapWidget->setDragEnabled(true);
|
||||||
vb->addWidget(d->imageLabel);
|
vb->addWidget(d->pixmapWidget);
|
||||||
|
|
||||||
d->busyPainter = new KPixmapSequenceOverlayPainter(this);
|
d->busyPainter = new KPixmapSequenceOverlayPainter(this);
|
||||||
d->busyPainter->setWidget(d->imageLabel);
|
d->busyPainter->setWidget(d->pixmapWidget);
|
||||||
d->busyPainter->stop();
|
d->busyPainter->stop();
|
||||||
|
|
||||||
setSupportedMimeTypes(KIO::PreviewJob::supportedMimeTypes());
|
setSupportedMimeTypes(KIO::PreviewJob::supportedMimeTypes());
|
||||||
|
@ -133,8 +134,8 @@ void KImageFilePreview::showPreview(const KUrl& url)
|
||||||
|
|
||||||
d->lastShownURL = url;
|
d->lastShownURL = url;
|
||||||
|
|
||||||
int w = d->imageLabel->contentsRect().width() - 4;
|
int w = d->pixmapWidget->contentsRect().width() - 4;
|
||||||
int h = d->imageLabel->contentsRect().height() - 4;
|
int h = d->pixmapWidget->contentsRect().height() - 4;
|
||||||
|
|
||||||
if (d->m_job) {
|
if (d->m_job) {
|
||||||
disconnect(
|
disconnect(
|
||||||
|
@ -188,7 +189,7 @@ QSize KImageFilePreview::sizeHint() const
|
||||||
void KImageFilePreview::gotPreview(const KFileItem &item, const QPixmap &pixmap)
|
void KImageFilePreview::gotPreview(const KFileItem &item, const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
d->busyPainter->stop();
|
d->busyPainter->stop();
|
||||||
d->imageLabel->setPixmap(pixmap);
|
d->pixmapWidget->setPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ void KImageFilePreview::clearPreview()
|
||||||
d->m_job->kill();
|
d->m_job->kill();
|
||||||
d->m_job = nullptr;
|
d->m_job = nullptr;
|
||||||
}
|
}
|
||||||
d->imageLabel->setPixmap(QPixmap());
|
d->pixmapWidget->setPixmap(QPixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_kimagefilepreview.cpp"
|
#include "moc_kimagefilepreview.cpp"
|
||||||
|
|
|
@ -43,7 +43,51 @@
|
||||||
|
|
||||||
#include "kpropertiesdialog.h"
|
#include "kpropertiesdialog.h"
|
||||||
#include "kpropertiesdialog_p.h"
|
#include "kpropertiesdialog_p.h"
|
||||||
|
#include "kdialog.h"
|
||||||
|
#include "kdirnotify.h"
|
||||||
|
#include "kdiskfreespaceinfo.h"
|
||||||
|
#include "kdebug.h"
|
||||||
|
#include "kdesktopfile.h"
|
||||||
|
#include "kicondialog.h"
|
||||||
|
#include "kurl.h"
|
||||||
|
#include "kurlrequester.h"
|
||||||
|
#include "klocale.h"
|
||||||
|
#include "kglobal.h"
|
||||||
|
#include "kglobalsettings.h"
|
||||||
|
#include "kstandarddirs.h"
|
||||||
|
#include "kjobuidelegate.h"
|
||||||
|
#include "kio/job.h"
|
||||||
|
#include "kio/copyjob.h"
|
||||||
|
#include "kio/chmodjob.h"
|
||||||
|
#include "kio/directorysizejob.h"
|
||||||
|
#include "kio/renamedialog.h"
|
||||||
|
#include "kio/netaccess.h"
|
||||||
|
#include "kio/jobuidelegate.h"
|
||||||
|
#include "kfiledialog.h"
|
||||||
|
#include "kmimetype.h"
|
||||||
|
#include "kmountpoint.h"
|
||||||
|
#include "kiconloader.h"
|
||||||
|
#include "kmessagebox.h"
|
||||||
|
#include "kservice.h"
|
||||||
|
#include "kcombobox.h"
|
||||||
|
#include "kcompletion.h"
|
||||||
|
#include "klineedit.h"
|
||||||
|
#include "kseparator.h"
|
||||||
|
#include "ksqueezedtextlabel.h"
|
||||||
|
#include "kmimetypetrader.h"
|
||||||
|
#include "kpreviewprops.h"
|
||||||
|
#include "kmetaprops.h"
|
||||||
|
#include "krun.h"
|
||||||
|
#include "kvbox.h"
|
||||||
|
#include "kacl.h"
|
||||||
|
#include "kconfiggroup.h"
|
||||||
|
#include "kshell.h"
|
||||||
|
#include "kcapacitybar.h"
|
||||||
|
#include "kfileitemlistproperties.h"
|
||||||
|
#include "kuser.h"
|
||||||
|
#include "kpixmapwidget.h"
|
||||||
|
#include "kbuildsycocaprogressdialog.h"
|
||||||
|
#include "kmimetypechooser.h"
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <config-acl.h>
|
#include <config-acl.h>
|
||||||
|
@ -75,59 +119,12 @@ extern "C" {
|
||||||
#include <sys/acl.h>
|
#include <sys/acl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <kdialog.h>
|
|
||||||
#include <kdirnotify.h>
|
|
||||||
#include <kdiskfreespaceinfo.h>
|
|
||||||
#include <kdebug.h>
|
|
||||||
#include <kdesktopfile.h>
|
|
||||||
#include <kicondialog.h>
|
|
||||||
#include <kurl.h>
|
|
||||||
#include <kurlrequester.h>
|
|
||||||
#include <klocale.h>
|
|
||||||
#include <kglobal.h>
|
|
||||||
#include <kglobalsettings.h>
|
|
||||||
#include <kstandarddirs.h>
|
|
||||||
#include <kjobuidelegate.h>
|
|
||||||
#include <kio/job.h>
|
|
||||||
#include <kio/copyjob.h>
|
|
||||||
#include <kio/chmodjob.h>
|
|
||||||
#include <kio/directorysizejob.h>
|
|
||||||
#include <kio/renamedialog.h>
|
|
||||||
#include <kio/netaccess.h>
|
|
||||||
#include <kio/jobuidelegate.h>
|
|
||||||
#include <kfiledialog.h>
|
|
||||||
#include <kmimetype.h>
|
|
||||||
#include <kmountpoint.h>
|
|
||||||
#include <kiconloader.h>
|
|
||||||
#include <kmessagebox.h>
|
|
||||||
#include <kservice.h>
|
|
||||||
#include <kcombobox.h>
|
|
||||||
#include <kcompletion.h>
|
|
||||||
#include <klineedit.h>
|
|
||||||
#include <kseparator.h>
|
|
||||||
#include <ksqueezedtextlabel.h>
|
|
||||||
#include <kmimetypetrader.h>
|
|
||||||
#include <kpreviewprops.h>
|
|
||||||
#include <kmetaprops.h>
|
|
||||||
#include <krun.h>
|
|
||||||
#include <kvbox.h>
|
|
||||||
#include <kacl.h>
|
|
||||||
#include <kconfiggroup.h>
|
|
||||||
#include <kshell.h>
|
|
||||||
#include <kcapacitybar.h>
|
|
||||||
#include <kfileitemlistproperties.h>
|
|
||||||
#include <kuser.h>
|
|
||||||
|
|
||||||
#include "ui_kpropertiesdesktopbase.h"
|
#include "ui_kpropertiesdesktopbase.h"
|
||||||
#include "ui_kpropertiesdesktopadvbase.h"
|
#include "ui_kpropertiesdesktopadvbase.h"
|
||||||
#ifdef HAVE_POSIX_ACL
|
#ifdef HAVE_POSIX_ACL
|
||||||
#include "kacleditwidget.h"
|
#include "kacleditwidget.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <kbuildsycocaprogressdialog.h>
|
|
||||||
#include <kmimetypechooser.h>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace KDEPrivate;
|
using namespace KDEPrivate;
|
||||||
|
|
||||||
static QString nameFromFileName(QString nameStr)
|
static QString nameFromFileName(QString nameStr)
|
||||||
|
@ -858,11 +855,11 @@ KFilePropsPlugin::KFilePropsPlugin(KPropertiesDialog *props)
|
||||||
this, SLOT(slotIconChanged())
|
this, SLOT(slotIconChanged())
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
QLabel *iconLabel = new QLabel(d->m_frame);
|
KPixmapWidget *iconWidget = new KPixmapWidget(d->m_frame);
|
||||||
int bsize = 66 + 2 * iconLabel->style()->pixelMetric(QStyle::PM_ButtonMargin);
|
int bsize = 66 + 2 * iconWidget->style()->pixelMetric(QStyle::PM_ButtonMargin);
|
||||||
iconLabel->setFixedSize(bsize, bsize);
|
iconWidget->setFixedSize(bsize, bsize);
|
||||||
iconLabel->setPixmap(KIconLoader::global()->loadIcon(iconStr, KIconLoader::Desktop, 48));
|
iconWidget->setPixmap(KIconLoader::global()->loadIcon(iconStr, KIconLoader::Desktop, 48));
|
||||||
d->iconArea = iconLabel;
|
d->iconArea = iconWidget;
|
||||||
}
|
}
|
||||||
grid->addWidget(d->iconArea, curRow, 0, Qt::AlignLeft);
|
grid->addWidget(d->iconArea, curRow, 0, Qt::AlignLeft);
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
#include <QtDBus/QDBusReply>
|
#include <QtDBus/QDBusReply>
|
||||||
#include <QtDBus/QDBusConnectionInterface>
|
#include <QtDBus/QDBusConnectionInterface>
|
||||||
|
|
||||||
#include <kmimetypetrader.h>
|
#include "kmimetypetrader.h"
|
||||||
#include <kmimetype.h>
|
#include "kmimetype.h"
|
||||||
#include "kio/jobclasses.h" // for KIO::JobFlags
|
#include "kio/jobclasses.h" // for KIO::JobFlags
|
||||||
#include "kio/job.h"
|
#include "kio/job.h"
|
||||||
#include "kio/jobuidelegate.h"
|
#include "kio/jobuidelegate.h"
|
||||||
|
@ -54,24 +54,25 @@
|
||||||
#include "kfile/kopenwithdialog.h"
|
#include "kfile/kopenwithdialog.h"
|
||||||
#include "kfile/krecentdocument.h"
|
#include "kfile/krecentdocument.h"
|
||||||
#include "kdesktopfileactions.h"
|
#include "kdesktopfileactions.h"
|
||||||
#include <kmessageboxwrapper.h>
|
#include "kmessageboxwrapper.h"
|
||||||
#include <kurl.h>
|
#include "kurl.h"
|
||||||
#include <kglobal.h>
|
#include "kglobal.h"
|
||||||
#include <ktoolinvocation.h>
|
#include "ktoolinvocation.h"
|
||||||
#include <kdebug.h>
|
#include "kdebug.h"
|
||||||
#include <klocale.h>
|
#include "klocale.h"
|
||||||
#include <kprotocolmanager.h>
|
#include "kprotocolmanager.h"
|
||||||
#include <kstandarddirs.h>
|
#include "kstandarddirs.h"
|
||||||
#include <kprocess.h>
|
#include "kprocess.h"
|
||||||
#include <kdesktopfile.h>
|
#include "kdesktopfile.h"
|
||||||
#include <kmacroexpander.h>
|
#include "kmacroexpander.h"
|
||||||
#include <kshell.h>
|
#include "kshell.h"
|
||||||
#include <kde_file.h>
|
#include "kde_file.h"
|
||||||
#include <kconfiggroup.h>
|
#include "kconfiggroup.h"
|
||||||
#include <kdialog.h>
|
#include "kdialog.h"
|
||||||
#include <kstandardguiitem.h>
|
#include "kstandardguiitem.h"
|
||||||
#include <kguiitem.h>
|
#include "kguiitem.h"
|
||||||
#include <ksavefile.h>
|
#include "ksavefile.h"
|
||||||
|
#include "kpixmapwidget.h"
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include <kwindowsystem.h>
|
#include <kwindowsystem.h>
|
||||||
|
@ -858,10 +859,10 @@ static bool makeServiceExecutable(const KService& service, QWidget* window)
|
||||||
QWidget *baseWidget = new QWidget(baseDialog);
|
QWidget *baseWidget = new QWidget(baseDialog);
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout(baseWidget);
|
QHBoxLayout *mainLayout = new QHBoxLayout(baseWidget);
|
||||||
|
|
||||||
QLabel *iconLabel = new QLabel(baseWidget);
|
KPixmapWidget *iconWidget = new KPixmapWidget(baseWidget);
|
||||||
QPixmap warningIcon(KIconLoader::global()->loadIcon("dialog-warning", KIconLoader::NoGroup, KIconLoader::SizeHuge));
|
QPixmap warningIcon(KIconLoader::global()->loadIcon("dialog-warning", KIconLoader::NoGroup, KIconLoader::SizeHuge));
|
||||||
mainLayout->addWidget(iconLabel);
|
mainLayout->addWidget(iconWidget);
|
||||||
iconLabel->setPixmap(warningIcon);
|
iconWidget->setPixmap(warningIcon);
|
||||||
|
|
||||||
QVBoxLayout *contentLayout = new QVBoxLayout;
|
QVBoxLayout *contentLayout = new QVBoxLayout;
|
||||||
QString warningMessage = i18nc("program name follows in a line edit below",
|
QString warningMessage = i18nc("program name follows in a line edit below",
|
||||||
|
|
|
@ -20,6 +20,15 @@
|
||||||
|
|
||||||
#include "tooltip_p.h"
|
#include "tooltip_p.h"
|
||||||
#include "windowpreview_p.h"
|
#include "windowpreview_p.h"
|
||||||
|
#include "plasma/plasma.h"
|
||||||
|
#include "plasma/paintutils.h"
|
||||||
|
#include "plasma/theme.h"
|
||||||
|
#include "plasma/framesvg.h"
|
||||||
|
#include "plasma/windoweffects.h"
|
||||||
|
#include "kdebug.h"
|
||||||
|
#include "kglobal.h"
|
||||||
|
#include "kglobalsettings.h"
|
||||||
|
#include "kpixmapwidget.h"
|
||||||
|
|
||||||
#include <QAbstractTextDocumentLayout>
|
#include <QAbstractTextDocumentLayout>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
|
@ -32,16 +41,6 @@
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QtGui/qtextobject.h>
|
#include <QtGui/qtextobject.h>
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
#include <kglobal.h>
|
|
||||||
#include <kglobalsettings.h>
|
|
||||||
|
|
||||||
#include <plasma/plasma.h>
|
|
||||||
#include <plasma/paintutils.h>
|
|
||||||
#include <plasma/theme.h>
|
|
||||||
#include <plasma/framesvg.h>
|
|
||||||
#include <plasma/windoweffects.h>
|
|
||||||
|
|
||||||
namespace Plasma {
|
namespace Plasma {
|
||||||
|
|
||||||
class TipTextWidget : public QWidget
|
class TipTextWidget : public QWidget
|
||||||
|
@ -140,15 +139,17 @@ class ToolTipPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ToolTipPrivate()
|
ToolTipPrivate()
|
||||||
: text(0),
|
: text(nullptr),
|
||||||
imageLabel(0),
|
imageWidget(nullptr),
|
||||||
preview(0),
|
preview(nullptr),
|
||||||
|
background(nullptr),
|
||||||
|
animation(nullptr),
|
||||||
direction(Plasma::Up),
|
direction(Plasma::Up),
|
||||||
autohide(true)
|
autohide(true)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
TipTextWidget *text;
|
TipTextWidget *text;
|
||||||
QLabel *imageLabel;
|
KPixmapWidget *imageWidget;
|
||||||
WindowPreview *preview;
|
WindowPreview *preview;
|
||||||
FrameSvg *background;
|
FrameSvg *background;
|
||||||
QWeakPointer<QObject> source;
|
QWeakPointer<QObject> source;
|
||||||
|
@ -165,9 +166,9 @@ ToolTip::ToolTip(QWidget *parent)
|
||||||
setWindowFlags(Qt::ToolTip);
|
setWindowFlags(Qt::ToolTip);
|
||||||
d->preview = new WindowPreview(this);
|
d->preview = new WindowPreview(this);
|
||||||
d->text = new TipTextWidget(this);
|
d->text = new TipTextWidget(this);
|
||||||
d->imageLabel = new QLabel(this);
|
d->imageWidget = new KPixmapWidget(this);
|
||||||
|
|
||||||
d->imageLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
d->imageWidget->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||||
d->animation = new QPropertyAnimation(this, "pos", this);
|
d->animation = new QPropertyAnimation(this, "pos", this);
|
||||||
d->animation->setEasingCurve(QEasingCurve::InOutQuad);
|
d->animation->setEasingCurve(QEasingCurve::InOutQuad);
|
||||||
d->animation->setDuration(250);
|
d->animation->setDuration(250);
|
||||||
|
@ -183,7 +184,7 @@ ToolTip::ToolTip(QWidget *parent)
|
||||||
QGridLayout *mainLayout = new QGridLayout();//2, 2);
|
QGridLayout *mainLayout = new QGridLayout();//2, 2);
|
||||||
mainLayout->addWidget(d->preview, 0, 0, 1, -1, Qt::AlignCenter);
|
mainLayout->addWidget(d->preview, 0, 0, 1, -1, Qt::AlignCenter);
|
||||||
|
|
||||||
mainLayout->addWidget(d->imageLabel, 1, 0, Qt::AlignTop | Qt::AlignHCenter);
|
mainLayout->addWidget(d->imageWidget, 1, 0, Qt::AlignTop | Qt::AlignHCenter);
|
||||||
mainLayout->addWidget(d->text, 1, 1, Qt::AlignCenter | Qt::AlignVCenter);
|
mainLayout->addWidget(d->text, 1, 1, Qt::AlignCenter | Qt::AlignVCenter);
|
||||||
mainLayout->setColumnStretch(1, 10);
|
mainLayout->setColumnStretch(1, 10);
|
||||||
|
|
||||||
|
@ -281,10 +282,10 @@ void ToolTip::setContent(QObject *tipper, const ToolTipContent &data)
|
||||||
if (data.image().isNull() ||
|
if (data.image().isNull() ||
|
||||||
(WindowEffects::isEffectAvailable(WindowEffects::WindowPreview) &&
|
(WindowEffects::isEffectAvailable(WindowEffects::WindowPreview) &&
|
||||||
!data.windowsToPreview().isEmpty())) {
|
!data.windowsToPreview().isEmpty())) {
|
||||||
d->imageLabel->hide();
|
d->imageWidget->hide();
|
||||||
} else {
|
} else {
|
||||||
d->imageLabel->show();
|
d->imageWidget->show();
|
||||||
d->imageLabel->setPixmap(data.image());
|
d->imageWidget->setPixmap(data.image());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.highlightWindows() && !data.windowsToPreview().isEmpty()) {
|
if (data.highlightWindows() && !data.windowsToPreview().isEmpty()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue