2005-12-29 22:55:22 +01:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2005 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
|
2008-04-14 12:48:32 +02:00
|
|
|
* Copyright 2008 by Ménard Alexis <darktears31@gmail.com>
|
2005-12-29 22:55:22 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* 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.
|
2005-12-29 22:55:22 +01:00
|
|
|
*
|
|
|
|
* 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.,
|
2006-01-23 12:37:31 +01:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-12-29 22:55:22 +01:00
|
|
|
*/
|
|
|
|
|
2007-05-30 18:47:36 +02:00
|
|
|
#include "applet.h"
|
|
|
|
|
2007-08-05 16:24:24 +02:00
|
|
|
#include <cmath>
|
|
|
|
#include <limits>
|
|
|
|
|
2007-07-12 20:34:53 +02:00
|
|
|
#include <QApplication>
|
2005-12-29 22:55:22 +01:00
|
|
|
#include <QEvent>
|
2007-07-30 18:00:29 +02:00
|
|
|
#include <QFile>
|
2005-12-29 22:55:22 +01:00
|
|
|
#include <QList>
|
2007-07-12 20:34:53 +02:00
|
|
|
#include <QPainter>
|
2005-12-29 22:55:22 +01:00
|
|
|
#include <QSize>
|
2007-07-26 01:42:43 +02:00
|
|
|
#include <QStyleOptionGraphicsItem>
|
2007-11-04 06:31:18 +01:00
|
|
|
#include <QTextDocument>
|
2007-07-30 18:00:29 +02:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QUiLoader>
|
2008-04-13 15:23:39 +02:00
|
|
|
#include <QLabel>
|
2008-04-14 00:01:18 +02:00
|
|
|
#include <QPushButton>
|
2008-02-21 11:26:40 +01:00
|
|
|
#include <QGraphicsSceneMouseEvent>
|
2008-04-13 15:23:39 +02:00
|
|
|
#include <QGraphicsLinearLayout>
|
2008-04-14 16:50:02 +02:00
|
|
|
#include <QDesktopWidget>
|
2008-04-14 18:02:23 +02:00
|
|
|
#include <QGraphicsView>
|
2008-04-13 15:23:39 +02:00
|
|
|
#include <QGraphicsProxyWidget>
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2007-07-26 01:42:43 +02:00
|
|
|
#include <KIcon>
|
2007-11-04 07:58:20 +01:00
|
|
|
#include <KColorScheme>
|
2007-07-30 18:00:29 +02:00
|
|
|
#include <KConfigDialog>
|
2007-07-12 20:34:53 +02:00
|
|
|
#include <KDialog>
|
2008-04-02 17:37:17 +02:00
|
|
|
#include <KIconLoader>
|
2007-03-05 01:07:21 +01:00
|
|
|
#include <KPluginInfo>
|
2006-12-17 00:04:44 +01:00
|
|
|
#include <KStandardDirs>
|
2007-03-05 01:07:21 +01:00
|
|
|
#include <KService>
|
2007-05-24 22:01:12 +02:00
|
|
|
#include <KServiceTypeTrader>
|
2008-04-02 17:37:17 +02:00
|
|
|
#include <KWindowSystem>
|
2007-06-01 00:40:38 +02:00
|
|
|
|
2007-12-21 13:27:29 +01:00
|
|
|
#include <Solid/PowerManagement>
|
|
|
|
|
2007-07-30 18:00:29 +02:00
|
|
|
#include "plasma/configxml.h"
|
2007-09-18 23:22:45 +02:00
|
|
|
#include "plasma/containment.h"
|
2008-04-25 20:44:09 +02:00
|
|
|
#include "plasma/containment_p.h"
|
2007-06-22 22:28:42 +02:00
|
|
|
#include "plasma/corona.h"
|
|
|
|
#include "plasma/dataenginemanager.h"
|
2007-07-20 05:28:34 +02:00
|
|
|
#include "plasma/package.h"
|
|
|
|
#include "plasma/packages_p.h"
|
2007-06-22 22:28:42 +02:00
|
|
|
#include "plasma/plasma.h"
|
2008-01-25 01:08:25 +01:00
|
|
|
#include "plasma/scripting/appletscript.h"
|
2007-08-05 10:41:55 +02:00
|
|
|
#include "plasma/shadowitem_p.h"
|
2007-06-22 22:28:42 +02:00
|
|
|
#include "plasma/svg.h"
|
2008-04-16 19:23:58 +02:00
|
|
|
#include "plasma/panelsvg.h"
|
2007-11-04 07:58:20 +01:00
|
|
|
#include "plasma/theme.h"
|
2007-11-15 10:39:46 +01:00
|
|
|
#include "plasma/view.h"
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2007-08-05 10:41:55 +02:00
|
|
|
//#define DYNAMIC_SHADOWS
|
2005-12-29 22:55:22 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-04-14 18:02:23 +02:00
|
|
|
class OverlayWidget : public QGraphicsWidget
|
2008-04-01 00:06:35 +02:00
|
|
|
{
|
|
|
|
public:
|
2008-04-14 18:02:23 +02:00
|
|
|
OverlayWidget(QGraphicsWidget *parent)
|
|
|
|
: QGraphicsWidget(parent)
|
2008-04-01 00:06:35 +02:00
|
|
|
{
|
|
|
|
resize(parent->size());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2008-04-14 18:02:23 +02:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
|
2008-04-01 00:06:35 +02:00
|
|
|
{
|
|
|
|
Q_UNUSED(option)
|
|
|
|
Q_UNUSED(widget)
|
|
|
|
painter->save();
|
|
|
|
painter->setRenderHint(QPainter::Antialiasing);
|
2008-04-24 00:36:00 +02:00
|
|
|
QColor wash = Plasma::Theme::defaultTheme()->color(Theme::BackgroundColor);
|
2008-04-01 00:06:35 +02:00
|
|
|
wash.setAlphaF(.6);
|
2008-04-14 18:02:23 +02:00
|
|
|
painter->fillPath(parentItem()->shape(), wash);
|
2008-04-01 00:06:35 +02:00
|
|
|
painter->restore();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
class Applet::Private
|
|
|
|
{
|
2007-07-20 05:28:34 +02:00
|
|
|
public:
|
|
|
|
Private(KService::Ptr service, int uniqueID)
|
|
|
|
: appletId(uniqueID),
|
2007-07-23 01:10:53 +02:00
|
|
|
appletDescription(service),
|
2007-07-20 05:28:34 +02:00
|
|
|
package(0),
|
2008-04-01 00:06:35 +02:00
|
|
|
needsConfigOverlay(0),
|
2007-07-20 05:28:34 +02:00
|
|
|
background(0),
|
2008-01-25 01:08:25 +01:00
|
|
|
script(0),
|
2007-07-30 18:00:29 +02:00
|
|
|
configXml(0),
|
2007-08-05 10:41:55 +02:00
|
|
|
shadow(0),
|
|
|
|
cachedBackground(0),
|
2007-11-27 07:01:06 +01:00
|
|
|
mainConfig(0),
|
2007-10-26 03:04:56 +02:00
|
|
|
pendingConstraints(NoConstraint),
|
2008-01-10 20:02:05 +01:00
|
|
|
aspectRatioMode(Qt::KeepAspectRatio),
|
2008-04-24 20:24:11 +02:00
|
|
|
immutability(NotImmutable),
|
2007-07-20 05:28:34 +02:00
|
|
|
hasConfigurationInterface(false),
|
2007-07-31 02:21:08 +02:00
|
|
|
failed(false),
|
2008-01-25 01:08:25 +01:00
|
|
|
isContainment(false),
|
2008-04-04 15:16:55 +02:00
|
|
|
square(false),
|
2008-04-14 11:42:57 +02:00
|
|
|
transient(false)
|
2007-07-20 05:28:34 +02:00
|
|
|
{
|
|
|
|
if (appletId == 0) {
|
2008-02-13 02:52:02 +01:00
|
|
|
appletId = ++s_maxAppletId;
|
|
|
|
} else if (appletId > s_maxAppletId) {
|
2007-07-20 05:28:34 +02:00
|
|
|
s_maxAppletId = appletId;
|
2007-05-24 22:01:12 +02:00
|
|
|
}
|
2007-07-20 05:28:34 +02:00
|
|
|
}
|
2005-12-29 22:55:22 +01:00
|
|
|
|
2007-07-20 05:28:34 +02:00
|
|
|
~Private()
|
|
|
|
{
|
|
|
|
foreach ( const QString& engine, loadedEngines ) {
|
2008-04-23 22:04:53 +02:00
|
|
|
DataEngineManager::self()->unloadEngine( engine );
|
2007-05-24 22:01:12 +02:00
|
|
|
}
|
2007-07-20 05:28:34 +02:00
|
|
|
delete background;
|
|
|
|
delete package;
|
2007-07-30 18:00:29 +02:00
|
|
|
delete configXml;
|
2007-08-05 10:41:55 +02:00
|
|
|
delete shadow;
|
2007-07-31 02:21:08 +02:00
|
|
|
delete cachedBackground;
|
2007-11-27 07:01:06 +01:00
|
|
|
delete mainConfig;
|
2007-07-20 05:28:34 +02:00
|
|
|
}
|
|
|
|
|
2007-07-20 10:12:20 +02:00
|
|
|
void init(Applet* applet)
|
|
|
|
{
|
2007-11-27 07:01:06 +01:00
|
|
|
// WARNING: do not access config() OR globalConfig() in this method!
|
|
|
|
// that requires a scene, which is not available at this point
|
2007-11-12 20:27:21 +01:00
|
|
|
applet->setAcceptsHoverEvents(true);
|
2008-04-14 23:50:41 +02:00
|
|
|
applet->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
2007-07-26 04:07:18 +02:00
|
|
|
|
2007-07-23 01:10:53 +02:00
|
|
|
if (!appletDescription.isValid()) {
|
2008-02-29 09:11:45 +01:00
|
|
|
applet->setFailedToLaunch(true, i18n("Invalid applet description"));
|
2007-07-23 17:59:10 +02:00
|
|
|
return;
|
2007-07-20 10:12:20 +02:00
|
|
|
}
|
|
|
|
|
2007-07-23 09:42:29 +02:00
|
|
|
QString language = appletDescription.property("X-Plasma-Language").toString();
|
|
|
|
|
|
|
|
// we have a scripted plasmoid
|
|
|
|
if (!language.isEmpty()) {
|
|
|
|
// find where the Package is
|
2008-02-19 09:31:49 +01:00
|
|
|
QString path = KStandardDirs::locate("data",
|
|
|
|
"plasma/plasmoids/" + appletDescription.pluginName() +
|
|
|
|
"/");
|
2007-07-23 09:42:29 +02:00
|
|
|
|
2007-11-29 21:38:13 +01:00
|
|
|
if (path.isEmpty()) {
|
|
|
|
applet->setFailedToLaunch(true, i18n("Could not locate the %1 package required for the %2 widget.",
|
|
|
|
appletDescription.pluginName(), appletDescription.name()));
|
|
|
|
} else {
|
2007-07-23 09:42:29 +02:00
|
|
|
// create the package and see if we have something real
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "trying for" << path;
|
2008-04-04 00:45:09 +02:00
|
|
|
PackageStructure::Ptr structure = Plasma::packageStructure(language, Plasma::AppletComponent);
|
|
|
|
structure->setPath(path);
|
|
|
|
package = new Package(path, structure);
|
2008-02-26 02:48:52 +01:00
|
|
|
|
2007-07-23 09:42:29 +02:00
|
|
|
if (package->isValid()) {
|
|
|
|
// now we try and set up the script engine.
|
|
|
|
// it will be parented to this applet and so will get
|
|
|
|
// deleted when the applet does
|
|
|
|
|
2008-01-25 01:08:25 +01:00
|
|
|
script = Plasma::loadScriptEngine(language, applet);
|
|
|
|
if (!script) {
|
2007-07-23 09:42:29 +02:00
|
|
|
delete package;
|
|
|
|
package = 0;
|
2007-11-29 21:38:13 +01:00
|
|
|
applet->setFailedToLaunch(true, i18n("Could not create a %1 ScriptEngine for the %2 widget.",
|
|
|
|
language, appletDescription.name()));
|
2007-07-23 09:42:29 +02:00
|
|
|
}
|
|
|
|
} else {
|
2007-11-29 21:38:13 +01:00
|
|
|
applet->setFailedToLaunch(true, i18n("Could not open the %1 package required for the %2 widget.",
|
|
|
|
appletDescription.pluginName(), appletDescription.name()));
|
2007-07-23 09:42:29 +02:00
|
|
|
delete package;
|
|
|
|
package = 0;
|
|
|
|
}
|
|
|
|
|
2007-11-29 21:38:13 +01:00
|
|
|
if (package) {
|
2007-07-30 18:00:29 +02:00
|
|
|
setupScriptSupport(applet);
|
2007-07-23 09:42:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-04-17 19:09:13 +02:00
|
|
|
|
2007-11-08 08:53:56 +01:00
|
|
|
applet->setDrawStandardBackground(true);
|
2008-02-12 08:33:07 +01:00
|
|
|
|
2008-04-23 20:35:03 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), applet, SLOT(themeChanged()));
|
2007-07-20 10:12:20 +02:00
|
|
|
}
|
|
|
|
|
2007-07-30 18:00:29 +02:00
|
|
|
// put all setup routines for script here. at this point we can assume that
|
|
|
|
// package exists and that we have a script engin
|
|
|
|
void setupScriptSupport(Applet* applet)
|
|
|
|
{
|
|
|
|
Q_ASSERT(package);
|
|
|
|
QString xmlPath = package->filePath("mainconfigxml");
|
|
|
|
if (!xmlPath.isEmpty()) {
|
|
|
|
QFile file(xmlPath);
|
2007-11-25 00:38:37 +01:00
|
|
|
// FIXME: KConfigSkeleton doesn't play well with KConfigGroup =/
|
2007-11-25 01:14:27 +01:00
|
|
|
KConfigGroup config = applet->config();
|
|
|
|
configXml = new ConfigXml(&config, &file);
|
2007-07-30 18:00:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!package->filePath("mainconfigui").isEmpty()) {
|
|
|
|
applet->setHasConfigurationInterface(true);
|
|
|
|
}
|
|
|
|
}
|
2007-07-30 18:19:07 +02:00
|
|
|
QString instanceName()
|
|
|
|
{
|
|
|
|
if (!appletDescription.isValid()) {
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return appletDescription.service()->library() + QString::number(appletId);
|
|
|
|
}
|
|
|
|
|
2007-08-17 17:05:01 +02:00
|
|
|
void getBorderSize(int& left , int& top, int &right, int& bottom)
|
|
|
|
{
|
2007-11-17 20:03:17 +01:00
|
|
|
if (background) {
|
2008-02-06 20:12:21 +01:00
|
|
|
top = background->marginSize(Plasma::TopMargin);
|
|
|
|
left = background->marginSize(Plasma::LeftMargin);
|
|
|
|
right = background->marginSize(Plasma::RightMargin);
|
|
|
|
bottom = background->marginSize(Plasma::BottomMargin);
|
2007-11-17 20:03:17 +01:00
|
|
|
} else {
|
|
|
|
top = left = right = bottom = 0;
|
2007-08-17 17:05:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-26 03:04:56 +02:00
|
|
|
void scheduleConstraintsUpdate(Plasma::Constraints c, Applet* applet)
|
|
|
|
{
|
|
|
|
if (pendingConstraints == NoConstraint) {
|
|
|
|
QTimer::singleShot(0, applet, SLOT(flushUpdatedConstraints()));
|
|
|
|
}
|
|
|
|
pendingConstraints |= c;
|
|
|
|
}
|
|
|
|
|
2007-11-27 07:01:06 +01:00
|
|
|
KConfigGroup* mainConfigGroup(const Applet* q)
|
2007-11-26 19:26:32 +01:00
|
|
|
{
|
2007-11-27 07:01:06 +01:00
|
|
|
if (mainConfig) {
|
|
|
|
return mainConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isContainment) {
|
|
|
|
const Containment *asContainment = qobject_cast<Containment*>(const_cast<Applet*>(q));
|
|
|
|
Q_ASSERT(asContainment);
|
|
|
|
|
|
|
|
KConfigGroup containmentConfig;
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "got a corona, baby?" << (QObject*)asContainment->corona();
|
2007-11-27 07:01:06 +01:00
|
|
|
if (asContainment->corona()) {
|
|
|
|
containmentConfig = KConfigGroup(asContainment->corona()->config(), "Containments");
|
|
|
|
} else {
|
|
|
|
containmentConfig = KConfigGroup(KGlobal::config(), "Containments");
|
|
|
|
}
|
2007-11-26 19:26:32 +01:00
|
|
|
|
2007-11-27 07:01:06 +01:00
|
|
|
mainConfig = new KConfigGroup(&containmentConfig, QString::number(appletId));
|
2007-11-26 19:26:32 +01:00
|
|
|
} else {
|
2007-11-27 07:01:06 +01:00
|
|
|
KConfigGroup appletConfig;
|
|
|
|
if (q->containment()) {
|
|
|
|
appletConfig = q->containment()->config();
|
|
|
|
appletConfig = KConfigGroup(&appletConfig, "Applets");
|
|
|
|
} else {
|
|
|
|
kWarning() << "requesting config for" << q->name() << "without a containment!";
|
|
|
|
appletConfig = KConfigGroup(KGlobal::config(), "Applets");
|
|
|
|
}
|
|
|
|
|
|
|
|
mainConfig = new KConfigGroup(&appletConfig, QString::number(appletId));
|
2007-11-26 19:26:32 +01:00
|
|
|
}
|
|
|
|
|
2007-11-27 07:01:06 +01:00
|
|
|
return mainConfig;
|
2007-11-26 19:26:32 +01:00
|
|
|
}
|
|
|
|
|
2008-01-02 03:05:47 +01:00
|
|
|
void copyEntries(KConfigGroup *source, KConfigGroup *destination)
|
|
|
|
{
|
|
|
|
foreach (const QString &group, source->groupList()) {
|
|
|
|
KConfigGroup subSource(source, group);
|
|
|
|
KConfigGroup subDest(destination, group);
|
|
|
|
copyEntries(&subSource, &subDest);
|
|
|
|
}
|
|
|
|
|
|
|
|
QMap<QString, QString> entries = source->entryMap();
|
|
|
|
QMapIterator<QString, QString> it(entries);
|
|
|
|
while (it.hasNext()) {
|
|
|
|
it.next();
|
|
|
|
destination->writeEntry(it.key(), it.value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-18 18:05:20 +02:00
|
|
|
QString visibleFailureText(const QString& reason)
|
|
|
|
{
|
|
|
|
QString text;
|
|
|
|
|
|
|
|
if (reason.isEmpty()) {
|
|
|
|
text = i18n("This object could not be created.");
|
|
|
|
} else {
|
|
|
|
text = i18n("This object could not be created for the following reason:<p><b>%1</b></p>", reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2007-07-20 05:28:34 +02:00
|
|
|
//TODO: examine the usage of memory here; there's a pretty large
|
|
|
|
// number of members at this point.
|
2008-02-13 02:52:02 +01:00
|
|
|
static uint s_maxAppletId;
|
|
|
|
static uint s_maxZValue;
|
2008-04-23 22:27:44 +02:00
|
|
|
static uint s_minZValue;
|
2008-02-26 05:08:51 +01:00
|
|
|
static PackageStructure::Ptr packageStructure;
|
2007-07-20 05:28:34 +02:00
|
|
|
uint appletId;
|
2007-07-23 01:10:53 +02:00
|
|
|
KPluginInfo appletDescription;
|
2007-07-20 05:28:34 +02:00
|
|
|
Package* package;
|
2008-04-01 00:06:35 +02:00
|
|
|
OverlayWidget *needsConfigOverlay;
|
2007-07-20 05:28:34 +02:00
|
|
|
QList<QObject*> watchedForFocus;
|
2008-02-21 11:26:40 +01:00
|
|
|
QList<QGraphicsItem*> watchedForMouseMove;
|
2007-07-20 05:28:34 +02:00
|
|
|
QStringList loadedEngines;
|
2008-04-16 19:23:58 +02:00
|
|
|
Plasma::PanelSvg *background;
|
2008-04-14 00:01:18 +02:00
|
|
|
//Plasma::LineEdit *failureText;
|
2008-01-25 01:08:25 +01:00
|
|
|
AppletScript *script;
|
2007-07-30 18:00:29 +02:00
|
|
|
ConfigXml* configXml;
|
2007-08-05 10:41:55 +02:00
|
|
|
ShadowItem* shadow;
|
2007-08-03 17:23:56 +02:00
|
|
|
QPixmap* cachedBackground;
|
2007-11-27 07:01:06 +01:00
|
|
|
KConfigGroup *mainConfig;
|
2007-10-26 03:04:56 +02:00
|
|
|
Plasma::Constraints pendingConstraints;
|
2008-01-10 20:02:05 +01:00
|
|
|
Qt::AspectRatioMode aspectRatioMode;
|
2008-04-24 20:24:11 +02:00
|
|
|
ImmutabilityType immutability;
|
2007-07-20 05:28:34 +02:00
|
|
|
bool hasConfigurationInterface : 1;
|
|
|
|
bool failed : 1;
|
2007-11-15 10:39:46 +01:00
|
|
|
bool isContainment : 1;
|
2008-01-25 01:08:25 +01:00
|
|
|
bool square : 1;
|
2008-04-14 11:42:57 +02:00
|
|
|
bool transient : 1;
|
2005-12-29 22:55:22 +01:00
|
|
|
};
|
|
|
|
|
2007-05-24 22:01:12 +02:00
|
|
|
uint Applet::Private::s_maxAppletId = 0;
|
2008-02-13 02:52:02 +01:00
|
|
|
uint Applet::Private::s_maxZValue = 0;
|
2008-04-23 22:27:44 +02:00
|
|
|
uint Applet::Private::s_minZValue = 0;
|
2008-02-26 05:08:51 +01:00
|
|
|
PackageStructure::Ptr Applet::Private::packageStructure(0);
|
2007-05-24 22:01:12 +02:00
|
|
|
|
|
|
|
Applet::Applet(QGraphicsItem *parent,
|
|
|
|
const QString& serviceID,
|
2007-07-12 20:34:53 +02:00
|
|
|
uint appletId)
|
2008-04-14 18:02:23 +02:00
|
|
|
: QGraphicsWidget(parent),
|
2007-08-03 18:00:10 +02:00
|
|
|
d(new Private(KService::serviceByStorageId(serviceID), appletId))
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2007-11-27 07:01:06 +01:00
|
|
|
// WARNING: do not access config() OR globalConfig() in this method!
|
|
|
|
// that requires a scene, which is not available at this point
|
2007-07-20 10:12:20 +02:00
|
|
|
d->init(this);
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2007-08-29 04:33:22 +02:00
|
|
|
Applet::Applet(QObject* parentObject, const QVariantList& args)
|
2008-04-14 18:02:23 +02:00
|
|
|
: QGraphicsWidget(0),
|
2007-08-29 04:33:22 +02:00
|
|
|
d(new Private(KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()),
|
2007-08-03 18:00:10 +02:00
|
|
|
args.count() > 1 ? args[1].toInt() : 0))
|
2007-05-24 22:01:12 +02:00
|
|
|
{
|
2008-04-24 18:29:23 +02:00
|
|
|
setParent(parentObject);
|
2007-11-27 07:01:06 +01:00
|
|
|
// WARNING: do not access config() OR globalConfig() in this method!
|
|
|
|
// that requires a scene, which is not available at this point
|
2007-07-20 10:12:20 +02:00
|
|
|
d->init(this);
|
2008-04-24 18:29:23 +02:00
|
|
|
|
2007-09-28 07:46:37 +02:00
|
|
|
// the brain damage seen in the initialization list is due to the
|
2007-06-20 08:45:08 +02:00
|
|
|
// inflexibility of KService::createInstance
|
2007-05-24 22:01:12 +02:00
|
|
|
}
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
Applet::~Applet()
|
|
|
|
{
|
2007-11-25 00:38:37 +01:00
|
|
|
needsFocus(false);
|
2008-04-14 11:42:57 +02:00
|
|
|
|
|
|
|
if (d->transient) {
|
|
|
|
resetConfigurationObject();
|
|
|
|
}
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
2008-02-26 05:08:51 +01:00
|
|
|
PackageStructure::Ptr Applet::packageStructure()
|
2008-02-15 11:35:00 +01:00
|
|
|
{
|
2008-02-26 05:08:51 +01:00
|
|
|
if (!Private::packageStructure) {
|
|
|
|
Private::packageStructure = new PlasmoidPackage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return Private::packageStructure;
|
2008-02-15 11:35:00 +01:00
|
|
|
}
|
|
|
|
|
2007-09-13 19:00:57 +02:00
|
|
|
void Applet::init()
|
|
|
|
{
|
2008-01-25 01:08:25 +01:00
|
|
|
if (d->script && !d->script->init()) {
|
2008-02-29 09:11:45 +01:00
|
|
|
setFailedToLaunch(true, i18n("Script initialization failed"));
|
2008-01-25 01:08:25 +01:00
|
|
|
}
|
2008-04-14 12:48:32 +02:00
|
|
|
//Here is the code for the window frame
|
|
|
|
//setWindowFlags(Qt::Window);
|
2007-09-13 19:00:57 +02:00
|
|
|
}
|
|
|
|
|
2007-08-05 15:01:09 +02:00
|
|
|
uint Applet::id() const
|
|
|
|
{
|
|
|
|
return d->appletId;
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:22:45 +02:00
|
|
|
void Applet::save(KConfigGroup* group) const
|
|
|
|
{
|
2007-12-07 06:02:54 +01:00
|
|
|
// we call the dptr member directly for locked since isImmutable()
|
|
|
|
// also checks kiosk and parent containers
|
2008-04-24 20:24:11 +02:00
|
|
|
group->writeEntry("immutability", (int)d->immutability);
|
2007-09-18 23:22:45 +02:00
|
|
|
group->writeEntry("plugin", pluginName());
|
2007-10-26 03:04:56 +02:00
|
|
|
//FIXME: for containments, we need to have some special values here w/regards to
|
|
|
|
// screen affinity (e.g. "bottom of screen 0")
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << pluginName() << "geometry is" << geometry() << "pos is" << pos() << "bounding rect is" << boundingRect();
|
2007-10-29 05:39:23 +01:00
|
|
|
group->writeEntry("geometry", geometry());
|
2008-02-13 02:52:02 +01:00
|
|
|
group->writeEntry("zvalue", zValue());
|
2007-09-18 23:22:45 +02:00
|
|
|
|
2007-11-19 10:21:11 +01:00
|
|
|
if (transform() == QTransform()) {
|
|
|
|
group->deleteEntry("transform");
|
|
|
|
} else {
|
|
|
|
QList<qreal> m;
|
|
|
|
QTransform t = transform();
|
|
|
|
m << t.m11() << t.m12() << t.m13() << t.m21() << t.m22() << t.m23() << t.m31() << t.m32() << t.m33();
|
|
|
|
group->writeEntry("transform", m);
|
|
|
|
//group->writeEntry("transform", transformToString(transform()));
|
|
|
|
}
|
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
KConfigGroup appletConfigGroup(group, "Configuration");
|
2008-01-02 03:05:47 +01:00
|
|
|
//FIXME: we need a global save state too
|
2007-11-25 00:38:37 +01:00
|
|
|
saveState(&appletConfigGroup);
|
2007-09-18 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
2008-02-13 02:52:02 +01:00
|
|
|
void Applet::restore(KConfigGroup *c)
|
|
|
|
{
|
|
|
|
QList<qreal> m = c->readEntry("transform", QList<qreal>());
|
|
|
|
if (m.count() == 9) {
|
|
|
|
QTransform t(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8]);
|
|
|
|
setTransform(t);
|
|
|
|
}
|
|
|
|
|
2008-04-23 22:27:44 +02:00
|
|
|
qreal z = c->readEntry("zvalue", 0);
|
2008-02-13 02:52:02 +01:00
|
|
|
|
2008-04-23 22:27:44 +02:00
|
|
|
if (z >= Private::s_maxZValue) {
|
2008-02-13 02:52:02 +01:00
|
|
|
Private::s_maxZValue = z;
|
|
|
|
}
|
|
|
|
|
|
|
|
setZValue(z);
|
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
setImmutability((ImmutabilityType)c->readEntry("immutability", (int)NotImmutable));
|
2008-02-13 02:52:02 +01:00
|
|
|
}
|
|
|
|
|
2008-04-18 18:05:20 +02:00
|
|
|
void Applet::setFailedToLaunch(bool failed, const QString& reason)
|
|
|
|
{
|
|
|
|
if (d->failed == failed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
d->failed = failed;
|
|
|
|
prepareGeometryChange();
|
|
|
|
|
|
|
|
qDeleteAll(QGraphicsItem::children());
|
|
|
|
setLayout(0);
|
|
|
|
|
|
|
|
if (failed) {
|
|
|
|
setDrawStandardBackground(true);
|
|
|
|
|
|
|
|
#ifdef TOPORT
|
|
|
|
Layout* failureLayout = new BoxLayout(BoxLayout::TopToBottom, this);
|
|
|
|
d->failureText = new LineEdit(this);
|
|
|
|
d->failureText->setTextInteractionFlags( Qt::TextSelectableByMouse );
|
|
|
|
d->failureText->setStyled(false);
|
|
|
|
d->failureText->document()->setTextWidth(200);
|
|
|
|
d->failureText->setHtml(visibleFailureText(reason));
|
|
|
|
//FIXME: this needs to get the colour from the theme's colour scheme
|
|
|
|
d->failureText->setDefaultTextColor(KStatefulBrush(KColorScheme::Window,
|
|
|
|
KColorScheme::NormalText,
|
2008-04-22 23:10:14 +02:00
|
|
|
Theme::defaultTheme()->colors())
|
2008-04-18 18:05:20 +02:00
|
|
|
.brush(QPalette::Normal).color());
|
|
|
|
failureLayout->addItem(d->failureText);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
QGraphicsLinearLayout *failureLayout = new QGraphicsLinearLayout();
|
|
|
|
failureLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
QGraphicsProxyWidget * failureWidget = new QGraphicsProxyWidget(this);
|
|
|
|
QLabel * label = new QLabel(d->visibleFailureText(reason));
|
|
|
|
label->setWordWrap(true);
|
|
|
|
failureWidget->setWidget(label);
|
|
|
|
failureLayout->addItem(failureWidget);
|
|
|
|
setLayout(failureLayout);
|
|
|
|
}
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:22:45 +02:00
|
|
|
void Applet::saveState(KConfigGroup* group) const
|
|
|
|
{
|
2008-01-02 03:05:47 +01:00
|
|
|
if (group->config()->name() != config().config()->name()) {
|
|
|
|
// we're being saved to a different file!
|
|
|
|
// let's just copy the current values in our configuration over
|
|
|
|
KConfigGroup c = config();
|
|
|
|
d->copyEntries(&c, group);
|
|
|
|
}
|
2007-09-18 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
KConfigGroup Applet::config(const QString &group) const
|
2007-07-12 21:14:23 +02:00
|
|
|
{
|
|
|
|
KConfigGroup cg = config();
|
2007-11-25 00:38:37 +01:00
|
|
|
return KConfigGroup(&cg, group);
|
|
|
|
}
|
|
|
|
|
|
|
|
KConfigGroup Applet::config() const
|
|
|
|
{
|
|
|
|
if (d->isContainment) {
|
2007-11-27 07:01:06 +01:00
|
|
|
return *(d->mainConfigGroup(this));
|
2007-11-25 00:38:37 +01:00
|
|
|
}
|
|
|
|
|
2007-11-27 07:01:06 +01:00
|
|
|
return KConfigGroup(d->mainConfigGroup(this), "Configuration");
|
2007-07-12 21:14:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
KConfigGroup Applet::globalConfig() const
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2007-11-25 00:38:37 +01:00
|
|
|
KConfigGroup globalAppletConfig;
|
2008-01-11 19:21:53 +01:00
|
|
|
const Containment *c = isContainment() ? dynamic_cast<const Containment*>(this) : containment();
|
|
|
|
QString group = isContainment() ? "ContainmentGlobals" : "AppletGlobals";
|
|
|
|
|
|
|
|
if (c && c->corona()) {
|
|
|
|
KSharedConfig::Ptr coronaConfig = c->corona()->config();
|
|
|
|
globalAppletConfig = KConfigGroup(coronaConfig, group);
|
2007-11-25 00:38:37 +01:00
|
|
|
} else {
|
2008-01-11 19:21:53 +01:00
|
|
|
globalAppletConfig = KConfigGroup(KGlobal::config(), group);
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
return KConfigGroup(&globalAppletConfig, globalName());
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2007-08-05 11:39:32 +02:00
|
|
|
void Applet::destroy()
|
|
|
|
{
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "???????????????? DESTROYING APPLET" << name() << " ???????????????????????????";
|
2007-08-05 11:39:32 +02:00
|
|
|
if (d->configXml) {
|
|
|
|
d->configXml->setDefaults();
|
|
|
|
}
|
|
|
|
|
2008-04-14 11:42:57 +02:00
|
|
|
d->transient = true;
|
2007-08-05 11:39:32 +02:00
|
|
|
deleteLater();
|
|
|
|
}
|
|
|
|
|
2007-11-27 07:01:06 +01:00
|
|
|
void Applet::resetConfigurationObject()
|
|
|
|
{
|
|
|
|
d->mainConfigGroup(this)->deleteGroup();
|
|
|
|
delete d->mainConfig;
|
|
|
|
d->mainConfig = 0;
|
|
|
|
}
|
|
|
|
|
2007-08-05 11:39:32 +02:00
|
|
|
ConfigXml* Applet::configXml() const
|
2007-07-30 18:19:07 +02:00
|
|
|
{
|
|
|
|
return d->configXml;
|
|
|
|
}
|
|
|
|
|
2007-07-20 05:34:20 +02:00
|
|
|
DataEngine* Applet::dataEngine(const QString& name) const
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2007-06-02 19:29:39 +02:00
|
|
|
int index = d->loadedEngines.indexOf(name);
|
|
|
|
if (index != -1) {
|
2008-04-23 21:05:47 +02:00
|
|
|
return DataEngineManager::self()->engine(name);
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 22:04:53 +02:00
|
|
|
DataEngine* engine = DataEngineManager::self()->loadEngine(name);
|
2007-07-11 03:24:43 +02:00
|
|
|
if (engine->isValid()) {
|
2007-06-02 19:29:39 +02:00
|
|
|
d->loadedEngines.append(name);
|
2006-04-13 02:11:16 +02:00
|
|
|
}
|
|
|
|
|
2007-07-11 03:24:43 +02:00
|
|
|
return engine;
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2007-07-20 05:34:20 +02:00
|
|
|
const Package* Applet::package() const
|
|
|
|
{
|
|
|
|
return d->package;
|
|
|
|
}
|
|
|
|
|
2008-04-14 16:50:02 +02:00
|
|
|
QGraphicsView *Applet::view() const
|
|
|
|
{
|
|
|
|
// It's assumed that we won't be visible on more than one view here.
|
|
|
|
// Anything that actually needs view() should only really care about
|
|
|
|
// one of them anyway though.
|
|
|
|
if (!scene()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (QGraphicsView *view, scene()->views()) {
|
|
|
|
if (view->sceneRect().intersects(sceneBoundingRect()) ||
|
|
|
|
view->sceneRect().contains(scenePos())) {
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRectF Applet::mapFromView(const QGraphicsView *view, const QRect &rect) const
|
|
|
|
{
|
|
|
|
// TODO: Confirm that adjusted() is needed and is not covering for some
|
|
|
|
// issue elsewhere
|
|
|
|
return mapFromScene(view->mapToScene(rect)).boundingRect().adjusted(0, 0, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect Applet::mapToView(const QGraphicsView *view, const QRectF &rect) const
|
|
|
|
{
|
|
|
|
// TODO: Confirm that adjusted() is needed and is not covering for some
|
|
|
|
// issue elsewhere
|
|
|
|
return view->mapFromScene(mapToScene(rect)).boundingRect().adjusted(0, 0, -1, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint Applet::popupPosition(const QSize &s) const
|
|
|
|
{
|
|
|
|
QGraphicsView *v = view();
|
|
|
|
Q_ASSERT(v);
|
|
|
|
|
|
|
|
QPoint pos = v->mapFromScene(scenePos());
|
|
|
|
pos = v->mapToGlobal(pos);
|
|
|
|
kDebug() << "==> position is" << scenePos() << v->mapFromScene(scenePos()) << pos;
|
|
|
|
Plasma::View *pv = dynamic_cast<Plasma::View *>(v);
|
|
|
|
|
|
|
|
Plasma::Location loc = Floating;
|
|
|
|
if (pv) {
|
|
|
|
loc = pv->containment()->location();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (loc) {
|
|
|
|
case BottomEdge:
|
|
|
|
pos = QPoint(pos.x(), pos.y() - s.height());
|
|
|
|
break;
|
|
|
|
case TopEdge:
|
|
|
|
pos = QPoint(pos.x(), pos.y() + (int)size().height());
|
|
|
|
break;
|
|
|
|
case LeftEdge:
|
|
|
|
pos = QPoint(pos.x() + (int)size().width(), pos.y());
|
|
|
|
break;
|
|
|
|
case RightEdge:
|
|
|
|
pos = QPoint(pos.x() - s.width(), pos.y());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (pos.y() - s.height() > 0) {
|
|
|
|
pos = QPoint(pos.x(), pos.y() - s.height());
|
|
|
|
} else {
|
|
|
|
pos = QPoint(pos.x(), pos.y() + (int)size().height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//are we out of screen?
|
|
|
|
|
|
|
|
QRect screenRect = QApplication::desktop()->screenGeometry(pv ? pv->containment()->screen() : -1);
|
|
|
|
kDebug() << "==> rect for" << (pv ? pv->containment()->screen() : -1) << "is" << screenRect;
|
|
|
|
|
|
|
|
if (pos.rx() + s.width() > screenRect.right()) {
|
|
|
|
pos.rx() -= ((pos.rx() + s.width()) - screenRect.right());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pos.ry() + s.height() > screenRect.bottom()) {
|
|
|
|
pos.ry() -= ((pos.ry() + s.height()) - screenRect.bottom());
|
|
|
|
}
|
|
|
|
pos.rx() = qMax(0, pos.rx());
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2007-10-02 01:24:38 +02:00
|
|
|
void Applet::updateConstraints(Plasma::Constraints constraints)
|
2007-08-05 10:41:55 +02:00
|
|
|
{
|
2007-10-26 03:04:56 +02:00
|
|
|
d->scheduleConstraintsUpdate(constraints, this);
|
2007-08-05 10:41:55 +02:00
|
|
|
}
|
|
|
|
|
2007-10-02 01:24:38 +02:00
|
|
|
void Applet::constraintsUpdated(Plasma::Constraints constraints)
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2008-02-04 21:09:45 +01:00
|
|
|
//NOTE: do NOT put any code in here that reacts to constraints updates
|
|
|
|
// as it will not get called for any applet that reimplements constraintsUpdated
|
|
|
|
// without calling the Applet:: version as well, which it shouldn't need to.
|
|
|
|
// INSTEAD put such code into flushUpdatedConstraints
|
2007-11-03 03:52:45 +01:00
|
|
|
Q_UNUSED(constraints)
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << constraints << "constraints are FormFactor: " << formFactor() << ", Location: " << location();
|
2008-03-02 22:36:59 +01:00
|
|
|
if (d->script) {
|
|
|
|
d->script->constraintsUpdated(constraints);
|
|
|
|
}
|
2007-06-01 00:40:38 +02:00
|
|
|
}
|
|
|
|
|
2007-06-21 20:24:05 +02:00
|
|
|
QString Applet::name() const
|
2007-06-05 21:31:48 +02:00
|
|
|
{
|
2007-07-23 01:10:53 +02:00
|
|
|
if (!d->appletDescription.isValid()) {
|
2007-07-18 00:26:18 +02:00
|
|
|
return i18n("Unknown Applet");
|
|
|
|
}
|
|
|
|
|
2007-07-23 01:10:53 +02:00
|
|
|
return d->appletDescription.name();
|
2007-06-05 21:31:48 +02:00
|
|
|
}
|
|
|
|
|
2008-04-14 17:15:26 +02:00
|
|
|
QFont Applet::font() const
|
|
|
|
{
|
|
|
|
return QApplication::font();
|
|
|
|
}
|
|
|
|
|
2007-07-23 08:12:38 +02:00
|
|
|
QString Applet::icon() const
|
|
|
|
{
|
|
|
|
if (!d->appletDescription.isValid()) {
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return d->appletDescription.icon();
|
|
|
|
}
|
|
|
|
|
2007-08-05 15:01:09 +02:00
|
|
|
QString Applet::pluginName() const
|
|
|
|
{
|
|
|
|
if (!d->appletDescription.isValid()) {
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return d->appletDescription.pluginName();
|
|
|
|
}
|
|
|
|
|
2007-12-21 13:27:29 +01:00
|
|
|
bool Applet::shouldConserveResources() const
|
|
|
|
{
|
|
|
|
return Solid::PowerManagement::appShouldConserveResources();
|
|
|
|
}
|
|
|
|
|
2007-07-12 15:24:35 +02:00
|
|
|
QString Applet::category() const
|
|
|
|
{
|
2007-07-23 01:10:53 +02:00
|
|
|
if (!d->appletDescription.isValid()) {
|
2007-08-05 15:01:09 +02:00
|
|
|
return i18n("Miscellaneous");
|
2007-07-18 00:26:18 +02:00
|
|
|
}
|
|
|
|
|
2007-08-05 15:01:09 +02:00
|
|
|
return d->appletDescription.category();
|
2007-07-12 15:24:35 +02:00
|
|
|
}
|
|
|
|
|
2007-07-23 01:10:53 +02:00
|
|
|
QString Applet::category(const KPluginInfo& applet)
|
2007-07-12 15:24:35 +02:00
|
|
|
{
|
2007-07-23 01:10:53 +02:00
|
|
|
return applet.property("X-KDE-PluginInfo-Category").toString();
|
2007-07-12 15:24:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Applet::category(const QString& appletName)
|
|
|
|
{
|
|
|
|
if (appletName.isEmpty()) {
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
|
|
|
|
|
|
|
if (offers.isEmpty()) {
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2007-07-17 23:30:27 +02:00
|
|
|
return offers.first()->property("X-KDE-PluginInfo-Category").toString();
|
2007-07-12 15:24:35 +02:00
|
|
|
}
|
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
ImmutabilityType Applet::immutability() const
|
2007-06-21 20:24:05 +02:00
|
|
|
{
|
2008-04-24 20:24:11 +02:00
|
|
|
//Returning the more strict immutability between the applet immutability and Corona one
|
|
|
|
ImmutabilityType coronaImmutability = NotImmutable;
|
2007-12-04 05:15:21 +01:00
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
if (dynamic_cast<Corona*>(scene())) {
|
|
|
|
coronaImmutability = static_cast<Corona*>(scene())->immutability();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (coronaImmutability == SystemImmutable) {
|
|
|
|
return SystemImmutable;
|
|
|
|
} else if (coronaImmutability == UserImmutable && d->immutability != SystemImmutable) {
|
|
|
|
return UserImmutable;
|
|
|
|
} else {
|
|
|
|
return d->immutability;
|
|
|
|
}
|
2007-06-21 20:24:05 +02:00
|
|
|
}
|
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
void Applet::setImmutability(const ImmutabilityType immutable)
|
2007-06-21 20:24:05 +02:00
|
|
|
{
|
2008-04-24 20:24:11 +02:00
|
|
|
if (d->immutability == immutable) {
|
2007-12-05 21:24:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
d->immutability = immutable;
|
2007-12-05 21:24:40 +01:00
|
|
|
updateConstraints(ImmutableConstraint);
|
2007-06-21 20:24:05 +02:00
|
|
|
}
|
|
|
|
|
2008-01-18 01:09:33 +01:00
|
|
|
bool Applet::drawStandardBackground() const
|
2007-06-22 22:28:42 +02:00
|
|
|
{
|
|
|
|
return d->background != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::setDrawStandardBackground(bool drawBackground)
|
|
|
|
{
|
|
|
|
if (drawBackground) {
|
|
|
|
if (!d->background) {
|
2008-04-23 15:07:41 +02:00
|
|
|
d->background = new Plasma::PanelSvg();
|
|
|
|
d->background->setImagePath("widgets/background");
|
2008-04-16 22:17:36 +02:00
|
|
|
d->background->setEnabledBorders(Plasma::PanelSvg::AllBorders);
|
2008-02-13 02:52:02 +01:00
|
|
|
int left, top, right, bottom;
|
|
|
|
d->getBorderSize(left, top, right, bottom);
|
2008-04-17 19:09:13 +02:00
|
|
|
setContentsMargins(left, right, top, bottom);
|
2008-04-17 19:49:33 +02:00
|
|
|
|
|
|
|
QSizeF fitSize(left + right, top + bottom);
|
|
|
|
if (minimumSize().expandedTo(fitSize) != minimumSize()) {
|
|
|
|
setMinimumSize(minimumSize().expandedTo(fitSize));
|
|
|
|
}
|
2008-04-23 22:42:10 +02:00
|
|
|
d->background->resizePanel(boundingRect().size());
|
2007-06-22 22:28:42 +02:00
|
|
|
}
|
2007-07-30 18:00:29 +02:00
|
|
|
} else if (d->background) {
|
2008-04-17 19:49:33 +02:00
|
|
|
int left, top, right, bottom;
|
|
|
|
d->getBorderSize(left, top, right, bottom);
|
|
|
|
//Setting a minimum size of 0,0 would result in the panel to be only
|
|
|
|
//on the first virtual desktop
|
|
|
|
setMinimumSize(qMax(minimumSize().width() - left - right, 1.0),
|
|
|
|
qMax(minimumSize().height() - top - bottom, 1.0));
|
|
|
|
|
2007-06-22 22:28:42 +02:00
|
|
|
delete d->background;
|
|
|
|
d->background = 0;
|
2008-04-13 15:23:39 +02:00
|
|
|
setContentsMargins(0, 0, 0, 0);
|
2007-06-22 22:28:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:15:38 +02:00
|
|
|
bool Applet::hasFailedToLaunch() const
|
2007-07-12 20:34:53 +02:00
|
|
|
{
|
|
|
|
return d->failed;
|
|
|
|
}
|
|
|
|
|
2008-04-13 15:23:39 +02:00
|
|
|
void Applet::paintWindowFrame ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
|
|
|
|
{
|
2008-04-14 12:48:32 +02:00
|
|
|
//Here come the code for the window frame
|
|
|
|
//kDebug()<<"ENTER in windowFrame";
|
|
|
|
//painter->drawRoundedRect(windowFrameGeometry(),5,5);
|
2008-04-13 15:23:39 +02:00
|
|
|
}
|
|
|
|
|
2007-08-03 17:23:56 +02:00
|
|
|
bool Applet::needsConfiguring() const
|
|
|
|
{
|
2008-04-01 00:06:35 +02:00
|
|
|
return d->needsConfigOverlay != 0;
|
2007-08-03 17:23:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::setNeedsConfiguring(bool needsConfig)
|
|
|
|
{
|
2008-04-01 00:06:35 +02:00
|
|
|
if ((d->needsConfigOverlay != 0) == needsConfig) {
|
2007-08-03 17:23:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-01 00:06:35 +02:00
|
|
|
if (d->needsConfigOverlay) {
|
|
|
|
delete d->needsConfigOverlay;
|
|
|
|
d->needsConfigOverlay = 0;
|
|
|
|
return;
|
2007-08-03 17:23:56 +02:00
|
|
|
}
|
|
|
|
|
2008-04-01 00:06:35 +02:00
|
|
|
d->needsConfigOverlay = new OverlayWidget(this);
|
2008-04-13 15:23:39 +02:00
|
|
|
d->needsConfigOverlay->resize(boundingRect().size());
|
2008-04-01 00:06:35 +02:00
|
|
|
|
2008-04-01 02:20:28 +02:00
|
|
|
int zValue = 100;
|
|
|
|
foreach (QGraphicsItem *child, QGraphicsItem::children()) {
|
|
|
|
if (child->zValue() > zValue) {
|
|
|
|
zValue = child->zValue() + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->needsConfigOverlay->setZValue(zValue);
|
|
|
|
|
2008-04-01 00:06:35 +02:00
|
|
|
qDeleteAll(d->needsConfigOverlay->QGraphicsItem::children());
|
2008-04-14 00:01:18 +02:00
|
|
|
QPushButton* button = new QPushButton();
|
2008-04-01 00:06:35 +02:00
|
|
|
button->setText(i18n("Configure..."));
|
|
|
|
connect(button, SIGNAL(clicked()), this, SLOT(showConfigurationInterface()));
|
2008-04-14 00:01:18 +02:00
|
|
|
QGraphicsLinearLayout *configLayout = new QGraphicsLinearLayout(this);
|
|
|
|
configLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
QGraphicsProxyWidget * configWidget = new QGraphicsProxyWidget(this);
|
|
|
|
configWidget->setWidget(button);
|
|
|
|
configLayout->addItem(configWidget);
|
|
|
|
setLayout(configLayout);
|
2008-04-01 00:06:35 +02:00
|
|
|
d->needsConfigOverlay->show();
|
2007-08-03 17:23:56 +02:00
|
|
|
}
|
|
|
|
|
2007-11-27 07:01:06 +01:00
|
|
|
void Applet::checkImmutability()
|
|
|
|
{
|
2008-04-24 20:24:11 +02:00
|
|
|
const bool systemImmutable = globalConfig().isImmutable() || config().isImmutable() ||
|
|
|
|
(containment() && containment()->immutability() == SystemImmutable) ||
|
|
|
|
(dynamic_cast<Corona*>(scene()) && static_cast<Corona*>(scene())->immutability() == SystemImmutable);
|
2008-01-07 05:00:39 +01:00
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
if (systemImmutable) {
|
2008-01-07 05:00:39 +01:00
|
|
|
updateConstraints(ImmutableConstraint);
|
|
|
|
}
|
2007-11-27 07:01:06 +01:00
|
|
|
}
|
|
|
|
|
2007-10-26 03:04:56 +02:00
|
|
|
void Applet::flushUpdatedConstraints()
|
|
|
|
{
|
|
|
|
if (d->pendingConstraints == NoConstraint) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "fushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
2007-10-26 03:04:56 +02:00
|
|
|
Plasma::Constraints c = d->pendingConstraints;
|
|
|
|
d->pendingConstraints = NoConstraint;
|
|
|
|
|
2008-04-01 00:06:35 +02:00
|
|
|
if (c & Plasma::SizeConstraint && d->needsConfigOverlay) {
|
2008-04-13 15:23:39 +02:00
|
|
|
d->needsConfigOverlay->setGeometry(QRectF(QPointF(0, 0), boundingRect().size()));
|
2008-04-01 00:06:35 +02:00
|
|
|
// FIXME:: rather horrible hack to work around the fact we don't have spacers
|
|
|
|
// for layouts, and with WoC coming i'd rather not expend effort there
|
|
|
|
QGraphicsItem * button = d->needsConfigOverlay->QGraphicsItem::children().first();
|
|
|
|
if (button) {
|
|
|
|
QSizeF s = button->boundingRect().size();
|
|
|
|
button->setPos(d->needsConfigOverlay->boundingRect().width() / 2 - s.width() / 2,
|
|
|
|
d->needsConfigOverlay->boundingRect().height() / 2 - s.height() / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-07 20:20:33 +01:00
|
|
|
if (c & Plasma::FormFactorConstraint) {
|
|
|
|
FormFactor f = formFactor();
|
|
|
|
setShadowShown(f == Planar);
|
2008-02-13 02:52:02 +01:00
|
|
|
setDrawStandardBackground(!isContainment() && f != Vertical && f != Horizontal);
|
2008-02-04 21:09:45 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
FIXME: what follows was an attempt to constrain the size of applets. it is, however,
|
|
|
|
broken for the following reasons:
|
|
|
|
|
|
|
|
* it constrains to the size of an icon, when clearly this is not valid for
|
|
|
|
any non-single-icon applet
|
|
|
|
* it is far too pessimistic for horizontal constraints
|
|
|
|
|
|
|
|
QSizeF newMax;
|
|
|
|
const QSizeF infSize(std::numeric_limits<qreal>::infinity(),
|
|
|
|
std::numeric_limits<qreal>::infinity());
|
|
|
|
if (f == Plasma::Vertical && !(expandingDirections() & Qt::Vertical)) {
|
|
|
|
newMax = QSizeF(maximumContentSize().width(), IconSize(KIconLoader::Panel));
|
|
|
|
} else if (f == Plasma::Horizontal && !(expandingDirections() & Qt::Horizontal)) {
|
|
|
|
newMax = QSizeF(IconSize(KIconLoader::Panel), maximumContentSize().height());
|
|
|
|
} else if (maximumContentSize() != infSize) {
|
|
|
|
newMax = infSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newMax.isValid()) {
|
|
|
|
setMaximumContentSize(newMax);
|
|
|
|
if (newMax.width() < contentSize().width() ||
|
|
|
|
newMax.height() < contentSize().height()) {
|
|
|
|
updateGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2007-11-19 02:21:41 +01:00
|
|
|
}
|
|
|
|
|
2008-02-13 02:52:02 +01:00
|
|
|
Containment* containment = qobject_cast<Plasma::Containment*>(this);
|
2007-11-19 02:21:41 +01:00
|
|
|
if (isContainment() && containment) {
|
2008-04-25 20:44:09 +02:00
|
|
|
containment->d->containmentConstraintsUpdated(c);
|
2007-11-07 20:20:33 +01:00
|
|
|
}
|
|
|
|
|
2007-10-26 03:04:56 +02:00
|
|
|
constraintsUpdated(c);
|
|
|
|
|
|
|
|
if (layout()) {
|
2007-11-20 00:45:56 +01:00
|
|
|
layout()->updateGeometry();
|
2007-10-26 03:04:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-23 00:01:10 +02:00
|
|
|
int Applet::type() const
|
|
|
|
{
|
|
|
|
return Type;
|
|
|
|
}
|
|
|
|
|
2008-01-12 07:02:29 +01:00
|
|
|
QPainterPath Applet::shape() const
|
|
|
|
{
|
|
|
|
if (isContainment()) {
|
2008-04-14 18:02:23 +02:00
|
|
|
return QGraphicsWidget::shape();
|
2008-01-12 07:02:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return Plasma::roundedRectangle(boundingRect().adjusted(-2, -2, 2, 2), 10);
|
|
|
|
}
|
|
|
|
|
2008-04-25 21:55:24 +02:00
|
|
|
QList<QAction*> Applet::contextualActions()
|
2007-07-31 02:20:19 +02:00
|
|
|
{
|
2008-02-09 04:41:57 +01:00
|
|
|
//kDebug() << "empty context actions";
|
2008-04-25 21:55:24 +02:00
|
|
|
return d->script ? d->script->contextualActions() : QList<QAction*>();
|
2007-07-31 02:20:19 +02:00
|
|
|
}
|
|
|
|
|
2007-07-27 00:58:30 +02:00
|
|
|
QColor Applet::color() const
|
|
|
|
{
|
|
|
|
// TODO: add more colors for more categories and
|
|
|
|
// maybe read from config?
|
2007-07-28 23:07:18 +02:00
|
|
|
QString c = category();
|
2007-07-29 06:36:38 +02:00
|
|
|
int alpha = 200;
|
2007-07-28 23:07:18 +02:00
|
|
|
// Colors taken from Oxygen color palette
|
|
|
|
if (c == "Date and Time") {
|
|
|
|
return QColor(191, 94, 0, alpha);
|
|
|
|
} else if (c == "Environment & Weather") {
|
|
|
|
return QColor(191, 0, 0, alpha);
|
|
|
|
} else if (c == "Examples") {
|
|
|
|
return QColor(204, 0, 154, alpha);
|
|
|
|
} else if (c == "File System") {
|
|
|
|
return QColor(90, 0, 179, alpha);
|
|
|
|
} else if (c == "Graphics") {
|
|
|
|
return QColor(0, 0, 255, alpha);
|
|
|
|
} else if (c == "Language") {
|
|
|
|
return QColor(0, 191, 0, alpha);
|
|
|
|
} else if (c == "Mapping") {
|
|
|
|
return QColor(191, 245, 0, alpha);
|
|
|
|
} else if (c == "Online Services") {
|
|
|
|
return QColor(255, 213, 0, alpha);
|
|
|
|
} else if (c == "System Information") {
|
|
|
|
return QColor(0, 196, 204, alpha);
|
|
|
|
} else if (c == "Windows and Tasks") {
|
|
|
|
return QColor(255, 126, 0, alpha);
|
2007-07-27 00:58:30 +02:00
|
|
|
} else {
|
2007-07-28 23:07:18 +02:00
|
|
|
return QColor(136, 136, 136, alpha);
|
2007-07-27 00:58:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-14 16:50:02 +02:00
|
|
|
void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
2007-06-22 22:28:42 +02:00
|
|
|
{
|
2007-08-05 10:41:55 +02:00
|
|
|
if (d->shadow && d->shadow->shadowedSize() != boundingRect().size()) {
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "sizes are " << d->shadow->shadowedSize() << boundingRect().size();
|
2007-08-05 10:41:55 +02:00
|
|
|
d->shadow->generate();
|
|
|
|
}
|
|
|
|
|
2007-11-19 10:21:11 +01:00
|
|
|
painter->save();
|
2008-04-15 04:38:48 +02:00
|
|
|
|
2007-11-19 10:21:11 +01:00
|
|
|
if (transform().isRotating()) {
|
|
|
|
painter->setRenderHint(QPainter::SmoothPixmapTransform);
|
|
|
|
painter->setRenderHint(QPainter::Antialiasing);
|
|
|
|
}
|
2008-02-06 19:50:25 +01:00
|
|
|
if (d->background &&
|
|
|
|
formFactor() != Plasma::Vertical &&
|
|
|
|
formFactor() != Plasma::Horizontal) {
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "option rect is" << option->rect;
|
2008-04-25 18:18:51 +02:00
|
|
|
d->background->paintPanel(painter, option->rect, QPointF(0,0));
|
2007-11-19 10:21:11 +01:00
|
|
|
}
|
2008-04-01 00:06:35 +02:00
|
|
|
if (!d->failed) {
|
2007-11-19 10:21:11 +01:00
|
|
|
if (widget && isContainment()) {
|
|
|
|
// note that the widget we get is actually the viewport of the view, not the view itself
|
|
|
|
View* v = qobject_cast<Plasma::View*>(widget->parent());
|
2008-04-18 19:40:57 +02:00
|
|
|
if (!v || v->isWallpaperEnabled()) {
|
2008-02-23 00:41:44 +01:00
|
|
|
Containment::StyleOption coption(*option);
|
2008-04-24 18:01:09 +02:00
|
|
|
coption.view = v;
|
2008-03-02 20:32:37 +01:00
|
|
|
|
2008-04-13 15:23:39 +02:00
|
|
|
paintInterface(painter, &coption, QRect(QPoint(0,0), boundingRect().size().toSize()));
|
2007-11-19 10:21:11 +01:00
|
|
|
}
|
2008-02-23 00:41:44 +01:00
|
|
|
|
|
|
|
painter->restore();
|
|
|
|
return;
|
2007-07-26 01:42:43 +02:00
|
|
|
}
|
2007-06-22 22:28:42 +02:00
|
|
|
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "paint interface of" << (QObject*) this;
|
2008-04-13 15:23:39 +02:00
|
|
|
paintInterface(painter, option, QRect(QPoint(0,0), boundingRect().size().toSize()));
|
2008-04-12 16:07:44 +02:00
|
|
|
}
|
2007-11-19 10:21:11 +01:00
|
|
|
painter->restore();
|
2007-06-22 22:28:42 +02:00
|
|
|
}
|
|
|
|
|
2007-07-24 23:04:31 +02:00
|
|
|
void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
|
|
const QRect & contentsRect)
|
2007-06-20 08:45:08 +02:00
|
|
|
{
|
2008-01-25 01:08:25 +01:00
|
|
|
if (d->script) {
|
|
|
|
d->script->paintInterface(painter, option, contentsRect);
|
2007-07-24 23:04:31 +02:00
|
|
|
} else {
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "Applet::paintInterface() default impl";
|
2007-07-23 11:21:45 +02:00
|
|
|
}
|
2007-06-20 08:45:08 +02:00
|
|
|
}
|
|
|
|
|
2007-06-01 00:40:38 +02:00
|
|
|
FormFactor Applet::formFactor() const
|
|
|
|
{
|
2007-09-18 23:22:45 +02:00
|
|
|
Containment* c = containment();
|
2007-12-19 01:45:29 +01:00
|
|
|
return c ? c->formFactor() : Plasma::Planar;
|
2007-09-18 23:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Containment* Applet::containment() const
|
|
|
|
{
|
2008-01-11 19:21:53 +01:00
|
|
|
/*
|
|
|
|
* while this is probably "more correct", much of the code in applet assumes containment
|
|
|
|
* returns zero in the case that this is a containment itself.
|
|
|
|
* if (isContainment()) {
|
|
|
|
return dynamic_cast<Containment*>(const_cast<Applet*>(this));
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2008-02-29 18:50:57 +01:00
|
|
|
QGraphicsItem *parent = parentItem();
|
2007-12-04 05:15:21 +01:00
|
|
|
Containment *c = 0;
|
2008-01-11 19:21:53 +01:00
|
|
|
|
2007-11-15 12:01:17 +01:00
|
|
|
while (parent) {
|
2008-01-11 19:21:53 +01:00
|
|
|
Containment *possibleC = dynamic_cast<Containment*>(parent);
|
|
|
|
if (possibleC && possibleC->isContainment()) {
|
|
|
|
c = possibleC;
|
2007-11-15 12:01:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-02-29 18:50:57 +01:00
|
|
|
parent = parent->parentItem();
|
2007-11-15 12:01:17 +01:00
|
|
|
}
|
2008-01-11 19:21:53 +01:00
|
|
|
|
2007-12-04 05:15:21 +01:00
|
|
|
return c;
|
2007-06-01 00:40:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Location Applet::location() const
|
|
|
|
{
|
2007-09-18 23:22:45 +02:00
|
|
|
Containment* c = containment();
|
|
|
|
|
|
|
|
if (!c) {
|
2007-06-02 00:58:48 +02:00
|
|
|
return Plasma::Desktop;
|
|
|
|
}
|
|
|
|
|
2007-09-18 23:22:45 +02:00
|
|
|
return c->location();
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2008-01-10 20:02:05 +01:00
|
|
|
Qt::AspectRatioMode Applet::aspectRatioMode() const
|
|
|
|
{
|
|
|
|
return d->aspectRatioMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::setAspectRatioMode(Qt::AspectRatioMode mode)
|
|
|
|
{
|
|
|
|
d->aspectRatioMode = mode;
|
|
|
|
}
|
|
|
|
|
2008-01-25 01:08:25 +01:00
|
|
|
bool Applet::remainSquare() const
|
|
|
|
{
|
|
|
|
return d->square;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::setRemainSquare(bool square)
|
|
|
|
{
|
|
|
|
d->square = square;
|
|
|
|
}
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
QString Applet::globalName() const
|
|
|
|
{
|
2007-07-23 01:10:53 +02:00
|
|
|
if (!d->appletDescription.isValid()) {
|
2007-07-18 00:26:18 +02:00
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2007-07-23 01:10:53 +02:00
|
|
|
return d->appletDescription.service()->library();
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Applet::instanceName() const
|
|
|
|
{
|
2007-07-31 03:11:25 +02:00
|
|
|
return d->instanceName();
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2007-03-01 02:09:20 +01:00
|
|
|
void Applet::watchForFocus(QObject *widget, bool watch)
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2008-02-21 11:26:40 +01:00
|
|
|
if (!widget) {
|
2005-12-29 22:55:22 +01:00
|
|
|
return;
|
2007-03-03 02:41:27 +01:00
|
|
|
}
|
2005-12-29 22:55:22 +01:00
|
|
|
|
|
|
|
int index = d->watchedForFocus.indexOf(widget);
|
2008-02-21 11:26:40 +01:00
|
|
|
if (watch) {
|
|
|
|
if (index == -1) {
|
|
|
|
d->watchedForFocus.append(widget);
|
|
|
|
widget->installEventFilter(this);
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
2008-02-21 11:26:40 +01:00
|
|
|
} else if (index != -1) {
|
|
|
|
d->watchedForFocus.removeAt(index);
|
|
|
|
widget->removeEventFilter(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::watchForMouseMove( QGraphicsItem * watched, bool watch )
|
|
|
|
{
|
|
|
|
if (!watched) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = d->watchedForMouseMove.indexOf(watched);
|
|
|
|
if (watch) {
|
|
|
|
if (index == -1) {
|
|
|
|
d->watchedForMouseMove.append(watched);
|
|
|
|
watched->installSceneEventFilter(this);
|
|
|
|
}
|
|
|
|
} else if (index != -1) {
|
|
|
|
d->watchedForMouseMove.removeAt(index);
|
|
|
|
watched->removeSceneEventFilter(this);
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-21 20:24:05 +02:00
|
|
|
void Applet::needsFocus(bool focus)
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2007-05-24 22:01:12 +02:00
|
|
|
if (focus == QGraphicsItem::hasFocus()) {
|
2005-12-29 22:55:22 +01:00
|
|
|
return;
|
2007-03-03 02:41:27 +01:00
|
|
|
}
|
2005-12-29 22:55:22 +01:00
|
|
|
|
|
|
|
emit requestFocus(focus);
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:15:38 +02:00
|
|
|
bool Applet::hasConfigurationInterface() const
|
2007-07-02 12:47:34 +02:00
|
|
|
{
|
|
|
|
return d->hasConfigurationInterface;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::setHasConfigurationInterface(bool hasInterface)
|
|
|
|
{
|
|
|
|
d->hasConfigurationInterface = hasInterface;
|
|
|
|
}
|
|
|
|
|
2007-03-03 02:41:27 +01:00
|
|
|
bool Applet::eventFilter( QObject *o, QEvent * e )
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2007-03-03 02:41:27 +01:00
|
|
|
if ( !d->watchedForFocus.contains( o ) )
|
2005-12-29 22:55:22 +01:00
|
|
|
{
|
2007-03-03 02:41:27 +01:00
|
|
|
if ( e->type() == QEvent::MouseButtonRelease ||
|
|
|
|
e->type() == QEvent::FocusIn ) {
|
|
|
|
needsFocus( true );
|
|
|
|
} else if ( e->type() == QEvent::FocusOut ) {
|
|
|
|
needsFocus( false );
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-24 22:01:12 +02:00
|
|
|
return QObject::eventFilter(o, e);
|
|
|
|
}
|
|
|
|
|
2008-02-21 11:26:40 +01:00
|
|
|
bool Applet::sceneEventFilter( QGraphicsItem * watched, QEvent * event )
|
|
|
|
{
|
|
|
|
switch (event->type()) {
|
|
|
|
case QEvent::GraphicsSceneMouseMove: {
|
|
|
|
if (d->watchedForMouseMove.contains( watched )) {
|
|
|
|
mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(event));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QGraphicsItem::sceneEventFilter(watched, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
{
|
2008-04-24 20:24:11 +02:00
|
|
|
if (d->immutability == NotImmutable && formFactor() == Plasma::Planar) {
|
2008-02-21 11:26:40 +01:00
|
|
|
QGraphicsItem *parent = parentItem();
|
|
|
|
Plasma::Applet *applet = qgraphicsitem_cast<Plasma::Applet*>(parent);
|
|
|
|
|
|
|
|
if (applet && applet->isContainment()) {
|
|
|
|
// our direct parent is a containment. just move ourselves.
|
|
|
|
QPointF curPos = event->pos();
|
|
|
|
QPointF lastPos = event->lastPos();
|
|
|
|
QPointF delta = curPos-lastPos;
|
|
|
|
|
|
|
|
moveBy(delta.x(),delta.y());
|
|
|
|
} else if (parent) {
|
|
|
|
//don't move the icon as well because our parent (usually an appletHandle) will do it for us
|
|
|
|
//parent->moveBy(delta.x(),delta.y());
|
|
|
|
QPointF curPos = parent->transform().map(event->pos());
|
|
|
|
QPointF lastPos = parent->transform().map(event->lastPos());
|
|
|
|
QPointF delta = curPos-lastPos;
|
|
|
|
|
|
|
|
parent->setPos(parent->pos() + delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-14 23:50:41 +02:00
|
|
|
void Applet::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
{
|
|
|
|
setFocus(Qt::MouseFocusReason);
|
|
|
|
QGraphicsWidget::mousePressEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Applet::focusInEvent(QFocusEvent * event)
|
|
|
|
{
|
|
|
|
kDebug() << "FOCUS! FOCUS! FOCUS!";
|
|
|
|
QGraphicsWidget::focusInEvent(event);
|
|
|
|
}
|
2008-02-21 11:26:40 +01:00
|
|
|
|
2007-07-02 12:58:03 +02:00
|
|
|
void Applet::showConfigurationInterface()
|
2007-07-02 12:47:34 +02:00
|
|
|
{
|
2008-04-02 17:37:17 +02:00
|
|
|
if (!hasConfigurationInterface()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString dialogId = QString("%1settings%2").arg(id()).arg(name());
|
|
|
|
KConfigDialog * dlg = KConfigDialog::exists(dialogId);
|
|
|
|
|
|
|
|
if (dlg) {
|
|
|
|
KWindowSystem::setOnDesktop(dlg->winId(), KWindowSystem::currentDesktop());
|
|
|
|
dlg->show();
|
|
|
|
KWindowSystem::activateWindow(dlg->winId());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString windowTitle = i18nc("@title:window", "%1 Settings", name());
|
2007-07-30 18:00:29 +02:00
|
|
|
if (d->package && d->configXml) {
|
|
|
|
QString uiFile = d->package->filePath("mainconfigui");
|
|
|
|
if (uiFile.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-02 17:37:17 +02:00
|
|
|
KConfigDialog *dialog = new KConfigDialog(0, dialogId, d->configXml);
|
|
|
|
dialog->setWindowTitle(windowTitle);
|
2007-07-30 18:00:29 +02:00
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
QUiLoader loader;
|
2008-01-25 15:53:12 +01:00
|
|
|
QFile f(uiFile);
|
2007-07-30 18:00:29 +02:00
|
|
|
if (!f.open(QIODevice::ReadOnly)) {
|
|
|
|
delete dialog;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *w = loader.load(&f);
|
|
|
|
f.close();
|
|
|
|
|
|
|
|
dialog->addPage(w, i18n("Settings"), icon(), i18n("%1 Settings", name()));
|
|
|
|
dialog->show();
|
2008-04-02 17:37:17 +02:00
|
|
|
} else if (d->script) {
|
2008-03-02 22:36:59 +01:00
|
|
|
d->script->showConfigurationInterface();
|
2008-04-02 17:37:17 +02:00
|
|
|
} else {
|
|
|
|
KConfigSkeleton *nullManager = new KConfigSkeleton(0);
|
|
|
|
KConfigDialog *dialog = new KConfigDialog(0, dialogId, nullManager);
|
|
|
|
dialog->setFaceType(KPageDialog::Auto);
|
|
|
|
dialog->setWindowTitle(windowTitle);
|
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
createConfigurationInterface(dialog);
|
|
|
|
//TODO: would be nice to not show dialog if there are no pages added?
|
|
|
|
connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
|
|
|
|
dialog->show();
|
|
|
|
dialog->enableButtonApply(true);
|
2008-03-02 22:36:59 +01:00
|
|
|
}
|
2008-04-25 19:21:24 +02:00
|
|
|
|
|
|
|
emit launchActivated();
|
2007-07-02 12:47:34 +02:00
|
|
|
}
|
|
|
|
|
2008-04-02 17:37:17 +02:00
|
|
|
void Applet::createConfigurationInterface(KConfigDialog *parent)
|
|
|
|
{
|
|
|
|
Q_UNUSED(parent)
|
|
|
|
// virtual method reimplemented by subclasses.
|
|
|
|
// do not put anything here ...
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:15:38 +02:00
|
|
|
KPluginInfo::List Applet::listAppletInfo(const QString &category,
|
2007-07-17 23:30:27 +02:00
|
|
|
const QString &parentApp)
|
2007-05-24 22:01:12 +02:00
|
|
|
{
|
2007-07-17 23:30:27 +02:00
|
|
|
QString constraint;
|
|
|
|
|
|
|
|
if (parentApp.isEmpty()) {
|
|
|
|
constraint.append("not exist [X-KDE-ParentApp]");
|
|
|
|
} else {
|
|
|
|
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!category.isEmpty()) {
|
|
|
|
if (!constraint.isEmpty()) {
|
|
|
|
constraint.append(" and ");
|
|
|
|
}
|
|
|
|
|
2007-07-18 00:26:18 +02:00
|
|
|
constraint.append("[X-KDE-PluginInfo-Category] == '").append(category).append("'");
|
2007-08-05 15:01:09 +02:00
|
|
|
if (category == "Miscellaneous") {
|
2007-07-18 00:26:18 +02:00
|
|
|
constraint.append(" or (not exist [X-KDE-PluginInfo-Category] or [X-KDE-PluginInfo-Category] == '')");
|
2007-07-17 23:30:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
2008-04-16 23:15:38 +02:00
|
|
|
//kDebug() << "Applet::listAppletInfo constraint was '" << constraint << "' which got us " << offers.count() << " matches";
|
2007-05-24 22:01:12 +02:00
|
|
|
return KPluginInfo::fromServices(offers);
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:15:38 +02:00
|
|
|
KPluginInfo::List Applet::listAppletInfoForMimetype(const QString &mimetype)
|
2007-07-31 12:52:05 +02:00
|
|
|
{
|
2007-08-05 23:52:35 +02:00
|
|
|
QString constraint = QString("'%1' in MimeTypes").arg(mimetype);
|
2008-04-16 23:15:38 +02:00
|
|
|
//kDebug() << "listAppletInfoForMimetype with" << mimetype << constraint;
|
2007-07-31 12:52:05 +02:00
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
|
|
|
return KPluginInfo::fromServices(offers);
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:15:38 +02:00
|
|
|
QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly)
|
2007-07-12 15:24:35 +02:00
|
|
|
{
|
2007-07-17 23:30:27 +02:00
|
|
|
QString constraint = "exist [X-KDE-PluginInfo-Category]";
|
|
|
|
|
|
|
|
if (parentApp.isEmpty()) {
|
|
|
|
constraint.append(" and not exist [X-KDE-ParentApp]");
|
|
|
|
} else {
|
|
|
|
constraint.append(" and [X-KDE-ParentApp] == '").append(parentApp).append("'");
|
|
|
|
}
|
|
|
|
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
2007-07-12 15:24:35 +02:00
|
|
|
QStringList categories;
|
2007-11-19 10:46:52 +01:00
|
|
|
foreach (const KService::Ptr applet, offers) {
|
2007-07-17 23:30:27 +02:00
|
|
|
QString appletCategory = applet->property("X-KDE-PluginInfo-Category").toString();
|
2007-11-19 17:37:46 +01:00
|
|
|
if (visibleOnly && applet->noDisplay()) {
|
2007-11-19 10:46:52 +01:00
|
|
|
// we don't want to show the hidden category
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << " and we have " << appletCategory;
|
2007-07-17 23:30:27 +02:00
|
|
|
if (appletCategory.isEmpty()) {
|
2007-08-05 15:01:09 +02:00
|
|
|
if (!categories.contains(i18n("Miscellaneous"))) {
|
|
|
|
categories << i18n("Miscellaneous");
|
2007-07-12 15:24:35 +02:00
|
|
|
}
|
2007-07-17 23:30:27 +02:00
|
|
|
} else if (!categories.contains(appletCategory)) {
|
|
|
|
categories << appletCategory;
|
2007-07-12 15:24:35 +02:00
|
|
|
}
|
|
|
|
}
|
2007-07-17 23:30:27 +02:00
|
|
|
|
|
|
|
categories.sort();
|
2007-07-12 15:24:35 +02:00
|
|
|
return categories;
|
|
|
|
}
|
|
|
|
|
2008-02-26 02:48:52 +01:00
|
|
|
Applet* Applet::load(const QString& appletName, uint appletId, const QVariantList& args)
|
2007-05-24 22:01:12 +02:00
|
|
|
{
|
|
|
|
if (appletName.isEmpty()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
|
|
|
|
2008-03-05 22:12:33 +01:00
|
|
|
bool isContainment = false;
|
2007-05-24 22:01:12 +02:00
|
|
|
if (offers.isEmpty()) {
|
|
|
|
//TODO: what would be -really- cool is offer to try and download the applet
|
|
|
|
// from the network at this point
|
2008-03-05 22:12:33 +01:00
|
|
|
offers = KServiceTypeTrader::self()->query("Plasma/Containment", constraint);
|
|
|
|
isContainment = true;
|
2008-03-05 22:19:48 +01:00
|
|
|
if (offers.isEmpty()) {
|
2008-03-05 22:12:33 +01:00
|
|
|
kDebug() << "offers is empty for " << appletName;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-26 03:06:03 +02:00
|
|
|
} /* else if (offers.count() > 1) {
|
2008-01-08 02:25:09 +01:00
|
|
|
kDebug() << "hey! we got more than one! let's blindly take the first one";
|
2007-10-26 03:06:03 +02:00
|
|
|
} */
|
2007-05-24 22:01:12 +02:00
|
|
|
|
2007-11-29 21:38:13 +01:00
|
|
|
KService::Ptr offer = offers.first();
|
|
|
|
|
2007-05-24 22:01:12 +02:00
|
|
|
if (appletId == 0) {
|
2008-02-13 02:52:02 +01:00
|
|
|
appletId = ++Private::s_maxAppletId;
|
2007-05-24 22:01:12 +02:00
|
|
|
}
|
|
|
|
|
2007-11-29 21:38:13 +01:00
|
|
|
if (!offer->property("X-Plasma-Language").toString().isEmpty()) {
|
2008-01-08 02:25:09 +01:00
|
|
|
kDebug() << "we have a script in the language of" << offer->property("X-Plasma-Language").toString();
|
2008-03-05 22:12:33 +01:00
|
|
|
if (isContainment) {
|
|
|
|
return new Containment(0, offer->storageId(), appletId);
|
|
|
|
}
|
|
|
|
return new Applet(0, offer->storageId(), appletId);
|
2007-11-29 21:38:13 +01:00
|
|
|
}
|
|
|
|
|
2007-08-29 04:33:22 +02:00
|
|
|
QVariantList allArgs;
|
2007-11-29 21:38:13 +01:00
|
|
|
allArgs << offer->storageId() << appletId << args;
|
2007-08-29 04:33:22 +02:00
|
|
|
QString error;
|
2007-11-29 21:38:13 +01:00
|
|
|
Applet* applet = offer->createInstance<Plasma::Applet>(0, allArgs, &error);
|
2007-05-24 22:01:12 +02:00
|
|
|
|
|
|
|
if (!applet) {
|
2008-01-08 02:25:09 +01:00
|
|
|
kDebug() << "Couldn't load applet \"" << appletName << "\"! reason given: " << error;
|
2007-05-24 22:01:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return applet;
|
2005-12-29 22:55:22 +01:00
|
|
|
}
|
|
|
|
|
2008-02-26 02:48:52 +01:00
|
|
|
Applet* Applet::load(const KPluginInfo& info, uint appletId, const QVariantList& args)
|
2007-05-24 22:51:59 +02:00
|
|
|
{
|
2007-07-23 01:10:53 +02:00
|
|
|
if (!info.isValid()) {
|
2007-05-24 22:51:59 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-26 02:48:52 +01:00
|
|
|
return load(info.pluginName(), appletId, args);
|
2007-05-24 22:51:59 +02:00
|
|
|
}
|
|
|
|
|
2007-08-05 10:41:55 +02:00
|
|
|
void Applet::setShadowShown(bool shown)
|
|
|
|
{
|
|
|
|
//There are various problems with shadows right now:
|
|
|
|
//
|
|
|
|
//1) shadows can be seen through translucent areas, which is probably technically correct ubt
|
|
|
|
//looks odd
|
|
|
|
//2) the shape of the item odesn't conform to the shape of the standard background, e.g. with
|
|
|
|
//rounded corners
|
|
|
|
#ifdef DYNAMIC_SHADOWS
|
|
|
|
if (shown) {
|
|
|
|
if (d->shadow) {
|
|
|
|
d->shadow->setVisible(true);
|
|
|
|
} else {
|
|
|
|
d->shadow = new ShadowItem(this);
|
|
|
|
if (scene()) {
|
|
|
|
scene()->addItem(d->shadow);
|
|
|
|
d->shadow->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
delete d->shadow;
|
|
|
|
d->shadow = 0;
|
|
|
|
}
|
2007-08-17 17:05:01 +02:00
|
|
|
#else
|
|
|
|
Q_UNUSED(shown);
|
2007-08-05 10:41:55 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Applet::isShadowShown() const
|
|
|
|
{
|
|
|
|
return d->shadow && d->shadow->isVisible();
|
|
|
|
}
|
|
|
|
|
2008-02-13 02:52:02 +01:00
|
|
|
QPointF Applet::topLeft() const
|
|
|
|
{
|
|
|
|
return boundingRect().topLeft();
|
|
|
|
}
|
2007-11-27 07:01:06 +01:00
|
|
|
|
2007-08-05 10:41:55 +02:00
|
|
|
QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
|
|
|
|
{
|
|
|
|
switch (change) {
|
|
|
|
case ItemPositionChange:
|
2007-11-27 07:01:06 +01:00
|
|
|
if (d->shadow) {
|
|
|
|
d->shadow->adjustPosition();
|
|
|
|
}
|
2007-08-05 10:41:55 +02:00
|
|
|
break;
|
2008-03-03 19:15:49 +01:00
|
|
|
case ItemSceneHasChanged: {
|
2007-08-05 10:41:55 +02:00
|
|
|
QGraphicsScene *newScene = qvariant_cast<QGraphicsScene*>(value);
|
|
|
|
if (newScene) {
|
2008-03-03 19:15:49 +01:00
|
|
|
checkImmutability();
|
2007-11-27 07:01:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (d->shadow) {
|
|
|
|
if (d->shadow->scene()) {
|
|
|
|
d->shadow->scene()->removeItem(d->shadow);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newScene) {
|
|
|
|
newScene->addItem(d->shadow);
|
|
|
|
d->shadow->generate();
|
|
|
|
d->shadow->adjustPosition();
|
|
|
|
d->shadow->show();
|
|
|
|
}
|
2007-08-05 10:41:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ItemVisibleChange:
|
2007-11-27 07:01:06 +01:00
|
|
|
if (d->shadow) {
|
|
|
|
d->shadow->setVisible(isVisible());
|
|
|
|
}
|
2007-08-05 10:41:55 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
2008-04-14 18:02:23 +02:00
|
|
|
return QGraphicsWidget::itemChange(change, value);
|
2007-08-05 10:41:55 +02:00
|
|
|
}
|
|
|
|
|
2007-09-28 07:46:37 +02:00
|
|
|
void Applet::setGeometry(const QRectF& geometry)
|
|
|
|
{
|
2008-04-14 18:02:23 +02:00
|
|
|
QRectF beforeGeom = QGraphicsWidget::geometry();
|
|
|
|
QGraphicsWidget::setGeometry(geometry);
|
2008-04-24 21:48:04 +02:00
|
|
|
if (geometry.size() != beforeGeom.size()) {
|
|
|
|
updateConstraints(Plasma::SizeConstraint);
|
|
|
|
if (d->background) {
|
|
|
|
d->background->resizePanel(boundingRect().size());
|
|
|
|
}
|
|
|
|
emit geometryChanged();
|
|
|
|
} else if (geometry.topLeft() != beforeGeom.topLeft()) {
|
|
|
|
/*if (d->background) {
|
|
|
|
kDebug() << QGraphicsWidget::geometry();
|
|
|
|
}*/
|
|
|
|
emit geometryChanged();
|
2008-04-13 15:38:21 +02:00
|
|
|
}
|
2007-09-28 07:46:37 +02:00
|
|
|
}
|
|
|
|
|
2008-02-13 02:52:02 +01:00
|
|
|
void Applet::raise()
|
|
|
|
{
|
|
|
|
setZValue(++Private::s_maxZValue);
|
|
|
|
}
|
|
|
|
|
2008-04-23 22:27:44 +02:00
|
|
|
void Applet::lower()
|
|
|
|
{
|
|
|
|
setZValue(--Private::s_minZValue);
|
|
|
|
}
|
|
|
|
|
2007-11-15 10:39:46 +01:00
|
|
|
void Applet::setIsContainment(bool isContainment)
|
|
|
|
{
|
2008-04-24 18:29:23 +02:00
|
|
|
if (d->isContainment == isContainment) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-15 10:39:46 +01:00
|
|
|
d->isContainment = isContainment;
|
2008-04-24 18:29:23 +02:00
|
|
|
|
|
|
|
Containment *c = qobject_cast<Containment*>(this);
|
|
|
|
if (c) {
|
|
|
|
// set up the toolbox
|
|
|
|
c->setContainmentType(c->containmentType());
|
|
|
|
}
|
2007-11-15 10:39:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Applet::isContainment() const
|
|
|
|
{
|
|
|
|
return d->isContainment;
|
|
|
|
}
|
|
|
|
|
2008-02-12 08:33:07 +01:00
|
|
|
void Applet::themeChanged()
|
|
|
|
{
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
2005-12-29 22:55:22 +01:00
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#include "applet.moc"
|