* Add support to load PopupApplet and Containment from path
* AppletScript::addStandardConfigurationPages adds also publish page * AppletScript::standardConfigurationDialog does not add standard pages (there is addStandardConfigurationPages) svn path=/trunk/KDE/kdelibs/; revision=1039471
This commit is contained in:
parent
d9de800d36
commit
042ed56b39
20
applet.cpp
20
applet.cpp
@ -1738,6 +1738,7 @@ void Applet::showConfigurationInterface()
|
||||
} else {
|
||||
KConfigDialog *dialog = d->generateGenericConfigDialog();
|
||||
//createConfigurationInterface(dialog);
|
||||
d->addStandardConfigurationPages(dialog);
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
@ -1789,8 +1790,6 @@ KConfigDialog *AppletPrivate::generateGenericConfigDialog()
|
||||
dialog->setWindowTitle(configWindowTitle());
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
q->createConfigurationInterface(dialog);
|
||||
addGlobalShortcutsPage(dialog);
|
||||
addPublishPage(dialog);
|
||||
//TODO: Apply button does not correctly work for now, so do not show it
|
||||
dialog->showButton(KDialog::Apply, false);
|
||||
QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
|
||||
@ -1799,6 +1798,12 @@ KConfigDialog *AppletPrivate::generateGenericConfigDialog()
|
||||
return dialog;
|
||||
}
|
||||
|
||||
void AppletPrivate::addStandardConfigurationPages(KConfigDialog *dialog)
|
||||
{
|
||||
addGlobalShortcutsPage(dialog);
|
||||
addPublishPage(dialog);
|
||||
}
|
||||
|
||||
void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
|
||||
{
|
||||
if (isContainment) {
|
||||
@ -2137,7 +2142,16 @@ Applet::Applet(const QString &packagePath, uint appletId, const QVariantList &ar
|
||||
Applet *Applet::loadPlasmoid(const QString &path, uint appletId, const QVariantList &args)
|
||||
{
|
||||
if (QFile::exists(path + "/metadata.desktop")) {
|
||||
return new Applet(path, appletId, args);
|
||||
KService service(path + "/metadata.desktop");
|
||||
const QStringList& types = service.serviceTypes();
|
||||
|
||||
if (types.contains("Plasma/Containment")) {
|
||||
return new Containment(path, appletId, args);
|
||||
} else if (types.contains("Plasma/PopupApplet")) {
|
||||
return new PopupApplet(path, appletId, args);
|
||||
} else {
|
||||
return new Applet(path, appletId, args);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -123,6 +123,17 @@ Containment::Containment(QObject *parent, const QVariantList &args)
|
||||
setHasConfigurationInterface(false);
|
||||
}
|
||||
|
||||
Containment::Containment(const QString &packagePath, uint appletId, const QVariantList &args)
|
||||
: Plasma::Applet(packagePath, appletId, args),
|
||||
d(new ContainmentPrivate(this))
|
||||
{
|
||||
// WARNING: do not access config() OR globalConfig() in this method!
|
||||
// that requires a scene, which is not available at this point
|
||||
setPos(0, 0);
|
||||
setBackgroundHints(NoBackground);
|
||||
setHasConfigurationInterface(false);
|
||||
}
|
||||
|
||||
Containment::~Containment()
|
||||
{
|
||||
delete d;
|
||||
|
@ -593,6 +593,16 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
AbstractToolBox *toolBox() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @internal This constructor is to be used with the Package loading system.
|
||||
*
|
||||
* @param parent a QObject parent; you probably want to pass in 0
|
||||
* @param args a list of strings containing two entries: the service id
|
||||
* and the applet id
|
||||
* @since 4.3
|
||||
*/
|
||||
Containment(const QString &packagePath, uint appletId, const QVariantList &args);
|
||||
|
||||
Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*))
|
||||
Q_PRIVATE_SLOT(d, void containmentAppletAnimationComplete(QGraphicsItem *,
|
||||
Plasma::Animator::Animation anim))
|
||||
|
@ -62,6 +62,17 @@ PopupApplet::PopupApplet(QObject *parent, const QVariantList &args)
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
PopupApplet::PopupApplet(const QString &packagePath, uint appletId, const QVariantList &args)
|
||||
: Plasma::Applet(packagePath, appletId, args),
|
||||
d(new PopupAppletPrivate(this))
|
||||
{
|
||||
int iconSize = IconSize(KIconLoader::Desktop);
|
||||
resize(iconSize, iconSize);
|
||||
disconnect(this, SIGNAL(activate()), (Applet*)this, SLOT(setFocus()));
|
||||
connect(this, SIGNAL(activate()), this, SLOT(internalTogglePopup()));
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
PopupApplet::~PopupApplet()
|
||||
{
|
||||
delete widget();
|
||||
|
@ -45,7 +45,7 @@ class PopupAppletPrivate;
|
||||
*
|
||||
* If you use this class as a base class for your extender using applet, the extender will
|
||||
* automatically be used for the popup; reimplementing graphicsWidget() is unnecessary in this case.
|
||||
* If you need a popup that does not steal window focus when openend or used, set window flag
|
||||
* If you need a popup that does not steal window focus when openend or used, set window flag
|
||||
* Qt::X11BypassWindowManagerHint the widget returned by widget() or graphicsWidget().
|
||||
*/
|
||||
|
||||
@ -100,7 +100,7 @@ public:
|
||||
|
||||
/**
|
||||
* Sets whether or not the dialog popup that gets created should be a "passive" popup
|
||||
* that does not steal focus from other windows or not.
|
||||
* that does not steal focus from other windows or not.
|
||||
*
|
||||
* @arg passive true if the dialog should be treated as a passive popup
|
||||
*/
|
||||
@ -152,6 +152,16 @@ protected:
|
||||
void dropEvent(QGraphicsSceneDragDropEvent *event);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @internal This constructor is to be used with the Package loading system.
|
||||
*
|
||||
* @param parent a QObject parent; you probably want to pass in 0
|
||||
* @param args a list of strings containing two entries: the service id
|
||||
* and the applet id
|
||||
* @since 4.3
|
||||
*/
|
||||
PopupApplet(const QString &packagePath, uint appletId, const QVariantList &args);
|
||||
|
||||
Q_PRIVATE_SLOT(d, void internalTogglePopup())
|
||||
Q_PRIVATE_SLOT(d, void hideTimedPopup())
|
||||
Q_PRIVATE_SLOT(d, void clearPopupLostFocus())
|
||||
|
@ -102,6 +102,7 @@ public:
|
||||
void clearShortcutEditorPtr();
|
||||
void configDialogFinished();
|
||||
KConfigDialog *generateGenericConfigDialog();
|
||||
void addStandardConfigurationPages(KConfigDialog *dialog);
|
||||
QString configDialogId() const;
|
||||
QString configWindowTitle() const;
|
||||
void updateShortcuts();
|
||||
|
@ -143,7 +143,7 @@ KConfigDialog *AppletScript::standardConfigurationDialog()
|
||||
void AppletScript::addStandardConfigurationPages(KConfigDialog *dialog)
|
||||
{
|
||||
if (applet()) {
|
||||
applet()->d->addGlobalShortcutsPage(dialog);
|
||||
applet()->d->addStandardConfigurationPages(dialog);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user