Fix Q_PROPERTY/Q_INVOKABLE's, readd icon accessor

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=696719
This commit is contained in:
Matt Broadstone 2007-08-05 18:03:26 +00:00
parent 8a4601f9b0
commit 6a6c508036
3 changed files with 30 additions and 14 deletions

View File

@ -36,7 +36,6 @@
#include <private/qwindowsurface_p.h>
#endif
#include <KIcon>
#include <KImageEffect>
#include <KIconEffect>
#include <KIconLoader>
@ -286,7 +285,7 @@ Icon::Icon(const QString &text, QGraphicsItem *parent)
init();
}
Icon::Icon(const QIcon &icon, const QString &text, QGraphicsItem *parent)
Icon::Icon(const KIcon &icon, const QString &text, QGraphicsItem *parent)
: Plasma::Widget(parent),
d(new Private)
{
@ -365,7 +364,10 @@ void Icon::actionDestroyed(QObject* action)
QSizeF Icon::Private::displaySizeHint(const QStyleOptionGraphicsItem *option) const
{
QString label = text;
const qreal maxWidth = (orientation == Qt::Vertical) ? iconSize.width() + 10 : 32757;
// const qreal maxWidth = (orientation == Qt::Vertical) ? iconSize.width() + 10 : 32757;
// NOTE: find a way to use the other layoutText, it currently returns nominal width, when
// we actually need the actual width.
// To compute the nominal size for the label + info, we'll just append
// the information string to the label
@ -853,17 +855,22 @@ QString Icon::infoText() const
return d->infoText;
}
KIcon Icon::icon() const
{
return d->icon;
}
void Icon::setIcon(const QString& icon)
{
if (icon.isEmpty()) {
setIcon(QIcon());
setIcon(KIcon());
return;
}
setIcon(KIcon(icon));
}
void Icon::setIcon(const QIcon& icon)
void Icon::setIcon(const KIcon& icon)
{
d->icon = icon;
d->calculateSizeRequested = true;

View File

@ -24,6 +24,8 @@
#include <QtCore/QObject>
#include <QtGui/QGraphicsTextItem>
#include <KIcon>
#include <plasma/dataengine.h>
#include <plasma/phase.h>
#include <plasma/plasma_export.h>
@ -48,6 +50,7 @@ class PLASMA_EXPORT Icon : public Plasma::Widget
Q_OBJECT
Q_PROPERTY( QString text READ text WRITE setText )
Q_PROPERTY( QString infoText READ infoText WRITE setInfoText )
Q_PROPERTY( KIcon icon READ icon WRITE setIcon )
Q_PROPERTY( QSizeF iconSize READ iconSize WRITE setIconSize )
public:
/**
@ -69,7 +72,7 @@ public:
* @param text the text that will be displayed with this icon.
* @param parent The QGraphicsItem this icon is parented to.
*/
Icon(const QIcon & icon, const QString &text, QGraphicsItem *parent = 0);
Icon(const KIcon & icon, const QString &text, QGraphicsItem *parent = 0);
/**
* Destroys this Plasma::Icon.
@ -100,10 +103,15 @@ public:
void setInfoText(const QString &text);
/**
* Sets the graphical icon for this Plasma::Icon.
* @param icon the QIcon to associate with this icon.
* @return the icon associated with this icon.
*/
Q_INVOKABLE void setIcon(const QIcon& icon);
KIcon icon() const;
/**
* Sets the graphical icon for this Plasma::Icon.
* @param icon the KIcon to associate with this icon.
*/
void setIcon(const KIcon& icon);
/**
* Convenience method to set the icon of this Plasma::Icon
@ -113,15 +121,15 @@ public:
Q_INVOKABLE void setIcon(const QString& icon);
/**
* Returns the size of this Plasma::Icon's graphical icon.
* @return the size of this Plasma::Icon's graphical icon.
*/
Q_INVOKABLE QSizeF iconSize() const;
QSizeF iconSize() const;
/**
* Sets the size of the graphical icon for this Plasma::Icon.
* @param size the size of the icon.
*/
Q_INVOKABLE void setIconSize(const QSizeF& size);
void setIconSize(const QSizeF& size);
/**
* Convenience method to set the icon size without a QSizeF.

View File

@ -25,7 +25,8 @@
#include <QtGui/QStyleOptionGraphicsItem>
#include <QtGui/QTextLayout>
#include <QtGui/QTextOption>
#include <QtGui/QIcon>
#include <KIcon>
#include <plasma/plasma_export.h>
#include <plasma/svg.h>
@ -169,7 +170,7 @@ public:
int svgElements;
QSizeF size;
QSizeF iconSize;
QIcon icon;
KIcon icon;
ButtonState state;
Qt::Orientation orientation;
bool calculateSizeRequested;