diff --git a/scriptengines/qml/CMakeLists.txt b/scriptengines/qml/CMakeLists.txt index 34ec20c58..23d3aec15 100644 --- a/scriptengines/qml/CMakeLists.txt +++ b/scriptengines/qml/CMakeLists.txt @@ -14,9 +14,6 @@ include_directories(${KDE4_INCLUDE_DIR}/KDE ${PHONON_INCLUDES} ${CMAKE_CURRENT_S #DECLARATIVE APPLET set(declarative_appletscript_SRCS common/scriptenv.cpp - #declarative/toolboxproxy.cpp - #declarative/appletcontainer.cpp - #declarative/declarativeitemcontainer.cpp declarative/packageaccessmanager.cpp declarative/packageaccessmanagerfactory.cpp declarative/qmlobject.cpp diff --git a/scriptengines/qml/declarative/toolboxproxy.cpp b/scriptengines/qml/declarative/toolboxproxy.cpp deleted file mode 100644 index 2e9ab556e..000000000 --- a/scriptengines/qml/declarative/toolboxproxy.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2007 by Aaron Seigo - * Copyright 2008 by Marco Martin - * Copyright 2012 by Sebastian Kügler - * - * 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 "toolboxproxy.h" -#include "../plasmoid/appletinterface.h" - -#include -#include -#include - -#include - -class ToolBoxProxyPrivate { -public: - bool showing; - Plasma::Containment *containment; - QList actions; - AppletInterface* appletInterface; - QAction* addPanelAction; - QAction* addWidgetsAction; - QAction* configureAction; -}; - -ToolBoxProxy::ToolBoxProxy(Plasma::Containment *parent, AppletInterface *appletInterface) - : AbstractToolBox(parent) -{ - d = new ToolBoxProxyPrivate; - d->containment = parent; - d->appletInterface = appletInterface; - init(); -} - -ToolBoxProxy::ToolBoxProxy(QObject *parent, const QVariantList &args) - : AbstractToolBox(parent, args) -{ - d = new ToolBoxProxyPrivate; - d->containment = qobject_cast(parent); - d->appletInterface = 0; - init(); -} - -ToolBoxProxy::~ToolBoxProxy() -{ - delete d; -} - -void ToolBoxProxy::init() -{ - d->showing = false; - d->addPanelAction = 0; - d->addWidgetsAction = 0; - d->configureAction = 0; - - if (d->containment) { - connect(d->containment, SIGNAL(immutabilityChanged(Plasma::ImmutabilityType)), - this, SLOT(immutabilityChanged(Plasma::ImmutabilityType))); - connect(this, SIGNAL(configureRequested(Plasma::Containment*)), - d->containment, SIGNAL(configureRequested(Plasma::Containment*))); - connect(this, SIGNAL(showAddWidgetsInterface(const QPointF&)), - d->containment, SIGNAL(showAddWidgetsInterface(const QPointF&))); - } - loadActions(); -} - -void ToolBoxProxy::loadActions() -{ - d->actions.clear(); - if (d->containment) { - if (!d->configureAction) { - d->configureAction = new QAction(this); - d->configureAction->setText(i18n("%1 Settings", d->containment->name())); - d->configureAction->setIcon(KIcon("configure")); - d->configureAction->setObjectName("configure"); - connect(d->configureAction, SIGNAL(triggered()), this, SLOT(configureRequested())); - } - addTool(d->configureAction); - - if (d->appletInterface) { - foreach (QAction *action, d->appletInterface->contextualActions()) { - addTool(action); - } - } - foreach (QAction *action, d->containment->actions()) { - addTool(action); - } - foreach (QAction *action, d->containment->corona()->actions()) { - addTool(action); - } - if (!d->addWidgetsAction) { - d->addWidgetsAction = new QAction(this); - d->addWidgetsAction->setObjectName("add widgets"); - d->addWidgetsAction->setText(i18n("Add Widgets")); - d->addWidgetsAction->setIcon(KIcon("list-add")); - connect(d->addWidgetsAction, SIGNAL(triggered()), this, SLOT(addWidgetsRequested())); - } - if (d->appletInterface && !d->appletInterface->immutable()) { - addTool(d->addWidgetsAction); - } - } - emit actionsChanged(); -} - -QDeclarativeListProperty ToolBoxProxy::actions() -{ - return QDeclarativeListProperty(this, d->actions); -} - -void ToolBoxProxy::addTool(QAction *action) -{ - if (!action || d->actions.contains(action)) { - return; - } - if (d->appletInterface && d->appletInterface->immutable() && action->objectName() == "add panel") { - d->addPanelAction = action; - return; - } - connect(action, SIGNAL(destroyed(QObject*)), this, SLOT(actionDestroyed(QObject*)), Qt::UniqueConnection); - d->actions.append(action); -} - -void ToolBoxProxy::removeTool(QAction *action) -{ - disconnect(action, 0, this, 0); - d->actions.removeAll(action); - emit actionsChanged(); -} - -void ToolBoxProxy::actionDestroyed(QObject *object) -{ - d->actions.removeAll(static_cast(object)); -} - -void ToolBoxProxy::configureRequested() -{ - emit configureRequested(d->containment); -} - -void ToolBoxProxy::addWidgetsRequested() -{ - emit showAddWidgetsInterface(QPointF(0, 0)); -} - -bool ToolBoxProxy::isShowing() const -{ - return d->showing; -} - -void ToolBoxProxy::setShowing(const bool show) -{ - if (d->showing == show) { - return; - } - d->showing = show; -} - -void ToolBoxProxy::immutabilityChanged(Plasma::ImmutabilityType immutability) -{ - Q_UNUSED(immutability); - loadActions(); -} - -#include "toolboxproxy.moc" diff --git a/scriptengines/qml/declarative/toolboxproxy.h b/scriptengines/qml/declarative/toolboxproxy.h deleted file mode 100644 index 4e4573669..000000000 --- a/scriptengines/qml/declarative/toolboxproxy.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2007 by Aaron Seigo - * Copyright 2008 by Marco Martin - * Copyright 2012 by Sebastian Kügler - * - * 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. - */ - -#ifndef TOOLBOXPROXY_H -#define TOOLBOXPROXY_H - -#include -#include - -#include - -class QAction; - -class ToolBoxProxyPrivate; -class AppletInterface; - -class ToolBoxProxy : public Plasma::AbstractToolBox -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty actions READ actions NOTIFY actionsChanged) - -public: - explicit ToolBoxProxy(Plasma::Containment *parent, AppletInterface *appletInterface); - explicit ToolBoxProxy(QObject *parent = 0, const QVariantList &args = QVariantList()); - ~ToolBoxProxy(); - - bool isShowing() const; // satisfy badly named API - void setShowing(const bool show); - - QDeclarativeListProperty actions(); - -public Q_SLOTS: - void configureRequested(); - void addWidgetsRequested(); - -Q_SIGNALS: - void actionsChanged(); - void immutableChanged(); - - void configureRequested(Plasma::Containment* containment); - void showAddWidgetsInterface(const QPointF& pos); - -private Q_SLOTS: - void actionDestroyed(QObject *object); - void immutabilityChanged(Plasma::ImmutabilityType immutability); - -private: - void init(); - void loadActions(); - /** - * create a toolbox tool from the given action - * @p action the action to associate hte tool with - */ - void addTool(QAction *action); - /** - * remove the tool associated with this action - */ - void removeTool(QAction *action); - - ToolBoxProxyPrivate* d; -}; - -#endif // TOOLBOXPROXY_H