2010-10-12 21:51:57 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright 2010 Marco Martin <mart@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program 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 General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
|
|
***************************************************************************/
|
|
|
|
#ifndef FRAMESVGITEM_P
|
|
|
|
#define FRAMESVGITEM_P
|
|
|
|
|
|
|
|
#include <QDeclarativeItem>
|
|
|
|
|
2010-11-05 21:50:28 +01:00
|
|
|
#include <Plasma/FrameSvg>
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
namespace Plasma {
|
|
|
|
|
|
|
|
class FrameSvg;
|
|
|
|
|
|
|
|
class FrameSvgItemMargins : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2012-01-10 12:29:35 +01:00
|
|
|
/**
|
|
|
|
* width in pixels of the left margin
|
|
|
|
*/
|
2010-10-12 21:51:57 +02:00
|
|
|
Q_PROPERTY(qreal left READ left NOTIFY marginsChanged)
|
2012-01-10 12:29:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* height in pixels of the top margin
|
|
|
|
*/
|
2010-10-12 21:51:57 +02:00
|
|
|
Q_PROPERTY(qreal top READ top NOTIFY marginsChanged)
|
2012-01-10 12:29:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* width in pixels of the right margin
|
|
|
|
*/
|
2010-10-12 21:51:57 +02:00
|
|
|
Q_PROPERTY(qreal right READ right NOTIFY marginsChanged)
|
2012-01-10 12:29:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* height in pixels of the bottom margin
|
|
|
|
*/
|
2010-10-12 21:51:57 +02:00
|
|
|
Q_PROPERTY(qreal bottom READ bottom NOTIFY marginsChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
FrameSvgItemMargins(Plasma::FrameSvg *frameSvg, QObject *parent = 0);
|
|
|
|
|
|
|
|
qreal left() const;
|
|
|
|
qreal top() const;
|
|
|
|
qreal right() const;
|
|
|
|
qreal bottom() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void marginsChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
FrameSvg *m_frameSvg;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FrameSvgItem : public QDeclarativeItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2012-01-10 12:29:35 +01:00
|
|
|
/**
|
|
|
|
* Theme relative path of the svg, like "widgets/background"
|
|
|
|
*/
|
2012-08-12 00:13:21 +02:00
|
|
|
Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged)
|
2012-01-10 12:29:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* prefix for the 9 piece svg, like "pushed" or "normal" for the button
|
|
|
|
* see http://techbase.kde.org/Development/Tutorials/Plasma/ThemeDetails
|
|
|
|
* for a list of paths and prefixes
|
|
|
|
*/
|
2012-08-12 00:13:21 +02:00
|
|
|
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix NOTIFY prefixChanged)
|
2012-01-10 12:29:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The margins of the frame, read only
|
|
|
|
* @see FrameSvgItemMargins
|
|
|
|
*/
|
2010-10-12 21:51:57 +02:00
|
|
|
Q_PROPERTY(QObject *margins READ margins CONSTANT)
|
|
|
|
|
2010-11-05 21:50:28 +01:00
|
|
|
Q_FLAGS(Plasma::FrameSvg::EnabledBorders)
|
2012-01-10 12:29:35 +01:00
|
|
|
/**
|
|
|
|
* The borders that will be rendered, it's a flag combination of:
|
|
|
|
* NoBorder
|
|
|
|
* TopBorder
|
|
|
|
* BottomBorder
|
|
|
|
* LeftBorder
|
|
|
|
* RightBorder
|
|
|
|
*/
|
2012-08-12 00:13:21 +02:00
|
|
|
Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders WRITE setEnabledBorders NOTIFY enabledBordersChanged)
|
2010-11-05 21:50:28 +01:00
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
public:
|
|
|
|
FrameSvgItem(QDeclarativeItem *parent=0);
|
|
|
|
~FrameSvgItem();
|
|
|
|
|
|
|
|
void setImagePath(const QString &path);
|
|
|
|
QString imagePath() const;
|
|
|
|
|
|
|
|
void setPrefix(const QString &prefix);
|
|
|
|
QString prefix() const;
|
|
|
|
|
2010-11-05 21:50:28 +01:00
|
|
|
void setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders);
|
|
|
|
Plasma::FrameSvg::EnabledBorders enabledBorders() const;
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
FrameSvgItemMargins *margins() const;
|
|
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
|
|
|
|
|
|
|
void geometryChanged(const QRectF &newGeometry,
|
|
|
|
const QRectF &oldGeometry);
|
|
|
|
|
2012-08-12 00:13:21 +02:00
|
|
|
signals:
|
|
|
|
void imagePathChanged();
|
|
|
|
void prefixChanged();
|
|
|
|
void enabledBordersChanged();
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
private Q_SLOTS:
|
|
|
|
void doUpdate();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Plasma::FrameSvg *m_frameSvg;
|
|
|
|
FrameSvgItemMargins *m_margins;
|
2011-03-27 12:37:23 +02:00
|
|
|
QString m_prefix;
|
2010-10-12 21:51:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|