API changes as announced:

* ConfigXml becomes ConfigLoader
  * Containment::(add|remove)ToolBoxTool(QAction *action) becomes
    Containment::(add|remove)ToolBoxAction(QAction *action)
  * Flash becomes FlashingLabel
  * Icon becomes IconWidget
  * PanelSvg becomes FrameSvg

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=877504
This commit is contained in:
Kevin Ottens 2008-10-29 17:46:33 +00:00
parent 871508e467
commit f66b4d819b
51 changed files with 1186 additions and 1186 deletions

View File

@ -25,7 +25,7 @@ set(plasma_LIB_SRCS
animationdriver.cpp
animator.cpp
applet.cpp
configxml.cpp
configloader.cpp
containment.cpp
context.cpp
corona.cpp
@ -37,7 +37,7 @@ set(plasma_LIB_SRCS
extender.cpp
extenderitem.cpp
paintutils.cpp
panelsvg.cpp
framesvg.cpp
plasma.cpp
popupapplet.cpp
private/applethandle.cpp
@ -69,10 +69,10 @@ set(plasma_LIB_SRCS
wallpaper.cpp
widgets/checkbox.cpp
widgets/combobox.cpp
widgets/flash.cpp
widgets/flashinglabel.cpp
widgets/frame.cpp
widgets/groupbox.cpp
widgets/icon.cpp
widgets/iconwidget.cpp
widgets/label.cpp
widgets/lineedit.cpp
widgets/meter.cpp
@ -140,7 +140,7 @@ set(plasma_LIB_INCLUDES
animationdriver.h
animator.h
applet.h
configxml.h
configloader.h
containment.h
context.h
corona.h
@ -152,7 +152,7 @@ set(plasma_LIB_INCLUDES
extender.h
extenderitem.h
paintutils.h
panelsvg.h
framesvg.h
plasma.h
plasma_export.h
popupapplet.h
@ -183,10 +183,10 @@ install(FILES
install(FILES
widgets/checkbox.h
widgets/combobox.h
widgets/flash.h
widgets/flashinglabel.h
widgets/frame.h
widgets/groupbox.h
widgets/icon.h
widgets/iconwidget.h
widgets/label.h
widgets/lineedit.h
widgets/meter.h
@ -218,7 +218,7 @@ includes/Applet
includes/AppletScript
includes/CheckBox
includes/ComboBox
includes/ConfigXml
includes/ConfigLoader
includes/Containment
includes/Context
includes/Corona
@ -230,10 +230,11 @@ includes/Delegate
includes/Dialog
includes/Extender
includes/ExtenderItem
includes/Flash
includes/FlashingLabel
includes/Frame
includes/FrameSvg
includes/GroupBox
includes/Icon
includes/IconWidget
includes/Label
includes/LineEdit
includes/Meter
@ -241,7 +242,6 @@ includes/Package
includes/PackageMetadata
includes/PackageStructure
includes/PaintUtils
includes/PanelSvg
includes/Plasma
includes/PopupApplet
includes/PushButton

View File

@ -45,7 +45,7 @@ Other important classes are:
for libplasma
- Plasma::PopupApplet: provides a simple way of implementing a Plasma::Applet
consisting of an icon that shows a popup when clicked
- Plasma::Svg and Plasma::PanelSvg: provides themable, cached SVGs
- Plasma::Svg and Plasma::FrameSvg: provides themable, cached SVGs
- Plasma::Wallpaper: provides pluggable backgrounds for containments
- Plasma::AppletScript, Plasma::DataEngineScript, Plasma::RunnerScript and
Plasma::ScriptEngine: provide scripting interfaces for plugins

View File

@ -58,7 +58,7 @@
#include <Solid/PowerManagement>
#include "configxml.h"
#include "configloader.h"
#include "containment.h"
#include "corona.h"
#include "dataenginemanager.h"
@ -68,10 +68,11 @@
#include "plasma.h"
#include "scripting/appletscript.h"
#include "svg.h"
#include "panelsvg.h"
#include "framesvg.h"
#include "popupapplet.h"
#include "theme.h"
#include "view.h"
#include "widgets/iconwidget.h"
#include "widgets/label.h"
#include "widgets/pushbutton.h"
#include "tooltipmanager.h"
@ -285,7 +286,7 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason)
QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this);
failureLayout->setContentsMargins(0, 0, 0, 0);
Icon *failureIcon = new Icon(this);
IconWidget *failureIcon = new IconWidget(this);
failureIcon->setIcon(KIcon("dialog-error"));
failureLayout->addItem(failureIcon);
@ -305,7 +306,7 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason)
setLayout(failureLayout);
resize(300, 250);
setMinimumSize(failureLayout->minimumSize());
d->background->resizePanel(geometry().size());
d->background->resizeFrame(geometry().size());
}
update();
@ -425,17 +426,17 @@ void AppletPrivate::cleanUpAndDelete()
}
}
if (configXml) {
configXml->setDefaults();
if (configLoader) {
configLoader->setDefaults();
}
q->scene()->removeItem(q);
q->deleteLater();
}
ConfigXml *Applet::configScheme() const
ConfigLoader *Applet::configScheme() const
{
return d->configXml;
return d->configLoader;
}
DataEngine *Applet::dataEngine(const QString &name) const
@ -656,7 +657,7 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
//Draw the standard background?
if ((hints & StandardBackground) || (hints & TranslucentBackground)) {
if (!d->background) {
d->background = new Plasma::PanelSvg(this);
d->background = new Plasma::FrameSvg(this);
}
if ((hints & TranslucentBackground) &&
@ -666,7 +667,7 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
d->background->setImagePath("widgets/background");
}
d->background->setEnabledBorders(Plasma::PanelSvg::AllBorders);
d->background->setEnabledBorders(Plasma::FrameSvg::AllBorders);
qreal left, top, right, bottom;
d->background->getMargins(left, top, right, bottom);
setContentsMargins(left, right, top, bottom);
@ -674,7 +675,7 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
if (minimumSize().expandedTo(fitSize) != minimumSize()) {
setMinimumSize(minimumSize().expandedTo(fitSize));
}
d->background->resizePanel(boundingRect().size());
d->background->resizeFrame(boundingRect().size());
} else if (d->background) {
qreal left, top, right, bottom;
d->background->getMargins(left, top, right, bottom);
@ -948,7 +949,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
formFactor() != Plasma::Vertical &&
formFactor() != Plasma::Horizontal) {
//kDebug() << "option rect is" << option->rect;
d->background->paintPanel(p);
d->background->paintFrame(p);
}
if (!d->failed) {
@ -1252,7 +1253,7 @@ void Applet::resizeEvent(QGraphicsSceneResizeEvent *event)
QGraphicsWidget::resizeEvent(event);
if (d->background) {
d->background->resizePanel(boundingRect().size());
d->background->resizeFrame(boundingRect().size());
}
updateConstraints(Plasma::SizeConstraint);
@ -1289,13 +1290,13 @@ void Applet::showConfigurationInterface()
}
const QString windowTitle = i18nc("@title:window", "%1 Settings", name());
if (d->package && d->configXml) {
if (d->package && d->configLoader) {
QString uiFile = d->package->filePath("mainconfigui");
if (uiFile.isEmpty()) {
return;
}
KConfigDialog *dialog = new KConfigDialog(0, dialogId, d->configXml);
KConfigDialog *dialog = new KConfigDialog(0, dialogId, d->configLoader);
dialog->setWindowTitle(windowTitle);
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
@ -1665,7 +1666,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
background(0),
script(0),
package(0),
configXml(0),
configLoader(0),
mainConfig(0),
pendingConstraints(NoConstraint),
aspectRatioMode(Plasma::KeepAspectRatio),
@ -1709,8 +1710,8 @@ AppletPrivate::~AppletPrivate()
script = 0;
delete package;
package = 0;
delete configXml;
configXml = 0;
delete configLoader;
configLoader = 0;
delete mainConfig;
mainConfig = 0;
}
@ -1795,8 +1796,8 @@ void AppletPrivate::setupScriptSupport()
QFile file(xmlPath);
// FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/
KConfigGroup config = q->config();
configXml = new ConfigXml(&config, &file);
QObject::connect(configXml, SIGNAL(configChanged()), q, SLOT(configChanged()));
configLoader = new ConfigLoader(&config, &file);
QObject::connect(configLoader, SIGNAL(configChanged()), q, SLOT(configChanged()));
}
if (!package->filePath("mainconfigui").isEmpty()) {

View File

@ -31,7 +31,7 @@
#include <KDE/KPluginInfo>
#include <KDE/KShortcut>
#include <plasma/configxml.h>
#include <plasma/configloader.h>
#include <plasma/packagestructure.h>
#include <plasma/plasma.h>
#include <plasma/animator.h>
@ -168,7 +168,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
*
* @return config skeleton object, or 0 if none
**/
ConfigXml *configScheme() const;
ConfigLoader *configScheme() const;
/**
* Loads the given DataEngine

View File

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "configxml.h"
#include "configloader.h"
#include <QColor>
#include <QFont>
@ -32,10 +32,10 @@
namespace Plasma
{
class ConfigXmlPrivate
class ConfigLoaderPrivate
{
public:
~ConfigXmlPrivate()
~ConfigLoaderPrivate()
{
qDeleteAll(bools);
qDeleteAll(strings);
@ -175,7 +175,7 @@ class ConfigXmlPrivate
return v;
}
void parse(ConfigXml *configXml, QIODevice *xml);
void parse(ConfigLoader *loader, QIODevice *xml);
QList<bool *> bools;
QList<QString *> strings;
@ -199,10 +199,10 @@ class ConfigXmlPrivate
QHash<QString, QString> keysToNames;
};
class ConfigXmlHandler : public QXmlDefaultHandler
class ConfigLoaderHandler : public QXmlDefaultHandler
{
public:
ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d);
ConfigLoaderHandler(ConfigLoader *config, ConfigLoaderPrivate *d);
bool startElement(const QString &namespaceURI, const QString &localName,
const QString &qName, const QXmlAttributes &atts);
bool endElement(const QString &namespaceURI, const QString &localName,
@ -213,8 +213,8 @@ private:
void addItem();
void resetState();
ConfigXml *m_config;
ConfigXmlPrivate *d;
ConfigLoader *m_config;
ConfigLoaderPrivate *d;
int m_min;
int m_max;
QString m_name;
@ -231,16 +231,16 @@ private:
bool m_inChoice;
};
void ConfigXmlPrivate::parse(ConfigXml *configXml, QIODevice *xml)
void ConfigLoaderPrivate::parse(ConfigLoader *loader, QIODevice *xml)
{
QXmlInputSource source(xml);
QXmlSimpleReader reader;
ConfigXmlHandler handler(configXml, this);
ConfigLoaderHandler handler(loader, this);
reader.setContentHandler(&handler);
reader.parse(&source, false);
}
ConfigXmlHandler::ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d)
ConfigLoaderHandler::ConfigLoaderHandler(ConfigLoader *config, ConfigLoaderPrivate *d)
: QXmlDefaultHandler(),
m_config(config),
d(d)
@ -248,13 +248,13 @@ ConfigXmlHandler::ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d)
resetState();
}
bool ConfigXmlHandler::startElement(const QString &namespaceURI, const QString &localName,
bool ConfigLoaderHandler::startElement(const QString &namespaceURI, const QString &localName,
const QString &qName, const QXmlAttributes &attrs)
{
Q_UNUSED(namespaceURI)
Q_UNUSED(qName)
// kDebug() << "ConfigXmlHandler::startElement(" << localName << qName;
// kDebug() << "ConfigLoaderHandler::startElement(" << localName << qName;
int numAttrs = attrs.count();
QString tag = localName.toLower();
if (tag == "group") {
@ -302,19 +302,19 @@ bool ConfigXmlHandler::startElement(const QString &namespaceURI, const QString &
return true;
}
bool ConfigXmlHandler::characters(const QString &ch)
bool ConfigLoaderHandler::characters(const QString &ch)
{
m_cdata.append(ch);
return true;
}
bool ConfigXmlHandler::endElement(const QString &namespaceURI,
bool ConfigLoaderHandler::endElement(const QString &namespaceURI,
const QString &localName, const QString &qName)
{
Q_UNUSED(namespaceURI)
Q_UNUSED(qName)
// kDebug() << "ConfigXmlHandler::endElement(" << localName << qName;
// kDebug() << "ConfigLoaderHandler::endElement(" << localName << qName;
QString tag = localName.toLower();
if (tag == "entry") {
addItem();
@ -346,7 +346,7 @@ bool ConfigXmlHandler::endElement(const QString &namespaceURI,
return true;
}
void ConfigXmlHandler::addItem()
void ConfigLoaderHandler::addItem()
{
if (m_name.isEmpty()) {
return;
@ -498,7 +498,7 @@ void ConfigXmlHandler::addItem()
}
}
void ConfigXmlHandler::resetState()
void ConfigLoaderHandler::resetState()
{
m_haveMin = false;
m_min = 0;
@ -514,16 +514,16 @@ void ConfigXmlHandler::resetState()
m_inChoice = false;
}
ConfigXml::ConfigXml(const QString &configFile, QIODevice *xml, QObject *parent)
ConfigLoader::ConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent)
: KConfigSkeleton(configFile, parent),
d(new ConfigXmlPrivate)
d(new ConfigLoaderPrivate)
{
d->parse(this, xml);
}
ConfigXml::ConfigXml(KSharedConfigPtr config, QIODevice *xml, QObject *parent)
ConfigLoader::ConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent)
: KConfigSkeleton(config, parent),
d(new ConfigXmlPrivate)
d(new ConfigLoaderPrivate)
{
d->parse(this, xml);
}
@ -531,9 +531,9 @@ ConfigXml::ConfigXml(KSharedConfigPtr config, QIODevice *xml, QObject *parent)
//FIXME: obviously this is broken and should be using the group as the root,
// but KConfigSkeleton does not currently support this. it will eventually though,
// at which point this can be addressed properly
ConfigXml::ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent)
ConfigLoader::ConfigLoader(const KConfigGroup *config, QIODevice *xml, QObject *parent)
: KConfigSkeleton(KSharedConfig::openConfig(config->config()->name()), parent),
d(new ConfigXmlPrivate)
d(new ConfigLoaderPrivate)
{
KConfigGroup group = config->parent();
d->baseGroup = config->name();
@ -544,22 +544,22 @@ ConfigXml::ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent
d->parse(this, xml);
}
ConfigXml::~ConfigXml()
ConfigLoader::~ConfigLoader()
{
delete d;
}
KConfigSkeletonItem *ConfigXml::findItem(const QString &group, const QString &key)
KConfigSkeletonItem *ConfigLoader::findItem(const QString &group, const QString &key)
{
return KConfigSkeleton::findItem(d->keysToNames[group + key]);
}
bool ConfigXml::hasGroup(const QString &group) const
bool ConfigLoader::hasGroup(const QString &group) const
{
return d->groups.contains(group);
}
QStringList ConfigXml::groupList() const
QStringList ConfigLoader::groupList() const
{
return d->groups;
}

View File

@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_CONFIGXML_H
#define PLASMA_CONFIGXML_H
#ifndef PLASMA_CONFIGLOADER_H
#define PLASMA_CONFIGLOADER_H
#include <KDE/KConfigGroup>
#include <KDE/KConfigSkeleton>
@ -27,7 +27,7 @@
#include <plasma/plasma_export.h>
/**
* @class ConfigXml plasma/configxml.h <Plasma/ConfigXml>
* @class ConfigLoader plasma/configloader.h <Plasma/ConfigLoader>
*
* @short A KConfigSkeleton that populates itself based on KConfigXT XML
*
@ -36,7 +36,7 @@
*
* \code
* QFile file(xmlFilePath);
* Plasma::ConfigXml appletConfig(configFilePath, &file);
* Plasma::ConfigLoader appletConfig(configFilePath, &file);
* \endcode
*
* Alternatively, any QIODevice may be used in place of QFile in the
@ -70,9 +70,9 @@
namespace Plasma
{
class ConfigXmlPrivate;
class ConfigLoaderPrivate;
class PLASMA_EXPORT ConfigXml : public KConfigSkeleton
class PLASMA_EXPORT ConfigLoader : public KConfigSkeleton
{
public:
/**
@ -83,7 +83,7 @@ public:
* @param xml the xml data; must be valid KConfigXT data
* @param parent optional QObject parent
**/
ConfigXml(const QString &configFile, QIODevice *xml, QObject *parent = 0);
ConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent = 0);
/**
* Creates a KConfigSkeleton populated using the definition found in
@ -93,7 +93,7 @@ public:
* @param xml the xml data; must be valid KConfigXT data
* @param parent optional QObject parent
**/
ConfigXml(KSharedConfigPtr config, QIODevice *xml, QObject *parent = 0);
ConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent = 0);
/**
* Creates a KConfigSkeleton populated using the definition found in
@ -103,8 +103,8 @@ public:
* @param xml the xml data; must be valid KConfigXT data
* @param parent optional QObject parent
**/
ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0);
~ConfigXml();
ConfigLoader(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0);
~ConfigLoader();
/**
* Finds the item for the given group and key.
@ -129,7 +129,7 @@ public:
QStringList groupList() const;
private:
ConfigXmlPrivate * const d;
ConfigLoaderPrivate * const d;
};
} // Plasma namespace

View File

@ -1115,14 +1115,14 @@ void Containment::enableAction(const QString &name, bool enable)
}
}
void Containment::addToolBoxTool(QAction *action)
void Containment::addToolBoxAction(QAction *action)
{
if (d->toolBox) {
d->toolBox->addTool(action);
}
}
void Containment::removeToolBoxTool(QAction *action)
void Containment::removeToolBoxAction(QAction *action)
{
if (d->toolBox) {
d->toolBox->removeTool(action);

View File

@ -32,8 +32,6 @@
#include <plasma/applet.h>
#include <plasma/animator.h>
#include "widgets/icon.h"
namespace Plasma
{
@ -240,12 +238,12 @@ class PLASMA_EXPORT Containment : public Applet
/**
* Add an action to the toolbox
*/
void addToolBoxTool(QAction *action);
void addToolBoxAction(QAction *action);
/**
* Remove an action from the toolbox
*/
void removeToolBoxTool(QAction *action);
void removeToolBoxAction(QAction *action);
/**
* Sets the open or closed state of the Containment's toolbox

View File

@ -41,7 +41,7 @@
#include "plasma/applet.h"
#include "plasma/extender.h"
#include "plasma/private/extender_p.h"
#include "plasma/panelsvg.h"
#include "plasma/framesvg.h"
#include "plasma/theme.h"
#ifdef Q_WS_X11
@ -78,7 +78,7 @@ public:
* Holds the background SVG, to be re-rendered when the cache is invalidated,
* for example by resizing the dialogue.
*/
Plasma::PanelSvg *background;
Plasma::FrameSvg *background;
QGraphicsView *view;
QGraphicsWidget *widget;
Dialog::ResizeCorners resizeCorners;
@ -98,27 +98,27 @@ void DialogPrivate::themeUpdated()
if (extender) {
switch (extender->d->applet->location()) {
case BottomEdge:
background->setEnabledBorders(PanelSvg::LeftBorder | PanelSvg::TopBorder
| PanelSvg::RightBorder);
background->setEnabledBorders(FrameSvg::LeftBorder | FrameSvg::TopBorder
| FrameSvg::RightBorder);
q->setContentsMargins(0, topHeight, 0, 0);
break;
case TopEdge:
background->setEnabledBorders(PanelSvg::LeftBorder | PanelSvg::BottomBorder
| PanelSvg::RightBorder);
background->setEnabledBorders(FrameSvg::LeftBorder | FrameSvg::BottomBorder
| FrameSvg::RightBorder);
q->setContentsMargins(0, 0, 0, bottomHeight);
break;
case LeftEdge:
background->setEnabledBorders(PanelSvg::TopBorder | PanelSvg::BottomBorder
| PanelSvg::RightBorder);
background->setEnabledBorders(FrameSvg::TopBorder | FrameSvg::BottomBorder
| FrameSvg::RightBorder);
q->setContentsMargins(0, topHeight, 0, bottomHeight);
break;
case RightEdge:
background->setEnabledBorders(PanelSvg::TopBorder | PanelSvg::BottomBorder
| PanelSvg::LeftBorder);
background->setEnabledBorders(FrameSvg::TopBorder | FrameSvg::BottomBorder
| FrameSvg::LeftBorder);
q->setContentsMargins(0, topHeight, 0, bottomHeight);
break;
default:
background->setEnabledBorders(PanelSvg::AllBorders);
background->setEnabledBorders(FrameSvg::AllBorders);
q->setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight);
}
} else {
@ -167,10 +167,10 @@ Dialog::Dialog(QWidget *parent, Qt::WindowFlags f)
d(new DialogPrivate(this))
{
setWindowFlags(Qt::FramelessWindowHint);
d->background = new PanelSvg(this);
d->background = new FrameSvg(this);
d->background->setImagePath("dialogs/background");
d->background->setEnabledBorders(PanelSvg::AllBorders);
d->background->resizePanel(size());
d->background->setEnabledBorders(FrameSvg::AllBorders);
d->background->resizeFrame(size());
connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
@ -192,7 +192,7 @@ void Dialog::paintEvent(QPaintEvent *e)
p.setClipRect(e->rect());
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(rect(), Qt::transparent);
d->background->paintPanel(&p);
d->background->paintFrame(&p);
//we set the resize handlers
d->resizeAreas.clear();
@ -315,7 +315,7 @@ void Dialog::mouseReleaseEvent(QMouseEvent *event)
void Dialog::resizeEvent(QResizeEvent *e)
{
d->background->resizePanel(e->size());
d->background->resizeFrame(e->size());
setMask(d->background->mask());

View File

@ -27,7 +27,7 @@
#include "containment.h"
#include "corona.h"
#include "extenderitem.h"
#include "panelsvg.h"
#include "framesvg.h"
#include "popupapplet.h"
#include "svg.h"
#include "widgets/label.h"
@ -274,16 +274,16 @@ void Extender::itemHoverLeaveEvent(ExtenderItem *item)
}
}
PanelSvg::EnabledBorders Extender::enabledBordersForItem(ExtenderItem *item) const
FrameSvg::EnabledBorders Extender::enabledBordersForItem(ExtenderItem *item) const
{
ExtenderItem *topItem = dynamic_cast<ExtenderItem*>(d->layout->itemAt(0));
ExtenderItem *bottomItem = dynamic_cast<ExtenderItem*>(d->layout->itemAt(d->layout->count() - 1));
if (d->appearance == TopDownStacked && bottomItem != item) {
return PanelSvg::LeftBorder | PanelSvg::BottomBorder | PanelSvg::RightBorder;
return FrameSvg::LeftBorder | FrameSvg::BottomBorder | FrameSvg::RightBorder;
} else if (d->appearance == BottomUpStacked && topItem != item) {
return PanelSvg::LeftBorder | PanelSvg::TopBorder | PanelSvg::RightBorder;
return FrameSvg::LeftBorder | FrameSvg::TopBorder | FrameSvg::RightBorder;
} else if (d->appearance != NoBorders) {
return PanelSvg::LeftBorder | PanelSvg::RightBorder;
return FrameSvg::LeftBorder | FrameSvg::RightBorder;
} else {
return 0;
}

View File

@ -22,7 +22,7 @@
#include <QtGui/QGraphicsWidget>
#include "plasma/panelsvg.h"
#include "plasma/framesvg.h"
#include "plasma/plasma_export.h"
namespace Plasma
@ -204,7 +204,7 @@ class PLASMA_EXPORT Extender : public QGraphicsWidget
* @param item the item for which it's position or extender has changed.
* @return the borders that have to be enabled on it's background.
*/
virtual PanelSvg::EnabledBorders enabledBordersForItem(ExtenderItem *item) const;
virtual FrameSvg::EnabledBorders enabledBordersForItem(ExtenderItem *item) const;
/**
* Reimplemented from QGraphicsWidget

View File

@ -39,7 +39,7 @@
#include "corona.h"
#include "dialog.h"
#include "extender.h"
#include "panelsvg.h"
#include "framesvg.h"
#include "popupapplet.h"
#include "theme.h"
#include "view.h"
@ -48,6 +48,8 @@
#include "private/extender_p.h"
#include "private/extenderitem_p.h"
#include "widgets/iconwidget.h"
namespace Plasma
{
@ -79,12 +81,12 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
dg.writeEntry("sourceAppletId", hostExtender->d->applet->id());
dg.writeEntry("sourceIconName", hostExtender->d->applet->icon());
d->sourceApplet = hostExtender->d->applet;
d->collapseIcon = new Icon(KIcon(hostExtender->d->applet->icon()), "", this);
d->collapseIcon = new IconWidget(KIcon(hostExtender->d->applet->icon()), "", this);
} else {
//The item already exists.
d->name = dg.readEntry("extenderItemName", "");
d->title = dg.readEntry("extenderTitle", "");
d->collapseIcon = new Icon(KIcon(dg.readEntry("extenderIconName", "")), "", this);
d->collapseIcon = new IconWidget(KIcon(dg.readEntry("extenderIconName", "")), "", this);
//Find the sourceapplet.
Corona *corona = hostExtender->d->applet->containment()->corona();
@ -108,7 +110,6 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
d->toolboxLayout = new QGraphicsLinearLayout(d->toolbox);
d->toolbox->setLayout(d->toolboxLayout);
//set the extender we want to move to.
setExtender(hostExtender);
@ -403,14 +404,14 @@ void ExtenderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
painter->setRenderHint(QPainter::TextAntialiasing, true);
painter->setRenderHint(QPainter::Antialiasing, true);
if (d->background->enabledBorders() != (PanelSvg::LeftBorder | PanelSvg::RightBorder) &&
if (d->background->enabledBorders() != (FrameSvg::LeftBorder | FrameSvg::RightBorder) &&
d->background->enabledBorders()) {
//Don't paint if only the left and right borders are enabled, we only use the left and right
//border in this situation to set the correct margins on this item.
d->background->paintPanel(painter, QPointF(0, 0));
d->background->paintFrame(painter, QPointF(0, 0));
}
d->dragger->paintPanel(painter, QPointF(d->bgLeft, d->bgTop));
d->dragger->paintFrame(painter, QPointF(d->bgLeft, d->bgTop));
//We don't need to paint a title if there is no title.
if (d->title.isEmpty()) {
@ -457,12 +458,12 @@ void ExtenderItem::resizeEvent(QGraphicsSceneResizeEvent *event)
qreal height = event->newSize().height();
//resize the dragger
d->dragger->resizePanel(QSizeF(width - d->bgLeft - d->bgRight,
d->dragger->resizeFrame(QSizeF(width - d->bgLeft - d->bgRight,
d->dragger->elementSize("hint-preferred-icon-size").height() +
d->dragTop + d->dragBottom));
//resize the applet background
d->background->resizePanel(event->newSize());
d->background->resizeFrame(event->newSize());
//resize the widget
if (d->widget && d->widget->isWidget()) {
@ -509,7 +510,7 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
return;
}
if (d->background->enabledBorders() != PanelSvg::AllBorders) {
if (d->background->enabledBorders() != FrameSvg::AllBorders) {
d->themeChanged();
}
@ -722,8 +723,8 @@ ExtenderItemPrivate::ExtenderItemPrivate(ExtenderItem *extenderItem, Extender *h
previousTargetExtender(0),
extender(hostExtender),
sourceApplet(0),
dragger(new PanelSvg(extenderItem)),
background(new PanelSvg(extenderItem)),
dragger(new FrameSvg(extenderItem)),
background(new FrameSvg(extenderItem)),
collapseIcon(0),
title(QString()),
mousePressed(false),
@ -814,7 +815,7 @@ void ExtenderItemPrivate::updateToolBox()
//add the actions that are actually set to visible.
foreach (QAction *action, actions) {
if (action->isVisible()) {
Icon *icon = new Icon(q);
IconWidget *icon = new IconWidget(q);
icon->setAction(action);
QSizeF iconSize = icon->sizeFromIconSize(iconHeight);
icon->setMinimumSize(iconSize);
@ -825,7 +826,7 @@ void ExtenderItemPrivate::updateToolBox()
//add the returntosource icon if we are detached, and have a source applet.
if (q->isDetached() && sourceApplet) {
Icon *returnToSource = new Icon(q);
IconWidget *returnToSource = new IconWidget(q);
returnToSource->setSvg("widgets/configuration-icons", "return-to-source");
QSizeF iconSize = returnToSource->sizeFromIconSize(iconHeight);
returnToSource->setMinimumSize(iconSize);
@ -912,7 +913,7 @@ void ExtenderItemPrivate::themeChanged()
background->setImagePath("widgets/extender-background");
if (mousePressed) {
background->setEnabledBorders(PanelSvg::AllBorders);
background->setEnabledBorders(FrameSvg::AllBorders);
} else {
background->setEnabledBorders(extender->enabledBordersForItem(q));
}

676
framesvg.cpp Normal file
View File

@ -0,0 +1,676 @@
/*
* Copyright 2008 by Aaron Seigo <aseigo@kde.org>
* Copyright 2008 Marco Martin <notmart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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.
*/
#include "framesvg.h"
#include <QPainter>
#include <QSize>
#include <QBitmap>
#include <KDebug>
#include <plasma/theme.h>
namespace Plasma
{
class FrameData
{
public:
FrameData()
: enabledBorders(FrameSvg::AllBorders),
frameSize(-1,-1)
{
}
FrameData(const FrameData &other)
: enabledBorders(other.enabledBorders),
frameSize(other.frameSize)
{
}
~FrameData()
{
}
FrameSvg::EnabledBorders enabledBorders;
QPixmap cachedBackground;
QBitmap cachedMask;
QSizeF frameSize;
//measures
int topHeight;
int leftWidth;
int rightWidth;
int bottomHeight;
//margins, are equal to the measures by default
int topMargin;
int leftMargin;
int rightMargin;
int bottomMargin;
//size of the svg where the size of the "center"
//element is contentWidth x contentHeight
bool noBorderPadding : 1;
bool stretchBorders : 1;
bool tileCenter : 1;
};
class FrameSvgPrivate
{
public:
FrameSvgPrivate(FrameSvg *psvg)
: q(psvg),
cacheAll(false)
{
}
~FrameSvgPrivate()
{
qDeleteAll(frames);
frames.clear();
}
void generateBackground(FrameData *frame);
void updateSizes();
void updateNeeded();
void updateAndSignalSizes();
Location location;
QString prefix;
FrameSvg *q;
bool cacheAll : 1;
QHash<QString, FrameData*> frames;
};
FrameSvg::FrameSvg(QObject *parent)
: Svg(parent),
d(new FrameSvgPrivate(this))
{
connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
d->frames.insert(QString(), new FrameData());
}
FrameSvg::~FrameSvg()
{
delete d;
}
void FrameSvg::setImagePath(const QString &path)
{
if (path == imagePath()) {
return;
}
Svg::setImagePath(path);
setContainsMultipleImages(true);
clearCache();
d->updateAndSignalSizes();
}
void FrameSvg::setEnabledBorders(const EnabledBorders borders)
{
if (borders == d->frames[d->prefix]->enabledBorders) {
return;
}
d->frames[d->prefix]->enabledBorders = borders;
d->updateAndSignalSizes();
}
FrameSvg::EnabledBorders FrameSvg::enabledBorders() const
{
QHash<QString, FrameData*>::const_iterator it = d->frames.constFind(d->prefix);
if (it != d->frames.constEnd()) {
return it.value()->enabledBorders;
} else {
return NoBorder;
}
}
void FrameSvg::setElementPrefix(Plasma::Location location)
{
switch (location) {
case TopEdge:
setElementPrefix("north");
break;
case BottomEdge:
setElementPrefix("south");
break;
case LeftEdge:
setElementPrefix("west");
break;
case RightEdge:
setElementPrefix("east");
break;
default:
setElementPrefix(QString());
break;
}
d->location = location;
}
void FrameSvg::setElementPrefix(const QString & prefix)
{
const QString oldPrefix(d->prefix);
if (!hasElement(prefix + "-center")) {
d->prefix.clear();
} else {
d->prefix = prefix;
if (!d->prefix.isEmpty()) {
d->prefix += '-';
}
}
if (oldPrefix == d->prefix && d->frames[oldPrefix]) {
return;
}
if (!d->frames.contains(d->prefix)) {
d->frames.insert(d->prefix, new FrameData(*(d->frames[oldPrefix])));
d->updateSizes();
}
if (!d->cacheAll) {
delete d->frames[oldPrefix];
d->frames.remove(oldPrefix);
}
d->location = Floating;
}
bool FrameSvg::hasElementPrefix(const QString & prefix) const
{
//for now it simply checks if a center element exists,
//because it could make sense for certain themes to not have all the elements
if (prefix.isEmpty()) {
return hasElement("center");
} else {
return hasElement(prefix + "-center");
}
}
bool FrameSvg::hasElementPrefix(Plasma::Location location) const
{
switch (location) {
case TopEdge:
return hasElementPrefix("north");
break;
case BottomEdge:
return hasElementPrefix("south");
break;
case LeftEdge:
return hasElementPrefix("west");
break;
case RightEdge:
return hasElementPrefix("east");
break;
default:
return hasElementPrefix(QString());
break;
}
}
QString FrameSvg::prefix()
{
if (d->prefix.isEmpty()) {
return d->prefix;
}
return d->prefix.left(d->prefix.size() - 1);
}
void FrameSvg::resizeFrame(const QSizeF &size)
{
if (size.isEmpty()) {
kWarning() << "Invalid size" << size;
return;
}
if (size == d->frames[d->prefix]->frameSize) {
return;
}
d->updateSizes();
d->frames[d->prefix]->frameSize = size;
}
QSizeF FrameSvg::frameSize() const
{
QHash<QString, FrameData*>::const_iterator it = d->frames.constFind(d->prefix);
if (it != d->frames.constEnd()) {
return it.value()->frameSize;
} else {
return QSize(-1, -1);
}
}
qreal FrameSvg::marginSize(const Plasma::MarginEdge edge) const
{
if (d->frames[d->prefix]->noBorderPadding) {
return .0;
}
switch (edge) {
case Plasma::TopMargin:
return d->frames[d->prefix]->topMargin;
break;
case Plasma::LeftMargin:
return d->frames[d->prefix]->leftMargin;
break;
case Plasma::RightMargin:
return d->frames[d->prefix]->rightMargin;
break;
//Plasma::BottomMargin
default:
return d->frames[d->prefix]->bottomMargin;
break;
}
}
void FrameSvg::getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
{
FrameData *frame = d->frames[d->prefix];
if (!frame || frame->noBorderPadding) {
left = top = right = bottom = 0;
return;
}
top = frame->topMargin;
left = frame->leftMargin;
right = frame->rightMargin;
bottom = frame->bottomMargin;
}
QRectF FrameSvg::contentsRect() const
{
QSizeF size(frameSize());
if (size.isValid()) {
QRectF rect(QPointF(0, 0), size);
FrameData *frame = d->frames[d->prefix];
return rect.adjusted(frame->leftMargin, frame->topMargin,
-frame->rightMargin, -frame->bottomMargin);
} else {
return QRectF();
}
}
QBitmap FrameSvg::mask() const
{
FrameData *frame = d->frames[d->prefix];
if (!frame->cachedMask) {
if (frame->cachedBackground.isNull()) {
d->generateBackground(frame);
if (frame->cachedBackground.isNull()) {
return QBitmap();
}
}
frame->cachedMask = QBitmap(frame->cachedBackground.alphaChannel().createMaskFromColor(Qt::black));
}
return frame->cachedMask;
}
void FrameSvg::setCacheAllRenderedFrames(bool cache)
{
if (d->cacheAll && !cache) {
clearCache();
}
d->cacheAll = cache;
}
bool FrameSvg::cacheAllRenderedFrames() const
{
return d->cacheAll;
}
void FrameSvg::clearCache()
{
FrameData *frame = d->frames[d->prefix];
// delete all the frames that aren't this one
QMutableHashIterator<QString, FrameData*> it(d->frames);
while (it.hasNext()) {
FrameData *p = it.next().value();
if (frame != p) {
delete p;
it.remove();
}
}
}
QPixmap FrameSvg::framePixmap()
{
FrameData *frame = d->frames[d->prefix];
if (frame->cachedBackground.isNull()) {
d->generateBackground(frame);
if (frame->cachedBackground.isNull()) {
return QPixmap();
}
}
return frame->cachedBackground;
}
void FrameSvg::paintFrame(QPainter *painter, const QRectF &target, const QRectF &source)
{
FrameData *frame = d->frames[d->prefix];
if (frame->cachedBackground.isNull()) {
d->generateBackground(frame);
if (frame->cachedBackground.isNull()) {
return;
}
}
painter->drawPixmap(target, frame->cachedBackground, source.isValid() ? source : target);
}
void FrameSvg::paintFrame(QPainter *painter, const QPointF &pos)
{
FrameData *frame = d->frames[d->prefix];
if (frame->cachedBackground.isNull()) {
d->generateBackground(frame);
if (frame->cachedBackground.isNull()) {
return;
}
}
painter->drawPixmap(pos, frame->cachedBackground);
}
void FrameSvgPrivate::generateBackground(FrameData *frame)
{
if (!frame->cachedBackground.isNull()) {
return;
}
QString id = QString::fromLatin1("%5_%4_%3_%2_%1_").
arg(frame->enabledBorders).arg(frame->frameSize.width()).arg(frame->frameSize.height()).arg(prefix).arg(q->imagePath());
Theme *theme = Theme::defaultTheme();
if (theme->findInCache(id, frame->cachedBackground) && !frame->cachedBackground.isNull()) {
return;
}
//kDebug() << "generating background";
const int topWidth = q->elementSize(prefix + "top").width();
const int leftHeight = q->elementSize(prefix + "left").height();
const int topOffset = 0;
const int leftOffset = 0;
if (!frame->frameSize.isValid()) {
kWarning() << "Invalid frame size" << frame->frameSize;
return;
}
const int contentWidth = frame->frameSize.width() - frame->leftWidth - frame->rightWidth;
const int contentHeight = frame->frameSize.height() - frame->topHeight - frame->bottomHeight;
int contentTop = 0;
int contentLeft = 0;
int rightOffset = contentWidth;
int bottomOffset = contentHeight;
frame->cachedBackground = QPixmap(frame->leftWidth + contentWidth + frame->rightWidth,
frame->topHeight + contentHeight + frame->bottomHeight);
frame->cachedBackground.fill(Qt::transparent);
QPainter p(&frame->cachedBackground);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.setRenderHint(QPainter::SmoothPixmapTransform);
//if we must stretch the center or the borders we compute how much we will have to stretch
//the svg to get the desired element sizes
QSizeF scaledContentSize(0, 0);
if (q->elementSize(prefix + "center").width() > 0 &&
q->elementSize(prefix + "center").height() > 0 &&
(!frame->tileCenter || frame->stretchBorders)) {
scaledContentSize = QSizeF(contentWidth * ((qreal)q->size().width() / (qreal)q->elementSize(prefix + "center").width()),
contentHeight * ((qreal)q->size().height() / (qreal)q->elementSize(prefix + "center").height()));
}
//CENTER
if (frame->tileCenter) {
if (contentHeight > 0 && contentWidth > 0) {
int centerTileHeight;
int centerTileWidth;
centerTileHeight = q->elementSize(prefix + "center").height();
centerTileWidth = q->elementSize(prefix + "center").width();
QPixmap center(centerTileWidth, centerTileHeight);
center.fill(Qt::transparent);
{
QPainter centerPainter(&center);
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&centerPainter, QRect(QPoint(0, 0), q->elementSize(prefix + "center")), prefix + "center");
}
p.drawTiledPixmap(QRect(frame->leftWidth, frame->topHeight,
contentWidth, contentHeight), center);
}
} else {
if (contentHeight > 0 && contentWidth > 0) {
q->paint(&p, QRect(frame->leftWidth, frame->topHeight,
contentWidth, contentHeight),
prefix + "center");
}
}
// Corners
if (q->hasElement(prefix + "top") && frame->enabledBorders & FrameSvg::TopBorder) {
contentTop = frame->topHeight;
bottomOffset += frame->topHeight;
if (q->hasElement(prefix + "topleft") && frame->enabledBorders & FrameSvg::LeftBorder) {
q->paint(&p, QRect(leftOffset, topOffset, frame->leftWidth, frame->topHeight), prefix + "topleft");
contentLeft = frame->leftWidth;
rightOffset = contentWidth + frame->leftWidth;
}
if (q->hasElement(prefix + "topright") && frame->enabledBorders & FrameSvg::RightBorder) {
q->paint(&p, QRect(rightOffset, topOffset, frame->rightWidth, frame->topHeight), prefix + "topright");
}
}
if (q->hasElement(prefix + "bottom") && frame->enabledBorders & FrameSvg::BottomBorder) {
if (q->hasElement(prefix + "bottomleft") && frame->enabledBorders & FrameSvg::LeftBorder) {
q->paint(&p, QRect(leftOffset, bottomOffset, frame->leftWidth, frame->bottomHeight), prefix + "bottomleft");
contentLeft = frame->leftWidth;
rightOffset = contentWidth + frame->leftWidth;
}
if (q->hasElement(prefix + "bottomright") && frame->enabledBorders & FrameSvg::RightBorder) {
q->paint(&p, QRect(rightOffset, bottomOffset, frame->rightWidth, frame->bottomHeight), prefix + "bottomright");
}
}
// Sides
if (frame->stretchBorders) {
if (frame->enabledBorders & FrameSvg::LeftBorder || frame->enabledBorders & FrameSvg::RightBorder) {
if (q->hasElement(prefix + "left") &&
frame->enabledBorders & FrameSvg::LeftBorder) {
q->paint(&p, QRect(leftOffset, contentTop, frame->leftWidth, contentHeight), prefix + "left");
}
if (q->hasElement(prefix + "right") &&
frame->enabledBorders & FrameSvg::RightBorder) {
q->paint(&p, QRect(rightOffset, contentTop, frame->rightWidth, contentHeight), prefix + "right");
}
}
if (frame->enabledBorders & FrameSvg::TopBorder ||
frame->enabledBorders & FrameSvg::BottomBorder) {
if (q->hasElement(prefix + "top") &&
frame->enabledBorders & FrameSvg::TopBorder) {
q->paint(&p, QRect(contentLeft, topOffset, contentWidth, frame->topHeight), prefix + "top");
}
if (q->hasElement(prefix + "bottom") &&
frame->enabledBorders & FrameSvg::BottomBorder) {
q->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, frame->bottomHeight), prefix + "bottom");
}
}
} else {
if (q->hasElement(prefix + "left") &&
frame->enabledBorders & FrameSvg::LeftBorder) {
QPixmap left(frame->leftWidth, leftHeight);
left.fill(Qt::transparent);
QPainter sidePainter(&left);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), left.size()), prefix + "left");
p.drawTiledPixmap(QRect(leftOffset, contentTop, frame->leftWidth, contentHeight), left);
}
if (q->hasElement(prefix + "right") && frame->enabledBorders & FrameSvg::RightBorder) {
QPixmap right(frame->rightWidth, leftHeight);
right.fill(Qt::transparent);
QPainter sidePainter(&right);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), right.size()), prefix + "right");
p.drawTiledPixmap(QRect(rightOffset, contentTop, frame->rightWidth, contentHeight), right);
}
if (q->hasElement(prefix + "top") && frame->enabledBorders & FrameSvg::TopBorder) {
QPixmap top(topWidth, frame->topHeight);
top.fill(Qt::transparent);
QPainter sidePainter(&top);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), top.size()), prefix + "top");
p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, frame->topHeight), top);
}
if (q->hasElement(prefix + "bottom") && frame->enabledBorders & FrameSvg::BottomBorder) {
QPixmap bottom(topWidth, frame->bottomHeight);
bottom.fill(Qt::transparent);
QPainter sidePainter(&bottom);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), bottom.size()), prefix + "bottom");
p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, frame->bottomHeight), bottom);
}
}
theme->insertIntoCache(id, frame->cachedBackground);
}
void FrameSvgPrivate::updateSizes()
{
//kDebug() << "!!!!!!!!!!!!!!!!!!!!!! updating sizes" << prefix;
FrameData *frame = frames[prefix];
Q_ASSERT(frame);
frame->cachedBackground = QPixmap();
frame->cachedMask = QPixmap();
if (frame->enabledBorders & FrameSvg::TopBorder) {
frame->topHeight = q->elementSize(prefix + "top").height();
if (q->hasElement(prefix + "hint-top-margin")) {
frame->topMargin = q->elementSize(prefix + "hint-top-margin").height();
} else {
frame->topMargin = frame->topHeight;
}
} else {
frame->topMargin = frame->topHeight = 0;
}
if (frame->enabledBorders & FrameSvg::LeftBorder) {
frame->leftWidth = q->elementSize(prefix + "left").width();
if (q->hasElement(prefix + "hint-left-margin")) {
frame->leftMargin = q->elementSize(prefix + "hint-left-margin").height();
} else {
frame->leftMargin = frame->leftWidth;
}
} else {
frame->leftMargin = frame->leftWidth = 0;
}
if (frame->enabledBorders & FrameSvg::RightBorder) {
frame->rightWidth = q->elementSize(prefix + "right").width();
if (q->hasElement(prefix + "hint-right-margin")) {
frame->rightMargin = q->elementSize(prefix + "hint-right-margin").height();
} else {
frame->rightMargin = frame->rightWidth;
}
} else {
frame->rightMargin = frame->rightWidth = 0;
}
if (frame->enabledBorders & FrameSvg::BottomBorder) {
frame->bottomHeight = q->elementSize(prefix + "bottom").height();
if (q->hasElement(prefix + "hint-bottom-margin")) {
frame->bottomMargin = q->elementSize(prefix + "hint-bottom-margin").height();
} else {
frame->bottomMargin = frame->bottomHeight;
}
} else {
frame->bottomMargin = frame->bottomHeight = 0;
}
//since it's rectangular, topWidth and bottomWidth must be the same
frame->tileCenter = q->hasElement("hint-tile-center");
frame->noBorderPadding = q->hasElement("hint-no-border-padding");
frame->stretchBorders = q->hasElement("hint-stretch-borders");
}
void FrameSvgPrivate::updateNeeded()
{
q->clearCache();
updateSizes();
}
void FrameSvgPrivate::updateAndSignalSizes()
{
updateSizes();
emit q->repaintNeeded();
}
} // Plasma namespace
#include "framesvg.moc"

View File

@ -18,8 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_PANELSVG_H
#define PLASMA_PANELSVG_H
#ifndef PLASMA_FRAMESVG_H
#define PLASMA_FRAMESVG_H
#include <QtCore/QObject>
#include <QtGui/QPixmap>
@ -41,10 +41,10 @@ class QMatrix;
namespace Plasma
{
class PanelSvgPrivate;
class FrameSvgPrivate;
/**
* @class PanelSvg plasma/panelsvg.h <Plasma/PanelSvg>
* @class FrameSvg plasma/framesvg.h <Plasma/FrameSvg>
*
* @short Provides an SVG with borders.
*
@ -52,7 +52,7 @@ class PanelSvgPrivate;
* its aspect ratio, such as a dialog, simply scaling a single image
* may not be enough.
*
* PanelSvg allows SVGs to provide several elements for borders as well
* FrameSvg allows SVGs to provide several elements for borders as well
* as a central element, each of which are scaled individually. These
* elements should be named
*
@ -73,7 +73,7 @@ class PanelSvgPrivate;
*
* @see Plamsa::Svg
**/
class PLASMA_EXPORT PanelSvg : public Svg
class PLASMA_EXPORT FrameSvg : public Svg
{
Q_OBJECT
public:
@ -91,7 +91,7 @@ class PLASMA_EXPORT PanelSvg : public Svg
Q_DECLARE_FLAGS(EnabledBorders, EnabledBorder)
/**
* Constructs a new PanelSvg that paints the proper named subelements
* Constructs a new FrameSvg that paints the proper named subelements
* as borders. It may also be used as a regular Plasma::Svg object
* for direct access to elements in the Svg.
*
@ -99,8 +99,8 @@ class PLASMA_EXPORT PanelSvg : public Svg
*
* @related Plasma::Theme
*/
explicit PanelSvg(QObject *parent = 0);
~PanelSvg();
explicit FrameSvg(QObject *parent = 0);
~FrameSvg();
/**
* Loads a new Svg
@ -121,15 +121,15 @@ class PLASMA_EXPORT PanelSvg : public Svg
EnabledBorders enabledBorders() const;
/**
* Resize the panel maintaining the same border size
* @arg size the new size of the panel
* Resize the frame maintaining the same border size
* @arg size the new size of the frame
*/
void resizePanel(const QSizeF &size);
void resizeFrame(const QSizeF &size);
/**
* @returns the size of the panel
* @returns the size of the frame
*/
QSizeF panelSize() const;
QSizeF frameSize() const;
/**
* Returns the margin size given the margin edge we want
@ -178,7 +178,7 @@ class PLASMA_EXPORT PanelSvg : public Svg
/**
* @return true if the svg has the necessary elements with the given prefix
* to draw a panel
* to draw a frame
* @arg prefix the given prefix we want to check if drawable
*/
bool hasElementPrefix(const QString & prefix) const;
@ -188,13 +188,13 @@ class PLASMA_EXPORT PanelSvg : public Svg
* hasElementPrefix("north"), hasElementPrefix("south")
* hasElementPrefix("west") and hasElementPrefix("east")
* @return true if the svg has the necessary elements with the given prefix
* to draw a panel.
* to draw a frame.
* @arg location the given prefix we want to check if drawable
*/
bool hasElementPrefix(Plasma::Location location) const;
/**
* Returns the prefix for SVG elements of the PanelSvg
* Returns the prefix for SVG elements of the FrameSvg
* @return the prefix
*/
QString prefix();
@ -209,12 +209,12 @@ class PLASMA_EXPORT PanelSvg : public Svg
* Sets whether saving all the rendered prefixes in a cache or not
* @arg cache if use the cache or not
*/
void setCacheAllRenderedPanels(bool cache);
void setCacheAllRenderedFrames(bool cache);
/**
* @return if all the different prefixes should be kept in a cache when rendered
*/
bool cacheAllRenderedPanels() const;
bool cacheAllRenderedFrames() const;
/**
* Deletes the internal cache freeing memory: use this if you want to switch the rendered
@ -230,7 +230,7 @@ class PLASMA_EXPORT PanelSvg : public Svg
* string for the whole SVG (the default)
* @return a QPixmap of the rendered SVG
*/
Q_INVOKABLE QPixmap panelPixmap();
Q_INVOKABLE QPixmap framePixmap();
/**
* Paints the loaded SVG with the elements that represents the border
@ -238,7 +238,7 @@ class PLASMA_EXPORT PanelSvg : public Svg
* @arg target the target rectangle on the paint device
* @arg source the portion rectangle of the source image
*/
Q_INVOKABLE void paintPanel(QPainter *painter, const QRectF &target,
Q_INVOKABLE void paintFrame(QPainter *painter, const QRectF &target,
const QRectF &source = QRectF());
/**
@ -247,10 +247,10 @@ class PLASMA_EXPORT PanelSvg : public Svg
* @arg painter the QPainter to use
* @arg pos where to paint the svg
*/
Q_INVOKABLE void paintPanel(QPainter *painter, const QPointF &pos = QPointF(0, 0));
Q_INVOKABLE void paintFrame(QPainter *painter, const QPointF &pos = QPointF(0, 0));
private:
PanelSvgPrivate *const d;
FrameSvgPrivate *const d;
Q_PRIVATE_SLOT(d, void updateSizes())
Q_PRIVATE_SLOT(d, void updateNeeded())
@ -258,6 +258,6 @@ class PLASMA_EXPORT PanelSvg : public Svg
} // Plasma namespace
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::PanelSvg::EnabledBorders)
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::FrameSvg::EnabledBorders)
#endif // multiple inclusion guard

1
includes/ConfigLoader Normal file
View File

@ -0,0 +1 @@
#include "../../plasma/configloader.h"

View File

@ -1 +0,0 @@
#include "../../plasma/configxml.h"

View File

@ -1 +0,0 @@
#include "../../plasma/widgets/flash.h"

1
includes/FlashingLabel Normal file
View File

@ -0,0 +1 @@
#include "../../plasma/widgets/flashinglabel.h"

1
includes/FrameSvg Normal file
View File

@ -0,0 +1 @@
#include "../../plasma/framesvg.h"

View File

@ -1 +0,0 @@
#include "../../plasma/widgets/icon.h"

1
includes/IconWidget Normal file
View File

@ -0,0 +1 @@
#include "../../plasma/widgets/iconwidget.h"

View File

@ -1 +0,0 @@
#include "../../plasma/panelsvg.h"

View File

@ -1,676 +0,0 @@
/*
* Copyright 2008 by Aaron Seigo <aseigo@kde.org>
* Copyright 2008 Marco Martin <notmart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, 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 Library 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.
*/
#include "panelsvg.h"
#include <QPainter>
#include <QSize>
#include <QBitmap>
#include <KDebug>
#include <plasma/theme.h>
namespace Plasma
{
class PanelData
{
public:
PanelData()
: enabledBorders(PanelSvg::AllBorders),
panelSize(-1,-1)
{
}
PanelData(const PanelData &other)
: enabledBorders(other.enabledBorders),
panelSize(other.panelSize)
{
}
~PanelData()
{
}
PanelSvg::EnabledBorders enabledBorders;
QPixmap cachedBackground;
QBitmap cachedMask;
QSizeF panelSize;
//measures
int topHeight;
int leftWidth;
int rightWidth;
int bottomHeight;
//margins, are equal to the measures by default
int topMargin;
int leftMargin;
int rightMargin;
int bottomMargin;
//size of the svg where the size of the "center"
//element is contentWidth x contentHeight
bool noBorderPadding : 1;
bool stretchBorders : 1;
bool tileCenter : 1;
};
class PanelSvgPrivate
{
public:
PanelSvgPrivate(PanelSvg *psvg)
: q(psvg),
cacheAll(false)
{
}
~PanelSvgPrivate()
{
qDeleteAll(panels);
panels.clear();
}
void generateBackground(PanelData *panel);
void updateSizes();
void updateNeeded();
void updateAndSignalSizes();
Location location;
QString prefix;
PanelSvg *q;
bool cacheAll : 1;
QHash<QString, PanelData*> panels;
};
PanelSvg::PanelSvg(QObject *parent)
: Svg(parent),
d(new PanelSvgPrivate(this))
{
connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
d->panels.insert(QString(), new PanelData());
}
PanelSvg::~PanelSvg()
{
delete d;
}
void PanelSvg::setImagePath(const QString &path)
{
if (path == imagePath()) {
return;
}
Svg::setImagePath(path);
setContainsMultipleImages(true);
clearCache();
d->updateAndSignalSizes();
}
void PanelSvg::setEnabledBorders(const EnabledBorders borders)
{
if (borders == d->panels[d->prefix]->enabledBorders) {
return;
}
d->panels[d->prefix]->enabledBorders = borders;
d->updateAndSignalSizes();
}
PanelSvg::EnabledBorders PanelSvg::enabledBorders() const
{
QHash<QString, PanelData*>::const_iterator it = d->panels.constFind(d->prefix);
if (it != d->panels.constEnd()) {
return it.value()->enabledBorders;
} else {
return NoBorder;
}
}
void PanelSvg::setElementPrefix(Plasma::Location location)
{
switch (location) {
case TopEdge:
setElementPrefix("north");
break;
case BottomEdge:
setElementPrefix("south");
break;
case LeftEdge:
setElementPrefix("west");
break;
case RightEdge:
setElementPrefix("east");
break;
default:
setElementPrefix(QString());
break;
}
d->location = location;
}
void PanelSvg::setElementPrefix(const QString & prefix)
{
const QString oldPrefix(d->prefix);
if (!hasElement(prefix + "-center")) {
d->prefix.clear();
} else {
d->prefix = prefix;
if (!d->prefix.isEmpty()) {
d->prefix += '-';
}
}
if (oldPrefix == d->prefix && d->panels[oldPrefix]) {
return;
}
if (!d->panels.contains(d->prefix)) {
d->panels.insert(d->prefix, new PanelData(*(d->panels[oldPrefix])));
d->updateSizes();
}
if (!d->cacheAll) {
delete d->panels[oldPrefix];
d->panels.remove(oldPrefix);
}
d->location = Floating;
}
bool PanelSvg::hasElementPrefix(const QString & prefix) const
{
//for now it simply checks if a center element exists,
//because it could make sense for certain themes to not have all the elements
if (prefix.isEmpty()) {
return hasElement("center");
} else {
return hasElement(prefix + "-center");
}
}
bool PanelSvg::hasElementPrefix(Plasma::Location location) const
{
switch (location) {
case TopEdge:
return hasElementPrefix("north");
break;
case BottomEdge:
return hasElementPrefix("south");
break;
case LeftEdge:
return hasElementPrefix("west");
break;
case RightEdge:
return hasElementPrefix("east");
break;
default:
return hasElementPrefix(QString());
break;
}
}
QString PanelSvg::prefix()
{
if (d->prefix.isEmpty()) {
return d->prefix;
}
return d->prefix.left(d->prefix.size() - 1);
}
void PanelSvg::resizePanel(const QSizeF &size)
{
if (size.isEmpty()) {
kWarning() << "Invalid size" << size;
return;
}
if (size == d->panels[d->prefix]->panelSize) {
return;
}
d->updateSizes();
d->panels[d->prefix]->panelSize = size;
}
QSizeF PanelSvg::panelSize() const
{
QHash<QString, PanelData*>::const_iterator it = d->panels.constFind(d->prefix);
if (it != d->panels.constEnd()) {
return it.value()->panelSize;
} else {
return QSize(-1, -1);
}
}
qreal PanelSvg::marginSize(const Plasma::MarginEdge edge) const
{
if (d->panels[d->prefix]->noBorderPadding) {
return .0;
}
switch (edge) {
case Plasma::TopMargin:
return d->panels[d->prefix]->topMargin;
break;
case Plasma::LeftMargin:
return d->panels[d->prefix]->leftMargin;
break;
case Plasma::RightMargin:
return d->panels[d->prefix]->rightMargin;
break;
//Plasma::BottomMargin
default:
return d->panels[d->prefix]->bottomMargin;
break;
}
}
void PanelSvg::getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
{
PanelData *panel = d->panels[d->prefix];
if (!panel || panel->noBorderPadding) {
left = top = right = bottom = 0;
return;
}
top = panel->topMargin;
left = panel->leftMargin;
right = panel->rightMargin;
bottom = panel->bottomMargin;
}
QRectF PanelSvg::contentsRect() const
{
QSizeF size(panelSize());
if (size.isValid()) {
QRectF rect(QPointF(0, 0), size);
PanelData *panel = d->panels[d->prefix];
return rect.adjusted(panel->leftMargin, panel->topMargin,
-panel->rightMargin, -panel->bottomMargin);
} else {
return QRectF();
}
}
QBitmap PanelSvg::mask() const
{
PanelData *panel = d->panels[d->prefix];
if (!panel->cachedMask) {
if (panel->cachedBackground.isNull()) {
d->generateBackground(panel);
if (panel->cachedBackground.isNull()) {
return QBitmap();
}
}
panel->cachedMask = QBitmap(panel->cachedBackground.alphaChannel().createMaskFromColor(Qt::black));
}
return panel->cachedMask;
}
void PanelSvg::setCacheAllRenderedPanels(bool cache)
{
if (d->cacheAll && !cache) {
clearCache();
}
d->cacheAll = cache;
}
bool PanelSvg::cacheAllRenderedPanels() const
{
return d->cacheAll;
}
void PanelSvg::clearCache()
{
PanelData *panel = d->panels[d->prefix];
// delete all the panels that aren't this one
QMutableHashIterator<QString, PanelData*> it(d->panels);
while (it.hasNext()) {
PanelData *p = it.next().value();
if (panel != p) {
delete p;
it.remove();
}
}
}
QPixmap PanelSvg::panelPixmap()
{
PanelData *panel = d->panels[d->prefix];
if (panel->cachedBackground.isNull()) {
d->generateBackground(panel);
if (panel->cachedBackground.isNull()) {
return QPixmap();
}
}
return panel->cachedBackground;
}
void PanelSvg::paintPanel(QPainter *painter, const QRectF &target, const QRectF &source)
{
PanelData *panel = d->panels[d->prefix];
if (panel->cachedBackground.isNull()) {
d->generateBackground(panel);
if (panel->cachedBackground.isNull()) {
return;
}
}
painter->drawPixmap(target, panel->cachedBackground, source.isValid() ? source : target);
}
void PanelSvg::paintPanel(QPainter *painter, const QPointF &pos)
{
PanelData *panel = d->panels[d->prefix];
if (panel->cachedBackground.isNull()) {
d->generateBackground(panel);
if (panel->cachedBackground.isNull()) {
return;
}
}
painter->drawPixmap(pos, panel->cachedBackground);
}
void PanelSvgPrivate::generateBackground(PanelData *panel)
{
if (!panel->cachedBackground.isNull()) {
return;
}
QString id = QString::fromLatin1("%5_%4_%3_%2_%1_").
arg(panel->enabledBorders).arg(panel->panelSize.width()).arg(panel->panelSize.height()).arg(prefix).arg(q->imagePath());
Theme *theme = Theme::defaultTheme();
if (theme->findInCache(id, panel->cachedBackground) && !panel->cachedBackground.isNull()) {
return;
}
//kDebug() << "generating background";
const int topWidth = q->elementSize(prefix + "top").width();
const int leftHeight = q->elementSize(prefix + "left").height();
const int topOffset = 0;
const int leftOffset = 0;
if (!panel->panelSize.isValid()) {
kWarning() << "Invalid panel size" << panel->panelSize;
return;
}
const int contentWidth = panel->panelSize.width() - panel->leftWidth - panel->rightWidth;
const int contentHeight = panel->panelSize.height() - panel->topHeight - panel->bottomHeight;
int contentTop = 0;
int contentLeft = 0;
int rightOffset = contentWidth;
int bottomOffset = contentHeight;
panel->cachedBackground = QPixmap(panel->leftWidth + contentWidth + panel->rightWidth,
panel->topHeight + contentHeight + panel->bottomHeight);
panel->cachedBackground.fill(Qt::transparent);
QPainter p(&panel->cachedBackground);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.setRenderHint(QPainter::SmoothPixmapTransform);
//if we must stretch the center or the borders we compute how much we will have to stretch
//the svg to get the desired element sizes
QSizeF scaledContentSize(0, 0);
if (q->elementSize(prefix + "center").width() > 0 &&
q->elementSize(prefix + "center").height() > 0 &&
(!panel->tileCenter || panel->stretchBorders)) {
scaledContentSize = QSizeF(contentWidth * ((qreal)q->size().width() / (qreal)q->elementSize(prefix + "center").width()),
contentHeight * ((qreal)q->size().height() / (qreal)q->elementSize(prefix + "center").height()));
}
//CENTER
if (panel->tileCenter) {
if (contentHeight > 0 && contentWidth > 0) {
int centerTileHeight;
int centerTileWidth;
centerTileHeight = q->elementSize(prefix + "center").height();
centerTileWidth = q->elementSize(prefix + "center").width();
QPixmap center(centerTileWidth, centerTileHeight);
center.fill(Qt::transparent);
{
QPainter centerPainter(&center);
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&centerPainter, QRect(QPoint(0, 0), q->elementSize(prefix + "center")), prefix + "center");
}
p.drawTiledPixmap(QRect(panel->leftWidth, panel->topHeight,
contentWidth, contentHeight), center);
}
} else {
if (contentHeight > 0 && contentWidth > 0) {
q->paint(&p, QRect(panel->leftWidth, panel->topHeight,
contentWidth, contentHeight),
prefix + "center");
}
}
// Corners
if (q->hasElement(prefix + "top") && panel->enabledBorders & PanelSvg::TopBorder) {
contentTop = panel->topHeight;
bottomOffset += panel->topHeight;
if (q->hasElement(prefix + "topleft") && panel->enabledBorders & PanelSvg::LeftBorder) {
q->paint(&p, QRect(leftOffset, topOffset, panel->leftWidth, panel->topHeight), prefix + "topleft");
contentLeft = panel->leftWidth;
rightOffset = contentWidth + panel->leftWidth;
}
if (q->hasElement(prefix + "topright") && panel->enabledBorders & PanelSvg::RightBorder) {
q->paint(&p, QRect(rightOffset, topOffset, panel->rightWidth, panel->topHeight), prefix + "topright");
}
}
if (q->hasElement(prefix + "bottom") && panel->enabledBorders & PanelSvg::BottomBorder) {
if (q->hasElement(prefix + "bottomleft") && panel->enabledBorders & PanelSvg::LeftBorder) {
q->paint(&p, QRect(leftOffset, bottomOffset, panel->leftWidth, panel->bottomHeight), prefix + "bottomleft");
contentLeft = panel->leftWidth;
rightOffset = contentWidth + panel->leftWidth;
}
if (q->hasElement(prefix + "bottomright") && panel->enabledBorders & PanelSvg::RightBorder) {
q->paint(&p, QRect(rightOffset, bottomOffset, panel->rightWidth, panel->bottomHeight), prefix + "bottomright");
}
}
// Sides
if (panel->stretchBorders) {
if (panel->enabledBorders & PanelSvg::LeftBorder || panel->enabledBorders & PanelSvg::RightBorder) {
if (q->hasElement(prefix + "left") &&
panel->enabledBorders & PanelSvg::LeftBorder) {
q->paint(&p, QRect(leftOffset, contentTop, panel->leftWidth, contentHeight), prefix + "left");
}
if (q->hasElement(prefix + "right") &&
panel->enabledBorders & PanelSvg::RightBorder) {
q->paint(&p, QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), prefix + "right");
}
}
if (panel->enabledBorders & PanelSvg::TopBorder ||
panel->enabledBorders & PanelSvg::BottomBorder) {
if (q->hasElement(prefix + "top") &&
panel->enabledBorders & PanelSvg::TopBorder) {
q->paint(&p, QRect(contentLeft, topOffset, contentWidth, panel->topHeight), prefix + "top");
}
if (q->hasElement(prefix + "bottom") &&
panel->enabledBorders & PanelSvg::BottomBorder) {
q->paint(&p, QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), prefix + "bottom");
}
}
} else {
if (q->hasElement(prefix + "left") &&
panel->enabledBorders & PanelSvg::LeftBorder) {
QPixmap left(panel->leftWidth, leftHeight);
left.fill(Qt::transparent);
QPainter sidePainter(&left);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), left.size()), prefix + "left");
p.drawTiledPixmap(QRect(leftOffset, contentTop, panel->leftWidth, contentHeight), left);
}
if (q->hasElement(prefix + "right") && panel->enabledBorders & PanelSvg::RightBorder) {
QPixmap right(panel->rightWidth, leftHeight);
right.fill(Qt::transparent);
QPainter sidePainter(&right);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), right.size()), prefix + "right");
p.drawTiledPixmap(QRect(rightOffset, contentTop, panel->rightWidth, contentHeight), right);
}
if (q->hasElement(prefix + "top") && panel->enabledBorders & PanelSvg::TopBorder) {
QPixmap top(topWidth, panel->topHeight);
top.fill(Qt::transparent);
QPainter sidePainter(&top);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), top.size()), prefix + "top");
p.drawTiledPixmap(QRect(contentLeft, topOffset, contentWidth, panel->topHeight), top);
}
if (q->hasElement(prefix + "bottom") && panel->enabledBorders & PanelSvg::BottomBorder) {
QPixmap bottom(topWidth, panel->bottomHeight);
bottom.fill(Qt::transparent);
QPainter sidePainter(&bottom);
sidePainter.setCompositionMode(QPainter::CompositionMode_Source);
q->paint(&sidePainter, QRect(QPoint(0, 0), bottom.size()), prefix + "bottom");
p.drawTiledPixmap(QRect(contentLeft, bottomOffset, contentWidth, panel->bottomHeight), bottom);
}
}
theme->insertIntoCache(id, panel->cachedBackground);
}
void PanelSvgPrivate::updateSizes()
{
//kDebug() << "!!!!!!!!!!!!!!!!!!!!!! updating sizes" << prefix;
PanelData *panel = panels[prefix];
Q_ASSERT(panel);
panel->cachedBackground = QPixmap();
panel->cachedMask = QPixmap();
if (panel->enabledBorders & PanelSvg::TopBorder) {
panel->topHeight = q->elementSize(prefix + "top").height();
if (q->hasElement(prefix + "hint-top-margin")) {
panel->topMargin = q->elementSize(prefix + "hint-top-margin").height();
} else {
panel->topMargin = panel->topHeight;
}
} else {
panel->topMargin = panel->topHeight = 0;
}
if (panel->enabledBorders & PanelSvg::LeftBorder) {
panel->leftWidth = q->elementSize(prefix + "left").width();
if (q->hasElement(prefix + "hint-left-margin")) {
panel->leftMargin = q->elementSize(prefix + "hint-left-margin").height();
} else {
panel->leftMargin = panel->leftWidth;
}
} else {
panel->leftMargin = panel->leftWidth = 0;
}
if (panel->enabledBorders & PanelSvg::RightBorder) {
panel->rightWidth = q->elementSize(prefix + "right").width();
if (q->hasElement(prefix + "hint-right-margin")) {
panel->rightMargin = q->elementSize(prefix + "hint-right-margin").height();
} else {
panel->rightMargin = panel->rightWidth;
}
} else {
panel->rightMargin = panel->rightWidth = 0;
}
if (panel->enabledBorders & PanelSvg::BottomBorder) {
panel->bottomHeight = q->elementSize(prefix + "bottom").height();
if (q->hasElement(prefix + "hint-bottom-margin")) {
panel->bottomMargin = q->elementSize(prefix + "hint-bottom-margin").height();
} else {
panel->bottomMargin = panel->bottomHeight;
}
} else {
panel->bottomMargin = panel->bottomHeight = 0;
}
//since it's rectangular, topWidth and bottomWidth must be the same
panel->tileCenter = q->hasElement("hint-tile-center");
panel->noBorderPadding = q->hasElement("hint-no-border-padding");
panel->stretchBorders = q->hasElement("hint-stretch-borders");
}
void PanelSvgPrivate::updateNeeded()
{
q->clearCache();
updateSizes();
}
void PanelSvgPrivate::updateAndSignalSizes()
{
updateSizes();
emit q->repaintNeeded();
}
} // Plasma namespace
#include "panelsvg.moc"

View File

@ -37,7 +37,7 @@
#include "plasma/corona.h"
#include "plasma/containment.h"
#include "plasma/extender.h"
#include "plasma/widgets/icon.h"
#include "plasma/widgets/iconwidget.h"
namespace Plasma
{
@ -69,7 +69,7 @@ void PopupApplet::setPopupIcon(const QIcon &icon)
}
if (!d->icon) {
d->icon = new Plasma::Icon(icon, QString(), this);
d->icon = new Plasma::IconWidget(icon, QString(), this);
connect(d->icon, SIGNAL(clicked()), this, SLOT(togglePopup()));
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();

View File

@ -30,7 +30,7 @@ namespace Plasma
{
class Dialog;
class Icon;
class IconWidget;
class PopupAppletPrivate;
/**

View File

@ -27,7 +27,7 @@
namespace Plasma
{
class PanelSvg;
class FrameSvg;
class AppletScript;
class Wallpaper;
@ -87,10 +87,10 @@ public:
AppletOverlayWidget *needsConfigOverlay;
QList<QGraphicsItem*> registeredAsDragHandle;
QStringList loadedEngines;
Plasma::PanelSvg *background;
Plasma::FrameSvg *background;
AppletScript *script;
Package *package;
ConfigXml *configXml;
ConfigLoader *configLoader;
KConfigGroup *mainConfig;
Plasma::Constraints pendingConstraints;
Plasma::AspectRatioMode aspectRatioMode;

View File

@ -42,7 +42,7 @@
#include "paintutils.h"
#include "theme.h"
#include "view.h"
#include "panelsvg.h"
#include "framesvg.h"
namespace Plasma
{
@ -119,7 +119,7 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
//FIXME: this should be of course true, but works only if false
m_configureIcons->setContainsMultipleImages(true);
m_background = new PanelSvg(this);
m_background = new FrameSvg(this);
m_background->setImagePath("widgets/background");
//We got to be able to see the applet while dragging to to another containment,
@ -289,7 +289,7 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
g.setColorAt(0.0, transparencyColor);
}
m_background->resizePanel(m_decorationRect.size());
m_background->resizeFrame(m_decorationRect.size());
if (!m_backgroundBuffer || m_backgroundBuffer->size() != pixmapSize) {
delete m_backgroundBuffer;
@ -298,7 +298,7 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
m_backgroundBuffer->fill(Qt::transparent);
QPainter buffPainter(m_backgroundBuffer);
m_background->paintPanel(&buffPainter);
m_background->paintFrame(&buffPainter);
//+1 because otherwise due to rounding errors when rotated could appear one pixel
//of the icon at the border of the applet

View File

@ -33,7 +33,7 @@ namespace Plasma
{
class Applet;
class Containment;
class PanelSvg;
class FrameSvg;
class View;
class AppletHandle : public QObject, public QGraphicsItem
@ -124,7 +124,7 @@ class AppletHandle : public QObject, public QGraphicsItem
QGraphicsView *m_currentView;
Svg *m_configureIcons;
PanelSvg *m_background;
FrameSvg *m_background;
QPoint m_mousePos; //mousepos relative to applet
QPointF m_entryPos; //where the hover in event occurred

View File

@ -55,7 +55,7 @@ class ExtenderPrivate
Applet *applet;
QGraphicsLinearLayout *layout;
PanelSvg *background;
FrameSvg *background;
int currentSpacerIndex;
QGraphicsWidget *spacerWidget;

View File

@ -36,8 +36,8 @@ namespace Plasma
class Applet;
class ExtenderItem;
class Extender;
class Icon;
class PanelSvg;
class IconWidget;
class FrameSvg;
class ExtenderItemPrivate
{
@ -70,10 +70,10 @@ class ExtenderItemPrivate
KConfigGroup config;
PanelSvg *dragger;
PanelSvg *background;
FrameSvg *dragger;
FrameSvg *background;
Icon *collapseIcon;
IconWidget *collapseIcon;
QMap<QString, QAction*> actions;

View File

@ -39,7 +39,7 @@
#include "plasma/plasma.h"
#include "plasma/theme.h"
#include "plasma/animator.h"
#include "plasma/panelsvg.h"
#include "plasma/framesvg.h"
#include "plasma/paintutils.h"
#include "private/style.h"
@ -69,9 +69,9 @@ public:
NativeTabBar *q;
QTabBar::Shape shape; //used to keep track of shape() changes
PanelSvg *backgroundSvg;
FrameSvg *backgroundSvg;
qreal left, top, right, bottom;
PanelSvg *buttonSvg;
FrameSvg *buttonSvg;
qreal buttonLeft, buttonTop, buttonRight, buttonBottom;
int animationId;
@ -101,11 +101,11 @@ NativeTabBar::NativeTabBar(QWidget *parent)
: QTabBar(parent),
d(new NativeTabBarPrivate(this))
{
d->backgroundSvg = new Plasma::PanelSvg();
d->backgroundSvg = new Plasma::FrameSvg();
d->backgroundSvg->setImagePath("widgets/frame");
d->backgroundSvg->setElementPrefix("sunken");
d->buttonSvg = new Plasma::PanelSvg();
d->buttonSvg = new Plasma::FrameSvg();
d->buttonSvg->setImagePath("widgets/button");
d->buttonSvg->setElementPrefix("normal");
@ -220,7 +220,7 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
//int numTabs = count();
//bool ltr = painter.layoutDirection() == Qt::LeftToRight; // Not yet used
d->backgroundSvg->paintPanel(&painter);
d->backgroundSvg->paintFrame(&painter);
// Drawing Tabborders
QRect movingRect;
@ -232,8 +232,8 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
}
//resizing here because in resizeevent the first time is invalid (still no tabs)
d->buttonSvg->resizePanel(movingRect.size());
d->buttonSvg->paintPanel(&painter, movingRect.topLeft());
d->buttonSvg->resizeFrame(movingRect.size());
d->buttonSvg->paintFrame(&painter, movingRect.topLeft());
QFontMetrics metrics(painter.font());
@ -311,7 +311,7 @@ void NativeTabBar::resizeEvent(QResizeEvent *event)
{
QTabBar::resizeEvent(event);
d->currentAnimRect = tabRect(currentIndex());
d->backgroundSvg->resizePanel(size());
d->backgroundSvg->resizeFrame(size());
update();
}

View File

@ -38,7 +38,7 @@ public:
void popupConstraintsEvent(Plasma::Constraints constraints);
PopupApplet *q;
Plasma::Icon *icon;
Plasma::IconWidget *icon;
QPointer<Plasma::Dialog> dialog;
QGraphicsProxyWidget *proxy;
Plasma::PopupPlacement popupPlacement;

View File

@ -32,7 +32,7 @@
namespace Plasma
{
class ConfigXml;
class ConfigLoader;
class NullServiceJob : public ServiceJob
{
@ -97,7 +97,7 @@ public:
Service *q;
QString destination;
QString name;
ConfigXml *config;
ConfigLoader *config;
KTemporaryFile *tempFile;
QMultiHash<QWidget *, QString> associatedWidgets;
QMultiHash<QGraphicsWidget *, QString> associatedGraphicsWidgets;

View File

@ -25,7 +25,7 @@
#include <KDebug>
#include <plasma/panelsvg.h>
#include <plasma/framesvg.h>
namespace Plasma {
@ -41,16 +41,16 @@ public:
{
}
Plasma::PanelSvg *scrollbar;
Plasma::FrameSvg *scrollbar;
};
Style::Style()
: QCommonStyle(),
d(new StylePrivate)
{
d->scrollbar = new Plasma::PanelSvg(this);
d->scrollbar = new Plasma::FrameSvg(this);
d->scrollbar->setImagePath("widgets/scrollbar");
d->scrollbar->setCacheAllRenderedPanels(true);
d->scrollbar->setCacheAllRenderedFrames(true);
}
Style::~Style()
@ -96,8 +96,8 @@ void Style::drawComplexControl(ComplexControl control,
subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0);
d->scrollbar->setElementPrefix("background");
d->scrollbar->resizePanel(option->rect.size());
d->scrollbar->paintPanel(painter);
d->scrollbar->resizeFrame(option->rect.size());
d->scrollbar->paintFrame(painter);
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarSlider) {
d->scrollbar->setElementPrefix("sunken-slider");
@ -105,8 +105,8 @@ void Style::drawComplexControl(ComplexControl control,
d->scrollbar->setElementPrefix(prefix + "slider");
}
d->scrollbar->resizePanel(slider.size());
d->scrollbar->paintPanel(painter, slider.topLeft());
d->scrollbar->resizeFrame(slider.size());
d->scrollbar->paintFrame(painter, slider.topLeft());
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) {

View File

@ -29,7 +29,7 @@
#include <KDebug>
#include <plasma/theme.h>
#include "widgets/icon.h"
#include "widgets/iconwidget.h"
namespace Plasma
{
@ -93,7 +93,7 @@ void ToolBox::addTool(QAction *action)
return;
}
Plasma::Icon *tool = new Plasma::Icon(this);
Plasma::IconWidget *tool = new Plasma::IconWidget(this);
tool->setAction(action);
tool->setDrawBackground(true);
@ -121,7 +121,7 @@ void ToolBox::removeTool(QAction *action)
{
foreach (QGraphicsItem *child, QGraphicsItem::children()) {
//kDebug() << "checking tool" << child << child->data(ToolName);
Plasma::Icon *tool = dynamic_cast<Plasma::Icon*>(child);
Plasma::IconWidget *tool = dynamic_cast<Plasma::IconWidget*>(child);
if (tool && tool->action() == action) {
//kDebug() << "tool found!";
tool->deleteLater();

View File

@ -33,7 +33,7 @@
#include <plasma/plasma.h>
#include <plasma/theme.h>
#include <plasma/panelsvg.h>
#include <plasma/framesvg.h>
namespace Plasma {
@ -53,7 +53,7 @@ class ToolTipPrivate
QLabel *imageLabel;
WindowPreview *preview;
WId windowToPreview;
PanelSvg *background;
FrameSvg *background;
QPointer<QObject> source;
bool autohide;
};
@ -96,7 +96,7 @@ ToolTip::ToolTip(QObject *source)
d->imageLabel = new QLabel(this);
d->imageLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
d->background = new PanelSvg(this);
d->background = new FrameSvg(this);
connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
l->addWidget(d->preview, 0, 0, 1, 2);
@ -144,7 +144,7 @@ void ToolTip::prepareShowing(bool cueUpdate)
void ToolTip::resizeEvent(QResizeEvent *e)
{
QWidget::resizeEvent(e);
d->background->resizePanel(size());
d->background->resizeFrame(size());
setMask(d->background->mask());
}
@ -157,7 +157,7 @@ void ToolTip::paintEvent(QPaintEvent *e)
painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(rect(), Qt::transparent);
d->background->paintPanel(&painter);
d->background->paintFrame(&painter);
}
void ToolTip::sourceDestroyed()
@ -173,7 +173,7 @@ bool ToolTip::autohide() const
void ToolTip::updateTheme()
{
d->background->setImagePath("widgets/tooltip");
d->background->setEnabledBorders(PanelSvg::AllBorders);
d->background->setEnabledBorders(FrameSvg::AllBorders);
const int topHeight = d->background->marginSize(Plasma::TopMargin);
const int leftWidth = d->background->marginSize(Plasma::LeftMargin);

View File

@ -30,7 +30,7 @@
#include <KStandardDirs>
#include <KTemporaryFile>
#include "configxml.h"
#include "configloader.h"
#include "version.h"
@ -263,7 +263,7 @@ void Service::setOperationsScheme(QIODevice *xml)
d->tempFile->open();
KSharedConfigPtr c = KSharedConfig::openConfig(d->tempFile->fileName(), KConfig::NoGlobals);
d->config = new ConfigXml(c, xml, this);
d->config = new ConfigLoader(c, xml, this);
emit operationsChanged();

6
svg.h
View File

@ -38,7 +38,7 @@ namespace Plasma
{
class SvgPrivate;
class PanelSvgPrivate;
class FrameSvgPrivate;
/**
* @class Svg plasma/svg.h <Plasma/Svg>
@ -50,7 +50,7 @@ class PanelSvgPrivate;
* the SVG document using Plasma::Theme. It also provides a number of internal
* optimizations to help lower the cost of painting SVGs, such as caching.
*
* @see Plasma::PanelSvg
* @see Plasma::FrameSvg
**/
class PLASMA_EXPORT Svg : public QObject
{
@ -227,7 +227,7 @@ class PLASMA_EXPORT Svg : public QObject
Q_PRIVATE_SLOT(d, void colorsChanged())
friend class SvgPrivate;
friend class PanelSvgPrivate;
friend class FrameSvgPrivate;
};
} // Plasma namespace

View File

@ -41,7 +41,7 @@
#include <applet.h>
#include <containment.h>
#include <corona.h>
#include <panelsvg.h>
#include <framesvg.h>
#include <theme.h>
#include <view.h>
#include <private/tooltip_p.h>

View File

@ -22,10 +22,10 @@
#include <QStringList>
#include "widgets/checkbox.h"
#include "widgets/combobox.h"
#include "widgets/flash.h"
#include "widgets/flashinglabel.h"
#include "widgets/frame.h"
#include "widgets/groupbox.h"
#include "widgets/icon.h"
#include "widgets/iconwidget.h"
#include "widgets/label.h"
#include "widgets/lineedit.h"
#include "widgets/pushbutton.h"
@ -51,10 +51,10 @@ UiLoader::UiLoader(QObject *parent)
d->widgets
<< "CheckBox"
<< "ComboBox"
<< "Flash"
<< "FlashingLabel"
<< "Frame"
<< "GroupBox"
<< "Icon"
<< "IconWidget"
<< "Label"
<< "LineEdit"
<< "PushButton"
@ -80,14 +80,14 @@ QGraphicsWidget *UiLoader::createWidget(const QString &className, QGraphicsWidge
return new CheckBox(parent);
} else if (className == QString("ComboBox")) {
return new ComboBox(parent);
} else if (className == QString("Flash")) {
return new Flash(parent);
} else if (className == QString("FlashingLabel")) {
return new FlashingLabel(parent);
} else if (className == QString("Frame")) {
return new Frame(parent);
} else if (className == QString("GroupBox")) {
return new GroupBox(parent);
} else if (className == QString("Icon")) {
return new Icon(parent);
} else if (className == QString("IconWidget")) {
return new IconWidget(parent);
} else if (className == QString("Label")) {
return new Label(parent);
} else if (className == QString("LineEdit")) {

View File

@ -28,7 +28,7 @@
#include <KIconLoader>
#include "theme.h"
#include "panelsvg.h"
#include "framesvg.h"
#include "animator.h"
#include "paintutils.h"
@ -54,7 +54,7 @@ public:
ComboBox *q;
PanelSvg *background;
FrameSvg *background;
int animId;
bool fadeIn;
qreal opacity;
@ -114,9 +114,9 @@ ComboBox::ComboBox(QGraphicsWidget *parent)
setWidget(native);
native->setAttribute(Qt::WA_NoSystemBackground);
d->background = new PanelSvg(this);
d->background = new FrameSvg(this);
d->background->setImagePath("widgets/button");
d->background->setCacheAllRenderedPanels(true);
d->background->setCacheAllRenderedFrames(true);
d->background->setElementPrefix("normal");
d->syncBorders();
@ -166,13 +166,13 @@ void ComboBox::resizeEvent(QGraphicsSceneResizeEvent *event)
d->syncActiveRect();
d->background->setElementPrefix("focus");
d->background->resizePanel(size());
d->background->resizeFrame(size());
d->background->setElementPrefix("active");
d->background->resizePanel(d->activeRect.size());
d->background->resizeFrame(d->activeRect.size());
d->background->setElementPrefix("normal");
d->background->resizePanel(size());
d->background->resizeFrame(size());
}
QGraphicsProxyWidget::resizeEvent(event);
@ -194,7 +194,7 @@ void ComboBox::paint(QPainter *painter,
d->background->setElementPrefix("normal");
if (d->animId == -1) {
d->background->paintPanel(painter);
d->background->paintFrame(painter);
}
//disabled widget
} else {
@ -202,7 +202,7 @@ void ComboBox::paint(QPainter *painter,
bufferPixmap.fill(Qt::transparent);
QPainter buffPainter(&bufferPixmap);
d->background->paintPanel(&buffPainter);
d->background->paintFrame(&buffPainter);
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
@ -213,20 +213,20 @@ void ComboBox::paint(QPainter *painter,
if (isEnabled() && acceptHoverEvents()) {
if (d->animId != -1) {
d->background->setElementPrefix("normal");
QPixmap normalPix = d->background->panelPixmap();
QPixmap normalPix = d->background->framePixmap();
d->background->setElementPrefix("active");
painter->drawPixmap(
d->activeRect.topLeft(),
PaintUtils::transition(d->background->panelPixmap(), normalPix, 1 - d->opacity));
PaintUtils::transition(d->background->framePixmap(), normalPix, 1 - d->opacity));
} else if (isUnderMouse()) {
d->background->setElementPrefix("active");
d->background->paintPanel(painter, d->activeRect.topLeft());
d->background->paintFrame(painter, d->activeRect.topLeft());
}
}
if (nativeWidget()->hasFocus()) {
d->background->setElementPrefix("focus");
d->background->paintPanel(painter);
d->background->paintFrame(painter);
}
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));

View File

@ -19,7 +19,7 @@
* et, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "flash.h"
#include "flashinglabel.h"
#include <QtCore/QString>
#include <QtCore/QTimeLine>
@ -34,10 +34,10 @@
using namespace Plasma;
class Plasma::FlashPrivate
class Plasma::FlashingLabelPrivate
{
public:
enum FlashType {
enum FlashingLabelType {
Text,
Pixmap
};
@ -46,13 +46,13 @@ class Plasma::FlashPrivate
Invisible
};
FlashPrivate(Flash *flash)
FlashingLabelPrivate(FlashingLabel *flash)
: q(flash),
defaultDuration(3000),
type(FlashPrivate::Text),
type(FlashingLabelPrivate::Text),
color(Qt::black),
animId(0),
state(FlashPrivate::Invisible),
state(FlashingLabelPrivate::Invisible),
autohide(false)
{
//TODO: put this on a diet by using timerEvent instead?
@ -62,15 +62,15 @@ class Plasma::FlashPrivate
fadeInTimer.setSingleShot(true);
}
~FlashPrivate() { }
~FlashingLabelPrivate() { }
void renderPixmap(const QSize &size);
void setupFlash(int duration);
void elementAnimationFinished(int);
Flash *q;
FlashingLabel *q;
int defaultDuration;
FlashType type;
FlashingLabelType type;
QTimer fadeInTimer;
QTimer fadeOutTimer;
QString text;
@ -88,9 +88,9 @@ class Plasma::FlashPrivate
bool autohide;
};
Flash::Flash(QGraphicsItem *parent)
FlashingLabel::FlashingLabel(QGraphicsItem *parent)
: QGraphicsWidget(parent),
d(new FlashPrivate(this))
d(new FlashingLabelPrivate(this))
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
setCacheMode(NoCache);
@ -98,12 +98,12 @@ Flash::Flash(QGraphicsItem *parent)
connect(&d->fadeInTimer, SIGNAL(timeout()), this, SLOT(fadeIn()));
}
Flash::~Flash()
FlashingLabel::~FlashingLabel()
{
delete d;
}
void Flash::setDuration(int duration)
void FlashingLabel::setDuration(int duration)
{
if (duration < 1) {
return;
@ -112,42 +112,42 @@ void Flash::setDuration(int duration)
d->defaultDuration = duration;
}
void Flash::setColor(const QColor &color)
void FlashingLabel::setColor(const QColor &color)
{
d->color = color;
}
void Flash::setFont(const QFont &font)
void FlashingLabel::setFont(const QFont &font)
{
d->font = font;
}
void Flash::flash(const QString &text, int duration, const QTextOption &option)
void FlashingLabel::flash(const QString &text, int duration, const QTextOption &option)
{
if (text.isEmpty()) {
return;
}
//kDebug() << duration << text;
d->type = FlashPrivate::Text;
d->type = FlashingLabelPrivate::Text;
d->text = text;
d->textOption = option;
d->setupFlash(duration);
}
void Flash::flash(const QPixmap &pixmap, int duration, Qt::Alignment align)
void FlashingLabel::flash(const QPixmap &pixmap, int duration, Qt::Alignment align)
{
if (pixmap.isNull()) {
return;
}
d->type = FlashPrivate::Pixmap;
d->type = FlashingLabelPrivate::Pixmap;
d->pixmap = pixmap;
d->alignment = align;
d->setupFlash(duration);
}
void Flash::setAutohide(bool autohide)
void FlashingLabel::setAutohide(bool autohide)
{
d->autohide = autohide;
@ -160,44 +160,44 @@ void Flash::setAutohide(bool autohide)
}
}
bool Flash::autohide() const
bool FlashingLabel::autohide() const
{
return d->autohide;
}
void Flash::kill()
void FlashingLabel::kill()
{
d->fadeInTimer.stop();
if (d->state == FlashPrivate::Visible) {
if (d->state == FlashingLabelPrivate::Visible) {
fadeOut();
}
}
void Flash::fadeIn()
void FlashingLabel::fadeIn()
{
//kDebug();
if (d->autohide) {
show();
}
d->state = FlashPrivate::Visible;
d->state = FlashingLabelPrivate::Visible;
d->animId = Plasma::Animator::self()->animateElement(this, Plasma::Animator::AppearAnimation);
Plasma::Animator::self()->setInitialPixmap(d->animId, d->renderedPixmap);
}
void Flash::fadeOut()
void FlashingLabel::fadeOut()
{
if (d->state == FlashPrivate::Invisible) {
return; // Flash was already killed - do not animate again
if (d->state == FlashingLabelPrivate::Invisible) {
return; // FlashingLabel was already killed - do not animate again
}
d->state = FlashPrivate::Invisible;
d->state = FlashingLabelPrivate::Invisible;
d->animId = Plasma::Animator::self()->animateElement(
this, Plasma::Animator::DisappearAnimation);
Plasma::Animator::self()->setInitialPixmap(d->animId, d->renderedPixmap);
}
void Flash::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void FlashingLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
@ -207,13 +207,13 @@ void Flash::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
} else {
d->animId = 0;
if (d->state == FlashPrivate::Visible) {
if (d->state == FlashingLabelPrivate::Visible) {
painter->drawPixmap(0, 0, d->renderedPixmap);
}
}
}
void FlashPrivate::renderPixmap(const QSize &size)
void FlashingLabelPrivate::renderPixmap(const QSize &size)
{
if (renderedPixmap.size() != size) {
renderedPixmap = QPixmap(size);
@ -221,11 +221,11 @@ void FlashPrivate::renderPixmap(const QSize &size)
renderedPixmap.fill(Qt::transparent);
QPainter painter(&renderedPixmap);
if (type == FlashPrivate::Text) {
if (type == FlashingLabelPrivate::Text) {
painter.setPen(color);
painter.setFont(font);
painter.drawText(QRect(QPoint(0, 0), size), text, textOption);
} else if (type == FlashPrivate::Pixmap) {
} else if (type == FlashingLabelPrivate::Pixmap) {
QPoint p;
if(alignment & Qt::AlignLeft) {
@ -253,13 +253,13 @@ void FlashPrivate::renderPixmap(const QSize &size)
}
}
void FlashPrivate::setupFlash(int duration)
void FlashingLabelPrivate::setupFlash(int duration)
{
fadeOutTimer.stop();
fadeOutTimer.setInterval(duration > 0 ? duration : defaultDuration);
renderPixmap(q->size().toSize());
if (state != FlashPrivate::Visible) {
if (state != FlashingLabelPrivate::Visible) {
fadeInTimer.start();
} else {
q->update();
@ -270,11 +270,11 @@ void FlashPrivate::setupFlash(int duration)
}
}
void FlashPrivate::elementAnimationFinished(int id)
void FlashingLabelPrivate::elementAnimationFinished(int id)
{
if (autohide && state == FlashPrivate::Invisible && id == animId) {
if (autohide && state == FlashingLabelPrivate::Invisible && id == animId) {
q->hide();
}
}
#include "flash.moc"
#include "flashinglabel.moc"

View File

@ -18,8 +18,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_FLASH_H
#define PLASMA_FLASH_H
#ifndef PLASMA_FLASHINGLABEL_H
#define PLASMA_FLASHINGLABEL_H
#include <QtGui/QGraphicsWidget>
#include <QtGui/QTextOption>
@ -29,19 +29,19 @@
namespace Plasma
{
class FlashPrivate;
class FlashingLabelPrivate;
/**
* @class Flash plasma/widgets/flash.h <Plasma/Widgets/Flash>
* @class FlashingLabel plasma/widgets/flashinglabel.h <Plasma/Widgets/FlashingLabel>
*
* @short Provides flashing text or icons inside Plasma
*/
class PLASMA_EXPORT Flash : public QGraphicsWidget
class PLASMA_EXPORT FlashingLabel : public QGraphicsWidget
{
Q_OBJECT
public:
explicit Flash(QGraphicsItem *parent = 0);
virtual ~Flash();
explicit FlashingLabel(QGraphicsItem *parent = 0);
virtual ~FlashingLabel();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
@ -66,7 +66,7 @@ class PLASMA_EXPORT Flash : public QGraphicsWidget
private:
Q_PRIVATE_SLOT(d, void elementAnimationFinished(int))
FlashPrivate *const d;
FlashingLabelPrivate *const d;
};
}

View File

@ -31,7 +31,7 @@
//Plasma
#include "plasma/theme.h"
#include "plasma/panelsvg.h"
#include "plasma/framesvg.h"
namespace Plasma
{
@ -55,7 +55,7 @@ public:
void syncBorders();
Frame *q;
PanelSvg *svg;
FrameSvg *svg;
Frame::Shadow shadow;
QString text;
QString styleSheet;
@ -84,7 +84,7 @@ Frame::Frame(QGraphicsWidget *parent)
: QGraphicsWidget(parent),
d(new FramePrivate(this))
{
d->svg = new Plasma::PanelSvg(this);
d->svg = new Plasma::FrameSvg(this);
d->svg->setImagePath("widgets/frame");
d->svg->setElementPrefix("plain");
d->syncBorders();
@ -202,7 +202,7 @@ void Frame::paint(QPainter *painter,
Q_UNUSED(option)
Q_UNUSED(widget)
d->svg->paintPanel(painter);
d->svg->paintFrame(painter);
if (!d->text.isNull()) {
QFontMetricsF fm(QApplication::font());
@ -223,7 +223,7 @@ void Frame::paint(QPainter *painter,
void Frame::resizeEvent(QGraphicsSceneResizeEvent *event)
{
d->svg->resizePanel(event->newSize());
d->svg->resizeFrame(event->newSize());
if (d->image) {
d->image->resize(contentsRect().size());

View File

@ -22,8 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "icon.h"
#include "icon_p.h"
#include "iconwidget.h"
#include "iconwidget_p.h"
#include <QAction>
#include <QApplication>
@ -59,14 +59,14 @@
namespace Plasma
{
IconPrivate::IconPrivate(Icon *i)
IconWidgetPrivate::IconWidgetPrivate(IconWidget *i)
: q(i),
iconSvg(0),
m_fadeIn(false),
m_hoverAnimId(-1),
m_hoverAlpha(20 / 255),
iconSize(48, 48),
states(IconPrivate::NoState),
states(IconWidgetPrivate::NoState),
orientation(Qt::Vertical),
numDisplayLines(2),
invertLayout(false),
@ -76,19 +76,19 @@ IconPrivate::IconPrivate(Icon *i)
{
}
IconPrivate::~IconPrivate()
IconWidgetPrivate::~IconWidgetPrivate()
{
qDeleteAll(cornerActions);
}
void Icon::readColors()
void IconWidget::readColors()
{
d->textColor = Plasma::Theme::defaultTheme()->color(Theme::TextColor);
d->shadowColor = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
}
IconAction::IconAction(Icon *icon, QAction *action)
IconAction::IconAction(IconWidget *icon, QAction *action)
: m_icon(icon),
m_action(action),
m_hovered(false),
@ -172,11 +172,11 @@ void IconAction::rebuildPixmap()
m_pixmap = QPixmap(26, 26);
m_pixmap.fill(Qt::transparent);
int element = IconPrivate::Minibutton;
int element = IconWidgetPrivate::Minibutton;
if (m_pressed) {
element = IconPrivate::MinibuttonPressed;
element = IconWidgetPrivate::MinibuttonPressed;
} else if (m_hovered) {
element = IconPrivate::MinibuttonHover;
element = IconWidgetPrivate::MinibuttonHover;
}
QPainter painter(&m_pixmap);
@ -264,36 +264,36 @@ void IconAction::paint(QPainter *painter) const
}
}
Icon::Icon(QGraphicsItem *parent)
IconWidget::IconWidget(QGraphicsItem *parent)
: QGraphicsWidget(parent),
d(new IconPrivate(this))
d(new IconWidgetPrivate(this))
{
init();
}
Icon::Icon(const QString &text, QGraphicsItem *parent)
IconWidget::IconWidget(const QString &text, QGraphicsItem *parent)
: QGraphicsWidget(parent),
d(new IconPrivate(this))
d(new IconWidgetPrivate(this))
{
init();
setText(text);
}
Icon::Icon(const QIcon &icon, const QString &text, QGraphicsItem *parent)
IconWidget::IconWidget(const QIcon &icon, const QString &text, QGraphicsItem *parent)
: QGraphicsWidget(parent),
d(new IconPrivate(this))
d(new IconWidgetPrivate(this))
{
init();
setText(text);
setIcon(icon);
}
Icon::~Icon()
IconWidget::~IconWidget()
{
delete d;
}
void Icon::init()
void IconWidget::init()
{
readColors();
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(readColors()));
@ -305,21 +305,21 @@ void Icon::init()
int focusVMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin);
// Margins for horizontal mode (list views, tree views, table views)
d->setHorizontalMargin(IconPrivate::TextMargin, focusHMargin, focusVMargin);
d->setHorizontalMargin(IconPrivate::IconMargin, focusHMargin, focusVMargin);
d->setHorizontalMargin(IconPrivate::ItemMargin, 0, 0);
d->setHorizontalMargin(IconWidgetPrivate::TextMargin, focusHMargin, focusVMargin);
d->setHorizontalMargin(IconWidgetPrivate::IconMargin, focusHMargin, focusVMargin);
d->setHorizontalMargin(IconWidgetPrivate::ItemMargin, 0, 0);
// Margins for vertical mode (icon views)
d->setVerticalMargin(IconPrivate::TextMargin, 6, 2);
d->setVerticalMargin(IconPrivate::IconMargin, focusHMargin, focusVMargin);
d->setVerticalMargin(IconPrivate::ItemMargin, 0, 0);
d->setVerticalMargin(IconWidgetPrivate::TextMargin, 6, 2);
d->setVerticalMargin(IconWidgetPrivate::IconMargin, focusHMargin, focusVMargin);
d->setVerticalMargin(IconWidgetPrivate::ItemMargin, 0, 0);
d->setActiveMargins();
d->currentSize = QSizeF(-1, -1);
//setDrawStandardBackground(false);
}
void Icon::addIconAction(QAction *action)
void IconWidget::addIconAction(QAction *action)
{
int count = d->cornerActions.count();
if (count > 3) {
@ -330,10 +330,10 @@ void Icon::addIconAction(QAction *action)
d->cornerActions.append(iconAction);
connect(action, SIGNAL(destroyed(QObject*)), this, SLOT(actionDestroyed(QObject*)));
iconAction->setRect(d->actionRect((IconPrivate::ActionPosition)count));
iconAction->setRect(d->actionRect((IconWidgetPrivate::ActionPosition)count));
}
void Icon::setAction(QAction *action)
void IconWidget::setAction(QAction *action)
{
if (d->action) {
disconnect(d->action, 0, this, 0);
@ -347,12 +347,12 @@ void Icon::setAction(QAction *action)
}
}
QAction *Icon::action() const
QAction *IconWidget::action() const
{
return d->action;
}
void Icon::actionDestroyed(QObject *action)
void IconWidget::actionDestroyed(QObject *action)
{
QList<IconAction*>::iterator it = d->cornerActions.begin();
@ -366,12 +366,12 @@ void Icon::actionDestroyed(QObject *action)
update(); // redraw since an action has been deleted.
}
int Icon::numDisplayLines()
int IconWidget::numDisplayLines()
{
return d->numDisplayLines;
}
void Icon::setNumDisplayLines(int numLines)
void IconWidget::setNumDisplayLines(int numLines)
{
if(numLines > d->maxDisplayLines) {
d->numDisplayLines = d->maxDisplayLines;
@ -380,7 +380,7 @@ void Icon::setNumDisplayLines(int numLines)
}
}
void Icon::setDrawBackground(bool draw)
void IconWidget::setDrawBackground(bool draw)
{
if (d->drawBg != draw) {
d->drawBg = draw;
@ -388,12 +388,12 @@ void Icon::setDrawBackground(bool draw)
}
}
bool Icon::drawBackground() const
bool IconWidget::drawBackground() const
{
return d->drawBg;
}
QPainterPath Icon::shape() const
QPainterPath IconWidget::shape() const
{
if (d->currentSize.width() < 1) {
return QGraphicsItem::shape();
@ -403,7 +403,7 @@ QPainterPath Icon::shape() const
QRectF(QPointF(0.0, 0.0), d->currentSize).adjusted(-2, -2, 2, 2), 10.0);
}
QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
QSizeF IconWidgetPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, const qreal width) const
{
if (text.isEmpty() && infoText.isEmpty()) {
return QSizeF(.0, .0);
@ -414,8 +414,8 @@ QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, cons
// we actually need the actual width.
qreal textWidth = width -
horizontalMargin[IconPrivate::TextMargin].left -
horizontalMargin[IconPrivate::TextMargin].right;
horizontalMargin[IconWidgetPrivate::TextMargin].left -
horizontalMargin[IconWidgetPrivate::TextMargin].right;
//allow only five lines of text
const qreal maxHeight =
@ -434,7 +434,7 @@ QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, cons
return addMargin(size, TextMargin);
}
void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
void IconWidget::layoutIcons(const QStyleOptionGraphicsItem *option)
{
if (size() == d->currentSize) {
return;
@ -452,8 +452,8 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
if (!d->text.isEmpty() || !d->infoText.isEmpty()) {
heightAvail = d->currentSize.height() -
d->displaySizeHint(option, d->currentSize.width()).height() -
d->verticalMargin[IconPrivate::TextMargin].top -
d->verticalMargin[IconPrivate::TextMargin].bottom;
d->verticalMargin[IconWidgetPrivate::TextMargin].top -
d->verticalMargin[IconWidgetPrivate::TextMargin].bottom;
//never make a label higher than half the total height
heightAvail = qMax(heightAvail, d->currentSize.height() / 2);
} else {
@ -463,12 +463,12 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
//aspect ratio very "tall"
if (d->currentSize.width() < heightAvail) {
iconWidth = d->currentSize.width() -
d->horizontalMargin[IconPrivate::IconMargin].left -
d->horizontalMargin[IconPrivate::IconMargin].right;
d->horizontalMargin[IconWidgetPrivate::IconMargin].left -
d->horizontalMargin[IconWidgetPrivate::IconMargin].right;
} else {
iconWidth = heightAvail -
d->verticalMargin[IconPrivate::IconMargin].top -
d->verticalMargin[IconPrivate::IconMargin].bottom;
d->verticalMargin[IconWidgetPrivate::IconMargin].top -
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom;
}
} else {
//Horizontal layout
@ -478,12 +478,12 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
if (d->text.isEmpty() && d->infoText.isEmpty()) {
// with no text, we just take up the whole geometry
iconWidth = d->currentSize.width() -
d->horizontalMargin[IconPrivate::IconMargin].left -
d->horizontalMargin[IconPrivate::IconMargin].right;
d->horizontalMargin[IconWidgetPrivate::IconMargin].left -
d->horizontalMargin[IconWidgetPrivate::IconMargin].right;
} else {
iconWidth = d->currentSize.height() -
d->verticalMargin[IconPrivate::IconMargin].top -
d->verticalMargin[IconPrivate::IconMargin].bottom;
d->verticalMargin[IconWidgetPrivate::IconMargin].top -
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom;
}
}
@ -491,12 +491,12 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
int count = 0;
foreach (IconAction *iconAction, d->cornerActions) {
iconAction->setRect(d->actionRect((IconPrivate::ActionPosition)count));
iconAction->setRect(d->actionRect((IconWidgetPrivate::ActionPosition)count));
++count;
}
}
void Icon::setSvg(const QString &svgFilePath, const QString &elementId)
void IconWidget::setSvg(const QString &svgFilePath, const QString &elementId)
{
if (!d->iconSvg) {
d->iconSvg = new Plasma::Svg(this);
@ -507,10 +507,10 @@ void Icon::setSvg(const QString &svgFilePath, const QString &elementId)
d->iconSvgElement = elementId;
}
void Icon::hoverEffect(bool show)
void IconWidget::hoverEffect(bool show)
{
if (show) {
d->states |= IconPrivate::HoverState;
d->states |= IconWidgetPrivate::HoverState;
}
d->m_fadeIn = show;
@ -524,7 +524,7 @@ void Icon::hoverEffect(bool show)
Animator::EaseOutCurve, this, "hoverAnimationUpdate");
}
void Icon::hoverAnimationUpdate(qreal progress)
void IconWidget::hoverAnimationUpdate(qreal progress)
{
if (d->m_fadeIn) {
d->m_hoverAlpha = progress;
@ -538,14 +538,14 @@ void Icon::hoverAnimationUpdate(qreal progress)
d->m_hoverAnimId = -1;
if (!d->m_fadeIn) {
d->states &= ~IconPrivate::HoverState;
d->states &= ~IconWidgetPrivate::HoverState;
}
}
update();
}
void IconPrivate::drawBackground(QPainter *painter, IconState state)
void IconWidgetPrivate::drawBackground(QPainter *painter, IconWidgetState state)
{
if (!drawBg) {
return;
@ -556,14 +556,14 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
QColor border = textColor;
switch (state) {
case IconPrivate::HoverState:
case IconWidgetPrivate::HoverState:
shadow.setHsv(
shadow.hue(),
shadow.saturation(),
shadow.value() + (int)(darkShadow ? 50 * m_hoverAlpha: -50 * m_hoverAlpha),
200 + (int)m_hoverAlpha * 55); // opacity
break;
case IconPrivate::PressedState:
case IconWidgetPrivate::PressedState:
shadow.setHsv(
shadow.hue(),
shadow.saturation(),
@ -591,7 +591,7 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
painter->restore();
}
QPixmap IconPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
{
QPixmap result;
@ -637,13 +637,13 @@ QPixmap IconPrivate::decoration(const QStyleOptionGraphicsItem *option, bool use
return result;
}
QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option,
const QPixmap &pixmap) const
QPointF IconWidgetPrivate::iconPosition(const QStyleOptionGraphicsItem *option,
const QPixmap &pixmap) const
{
const QRectF itemRect = subtractMargin(option->rect, IconPrivate::ItemMargin);
const QRectF itemRect = subtractMargin(option->rect, IconWidgetPrivate::ItemMargin);
// Compute the nominal decoration rectangle
const QSizeF size = addMargin(iconSize, IconPrivate::IconMargin);
const QSizeF size = addMargin(iconSize, IconWidgetPrivate::IconMargin);
Qt::LayoutDirection direction = iconDirection(option);
@ -672,9 +672,9 @@ QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option,
return QPointF(pixmapRect.topLeft());
}
QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
const QPixmap &icon,
const QString &string) const
QRectF IconWidgetPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
const QPixmap &icon,
const QString &string) const
{
Q_UNUSED(string)
@ -682,8 +682,8 @@ QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
return option->rect;
}
const QSizeF decoSize = addMargin(iconSize, IconPrivate::IconMargin);
const QRectF itemRect = subtractMargin(option->rect, IconPrivate::ItemMargin);
const QSizeF decoSize = addMargin(iconSize, IconWidgetPrivate::IconMargin);
const QRectF itemRect = subtractMargin(option->rect, IconWidgetPrivate::ItemMargin);
QRectF textArea(QPointF(0, 0), itemRect.size());
if (orientation == Qt::Vertical) {
@ -698,8 +698,8 @@ QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
}
// Lays the text out in a rectangle no larger than constraints, eliding it as necessary
QSizeF IconPrivate::layoutText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
const QString &text, const QSizeF &constraints) const
QSizeF IconWidgetPrivate::layoutText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
const QString &text, const QSizeF &constraints) const
{
const QSizeF size = layoutText(layout, text, constraints.width());
@ -712,7 +712,7 @@ QSizeF IconPrivate::layoutText(QTextLayout &layout, const QStyleOptionGraphicsIt
}
// Lays the text out in a rectangle no wider than maxWidth
QSizeF IconPrivate::layoutText(QTextLayout &layout, const QString &text, qreal maxWidth) const
QSizeF IconWidgetPrivate::layoutText(QTextLayout &layout, const QString &text, qreal maxWidth) const
{
QFontMetricsF metrics(layout.font());
qreal leading = metrics.leading();
@ -740,8 +740,8 @@ QSizeF IconPrivate::layoutText(QTextLayout &layout, const QString &text, qreal m
// or word breaking the line if it's wider than the max width, and finally adding an
// ellipses at the end of the last line, if there are more lines than will fit within
// the vertical size constraints.
QString IconPrivate::elidedText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
const QSizeF &size) const
QString IconWidgetPrivate::elidedText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
const QSizeF &size) const
{
Q_UNUSED(option)
@ -785,9 +785,9 @@ QString IconPrivate::elidedText(QTextLayout &layout, const QStyleOptionGraphicsI
return elided;
}
void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
const QPixmap &icon, QTextLayout *labelLayout,
QTextLayout *infoLayout, QRectF *textBoundingRect) const
void IconWidgetPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
const QPixmap &icon, QTextLayout *labelLayout,
QTextLayout *infoLayout, QRectF *textBoundingRect) const
{
bool showInformation = false;
@ -795,7 +795,7 @@ void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
QFontMetricsF fm(labelLayout->font());
const QRectF textArea = labelRectangle(option, icon, text);
QRectF textRect = subtractMargin(textArea, IconPrivate::TextMargin);
QRectF textRect = subtractMargin(textArea, IconWidgetPrivate::TextMargin);
//kDebug() << this << "text area" << textArea << "text rect" << textRect;
// Sizes and constraints for the different text parts
@ -837,7 +837,7 @@ void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
//kDebug() << "final position is" << labelLayout->position();
}
QBrush IconPrivate::foregroundBrush(const QStyleOptionGraphicsItem *option) const
QBrush IconWidgetPrivate::foregroundBrush(const QStyleOptionGraphicsItem *option) const
{
const QPalette::ColorGroup group = option->state & QStyle::State_Enabled ?
QPalette::Normal : QPalette::Disabled;
@ -849,7 +849,7 @@ QBrush IconPrivate::foregroundBrush(const QStyleOptionGraphicsItem *option) cons
return option->palette.brush(group, QPalette::Text);
}
QBrush IconPrivate::backgroundBrush(const QStyleOptionGraphicsItem *option) const
QBrush IconWidgetPrivate::backgroundBrush(const QStyleOptionGraphicsItem *option) const
{
const QPalette::ColorGroup group = option->state & QStyle::State_Enabled ?
QPalette::Normal : QPalette::Disabled;
@ -863,10 +863,10 @@ QBrush IconPrivate::backgroundBrush(const QStyleOptionGraphicsItem *option) cons
return background;
}
void IconPrivate::drawTextItems(QPainter *painter,
const QStyleOptionGraphicsItem *option,
const QTextLayout &labelLayout,
const QTextLayout &infoLayout) const
void IconWidgetPrivate::drawTextItems(QPainter *painter,
const QStyleOptionGraphicsItem *option,
const QTextLayout &labelLayout,
const QTextLayout &infoLayout) const
{
Q_UNUSED(option)
@ -886,12 +886,12 @@ void IconPrivate::drawTextItems(QPainter *painter,
painter->restore();
}
void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void IconWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
#ifdef BACKINGSTORE_BLUR_HACK
if (d->state == IconPrivate::HoverState && scene()) {
if (d->state == IconWidgetPrivate::HoverState && scene()) {
QList<QGraphicsView*> views = scene()->views();
if (views.count() > 0) {
QPixmap* pix = static_cast<QPixmap*>(views[0]->windowSurface()->paintDevice());
@ -911,18 +911,18 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
// Compute the metrics, and lay out the text items
// ========================================================================
IconPrivate::IconState state = IconPrivate::NoState;
if (d->states & IconPrivate::ManualPressedState) {
state = IconPrivate::PressedState;
} else if (d->states & IconPrivate::PressedState) {
if (d->states & IconPrivate::HoverState) {
state = IconPrivate::PressedState;
IconWidgetPrivate::IconWidgetState state = IconWidgetPrivate::NoState;
if (d->states & IconWidgetPrivate::ManualPressedState) {
state = IconWidgetPrivate::PressedState;
} else if (d->states & IconWidgetPrivate::PressedState) {
if (d->states & IconWidgetPrivate::HoverState) {
state = IconWidgetPrivate::PressedState;
}
} else if (d->states & IconPrivate::HoverState) {
state = IconPrivate::HoverState;
} else if (d->states & IconWidgetPrivate::HoverState) {
state = IconWidgetPrivate::HoverState;
}
QPixmap icon = d->decoration(option, state != IconPrivate::NoState);
QPixmap icon = d->decoration(option, state != IconWidgetPrivate::NoState);
const QPointF iconPos = d->iconPosition(option, icon);
d->drawBackground(painter, state);
@ -963,15 +963,15 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
d->drawTextItems(painter, option, labelLayout, infoLayout);
}
void Icon::drawActionButtonBase(QPainter *painter, const QSize &size, int element)
void IconWidget::drawActionButtonBase(QPainter *painter, const QSize &size, int element)
{
qreal radius = size.width() / 2;
QRadialGradient gradient(radius, radius, radius, radius, radius);
int alpha;
if (element == IconPrivate::MinibuttonPressed) {
if (element == IconWidgetPrivate::MinibuttonPressed) {
alpha = 255;
} else if (element == IconPrivate::MinibuttonHover) {
} else if (element == IconWidgetPrivate::MinibuttonHover) {
alpha = 200;
} else {
alpha = 160;
@ -988,7 +988,7 @@ void Icon::drawActionButtonBase(QPainter *painter, const QSize &size, int elemen
painter->drawEllipse(QRectF(QPointF(.0, .0), size));
}
void Icon::setText(const QString &text)
void IconWidget::setText(const QString &text)
{
d->text = text;
// cause a relayout
@ -1001,12 +1001,12 @@ void Icon::setText(const QString &text)
resize(sizeFromIconSize(d->iconSize.width()));
}
QString Icon::text() const
QString IconWidget::text() const
{
return d->text;
}
void Icon::setInfoText(const QString &text)
void IconWidget::setInfoText(const QString &text)
{
d->infoText = text;
// cause a relayout
@ -1018,17 +1018,17 @@ void Icon::setInfoText(const QString &text)
resize(sizeFromIconSize(d->iconSize.width()));
}
QString Icon::infoText() const
QString IconWidget::infoText() const
{
return d->infoText;
}
QIcon Icon::icon() const
QIcon IconWidget::icon() const
{
return d->icon;
}
void Icon::setIcon(const QString &icon)
void IconWidget::setIcon(const QString &icon)
{
if (icon.isEmpty()) {
setIcon(QIcon());
@ -1038,29 +1038,29 @@ void Icon::setIcon(const QString &icon)
setIcon(KIcon(icon));
}
void Icon::setIcon(const QIcon &icon)
void IconWidget::setIcon(const QIcon &icon)
{
d->icon = icon;
}
QSizeF Icon::iconSize() const
QSizeF IconWidget::iconSize() const
{
return d->iconSize;
}
bool Icon::isDown()
bool IconWidget::isDown()
{
return d->states & IconPrivate::PressedState;
return d->states & IconWidgetPrivate::PressedState;
}
void Icon::mousePressEvent(QGraphicsSceneMouseEvent *event)
void IconWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() != Qt::LeftButton) {
QGraphicsWidget::mousePressEvent(event);
return;
}
d->states |= IconPrivate::PressedState;
d->states |= IconWidgetPrivate::PressedState;
d->clickStartPos = scenePos();
bool handled = false;
@ -1078,34 +1078,34 @@ void Icon::mousePressEvent(QGraphicsSceneMouseEvent *event)
update();
}
void Icon::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void IconWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if (~d->states & IconPrivate::PressedState) {
if (~d->states & IconWidgetPrivate::PressedState) {
QGraphicsWidget::mouseMoveEvent(event);
return;
}
if (boundingRect().contains(event->pos())) {
if (~d->states & IconPrivate::HoverState) {
d->states |= IconPrivate::HoverState;
if (~d->states & IconWidgetPrivate::HoverState) {
d->states |= IconWidgetPrivate::HoverState;
update();
}
} else {
if (d->states & IconPrivate::HoverState) {
d->states &= ~IconPrivate::HoverState;
if (d->states & IconWidgetPrivate::HoverState) {
d->states &= ~IconWidgetPrivate::HoverState;
update();
}
}
}
void Icon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void IconWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (~d->states & IconPrivate::PressedState) {
if (~d->states & IconWidgetPrivate::PressedState) {
QGraphicsWidget::mouseMoveEvent(event);
return;
}
d->states &= ~IconPrivate::PressedState;
d->states &= ~IconWidgetPrivate::PressedState;
//don't pass click when the mouse was moved
bool handled = d->clickStartPos != scenePos();
@ -1131,7 +1131,7 @@ void Icon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
update();
}
void Icon::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void IconWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
@ -1141,7 +1141,7 @@ void Icon::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
}
}
void Icon::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void IconWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
foreach (IconAction *action, d->cornerActions) {
action->show();
@ -1153,37 +1153,37 @@ void Icon::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
QGraphicsWidget::hoverEnterEvent(event);
}
void Icon::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void IconWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
foreach (IconAction *action, d->cornerActions) {
action->hide();
action->event(event->type(), event->pos());
}
// d->states &= ~IconPrivate::HoverState; // Will be set once progress is zero again ...
// d->states &= ~IconWidgetPrivate::HoverState; // Will be set once progress is zero again ...
hoverEffect(false);
update();
QGraphicsWidget::hoverLeaveEvent(event);
}
void Icon::setPressed(bool pressed)
void IconWidget::setPressed(bool pressed)
{
if (pressed) {
d->states |= IconPrivate::ManualPressedState;
d->states |= IconPrivate::PressedState;
d->states |= IconWidgetPrivate::ManualPressedState;
d->states |= IconWidgetPrivate::PressedState;
} else {
d->states &= ~IconPrivate::ManualPressedState;
d->states &= ~IconPrivate::PressedState;
d->states &= ~IconWidgetPrivate::ManualPressedState;
d->states &= ~IconWidgetPrivate::PressedState;
}
update();
}
void Icon::setUnpressed()
void IconWidget::setUnpressed()
{
setPressed(false);
}
void IconPrivate::syncToAction()
void IconWidgetPrivate::syncToAction()
{
if (!action) {
return;
@ -1198,28 +1198,28 @@ void IconPrivate::syncToAction()
emit q->changed();
}
void Icon::setOrientation(Qt::Orientation orientation)
void IconWidget::setOrientation(Qt::Orientation orientation)
{
d->orientation = orientation;
resize(sizeFromIconSize(d->iconSize.width()));
}
void Icon::invertLayout(bool invert)
void IconWidget::invertLayout(bool invert)
{
d->invertLayout = invert;
}
bool Icon::invertedLayout() const
bool IconWidget::invertedLayout() const
{
return d->invertLayout;
}
QSizeF Icon::sizeFromIconSize(const qreal iconWidth) const
QSizeF IconWidget::sizeFromIconSize(const qreal iconWidth) const
{
if (d->text.isEmpty() && d->infoText.isEmpty()) {
//no text, less calculations
return d->addMargin(d->addMargin(QSizeF(iconWidth, iconWidth), IconPrivate::IconMargin),
IconPrivate::ItemMargin);
return d->addMargin(d->addMargin(QSizeF(iconWidth, iconWidth), IconWidgetPrivate::IconMargin),
IconWidgetPrivate::ItemMargin);
}
QFontMetricsF fm = Plasma::Theme::defaultTheme()->fontMetrics();
@ -1230,20 +1230,20 @@ QSizeF Icon::sizeFromIconSize(const qreal iconWidth) const
width = qMax(fm.width(d->text.left(12)),
fm.width(d->infoText.left(12))) +
fm.width("xx") +
d->horizontalMargin[IconPrivate::TextMargin].left +
d->horizontalMargin[IconPrivate::TextMargin].right;
d->horizontalMargin[IconWidgetPrivate::TextMargin].left +
d->horizontalMargin[IconWidgetPrivate::TextMargin].right;
width = qMax(width,
iconWidth +
d->horizontalMargin[IconPrivate::IconMargin].left +
d->horizontalMargin[IconPrivate::IconMargin].right);
d->horizontalMargin[IconWidgetPrivate::IconMargin].left +
d->horizontalMargin[IconWidgetPrivate::IconMargin].right);
} else {
width = iconWidth +
d->horizontalMargin[IconPrivate::IconMargin].left +
d->horizontalMargin[IconPrivate::IconMargin].right +
d->horizontalMargin[IconWidgetPrivate::IconMargin].left +
d->horizontalMargin[IconWidgetPrivate::IconMargin].right +
qMax(fm.width(d->text), fm.width(d->infoText)) + fm.width("xx") +
d->horizontalMargin[IconPrivate::TextMargin].left +
d->horizontalMargin[IconPrivate::TextMargin].right;
d->horizontalMargin[IconWidgetPrivate::TextMargin].left +
d->horizontalMargin[IconWidgetPrivate::TextMargin].right;
}
qreal height;
@ -1256,23 +1256,23 @@ QSizeF Icon::sizeFromIconSize(const qreal iconWidth) const
if (d->orientation == Qt::Vertical) {
height = iconWidth + textHeight +
d->verticalMargin[IconPrivate::TextMargin].top +
d->verticalMargin[IconPrivate::TextMargin].bottom +
d->verticalMargin[IconPrivate::IconMargin].top +
d->verticalMargin[IconPrivate::IconMargin].bottom;
d->verticalMargin[IconWidgetPrivate::TextMargin].top +
d->verticalMargin[IconWidgetPrivate::TextMargin].bottom +
d->verticalMargin[IconWidgetPrivate::IconMargin].top +
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom;
} else {
//Horizontal
height = qMax(iconWidth +
d->verticalMargin[IconPrivate::IconMargin].top +
d->verticalMargin[IconPrivate::IconMargin].bottom,
d->verticalMargin[IconWidgetPrivate::IconMargin].top +
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom,
textHeight +
d->verticalMargin[IconPrivate::TextMargin].top +
d->verticalMargin[IconPrivate::TextMargin].bottom);
d->verticalMargin[IconWidgetPrivate::TextMargin].top +
d->verticalMargin[IconWidgetPrivate::TextMargin].bottom);
}
return d->addMargin(QSizeF(width, height), IconPrivate::ItemMargin);
return d->addMargin(QSizeF(width, height), IconWidgetPrivate::ItemMargin);
}
} // namespace Plasma
#include "icon.moc"
#include "iconwidget.moc"

View File

@ -20,8 +20,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_ICON_H
#define PLASMA_ICON_H
#ifndef PLASMA_ICONWIDGET_H
#define PLASMA_ICONWIDGET_H
#include <QtCore/QObject>
#include <QtGui/QGraphicsTextItem>
@ -35,12 +35,12 @@
class QAction;
/**
* @class Icon plasma/widgets/icon.h <Plasma/Widgets/Icon>
* @class IconWidget plasma/widgets/iconwidget.h <Plasma/Widgets/IconWidget>
*
* @short Provides a generic icon.
*
* An icon, in this sense, is not restricted to just an image, but can also
* contain text. Currently, the Icon class is primarily used for desktop items,
* contain text. Currently, the IconWidget class is primarily used for desktop items,
* but is designed to be used anywhere an icon is needed in an applet.
*
* @author Siraj Razick <siraj@kde.org>
@ -49,9 +49,9 @@ class QAction;
namespace Plasma
{
class IconPrivate;
class IconWidgetPrivate;
class PLASMA_EXPORT Icon : public QGraphicsWidget
class PLASMA_EXPORT IconWidget : public QGraphicsWidget
{
Q_OBJECT
Q_PROPERTY(QString text READ text WRITE setText)
@ -63,30 +63,30 @@ class PLASMA_EXPORT Icon : public QGraphicsWidget
public:
/**
* Creates a new Plasma::Icon.
* Creates a new Plasma::IconWidget.
* @param parent the QGraphicsItem this icon is parented to.
*/
explicit Icon(QGraphicsItem *parent = 0);
explicit IconWidget(QGraphicsItem *parent = 0);
/**
* Convenience constructor to create a Plasma::Icon with text.
* Convenience constructor to create a Plasma::IconWidget with text.
* @param text the text that will be displayed with this icon.
* @param parent the QGraphicsItem this icon is parented to.
*/
explicit Icon(const QString &text, QGraphicsItem *parent = 0);
explicit IconWidget(const QString &text, QGraphicsItem *parent = 0);
/**
* Creates a new Plasma::Icon with text and an icon.
* Creates a new Plasma::IconWidget with text and an icon.
* @param icon the icon that will be displayed with this icon.
* @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);
IconWidget(const QIcon &icon, const QString &text, QGraphicsItem *parent = 0);
/**
* Destroys this Plasma::Icon.
* Destroys this Plasma::IconWidget.
*/
virtual ~Icon();
virtual ~IconWidget();
/**
* Returns the text associated with this icon.
@ -124,35 +124,35 @@ public:
QIcon icon() const;
/**
* Sets the graphical icon for this Plasma::Icon.
* Sets the graphical icon for this Plasma::IconWidget.
* @param icon the KIcon to associate with this icon.
*/
void setIcon(const QIcon &icon);
/**
* Convenience method to set the icon of this Plasma::Icon
* Convenience method to set the icon of this Plasma::IconWidget
* using a QString path to the icon.
* @param icon the path to the icon to associate with this Plasma::Icon.
* @param icon the path to the icon to associate with this Plasma::IconWidget.
*/
Q_INVOKABLE void setIcon(const QString &icon);
/**
* @return the size of this Plasma::Icon's graphical icon.
* @return the size of this Plasma::IconWidget's graphical icon.
*/
QSizeF iconSize() const;
/**
* Plasma::Icon allows the user to specify a number of actions
* Plasma::IconWidget allows the user to specify a number of actions
* (currently four) to be displayed around the widget. This method
* allows for a created QAction to be added to the Plasma::Icon.
* allows for a created QAction to be added to the Plasma::IconWidget.
* @param action the QAction to associate with this icon.
*/
void addIconAction(QAction *action);
/**
* Associate an action with this Icon
* this makes the Icon follow the state of the action, using its icon, text, etc.
* when the Icon is clicked, it will also trigger the action.
* Associate an action with this IconWidget
* this makes the IconWidget follow the state of the action, using its icon, text, etc.
* when the IconWidget is clicked, it will also trigger the action.
* Unlike addIconAction, there can be only one associated action.
*/
void setAction(QAction *action);
@ -282,9 +282,9 @@ private:
void layoutIcons(const QStyleOptionGraphicsItem *option);
void hoverEffect(bool);
IconPrivate * const d;
IconWidgetPrivate * const d;
friend class IconPrivate;
friend class IconWidgetPrivate;
private Q_SLOTS:
void actionDestroyed(QObject *obj);

View File

@ -19,8 +19,8 @@
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_ICON_P_H
#define PLASMA_ICON_P_H
#ifndef PLASMA_ICONWIDGET_P_H
#define PLASMA_ICONWIDGET_P_H
#include <QtCore/QEvent>
#include <QtGui/QApplication>
@ -32,7 +32,7 @@
#include <plasma/plasma_export.h>
#include <plasma/svg.h>
#include "icon.h"
#include "iconwidget.h"
#include "animator.h"
class QAction;
@ -45,7 +45,7 @@ namespace Plasma
class PLASMA_EXPORT IconAction
{
public:
IconAction(Icon *icon, QAction *action);
IconAction(IconWidget *icon, QAction *action);
void show();
void hide();
@ -69,7 +69,7 @@ public:
private:
void rebuildPixmap();
Icon *m_icon;
IconWidget *m_icon;
QAction *m_action;
QPixmap m_pixmap;
QRectF m_rect;
@ -87,7 +87,7 @@ struct Margin
qreal left, right, top, bottom;
};
class IconPrivate
class IconWidgetPrivate
{
public:
enum MarginType {
@ -97,19 +97,19 @@ public:
NMargins
};
enum IconState {
enum IconWidgetState {
NoState = 0,
HoverState = 1,
PressedState = 2,
ManualPressedState = 4
};
Q_DECLARE_FLAGS(IconStates, IconState)
Q_DECLARE_FLAGS(IconWidgetStates, IconWidgetState)
public:
IconPrivate(Icon *i);
~IconPrivate();
IconWidgetPrivate(IconWidget *i);
~IconWidgetPrivate();
void drawBackground(QPainter *painter, IconState state);
void drawBackground(QPainter *painter, IconWidgetState state);
void drawText(QPainter *painter);
void drawTextItems(QPainter *painter, const QStyleOptionGraphicsItem *option,
const QTextLayout &labelLayout, const QTextLayout &infoLayout) const;
@ -176,7 +176,7 @@ public:
*/
void syncToAction();
Icon *q;
IconWidget *q;
QString text;
QString infoText;
Svg *iconSvg;
@ -189,7 +189,7 @@ public:
qreal m_hoverAlpha;
QSizeF iconSize;
QIcon icon;
IconStates states;
IconWidgetStates states;
Qt::Orientation orientation;
int numDisplayLines;
bool invertLayout;
@ -209,11 +209,11 @@ public:
static const int iconActionMargin = 4;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(IconPrivate::IconStates)
Q_DECLARE_OPERATORS_FOR_FLAGS(IconWidgetPrivate::IconWidgetStates)
// Inline methods
void IconPrivate::setLayoutOptions(QTextLayout &layout,
const QStyleOptionGraphicsItem *option) const
void IconWidgetPrivate::setLayoutOptions(QTextLayout &layout,
const QStyleOptionGraphicsItem *option) const
{
QTextOption textoption;
textoption.setTextDirection(option->direction);
@ -224,7 +224,7 @@ void IconPrivate::setLayoutOptions(QTextLayout &layout,
layout.setTextOption(textoption);
}
Qt::LayoutDirection IconPrivate::iconDirection(const QStyleOptionGraphicsItem *option) const
Qt::LayoutDirection IconWidgetPrivate::iconDirection(const QStyleOptionGraphicsItem *option) const
{
Qt::LayoutDirection direction;
@ -241,14 +241,14 @@ Qt::LayoutDirection IconPrivate::iconDirection(const QStyleOptionGraphicsItem *o
return direction;
}
void IconPrivate::setActiveMargins()
void IconWidgetPrivate::setActiveMargins()
{
activeMargins = (orientation == Qt::Horizontal ?
horizontalMargin : verticalMargin);
}
void IconPrivate::setVerticalMargin(MarginType type, qreal left, qreal top,
qreal right, qreal bottom)
void IconWidgetPrivate::setVerticalMargin(MarginType type, qreal left, qreal top,
qreal right, qreal bottom)
{
verticalMargin[type].left = left;
verticalMargin[type].right = right;
@ -256,8 +256,8 @@ void IconPrivate::setVerticalMargin(MarginType type, qreal left, qreal top,
verticalMargin[type].bottom = bottom;
}
void IconPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top,
qreal right, qreal bottom)
void IconWidgetPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top,
qreal right, qreal bottom)
{
horizontalMargin[type].left = left;
horizontalMargin[type].right = right;
@ -265,45 +265,45 @@ void IconPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top,
horizontalMargin[type].bottom = bottom;
}
void IconPrivate::setVerticalMargin(MarginType type, qreal horizontal, qreal vertical)
void IconWidgetPrivate::setVerticalMargin(MarginType type, qreal horizontal, qreal vertical)
{
setVerticalMargin(type, horizontal, vertical, horizontal, vertical);
}
void IconPrivate::setHorizontalMargin(MarginType type, qreal horizontal, qreal vertical)
void IconWidgetPrivate::setHorizontalMargin(MarginType type, qreal horizontal, qreal vertical)
{
setHorizontalMargin(type, horizontal, vertical, horizontal, vertical);
}
QRectF IconPrivate::addMargin(const QRectF &rect, MarginType type) const
QRectF IconWidgetPrivate::addMargin(const QRectF &rect, MarginType type) const
{
Q_ASSERT(activeMargins);
const Margin &m = activeMargins[type];
return rect.adjusted(-m.left, -m.top, m.right, m.bottom);
}
QRectF IconPrivate::subtractMargin(const QRectF &rect, MarginType type) const
QRectF IconWidgetPrivate::subtractMargin(const QRectF &rect, MarginType type) const
{
Q_ASSERT(activeMargins);
const Margin &m = activeMargins[type];
return rect.adjusted(m.left, m.top, -m.right, -m.bottom);
}
QSizeF IconPrivate::addMargin(const QSizeF &size, MarginType type) const
QSizeF IconWidgetPrivate::addMargin(const QSizeF &size, MarginType type) const
{
Q_ASSERT(activeMargins);
const Margin &m = activeMargins[type];
return QSizeF(size.width() + m.left + m.right, size.height() + m.top + m.bottom);
}
QSizeF IconPrivate::subtractMargin(const QSizeF &size, MarginType type) const
QSizeF IconWidgetPrivate::subtractMargin(const QSizeF &size, MarginType type) const
{
Q_ASSERT(activeMargins);
const Margin &m = activeMargins[type];
return QSizeF(size.width() - m.left - m.right, size.height() - m.top - m.bottom);
}
QRectF IconPrivate::actionRect(ActionPosition position) const
QRectF IconWidgetPrivate::actionRect(ActionPosition position) const
{
switch (position) {
case TopLeft:

View File

@ -18,7 +18,7 @@
*/
#include "meter.h"
#include "plasma/panelsvg.h"
#include "plasma/framesvg.h"
#include <cmath>
#include <kdebug.h>
#include <QPainter>
@ -100,8 +100,8 @@ public:
image->resize();
image->setElementPrefix("background");
image->resizePanel(elementRect.size());
image->paintPanel(p, elementRect.topLeft());
image->resizeFrame(elementRect.size());
image->paintFrame(p, elementRect.topLeft());
image->resize(imageSize);
paintBar(p, "bar-inactive");
@ -136,8 +136,8 @@ public:
}
image->setElementPrefix(prefix);
image->resizePanel(tileSize);
p->drawTiledPixmap(elementRect, image->panelPixmap());
image->resizeFrame(tileSize);
p->drawTiledPixmap(elementRect, image->framePixmap());
image->resize(imageSize);
}
@ -180,7 +180,7 @@ public:
QList<QFont> fonts;
QString svg;
Meter::MeterType meterType;
Plasma::PanelSvg *image;
Plasma::FrameSvg *image;
int minrotate;
int maxrotate;
Meter *meter;
@ -300,7 +300,7 @@ void Meter::setSvg(const QString &svg)
{
d->svg = svg;
delete d->image;
d->image = new Plasma::PanelSvg(this);
d->image = new Plasma::FrameSvg(this);
d->image->setImagePath(svg);
// To create renderer and get default size
d->image->resize();

View File

@ -38,10 +38,10 @@ class MeterPrivate;
*
* Svgs can have following ids:
* - background: Drawn first to the bottom
* background can be a PanelSvg
* background can be a FrameSvg
* - label0, label1, ...: Rectangles mark the label places
* - bar: Bar for the bar meter
* can be replaced with bar-active and bar-inactive PanelSvg
* can be replaced with bar-active and bar-inactive FrameSvg
* - pointer: Pointer for analog meter
* - rotatecenter: Marks the place of pointer rotation center
* - rotateminmax: Width and height of this object are the Min and Max rotate

View File

@ -32,7 +32,7 @@
#include "theme.h"
#include "svg.h"
#include "panelsvg.h"
#include "framesvg.h"
#include "animator.h"
#include "paintutils.h"
@ -82,7 +82,7 @@ public:
PushButton *q;
PanelSvg *background;
FrameSvg *background;
int animId;
bool fadeIn;
qreal opacity;
@ -146,9 +146,9 @@ PushButton::PushButton(QGraphicsWidget *parent)
setWidget(native);
native->setAttribute(Qt::WA_NoSystemBackground);
d->background = new PanelSvg(this);
d->background = new FrameSvg(this);
d->background->setImagePath("widgets/button");
d->background->setCacheAllRenderedPanels(true);
d->background->setCacheAllRenderedFrames(true);
d->background->setElementPrefix("normal");
d->syncBorders();
setAcceptHoverEvents(true);
@ -225,17 +225,17 @@ void PushButton::resizeEvent(QGraphicsSceneResizeEvent *event)
if (d->background) {
//resize all four panels
d->background->setElementPrefix("pressed");
d->background->resizePanel(size());
d->background->resizeFrame(size());
d->background->setElementPrefix("focus");
d->background->resizePanel(size());
d->background->resizeFrame(size());
d->syncActiveRect();
d->background->setElementPrefix("active");
d->background->resizePanel(d->activeRect.size());
d->background->resizeFrame(d->activeRect.size());
d->background->setElementPrefix("normal");
d->background->resizePanel(size());
d->background->resizeFrame(size());
}
QGraphicsProxyWidget::resizeEvent(event);
@ -260,7 +260,7 @@ void PushButton::paint(QPainter *painter,
d->background->setElementPrefix("normal");
}
if (d->animId == -1) {
d->background->paintPanel(painter);
d->background->paintFrame(painter);
}
//flat or disabled
} else if (!isEnabled() || nativeWidget()->isFlat()) {
@ -268,7 +268,7 @@ void PushButton::paint(QPainter *painter,
bufferPixmap.fill(Qt::transparent);
QPainter buffPainter(&bufferPixmap);
d->background->paintPanel(&buffPainter);
d->background->paintFrame(&buffPainter);
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
@ -278,20 +278,20 @@ void PushButton::paint(QPainter *painter,
//if is under mouse draw the animated glow overlay
if (!nativeWidget()->isDown() && isEnabled() && acceptHoverEvents()) {
if (d->animId != -1) {
QPixmap normalPix = d->background->panelPixmap();
QPixmap normalPix = d->background->framePixmap();
d->background->setElementPrefix("active");
painter->drawPixmap(
d->activeRect.topLeft(),
PaintUtils::transition(d->background->panelPixmap(), normalPix, 1 - d->opacity));
PaintUtils::transition(d->background->framePixmap(), normalPix, 1 - d->opacity));
} else if (isUnderMouse() || nativeWidget()->isDefault()) {
d->background->setElementPrefix("active");
d->background->paintPanel(painter, d->activeRect.topLeft());
d->background->paintFrame(painter, d->activeRect.topLeft());
}
}
if (nativeWidget()->hasFocus()) {
d->background->setElementPrefix("focus");
d->background->paintPanel(painter);
d->background->paintFrame(painter);
}
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));

View File

@ -26,7 +26,7 @@
#include <KMimeType>
#include "theme.h"
#include "panelsvg.h"
#include "framesvg.h"
namespace Plasma
{
@ -42,8 +42,8 @@ public:
{
}
Plasma::PanelSvg *background;
Plasma::PanelSvg *handle;
Plasma::FrameSvg *background;
Plasma::FrameSvg *handle;
};
Slider::Slider(QGraphicsWidget *parent)
@ -58,11 +58,11 @@ Slider::Slider(QGraphicsWidget *parent)
setWidget(native);
native->setAttribute(Qt::WA_NoSystemBackground);
d->background = new Plasma::PanelSvg(this);
d->background = new Plasma::FrameSvg(this);
d->background->setImagePath("widgets/frame");
d->background->setElementPrefix("sunken");
d->handle = new Plasma::PanelSvg(this);
d->handle = new Plasma::FrameSvg(this);
d->handle->setImagePath("widgets/button");
d->handle->setElementPrefix("normal");
}
@ -108,8 +108,8 @@ void Slider::paint(QPainter *painter,
QRect backgroundRect =
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderGroove, slider);
d->background->resizePanel(backgroundRect.size());
d->background->paintPanel(painter, backgroundRect.topLeft());
d->background->resizeFrame(backgroundRect.size());
d->background->paintFrame(painter, backgroundRect.topLeft());
//Thickmarks
if (sliderOpt.tickPosition != QSlider::NoTicks) {
@ -121,8 +121,8 @@ void Slider::paint(QPainter *painter,
QRect handleRect =
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderHandle, slider);
d->handle->resizePanel(handleRect.size());
d->handle->paintPanel(painter, handleRect.topLeft());
d->handle->resizeFrame(handleRect.size());
d->handle->paintFrame(painter, handleRect.topLeft());
}
void Slider::setMaximum(int max)