Move ExtenderApplet to libplasma. This doesn't work just yet, but aseigo will take a look at
it, so it will soon. ;) svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=860007
This commit is contained in:
parent
d0863e43e8
commit
cb4d610219
@ -48,6 +48,7 @@ set(plasma_LIB_SRCS
|
|||||||
private/applethandle.cpp
|
private/applethandle.cpp
|
||||||
private/datacontainer_p.cpp
|
private/datacontainer_p.cpp
|
||||||
private/desktoptoolbox.cpp
|
private/desktoptoolbox.cpp
|
||||||
|
private/extenderapplet.cpp
|
||||||
private/nativetabbar.cpp
|
private/nativetabbar.cpp
|
||||||
private/packages.cpp
|
private/packages.cpp
|
||||||
private/paneltoolbox.cpp
|
private/paneltoolbox.cpp
|
||||||
@ -286,6 +287,10 @@ install(FILES
|
|||||||
servicetypes/plasma-wallpaper.desktop
|
servicetypes/plasma-wallpaper.desktop
|
||||||
DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
DESTINATION ${SERVICETYPES_INSTALL_DIR})
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
servicetypes/plasma-applet-extenderapplet.desktop
|
||||||
|
DESTINATION ${SERVICES_INSTALL_DIR})
|
||||||
|
|
||||||
install(FILES scripting/plasmoids.knsrc DESTINATION ${CONFIG_INSTALL_DIR})
|
install(FILES scripting/plasmoids.knsrc DESTINATION ${CONFIG_INSTALL_DIR})
|
||||||
|
|
||||||
# Nepomuk integration
|
# Nepomuk integration
|
||||||
|
10
applet.cpp
10
applet.cpp
@ -78,6 +78,7 @@
|
|||||||
#include "wallpaper.h"
|
#include "wallpaper.h"
|
||||||
|
|
||||||
#include "private/containment_p.h"
|
#include "private/containment_p.h"
|
||||||
|
#include "private/extenderapplet_p.h"
|
||||||
#include "private/packages_p.h"
|
#include "private/packages_p.h"
|
||||||
#include "private/toolbox_p.h"
|
#include "private/toolbox_p.h"
|
||||||
|
|
||||||
@ -1324,6 +1325,7 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||||
|
|
||||||
@ -1364,7 +1366,13 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis
|
|||||||
QVariantList allArgs;
|
QVariantList allArgs;
|
||||||
allArgs << offer->storageId() << appletId << args;
|
allArgs << offer->storageId() << appletId << args;
|
||||||
QString error;
|
QString error;
|
||||||
Applet* applet = offer->createInstance<Plasma::Applet>(0, allArgs, &error);
|
Applet *applet;
|
||||||
|
|
||||||
|
if (appletName == "extenderapplet") {
|
||||||
|
applet = new ExtenderApplet(0, allArgs);
|
||||||
|
} else {
|
||||||
|
applet = offer->createInstance<Plasma::Applet>(0, allArgs, &error);
|
||||||
|
}
|
||||||
|
|
||||||
if (!applet) {
|
if (!applet) {
|
||||||
kDebug() << "Couldn't load applet \"" << appletName << "\"! reason given: " << error;
|
kDebug() << "Couldn't load applet \"" << appletName << "\"! reason given: " << error;
|
||||||
|
3
applet.h
3
applet.h
@ -606,6 +606,9 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
|||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* You can also add one or more custom qactions to this extender item in this function.
|
* You can also add one or more custom qactions to this extender item in this function.
|
||||||
|
*
|
||||||
|
* Note that by default, not all ExtenderItems are persistent. Only items that are detached,
|
||||||
|
* will have there configuration stored when plasma exists.
|
||||||
*/
|
*/
|
||||||
virtual void initExtenderItem(ExtenderItem *item);
|
virtual void initExtenderItem(ExtenderItem *item);
|
||||||
|
|
||||||
|
85
private/extenderapplet.cpp
Normal file
85
private/extenderapplet.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "extenderapplet_p.h"
|
||||||
|
|
||||||
|
#include "extender.h"
|
||||||
|
#include "extenderitem.h"
|
||||||
|
|
||||||
|
#include <KDebug>
|
||||||
|
#include <KIcon>
|
||||||
|
|
||||||
|
#include <QGraphicsLinearLayout>
|
||||||
|
|
||||||
|
ExtenderApplet::ExtenderApplet(QObject *parent, const QVariantList &args)
|
||||||
|
: Plasma::Applet(parent, args)
|
||||||
|
{
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtenderApplet::~ExtenderApplet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenderApplet::init()
|
||||||
|
{
|
||||||
|
new Plasma::Extender(this);
|
||||||
|
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
|
||||||
|
setLayout(layout);
|
||||||
|
extender()->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
connect(extender(), SIGNAL(geometryChanged()), this, SLOT(adjustSize()));
|
||||||
|
connect(extender(), SIGNAL(itemDetached(Plasma::ExtenderItem*)),
|
||||||
|
this, SLOT(itemDetached(Plasma::ExtenderItem*)));
|
||||||
|
layout->addItem(extender());
|
||||||
|
adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenderApplet::adjustSize()
|
||||||
|
{
|
||||||
|
layout()->updateGeometry();
|
||||||
|
|
||||||
|
qreal left, top, right, bottom;
|
||||||
|
getContentsMargins(&left, &top, &right, &bottom);
|
||||||
|
|
||||||
|
setPreferredSize(QSizeF(left + right + layout()->preferredWidth(),
|
||||||
|
top + bottom + layout()->preferredHeight()));
|
||||||
|
setMinimumSize( QSizeF(left + right + layout()->minimumWidth(),
|
||||||
|
top + bottom + layout()->minimumHeight()));
|
||||||
|
setMaximumSize( QSizeF(left + right + layout()->maximumWidth(),
|
||||||
|
top + bottom + layout()->maximumHeight()));
|
||||||
|
|
||||||
|
updateGeometry();
|
||||||
|
//This wasn't necesarry before... but it is now. weirdness.
|
||||||
|
resize(size().width(), preferredHeight());
|
||||||
|
layout()->invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenderApplet::itemDetached(Plasma::ExtenderItem*)
|
||||||
|
{
|
||||||
|
kDebug() << "item detached: " << extender()->attachedItems().count();
|
||||||
|
if (!extender()->attachedItems().count()) {
|
||||||
|
destroy();
|
||||||
|
//FIXME: only fire the signal when the item is really detached, not just being dragged away.
|
||||||
|
kDebug() << "delete the extender applet...";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#include "extenderapplet_p.moc"
|
||||||
|
|
39
private/extenderapplet_p.h
Normal file
39
private/extenderapplet_p.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EXTENDERAPPLET_H
|
||||||
|
#define EXTENDERAPPLET_H
|
||||||
|
|
||||||
|
#include "applet.h"
|
||||||
|
|
||||||
|
class ExtenderApplet : public Plasma::Applet
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ExtenderApplet(QObject *parent, const QVariantList &args);
|
||||||
|
~ExtenderApplet();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void itemDetached(Plasma::ExtenderItem*);
|
||||||
|
void adjustSize();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user