forward signals, no need for image setting
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=809574
This commit is contained in:
parent
51bb717cae
commit
69435a397f
@ -34,40 +34,12 @@ class LineEdit::Private
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private()
|
Private()
|
||||||
: svg(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~Private()
|
~Private()
|
||||||
{
|
{
|
||||||
delete svg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPixmap(LineEdit *q)
|
|
||||||
{
|
|
||||||
if (imagePath.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KMimeType::Ptr mime = KMimeType::findByPath(absImagePath);
|
|
||||||
QPixmap pm(q->size().toSize());
|
|
||||||
|
|
||||||
if (mime->is("image/svg+xml")) {
|
|
||||||
svg = new Svg();
|
|
||||||
QPainter p(&pm);
|
|
||||||
svg->paint(&p, pm.rect());
|
|
||||||
} else {
|
|
||||||
pm = QPixmap(absImagePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: load image into widget
|
|
||||||
//static_cast<QLineEdit*>(widget())->setPixmap();
|
|
||||||
//static_cast<QLineEdit*>(widget())->setIcon(QIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString imagePath;
|
|
||||||
QString absImagePath;
|
|
||||||
Svg *svg;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LineEdit::LineEdit(QGraphicsWidget *parent)
|
LineEdit::LineEdit(QGraphicsWidget *parent)
|
||||||
@ -75,7 +47,9 @@ LineEdit::LineEdit(QGraphicsWidget *parent)
|
|||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
QLineEdit* native = new QLineEdit;
|
QLineEdit* native = new QLineEdit;
|
||||||
//TODO: forward signals
|
connect(native, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
|
||||||
|
connect(native, SIGNAL(returnPressed()), this, SIGNAL(returnPressed()));
|
||||||
|
connect(native, SIGNAL(textEdited(const QString&)), this, SIGNAL(textEdited(const QString&)));
|
||||||
setWidget(native);
|
setWidget(native);
|
||||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
}
|
}
|
||||||
@ -95,39 +69,6 @@ QString LineEdit::text() const
|
|||||||
return static_cast<QLineEdit*>(widget())->text();
|
return static_cast<QLineEdit*>(widget())->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::setImage(const QString &path)
|
|
||||||
{
|
|
||||||
if (d->imagePath == path) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete d->svg;
|
|
||||||
d->svg = 0;
|
|
||||||
d->imagePath = path;
|
|
||||||
|
|
||||||
bool absolutePath = !path.isEmpty() &&
|
|
||||||
#ifdef Q_WS_WIN
|
|
||||||
!QDir::isRelativePath(path)
|
|
||||||
#else
|
|
||||||
path[0] == '/'
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
if (absolutePath) {
|
|
||||||
d->absImagePath = path;
|
|
||||||
} else {
|
|
||||||
//TODO: package support
|
|
||||||
d->absImagePath = Theme::defaultTheme()->imagePath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
d->setPixmap(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString LineEdit::image() const
|
|
||||||
{
|
|
||||||
return d->imagePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LineEdit::setStylesheet(const QString &stylesheet)
|
void LineEdit::setStylesheet(const QString &stylesheet)
|
||||||
{
|
{
|
||||||
widget()->setStyleSheet(stylesheet);
|
widget()->setStyleSheet(stylesheet);
|
||||||
@ -143,12 +84,6 @@ QLineEdit* LineEdit::nativeWidget() const
|
|||||||
return static_cast<QLineEdit*>(widget());
|
return static_cast<QLineEdit*>(widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|
||||||
{
|
|
||||||
d->setPixmap(this);
|
|
||||||
QGraphicsProxyWidget::resizeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
|
||||||
#include <lineedit.moc>
|
#include <lineedit.moc>
|
||||||
|
@ -34,7 +34,6 @@ class LineEdit : public QGraphicsProxyWidget
|
|||||||
|
|
||||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||||
Q_PROPERTY(QString text READ text WRITE setText)
|
Q_PROPERTY(QString text READ text WRITE setText)
|
||||||
Q_PROPERTY(QString image READ image WRITE setImage)
|
|
||||||
Q_PROPERTY(QString stylesheet READ stylesheet WRITE setStylesheet)
|
Q_PROPERTY(QString stylesheet READ stylesheet WRITE setStylesheet)
|
||||||
Q_PROPERTY(QLineEdit* nativeWidget READ nativeWidget)
|
Q_PROPERTY(QLineEdit* nativeWidget READ nativeWidget)
|
||||||
|
|
||||||
@ -54,18 +53,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
QString text() const;
|
QString text() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the path to an image to display.
|
|
||||||
*
|
|
||||||
* @arg path the path to the image; if a relative path, then a themed image will be loaded.
|
|
||||||
*/
|
|
||||||
void setImage(const QString &path);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the image path being displayed currently, or an empty string if none.
|
|
||||||
*/
|
|
||||||
QString image() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the style sheet used to control the visual display of this LineEdit
|
* Sets the style sheet used to control the visual display of this LineEdit
|
||||||
*
|
*
|
||||||
@ -84,9 +71,9 @@ public:
|
|||||||
QLineEdit* nativeWidget() const;
|
QLineEdit* nativeWidget() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
void editingFinished();
|
||||||
protected:
|
void returnPressed();
|
||||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
void textEdited(const QString & text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user