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:
parent
871508e467
commit
f66b4d819b
@ -25,7 +25,7 @@ set(plasma_LIB_SRCS
|
|||||||
animationdriver.cpp
|
animationdriver.cpp
|
||||||
animator.cpp
|
animator.cpp
|
||||||
applet.cpp
|
applet.cpp
|
||||||
configxml.cpp
|
configloader.cpp
|
||||||
containment.cpp
|
containment.cpp
|
||||||
context.cpp
|
context.cpp
|
||||||
corona.cpp
|
corona.cpp
|
||||||
@ -37,7 +37,7 @@ set(plasma_LIB_SRCS
|
|||||||
extender.cpp
|
extender.cpp
|
||||||
extenderitem.cpp
|
extenderitem.cpp
|
||||||
paintutils.cpp
|
paintutils.cpp
|
||||||
panelsvg.cpp
|
framesvg.cpp
|
||||||
plasma.cpp
|
plasma.cpp
|
||||||
popupapplet.cpp
|
popupapplet.cpp
|
||||||
private/applethandle.cpp
|
private/applethandle.cpp
|
||||||
@ -69,10 +69,10 @@ set(plasma_LIB_SRCS
|
|||||||
wallpaper.cpp
|
wallpaper.cpp
|
||||||
widgets/checkbox.cpp
|
widgets/checkbox.cpp
|
||||||
widgets/combobox.cpp
|
widgets/combobox.cpp
|
||||||
widgets/flash.cpp
|
widgets/flashinglabel.cpp
|
||||||
widgets/frame.cpp
|
widgets/frame.cpp
|
||||||
widgets/groupbox.cpp
|
widgets/groupbox.cpp
|
||||||
widgets/icon.cpp
|
widgets/iconwidget.cpp
|
||||||
widgets/label.cpp
|
widgets/label.cpp
|
||||||
widgets/lineedit.cpp
|
widgets/lineedit.cpp
|
||||||
widgets/meter.cpp
|
widgets/meter.cpp
|
||||||
@ -140,7 +140,7 @@ set(plasma_LIB_INCLUDES
|
|||||||
animationdriver.h
|
animationdriver.h
|
||||||
animator.h
|
animator.h
|
||||||
applet.h
|
applet.h
|
||||||
configxml.h
|
configloader.h
|
||||||
containment.h
|
containment.h
|
||||||
context.h
|
context.h
|
||||||
corona.h
|
corona.h
|
||||||
@ -152,7 +152,7 @@ set(plasma_LIB_INCLUDES
|
|||||||
extender.h
|
extender.h
|
||||||
extenderitem.h
|
extenderitem.h
|
||||||
paintutils.h
|
paintutils.h
|
||||||
panelsvg.h
|
framesvg.h
|
||||||
plasma.h
|
plasma.h
|
||||||
plasma_export.h
|
plasma_export.h
|
||||||
popupapplet.h
|
popupapplet.h
|
||||||
@ -183,10 +183,10 @@ install(FILES
|
|||||||
install(FILES
|
install(FILES
|
||||||
widgets/checkbox.h
|
widgets/checkbox.h
|
||||||
widgets/combobox.h
|
widgets/combobox.h
|
||||||
widgets/flash.h
|
widgets/flashinglabel.h
|
||||||
widgets/frame.h
|
widgets/frame.h
|
||||||
widgets/groupbox.h
|
widgets/groupbox.h
|
||||||
widgets/icon.h
|
widgets/iconwidget.h
|
||||||
widgets/label.h
|
widgets/label.h
|
||||||
widgets/lineedit.h
|
widgets/lineedit.h
|
||||||
widgets/meter.h
|
widgets/meter.h
|
||||||
@ -218,7 +218,7 @@ includes/Applet
|
|||||||
includes/AppletScript
|
includes/AppletScript
|
||||||
includes/CheckBox
|
includes/CheckBox
|
||||||
includes/ComboBox
|
includes/ComboBox
|
||||||
includes/ConfigXml
|
includes/ConfigLoader
|
||||||
includes/Containment
|
includes/Containment
|
||||||
includes/Context
|
includes/Context
|
||||||
includes/Corona
|
includes/Corona
|
||||||
@ -230,10 +230,11 @@ includes/Delegate
|
|||||||
includes/Dialog
|
includes/Dialog
|
||||||
includes/Extender
|
includes/Extender
|
||||||
includes/ExtenderItem
|
includes/ExtenderItem
|
||||||
includes/Flash
|
includes/FlashingLabel
|
||||||
includes/Frame
|
includes/Frame
|
||||||
|
includes/FrameSvg
|
||||||
includes/GroupBox
|
includes/GroupBox
|
||||||
includes/Icon
|
includes/IconWidget
|
||||||
includes/Label
|
includes/Label
|
||||||
includes/LineEdit
|
includes/LineEdit
|
||||||
includes/Meter
|
includes/Meter
|
||||||
@ -241,7 +242,6 @@ includes/Package
|
|||||||
includes/PackageMetadata
|
includes/PackageMetadata
|
||||||
includes/PackageStructure
|
includes/PackageStructure
|
||||||
includes/PaintUtils
|
includes/PaintUtils
|
||||||
includes/PanelSvg
|
|
||||||
includes/Plasma
|
includes/Plasma
|
||||||
includes/PopupApplet
|
includes/PopupApplet
|
||||||
includes/PushButton
|
includes/PushButton
|
||||||
|
@ -45,7 +45,7 @@ Other important classes are:
|
|||||||
for libplasma
|
for libplasma
|
||||||
- Plasma::PopupApplet: provides a simple way of implementing a Plasma::Applet
|
- Plasma::PopupApplet: provides a simple way of implementing a Plasma::Applet
|
||||||
consisting of an icon that shows a popup when clicked
|
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::Wallpaper: provides pluggable backgrounds for containments
|
||||||
- Plasma::AppletScript, Plasma::DataEngineScript, Plasma::RunnerScript and
|
- Plasma::AppletScript, Plasma::DataEngineScript, Plasma::RunnerScript and
|
||||||
Plasma::ScriptEngine: provide scripting interfaces for plugins
|
Plasma::ScriptEngine: provide scripting interfaces for plugins
|
||||||
|
41
applet.cpp
41
applet.cpp
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
#include <Solid/PowerManagement>
|
#include <Solid/PowerManagement>
|
||||||
|
|
||||||
#include "configxml.h"
|
#include "configloader.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
#include "dataenginemanager.h"
|
#include "dataenginemanager.h"
|
||||||
@ -68,10 +68,11 @@
|
|||||||
#include "plasma.h"
|
#include "plasma.h"
|
||||||
#include "scripting/appletscript.h"
|
#include "scripting/appletscript.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
#include "panelsvg.h"
|
#include "framesvg.h"
|
||||||
#include "popupapplet.h"
|
#include "popupapplet.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "widgets/iconwidget.h"
|
||||||
#include "widgets/label.h"
|
#include "widgets/label.h"
|
||||||
#include "widgets/pushbutton.h"
|
#include "widgets/pushbutton.h"
|
||||||
#include "tooltipmanager.h"
|
#include "tooltipmanager.h"
|
||||||
@ -285,7 +286,7 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason)
|
|||||||
QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this);
|
QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout(this);
|
||||||
failureLayout->setContentsMargins(0, 0, 0, 0);
|
failureLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
Icon *failureIcon = new Icon(this);
|
IconWidget *failureIcon = new IconWidget(this);
|
||||||
failureIcon->setIcon(KIcon("dialog-error"));
|
failureIcon->setIcon(KIcon("dialog-error"));
|
||||||
failureLayout->addItem(failureIcon);
|
failureLayout->addItem(failureIcon);
|
||||||
|
|
||||||
@ -305,7 +306,7 @@ void Applet::setFailedToLaunch(bool failed, const QString &reason)
|
|||||||
setLayout(failureLayout);
|
setLayout(failureLayout);
|
||||||
resize(300, 250);
|
resize(300, 250);
|
||||||
setMinimumSize(failureLayout->minimumSize());
|
setMinimumSize(failureLayout->minimumSize());
|
||||||
d->background->resizePanel(geometry().size());
|
d->background->resizeFrame(geometry().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
@ -425,17 +426,17 @@ void AppletPrivate::cleanUpAndDelete()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configXml) {
|
if (configLoader) {
|
||||||
configXml->setDefaults();
|
configLoader->setDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
q->scene()->removeItem(q);
|
q->scene()->removeItem(q);
|
||||||
q->deleteLater();
|
q->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXml *Applet::configScheme() const
|
ConfigLoader *Applet::configScheme() const
|
||||||
{
|
{
|
||||||
return d->configXml;
|
return d->configLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine *Applet::dataEngine(const QString &name) const
|
DataEngine *Applet::dataEngine(const QString &name) const
|
||||||
@ -656,7 +657,7 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
|
|||||||
//Draw the standard background?
|
//Draw the standard background?
|
||||||
if ((hints & StandardBackground) || (hints & TranslucentBackground)) {
|
if ((hints & StandardBackground) || (hints & TranslucentBackground)) {
|
||||||
if (!d->background) {
|
if (!d->background) {
|
||||||
d->background = new Plasma::PanelSvg(this);
|
d->background = new Plasma::FrameSvg(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hints & TranslucentBackground) &&
|
if ((hints & TranslucentBackground) &&
|
||||||
@ -666,7 +667,7 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
|
|||||||
d->background->setImagePath("widgets/background");
|
d->background->setImagePath("widgets/background");
|
||||||
}
|
}
|
||||||
|
|
||||||
d->background->setEnabledBorders(Plasma::PanelSvg::AllBorders);
|
d->background->setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
d->background->getMargins(left, top, right, bottom);
|
d->background->getMargins(left, top, right, bottom);
|
||||||
setContentsMargins(left, right, top, bottom);
|
setContentsMargins(left, right, top, bottom);
|
||||||
@ -674,7 +675,7 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
|
|||||||
if (minimumSize().expandedTo(fitSize) != minimumSize()) {
|
if (minimumSize().expandedTo(fitSize) != minimumSize()) {
|
||||||
setMinimumSize(minimumSize().expandedTo(fitSize));
|
setMinimumSize(minimumSize().expandedTo(fitSize));
|
||||||
}
|
}
|
||||||
d->background->resizePanel(boundingRect().size());
|
d->background->resizeFrame(boundingRect().size());
|
||||||
} else if (d->background) {
|
} else if (d->background) {
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
d->background->getMargins(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::Vertical &&
|
||||||
formFactor() != Plasma::Horizontal) {
|
formFactor() != Plasma::Horizontal) {
|
||||||
//kDebug() << "option rect is" << option->rect;
|
//kDebug() << "option rect is" << option->rect;
|
||||||
d->background->paintPanel(p);
|
d->background->paintFrame(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->failed) {
|
if (!d->failed) {
|
||||||
@ -1252,7 +1253,7 @@ void Applet::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
QGraphicsWidget::resizeEvent(event);
|
QGraphicsWidget::resizeEvent(event);
|
||||||
|
|
||||||
if (d->background) {
|
if (d->background) {
|
||||||
d->background->resizePanel(boundingRect().size());
|
d->background->resizeFrame(boundingRect().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateConstraints(Plasma::SizeConstraint);
|
updateConstraints(Plasma::SizeConstraint);
|
||||||
@ -1289,13 +1290,13 @@ void Applet::showConfigurationInterface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QString windowTitle = i18nc("@title:window", "%1 Settings", name());
|
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");
|
QString uiFile = d->package->filePath("mainconfigui");
|
||||||
if (uiFile.isEmpty()) {
|
if (uiFile.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigDialog *dialog = new KConfigDialog(0, dialogId, d->configXml);
|
KConfigDialog *dialog = new KConfigDialog(0, dialogId, d->configLoader);
|
||||||
dialog->setWindowTitle(windowTitle);
|
dialog->setWindowTitle(windowTitle);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
|
||||||
@ -1665,7 +1666,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
|
|||||||
background(0),
|
background(0),
|
||||||
script(0),
|
script(0),
|
||||||
package(0),
|
package(0),
|
||||||
configXml(0),
|
configLoader(0),
|
||||||
mainConfig(0),
|
mainConfig(0),
|
||||||
pendingConstraints(NoConstraint),
|
pendingConstraints(NoConstraint),
|
||||||
aspectRatioMode(Plasma::KeepAspectRatio),
|
aspectRatioMode(Plasma::KeepAspectRatio),
|
||||||
@ -1709,8 +1710,8 @@ AppletPrivate::~AppletPrivate()
|
|||||||
script = 0;
|
script = 0;
|
||||||
delete package;
|
delete package;
|
||||||
package = 0;
|
package = 0;
|
||||||
delete configXml;
|
delete configLoader;
|
||||||
configXml = 0;
|
configLoader = 0;
|
||||||
delete mainConfig;
|
delete mainConfig;
|
||||||
mainConfig = 0;
|
mainConfig = 0;
|
||||||
}
|
}
|
||||||
@ -1795,8 +1796,8 @@ void AppletPrivate::setupScriptSupport()
|
|||||||
QFile file(xmlPath);
|
QFile file(xmlPath);
|
||||||
// FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/
|
// FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/
|
||||||
KConfigGroup config = q->config();
|
KConfigGroup config = q->config();
|
||||||
configXml = new ConfigXml(&config, &file);
|
configLoader = new ConfigLoader(&config, &file);
|
||||||
QObject::connect(configXml, SIGNAL(configChanged()), q, SLOT(configChanged()));
|
QObject::connect(configLoader, SIGNAL(configChanged()), q, SLOT(configChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!package->filePath("mainconfigui").isEmpty()) {
|
if (!package->filePath("mainconfigui").isEmpty()) {
|
||||||
|
4
applet.h
4
applet.h
@ -31,7 +31,7 @@
|
|||||||
#include <KDE/KPluginInfo>
|
#include <KDE/KPluginInfo>
|
||||||
#include <KDE/KShortcut>
|
#include <KDE/KShortcut>
|
||||||
|
|
||||||
#include <plasma/configxml.h>
|
#include <plasma/configloader.h>
|
||||||
#include <plasma/packagestructure.h>
|
#include <plasma/packagestructure.h>
|
||||||
#include <plasma/plasma.h>
|
#include <plasma/plasma.h>
|
||||||
#include <plasma/animator.h>
|
#include <plasma/animator.h>
|
||||||
@ -168,7 +168,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
|||||||
*
|
*
|
||||||
* @return config skeleton object, or 0 if none
|
* @return config skeleton object, or 0 if none
|
||||||
**/
|
**/
|
||||||
ConfigXml *configScheme() const;
|
ConfigLoader *configScheme() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the given DataEngine
|
* Loads the given DataEngine
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "configxml.h"
|
#include "configloader.h"
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
@ -32,10 +32,10 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConfigXmlPrivate
|
class ConfigLoaderPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~ConfigXmlPrivate()
|
~ConfigLoaderPrivate()
|
||||||
{
|
{
|
||||||
qDeleteAll(bools);
|
qDeleteAll(bools);
|
||||||
qDeleteAll(strings);
|
qDeleteAll(strings);
|
||||||
@ -175,7 +175,7 @@ class ConfigXmlPrivate
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse(ConfigXml *configXml, QIODevice *xml);
|
void parse(ConfigLoader *loader, QIODevice *xml);
|
||||||
|
|
||||||
QList<bool *> bools;
|
QList<bool *> bools;
|
||||||
QList<QString *> strings;
|
QList<QString *> strings;
|
||||||
@ -199,10 +199,10 @@ class ConfigXmlPrivate
|
|||||||
QHash<QString, QString> keysToNames;
|
QHash<QString, QString> keysToNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigXmlHandler : public QXmlDefaultHandler
|
class ConfigLoaderHandler : public QXmlDefaultHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d);
|
ConfigLoaderHandler(ConfigLoader *config, ConfigLoaderPrivate *d);
|
||||||
bool startElement(const QString &namespaceURI, const QString &localName,
|
bool startElement(const QString &namespaceURI, const QString &localName,
|
||||||
const QString &qName, const QXmlAttributes &atts);
|
const QString &qName, const QXmlAttributes &atts);
|
||||||
bool endElement(const QString &namespaceURI, const QString &localName,
|
bool endElement(const QString &namespaceURI, const QString &localName,
|
||||||
@ -213,8 +213,8 @@ private:
|
|||||||
void addItem();
|
void addItem();
|
||||||
void resetState();
|
void resetState();
|
||||||
|
|
||||||
ConfigXml *m_config;
|
ConfigLoader *m_config;
|
||||||
ConfigXmlPrivate *d;
|
ConfigLoaderPrivate *d;
|
||||||
int m_min;
|
int m_min;
|
||||||
int m_max;
|
int m_max;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
@ -231,16 +231,16 @@ private:
|
|||||||
bool m_inChoice;
|
bool m_inChoice;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ConfigXmlPrivate::parse(ConfigXml *configXml, QIODevice *xml)
|
void ConfigLoaderPrivate::parse(ConfigLoader *loader, QIODevice *xml)
|
||||||
{
|
{
|
||||||
QXmlInputSource source(xml);
|
QXmlInputSource source(xml);
|
||||||
QXmlSimpleReader reader;
|
QXmlSimpleReader reader;
|
||||||
ConfigXmlHandler handler(configXml, this);
|
ConfigLoaderHandler handler(loader, this);
|
||||||
reader.setContentHandler(&handler);
|
reader.setContentHandler(&handler);
|
||||||
reader.parse(&source, false);
|
reader.parse(&source, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXmlHandler::ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d)
|
ConfigLoaderHandler::ConfigLoaderHandler(ConfigLoader *config, ConfigLoaderPrivate *d)
|
||||||
: QXmlDefaultHandler(),
|
: QXmlDefaultHandler(),
|
||||||
m_config(config),
|
m_config(config),
|
||||||
d(d)
|
d(d)
|
||||||
@ -248,13 +248,13 @@ ConfigXmlHandler::ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d)
|
|||||||
resetState();
|
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)
|
const QString &qName, const QXmlAttributes &attrs)
|
||||||
{
|
{
|
||||||
Q_UNUSED(namespaceURI)
|
Q_UNUSED(namespaceURI)
|
||||||
Q_UNUSED(qName)
|
Q_UNUSED(qName)
|
||||||
|
|
||||||
// kDebug() << "ConfigXmlHandler::startElement(" << localName << qName;
|
// kDebug() << "ConfigLoaderHandler::startElement(" << localName << qName;
|
||||||
int numAttrs = attrs.count();
|
int numAttrs = attrs.count();
|
||||||
QString tag = localName.toLower();
|
QString tag = localName.toLower();
|
||||||
if (tag == "group") {
|
if (tag == "group") {
|
||||||
@ -302,19 +302,19 @@ bool ConfigXmlHandler::startElement(const QString &namespaceURI, const QString &
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigXmlHandler::characters(const QString &ch)
|
bool ConfigLoaderHandler::characters(const QString &ch)
|
||||||
{
|
{
|
||||||
m_cdata.append(ch);
|
m_cdata.append(ch);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigXmlHandler::endElement(const QString &namespaceURI,
|
bool ConfigLoaderHandler::endElement(const QString &namespaceURI,
|
||||||
const QString &localName, const QString &qName)
|
const QString &localName, const QString &qName)
|
||||||
{
|
{
|
||||||
Q_UNUSED(namespaceURI)
|
Q_UNUSED(namespaceURI)
|
||||||
Q_UNUSED(qName)
|
Q_UNUSED(qName)
|
||||||
|
|
||||||
// kDebug() << "ConfigXmlHandler::endElement(" << localName << qName;
|
// kDebug() << "ConfigLoaderHandler::endElement(" << localName << qName;
|
||||||
QString tag = localName.toLower();
|
QString tag = localName.toLower();
|
||||||
if (tag == "entry") {
|
if (tag == "entry") {
|
||||||
addItem();
|
addItem();
|
||||||
@ -346,7 +346,7 @@ bool ConfigXmlHandler::endElement(const QString &namespaceURI,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigXmlHandler::addItem()
|
void ConfigLoaderHandler::addItem()
|
||||||
{
|
{
|
||||||
if (m_name.isEmpty()) {
|
if (m_name.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -498,7 +498,7 @@ void ConfigXmlHandler::addItem()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigXmlHandler::resetState()
|
void ConfigLoaderHandler::resetState()
|
||||||
{
|
{
|
||||||
m_haveMin = false;
|
m_haveMin = false;
|
||||||
m_min = 0;
|
m_min = 0;
|
||||||
@ -514,16 +514,16 @@ void ConfigXmlHandler::resetState()
|
|||||||
m_inChoice = false;
|
m_inChoice = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXml::ConfigXml(const QString &configFile, QIODevice *xml, QObject *parent)
|
ConfigLoader::ConfigLoader(const QString &configFile, QIODevice *xml, QObject *parent)
|
||||||
: KConfigSkeleton(configFile, parent),
|
: KConfigSkeleton(configFile, parent),
|
||||||
d(new ConfigXmlPrivate)
|
d(new ConfigLoaderPrivate)
|
||||||
{
|
{
|
||||||
d->parse(this, xml);
|
d->parse(this, xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXml::ConfigXml(KSharedConfigPtr config, QIODevice *xml, QObject *parent)
|
ConfigLoader::ConfigLoader(KSharedConfigPtr config, QIODevice *xml, QObject *parent)
|
||||||
: KConfigSkeleton(config, parent),
|
: KConfigSkeleton(config, parent),
|
||||||
d(new ConfigXmlPrivate)
|
d(new ConfigLoaderPrivate)
|
||||||
{
|
{
|
||||||
d->parse(this, xml);
|
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,
|
//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,
|
// but KConfigSkeleton does not currently support this. it will eventually though,
|
||||||
// at which point this can be addressed properly
|
// 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),
|
: KConfigSkeleton(KSharedConfig::openConfig(config->config()->name()), parent),
|
||||||
d(new ConfigXmlPrivate)
|
d(new ConfigLoaderPrivate)
|
||||||
{
|
{
|
||||||
KConfigGroup group = config->parent();
|
KConfigGroup group = config->parent();
|
||||||
d->baseGroup = config->name();
|
d->baseGroup = config->name();
|
||||||
@ -544,22 +544,22 @@ ConfigXml::ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent
|
|||||||
d->parse(this, xml);
|
d->parse(this, xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXml::~ConfigXml()
|
ConfigLoader::~ConfigLoader()
|
||||||
{
|
{
|
||||||
delete d;
|
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]);
|
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);
|
return d->groups.contains(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ConfigXml::groupList() const
|
QStringList ConfigLoader::groupList() const
|
||||||
{
|
{
|
||||||
return d->groups;
|
return d->groups;
|
||||||
}
|
}
|
@ -17,8 +17,8 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLASMA_CONFIGXML_H
|
#ifndef PLASMA_CONFIGLOADER_H
|
||||||
#define PLASMA_CONFIGXML_H
|
#define PLASMA_CONFIGLOADER_H
|
||||||
|
|
||||||
#include <KDE/KConfigGroup>
|
#include <KDE/KConfigGroup>
|
||||||
#include <KDE/KConfigSkeleton>
|
#include <KDE/KConfigSkeleton>
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include <plasma/plasma_export.h>
|
#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
|
* @short A KConfigSkeleton that populates itself based on KConfigXT XML
|
||||||
*
|
*
|
||||||
@ -36,7 +36,7 @@
|
|||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* QFile file(xmlFilePath);
|
* QFile file(xmlFilePath);
|
||||||
* Plasma::ConfigXml appletConfig(configFilePath, &file);
|
* Plasma::ConfigLoader appletConfig(configFilePath, &file);
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* Alternatively, any QIODevice may be used in place of QFile in the
|
* Alternatively, any QIODevice may be used in place of QFile in the
|
||||||
@ -70,9 +70,9 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConfigXmlPrivate;
|
class ConfigLoaderPrivate;
|
||||||
|
|
||||||
class PLASMA_EXPORT ConfigXml : public KConfigSkeleton
|
class PLASMA_EXPORT ConfigLoader : public KConfigSkeleton
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -83,7 +83,7 @@ public:
|
|||||||
* @param xml the xml data; must be valid KConfigXT data
|
* @param xml the xml data; must be valid KConfigXT data
|
||||||
* @param parent optional QObject parent
|
* @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
|
* 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 xml the xml data; must be valid KConfigXT data
|
||||||
* @param parent optional QObject parent
|
* @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
|
* 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 xml the xml data; must be valid KConfigXT data
|
||||||
* @param parent optional QObject parent
|
* @param parent optional QObject parent
|
||||||
**/
|
**/
|
||||||
ConfigXml(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0);
|
ConfigLoader(const KConfigGroup *config, QIODevice *xml, QObject *parent = 0);
|
||||||
~ConfigXml();
|
~ConfigLoader();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the item for the given group and key.
|
* Finds the item for the given group and key.
|
||||||
@ -129,7 +129,7 @@ public:
|
|||||||
QStringList groupList() const;
|
QStringList groupList() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConfigXmlPrivate * const d;
|
ConfigLoaderPrivate * const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
@ -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) {
|
if (d->toolBox) {
|
||||||
d->toolBox->addTool(action);
|
d->toolBox->addTool(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::removeToolBoxTool(QAction *action)
|
void Containment::removeToolBoxAction(QAction *action)
|
||||||
{
|
{
|
||||||
if (d->toolBox) {
|
if (d->toolBox) {
|
||||||
d->toolBox->removeTool(action);
|
d->toolBox->removeTool(action);
|
||||||
|
@ -32,8 +32,6 @@
|
|||||||
#include <plasma/applet.h>
|
#include <plasma/applet.h>
|
||||||
#include <plasma/animator.h>
|
#include <plasma/animator.h>
|
||||||
|
|
||||||
#include "widgets/icon.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -240,12 +238,12 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
/**
|
/**
|
||||||
* Add an action to the toolbox
|
* Add an action to the toolbox
|
||||||
*/
|
*/
|
||||||
void addToolBoxTool(QAction *action);
|
void addToolBoxAction(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an action from the toolbox
|
* 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
|
* Sets the open or closed state of the Containment's toolbox
|
||||||
|
32
dialog.cpp
32
dialog.cpp
@ -41,7 +41,7 @@
|
|||||||
#include "plasma/applet.h"
|
#include "plasma/applet.h"
|
||||||
#include "plasma/extender.h"
|
#include "plasma/extender.h"
|
||||||
#include "plasma/private/extender_p.h"
|
#include "plasma/private/extender_p.h"
|
||||||
#include "plasma/panelsvg.h"
|
#include "plasma/framesvg.h"
|
||||||
#include "plasma/theme.h"
|
#include "plasma/theme.h"
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
* Holds the background SVG, to be re-rendered when the cache is invalidated,
|
* Holds the background SVG, to be re-rendered when the cache is invalidated,
|
||||||
* for example by resizing the dialogue.
|
* for example by resizing the dialogue.
|
||||||
*/
|
*/
|
||||||
Plasma::PanelSvg *background;
|
Plasma::FrameSvg *background;
|
||||||
QGraphicsView *view;
|
QGraphicsView *view;
|
||||||
QGraphicsWidget *widget;
|
QGraphicsWidget *widget;
|
||||||
Dialog::ResizeCorners resizeCorners;
|
Dialog::ResizeCorners resizeCorners;
|
||||||
@ -98,27 +98,27 @@ void DialogPrivate::themeUpdated()
|
|||||||
if (extender) {
|
if (extender) {
|
||||||
switch (extender->d->applet->location()) {
|
switch (extender->d->applet->location()) {
|
||||||
case BottomEdge:
|
case BottomEdge:
|
||||||
background->setEnabledBorders(PanelSvg::LeftBorder | PanelSvg::TopBorder
|
background->setEnabledBorders(FrameSvg::LeftBorder | FrameSvg::TopBorder
|
||||||
| PanelSvg::RightBorder);
|
| FrameSvg::RightBorder);
|
||||||
q->setContentsMargins(0, topHeight, 0, 0);
|
q->setContentsMargins(0, topHeight, 0, 0);
|
||||||
break;
|
break;
|
||||||
case TopEdge:
|
case TopEdge:
|
||||||
background->setEnabledBorders(PanelSvg::LeftBorder | PanelSvg::BottomBorder
|
background->setEnabledBorders(FrameSvg::LeftBorder | FrameSvg::BottomBorder
|
||||||
| PanelSvg::RightBorder);
|
| FrameSvg::RightBorder);
|
||||||
q->setContentsMargins(0, 0, 0, bottomHeight);
|
q->setContentsMargins(0, 0, 0, bottomHeight);
|
||||||
break;
|
break;
|
||||||
case LeftEdge:
|
case LeftEdge:
|
||||||
background->setEnabledBorders(PanelSvg::TopBorder | PanelSvg::BottomBorder
|
background->setEnabledBorders(FrameSvg::TopBorder | FrameSvg::BottomBorder
|
||||||
| PanelSvg::RightBorder);
|
| FrameSvg::RightBorder);
|
||||||
q->setContentsMargins(0, topHeight, 0, bottomHeight);
|
q->setContentsMargins(0, topHeight, 0, bottomHeight);
|
||||||
break;
|
break;
|
||||||
case RightEdge:
|
case RightEdge:
|
||||||
background->setEnabledBorders(PanelSvg::TopBorder | PanelSvg::BottomBorder
|
background->setEnabledBorders(FrameSvg::TopBorder | FrameSvg::BottomBorder
|
||||||
| PanelSvg::LeftBorder);
|
| FrameSvg::LeftBorder);
|
||||||
q->setContentsMargins(0, topHeight, 0, bottomHeight);
|
q->setContentsMargins(0, topHeight, 0, bottomHeight);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
background->setEnabledBorders(PanelSvg::AllBorders);
|
background->setEnabledBorders(FrameSvg::AllBorders);
|
||||||
q->setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight);
|
q->setContentsMargins(leftWidth, topHeight, rightWidth, bottomHeight);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -167,10 +167,10 @@ Dialog::Dialog(QWidget *parent, Qt::WindowFlags f)
|
|||||||
d(new DialogPrivate(this))
|
d(new DialogPrivate(this))
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
d->background = new PanelSvg(this);
|
d->background = new FrameSvg(this);
|
||||||
d->background->setImagePath("dialogs/background");
|
d->background->setImagePath("dialogs/background");
|
||||||
d->background->setEnabledBorders(PanelSvg::AllBorders);
|
d->background->setEnabledBorders(FrameSvg::AllBorders);
|
||||||
d->background->resizePanel(size());
|
d->background->resizeFrame(size());
|
||||||
|
|
||||||
connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
|
connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ void Dialog::paintEvent(QPaintEvent *e)
|
|||||||
p.setClipRect(e->rect());
|
p.setClipRect(e->rect());
|
||||||
p.setCompositionMode(QPainter::CompositionMode_Source);
|
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
p.fillRect(rect(), Qt::transparent);
|
p.fillRect(rect(), Qt::transparent);
|
||||||
d->background->paintPanel(&p);
|
d->background->paintFrame(&p);
|
||||||
|
|
||||||
//we set the resize handlers
|
//we set the resize handlers
|
||||||
d->resizeAreas.clear();
|
d->resizeAreas.clear();
|
||||||
@ -315,7 +315,7 @@ void Dialog::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void Dialog::resizeEvent(QResizeEvent *e)
|
void Dialog::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
d->background->resizePanel(e->size());
|
d->background->resizeFrame(e->size());
|
||||||
|
|
||||||
setMask(d->background->mask());
|
setMask(d->background->mask());
|
||||||
|
|
||||||
|
10
extender.cpp
10
extender.cpp
@ -27,7 +27,7 @@
|
|||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
#include "extenderitem.h"
|
#include "extenderitem.h"
|
||||||
#include "panelsvg.h"
|
#include "framesvg.h"
|
||||||
#include "popupapplet.h"
|
#include "popupapplet.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
#include "widgets/label.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 *topItem = dynamic_cast<ExtenderItem*>(d->layout->itemAt(0));
|
||||||
ExtenderItem *bottomItem = dynamic_cast<ExtenderItem*>(d->layout->itemAt(d->layout->count() - 1));
|
ExtenderItem *bottomItem = dynamic_cast<ExtenderItem*>(d->layout->itemAt(d->layout->count() - 1));
|
||||||
if (d->appearance == TopDownStacked && bottomItem != item) {
|
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) {
|
} 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) {
|
} else if (d->appearance != NoBorders) {
|
||||||
return PanelSvg::LeftBorder | PanelSvg::RightBorder;
|
return FrameSvg::LeftBorder | FrameSvg::RightBorder;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <QtGui/QGraphicsWidget>
|
#include <QtGui/QGraphicsWidget>
|
||||||
|
|
||||||
#include "plasma/panelsvg.h"
|
#include "plasma/framesvg.h"
|
||||||
#include "plasma/plasma_export.h"
|
#include "plasma/plasma_export.h"
|
||||||
|
|
||||||
namespace Plasma
|
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.
|
* @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.
|
* @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
|
* Reimplemented from QGraphicsWidget
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "extender.h"
|
#include "extender.h"
|
||||||
#include "panelsvg.h"
|
#include "framesvg.h"
|
||||||
#include "popupapplet.h"
|
#include "popupapplet.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
@ -48,6 +48,8 @@
|
|||||||
#include "private/extender_p.h"
|
#include "private/extender_p.h"
|
||||||
#include "private/extenderitem_p.h"
|
#include "private/extenderitem_p.h"
|
||||||
|
|
||||||
|
#include "widgets/iconwidget.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -79,12 +81,12 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
|
|||||||
dg.writeEntry("sourceAppletId", hostExtender->d->applet->id());
|
dg.writeEntry("sourceAppletId", hostExtender->d->applet->id());
|
||||||
dg.writeEntry("sourceIconName", hostExtender->d->applet->icon());
|
dg.writeEntry("sourceIconName", hostExtender->d->applet->icon());
|
||||||
d->sourceApplet = hostExtender->d->applet;
|
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 {
|
} else {
|
||||||
//The item already exists.
|
//The item already exists.
|
||||||
d->name = dg.readEntry("extenderItemName", "");
|
d->name = dg.readEntry("extenderItemName", "");
|
||||||
d->title = dg.readEntry("extenderTitle", "");
|
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.
|
//Find the sourceapplet.
|
||||||
Corona *corona = hostExtender->d->applet->containment()->corona();
|
Corona *corona = hostExtender->d->applet->containment()->corona();
|
||||||
@ -108,7 +110,6 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
|
|||||||
d->toolboxLayout = new QGraphicsLinearLayout(d->toolbox);
|
d->toolboxLayout = new QGraphicsLinearLayout(d->toolbox);
|
||||||
d->toolbox->setLayout(d->toolboxLayout);
|
d->toolbox->setLayout(d->toolboxLayout);
|
||||||
|
|
||||||
|
|
||||||
//set the extender we want to move to.
|
//set the extender we want to move to.
|
||||||
setExtender(hostExtender);
|
setExtender(hostExtender);
|
||||||
|
|
||||||
@ -403,14 +404,14 @@ void ExtenderItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
painter->setRenderHint(QPainter::TextAntialiasing, true);
|
painter->setRenderHint(QPainter::TextAntialiasing, true);
|
||||||
painter->setRenderHint(QPainter::Antialiasing, 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()) {
|
d->background->enabledBorders()) {
|
||||||
//Don't paint if only the left and right borders are enabled, we only use the left and right
|
//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.
|
//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.
|
//We don't need to paint a title if there is no title.
|
||||||
if (d->title.isEmpty()) {
|
if (d->title.isEmpty()) {
|
||||||
@ -457,12 +458,12 @@ void ExtenderItem::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
qreal height = event->newSize().height();
|
qreal height = event->newSize().height();
|
||||||
|
|
||||||
//resize the dragger
|
//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->dragger->elementSize("hint-preferred-icon-size").height() +
|
||||||
d->dragTop + d->dragBottom));
|
d->dragTop + d->dragBottom));
|
||||||
|
|
||||||
//resize the applet background
|
//resize the applet background
|
||||||
d->background->resizePanel(event->newSize());
|
d->background->resizeFrame(event->newSize());
|
||||||
|
|
||||||
//resize the widget
|
//resize the widget
|
||||||
if (d->widget && d->widget->isWidget()) {
|
if (d->widget && d->widget->isWidget()) {
|
||||||
@ -509,7 +510,7 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->background->enabledBorders() != PanelSvg::AllBorders) {
|
if (d->background->enabledBorders() != FrameSvg::AllBorders) {
|
||||||
d->themeChanged();
|
d->themeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,8 +723,8 @@ ExtenderItemPrivate::ExtenderItemPrivate(ExtenderItem *extenderItem, Extender *h
|
|||||||
previousTargetExtender(0),
|
previousTargetExtender(0),
|
||||||
extender(hostExtender),
|
extender(hostExtender),
|
||||||
sourceApplet(0),
|
sourceApplet(0),
|
||||||
dragger(new PanelSvg(extenderItem)),
|
dragger(new FrameSvg(extenderItem)),
|
||||||
background(new PanelSvg(extenderItem)),
|
background(new FrameSvg(extenderItem)),
|
||||||
collapseIcon(0),
|
collapseIcon(0),
|
||||||
title(QString()),
|
title(QString()),
|
||||||
mousePressed(false),
|
mousePressed(false),
|
||||||
@ -814,7 +815,7 @@ void ExtenderItemPrivate::updateToolBox()
|
|||||||
//add the actions that are actually set to visible.
|
//add the actions that are actually set to visible.
|
||||||
foreach (QAction *action, actions) {
|
foreach (QAction *action, actions) {
|
||||||
if (action->isVisible()) {
|
if (action->isVisible()) {
|
||||||
Icon *icon = new Icon(q);
|
IconWidget *icon = new IconWidget(q);
|
||||||
icon->setAction(action);
|
icon->setAction(action);
|
||||||
QSizeF iconSize = icon->sizeFromIconSize(iconHeight);
|
QSizeF iconSize = icon->sizeFromIconSize(iconHeight);
|
||||||
icon->setMinimumSize(iconSize);
|
icon->setMinimumSize(iconSize);
|
||||||
@ -825,7 +826,7 @@ void ExtenderItemPrivate::updateToolBox()
|
|||||||
|
|
||||||
//add the returntosource icon if we are detached, and have a source applet.
|
//add the returntosource icon if we are detached, and have a source applet.
|
||||||
if (q->isDetached() && sourceApplet) {
|
if (q->isDetached() && sourceApplet) {
|
||||||
Icon *returnToSource = new Icon(q);
|
IconWidget *returnToSource = new IconWidget(q);
|
||||||
returnToSource->setSvg("widgets/configuration-icons", "return-to-source");
|
returnToSource->setSvg("widgets/configuration-icons", "return-to-source");
|
||||||
QSizeF iconSize = returnToSource->sizeFromIconSize(iconHeight);
|
QSizeF iconSize = returnToSource->sizeFromIconSize(iconHeight);
|
||||||
returnToSource->setMinimumSize(iconSize);
|
returnToSource->setMinimumSize(iconSize);
|
||||||
@ -912,7 +913,7 @@ void ExtenderItemPrivate::themeChanged()
|
|||||||
|
|
||||||
background->setImagePath("widgets/extender-background");
|
background->setImagePath("widgets/extender-background");
|
||||||
if (mousePressed) {
|
if (mousePressed) {
|
||||||
background->setEnabledBorders(PanelSvg::AllBorders);
|
background->setEnabledBorders(FrameSvg::AllBorders);
|
||||||
} else {
|
} else {
|
||||||
background->setEnabledBorders(extender->enabledBordersForItem(q));
|
background->setEnabledBorders(extender->enabledBordersForItem(q));
|
||||||
}
|
}
|
||||||
|
676
framesvg.cpp
Normal file
676
framesvg.cpp
Normal 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(¢er);
|
||||||
|
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
q->paint(¢erPainter, 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"
|
@ -18,8 +18,8 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLASMA_PANELSVG_H
|
#ifndef PLASMA_FRAMESVG_H
|
||||||
#define PLASMA_PANELSVG_H
|
#define PLASMA_FRAMESVG_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QPixmap>
|
#include <QtGui/QPixmap>
|
||||||
@ -41,10 +41,10 @@ class QMatrix;
|
|||||||
namespace Plasma
|
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.
|
* @short Provides an SVG with borders.
|
||||||
*
|
*
|
||||||
@ -52,7 +52,7 @@ class PanelSvgPrivate;
|
|||||||
* its aspect ratio, such as a dialog, simply scaling a single image
|
* its aspect ratio, such as a dialog, simply scaling a single image
|
||||||
* may not be enough.
|
* 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
|
* as a central element, each of which are scaled individually. These
|
||||||
* elements should be named
|
* elements should be named
|
||||||
*
|
*
|
||||||
@ -73,7 +73,7 @@ class PanelSvgPrivate;
|
|||||||
*
|
*
|
||||||
* @see Plamsa::Svg
|
* @see Plamsa::Svg
|
||||||
**/
|
**/
|
||||||
class PLASMA_EXPORT PanelSvg : public Svg
|
class PLASMA_EXPORT FrameSvg : public Svg
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -91,7 +91,7 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
|||||||
Q_DECLARE_FLAGS(EnabledBorders, EnabledBorder)
|
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
|
* as borders. It may also be used as a regular Plasma::Svg object
|
||||||
* for direct access to elements in the Svg.
|
* for direct access to elements in the Svg.
|
||||||
*
|
*
|
||||||
@ -99,8 +99,8 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
|||||||
*
|
*
|
||||||
* @related Plasma::Theme
|
* @related Plasma::Theme
|
||||||
*/
|
*/
|
||||||
explicit PanelSvg(QObject *parent = 0);
|
explicit FrameSvg(QObject *parent = 0);
|
||||||
~PanelSvg();
|
~FrameSvg();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a new Svg
|
* Loads a new Svg
|
||||||
@ -121,15 +121,15 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
|||||||
EnabledBorders enabledBorders() const;
|
EnabledBorders enabledBorders() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize the panel maintaining the same border size
|
* Resize the frame maintaining the same border size
|
||||||
* @arg size the new size of the panel
|
* @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
|
* 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
|
* @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
|
* @arg prefix the given prefix we want to check if drawable
|
||||||
*/
|
*/
|
||||||
bool hasElementPrefix(const QString & prefix) const;
|
bool hasElementPrefix(const QString & prefix) const;
|
||||||
@ -188,13 +188,13 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
|||||||
* hasElementPrefix("north"), hasElementPrefix("south")
|
* hasElementPrefix("north"), hasElementPrefix("south")
|
||||||
* hasElementPrefix("west") and hasElementPrefix("east")
|
* hasElementPrefix("west") and hasElementPrefix("east")
|
||||||
* @return true if the svg has the necessary elements with the given prefix
|
* @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
|
* @arg location the given prefix we want to check if drawable
|
||||||
*/
|
*/
|
||||||
bool hasElementPrefix(Plasma::Location location) const;
|
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
|
* @return the prefix
|
||||||
*/
|
*/
|
||||||
QString 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
|
* Sets whether saving all the rendered prefixes in a cache or not
|
||||||
* @arg cache if use the 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
|
* @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
|
* 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)
|
* string for the whole SVG (the default)
|
||||||
* @return a QPixmap of the rendered SVG
|
* @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
|
* 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 target the target rectangle on the paint device
|
||||||
* @arg source the portion rectangle of the source image
|
* @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());
|
const QRectF &source = QRectF());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,10 +247,10 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
|||||||
* @arg painter the QPainter to use
|
* @arg painter the QPainter to use
|
||||||
* @arg pos where to paint the svg
|
* @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:
|
private:
|
||||||
PanelSvgPrivate *const d;
|
FrameSvgPrivate *const d;
|
||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void updateSizes())
|
Q_PRIVATE_SLOT(d, void updateSizes())
|
||||||
Q_PRIVATE_SLOT(d, void updateNeeded())
|
Q_PRIVATE_SLOT(d, void updateNeeded())
|
||||||
@ -258,6 +258,6 @@ class PLASMA_EXPORT PanelSvg : public Svg
|
|||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::PanelSvg::EnabledBorders)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::FrameSvg::EnabledBorders)
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
#endif // multiple inclusion guard
|
1
includes/ConfigLoader
Normal file
1
includes/ConfigLoader
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "../../plasma/configloader.h"
|
@ -1 +0,0 @@
|
|||||||
#include "../../plasma/configxml.h"
|
|
@ -1 +0,0 @@
|
|||||||
#include "../../plasma/widgets/flash.h"
|
|
1
includes/FlashingLabel
Normal file
1
includes/FlashingLabel
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "../../plasma/widgets/flashinglabel.h"
|
1
includes/FrameSvg
Normal file
1
includes/FrameSvg
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "../../plasma/framesvg.h"
|
@ -1 +0,0 @@
|
|||||||
#include "../../plasma/widgets/icon.h"
|
|
1
includes/IconWidget
Normal file
1
includes/IconWidget
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "../../plasma/widgets/iconwidget.h"
|
@ -1 +0,0 @@
|
|||||||
#include "../../plasma/panelsvg.h"
|
|
676
panelsvg.cpp
676
panelsvg.cpp
@ -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(¢er);
|
|
||||||
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
|
|
||||||
q->paint(¢erPainter, 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"
|
|
@ -37,7 +37,7 @@
|
|||||||
#include "plasma/corona.h"
|
#include "plasma/corona.h"
|
||||||
#include "plasma/containment.h"
|
#include "plasma/containment.h"
|
||||||
#include "plasma/extender.h"
|
#include "plasma/extender.h"
|
||||||
#include "plasma/widgets/icon.h"
|
#include "plasma/widgets/iconwidget.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ void PopupApplet::setPopupIcon(const QIcon &icon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!d->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()));
|
connect(d->icon, SIGNAL(clicked()), this, SLOT(togglePopup()));
|
||||||
|
|
||||||
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
|
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
|
||||||
|
@ -30,7 +30,7 @@ namespace Plasma
|
|||||||
{
|
{
|
||||||
|
|
||||||
class Dialog;
|
class Dialog;
|
||||||
class Icon;
|
class IconWidget;
|
||||||
class PopupAppletPrivate;
|
class PopupAppletPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class PanelSvg;
|
class FrameSvg;
|
||||||
class AppletScript;
|
class AppletScript;
|
||||||
class Wallpaper;
|
class Wallpaper;
|
||||||
|
|
||||||
@ -87,10 +87,10 @@ public:
|
|||||||
AppletOverlayWidget *needsConfigOverlay;
|
AppletOverlayWidget *needsConfigOverlay;
|
||||||
QList<QGraphicsItem*> registeredAsDragHandle;
|
QList<QGraphicsItem*> registeredAsDragHandle;
|
||||||
QStringList loadedEngines;
|
QStringList loadedEngines;
|
||||||
Plasma::PanelSvg *background;
|
Plasma::FrameSvg *background;
|
||||||
AppletScript *script;
|
AppletScript *script;
|
||||||
Package *package;
|
Package *package;
|
||||||
ConfigXml *configXml;
|
ConfigLoader *configLoader;
|
||||||
KConfigGroup *mainConfig;
|
KConfigGroup *mainConfig;
|
||||||
Plasma::Constraints pendingConstraints;
|
Plasma::Constraints pendingConstraints;
|
||||||
Plasma::AspectRatioMode aspectRatioMode;
|
Plasma::AspectRatioMode aspectRatioMode;
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include "paintutils.h"
|
#include "paintutils.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "panelsvg.h"
|
#include "framesvg.h"
|
||||||
|
|
||||||
namespace Plasma
|
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
|
//FIXME: this should be of course true, but works only if false
|
||||||
m_configureIcons->setContainsMultipleImages(true);
|
m_configureIcons->setContainsMultipleImages(true);
|
||||||
|
|
||||||
m_background = new PanelSvg(this);
|
m_background = new FrameSvg(this);
|
||||||
m_background->setImagePath("widgets/background");
|
m_background->setImagePath("widgets/background");
|
||||||
|
|
||||||
//We got to be able to see the applet while dragging to to another containment,
|
//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);
|
g.setColorAt(0.0, transparencyColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_background->resizePanel(m_decorationRect.size());
|
m_background->resizeFrame(m_decorationRect.size());
|
||||||
|
|
||||||
if (!m_backgroundBuffer || m_backgroundBuffer->size() != pixmapSize) {
|
if (!m_backgroundBuffer || m_backgroundBuffer->size() != pixmapSize) {
|
||||||
delete m_backgroundBuffer;
|
delete m_backgroundBuffer;
|
||||||
@ -298,7 +298,7 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
|||||||
m_backgroundBuffer->fill(Qt::transparent);
|
m_backgroundBuffer->fill(Qt::transparent);
|
||||||
QPainter buffPainter(m_backgroundBuffer);
|
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
|
//+1 because otherwise due to rounding errors when rotated could appear one pixel
|
||||||
//of the icon at the border of the applet
|
//of the icon at the border of the applet
|
||||||
|
@ -33,7 +33,7 @@ namespace Plasma
|
|||||||
{
|
{
|
||||||
class Applet;
|
class Applet;
|
||||||
class Containment;
|
class Containment;
|
||||||
class PanelSvg;
|
class FrameSvg;
|
||||||
class View;
|
class View;
|
||||||
|
|
||||||
class AppletHandle : public QObject, public QGraphicsItem
|
class AppletHandle : public QObject, public QGraphicsItem
|
||||||
@ -124,7 +124,7 @@ class AppletHandle : public QObject, public QGraphicsItem
|
|||||||
QGraphicsView *m_currentView;
|
QGraphicsView *m_currentView;
|
||||||
|
|
||||||
Svg *m_configureIcons;
|
Svg *m_configureIcons;
|
||||||
PanelSvg *m_background;
|
FrameSvg *m_background;
|
||||||
|
|
||||||
QPoint m_mousePos; //mousepos relative to applet
|
QPoint m_mousePos; //mousepos relative to applet
|
||||||
QPointF m_entryPos; //where the hover in event occurred
|
QPointF m_entryPos; //where the hover in event occurred
|
||||||
|
@ -55,7 +55,7 @@ class ExtenderPrivate
|
|||||||
|
|
||||||
Applet *applet;
|
Applet *applet;
|
||||||
QGraphicsLinearLayout *layout;
|
QGraphicsLinearLayout *layout;
|
||||||
PanelSvg *background;
|
FrameSvg *background;
|
||||||
|
|
||||||
int currentSpacerIndex;
|
int currentSpacerIndex;
|
||||||
QGraphicsWidget *spacerWidget;
|
QGraphicsWidget *spacerWidget;
|
||||||
|
@ -36,8 +36,8 @@ namespace Plasma
|
|||||||
class Applet;
|
class Applet;
|
||||||
class ExtenderItem;
|
class ExtenderItem;
|
||||||
class Extender;
|
class Extender;
|
||||||
class Icon;
|
class IconWidget;
|
||||||
class PanelSvg;
|
class FrameSvg;
|
||||||
|
|
||||||
class ExtenderItemPrivate
|
class ExtenderItemPrivate
|
||||||
{
|
{
|
||||||
@ -70,10 +70,10 @@ class ExtenderItemPrivate
|
|||||||
|
|
||||||
KConfigGroup config;
|
KConfigGroup config;
|
||||||
|
|
||||||
PanelSvg *dragger;
|
FrameSvg *dragger;
|
||||||
PanelSvg *background;
|
FrameSvg *background;
|
||||||
|
|
||||||
Icon *collapseIcon;
|
IconWidget *collapseIcon;
|
||||||
|
|
||||||
QMap<QString, QAction*> actions;
|
QMap<QString, QAction*> actions;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "plasma/plasma.h"
|
#include "plasma/plasma.h"
|
||||||
#include "plasma/theme.h"
|
#include "plasma/theme.h"
|
||||||
#include "plasma/animator.h"
|
#include "plasma/animator.h"
|
||||||
#include "plasma/panelsvg.h"
|
#include "plasma/framesvg.h"
|
||||||
#include "plasma/paintutils.h"
|
#include "plasma/paintutils.h"
|
||||||
|
|
||||||
#include "private/style.h"
|
#include "private/style.h"
|
||||||
@ -69,9 +69,9 @@ public:
|
|||||||
|
|
||||||
NativeTabBar *q;
|
NativeTabBar *q;
|
||||||
QTabBar::Shape shape; //used to keep track of shape() changes
|
QTabBar::Shape shape; //used to keep track of shape() changes
|
||||||
PanelSvg *backgroundSvg;
|
FrameSvg *backgroundSvg;
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
PanelSvg *buttonSvg;
|
FrameSvg *buttonSvg;
|
||||||
qreal buttonLeft, buttonTop, buttonRight, buttonBottom;
|
qreal buttonLeft, buttonTop, buttonRight, buttonBottom;
|
||||||
|
|
||||||
int animationId;
|
int animationId;
|
||||||
@ -101,11 +101,11 @@ NativeTabBar::NativeTabBar(QWidget *parent)
|
|||||||
: QTabBar(parent),
|
: QTabBar(parent),
|
||||||
d(new NativeTabBarPrivate(this))
|
d(new NativeTabBarPrivate(this))
|
||||||
{
|
{
|
||||||
d->backgroundSvg = new Plasma::PanelSvg();
|
d->backgroundSvg = new Plasma::FrameSvg();
|
||||||
d->backgroundSvg->setImagePath("widgets/frame");
|
d->backgroundSvg->setImagePath("widgets/frame");
|
||||||
d->backgroundSvg->setElementPrefix("sunken");
|
d->backgroundSvg->setElementPrefix("sunken");
|
||||||
|
|
||||||
d->buttonSvg = new Plasma::PanelSvg();
|
d->buttonSvg = new Plasma::FrameSvg();
|
||||||
d->buttonSvg->setImagePath("widgets/button");
|
d->buttonSvg->setImagePath("widgets/button");
|
||||||
d->buttonSvg->setElementPrefix("normal");
|
d->buttonSvg->setElementPrefix("normal");
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
|
|||||||
//int numTabs = count();
|
//int numTabs = count();
|
||||||
//bool ltr = painter.layoutDirection() == Qt::LeftToRight; // Not yet used
|
//bool ltr = painter.layoutDirection() == Qt::LeftToRight; // Not yet used
|
||||||
|
|
||||||
d->backgroundSvg->paintPanel(&painter);
|
d->backgroundSvg->paintFrame(&painter);
|
||||||
|
|
||||||
// Drawing Tabborders
|
// Drawing Tabborders
|
||||||
QRect movingRect;
|
QRect movingRect;
|
||||||
@ -232,8 +232,8 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//resizing here because in resizeevent the first time is invalid (still no tabs)
|
//resizing here because in resizeevent the first time is invalid (still no tabs)
|
||||||
d->buttonSvg->resizePanel(movingRect.size());
|
d->buttonSvg->resizeFrame(movingRect.size());
|
||||||
d->buttonSvg->paintPanel(&painter, movingRect.topLeft());
|
d->buttonSvg->paintFrame(&painter, movingRect.topLeft());
|
||||||
|
|
||||||
QFontMetrics metrics(painter.font());
|
QFontMetrics metrics(painter.font());
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ void NativeTabBar::resizeEvent(QResizeEvent *event)
|
|||||||
{
|
{
|
||||||
QTabBar::resizeEvent(event);
|
QTabBar::resizeEvent(event);
|
||||||
d->currentAnimRect = tabRect(currentIndex());
|
d->currentAnimRect = tabRect(currentIndex());
|
||||||
d->backgroundSvg->resizePanel(size());
|
d->backgroundSvg->resizeFrame(size());
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
void popupConstraintsEvent(Plasma::Constraints constraints);
|
void popupConstraintsEvent(Plasma::Constraints constraints);
|
||||||
|
|
||||||
PopupApplet *q;
|
PopupApplet *q;
|
||||||
Plasma::Icon *icon;
|
Plasma::IconWidget *icon;
|
||||||
QPointer<Plasma::Dialog> dialog;
|
QPointer<Plasma::Dialog> dialog;
|
||||||
QGraphicsProxyWidget *proxy;
|
QGraphicsProxyWidget *proxy;
|
||||||
Plasma::PopupPlacement popupPlacement;
|
Plasma::PopupPlacement popupPlacement;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class ConfigXml;
|
class ConfigLoader;
|
||||||
|
|
||||||
class NullServiceJob : public ServiceJob
|
class NullServiceJob : public ServiceJob
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ public:
|
|||||||
Service *q;
|
Service *q;
|
||||||
QString destination;
|
QString destination;
|
||||||
QString name;
|
QString name;
|
||||||
ConfigXml *config;
|
ConfigLoader *config;
|
||||||
KTemporaryFile *tempFile;
|
KTemporaryFile *tempFile;
|
||||||
QMultiHash<QWidget *, QString> associatedWidgets;
|
QMultiHash<QWidget *, QString> associatedWidgets;
|
||||||
QMultiHash<QGraphicsWidget *, QString> associatedGraphicsWidgets;
|
QMultiHash<QGraphicsWidget *, QString> associatedGraphicsWidgets;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
|
||||||
#include <plasma/panelsvg.h>
|
#include <plasma/framesvg.h>
|
||||||
|
|
||||||
namespace Plasma {
|
namespace Plasma {
|
||||||
|
|
||||||
@ -41,16 +41,16 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::PanelSvg *scrollbar;
|
Plasma::FrameSvg *scrollbar;
|
||||||
};
|
};
|
||||||
|
|
||||||
Style::Style()
|
Style::Style()
|
||||||
: QCommonStyle(),
|
: QCommonStyle(),
|
||||||
d(new StylePrivate)
|
d(new StylePrivate)
|
||||||
{
|
{
|
||||||
d->scrollbar = new Plasma::PanelSvg(this);
|
d->scrollbar = new Plasma::FrameSvg(this);
|
||||||
d->scrollbar->setImagePath("widgets/scrollbar");
|
d->scrollbar->setImagePath("widgets/scrollbar");
|
||||||
d->scrollbar->setCacheAllRenderedPanels(true);
|
d->scrollbar->setCacheAllRenderedFrames(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::~Style()
|
Style::~Style()
|
||||||
@ -96,8 +96,8 @@ void Style::drawComplexControl(ComplexControl control,
|
|||||||
subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0);
|
subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0);
|
||||||
|
|
||||||
d->scrollbar->setElementPrefix("background");
|
d->scrollbar->setElementPrefix("background");
|
||||||
d->scrollbar->resizePanel(option->rect.size());
|
d->scrollbar->resizeFrame(option->rect.size());
|
||||||
d->scrollbar->paintPanel(painter);
|
d->scrollbar->paintFrame(painter);
|
||||||
|
|
||||||
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarSlider) {
|
if (sunken && scrollOption && scrollOption->activeSubControls & SC_ScrollBarSlider) {
|
||||||
d->scrollbar->setElementPrefix("sunken-slider");
|
d->scrollbar->setElementPrefix("sunken-slider");
|
||||||
@ -105,8 +105,8 @@ void Style::drawComplexControl(ComplexControl control,
|
|||||||
d->scrollbar->setElementPrefix(prefix + "slider");
|
d->scrollbar->setElementPrefix(prefix + "slider");
|
||||||
}
|
}
|
||||||
|
|
||||||
d->scrollbar->resizePanel(slider.size());
|
d->scrollbar->resizeFrame(slider.size());
|
||||||
d->scrollbar->paintPanel(painter, slider.topLeft());
|
d->scrollbar->paintFrame(painter, slider.topLeft());
|
||||||
|
|
||||||
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
if (scrollOption && scrollOption->orientation == Qt::Horizontal) {
|
||||||
if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
if (sunken && scrollOption->activeSubControls & SC_ScrollBarAddLine) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
|
||||||
#include <plasma/theme.h>
|
#include <plasma/theme.h>
|
||||||
#include "widgets/icon.h"
|
#include "widgets/iconwidget.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ void ToolBox::addTool(QAction *action)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Icon *tool = new Plasma::Icon(this);
|
Plasma::IconWidget *tool = new Plasma::IconWidget(this);
|
||||||
|
|
||||||
tool->setAction(action);
|
tool->setAction(action);
|
||||||
tool->setDrawBackground(true);
|
tool->setDrawBackground(true);
|
||||||
@ -121,7 +121,7 @@ void ToolBox::removeTool(QAction *action)
|
|||||||
{
|
{
|
||||||
foreach (QGraphicsItem *child, QGraphicsItem::children()) {
|
foreach (QGraphicsItem *child, QGraphicsItem::children()) {
|
||||||
//kDebug() << "checking tool" << child << child->data(ToolName);
|
//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) {
|
if (tool && tool->action() == action) {
|
||||||
//kDebug() << "tool found!";
|
//kDebug() << "tool found!";
|
||||||
tool->deleteLater();
|
tool->deleteLater();
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <plasma/plasma.h>
|
#include <plasma/plasma.h>
|
||||||
#include <plasma/theme.h>
|
#include <plasma/theme.h>
|
||||||
#include <plasma/panelsvg.h>
|
#include <plasma/framesvg.h>
|
||||||
|
|
||||||
namespace Plasma {
|
namespace Plasma {
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class ToolTipPrivate
|
|||||||
QLabel *imageLabel;
|
QLabel *imageLabel;
|
||||||
WindowPreview *preview;
|
WindowPreview *preview;
|
||||||
WId windowToPreview;
|
WId windowToPreview;
|
||||||
PanelSvg *background;
|
FrameSvg *background;
|
||||||
QPointer<QObject> source;
|
QPointer<QObject> source;
|
||||||
bool autohide;
|
bool autohide;
|
||||||
};
|
};
|
||||||
@ -96,7 +96,7 @@ ToolTip::ToolTip(QObject *source)
|
|||||||
d->imageLabel = new QLabel(this);
|
d->imageLabel = new QLabel(this);
|
||||||
d->imageLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
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()));
|
connect(d->background, SIGNAL(repaintNeeded()), this, SLOT(update()));
|
||||||
|
|
||||||
l->addWidget(d->preview, 0, 0, 1, 2);
|
l->addWidget(d->preview, 0, 0, 1, 2);
|
||||||
@ -144,7 +144,7 @@ void ToolTip::prepareShowing(bool cueUpdate)
|
|||||||
void ToolTip::resizeEvent(QResizeEvent *e)
|
void ToolTip::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(e);
|
QWidget::resizeEvent(e);
|
||||||
d->background->resizePanel(size());
|
d->background->resizeFrame(size());
|
||||||
|
|
||||||
setMask(d->background->mask());
|
setMask(d->background->mask());
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ void ToolTip::paintEvent(QPaintEvent *e)
|
|||||||
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
painter.fillRect(rect(), Qt::transparent);
|
painter.fillRect(rect(), Qt::transparent);
|
||||||
|
|
||||||
d->background->paintPanel(&painter);
|
d->background->paintFrame(&painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolTip::sourceDestroyed()
|
void ToolTip::sourceDestroyed()
|
||||||
@ -173,7 +173,7 @@ bool ToolTip::autohide() const
|
|||||||
void ToolTip::updateTheme()
|
void ToolTip::updateTheme()
|
||||||
{
|
{
|
||||||
d->background->setImagePath("widgets/tooltip");
|
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 topHeight = d->background->marginSize(Plasma::TopMargin);
|
||||||
const int leftWidth = d->background->marginSize(Plasma::LeftMargin);
|
const int leftWidth = d->background->marginSize(Plasma::LeftMargin);
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
#include <KTemporaryFile>
|
#include <KTemporaryFile>
|
||||||
|
|
||||||
#include "configxml.h"
|
#include "configloader.h"
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ void Service::setOperationsScheme(QIODevice *xml)
|
|||||||
d->tempFile->open();
|
d->tempFile->open();
|
||||||
|
|
||||||
KSharedConfigPtr c = KSharedConfig::openConfig(d->tempFile->fileName(), KConfig::NoGlobals);
|
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();
|
emit operationsChanged();
|
||||||
|
|
||||||
|
6
svg.h
6
svg.h
@ -38,7 +38,7 @@ namespace Plasma
|
|||||||
{
|
{
|
||||||
|
|
||||||
class SvgPrivate;
|
class SvgPrivate;
|
||||||
class PanelSvgPrivate;
|
class FrameSvgPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Svg plasma/svg.h <Plasma/Svg>
|
* @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
|
* 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.
|
* optimizations to help lower the cost of painting SVGs, such as caching.
|
||||||
*
|
*
|
||||||
* @see Plasma::PanelSvg
|
* @see Plasma::FrameSvg
|
||||||
**/
|
**/
|
||||||
class PLASMA_EXPORT Svg : public QObject
|
class PLASMA_EXPORT Svg : public QObject
|
||||||
{
|
{
|
||||||
@ -227,7 +227,7 @@ class PLASMA_EXPORT Svg : public QObject
|
|||||||
Q_PRIVATE_SLOT(d, void colorsChanged())
|
Q_PRIVATE_SLOT(d, void colorsChanged())
|
||||||
|
|
||||||
friend class SvgPrivate;
|
friend class SvgPrivate;
|
||||||
friend class PanelSvgPrivate;
|
friend class FrameSvgPrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <applet.h>
|
#include <applet.h>
|
||||||
#include <containment.h>
|
#include <containment.h>
|
||||||
#include <corona.h>
|
#include <corona.h>
|
||||||
#include <panelsvg.h>
|
#include <framesvg.h>
|
||||||
#include <theme.h>
|
#include <theme.h>
|
||||||
#include <view.h>
|
#include <view.h>
|
||||||
#include <private/tooltip_p.h>
|
#include <private/tooltip_p.h>
|
||||||
|
16
uiloader.cpp
16
uiloader.cpp
@ -22,10 +22,10 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "widgets/checkbox.h"
|
#include "widgets/checkbox.h"
|
||||||
#include "widgets/combobox.h"
|
#include "widgets/combobox.h"
|
||||||
#include "widgets/flash.h"
|
#include "widgets/flashinglabel.h"
|
||||||
#include "widgets/frame.h"
|
#include "widgets/frame.h"
|
||||||
#include "widgets/groupbox.h"
|
#include "widgets/groupbox.h"
|
||||||
#include "widgets/icon.h"
|
#include "widgets/iconwidget.h"
|
||||||
#include "widgets/label.h"
|
#include "widgets/label.h"
|
||||||
#include "widgets/lineedit.h"
|
#include "widgets/lineedit.h"
|
||||||
#include "widgets/pushbutton.h"
|
#include "widgets/pushbutton.h"
|
||||||
@ -51,10 +51,10 @@ UiLoader::UiLoader(QObject *parent)
|
|||||||
d->widgets
|
d->widgets
|
||||||
<< "CheckBox"
|
<< "CheckBox"
|
||||||
<< "ComboBox"
|
<< "ComboBox"
|
||||||
<< "Flash"
|
<< "FlashingLabel"
|
||||||
<< "Frame"
|
<< "Frame"
|
||||||
<< "GroupBox"
|
<< "GroupBox"
|
||||||
<< "Icon"
|
<< "IconWidget"
|
||||||
<< "Label"
|
<< "Label"
|
||||||
<< "LineEdit"
|
<< "LineEdit"
|
||||||
<< "PushButton"
|
<< "PushButton"
|
||||||
@ -80,14 +80,14 @@ QGraphicsWidget *UiLoader::createWidget(const QString &className, QGraphicsWidge
|
|||||||
return new CheckBox(parent);
|
return new CheckBox(parent);
|
||||||
} else if (className == QString("ComboBox")) {
|
} else if (className == QString("ComboBox")) {
|
||||||
return new ComboBox(parent);
|
return new ComboBox(parent);
|
||||||
} else if (className == QString("Flash")) {
|
} else if (className == QString("FlashingLabel")) {
|
||||||
return new Flash(parent);
|
return new FlashingLabel(parent);
|
||||||
} else if (className == QString("Frame")) {
|
} else if (className == QString("Frame")) {
|
||||||
return new Frame(parent);
|
return new Frame(parent);
|
||||||
} else if (className == QString("GroupBox")) {
|
} else if (className == QString("GroupBox")) {
|
||||||
return new GroupBox(parent);
|
return new GroupBox(parent);
|
||||||
} else if (className == QString("Icon")) {
|
} else if (className == QString("IconWidget")) {
|
||||||
return new Icon(parent);
|
return new IconWidget(parent);
|
||||||
} else if (className == QString("Label")) {
|
} else if (className == QString("Label")) {
|
||||||
return new Label(parent);
|
return new Label(parent);
|
||||||
} else if (className == QString("LineEdit")) {
|
} else if (className == QString("LineEdit")) {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <KIconLoader>
|
#include <KIconLoader>
|
||||||
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "panelsvg.h"
|
#include "framesvg.h"
|
||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
#include "paintutils.h"
|
#include "paintutils.h"
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
ComboBox *q;
|
ComboBox *q;
|
||||||
|
|
||||||
PanelSvg *background;
|
FrameSvg *background;
|
||||||
int animId;
|
int animId;
|
||||||
bool fadeIn;
|
bool fadeIn;
|
||||||
qreal opacity;
|
qreal opacity;
|
||||||
@ -114,9 +114,9 @@ ComboBox::ComboBox(QGraphicsWidget *parent)
|
|||||||
setWidget(native);
|
setWidget(native);
|
||||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
|
||||||
d->background = new PanelSvg(this);
|
d->background = new FrameSvg(this);
|
||||||
d->background->setImagePath("widgets/button");
|
d->background->setImagePath("widgets/button");
|
||||||
d->background->setCacheAllRenderedPanels(true);
|
d->background->setCacheAllRenderedFrames(true);
|
||||||
d->background->setElementPrefix("normal");
|
d->background->setElementPrefix("normal");
|
||||||
|
|
||||||
d->syncBorders();
|
d->syncBorders();
|
||||||
@ -166,13 +166,13 @@ void ComboBox::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
d->syncActiveRect();
|
d->syncActiveRect();
|
||||||
|
|
||||||
d->background->setElementPrefix("focus");
|
d->background->setElementPrefix("focus");
|
||||||
d->background->resizePanel(size());
|
d->background->resizeFrame(size());
|
||||||
|
|
||||||
d->background->setElementPrefix("active");
|
d->background->setElementPrefix("active");
|
||||||
d->background->resizePanel(d->activeRect.size());
|
d->background->resizeFrame(d->activeRect.size());
|
||||||
|
|
||||||
d->background->setElementPrefix("normal");
|
d->background->setElementPrefix("normal");
|
||||||
d->background->resizePanel(size());
|
d->background->resizeFrame(size());
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsProxyWidget::resizeEvent(event);
|
QGraphicsProxyWidget::resizeEvent(event);
|
||||||
@ -194,7 +194,7 @@ void ComboBox::paint(QPainter *painter,
|
|||||||
d->background->setElementPrefix("normal");
|
d->background->setElementPrefix("normal");
|
||||||
|
|
||||||
if (d->animId == -1) {
|
if (d->animId == -1) {
|
||||||
d->background->paintPanel(painter);
|
d->background->paintFrame(painter);
|
||||||
}
|
}
|
||||||
//disabled widget
|
//disabled widget
|
||||||
} else {
|
} else {
|
||||||
@ -202,7 +202,7 @@ void ComboBox::paint(QPainter *painter,
|
|||||||
bufferPixmap.fill(Qt::transparent);
|
bufferPixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter buffPainter(&bufferPixmap);
|
QPainter buffPainter(&bufferPixmap);
|
||||||
d->background->paintPanel(&buffPainter);
|
d->background->paintFrame(&buffPainter);
|
||||||
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
|
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
|
||||||
|
|
||||||
@ -213,20 +213,20 @@ void ComboBox::paint(QPainter *painter,
|
|||||||
if (isEnabled() && acceptHoverEvents()) {
|
if (isEnabled() && acceptHoverEvents()) {
|
||||||
if (d->animId != -1) {
|
if (d->animId != -1) {
|
||||||
d->background->setElementPrefix("normal");
|
d->background->setElementPrefix("normal");
|
||||||
QPixmap normalPix = d->background->panelPixmap();
|
QPixmap normalPix = d->background->framePixmap();
|
||||||
d->background->setElementPrefix("active");
|
d->background->setElementPrefix("active");
|
||||||
painter->drawPixmap(
|
painter->drawPixmap(
|
||||||
d->activeRect.topLeft(),
|
d->activeRect.topLeft(),
|
||||||
PaintUtils::transition(d->background->panelPixmap(), normalPix, 1 - d->opacity));
|
PaintUtils::transition(d->background->framePixmap(), normalPix, 1 - d->opacity));
|
||||||
} else if (isUnderMouse()) {
|
} else if (isUnderMouse()) {
|
||||||
d->background->setElementPrefix("active");
|
d->background->setElementPrefix("active");
|
||||||
d->background->paintPanel(painter, d->activeRect.topLeft());
|
d->background->paintFrame(painter, d->activeRect.topLeft());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nativeWidget()->hasFocus()) {
|
if (nativeWidget()->hasFocus()) {
|
||||||
d->background->setElementPrefix("focus");
|
d->background->setElementPrefix("focus");
|
||||||
d->background->paintPanel(painter);
|
d->background->paintFrame(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
* et, Fifth Floor, Boston, MA 02110-1301, USA.
|
* et, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "flash.h"
|
#include "flashinglabel.h"
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QTimeLine>
|
#include <QtCore/QTimeLine>
|
||||||
@ -34,10 +34,10 @@
|
|||||||
|
|
||||||
using namespace Plasma;
|
using namespace Plasma;
|
||||||
|
|
||||||
class Plasma::FlashPrivate
|
class Plasma::FlashingLabelPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum FlashType {
|
enum FlashingLabelType {
|
||||||
Text,
|
Text,
|
||||||
Pixmap
|
Pixmap
|
||||||
};
|
};
|
||||||
@ -46,13 +46,13 @@ class Plasma::FlashPrivate
|
|||||||
Invisible
|
Invisible
|
||||||
};
|
};
|
||||||
|
|
||||||
FlashPrivate(Flash *flash)
|
FlashingLabelPrivate(FlashingLabel *flash)
|
||||||
: q(flash),
|
: q(flash),
|
||||||
defaultDuration(3000),
|
defaultDuration(3000),
|
||||||
type(FlashPrivate::Text),
|
type(FlashingLabelPrivate::Text),
|
||||||
color(Qt::black),
|
color(Qt::black),
|
||||||
animId(0),
|
animId(0),
|
||||||
state(FlashPrivate::Invisible),
|
state(FlashingLabelPrivate::Invisible),
|
||||||
autohide(false)
|
autohide(false)
|
||||||
{
|
{
|
||||||
//TODO: put this on a diet by using timerEvent instead?
|
//TODO: put this on a diet by using timerEvent instead?
|
||||||
@ -62,15 +62,15 @@ class Plasma::FlashPrivate
|
|||||||
fadeInTimer.setSingleShot(true);
|
fadeInTimer.setSingleShot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
~FlashPrivate() { }
|
~FlashingLabelPrivate() { }
|
||||||
|
|
||||||
void renderPixmap(const QSize &size);
|
void renderPixmap(const QSize &size);
|
||||||
void setupFlash(int duration);
|
void setupFlash(int duration);
|
||||||
void elementAnimationFinished(int);
|
void elementAnimationFinished(int);
|
||||||
|
|
||||||
Flash *q;
|
FlashingLabel *q;
|
||||||
int defaultDuration;
|
int defaultDuration;
|
||||||
FlashType type;
|
FlashingLabelType type;
|
||||||
QTimer fadeInTimer;
|
QTimer fadeInTimer;
|
||||||
QTimer fadeOutTimer;
|
QTimer fadeOutTimer;
|
||||||
QString text;
|
QString text;
|
||||||
@ -88,9 +88,9 @@ class Plasma::FlashPrivate
|
|||||||
bool autohide;
|
bool autohide;
|
||||||
};
|
};
|
||||||
|
|
||||||
Flash::Flash(QGraphicsItem *parent)
|
FlashingLabel::FlashingLabel(QGraphicsItem *parent)
|
||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
d(new FlashPrivate(this))
|
d(new FlashingLabelPrivate(this))
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
|
||||||
setCacheMode(NoCache);
|
setCacheMode(NoCache);
|
||||||
@ -98,12 +98,12 @@ Flash::Flash(QGraphicsItem *parent)
|
|||||||
connect(&d->fadeInTimer, SIGNAL(timeout()), this, SLOT(fadeIn()));
|
connect(&d->fadeInTimer, SIGNAL(timeout()), this, SLOT(fadeIn()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Flash::~Flash()
|
FlashingLabel::~FlashingLabel()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flash::setDuration(int duration)
|
void FlashingLabel::setDuration(int duration)
|
||||||
{
|
{
|
||||||
if (duration < 1) {
|
if (duration < 1) {
|
||||||
return;
|
return;
|
||||||
@ -112,42 +112,42 @@ void Flash::setDuration(int duration)
|
|||||||
d->defaultDuration = duration;
|
d->defaultDuration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flash::setColor(const QColor &color)
|
void FlashingLabel::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
d->color = color;
|
d->color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flash::setFont(const QFont &font)
|
void FlashingLabel::setFont(const QFont &font)
|
||||||
{
|
{
|
||||||
d->font = 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()) {
|
if (text.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//kDebug() << duration << text;
|
//kDebug() << duration << text;
|
||||||
d->type = FlashPrivate::Text;
|
d->type = FlashingLabelPrivate::Text;
|
||||||
d->text = text;
|
d->text = text;
|
||||||
d->textOption = option;
|
d->textOption = option;
|
||||||
d->setupFlash(duration);
|
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()) {
|
if (pixmap.isNull()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->type = FlashPrivate::Pixmap;
|
d->type = FlashingLabelPrivate::Pixmap;
|
||||||
d->pixmap = pixmap;
|
d->pixmap = pixmap;
|
||||||
d->alignment = align;
|
d->alignment = align;
|
||||||
d->setupFlash(duration);
|
d->setupFlash(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flash::setAutohide(bool autohide)
|
void FlashingLabel::setAutohide(bool autohide)
|
||||||
{
|
{
|
||||||
d->autohide = autohide;
|
d->autohide = autohide;
|
||||||
|
|
||||||
@ -160,44 +160,44 @@ void Flash::setAutohide(bool autohide)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Flash::autohide() const
|
bool FlashingLabel::autohide() const
|
||||||
{
|
{
|
||||||
return d->autohide;
|
return d->autohide;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flash::kill()
|
void FlashingLabel::kill()
|
||||||
{
|
{
|
||||||
d->fadeInTimer.stop();
|
d->fadeInTimer.stop();
|
||||||
if (d->state == FlashPrivate::Visible) {
|
if (d->state == FlashingLabelPrivate::Visible) {
|
||||||
fadeOut();
|
fadeOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flash::fadeIn()
|
void FlashingLabel::fadeIn()
|
||||||
{
|
{
|
||||||
//kDebug();
|
//kDebug();
|
||||||
if (d->autohide) {
|
if (d->autohide) {
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->state = FlashPrivate::Visible;
|
d->state = FlashingLabelPrivate::Visible;
|
||||||
d->animId = Plasma::Animator::self()->animateElement(this, Plasma::Animator::AppearAnimation);
|
d->animId = Plasma::Animator::self()->animateElement(this, Plasma::Animator::AppearAnimation);
|
||||||
Plasma::Animator::self()->setInitialPixmap(d->animId, d->renderedPixmap);
|
Plasma::Animator::self()->setInitialPixmap(d->animId, d->renderedPixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Flash::fadeOut()
|
void FlashingLabel::fadeOut()
|
||||||
{
|
{
|
||||||
if (d->state == FlashPrivate::Invisible) {
|
if (d->state == FlashingLabelPrivate::Invisible) {
|
||||||
return; // Flash was already killed - do not animate again
|
return; // FlashingLabel was already killed - do not animate again
|
||||||
}
|
}
|
||||||
|
|
||||||
d->state = FlashPrivate::Invisible;
|
d->state = FlashingLabelPrivate::Invisible;
|
||||||
d->animId = Plasma::Animator::self()->animateElement(
|
d->animId = Plasma::Animator::self()->animateElement(
|
||||||
this, Plasma::Animator::DisappearAnimation);
|
this, Plasma::Animator::DisappearAnimation);
|
||||||
Plasma::Animator::self()->setInitialPixmap(d->animId, d->renderedPixmap);
|
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(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
@ -207,13 +207,13 @@ void Flash::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
|
|||||||
} else {
|
} else {
|
||||||
d->animId = 0;
|
d->animId = 0;
|
||||||
|
|
||||||
if (d->state == FlashPrivate::Visible) {
|
if (d->state == FlashingLabelPrivate::Visible) {
|
||||||
painter->drawPixmap(0, 0, d->renderedPixmap);
|
painter->drawPixmap(0, 0, d->renderedPixmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlashPrivate::renderPixmap(const QSize &size)
|
void FlashingLabelPrivate::renderPixmap(const QSize &size)
|
||||||
{
|
{
|
||||||
if (renderedPixmap.size() != size) {
|
if (renderedPixmap.size() != size) {
|
||||||
renderedPixmap = QPixmap(size);
|
renderedPixmap = QPixmap(size);
|
||||||
@ -221,11 +221,11 @@ void FlashPrivate::renderPixmap(const QSize &size)
|
|||||||
renderedPixmap.fill(Qt::transparent);
|
renderedPixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter painter(&renderedPixmap);
|
QPainter painter(&renderedPixmap);
|
||||||
if (type == FlashPrivate::Text) {
|
if (type == FlashingLabelPrivate::Text) {
|
||||||
painter.setPen(color);
|
painter.setPen(color);
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
painter.drawText(QRect(QPoint(0, 0), size), text, textOption);
|
painter.drawText(QRect(QPoint(0, 0), size), text, textOption);
|
||||||
} else if (type == FlashPrivate::Pixmap) {
|
} else if (type == FlashingLabelPrivate::Pixmap) {
|
||||||
QPoint p;
|
QPoint p;
|
||||||
|
|
||||||
if(alignment & Qt::AlignLeft) {
|
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.stop();
|
||||||
fadeOutTimer.setInterval(duration > 0 ? duration : defaultDuration);
|
fadeOutTimer.setInterval(duration > 0 ? duration : defaultDuration);
|
||||||
|
|
||||||
renderPixmap(q->size().toSize());
|
renderPixmap(q->size().toSize());
|
||||||
if (state != FlashPrivate::Visible) {
|
if (state != FlashingLabelPrivate::Visible) {
|
||||||
fadeInTimer.start();
|
fadeInTimer.start();
|
||||||
} else {
|
} else {
|
||||||
q->update();
|
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();
|
q->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "flash.moc"
|
#include "flashinglabel.moc"
|
@ -18,8 +18,8 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLASMA_FLASH_H
|
#ifndef PLASMA_FLASHINGLABEL_H
|
||||||
#define PLASMA_FLASH_H
|
#define PLASMA_FLASHINGLABEL_H
|
||||||
|
|
||||||
#include <QtGui/QGraphicsWidget>
|
#include <QtGui/QGraphicsWidget>
|
||||||
#include <QtGui/QTextOption>
|
#include <QtGui/QTextOption>
|
||||||
@ -29,19 +29,19 @@
|
|||||||
namespace Plasma
|
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
|
* @short Provides flashing text or icons inside Plasma
|
||||||
*/
|
*/
|
||||||
class PLASMA_EXPORT Flash : public QGraphicsWidget
|
class PLASMA_EXPORT FlashingLabel : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Flash(QGraphicsItem *parent = 0);
|
explicit FlashingLabel(QGraphicsItem *parent = 0);
|
||||||
virtual ~Flash();
|
virtual ~FlashingLabel();
|
||||||
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class PLASMA_EXPORT Flash : public QGraphicsWidget
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void elementAnimationFinished(int))
|
Q_PRIVATE_SLOT(d, void elementAnimationFinished(int))
|
||||||
FlashPrivate *const d;
|
FlashingLabelPrivate *const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
//Plasma
|
//Plasma
|
||||||
#include "plasma/theme.h"
|
#include "plasma/theme.h"
|
||||||
#include "plasma/panelsvg.h"
|
#include "plasma/framesvg.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
void syncBorders();
|
void syncBorders();
|
||||||
|
|
||||||
Frame *q;
|
Frame *q;
|
||||||
PanelSvg *svg;
|
FrameSvg *svg;
|
||||||
Frame::Shadow shadow;
|
Frame::Shadow shadow;
|
||||||
QString text;
|
QString text;
|
||||||
QString styleSheet;
|
QString styleSheet;
|
||||||
@ -84,7 +84,7 @@ Frame::Frame(QGraphicsWidget *parent)
|
|||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
d(new FramePrivate(this))
|
d(new FramePrivate(this))
|
||||||
{
|
{
|
||||||
d->svg = new Plasma::PanelSvg(this);
|
d->svg = new Plasma::FrameSvg(this);
|
||||||
d->svg->setImagePath("widgets/frame");
|
d->svg->setImagePath("widgets/frame");
|
||||||
d->svg->setElementPrefix("plain");
|
d->svg->setElementPrefix("plain");
|
||||||
d->syncBorders();
|
d->syncBorders();
|
||||||
@ -202,7 +202,7 @@ void Frame::paint(QPainter *painter,
|
|||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
d->svg->paintPanel(painter);
|
d->svg->paintFrame(painter);
|
||||||
|
|
||||||
if (!d->text.isNull()) {
|
if (!d->text.isNull()) {
|
||||||
QFontMetricsF fm(QApplication::font());
|
QFontMetricsF fm(QApplication::font());
|
||||||
@ -223,7 +223,7 @@ void Frame::paint(QPainter *painter,
|
|||||||
|
|
||||||
void Frame::resizeEvent(QGraphicsSceneResizeEvent *event)
|
void Frame::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
{
|
{
|
||||||
d->svg->resizePanel(event->newSize());
|
d->svg->resizeFrame(event->newSize());
|
||||||
|
|
||||||
if (d->image) {
|
if (d->image) {
|
||||||
d->image->resize(contentsRect().size());
|
d->image->resize(contentsRect().size());
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "icon.h"
|
#include "iconwidget.h"
|
||||||
#include "icon_p.h"
|
#include "iconwidget_p.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -59,14 +59,14 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
IconPrivate::IconPrivate(Icon *i)
|
IconWidgetPrivate::IconWidgetPrivate(IconWidget *i)
|
||||||
: q(i),
|
: q(i),
|
||||||
iconSvg(0),
|
iconSvg(0),
|
||||||
m_fadeIn(false),
|
m_fadeIn(false),
|
||||||
m_hoverAnimId(-1),
|
m_hoverAnimId(-1),
|
||||||
m_hoverAlpha(20 / 255),
|
m_hoverAlpha(20 / 255),
|
||||||
iconSize(48, 48),
|
iconSize(48, 48),
|
||||||
states(IconPrivate::NoState),
|
states(IconWidgetPrivate::NoState),
|
||||||
orientation(Qt::Vertical),
|
orientation(Qt::Vertical),
|
||||||
numDisplayLines(2),
|
numDisplayLines(2),
|
||||||
invertLayout(false),
|
invertLayout(false),
|
||||||
@ -76,19 +76,19 @@ IconPrivate::IconPrivate(Icon *i)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
IconPrivate::~IconPrivate()
|
IconWidgetPrivate::~IconWidgetPrivate()
|
||||||
{
|
{
|
||||||
qDeleteAll(cornerActions);
|
qDeleteAll(cornerActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::readColors()
|
void IconWidget::readColors()
|
||||||
{
|
{
|
||||||
d->textColor = Plasma::Theme::defaultTheme()->color(Theme::TextColor);
|
d->textColor = Plasma::Theme::defaultTheme()->color(Theme::TextColor);
|
||||||
d->shadowColor = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
d->shadowColor = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IconAction::IconAction(Icon *icon, QAction *action)
|
IconAction::IconAction(IconWidget *icon, QAction *action)
|
||||||
: m_icon(icon),
|
: m_icon(icon),
|
||||||
m_action(action),
|
m_action(action),
|
||||||
m_hovered(false),
|
m_hovered(false),
|
||||||
@ -172,11 +172,11 @@ void IconAction::rebuildPixmap()
|
|||||||
m_pixmap = QPixmap(26, 26);
|
m_pixmap = QPixmap(26, 26);
|
||||||
m_pixmap.fill(Qt::transparent);
|
m_pixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
int element = IconPrivate::Minibutton;
|
int element = IconWidgetPrivate::Minibutton;
|
||||||
if (m_pressed) {
|
if (m_pressed) {
|
||||||
element = IconPrivate::MinibuttonPressed;
|
element = IconWidgetPrivate::MinibuttonPressed;
|
||||||
} else if (m_hovered) {
|
} else if (m_hovered) {
|
||||||
element = IconPrivate::MinibuttonHover;
|
element = IconWidgetPrivate::MinibuttonHover;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainter painter(&m_pixmap);
|
QPainter painter(&m_pixmap);
|
||||||
@ -264,36 +264,36 @@ void IconAction::paint(QPainter *painter) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon::Icon(QGraphicsItem *parent)
|
IconWidget::IconWidget(QGraphicsItem *parent)
|
||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
d(new IconPrivate(this))
|
d(new IconWidgetPrivate(this))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon::Icon(const QString &text, QGraphicsItem *parent)
|
IconWidget::IconWidget(const QString &text, QGraphicsItem *parent)
|
||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
d(new IconPrivate(this))
|
d(new IconWidgetPrivate(this))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
setText(text);
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon::Icon(const QIcon &icon, const QString &text, QGraphicsItem *parent)
|
IconWidget::IconWidget(const QIcon &icon, const QString &text, QGraphicsItem *parent)
|
||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
d(new IconPrivate(this))
|
d(new IconWidgetPrivate(this))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
setText(text);
|
setText(text);
|
||||||
setIcon(icon);
|
setIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
Icon::~Icon()
|
IconWidget::~IconWidget()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::init()
|
void IconWidget::init()
|
||||||
{
|
{
|
||||||
readColors();
|
readColors();
|
||||||
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(readColors()));
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(readColors()));
|
||||||
@ -305,21 +305,21 @@ void Icon::init()
|
|||||||
int focusVMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin);
|
int focusVMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin);
|
||||||
|
|
||||||
// Margins for horizontal mode (list views, tree views, table views)
|
// Margins for horizontal mode (list views, tree views, table views)
|
||||||
d->setHorizontalMargin(IconPrivate::TextMargin, focusHMargin, focusVMargin);
|
d->setHorizontalMargin(IconWidgetPrivate::TextMargin, focusHMargin, focusVMargin);
|
||||||
d->setHorizontalMargin(IconPrivate::IconMargin, focusHMargin, focusVMargin);
|
d->setHorizontalMargin(IconWidgetPrivate::IconMargin, focusHMargin, focusVMargin);
|
||||||
d->setHorizontalMargin(IconPrivate::ItemMargin, 0, 0);
|
d->setHorizontalMargin(IconWidgetPrivate::ItemMargin, 0, 0);
|
||||||
|
|
||||||
// Margins for vertical mode (icon views)
|
// Margins for vertical mode (icon views)
|
||||||
d->setVerticalMargin(IconPrivate::TextMargin, 6, 2);
|
d->setVerticalMargin(IconWidgetPrivate::TextMargin, 6, 2);
|
||||||
d->setVerticalMargin(IconPrivate::IconMargin, focusHMargin, focusVMargin);
|
d->setVerticalMargin(IconWidgetPrivate::IconMargin, focusHMargin, focusVMargin);
|
||||||
d->setVerticalMargin(IconPrivate::ItemMargin, 0, 0);
|
d->setVerticalMargin(IconWidgetPrivate::ItemMargin, 0, 0);
|
||||||
|
|
||||||
d->setActiveMargins();
|
d->setActiveMargins();
|
||||||
d->currentSize = QSizeF(-1, -1);
|
d->currentSize = QSizeF(-1, -1);
|
||||||
//setDrawStandardBackground(false);
|
//setDrawStandardBackground(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::addIconAction(QAction *action)
|
void IconWidget::addIconAction(QAction *action)
|
||||||
{
|
{
|
||||||
int count = d->cornerActions.count();
|
int count = d->cornerActions.count();
|
||||||
if (count > 3) {
|
if (count > 3) {
|
||||||
@ -330,10 +330,10 @@ void Icon::addIconAction(QAction *action)
|
|||||||
d->cornerActions.append(iconAction);
|
d->cornerActions.append(iconAction);
|
||||||
connect(action, SIGNAL(destroyed(QObject*)), this, SLOT(actionDestroyed(QObject*)));
|
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) {
|
if (d->action) {
|
||||||
disconnect(d->action, 0, this, 0);
|
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;
|
return d->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::actionDestroyed(QObject *action)
|
void IconWidget::actionDestroyed(QObject *action)
|
||||||
{
|
{
|
||||||
QList<IconAction*>::iterator it = d->cornerActions.begin();
|
QList<IconAction*>::iterator it = d->cornerActions.begin();
|
||||||
|
|
||||||
@ -366,12 +366,12 @@ void Icon::actionDestroyed(QObject *action)
|
|||||||
update(); // redraw since an action has been deleted.
|
update(); // redraw since an action has been deleted.
|
||||||
}
|
}
|
||||||
|
|
||||||
int Icon::numDisplayLines()
|
int IconWidget::numDisplayLines()
|
||||||
{
|
{
|
||||||
return d->numDisplayLines;
|
return d->numDisplayLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setNumDisplayLines(int numLines)
|
void IconWidget::setNumDisplayLines(int numLines)
|
||||||
{
|
{
|
||||||
if(numLines > d->maxDisplayLines) {
|
if(numLines > d->maxDisplayLines) {
|
||||||
d->numDisplayLines = 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) {
|
if (d->drawBg != draw) {
|
||||||
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;
|
return d->drawBg;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath Icon::shape() const
|
QPainterPath IconWidget::shape() const
|
||||||
{
|
{
|
||||||
if (d->currentSize.width() < 1) {
|
if (d->currentSize.width() < 1) {
|
||||||
return QGraphicsItem::shape();
|
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);
|
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()) {
|
if (text.isEmpty() && infoText.isEmpty()) {
|
||||||
return QSizeF(.0, .0);
|
return QSizeF(.0, .0);
|
||||||
@ -414,8 +414,8 @@ QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, cons
|
|||||||
// we actually need the actual width.
|
// we actually need the actual width.
|
||||||
|
|
||||||
qreal textWidth = width -
|
qreal textWidth = width -
|
||||||
horizontalMargin[IconPrivate::TextMargin].left -
|
horizontalMargin[IconWidgetPrivate::TextMargin].left -
|
||||||
horizontalMargin[IconPrivate::TextMargin].right;
|
horizontalMargin[IconWidgetPrivate::TextMargin].right;
|
||||||
|
|
||||||
//allow only five lines of text
|
//allow only five lines of text
|
||||||
const qreal maxHeight =
|
const qreal maxHeight =
|
||||||
@ -434,7 +434,7 @@ QSizeF IconPrivate::displaySizeHint(const QStyleOptionGraphicsItem *option, cons
|
|||||||
return addMargin(size, TextMargin);
|
return addMargin(size, TextMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
void IconWidget::layoutIcons(const QStyleOptionGraphicsItem *option)
|
||||||
{
|
{
|
||||||
if (size() == d->currentSize) {
|
if (size() == d->currentSize) {
|
||||||
return;
|
return;
|
||||||
@ -452,8 +452,8 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
|||||||
if (!d->text.isEmpty() || !d->infoText.isEmpty()) {
|
if (!d->text.isEmpty() || !d->infoText.isEmpty()) {
|
||||||
heightAvail = d->currentSize.height() -
|
heightAvail = d->currentSize.height() -
|
||||||
d->displaySizeHint(option, d->currentSize.width()).height() -
|
d->displaySizeHint(option, d->currentSize.width()).height() -
|
||||||
d->verticalMargin[IconPrivate::TextMargin].top -
|
d->verticalMargin[IconWidgetPrivate::TextMargin].top -
|
||||||
d->verticalMargin[IconPrivate::TextMargin].bottom;
|
d->verticalMargin[IconWidgetPrivate::TextMargin].bottom;
|
||||||
//never make a label higher than half the total height
|
//never make a label higher than half the total height
|
||||||
heightAvail = qMax(heightAvail, d->currentSize.height() / 2);
|
heightAvail = qMax(heightAvail, d->currentSize.height() / 2);
|
||||||
} else {
|
} else {
|
||||||
@ -463,12 +463,12 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
|||||||
//aspect ratio very "tall"
|
//aspect ratio very "tall"
|
||||||
if (d->currentSize.width() < heightAvail) {
|
if (d->currentSize.width() < heightAvail) {
|
||||||
iconWidth = d->currentSize.width() -
|
iconWidth = d->currentSize.width() -
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].left -
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].left -
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].right;
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].right;
|
||||||
} else {
|
} else {
|
||||||
iconWidth = heightAvail -
|
iconWidth = heightAvail -
|
||||||
d->verticalMargin[IconPrivate::IconMargin].top -
|
d->verticalMargin[IconWidgetPrivate::IconMargin].top -
|
||||||
d->verticalMargin[IconPrivate::IconMargin].bottom;
|
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Horizontal layout
|
//Horizontal layout
|
||||||
@ -478,12 +478,12 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
|||||||
if (d->text.isEmpty() && d->infoText.isEmpty()) {
|
if (d->text.isEmpty() && d->infoText.isEmpty()) {
|
||||||
// with no text, we just take up the whole geometry
|
// with no text, we just take up the whole geometry
|
||||||
iconWidth = d->currentSize.width() -
|
iconWidth = d->currentSize.width() -
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].left -
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].left -
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].right;
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].right;
|
||||||
} else {
|
} else {
|
||||||
iconWidth = d->currentSize.height() -
|
iconWidth = d->currentSize.height() -
|
||||||
d->verticalMargin[IconPrivate::IconMargin].top -
|
d->verticalMargin[IconWidgetPrivate::IconMargin].top -
|
||||||
d->verticalMargin[IconPrivate::IconMargin].bottom;
|
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,12 +491,12 @@ void Icon::layoutIcons(const QStyleOptionGraphicsItem *option)
|
|||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach (IconAction *iconAction, d->cornerActions) {
|
foreach (IconAction *iconAction, d->cornerActions) {
|
||||||
iconAction->setRect(d->actionRect((IconPrivate::ActionPosition)count));
|
iconAction->setRect(d->actionRect((IconWidgetPrivate::ActionPosition)count));
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setSvg(const QString &svgFilePath, const QString &elementId)
|
void IconWidget::setSvg(const QString &svgFilePath, const QString &elementId)
|
||||||
{
|
{
|
||||||
if (!d->iconSvg) {
|
if (!d->iconSvg) {
|
||||||
d->iconSvg = new Plasma::Svg(this);
|
d->iconSvg = new Plasma::Svg(this);
|
||||||
@ -507,10 +507,10 @@ void Icon::setSvg(const QString &svgFilePath, const QString &elementId)
|
|||||||
d->iconSvgElement = elementId;
|
d->iconSvgElement = elementId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::hoverEffect(bool show)
|
void IconWidget::hoverEffect(bool show)
|
||||||
{
|
{
|
||||||
if (show) {
|
if (show) {
|
||||||
d->states |= IconPrivate::HoverState;
|
d->states |= IconWidgetPrivate::HoverState;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_fadeIn = show;
|
d->m_fadeIn = show;
|
||||||
@ -524,7 +524,7 @@ void Icon::hoverEffect(bool show)
|
|||||||
Animator::EaseOutCurve, this, "hoverAnimationUpdate");
|
Animator::EaseOutCurve, this, "hoverAnimationUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::hoverAnimationUpdate(qreal progress)
|
void IconWidget::hoverAnimationUpdate(qreal progress)
|
||||||
{
|
{
|
||||||
if (d->m_fadeIn) {
|
if (d->m_fadeIn) {
|
||||||
d->m_hoverAlpha = progress;
|
d->m_hoverAlpha = progress;
|
||||||
@ -538,14 +538,14 @@ void Icon::hoverAnimationUpdate(qreal progress)
|
|||||||
d->m_hoverAnimId = -1;
|
d->m_hoverAnimId = -1;
|
||||||
|
|
||||||
if (!d->m_fadeIn) {
|
if (!d->m_fadeIn) {
|
||||||
d->states &= ~IconPrivate::HoverState;
|
d->states &= ~IconWidgetPrivate::HoverState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconPrivate::drawBackground(QPainter *painter, IconState state)
|
void IconWidgetPrivate::drawBackground(QPainter *painter, IconWidgetState state)
|
||||||
{
|
{
|
||||||
if (!drawBg) {
|
if (!drawBg) {
|
||||||
return;
|
return;
|
||||||
@ -556,14 +556,14 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
|
|||||||
QColor border = textColor;
|
QColor border = textColor;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case IconPrivate::HoverState:
|
case IconWidgetPrivate::HoverState:
|
||||||
shadow.setHsv(
|
shadow.setHsv(
|
||||||
shadow.hue(),
|
shadow.hue(),
|
||||||
shadow.saturation(),
|
shadow.saturation(),
|
||||||
shadow.value() + (int)(darkShadow ? 50 * m_hoverAlpha: -50 * m_hoverAlpha),
|
shadow.value() + (int)(darkShadow ? 50 * m_hoverAlpha: -50 * m_hoverAlpha),
|
||||||
200 + (int)m_hoverAlpha * 55); // opacity
|
200 + (int)m_hoverAlpha * 55); // opacity
|
||||||
break;
|
break;
|
||||||
case IconPrivate::PressedState:
|
case IconWidgetPrivate::PressedState:
|
||||||
shadow.setHsv(
|
shadow.setHsv(
|
||||||
shadow.hue(),
|
shadow.hue(),
|
||||||
shadow.saturation(),
|
shadow.saturation(),
|
||||||
@ -591,7 +591,7 @@ void IconPrivate::drawBackground(QPainter *painter, IconState state)
|
|||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap IconPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
|
QPixmap IconWidgetPrivate::decoration(const QStyleOptionGraphicsItem *option, bool useHoverEffect)
|
||||||
{
|
{
|
||||||
QPixmap result;
|
QPixmap result;
|
||||||
|
|
||||||
@ -637,13 +637,13 @@ QPixmap IconPrivate::decoration(const QStyleOptionGraphicsItem *option, bool use
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option,
|
QPointF IconWidgetPrivate::iconPosition(const QStyleOptionGraphicsItem *option,
|
||||||
const QPixmap &pixmap) const
|
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
|
// Compute the nominal decoration rectangle
|
||||||
const QSizeF size = addMargin(iconSize, IconPrivate::IconMargin);
|
const QSizeF size = addMargin(iconSize, IconWidgetPrivate::IconMargin);
|
||||||
|
|
||||||
Qt::LayoutDirection direction = iconDirection(option);
|
Qt::LayoutDirection direction = iconDirection(option);
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ QPointF IconPrivate::iconPosition(const QStyleOptionGraphicsItem *option,
|
|||||||
return QPointF(pixmapRect.topLeft());
|
return QPointF(pixmapRect.topLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
|
QRectF IconWidgetPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
|
||||||
const QPixmap &icon,
|
const QPixmap &icon,
|
||||||
const QString &string) const
|
const QString &string) const
|
||||||
{
|
{
|
||||||
@ -682,8 +682,8 @@ QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
|
|||||||
return option->rect;
|
return option->rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSizeF decoSize = addMargin(iconSize, IconPrivate::IconMargin);
|
const QSizeF decoSize = addMargin(iconSize, IconWidgetPrivate::IconMargin);
|
||||||
const QRectF itemRect = subtractMargin(option->rect, IconPrivate::ItemMargin);
|
const QRectF itemRect = subtractMargin(option->rect, IconWidgetPrivate::ItemMargin);
|
||||||
QRectF textArea(QPointF(0, 0), itemRect.size());
|
QRectF textArea(QPointF(0, 0), itemRect.size());
|
||||||
|
|
||||||
if (orientation == Qt::Vertical) {
|
if (orientation == Qt::Vertical) {
|
||||||
@ -698,7 +698,7 @@ QRectF IconPrivate::labelRectangle(const QStyleOptionGraphicsItem *option,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lays the text out in a rectangle no larger than constraints, eliding it as necessary
|
// Lays the text out in a rectangle no larger than constraints, eliding it as necessary
|
||||||
QSizeF IconPrivate::layoutText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
|
QSizeF IconWidgetPrivate::layoutText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
|
||||||
const QString &text, const QSizeF &constraints) const
|
const QString &text, const QSizeF &constraints) const
|
||||||
{
|
{
|
||||||
const QSizeF size = layoutText(layout, text, constraints.width());
|
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
|
// 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());
|
QFontMetricsF metrics(layout.font());
|
||||||
qreal leading = metrics.leading();
|
qreal leading = metrics.leading();
|
||||||
@ -740,7 +740,7 @@ 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
|
// 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
|
// ellipses at the end of the last line, if there are more lines than will fit within
|
||||||
// the vertical size constraints.
|
// the vertical size constraints.
|
||||||
QString IconPrivate::elidedText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
|
QString IconWidgetPrivate::elidedText(QTextLayout &layout, const QStyleOptionGraphicsItem *option,
|
||||||
const QSizeF &size) const
|
const QSizeF &size) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
@ -785,7 +785,7 @@ QString IconPrivate::elidedText(QTextLayout &layout, const QStyleOptionGraphicsI
|
|||||||
return elided;
|
return elided;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
|
void IconWidgetPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
|
||||||
const QPixmap &icon, QTextLayout *labelLayout,
|
const QPixmap &icon, QTextLayout *labelLayout,
|
||||||
QTextLayout *infoLayout, QRectF *textBoundingRect) const
|
QTextLayout *infoLayout, QRectF *textBoundingRect) const
|
||||||
{
|
{
|
||||||
@ -795,7 +795,7 @@ void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
|
|||||||
|
|
||||||
QFontMetricsF fm(labelLayout->font());
|
QFontMetricsF fm(labelLayout->font());
|
||||||
const QRectF textArea = labelRectangle(option, icon, text);
|
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;
|
//kDebug() << this << "text area" << textArea << "text rect" << textRect;
|
||||||
// Sizes and constraints for the different text parts
|
// Sizes and constraints for the different text parts
|
||||||
@ -837,7 +837,7 @@ void IconPrivate::layoutTextItems(const QStyleOptionGraphicsItem *option,
|
|||||||
//kDebug() << "final position is" << labelLayout->position();
|
//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 ?
|
const QPalette::ColorGroup group = option->state & QStyle::State_Enabled ?
|
||||||
QPalette::Normal : QPalette::Disabled;
|
QPalette::Normal : QPalette::Disabled;
|
||||||
@ -849,7 +849,7 @@ QBrush IconPrivate::foregroundBrush(const QStyleOptionGraphicsItem *option) cons
|
|||||||
return option->palette.brush(group, QPalette::Text);
|
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 ?
|
const QPalette::ColorGroup group = option->state & QStyle::State_Enabled ?
|
||||||
QPalette::Normal : QPalette::Disabled;
|
QPalette::Normal : QPalette::Disabled;
|
||||||
@ -863,7 +863,7 @@ QBrush IconPrivate::backgroundBrush(const QStyleOptionGraphicsItem *option) cons
|
|||||||
return background;
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconPrivate::drawTextItems(QPainter *painter,
|
void IconWidgetPrivate::drawTextItems(QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
const QTextLayout &labelLayout,
|
const QTextLayout &labelLayout,
|
||||||
const QTextLayout &infoLayout) const
|
const QTextLayout &infoLayout) const
|
||||||
@ -886,12 +886,12 @@ void IconPrivate::drawTextItems(QPainter *painter,
|
|||||||
painter->restore();
|
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);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
#ifdef BACKINGSTORE_BLUR_HACK
|
#ifdef BACKINGSTORE_BLUR_HACK
|
||||||
if (d->state == IconPrivate::HoverState && scene()) {
|
if (d->state == IconWidgetPrivate::HoverState && scene()) {
|
||||||
QList<QGraphicsView*> views = scene()->views();
|
QList<QGraphicsView*> views = scene()->views();
|
||||||
if (views.count() > 0) {
|
if (views.count() > 0) {
|
||||||
QPixmap* pix = static_cast<QPixmap*>(views[0]->windowSurface()->paintDevice());
|
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
|
// Compute the metrics, and lay out the text items
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
IconPrivate::IconState state = IconPrivate::NoState;
|
IconWidgetPrivate::IconWidgetState state = IconWidgetPrivate::NoState;
|
||||||
if (d->states & IconPrivate::ManualPressedState) {
|
if (d->states & IconWidgetPrivate::ManualPressedState) {
|
||||||
state = IconPrivate::PressedState;
|
state = IconWidgetPrivate::PressedState;
|
||||||
} else if (d->states & IconPrivate::PressedState) {
|
} else if (d->states & IconWidgetPrivate::PressedState) {
|
||||||
if (d->states & IconPrivate::HoverState) {
|
if (d->states & IconWidgetPrivate::HoverState) {
|
||||||
state = IconPrivate::PressedState;
|
state = IconWidgetPrivate::PressedState;
|
||||||
}
|
}
|
||||||
} else if (d->states & IconPrivate::HoverState) {
|
} else if (d->states & IconWidgetPrivate::HoverState) {
|
||||||
state = IconPrivate::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);
|
const QPointF iconPos = d->iconPosition(option, icon);
|
||||||
|
|
||||||
d->drawBackground(painter, state);
|
d->drawBackground(painter, state);
|
||||||
@ -963,15 +963,15 @@ void Icon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
|
|||||||
d->drawTextItems(painter, option, labelLayout, infoLayout);
|
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;
|
qreal radius = size.width() / 2;
|
||||||
QRadialGradient gradient(radius, radius, radius, radius, radius);
|
QRadialGradient gradient(radius, radius, radius, radius, radius);
|
||||||
int alpha;
|
int alpha;
|
||||||
|
|
||||||
if (element == IconPrivate::MinibuttonPressed) {
|
if (element == IconWidgetPrivate::MinibuttonPressed) {
|
||||||
alpha = 255;
|
alpha = 255;
|
||||||
} else if (element == IconPrivate::MinibuttonHover) {
|
} else if (element == IconWidgetPrivate::MinibuttonHover) {
|
||||||
alpha = 200;
|
alpha = 200;
|
||||||
} else {
|
} else {
|
||||||
alpha = 160;
|
alpha = 160;
|
||||||
@ -988,7 +988,7 @@ void Icon::drawActionButtonBase(QPainter *painter, const QSize &size, int elemen
|
|||||||
painter->drawEllipse(QRectF(QPointF(.0, .0), size));
|
painter->drawEllipse(QRectF(QPointF(.0, .0), size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setText(const QString &text)
|
void IconWidget::setText(const QString &text)
|
||||||
{
|
{
|
||||||
d->text = text;
|
d->text = text;
|
||||||
// cause a relayout
|
// cause a relayout
|
||||||
@ -1001,12 +1001,12 @@ void Icon::setText(const QString &text)
|
|||||||
resize(sizeFromIconSize(d->iconSize.width()));
|
resize(sizeFromIconSize(d->iconSize.width()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Icon::text() const
|
QString IconWidget::text() const
|
||||||
{
|
{
|
||||||
return d->text;
|
return d->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setInfoText(const QString &text)
|
void IconWidget::setInfoText(const QString &text)
|
||||||
{
|
{
|
||||||
d->infoText = text;
|
d->infoText = text;
|
||||||
// cause a relayout
|
// cause a relayout
|
||||||
@ -1018,17 +1018,17 @@ void Icon::setInfoText(const QString &text)
|
|||||||
resize(sizeFromIconSize(d->iconSize.width()));
|
resize(sizeFromIconSize(d->iconSize.width()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Icon::infoText() const
|
QString IconWidget::infoText() const
|
||||||
{
|
{
|
||||||
return d->infoText;
|
return d->infoText;
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon Icon::icon() const
|
QIcon IconWidget::icon() const
|
||||||
{
|
{
|
||||||
return d->icon;
|
return d->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setIcon(const QString &icon)
|
void IconWidget::setIcon(const QString &icon)
|
||||||
{
|
{
|
||||||
if (icon.isEmpty()) {
|
if (icon.isEmpty()) {
|
||||||
setIcon(QIcon());
|
setIcon(QIcon());
|
||||||
@ -1038,29 +1038,29 @@ void Icon::setIcon(const QString &icon)
|
|||||||
setIcon(KIcon(icon));
|
setIcon(KIcon(icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setIcon(const QIcon &icon)
|
void IconWidget::setIcon(const QIcon &icon)
|
||||||
{
|
{
|
||||||
d->icon = icon;
|
d->icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF Icon::iconSize() const
|
QSizeF IconWidget::iconSize() const
|
||||||
{
|
{
|
||||||
return d->iconSize;
|
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) {
|
if (event->button() != Qt::LeftButton) {
|
||||||
QGraphicsWidget::mousePressEvent(event);
|
QGraphicsWidget::mousePressEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->states |= IconPrivate::PressedState;
|
d->states |= IconWidgetPrivate::PressedState;
|
||||||
d->clickStartPos = scenePos();
|
d->clickStartPos = scenePos();
|
||||||
|
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
@ -1078,34 +1078,34 @@ void Icon::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
void IconWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (~d->states & IconPrivate::PressedState) {
|
if (~d->states & IconWidgetPrivate::PressedState) {
|
||||||
QGraphicsWidget::mouseMoveEvent(event);
|
QGraphicsWidget::mouseMoveEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boundingRect().contains(event->pos())) {
|
if (boundingRect().contains(event->pos())) {
|
||||||
if (~d->states & IconPrivate::HoverState) {
|
if (~d->states & IconWidgetPrivate::HoverState) {
|
||||||
d->states |= IconPrivate::HoverState;
|
d->states |= IconWidgetPrivate::HoverState;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (d->states & IconPrivate::HoverState) {
|
if (d->states & IconWidgetPrivate::HoverState) {
|
||||||
d->states &= ~IconPrivate::HoverState;
|
d->states &= ~IconWidgetPrivate::HoverState;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void IconWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (~d->states & IconPrivate::PressedState) {
|
if (~d->states & IconWidgetPrivate::PressedState) {
|
||||||
QGraphicsWidget::mouseMoveEvent(event);
|
QGraphicsWidget::mouseMoveEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->states &= ~IconPrivate::PressedState;
|
d->states &= ~IconWidgetPrivate::PressedState;
|
||||||
|
|
||||||
//don't pass click when the mouse was moved
|
//don't pass click when the mouse was moved
|
||||||
bool handled = d->clickStartPos != scenePos();
|
bool handled = d->clickStartPos != scenePos();
|
||||||
@ -1131,7 +1131,7 @@ void Icon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
void IconWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(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) {
|
foreach (IconAction *action, d->cornerActions) {
|
||||||
action->show();
|
action->show();
|
||||||
@ -1153,37 +1153,37 @@ void Icon::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
|||||||
QGraphicsWidget::hoverEnterEvent(event);
|
QGraphicsWidget::hoverEnterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void IconWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
foreach (IconAction *action, d->cornerActions) {
|
foreach (IconAction *action, d->cornerActions) {
|
||||||
action->hide();
|
action->hide();
|
||||||
action->event(event->type(), event->pos());
|
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);
|
hoverEffect(false);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
QGraphicsWidget::hoverLeaveEvent(event);
|
QGraphicsWidget::hoverLeaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setPressed(bool pressed)
|
void IconWidget::setPressed(bool pressed)
|
||||||
{
|
{
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
d->states |= IconPrivate::ManualPressedState;
|
d->states |= IconWidgetPrivate::ManualPressedState;
|
||||||
d->states |= IconPrivate::PressedState;
|
d->states |= IconWidgetPrivate::PressedState;
|
||||||
} else {
|
} else {
|
||||||
d->states &= ~IconPrivate::ManualPressedState;
|
d->states &= ~IconWidgetPrivate::ManualPressedState;
|
||||||
d->states &= ~IconPrivate::PressedState;
|
d->states &= ~IconWidgetPrivate::PressedState;
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setUnpressed()
|
void IconWidget::setUnpressed()
|
||||||
{
|
{
|
||||||
setPressed(false);
|
setPressed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconPrivate::syncToAction()
|
void IconWidgetPrivate::syncToAction()
|
||||||
{
|
{
|
||||||
if (!action) {
|
if (!action) {
|
||||||
return;
|
return;
|
||||||
@ -1198,28 +1198,28 @@ void IconPrivate::syncToAction()
|
|||||||
emit q->changed();
|
emit q->changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::setOrientation(Qt::Orientation orientation)
|
void IconWidget::setOrientation(Qt::Orientation orientation)
|
||||||
{
|
{
|
||||||
d->orientation = orientation;
|
d->orientation = orientation;
|
||||||
resize(sizeFromIconSize(d->iconSize.width()));
|
resize(sizeFromIconSize(d->iconSize.width()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Icon::invertLayout(bool invert)
|
void IconWidget::invertLayout(bool invert)
|
||||||
{
|
{
|
||||||
d->invertLayout = invert;
|
d->invertLayout = invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Icon::invertedLayout() const
|
bool IconWidget::invertedLayout() const
|
||||||
{
|
{
|
||||||
return d->invertLayout;
|
return d->invertLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF Icon::sizeFromIconSize(const qreal iconWidth) const
|
QSizeF IconWidget::sizeFromIconSize(const qreal iconWidth) const
|
||||||
{
|
{
|
||||||
if (d->text.isEmpty() && d->infoText.isEmpty()) {
|
if (d->text.isEmpty() && d->infoText.isEmpty()) {
|
||||||
//no text, less calculations
|
//no text, less calculations
|
||||||
return d->addMargin(d->addMargin(QSizeF(iconWidth, iconWidth), IconPrivate::IconMargin),
|
return d->addMargin(d->addMargin(QSizeF(iconWidth, iconWidth), IconWidgetPrivate::IconMargin),
|
||||||
IconPrivate::ItemMargin);
|
IconWidgetPrivate::ItemMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFontMetricsF fm = Plasma::Theme::defaultTheme()->fontMetrics();
|
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)),
|
width = qMax(fm.width(d->text.left(12)),
|
||||||
fm.width(d->infoText.left(12))) +
|
fm.width(d->infoText.left(12))) +
|
||||||
fm.width("xx") +
|
fm.width("xx") +
|
||||||
d->horizontalMargin[IconPrivate::TextMargin].left +
|
d->horizontalMargin[IconWidgetPrivate::TextMargin].left +
|
||||||
d->horizontalMargin[IconPrivate::TextMargin].right;
|
d->horizontalMargin[IconWidgetPrivate::TextMargin].right;
|
||||||
|
|
||||||
width = qMax(width,
|
width = qMax(width,
|
||||||
iconWidth +
|
iconWidth +
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].left +
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].left +
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].right);
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].right);
|
||||||
} else {
|
} else {
|
||||||
width = iconWidth +
|
width = iconWidth +
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].left +
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].left +
|
||||||
d->horizontalMargin[IconPrivate::IconMargin].right +
|
d->horizontalMargin[IconWidgetPrivate::IconMargin].right +
|
||||||
qMax(fm.width(d->text), fm.width(d->infoText)) + fm.width("xx") +
|
qMax(fm.width(d->text), fm.width(d->infoText)) + fm.width("xx") +
|
||||||
d->horizontalMargin[IconPrivate::TextMargin].left +
|
d->horizontalMargin[IconWidgetPrivate::TextMargin].left +
|
||||||
d->horizontalMargin[IconPrivate::TextMargin].right;
|
d->horizontalMargin[IconWidgetPrivate::TextMargin].right;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal height;
|
qreal height;
|
||||||
@ -1256,23 +1256,23 @@ QSizeF Icon::sizeFromIconSize(const qreal iconWidth) const
|
|||||||
|
|
||||||
if (d->orientation == Qt::Vertical) {
|
if (d->orientation == Qt::Vertical) {
|
||||||
height = iconWidth + textHeight +
|
height = iconWidth + textHeight +
|
||||||
d->verticalMargin[IconPrivate::TextMargin].top +
|
d->verticalMargin[IconWidgetPrivate::TextMargin].top +
|
||||||
d->verticalMargin[IconPrivate::TextMargin].bottom +
|
d->verticalMargin[IconWidgetPrivate::TextMargin].bottom +
|
||||||
d->verticalMargin[IconPrivate::IconMargin].top +
|
d->verticalMargin[IconWidgetPrivate::IconMargin].top +
|
||||||
d->verticalMargin[IconPrivate::IconMargin].bottom;
|
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom;
|
||||||
} else {
|
} else {
|
||||||
//Horizontal
|
//Horizontal
|
||||||
height = qMax(iconWidth +
|
height = qMax(iconWidth +
|
||||||
d->verticalMargin[IconPrivate::IconMargin].top +
|
d->verticalMargin[IconWidgetPrivate::IconMargin].top +
|
||||||
d->verticalMargin[IconPrivate::IconMargin].bottom,
|
d->verticalMargin[IconWidgetPrivate::IconMargin].bottom,
|
||||||
textHeight +
|
textHeight +
|
||||||
d->verticalMargin[IconPrivate::TextMargin].top +
|
d->verticalMargin[IconWidgetPrivate::TextMargin].top +
|
||||||
d->verticalMargin[IconPrivate::TextMargin].bottom);
|
d->verticalMargin[IconWidgetPrivate::TextMargin].bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->addMargin(QSizeF(width, height), IconPrivate::ItemMargin);
|
return d->addMargin(QSizeF(width, height), IconWidgetPrivate::ItemMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
|
||||||
#include "icon.moc"
|
#include "iconwidget.moc"
|
@ -20,8 +20,8 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PLASMA_ICON_H
|
#ifndef PLASMA_ICONWIDGET_H
|
||||||
#define PLASMA_ICON_H
|
#define PLASMA_ICONWIDGET_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QGraphicsTextItem>
|
#include <QtGui/QGraphicsTextItem>
|
||||||
@ -35,12 +35,12 @@
|
|||||||
class QAction;
|
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.
|
* @short Provides a generic icon.
|
||||||
*
|
*
|
||||||
* An icon, in this sense, is not restricted to just an image, but can also
|
* 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.
|
* but is designed to be used anywhere an icon is needed in an applet.
|
||||||
*
|
*
|
||||||
* @author Siraj Razick <siraj@kde.org>
|
* @author Siraj Razick <siraj@kde.org>
|
||||||
@ -49,9 +49,9 @@ class QAction;
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class IconPrivate;
|
class IconWidgetPrivate;
|
||||||
|
|
||||||
class PLASMA_EXPORT Icon : public QGraphicsWidget
|
class PLASMA_EXPORT IconWidget : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString text READ text WRITE setText)
|
Q_PROPERTY(QString text READ text WRITE setText)
|
||||||
@ -63,30 +63,30 @@ class PLASMA_EXPORT Icon : public QGraphicsWidget
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Creates a new Plasma::Icon.
|
* Creates a new Plasma::IconWidget.
|
||||||
* @param parent the QGraphicsItem this icon is parented to.
|
* @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 text the text that will be displayed with this icon.
|
||||||
* @param parent the QGraphicsItem this icon is parented to.
|
* @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 icon the icon that will be displayed with this icon.
|
||||||
* @param text the text 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.
|
* @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.
|
* Returns the text associated with this icon.
|
||||||
@ -124,35 +124,35 @@ public:
|
|||||||
QIcon icon() const;
|
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.
|
* @param icon the KIcon to associate with this icon.
|
||||||
*/
|
*/
|
||||||
void setIcon(const QIcon &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.
|
* 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);
|
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;
|
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
|
* (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.
|
* @param action the QAction to associate with this icon.
|
||||||
*/
|
*/
|
||||||
void addIconAction(QAction *action);
|
void addIconAction(QAction *action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate an action with this Icon
|
* Associate an action with this IconWidget
|
||||||
* this makes the Icon follow the state of the action, using its icon, text, etc.
|
* this makes the IconWidget follow the state of the action, using its icon, text, etc.
|
||||||
* when the Icon is clicked, it will also trigger the action.
|
* when the IconWidget is clicked, it will also trigger the action.
|
||||||
* Unlike addIconAction, there can be only one associated action.
|
* Unlike addIconAction, there can be only one associated action.
|
||||||
*/
|
*/
|
||||||
void setAction(QAction *action);
|
void setAction(QAction *action);
|
||||||
@ -282,9 +282,9 @@ private:
|
|||||||
void layoutIcons(const QStyleOptionGraphicsItem *option);
|
void layoutIcons(const QStyleOptionGraphicsItem *option);
|
||||||
void hoverEffect(bool);
|
void hoverEffect(bool);
|
||||||
|
|
||||||
IconPrivate * const d;
|
IconWidgetPrivate * const d;
|
||||||
|
|
||||||
friend class IconPrivate;
|
friend class IconWidgetPrivate;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void actionDestroyed(QObject *obj);
|
void actionDestroyed(QObject *obj);
|
@ -19,8 +19,8 @@
|
|||||||
* Free Software Foundation, Inc.,
|
* Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
#ifndef PLASMA_ICON_P_H
|
#ifndef PLASMA_ICONWIDGET_P_H
|
||||||
#define PLASMA_ICON_P_H
|
#define PLASMA_ICONWIDGET_P_H
|
||||||
|
|
||||||
#include <QtCore/QEvent>
|
#include <QtCore/QEvent>
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
#include <plasma/svg.h>
|
#include <plasma/svg.h>
|
||||||
|
|
||||||
#include "icon.h"
|
#include "iconwidget.h"
|
||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
@ -45,7 +45,7 @@ namespace Plasma
|
|||||||
class PLASMA_EXPORT IconAction
|
class PLASMA_EXPORT IconAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IconAction(Icon *icon, QAction *action);
|
IconAction(IconWidget *icon, QAction *action);
|
||||||
|
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void rebuildPixmap();
|
void rebuildPixmap();
|
||||||
|
|
||||||
Icon *m_icon;
|
IconWidget *m_icon;
|
||||||
QAction *m_action;
|
QAction *m_action;
|
||||||
QPixmap m_pixmap;
|
QPixmap m_pixmap;
|
||||||
QRectF m_rect;
|
QRectF m_rect;
|
||||||
@ -87,7 +87,7 @@ struct Margin
|
|||||||
qreal left, right, top, bottom;
|
qreal left, right, top, bottom;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IconPrivate
|
class IconWidgetPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum MarginType {
|
enum MarginType {
|
||||||
@ -97,19 +97,19 @@ public:
|
|||||||
NMargins
|
NMargins
|
||||||
};
|
};
|
||||||
|
|
||||||
enum IconState {
|
enum IconWidgetState {
|
||||||
NoState = 0,
|
NoState = 0,
|
||||||
HoverState = 1,
|
HoverState = 1,
|
||||||
PressedState = 2,
|
PressedState = 2,
|
||||||
ManualPressedState = 4
|
ManualPressedState = 4
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(IconStates, IconState)
|
Q_DECLARE_FLAGS(IconWidgetStates, IconWidgetState)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IconPrivate(Icon *i);
|
IconWidgetPrivate(IconWidget *i);
|
||||||
~IconPrivate();
|
~IconWidgetPrivate();
|
||||||
|
|
||||||
void drawBackground(QPainter *painter, IconState state);
|
void drawBackground(QPainter *painter, IconWidgetState state);
|
||||||
void drawText(QPainter *painter);
|
void drawText(QPainter *painter);
|
||||||
void drawTextItems(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void drawTextItems(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
const QTextLayout &labelLayout, const QTextLayout &infoLayout) const;
|
const QTextLayout &labelLayout, const QTextLayout &infoLayout) const;
|
||||||
@ -176,7 +176,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void syncToAction();
|
void syncToAction();
|
||||||
|
|
||||||
Icon *q;
|
IconWidget *q;
|
||||||
QString text;
|
QString text;
|
||||||
QString infoText;
|
QString infoText;
|
||||||
Svg *iconSvg;
|
Svg *iconSvg;
|
||||||
@ -189,7 +189,7 @@ public:
|
|||||||
qreal m_hoverAlpha;
|
qreal m_hoverAlpha;
|
||||||
QSizeF iconSize;
|
QSizeF iconSize;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
IconStates states;
|
IconWidgetStates states;
|
||||||
Qt::Orientation orientation;
|
Qt::Orientation orientation;
|
||||||
int numDisplayLines;
|
int numDisplayLines;
|
||||||
bool invertLayout;
|
bool invertLayout;
|
||||||
@ -209,10 +209,10 @@ public:
|
|||||||
static const int iconActionMargin = 4;
|
static const int iconActionMargin = 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(IconPrivate::IconStates)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(IconWidgetPrivate::IconWidgetStates)
|
||||||
|
|
||||||
// Inline methods
|
// Inline methods
|
||||||
void IconPrivate::setLayoutOptions(QTextLayout &layout,
|
void IconWidgetPrivate::setLayoutOptions(QTextLayout &layout,
|
||||||
const QStyleOptionGraphicsItem *option) const
|
const QStyleOptionGraphicsItem *option) const
|
||||||
{
|
{
|
||||||
QTextOption textoption;
|
QTextOption textoption;
|
||||||
@ -224,7 +224,7 @@ void IconPrivate::setLayoutOptions(QTextLayout &layout,
|
|||||||
layout.setTextOption(textoption);
|
layout.setTextOption(textoption);
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::LayoutDirection IconPrivate::iconDirection(const QStyleOptionGraphicsItem *option) const
|
Qt::LayoutDirection IconWidgetPrivate::iconDirection(const QStyleOptionGraphicsItem *option) const
|
||||||
{
|
{
|
||||||
Qt::LayoutDirection direction;
|
Qt::LayoutDirection direction;
|
||||||
|
|
||||||
@ -241,13 +241,13 @@ Qt::LayoutDirection IconPrivate::iconDirection(const QStyleOptionGraphicsItem *o
|
|||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconPrivate::setActiveMargins()
|
void IconWidgetPrivate::setActiveMargins()
|
||||||
{
|
{
|
||||||
activeMargins = (orientation == Qt::Horizontal ?
|
activeMargins = (orientation == Qt::Horizontal ?
|
||||||
horizontalMargin : verticalMargin);
|
horizontalMargin : verticalMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconPrivate::setVerticalMargin(MarginType type, qreal left, qreal top,
|
void IconWidgetPrivate::setVerticalMargin(MarginType type, qreal left, qreal top,
|
||||||
qreal right, qreal bottom)
|
qreal right, qreal bottom)
|
||||||
{
|
{
|
||||||
verticalMargin[type].left = left;
|
verticalMargin[type].left = left;
|
||||||
@ -256,7 +256,7 @@ void IconPrivate::setVerticalMargin(MarginType type, qreal left, qreal top,
|
|||||||
verticalMargin[type].bottom = bottom;
|
verticalMargin[type].bottom = bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top,
|
void IconWidgetPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top,
|
||||||
qreal right, qreal bottom)
|
qreal right, qreal bottom)
|
||||||
{
|
{
|
||||||
horizontalMargin[type].left = left;
|
horizontalMargin[type].left = left;
|
||||||
@ -265,45 +265,45 @@ void IconPrivate::setHorizontalMargin(MarginType type, qreal left, qreal top,
|
|||||||
horizontalMargin[type].bottom = bottom;
|
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);
|
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);
|
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);
|
Q_ASSERT(activeMargins);
|
||||||
const Margin &m = activeMargins[type];
|
const Margin &m = activeMargins[type];
|
||||||
return rect.adjusted(-m.left, -m.top, m.right, m.bottom);
|
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);
|
Q_ASSERT(activeMargins);
|
||||||
const Margin &m = activeMargins[type];
|
const Margin &m = activeMargins[type];
|
||||||
return rect.adjusted(m.left, m.top, -m.right, -m.bottom);
|
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);
|
Q_ASSERT(activeMargins);
|
||||||
const Margin &m = activeMargins[type];
|
const Margin &m = activeMargins[type];
|
||||||
return QSizeF(size.width() + m.left + m.right, size.height() + m.top + m.bottom);
|
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);
|
Q_ASSERT(activeMargins);
|
||||||
const Margin &m = activeMargins[type];
|
const Margin &m = activeMargins[type];
|
||||||
return QSizeF(size.width() - m.left - m.right, size.height() - m.top - m.bottom);
|
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) {
|
switch (position) {
|
||||||
case TopLeft:
|
case TopLeft:
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "meter.h"
|
#include "meter.h"
|
||||||
#include "plasma/panelsvg.h"
|
#include "plasma/framesvg.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -100,8 +100,8 @@ public:
|
|||||||
image->resize();
|
image->resize();
|
||||||
|
|
||||||
image->setElementPrefix("background");
|
image->setElementPrefix("background");
|
||||||
image->resizePanel(elementRect.size());
|
image->resizeFrame(elementRect.size());
|
||||||
image->paintPanel(p, elementRect.topLeft());
|
image->paintFrame(p, elementRect.topLeft());
|
||||||
image->resize(imageSize);
|
image->resize(imageSize);
|
||||||
|
|
||||||
paintBar(p, "bar-inactive");
|
paintBar(p, "bar-inactive");
|
||||||
@ -136,8 +136,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
image->setElementPrefix(prefix);
|
image->setElementPrefix(prefix);
|
||||||
image->resizePanel(tileSize);
|
image->resizeFrame(tileSize);
|
||||||
p->drawTiledPixmap(elementRect, image->panelPixmap());
|
p->drawTiledPixmap(elementRect, image->framePixmap());
|
||||||
image->resize(imageSize);
|
image->resize(imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ public:
|
|||||||
QList<QFont> fonts;
|
QList<QFont> fonts;
|
||||||
QString svg;
|
QString svg;
|
||||||
Meter::MeterType meterType;
|
Meter::MeterType meterType;
|
||||||
Plasma::PanelSvg *image;
|
Plasma::FrameSvg *image;
|
||||||
int minrotate;
|
int minrotate;
|
||||||
int maxrotate;
|
int maxrotate;
|
||||||
Meter *meter;
|
Meter *meter;
|
||||||
@ -300,7 +300,7 @@ void Meter::setSvg(const QString &svg)
|
|||||||
{
|
{
|
||||||
d->svg = svg;
|
d->svg = svg;
|
||||||
delete d->image;
|
delete d->image;
|
||||||
d->image = new Plasma::PanelSvg(this);
|
d->image = new Plasma::FrameSvg(this);
|
||||||
d->image->setImagePath(svg);
|
d->image->setImagePath(svg);
|
||||||
// To create renderer and get default size
|
// To create renderer and get default size
|
||||||
d->image->resize();
|
d->image->resize();
|
||||||
|
@ -38,10 +38,10 @@ class MeterPrivate;
|
|||||||
*
|
*
|
||||||
* Svgs can have following ids:
|
* Svgs can have following ids:
|
||||||
* - background: Drawn first to the bottom
|
* - background: Drawn first to the bottom
|
||||||
* background can be a PanelSvg
|
* background can be a FrameSvg
|
||||||
* - label0, label1, ...: Rectangles mark the label places
|
* - label0, label1, ...: Rectangles mark the label places
|
||||||
* - bar: Bar for the bar meter
|
* - 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
|
* - pointer: Pointer for analog meter
|
||||||
* - rotatecenter: Marks the place of pointer rotation center
|
* - rotatecenter: Marks the place of pointer rotation center
|
||||||
* - rotateminmax: Width and height of this object are the Min and Max rotate
|
* - rotateminmax: Width and height of this object are the Min and Max rotate
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
#include "panelsvg.h"
|
#include "framesvg.h"
|
||||||
#include "animator.h"
|
#include "animator.h"
|
||||||
#include "paintutils.h"
|
#include "paintutils.h"
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
PushButton *q;
|
PushButton *q;
|
||||||
|
|
||||||
PanelSvg *background;
|
FrameSvg *background;
|
||||||
int animId;
|
int animId;
|
||||||
bool fadeIn;
|
bool fadeIn;
|
||||||
qreal opacity;
|
qreal opacity;
|
||||||
@ -146,9 +146,9 @@ PushButton::PushButton(QGraphicsWidget *parent)
|
|||||||
setWidget(native);
|
setWidget(native);
|
||||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
|
||||||
d->background = new PanelSvg(this);
|
d->background = new FrameSvg(this);
|
||||||
d->background->setImagePath("widgets/button");
|
d->background->setImagePath("widgets/button");
|
||||||
d->background->setCacheAllRenderedPanels(true);
|
d->background->setCacheAllRenderedFrames(true);
|
||||||
d->background->setElementPrefix("normal");
|
d->background->setElementPrefix("normal");
|
||||||
d->syncBorders();
|
d->syncBorders();
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
@ -225,17 +225,17 @@ void PushButton::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
if (d->background) {
|
if (d->background) {
|
||||||
//resize all four panels
|
//resize all four panels
|
||||||
d->background->setElementPrefix("pressed");
|
d->background->setElementPrefix("pressed");
|
||||||
d->background->resizePanel(size());
|
d->background->resizeFrame(size());
|
||||||
d->background->setElementPrefix("focus");
|
d->background->setElementPrefix("focus");
|
||||||
d->background->resizePanel(size());
|
d->background->resizeFrame(size());
|
||||||
|
|
||||||
d->syncActiveRect();
|
d->syncActiveRect();
|
||||||
|
|
||||||
d->background->setElementPrefix("active");
|
d->background->setElementPrefix("active");
|
||||||
d->background->resizePanel(d->activeRect.size());
|
d->background->resizeFrame(d->activeRect.size());
|
||||||
|
|
||||||
d->background->setElementPrefix("normal");
|
d->background->setElementPrefix("normal");
|
||||||
d->background->resizePanel(size());
|
d->background->resizeFrame(size());
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsProxyWidget::resizeEvent(event);
|
QGraphicsProxyWidget::resizeEvent(event);
|
||||||
@ -260,7 +260,7 @@ void PushButton::paint(QPainter *painter,
|
|||||||
d->background->setElementPrefix("normal");
|
d->background->setElementPrefix("normal");
|
||||||
}
|
}
|
||||||
if (d->animId == -1) {
|
if (d->animId == -1) {
|
||||||
d->background->paintPanel(painter);
|
d->background->paintFrame(painter);
|
||||||
}
|
}
|
||||||
//flat or disabled
|
//flat or disabled
|
||||||
} else if (!isEnabled() || nativeWidget()->isFlat()) {
|
} else if (!isEnabled() || nativeWidget()->isFlat()) {
|
||||||
@ -268,7 +268,7 @@ void PushButton::paint(QPainter *painter,
|
|||||||
bufferPixmap.fill(Qt::transparent);
|
bufferPixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter buffPainter(&bufferPixmap);
|
QPainter buffPainter(&bufferPixmap);
|
||||||
d->background->paintPanel(&buffPainter);
|
d->background->paintFrame(&buffPainter);
|
||||||
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
buffPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||||
buffPainter.fillRect(bufferPixmap.rect(), QColor(0, 0, 0, 128));
|
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 is under mouse draw the animated glow overlay
|
||||||
if (!nativeWidget()->isDown() && isEnabled() && acceptHoverEvents()) {
|
if (!nativeWidget()->isDown() && isEnabled() && acceptHoverEvents()) {
|
||||||
if (d->animId != -1) {
|
if (d->animId != -1) {
|
||||||
QPixmap normalPix = d->background->panelPixmap();
|
QPixmap normalPix = d->background->framePixmap();
|
||||||
d->background->setElementPrefix("active");
|
d->background->setElementPrefix("active");
|
||||||
painter->drawPixmap(
|
painter->drawPixmap(
|
||||||
d->activeRect.topLeft(),
|
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()) {
|
} else if (isUnderMouse() || nativeWidget()->isDefault()) {
|
||||||
d->background->setElementPrefix("active");
|
d->background->setElementPrefix("active");
|
||||||
d->background->paintPanel(painter, d->activeRect.topLeft());
|
d->background->paintFrame(painter, d->activeRect.topLeft());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nativeWidget()->hasFocus()) {
|
if (nativeWidget()->hasFocus()) {
|
||||||
d->background->setElementPrefix("focus");
|
d->background->setElementPrefix("focus");
|
||||||
d->background->paintPanel(painter);
|
d->background->paintFrame(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
painter->setPen(Plasma::Theme::defaultTheme()->color(Theme::ButtonTextColor));
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <KMimeType>
|
#include <KMimeType>
|
||||||
|
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "panelsvg.h"
|
#include "framesvg.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
@ -42,8 +42,8 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::PanelSvg *background;
|
Plasma::FrameSvg *background;
|
||||||
Plasma::PanelSvg *handle;
|
Plasma::FrameSvg *handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
Slider::Slider(QGraphicsWidget *parent)
|
Slider::Slider(QGraphicsWidget *parent)
|
||||||
@ -58,11 +58,11 @@ Slider::Slider(QGraphicsWidget *parent)
|
|||||||
setWidget(native);
|
setWidget(native);
|
||||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
|
||||||
d->background = new Plasma::PanelSvg(this);
|
d->background = new Plasma::FrameSvg(this);
|
||||||
d->background->setImagePath("widgets/frame");
|
d->background->setImagePath("widgets/frame");
|
||||||
d->background->setElementPrefix("sunken");
|
d->background->setElementPrefix("sunken");
|
||||||
|
|
||||||
d->handle = new Plasma::PanelSvg(this);
|
d->handle = new Plasma::FrameSvg(this);
|
||||||
d->handle->setImagePath("widgets/button");
|
d->handle->setImagePath("widgets/button");
|
||||||
d->handle->setElementPrefix("normal");
|
d->handle->setElementPrefix("normal");
|
||||||
}
|
}
|
||||||
@ -108,8 +108,8 @@ void Slider::paint(QPainter *painter,
|
|||||||
|
|
||||||
QRect backgroundRect =
|
QRect backgroundRect =
|
||||||
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderGroove, slider);
|
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderGroove, slider);
|
||||||
d->background->resizePanel(backgroundRect.size());
|
d->background->resizeFrame(backgroundRect.size());
|
||||||
d->background->paintPanel(painter, backgroundRect.topLeft());
|
d->background->paintFrame(painter, backgroundRect.topLeft());
|
||||||
|
|
||||||
//Thickmarks
|
//Thickmarks
|
||||||
if (sliderOpt.tickPosition != QSlider::NoTicks) {
|
if (sliderOpt.tickPosition != QSlider::NoTicks) {
|
||||||
@ -121,8 +121,8 @@ void Slider::paint(QPainter *painter,
|
|||||||
|
|
||||||
QRect handleRect =
|
QRect handleRect =
|
||||||
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderHandle, slider);
|
style->subControlRect(QStyle::CC_Slider, &sliderOpt, QStyle::SC_SliderHandle, slider);
|
||||||
d->handle->resizePanel(handleRect.size());
|
d->handle->resizeFrame(handleRect.size());
|
||||||
d->handle->paintPanel(painter, handleRect.topLeft());
|
d->handle->paintFrame(painter, handleRect.topLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::setMaximum(int max)
|
void Slider::setMaximum(int max)
|
||||||
|
Loading…
Reference in New Issue
Block a user