From 52e96b41df2e0a9826f7c3f2bdeaf33354e1d034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 11 Sep 2013 13:57:40 +0200 Subject: [PATCH 01/57] Ensure that the WindowThumbnail is not trying to render a thumbnail of itself Recursive window thumbnails would look awesome on the screen, but reality is that X/OpenGL or $DEITY doesn't like it at all and decided to just freeze the view. So let's delay all the redirecting till the WindowThumbnail has been added to its QQuickWindow and if the window id is the one of the own window we just render the icon instead. --- src/declarativeimports/core/windowthumbnail.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/declarativeimports/core/windowthumbnail.cpp b/src/declarativeimports/core/windowthumbnail.cpp index 5d99ca61e..3baf98145 100644 --- a/src/declarativeimports/core/windowthumbnail.cpp +++ b/src/declarativeimports/core/windowthumbnail.cpp @@ -71,6 +71,14 @@ WindowThumbnail::WindowThumbnail(QQuickItem* parent) #endif { setFlag(ItemHasContents); + connect(this, &QQuickItem::windowChanged, [this](QQuickWindow *window) { + if (!window) { + return; + } + // restart the redirection, it might not have been active yet + stopRedirecting(); + startRedirecting(); + }); if (QGuiApplication *gui = dynamic_cast(QCoreApplication::instance())) { m_xcb = (gui->platformName() == QStringLiteral("xcb")); if (m_xcb) { @@ -111,6 +119,10 @@ void WindowThumbnail::setWinId(uint32_t winId) // invalid Id, don't updated return; } + if (window() && winId == window()->winId()) { + // don't redirect to yourself + return; + } stopRedirecting(); m_winId = winId; startRedirecting(); @@ -125,7 +137,7 @@ QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData node = new WindowTextureNode(); node->setFiltering(QSGTexture::Linear); } - if (!m_xcb || m_winId == 0) { + if (!m_xcb || m_winId == 0 || (window() && window()->winId() == m_winId)) { iconToTexture(node); } else { windowToTexture(node); @@ -347,7 +359,7 @@ void WindowThumbnail::stopRedirecting() void WindowThumbnail::startRedirecting() { - if (!m_xcb) { + if (!m_xcb || !window() || window()->winId() == m_winId) { return; } #if HAVE_XCB_COMPOSITE From 6bf3f5478377b8e29bb1edfa087af064265f2581 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 14:40:11 +0200 Subject: [PATCH 02/57] configmodel in own file --- src/plasmaquick/CMakeLists.txt | 2 + src/plasmaquick/configmodel.cpp | 334 ++++++++++++++++++++ src/plasmaquick/configmodel.h | 102 ++++++ src/plasmaquick/configview.cpp | 292 +---------------- src/plasmaquick/configview.h | 79 +---- src/plasmaquick/containmentconfigview_p.cpp | 5 +- src/plasmaquick/containmentconfigview_p.h | 5 +- 7 files changed, 449 insertions(+), 370 deletions(-) create mode 100644 src/plasmaquick/configmodel.cpp create mode 100644 src/plasmaquick/configmodel.h diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index 4730a46fe..f95995b5a 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -2,6 +2,7 @@ project(PlasmaQuick) set(plasmaquick_LIB_SRC plasmaquickview.cpp + configmodel.cpp configview.cpp containmentconfigview_p.cpp currentcontainmentactionsmodel_p.cpp @@ -39,6 +40,7 @@ set(plasmaquick_LIB_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/plasmaquick_export.h plasmaquickview.h configview.h + configmodel.h ) install(FILES ${plasmaquick_LIB_INCLUDES} diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp new file mode 100644 index 000000000..7d7e75f0a --- /dev/null +++ b/src/plasmaquick/configmodel.cpp @@ -0,0 +1,334 @@ +/* + * Copyright 2013 Marco Martin + * + * 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 "configview_p.h" +#include "configview.h" +#include "configmodel.h" +#include "Plasma/Applet" +#include "Plasma/Containment" +//#include "plasmoid/wallpaperinterface.h" +#include "kdeclarative/configpropertymap.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +///////////////////////ConfigCategory + +ConfigCategory::ConfigCategory(QObject *parent) + : QObject(parent) +{ +} + +ConfigCategory::~ConfigCategory() +{} + +QString ConfigCategory::name() const +{ + return m_name; +} + +void ConfigCategory::setName(const QString &name) +{ + if (m_name == name) { + return; + } + + m_name = name; + emit nameChanged(); +} + + +QString ConfigCategory::icon() const +{ + return m_icon; +} + +void ConfigCategory::setIcon(const QString &icon) +{ + if (m_icon == icon) { + return; + } + + m_icon = icon; + emit iconChanged(); +} + + +QString ConfigCategory::source() const +{ + return m_source; +} + +void ConfigCategory::setSource(const QString &source) +{ + if (m_source == source) { + return; + } + + m_source = source; + emit sourceChanged(); +} + +QString ConfigCategory::pluginName() const +{ + return m_pluginName; +} + +void ConfigCategory::setPluginName(const QString &name) +{ + if (m_pluginName == name) { + return; + } + + m_pluginName = name; + emit pluginNameChanged(); +} + + + +//////////////////////////////ConfigModel + +class ConfigModelPrivate +{ +public: + ConfigModelPrivate(ConfigModel *model); + ~ConfigModelPrivate(); + + ConfigModel *q; + QList categories; + QWeakPointer appletInterface; + + void appendCategory(ConfigCategory *c); + void clear(); + QVariant get(int row) const; + + static ConfigCategory *categories_at(QQmlListProperty *prop, int index); + static void categories_append(QQmlListProperty *prop, ConfigCategory *o); + static int categories_count(QQmlListProperty *prop); + static void categories_clear(QQmlListProperty *prop); +}; + +ConfigModelPrivate::ConfigModelPrivate(ConfigModel *model) + : q(model) +{ +} + +ConfigModelPrivate::~ConfigModelPrivate() +{ +} + +ConfigCategory *ConfigModelPrivate::categories_at(QQmlListProperty *prop, int index) +{ + ConfigModel *model = qobject_cast(prop->object); + if (!model || index >= model->d->categories.count() || index < 0) { + return 0; + } else { + return model->d->categories.at(index); + } +} + +void ConfigModelPrivate::categories_append(QQmlListProperty *prop, ConfigCategory *o) +{ + ConfigModel *model = qobject_cast(prop->object); + if (!o || !model) { + return; + } + + if (o->parent() == prop->object) { + o->setParent(0); + } + + o->setParent(prop->object); + model->appendCategory(o); +} + +int ConfigModelPrivate::categories_count(QQmlListProperty *prop) +{ + ConfigModel *model = qobject_cast(prop->object); + if (model) { + return model->d->categories.count(); + } else { + return 0; + } +} + +void ConfigModelPrivate::categories_clear(QQmlListProperty *prop) +{ + ConfigModel *model = qobject_cast(prop->object); + if (!model) { + return; + } + + model->clear(); +} + +void ConfigModelPrivate::clear() +{ + q->beginResetModel(); + while (!categories.isEmpty()) { + categories.first()->setParent(0); + categories.pop_front(); + } + q->endResetModel(); + emit q->countChanged(); +} + +void ConfigModelPrivate::appendCategory(ConfigCategory *c) +{ + q->beginInsertRows(QModelIndex(), categories.size(), categories.size()); + categories.append(c); + q->endInsertRows(); + emit q->countChanged(); +} + +QVariant ConfigModelPrivate::get(int row) const +{ + QVariantMap value; + if (row < 0 || row >= categories.count()) { + return value; + } + + value["name"] = categories.at(row)->name(); + value["icon"] = categories.at(row)->icon(); + value["pluginName"] = categories.at(row)->pluginName(); + if (appletInterface) { + value["source"] = QUrl::fromLocalFile(appletInterface.data()->package().filePath("ui", categories.at(row)->source())); + } else { + value["source"] = categories.at(row)->source(); + } + return value; +} + + +ConfigModel::ConfigModel(QObject *parent) + : QAbstractListModel(parent), + d(new ConfigModelPrivate(this)) +{ + QHash roleNames; + roleNames[NameRole] = "name"; + roleNames[IconRole] = "icon"; + roleNames[SourceRole] = "source"; + roleNames[PluginNameRole] = "pluginName"; + + setRoleNames(roleNames); +} + +ConfigModel::~ConfigModel() +{ + delete d; +} + +int ConfigModel::rowCount(const QModelIndex &index) const +{ + if (index.column() > 0) { + return 0; + } + return d->categories.count(); +} + +QVariant ConfigModel::data(const QModelIndex& index, int role) const +{ + if (index.row() < 0 || index.row() >= d->categories.count()) { + return QVariant(); + } + switch (role) { + case NameRole: + return d->categories.at(index.row())->name(); + case IconRole: + return d->categories.at(index.row())->icon(); + case SourceRole: + if (d->appletInterface) { + return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", d->categories.at(index.row())->source())); + } else { + return d->categories.at(index.row())->source(); + } + case PluginNameRole: + return d->categories.at(index.row())->pluginName(); + default: + return QVariant(); + } +} + +QVariant ConfigModel::get(int row) const +{ + return d->get(row); +} + +void ConfigModel::appendCategory(ConfigCategory *c) +{ + d->appendCategory(c); +} + +void ConfigModel::clear() +{ + d->clear(); +} + +void ConfigModel::setApplet(Plasma::Applet *interface) +{ + d->appletInterface = interface; +} + +Plasma::Applet *ConfigModel::applet() const +{ + return d->appletInterface.data(); +} + +QQmlListProperty ConfigModel::categories() +{ + return QQmlListProperty(this, 0, ConfigModel::categories_append, + ConfigModel::categories_count, + ConfigModel::categories_at, + ConfigModel::categories_clear); + +} + +ConfigCategory *ConfigModel::categories_at(QQmlListProperty *prop, int index) +{ + return ConfigModelPrivate::categories_at(prop, index); +} + +void ConfigModel::categories_append(QQmlListProperty *prop, ConfigCategory *o) +{ + ConfigModelPrivate::categories_append(prop, o); +} + +int ConfigModel::categories_count(QQmlListProperty *prop) +{ + return ConfigModelPrivate::categories_count(prop); +} + +void ConfigModel::categories_clear(QQmlListProperty *prop) +{ + ConfigModelPrivate::categories_clear(prop); +} + + +#include "moc_configmodel.cpp" diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h new file mode 100644 index 000000000..1a49116ba --- /dev/null +++ b/src/plasmaquick/configmodel.h @@ -0,0 +1,102 @@ +/* + * Copyright 2013 Marco Martin + * + * 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 CONFIGMODEL_H +#define CONFIGMODEL_H + + +#include +#include + +#include + +namespace Plasma { + class Applet; +} + +class ConfigPropertyMap; + +class ConfigCategoryPrivate; + +class ConfigModelPrivate; +class ConfigCategory; + +class PLASMAQUICK_EXPORT ConfigModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty categories READ categories CONSTANT) + Q_CLASSINFO("DefaultProperty", "categories") + Q_PROPERTY(int count READ count NOTIFY countChanged) + +public: + enum Roles { + NameRole = Qt::UserRole+1, + IconRole, + SourceRole, + PluginNameRole + }; + ConfigModel(QObject *parent = 0); + ~ConfigModel(); + + /** + * add a new category in the model + * @param ConfigCategory the new category + **/ + void appendCategory(ConfigCategory *c); + + /** + * clears the model + **/ + void clear(); + + void setApplet(Plasma::Applet *interface); + Plasma::Applet *applet() const; + + int count() {return rowCount();} + virtual int rowCount(const QModelIndex &index = QModelIndex()) const; + virtual QVariant data(const QModelIndex&, int) const; + + /** + * @param row the row for which the data will be returned + * @raturn the data of the specified row + **/ + Q_INVOKABLE QVariant get(int row) const; + + /** + * @return the categories of the model + **/ + QQmlListProperty categories(); + + static ConfigCategory *categories_at(QQmlListProperty *prop, int index); + static void categories_append(QQmlListProperty *prop, ConfigCategory *o); + static int categories_count(QQmlListProperty *prop); + static void categories_clear(QQmlListProperty *prop); + +Q_SIGNALS: + /** + * emitted when the count is changed + **/ + void countChanged(); + +private: + friend class ConfigModelPrivate; + ConfigModelPrivate *const d; +}; + +#endif // multiple inclusion guard diff --git a/src/plasmaquick/configview.cpp b/src/plasmaquick/configview.cpp index 4f0caeb24..dfdd24e0a 100644 --- a/src/plasmaquick/configview.cpp +++ b/src/plasmaquick/configview.cpp @@ -19,6 +19,7 @@ #include "configview_p.h" #include "configview.h" +#include "configmodel.h" #include "Plasma/Applet" #include "Plasma/Containment" //#include "plasmoid/wallpaperinterface.h" @@ -38,297 +39,6 @@ #include #include -///////////////////////ConfigCategory - -ConfigCategory::ConfigCategory(QObject *parent) - : QObject(parent) -{ -} - -ConfigCategory::~ConfigCategory() -{} - -QString ConfigCategory::name() const -{ - return m_name; -} - -void ConfigCategory::setName(const QString &name) -{ - if (m_name == name) { - return; - } - - m_name = name; - emit nameChanged(); -} - - -QString ConfigCategory::icon() const -{ - return m_icon; -} - -void ConfigCategory::setIcon(const QString &icon) -{ - if (m_icon == icon) { - return; - } - - m_icon = icon; - emit iconChanged(); -} - - -QString ConfigCategory::source() const -{ - return m_source; -} - -void ConfigCategory::setSource(const QString &source) -{ - if (m_source == source) { - return; - } - - m_source = source; - emit sourceChanged(); -} - -QString ConfigCategory::pluginName() const -{ - return m_pluginName; -} - -void ConfigCategory::setPluginName(const QString &name) -{ - if (m_pluginName == name) { - return; - } - - m_pluginName = name; - emit pluginNameChanged(); -} - - - -//////////////////////////////ConfigModel - -class ConfigModelPrivate -{ -public: - ConfigModelPrivate(ConfigModel *model); - ~ConfigModelPrivate(); - - ConfigModel *q; - QList categories; - QWeakPointer appletInterface; - - void appendCategory(ConfigCategory *c); - void clear(); - QVariant get(int row) const; - - static ConfigCategory *categories_at(QQmlListProperty *prop, int index); - static void categories_append(QQmlListProperty *prop, ConfigCategory *o); - static int categories_count(QQmlListProperty *prop); - static void categories_clear(QQmlListProperty *prop); -}; - -ConfigModelPrivate::ConfigModelPrivate(ConfigModel *model) - : q(model) -{ -} - -ConfigModelPrivate::~ConfigModelPrivate() -{ -} - -ConfigCategory *ConfigModelPrivate::categories_at(QQmlListProperty *prop, int index) -{ - ConfigModel *model = qobject_cast(prop->object); - if (!model || index >= model->d->categories.count() || index < 0) { - return 0; - } else { - return model->d->categories.at(index); - } -} - -void ConfigModelPrivate::categories_append(QQmlListProperty *prop, ConfigCategory *o) -{ - ConfigModel *model = qobject_cast(prop->object); - if (!o || !model) { - return; - } - - if (o->parent() == prop->object) { - o->setParent(0); - } - - o->setParent(prop->object); - model->appendCategory(o); -} - -int ConfigModelPrivate::categories_count(QQmlListProperty *prop) -{ - ConfigModel *model = qobject_cast(prop->object); - if (model) { - return model->d->categories.count(); - } else { - return 0; - } -} - -void ConfigModelPrivate::categories_clear(QQmlListProperty *prop) -{ - ConfigModel *model = qobject_cast(prop->object); - if (!model) { - return; - } - - model->clear(); -} - -void ConfigModelPrivate::clear() -{ - q->beginResetModel(); - while (!categories.isEmpty()) { - categories.first()->setParent(0); - categories.pop_front(); - } - q->endResetModel(); - emit q->countChanged(); -} - -void ConfigModelPrivate::appendCategory(ConfigCategory *c) -{ - q->beginInsertRows(QModelIndex(), categories.size(), categories.size()); - categories.append(c); - q->endInsertRows(); - emit q->countChanged(); -} - -QVariant ConfigModelPrivate::get(int row) const -{ - QVariantMap value; - if (row < 0 || row >= categories.count()) { - return value; - } - - value["name"] = categories.at(row)->name(); - value["icon"] = categories.at(row)->icon(); - value["pluginName"] = categories.at(row)->pluginName(); - if (appletInterface) { - value["source"] = QUrl::fromLocalFile(appletInterface.data()->package().filePath("ui", categories.at(row)->source())); - } else { - value["source"] = categories.at(row)->source(); - } - return value; -} - - -ConfigModel::ConfigModel(QObject *parent) - : QAbstractListModel(parent), - d(new ConfigModelPrivate(this)) -{ - QHash roleNames; - roleNames[NameRole] = "name"; - roleNames[IconRole] = "icon"; - roleNames[SourceRole] = "source"; - roleNames[PluginNameRole] = "pluginName"; - - setRoleNames(roleNames); -} - -ConfigModel::~ConfigModel() -{ - delete d; -} - -int ConfigModel::rowCount(const QModelIndex &index) const -{ - if (index.column() > 0) { - return 0; - } - return d->categories.count(); -} - -QVariant ConfigModel::data(const QModelIndex& index, int role) const -{ - if (index.row() < 0 || index.row() >= d->categories.count()) { - return QVariant(); - } - switch (role) { - case NameRole: - return d->categories.at(index.row())->name(); - case IconRole: - return d->categories.at(index.row())->icon(); - case SourceRole: - if (d->appletInterface) { - return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", d->categories.at(index.row())->source())); - } else { - return d->categories.at(index.row())->source(); - } - case PluginNameRole: - return d->categories.at(index.row())->pluginName(); - default: - return QVariant(); - } -} - -QVariant ConfigModel::get(int row) const -{ - return d->get(row); -} - -void ConfigModel::appendCategory(ConfigCategory *c) -{ - d->appendCategory(c); -} - -void ConfigModel::clear() -{ - d->clear(); -} - -void ConfigModel::setApplet(Plasma::Applet *interface) -{ - d->appletInterface = interface; -} - -Plasma::Applet *ConfigModel::applet() const -{ - return d->appletInterface.data(); -} - -QQmlListProperty ConfigModel::categories() -{ - return QQmlListProperty(this, 0, ConfigModel::categories_append, - ConfigModel::categories_count, - ConfigModel::categories_at, - ConfigModel::categories_clear); - -} - -ConfigCategory *ConfigModel::categories_at(QQmlListProperty *prop, int index) -{ - return ConfigModelPrivate::categories_at(prop, index); -} - -void ConfigModel::categories_append(QQmlListProperty *prop, ConfigCategory *o) -{ - ConfigModelPrivate::categories_append(prop, o); -} - -int ConfigModel::categories_count(QQmlListProperty *prop) -{ - return ConfigModelPrivate::categories_count(prop); -} - -void ConfigModel::categories_clear(QQmlListProperty *prop) -{ - ConfigModelPrivate::categories_clear(prop); -} - //////////////////////////////ConfigView diff --git a/src/plasmaquick/configview.h b/src/plasmaquick/configview.h index 7e72421bc..bd1a86df2 100644 --- a/src/plasmaquick/configview.h +++ b/src/plasmaquick/configview.h @@ -17,14 +17,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef CONFIGUILOADER_H -#define CONFIGUILOADER_H +#ifndef CONFIGVIEW_H +#define CONFIGVIEW_H #include -#include -#include -#include #include @@ -32,78 +29,10 @@ namespace Plasma { class Applet; } -class ConfigPropertyMap; - -class ConfigCategoryPrivate; - -class ConfigModelPrivate; -class ConfigCategory; - -class PLASMAQUICK_EXPORT ConfigModel : public QAbstractListModel -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty categories READ categories CONSTANT) - Q_CLASSINFO("DefaultProperty", "categories") - Q_PROPERTY(int count READ count NOTIFY countChanged) - -public: - enum Roles { - NameRole = Qt::UserRole+1, - IconRole, - SourceRole, - PluginNameRole - }; - ConfigModel(QObject *parent = 0); - ~ConfigModel(); - - /** - * add a new category in the model - * @param ConfigCategory the new category - **/ - void appendCategory(ConfigCategory *c); - - /** - * clears the model - **/ - void clear(); - - void setApplet(Plasma::Applet *interface); - Plasma::Applet *applet() const; - - int count() {return rowCount();} - virtual int rowCount(const QModelIndex &index = QModelIndex()) const; - virtual QVariant data(const QModelIndex&, int) const; - - /** - * @param row the row for which the data will be returned - * @raturn the data of the specified row - **/ - Q_INVOKABLE QVariant get(int row) const; - - /** - * @return the categories of the model - **/ - QQmlListProperty categories(); - - static ConfigCategory *categories_at(QQmlListProperty *prop, int index); - static void categories_append(QQmlListProperty *prop, ConfigCategory *o); - static int categories_count(QQmlListProperty *prop); - static void categories_clear(QQmlListProperty *prop); - -Q_SIGNALS: - /** - * emitted when the count is changed - **/ - void countChanged(); - -private: - friend class ConfigModelPrivate; - ConfigModelPrivate *const d; -}; - - class ConfigViewPrivate; +class ConfigModel; + class PLASMAQUICK_EXPORT ConfigView : public QQuickView { Q_OBJECT diff --git a/src/plasmaquick/containmentconfigview_p.cpp b/src/plasmaquick/containmentconfigview_p.cpp index 15023fed8..a668aaf04 100644 --- a/src/plasmaquick/containmentconfigview_p.cpp +++ b/src/plasmaquick/containmentconfigview_p.cpp @@ -20,6 +20,7 @@ #include "currentcontainmentactionsmodel_p.h" #include "containmentconfigview_p.h" #include "configview_p.h" +#include "configmodel.h" #include @@ -45,7 +46,7 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow m_currentWallpaperConfig(0), m_ownWallpaperConfig(0) { - qmlRegisterType(); + qmlRegisterType(); engine()->rootContext()->setContextProperty("configDialog", this); setCurrentWallpaper(cont->containment()->wallpaper()); @@ -90,7 +91,7 @@ ConfigModel *ContainmentConfigView::containmentActionConfigModel() return m_containmentActionConfigModel; } -QStandardItemModel *ContainmentConfigView::currentContainmentActionsModel() +QAbstractItemModel *ContainmentConfigView::currentContainmentActionsModel() { if (!m_currentContainmentActionsModel) { m_currentContainmentActionsModel = new CurrentContainmentActionsModel(m_containment, this); diff --git a/src/plasmaquick/containmentconfigview_p.h b/src/plasmaquick/containmentconfigview_p.h index eefea0abf..f6239dc2d 100644 --- a/src/plasmaquick/containmentconfigview_p.h +++ b/src/plasmaquick/containmentconfigview_p.h @@ -28,6 +28,7 @@ namespace Plasma { class Containment; } +class QAbstractItemModel; class ConfigPropertyMap; class CurrentContainmentActionsModel; @@ -36,7 +37,7 @@ class ContainmentConfigView : public ConfigView { Q_OBJECT Q_PROPERTY(ConfigModel *containmentActionConfigModel READ containmentActionConfigModel CONSTANT) - Q_PROPERTY(QStandardItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT) + Q_PROPERTY(QAbstractItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT) Q_PROPERTY(ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT) Q_PROPERTY(ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged) Q_PROPERTY(QString currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged) @@ -48,7 +49,7 @@ public: virtual void init(); ConfigModel *containmentActionConfigModel(); - QStandardItemModel *currentContainmentActionsModel(); + QAbstractItemModel *currentContainmentActionsModel(); ConfigModel *wallpaperConfigModel(); QString currentWallpaper() const; void setCurrentWallpaper(const QString &wallpaper); From 2c108e00360f7d5824cd32543057fe0c6c7a4b85 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 14:44:28 +0200 Subject: [PATCH 03/57] get rid of QQmlListProperty accessors in public clas --- src/plasmaquick/configmodel.cpp | 28 ++++------------------------ src/plasmaquick/configmodel.h | 5 ----- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index 7d7e75f0a..f188ebd59 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -303,32 +303,12 @@ Plasma::Applet *ConfigModel::applet() const QQmlListProperty ConfigModel::categories() { - return QQmlListProperty(this, 0, ConfigModel::categories_append, - ConfigModel::categories_count, - ConfigModel::categories_at, - ConfigModel::categories_clear); + return QQmlListProperty(this, 0, ConfigModelPrivate::categories_append, + ConfigModelPrivate::categories_count, + ConfigModelPrivate::categories_at, + ConfigModelPrivate::categories_clear); } -ConfigCategory *ConfigModel::categories_at(QQmlListProperty *prop, int index) -{ - return ConfigModelPrivate::categories_at(prop, index); -} - -void ConfigModel::categories_append(QQmlListProperty *prop, ConfigCategory *o) -{ - ConfigModelPrivate::categories_append(prop, o); -} - -int ConfigModel::categories_count(QQmlListProperty *prop) -{ - return ConfigModelPrivate::categories_count(prop); -} - -void ConfigModel::categories_clear(QQmlListProperty *prop) -{ - ConfigModelPrivate::categories_clear(prop); -} - #include "moc_configmodel.cpp" diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index 1a49116ba..daa9cced3 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -83,11 +83,6 @@ public: **/ QQmlListProperty categories(); - static ConfigCategory *categories_at(QQmlListProperty *prop, int index); - static void categories_append(QQmlListProperty *prop, ConfigCategory *o); - static int categories_count(QQmlListProperty *prop); - static void categories_clear(QQmlListProperty *prop); - Q_SIGNALS: /** * emitted when the count is changed From 819bece75585ad8eae9bd48a52b7314d9c41aeba Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 14:55:10 +0200 Subject: [PATCH 04/57] ppendCategory with data to avoif exposin ConfigCategory --- src/plasmaquick/configmodel.cpp | 12 +++++++++--- src/plasmaquick/configmodel.h | 3 ++- src/plasmaquick/containmentconfigview_p.cpp | 14 ++------------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index f188ebd59..25ed2f5b3 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -166,7 +166,7 @@ void ConfigModelPrivate::categories_append(QQmlListProperty *pro } o->setParent(prop->object); - model->appendCategory(o); + model->d->appendCategory(o); } int ConfigModelPrivate::categories_count(QQmlListProperty *prop) @@ -281,9 +281,15 @@ QVariant ConfigModel::get(int row) const return d->get(row); } -void ConfigModel::appendCategory(ConfigCategory *c) +void ConfigModel::appendCategory(const QString &iconName, const QString &name, + const QString &path, const QString &pluginName) { - d->appendCategory(c); + ConfigCategory *cat = new ConfigCategory(this); + cat->setIcon(iconName); + cat->setName(name); + cat->setSource(path); + cat->setPluginName(pluginName); + d->appendCategory(cat); } void ConfigModel::clear() diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index daa9cced3..8858c36dc 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -58,7 +58,8 @@ public: * add a new category in the model * @param ConfigCategory the new category **/ - void appendCategory(ConfigCategory *c); + void appendCategory(const QString &iconName, const QString &name, + const QString &path, const QString &pluginName); /** * clears the model diff --git a/src/plasmaquick/containmentconfigview_p.cpp b/src/plasmaquick/containmentconfigview_p.cpp index a668aaf04..30a279a2e 100644 --- a/src/plasmaquick/containmentconfigview_p.cpp +++ b/src/plasmaquick/containmentconfigview_p.cpp @@ -79,12 +79,7 @@ ConfigModel *ContainmentConfigView::containmentActionConfigModel() foreach (const KPluginInfo &info, actions) { pkg.setDefaultPackageRoot(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/containmentactions", QStandardPaths::LocateDirectory)); - ConfigCategory *cat = new ConfigCategory(m_containmentActionConfigModel); - cat->setName(info.name()); - cat->setIcon(info.icon()); - cat->setSource(pkg.filePath("ui", "config.qml")); - cat->setPluginName(info.pluginName()); - m_containmentActionConfigModel->appendCategory(cat); + m_containmentActionConfigModel->appendCategory(info.icon(), info.name(), pkg.filePath("ui", "config.qml"), info.pluginName()); } } @@ -122,12 +117,7 @@ ConfigModel *ContainmentConfigView::wallpaperConfigModel() if (!pkg.isValid()) { continue; } - ConfigCategory *cat = new ConfigCategory(m_wallpaperConfigModel); - cat->setName(pkg.metadata().name()); - cat->setIcon(pkg.metadata().icon()); - cat->setSource(pkg.filePath("ui", "config.qml")); - cat->setPluginName(package); - m_wallpaperConfigModel->appendCategory(cat); + m_wallpaperConfigModel->appendCategory(pkg.metadata().icon(), pkg.metadata().name(), pkg.filePath("ui", "config.qml"), package); } } } From c33282e37f41078bc41a974a4441b20b3519aa54 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 15:13:31 +0200 Subject: [PATCH 05/57] move configcategory in own file --- src/plasmaquick/CMakeLists.txt | 1 + src/plasmaquick/configcategory_p.cpp | 115 ++++++++++++++++++ .../{configview_p.h => configcategory_p.h} | 4 +- src/plasmaquick/configmodel.cpp | 75 +----------- src/plasmaquick/configview.cpp | 2 +- src/plasmaquick/containmentconfigview_p.cpp | 2 +- src/plasmaquick/containmentconfigview_p.h | 2 +- .../currentcontainmentactionsmodel_p.h | 1 + 8 files changed, 123 insertions(+), 79 deletions(-) create mode 100644 src/plasmaquick/configcategory_p.cpp rename src/plasmaquick/{configview_p.h => configcategory_p.h} (97%) diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index f95995b5a..8e32425d3 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -2,6 +2,7 @@ project(PlasmaQuick) set(plasmaquick_LIB_SRC plasmaquickview.cpp + configcategory_p.cpp configmodel.cpp configview.cpp containmentconfigview_p.cpp diff --git a/src/plasmaquick/configcategory_p.cpp b/src/plasmaquick/configcategory_p.cpp new file mode 100644 index 000000000..0d4275dd4 --- /dev/null +++ b/src/plasmaquick/configcategory_p.cpp @@ -0,0 +1,115 @@ +/* + * Copyright 2013 Marco Martin + * + * 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 "configcategory_p.h" +#include "configview.h" +#include "configmodel.h" +#include "Plasma/Applet" +#include "Plasma/Containment" +//#include "plasmoid/wallpaperinterface.h" +#include "kdeclarative/configpropertymap.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +///////////////////////ConfigCategory + +ConfigCategory::ConfigCategory(QObject *parent) + : QObject(parent) +{ +} + +ConfigCategory::~ConfigCategory() +{} + +QString ConfigCategory::name() const +{ + return m_name; +} + +void ConfigCategory::setName(const QString &name) +{ + if (m_name == name) { + return; + } + + m_name = name; + emit nameChanged(); +} + + +QString ConfigCategory::icon() const +{ + return m_icon; +} + +void ConfigCategory::setIcon(const QString &icon) +{ + if (m_icon == icon) { + return; + } + + m_icon = icon; + emit iconChanged(); +} + + +QString ConfigCategory::source() const +{ + return m_source; +} + +void ConfigCategory::setSource(const QString &source) +{ + if (m_source == source) { + return; + } + + m_source = source; + emit sourceChanged(); +} + +QString ConfigCategory::pluginName() const +{ + return m_pluginName; +} + +void ConfigCategory::setPluginName(const QString &name) +{ + if (m_pluginName == name) { + return; + } + + m_pluginName = name; + emit pluginNameChanged(); +} + + +#include "moc_configcategory_p.cpp" diff --git a/src/plasmaquick/configview_p.h b/src/plasmaquick/configcategory_p.h similarity index 97% rename from src/plasmaquick/configview_p.h rename to src/plasmaquick/configcategory_p.h index ed716abdc..6c1df10d8 100644 --- a/src/plasmaquick/configview_p.h +++ b/src/plasmaquick/configcategory_p.h @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef CONFIGUILOADER_P_H -#define CONFIGUILOADER_P_H +#ifndef CONFIGCATEGORY_P_H +#define CONFIGCATEGORY_P_H #include diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index 25ed2f5b3..362ec5e78 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "configview_p.h" +#include "configcategory_p.h" #include "configview.h" #include "configmodel.h" #include "Plasma/Applet" @@ -39,79 +39,6 @@ #include #include -///////////////////////ConfigCategory - -ConfigCategory::ConfigCategory(QObject *parent) - : QObject(parent) -{ -} - -ConfigCategory::~ConfigCategory() -{} - -QString ConfigCategory::name() const -{ - return m_name; -} - -void ConfigCategory::setName(const QString &name) -{ - if (m_name == name) { - return; - } - - m_name = name; - emit nameChanged(); -} - - -QString ConfigCategory::icon() const -{ - return m_icon; -} - -void ConfigCategory::setIcon(const QString &icon) -{ - if (m_icon == icon) { - return; - } - - m_icon = icon; - emit iconChanged(); -} - - -QString ConfigCategory::source() const -{ - return m_source; -} - -void ConfigCategory::setSource(const QString &source) -{ - if (m_source == source) { - return; - } - - m_source = source; - emit sourceChanged(); -} - -QString ConfigCategory::pluginName() const -{ - return m_pluginName; -} - -void ConfigCategory::setPluginName(const QString &name) -{ - if (m_pluginName == name) { - return; - } - - m_pluginName = name; - emit pluginNameChanged(); -} - - //////////////////////////////ConfigModel diff --git a/src/plasmaquick/configview.cpp b/src/plasmaquick/configview.cpp index dfdd24e0a..215f85e23 100644 --- a/src/plasmaquick/configview.cpp +++ b/src/plasmaquick/configview.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "configview_p.h" +#include "configcategory_p.h" #include "configview.h" #include "configmodel.h" #include "Plasma/Applet" diff --git a/src/plasmaquick/containmentconfigview_p.cpp b/src/plasmaquick/containmentconfigview_p.cpp index 30a279a2e..74a1f9575 100644 --- a/src/plasmaquick/containmentconfigview_p.cpp +++ b/src/plasmaquick/containmentconfigview_p.cpp @@ -19,7 +19,7 @@ #include "currentcontainmentactionsmodel_p.h" #include "containmentconfigview_p.h" -#include "configview_p.h" +#include "configcategory_p.h" #include "configmodel.h" #include diff --git a/src/plasmaquick/containmentconfigview_p.h b/src/plasmaquick/containmentconfigview_p.h index f6239dc2d..2f343e6d4 100644 --- a/src/plasmaquick/containmentconfigview_p.h +++ b/src/plasmaquick/containmentconfigview_p.h @@ -32,7 +32,7 @@ class QAbstractItemModel; class ConfigPropertyMap; class CurrentContainmentActionsModel; - +//TODO: out of the library? class ContainmentConfigView : public ConfigView { Q_OBJECT diff --git a/src/plasmaquick/currentcontainmentactionsmodel_p.h b/src/plasmaquick/currentcontainmentactionsmodel_p.h index db94da1e4..c30630829 100644 --- a/src/plasmaquick/currentcontainmentactionsmodel_p.h +++ b/src/plasmaquick/currentcontainmentactionsmodel_p.h @@ -30,6 +30,7 @@ namespace Plasma { class ContainmentActions; } +//TODO: out of the library? class CurrentContainmentActionsModel : public QStandardItemModel { Q_OBJECT From 5b5c1a5a1c0ad8574dbb81b881a8b64a0fdba9a7 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 15:18:19 +0200 Subject: [PATCH 06/57] move private stuff in private/ --- src/plasmaquick/CMakeLists.txt | 6 +++--- src/plasmaquick/configmodel.cpp | 2 +- src/plasmaquick/configview.cpp | 2 +- src/plasmaquick/plasmaquickview.cpp | 2 +- src/plasmaquick/{ => private}/configcategory_p.cpp | 2 +- src/plasmaquick/{ => private}/configcategory_p.h | 0 src/plasmaquick/{ => private}/containmentconfigview_p.cpp | 2 +- src/plasmaquick/{ => private}/containmentconfigview_p.h | 0 .../{ => private}/currentcontainmentactionsmodel_p.cpp | 2 +- .../{ => private}/currentcontainmentactionsmodel_p.h | 0 10 files changed, 9 insertions(+), 9 deletions(-) rename src/plasmaquick/{ => private}/configcategory_p.cpp (98%) rename src/plasmaquick/{ => private}/configcategory_p.h (100%) rename src/plasmaquick/{ => private}/containmentconfigview_p.cpp (99%) rename src/plasmaquick/{ => private}/containmentconfigview_p.h (100%) rename src/plasmaquick/{ => private}/currentcontainmentactionsmodel_p.cpp (99%) rename src/plasmaquick/{ => private}/currentcontainmentactionsmodel_p.h (100%) diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index 8e32425d3..9c3bd77b8 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -2,11 +2,11 @@ project(PlasmaQuick) set(plasmaquick_LIB_SRC plasmaquickview.cpp - configcategory_p.cpp configmodel.cpp configview.cpp - containmentconfigview_p.cpp - currentcontainmentactionsmodel_p.cpp + private/configcategory_p.cpp + private/containmentconfigview_p.cpp + private/currentcontainmentactionsmodel_p.cpp ) diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp index 362ec5e78..0cbb515e2 100644 --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "configcategory_p.h" +#include "private/configcategory_p.h" #include "configview.h" #include "configmodel.h" #include "Plasma/Applet" diff --git a/src/plasmaquick/configview.cpp b/src/plasmaquick/configview.cpp index 215f85e23..0d8253de5 100644 --- a/src/plasmaquick/configview.cpp +++ b/src/plasmaquick/configview.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "configcategory_p.h" +#include "private/configcategory_p.h" #include "configview.h" #include "configmodel.h" #include "Plasma/Applet" diff --git a/src/plasmaquick/plasmaquickview.cpp b/src/plasmaquick/plasmaquickview.cpp index ecab1b1af..540fd58d5 100644 --- a/src/plasmaquick/plasmaquickview.cpp +++ b/src/plasmaquick/plasmaquickview.cpp @@ -17,7 +17,7 @@ */ #include "plasmaquickview.h" -#include "containmentconfigview_p.h" +#include "private/containmentconfigview_p.h" #include "configview.h" #include diff --git a/src/plasmaquick/configcategory_p.cpp b/src/plasmaquick/private/configcategory_p.cpp similarity index 98% rename from src/plasmaquick/configcategory_p.cpp rename to src/plasmaquick/private/configcategory_p.cpp index 0d4275dd4..5733409be 100644 --- a/src/plasmaquick/configcategory_p.cpp +++ b/src/plasmaquick/private/configcategory_p.cpp @@ -112,4 +112,4 @@ void ConfigCategory::setPluginName(const QString &name) } -#include "moc_configcategory_p.cpp" +#include "private/moc_configcategory_p.cpp" diff --git a/src/plasmaquick/configcategory_p.h b/src/plasmaquick/private/configcategory_p.h similarity index 100% rename from src/plasmaquick/configcategory_p.h rename to src/plasmaquick/private/configcategory_p.h diff --git a/src/plasmaquick/containmentconfigview_p.cpp b/src/plasmaquick/private/containmentconfigview_p.cpp similarity index 99% rename from src/plasmaquick/containmentconfigview_p.cpp rename to src/plasmaquick/private/containmentconfigview_p.cpp index 74a1f9575..8b1deb504 100644 --- a/src/plasmaquick/containmentconfigview_p.cpp +++ b/src/plasmaquick/private/containmentconfigview_p.cpp @@ -182,4 +182,4 @@ void ContainmentConfigView::syncWallpaperObjects() m_currentWallpaperConfig = static_cast(wallpaperGraphicsObject->property("configuration").value()); } -#include "moc_containmentconfigview_p.cpp" +#include "private/moc_containmentconfigview_p.cpp" diff --git a/src/plasmaquick/containmentconfigview_p.h b/src/plasmaquick/private/containmentconfigview_p.h similarity index 100% rename from src/plasmaquick/containmentconfigview_p.h rename to src/plasmaquick/private/containmentconfigview_p.h diff --git a/src/plasmaquick/currentcontainmentactionsmodel_p.cpp b/src/plasmaquick/private/currentcontainmentactionsmodel_p.cpp similarity index 99% rename from src/plasmaquick/currentcontainmentactionsmodel_p.cpp rename to src/plasmaquick/private/currentcontainmentactionsmodel_p.cpp index 0b98da3e9..7a15ee21b 100644 --- a/src/plasmaquick/currentcontainmentactionsmodel_p.cpp +++ b/src/plasmaquick/private/currentcontainmentactionsmodel_p.cpp @@ -259,4 +259,4 @@ void CurrentContainmentActionsModel::save() } } -#include "moc_currentcontainmentactionsmodel_p.cpp" +#include "private/moc_currentcontainmentactionsmodel_p.cpp" diff --git a/src/plasmaquick/currentcontainmentactionsmodel_p.h b/src/plasmaquick/private/currentcontainmentactionsmodel_p.h similarity index 100% rename from src/plasmaquick/currentcontainmentactionsmodel_p.h rename to src/plasmaquick/private/currentcontainmentactionsmodel_p.h From 6e3b20a3e6d18df2ac60583728e4ffd18c8f6226 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 15:26:16 +0200 Subject: [PATCH 07/57] some documentation --- src/plasmaquick/configmodel.h | 5 +++++ src/plasmaquick/private/configcategory_p.h | 2 ++ src/plasmaquick/private/currentcontainmentactionsmodel_p.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index 8858c36dc..c158c16de 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -37,6 +37,11 @@ class ConfigCategoryPrivate; class ConfigModelPrivate; class ConfigCategory; +/** + * This model contains all the possible config categories for a dialog, + * such as categories of the config dialog for an Applet + * TODO: it should probably become an import instead of a library? + */ class PLASMAQUICK_EXPORT ConfigModel : public QAbstractListModel { Q_OBJECT diff --git a/src/plasmaquick/private/configcategory_p.h b/src/plasmaquick/private/configcategory_p.h index 6c1df10d8..3ea208a7a 100644 --- a/src/plasmaquick/private/configcategory_p.h +++ b/src/plasmaquick/private/configcategory_p.h @@ -22,6 +22,8 @@ #include +//This class represents a single row item of the ConfigModel model in a QML friendly manner. +//the properties contains all the data needed to represent an icon in the sidebar of a configuration dialog, of applets or containments class ConfigCategory : public QObject { Q_OBJECT diff --git a/src/plasmaquick/private/currentcontainmentactionsmodel_p.h b/src/plasmaquick/private/currentcontainmentactionsmodel_p.h index c30630829..66a9476a0 100644 --- a/src/plasmaquick/private/currentcontainmentactionsmodel_p.h +++ b/src/plasmaquick/private/currentcontainmentactionsmodel_p.h @@ -30,6 +30,7 @@ namespace Plasma { class ContainmentActions; } +//This model load the data about available containment actions plugins, such as context menus that can be loaded on mouse click //TODO: out of the library? class CurrentContainmentActionsModel : public QStandardItemModel { From cdc778f417c667e3aa12c0dc2685c383f5ab8dba Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 17:39:09 +0200 Subject: [PATCH 08/57] test applet for config uis --- examples/applets/CMakeLists.txt | 1 + .../contents/ui/configGeneral.qml | 5 +- .../applets/config/contents/config/config.qml | 34 +++++++++++ .../applets/config/contents/config/main.xml | 25 ++++++++ .../config/contents/ui/configGeneral.qml | 57 +++++++++++++++++++ examples/applets/config/contents/ui/main.qml | 56 ++++++++++++++++++ examples/applets/config/metadata.desktop | 17 ++++++ .../qml/private/DualStateButton.qml | 1 + 8 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 examples/applets/config/contents/config/config.qml create mode 100644 examples/applets/config/contents/config/main.xml create mode 100644 examples/applets/config/contents/ui/configGeneral.qml create mode 100644 examples/applets/config/contents/ui/main.qml create mode 100644 examples/applets/config/metadata.desktop diff --git a/examples/applets/CMakeLists.txt b/examples/applets/CMakeLists.txt index ef2e1ef11..ef7e80689 100644 --- a/examples/applets/CMakeLists.txt +++ b/examples/applets/CMakeLists.txt @@ -1,4 +1,5 @@ +plasma_install_package(config org.kde.example.configuration) plasma_install_package(localegallery org.kde.example.locale) plasma_install_package(widgetgallery org.kde.example.widgetgallery) plasma_install_package(qmltasks org.kde.example.tasks) diff --git a/examples/applets/conditionalloader/contents/ui/configGeneral.qml b/examples/applets/conditionalloader/contents/ui/configGeneral.qml index e7a54e1d2..63e579473 100644 --- a/examples/applets/conditionalloader/contents/ui/configGeneral.qml +++ b/examples/applets/conditionalloader/contents/ui/configGeneral.qml @@ -17,6 +17,7 @@ */ import QtQuick 2.0 +import QtQuick.Controls 1.0 as QtControls import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents @@ -36,10 +37,10 @@ Item { anchors.fill: parent spacing: 4 Row { - PlasmaComponents.Label { + QtControls.Label { text: "Text Config value" } - PlasmaComponents.TextField { + QtControls.TextField { id: testConfigField } } diff --git a/examples/applets/config/contents/config/config.qml b/examples/applets/config/contents/config/config.qml new file mode 100644 index 000000000..1cace8db4 --- /dev/null +++ b/examples/applets/config/contents/config/config.qml @@ -0,0 +1,34 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.0 + +import org.kde.plasma.configuration 2.0 + +ConfigModel { + ConfigCategory { + name: "General" + icon: "plasma" + source: "configGeneral.qml" + } + ConfigCategory { + name: "Other page" + icon: "konqueror" + source: "configSecondPage.qml" + } +} diff --git a/examples/applets/config/contents/config/main.xml b/examples/applets/config/contents/config/main.xml new file mode 100644 index 000000000..9f6f0b9ce --- /dev/null +++ b/examples/applets/config/contents/config/main.xml @@ -0,0 +1,25 @@ + + + + + + + + test + + + true + + + + + + + test2 + + + + diff --git a/examples/applets/config/contents/ui/configGeneral.qml b/examples/applets/config/contents/ui/configGeneral.qml new file mode 100644 index 000000000..15fb4e41b --- /dev/null +++ b/examples/applets/config/contents/ui/configGeneral.qml @@ -0,0 +1,57 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.0 +import QtQuick.Controls 1.0 as QtControls + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + + +Item { + id: iconsPage + width: childrenRect.width + height: childrenRect.height + implicitWidth: mainColumn.implicitWidth + implicitHeight: pageColumn.implicitHeight + + property alias cfg_Test: testConfigField.text + property alias cfg_TestBool: testBoolConfigField.checked + + Column { + id: pageColumn + anchors.fill: parent + spacing: 4 + Row { + QtControls.Label { + text: "Text Config value" + } + QtControls.TextField { + id: testConfigField + } + } + Row { + QtControls.Label { + text: "Bool Config value" + } + QtControls.CheckBox { + id: testBoolConfigField + } + } + } +} diff --git a/examples/applets/config/contents/ui/main.qml b/examples/applets/config/contents/ui/main.qml new file mode 100644 index 000000000..f30f42265 --- /dev/null +++ b/examples/applets/config/contents/ui/main.qml @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Marco Martin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. + */ + +import QtQuick 2.1 +import QtQuick.Layouts 1.0 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + +Item { + id: root + width: 100 + height: 100 + property int minimumWidth: units.gridUnit * 20 + property int minimumHeight: column.implicitHeight + + + ColumnLayout { + id: column + anchors.centerIn: parent + PlasmaComponents.Label { + anchors.horizontalCenter: parent.horizontalCenter + text: i18n("I'm an applet") + } + PlasmaComponents.TextField { + text: plasmoid.configuration.Test + onTextChanged: plasmoid.configuration.Test = text + } + PlasmaComponents.CheckBox { + enabled: true + checked: plasmoid.configuration.TestBool + text: i18n("Bool from config") + onCheckedChanged: plasmoid.configuration.TestBool = checked + } + PlasmaComponents.TextField { + text: plasmoid.configuration.OtherTest + onTextChanged: plasmoid.configuration.OtherTest = text + } + } + +} \ No newline at end of file diff --git a/examples/applets/config/metadata.desktop b/examples/applets/config/metadata.desktop new file mode 100644 index 000000000..a17ef60ad --- /dev/null +++ b/examples/applets/config/metadata.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Encoding=UTF-8 +Keywords= +Name=Configuration test +Type=Service + +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPLv2+ +X-KDE-PluginInfo-Name=org.kde.example.configuration +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-Plasma-MainScript=ui/main.qml diff --git a/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml b/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml index e4eb4ba43..a16fddb99 100644 --- a/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml +++ b/src/declarativeimports/plasmacomponents/qml/private/DualStateButton.qml @@ -93,6 +93,7 @@ Item { id: label text: dualButton.text + renderType: Text.NativeRendering anchors { top: parent.top bottom: parent.bottom From 879b6adff371bd41a7a8999d90f845acd84402fd Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 17:51:56 +0200 Subject: [PATCH 09/57] example for enums --- examples/applets/config/contents/config/main.xml | 12 ++++++++++++ examples/applets/config/contents/ui/main.qml | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/examples/applets/config/contents/config/main.xml b/examples/applets/config/contents/config/main.xml index 9f6f0b9ce..2736c4d10 100644 --- a/examples/applets/config/contents/config/main.xml +++ b/examples/applets/config/contents/config/main.xml @@ -20,6 +20,18 @@ test2 + + 0 + + + + + + + + + + diff --git a/examples/applets/config/contents/ui/main.qml b/examples/applets/config/contents/ui/main.qml index f30f42265..1734dc406 100644 --- a/examples/applets/config/contents/ui/main.qml +++ b/examples/applets/config/contents/ui/main.qml @@ -51,6 +51,10 @@ Item { text: plasmoid.configuration.OtherTest onTextChanged: plasmoid.configuration.OtherTest = text } + PlasmaComponents.TextField { + text: plasmoid.configuration.EnumTest + onTextChanged: plasmoid.configuration.EnumTest = text + } } } \ No newline at end of file From 65037c2873add41b78238a2371104f9558d221e7 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 18:00:44 +0200 Subject: [PATCH 10/57] enum and int tests --- .../applets/config/contents/config/main.xml | 7 +++++- .../config/contents/ui/configGeneral.qml | 2 +- examples/applets/config/contents/ui/main.qml | 22 ++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/examples/applets/config/contents/config/main.xml b/examples/applets/config/contents/config/main.xml index 2736c4d10..889f44149 100644 --- a/examples/applets/config/contents/config/main.xml +++ b/examples/applets/config/contents/config/main.xml @@ -10,9 +10,14 @@ test - + true + + 1 + -1 + 100 + diff --git a/examples/applets/config/contents/ui/configGeneral.qml b/examples/applets/config/contents/ui/configGeneral.qml index 15fb4e41b..cb9703f08 100644 --- a/examples/applets/config/contents/ui/configGeneral.qml +++ b/examples/applets/config/contents/ui/configGeneral.qml @@ -31,7 +31,7 @@ Item { implicitHeight: pageColumn.implicitHeight property alias cfg_Test: testConfigField.text - property alias cfg_TestBool: testBoolConfigField.checked + property alias cfg_BoolTest: testBoolConfigField.checked Column { id: pageColumn diff --git a/examples/applets/config/contents/ui/main.qml b/examples/applets/config/contents/ui/main.qml index 1734dc406..15969b0bc 100644 --- a/examples/applets/config/contents/ui/main.qml +++ b/examples/applets/config/contents/ui/main.qml @@ -35,7 +35,7 @@ Item { anchors.centerIn: parent PlasmaComponents.Label { anchors.horizontalCenter: parent.horizontalCenter - text: i18n("I'm an applet") + text: i18n("String test") } PlasmaComponents.TextField { text: plasmoid.configuration.Test @@ -43,18 +43,34 @@ Item { } PlasmaComponents.CheckBox { enabled: true - checked: plasmoid.configuration.TestBool + checked: plasmoid.configuration.BoolTest text: i18n("Bool from config") - onCheckedChanged: plasmoid.configuration.TestBool = checked + onCheckedChanged: plasmoid.configuration.BoolTest = checked + } + PlasmaComponents.Label { + anchors.horizontalCenter: parent.horizontalCenter + text: i18n("String from another group") } PlasmaComponents.TextField { text: plasmoid.configuration.OtherTest onTextChanged: plasmoid.configuration.OtherTest = text } + PlasmaComponents.Label { + anchors.horizontalCenter: parent.horizontalCenter + text: i18n("Enum: displayed as int,\n written as string") + } PlasmaComponents.TextField { text: plasmoid.configuration.EnumTest onTextChanged: plasmoid.configuration.EnumTest = text } + PlasmaComponents.Label { + anchors.horizontalCenter: parent.horizontalCenter + text: i18n("Integer: minimum -1,\n maximum 100") + } + PlasmaComponents.TextField { + text: plasmoid.configuration.IntTest + onTextChanged: plasmoid.configuration.IntTest = text + } } } \ No newline at end of file From 21c0f9e6dfe5075c130dc973a4c8258d7a48b926 Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Wed, 11 Sep 2013 18:24:20 +0200 Subject: [PATCH 11/57] Fix build. --- src/scriptengines/qml/plasmoid/wallpaperinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp index 4004bd094..ba629be86 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -182,7 +182,7 @@ void WallpaperInterface::setAction(const QString &name, const QString &text, con action = new QAction(text, this); m_actions->addAction(name, action); - Q_ASSERT(!m_actions->actions().contains(name)); + Q_ASSERT(!m_actions->action(name)); m_actions->addAction(name, action); if (!m_actionSignals) { From e95c4b8550336032e91627c4d4184d0da053b153 Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Wed, 11 Sep 2013 18:35:14 +0200 Subject: [PATCH 12/57] ++sense; --- src/scriptengines/qml/plasmoid/wallpaperinterface.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp index ba629be86..6d67e1e49 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -179,10 +179,8 @@ void WallpaperInterface::setAction(const QString &name, const QString &text, con if (action) { action->setText(text); } else { - action = new QAction(text, this); - m_actions->addAction(name, action); - Q_ASSERT(!m_actions->action(name)); + action = new QAction(text, this); m_actions->addAction(name, action); if (!m_actionSignals) { From f4d222c9c447dfdf3e33c52aef3bbd7f207b2e8a Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 11 Sep 2013 18:51:27 +0200 Subject: [PATCH 13/57] very crude support for a string default in choices still a long way to real enums --- examples/applets/config/contents/config/main.xml | 16 ++++++++-------- src/plasma/configloader.cpp | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/examples/applets/config/contents/config/main.xml b/examples/applets/config/contents/config/main.xml index 889f44149..f90376590 100644 --- a/examples/applets/config/contents/config/main.xml +++ b/examples/applets/config/contents/config/main.xml @@ -26,15 +26,15 @@ test2 - 0 + Value2 - - - - - - - + + + + + + + diff --git a/src/plasma/configloader.cpp b/src/plasma/configloader.cpp index 91d60a619..6db1b864b 100644 --- a/src/plasma/configloader.cpp +++ b/src/plasma/configloader.cpp @@ -223,11 +223,24 @@ void ConfigLoaderHandler::addItem() QDateTime::fromString(m_default), m_key); } else if (m_type == "enum") { m_key = (m_key.isEmpty()) ? m_name : m_key; + bool ok; + int value = m_default.toUInt(&ok); + //if is not an integer, try to find the string value among the registered choices + if (!ok) { + int i = 0; + foreach (const KConfigSkeleton::ItemEnum::Choice &choice, m_enumChoices) { + if (choice.name == m_default) { + value = i; + break; + } + ++i; + } + } KConfigSkeleton::ItemEnum *enumItem = new KConfigSkeleton::ItemEnum(m_config->currentGroup(), m_key, *d->newInt(), m_enumChoices, - m_default.toUInt()); + value); m_config->addItem(enumItem, m_name); item = enumItem; } else if (m_type == "font") { From eaef6cfbcbee02b45a8401fe49cb1972f6b3d343 Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Wed, 11 Sep 2013 19:01:17 +0200 Subject: [PATCH 14/57] Make KDeclarativeMouseEvent's button prop usable in QML. Qt::MouseButton is not registered, so use int instead. This matches QML's own MouseEvent.button property. Ack'ed by Marco Martin. --- src/declarativeimports/qtextracomponents/mouseeventlistener.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarativeimports/qtextracomponents/mouseeventlistener.h b/src/declarativeimports/qtextracomponents/mouseeventlistener.h index 6d34fdc67..ec8a22e89 100644 --- a/src/declarativeimports/qtextracomponents/mouseeventlistener.h +++ b/src/declarativeimports/qtextracomponents/mouseeventlistener.h @@ -30,7 +30,7 @@ class KDeclarativeMouseEvent : public QObject Q_PROPERTY(int y READ y) Q_PROPERTY(int screenX READ screenX) Q_PROPERTY(int screenY READ screenY) - Q_PROPERTY(Qt::MouseButton button READ button) + Q_PROPERTY(int button READ button) Q_PROPERTY(Qt::MouseButtons buttons READ buttons) Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers) @@ -52,7 +52,7 @@ public: int y() const { return m_y; } int screenX() const { return m_screenX; } int screenY() const { return m_screenY; } - Qt::MouseButton button() const { return m_button; } + int button() const { return m_button; } Qt::MouseButtons buttons() const { return m_buttons; } Qt::KeyboardModifiers modifiers() const { return m_modifiers; } From 79969720786faf30abbd4465abae24957e2f2304 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Thu, 12 Sep 2013 04:08:57 +0000 Subject: [PATCH 15/57] SVN_SILENT made messages (.desktop file) --- examples/applets/localegallery/metadata.desktop | 2 ++ examples/applets/nowplaying/metadata.desktop | 2 ++ examples/applets/qmltasks/metadata.desktop | 2 ++ examples/applets/samegame/metadata.desktop | 2 ++ examples/applets/widgetgallery/metadata.desktop | 2 ++ examples/applets/windowthumbnails/metadata.desktop | 5 ----- src/scriptengines/qml/data/plasma-wallpaper.desktop | 7 +++++++ 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/examples/applets/localegallery/metadata.desktop b/examples/applets/localegallery/metadata.desktop index 815fb6e73..fcee6e1ea 100644 --- a/examples/applets/localegallery/metadata.desktop +++ b/examples/applets/localegallery/metadata.desktop @@ -1,12 +1,14 @@ [Desktop Entry] Encoding=UTF-8 Name=Locale gallery +Name[nl]=Lokale galerij Name[pt]=Galeria regional Name[pt_BR]=Galeria regional Name[sv]=Locale-galleri Name[uk]=Галерея локалей Name[x-test]=xxLocale galleryxx Comment=gallery of KLocale QML Bindings +Comment[nl]=galerij van KLocale QML-bindingen Comment[pt]=Galeria de Interfaces em QML do KLocale Comment[pt_BR]=Galeria de interfaces em QML do KLocale Comment[sv]=galleri av QML-bindningar för KLocale diff --git a/examples/applets/nowplaying/metadata.desktop b/examples/applets/nowplaying/metadata.desktop index 51cdb8ad0..206a440af 100644 --- a/examples/applets/nowplaying/metadata.desktop +++ b/examples/applets/nowplaying/metadata.desktop @@ -1,11 +1,13 @@ [Desktop Entry] Name=Now playing (QML) +Name[nl]=Speelt nu (QML) Name[pt]=Agora a tocar (QML) Name[pt_BR]=Reproduzindo (QML) Name[sv]=Spelar nu (QML) Name[uk]=Зараз відтворюється (QML) Name[x-test]=xxNow playing (QML)xx Comment=A proof of concept media player controller qml +Comment[nl]=Een 'proof of concept' qml voor besturing van een mediaspeler Comment[pt]=A prova de conceito de um QML com controlo de leitor multimédia Comment[pt_BR]=A prova de conceito de um QML com controle de reprodutor multimídia Comment[sv]=Ett koncept för styrning av mediaspelare i QML diff --git a/examples/applets/qmltasks/metadata.desktop b/examples/applets/qmltasks/metadata.desktop index bb24aa664..c683b0f2a 100644 --- a/examples/applets/qmltasks/metadata.desktop +++ b/examples/applets/qmltasks/metadata.desktop @@ -1,11 +1,13 @@ [Desktop Entry] Name=Poor Man's Tasks +Name[nl]=Taken van 'Poor Man' Name[pt]=Tarefas Simples Name[pt_BR]=Tarefas simples Name[sv]=Fattigmans aktiviteter Name[uk]=Задачі для початківців Name[x-test]=xxPoor Man's Tasksxx Comment=Example showing how to write your own tasks Widget +Comment[nl]=Voorbeeld die toont hoe u uw eigen taak-widget schrijft Comment[pt]=Um exemplo que demonstra como criar o seu próprio item de tarefas Comment[pt_BR]=Exemplo que mostra como criar seu próprio widget de tarefas Comment[sv]=Exempel som visar hur man skriver en egen grafisk komponent för aktiviteter diff --git a/examples/applets/samegame/metadata.desktop b/examples/applets/samegame/metadata.desktop index e1fe36ab7..5083eb312 100644 --- a/examples/applets/samegame/metadata.desktop +++ b/examples/applets/samegame/metadata.desktop @@ -1,12 +1,14 @@ [Desktop Entry] Encoding=UTF-8 Name=Same game (QML) +Name[nl]=Zelfde spel (QML) Name[pt]=Jogo de bolas (QML) Name[pt_BR]=Jogo de bolas (QML) Name[sv]=Samegame (QML) Name[uk]=Та сама гра (QML) Name[x-test]=xxSame game (QML)xx Comment=The Same game QML Qt demo converted as plasmoid +Comment[nl]=De demo van QML Qt van 'Zelfde spel' geconverteerd als plasmoid Comment[pt]=A demonstração do jogo Same Game do Qt em QML Comment[pt_BR]=Demonstração do jogo Same Game do Qt em QML convertido como plasmoide Comment[sv]=Samegame QML Qt-demonstrationen konverterad till Plasmoid diff --git a/examples/applets/widgetgallery/metadata.desktop b/examples/applets/widgetgallery/metadata.desktop index e0b31500c..c609eb83d 100644 --- a/examples/applets/widgetgallery/metadata.desktop +++ b/examples/applets/widgetgallery/metadata.desktop @@ -1,12 +1,14 @@ [Desktop Entry] Encoding=UTF-8 Name=Widgets gallery +Name[nl]=Galerij van widgets Name[pt]=Galeria de elementos Name[pt_BR]=Galeria de widgets Name[sv]=Grafiskt komponentgalleri Name[uk]=Галерея віджетів Name[x-test]=xxWidgets galleryxx Comment=gallery of widgets done with Plasma QtComponents +Comment[nl]=galerij van widgets gemaakt met Plasma QtComponents Comment[pt]=Uma galeria de elementos gráficos feita com o QtComponents do Plasma Comment[pt_BR]=Galeria de widgets gráficos feita com o QtComponents do Plasma Comment[sv]=galleri av grafiska komponenter skapade med Plasma Qt-komponenter diff --git a/examples/applets/windowthumbnails/metadata.desktop b/examples/applets/windowthumbnails/metadata.desktop index 3246af7f3..f5de5c5f2 100644 --- a/examples/applets/windowthumbnails/metadata.desktop +++ b/examples/applets/windowthumbnails/metadata.desktop @@ -1,10 +1,5 @@ [Desktop Entry] Name=Example window thumbnails list -Name[pt]=Lista de janelas de exemplo -Name[pt_BR]=Lista de janelas de exemplo -Name[sv]=Exempel på fönsterlista -Name[uk]=Приклад списку вікон -Name[x-test]=xxExample window listxx Comment=Example showing how to display window thumbnails Comment[pt]=Exemplo que demonstra como apresentar miniaturas das janelas Comment[pt_BR]=Exemplo que demostra como apresentar as miniaturas das janelas diff --git a/src/scriptengines/qml/data/plasma-wallpaper.desktop b/src/scriptengines/qml/data/plasma-wallpaper.desktop index 3575facbb..0c30c8a3b 100644 --- a/src/scriptengines/qml/data/plasma-wallpaper.desktop +++ b/src/scriptengines/qml/data/plasma-wallpaper.desktop @@ -3,6 +3,13 @@ Type=ServiceType X-KDE-ServiceType=Plasma/Wallpaper Comment=Plasma wallpaper +Comment[cs]=Tapeta Plasmy +Comment[nl]=Plasma-bureaubladachtergrond +Comment[pt]=Papel de parede do Plasma +Comment[pt_BR]=Papel de parede do Plasma +Comment[sv]=Plasma skrivbordsunderlägg +Comment[uk]=Тло стільниці Плазми +Comment[x-test]=xxPlasma wallpaperxx [PropertyDef::X-Plasma-FormFactors] Type=QStringList From 443216a29b70fc1dbcafa79ae41e9775fafaa2e1 Mon Sep 17 00:00:00 2001 From: Giorgos Tsiapaliokas Date: Thu, 12 Sep 2013 17:16:30 +0300 Subject: [PATCH 16/57] KF5::plasmaquick -> KF5::PlasmaQuick --- src/plasmaquick/CMakeLists.txt | 10 +++++----- src/shell/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index 9c3bd77b8..46bd11894 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -14,9 +14,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) -add_library(plasmaquick SHARED ${plasmaquick_LIB_SRC}) +add_library(PlasmaQuick SHARED ${plasmaquick_LIB_SRC}) -target_link_libraries(plasmaquick +target_link_libraries(PlasmaQuick ${Qt5Quick_LIBRARIES} ${Qt5Qml_LIBRARIES} ${KWindowSystem_LIBRARIES} @@ -28,14 +28,14 @@ target_link_libraries(plasmaquick kdeclarative ) -set_target_properties(plasmaquick PROPERTIES +set_target_properties(PlasmaQuick PROPERTIES VERSION 5.0.0 SOVERSION 5 ) -install(TARGETS plasmaquick EXPORT PlasmaQuickTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS PlasmaQuick EXPORT PlasmaQuickTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) -generate_export_header(plasmaquick) +generate_export_header(PlasmaQuick) set(plasmaquick_LIB_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/plasmaquick_export.h diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index a60711e79..2c6af922b 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -79,7 +79,7 @@ target_link_libraries(plasma-shell ${KWindowSystem_LIBRARIES} ${KCoreAddons_LIBRARIES} plasma - plasmaquick + PlasmaQuick ${Qt5Script_LIBRARIES} ${KDE4Support_LIBRARIES} ${Solid_LIBRARIES} From fe58688e09ab99341311a8c7f877bc608ecde604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Thu, 12 Sep 2013 18:41:10 +0200 Subject: [PATCH 17/57] Desktop is now always willing --- src/shell/qmlpackages/blank/contents/loader.qml | 2 +- src/shell/qmlpackages/desktop/contents/loader.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shell/qmlpackages/blank/contents/loader.qml b/src/shell/qmlpackages/blank/contents/loader.qml index 02475e9b9..df8779edf 100644 --- a/src/shell/qmlpackages/blank/contents/loader.qml +++ b/src/shell/qmlpackages/blank/contents/loader.qml @@ -27,7 +27,7 @@ Item { id: main property string shell : "org.kde.blank" - property bool willing : keyboards.count != 1 + property bool willing : false property int priority : 0 // This is not needed, but allows the diff --git a/src/shell/qmlpackages/desktop/contents/loader.qml b/src/shell/qmlpackages/desktop/contents/loader.qml index 74b829509..3c4dd8bca 100644 --- a/src/shell/qmlpackages/desktop/contents/loader.qml +++ b/src/shell/qmlpackages/desktop/contents/loader.qml @@ -26,7 +26,7 @@ Item { id: main property string shell : "org.kde.desktop" - property bool willing : keyboards.count == 1 + property bool willing : true property int priority : 1 // This is not needed, but allows the From 29d10cc4b5e8930fa5f6b782dc96a770a11e56bc Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 12 Sep 2013 18:58:16 +0200 Subject: [PATCH 18/57] add a todo where shellmanager panel management should be done --- src/shell/shellcorona.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shell/shellcorona.cpp b/src/shell/shellcorona.cpp index 808ebc3e7..08283fd46 100644 --- a/src/shell/shellcorona.cpp +++ b/src/shell/shellcorona.cpp @@ -114,6 +114,7 @@ void ShellCorona::setShell(const QString &shell) setPackage(package); load(); + //TODO: panel views should be synced here: either creating views for panels without, or deleting views for panels that don't have one anymore } QString ShellCorona::shell() const From 7c9ad840d12dd4b53624a62b075c73ffcfab5534 Mon Sep 17 00:00:00 2001 From: Eike Hein Date: Thu, 12 Sep 2013 19:21:50 +0200 Subject: [PATCH 19/57] Make panels default to spanning the screen axis. --- src/shell/panelview.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/shell/panelview.cpp b/src/shell/panelview.cpp index 0088cf73c..e91fdd211 100644 --- a/src/shell/panelview.cpp +++ b/src/shell/panelview.cpp @@ -341,8 +341,6 @@ void PanelView::restore() m_offset = qMax(0, m_offset); } - m_maxLength = config().readEntry("maxLength", -1); - m_minLength = config().readEntry("minLength", -1); m_alignment = (Qt::Alignment)config().readEntry("alignment", Qt::AlignLeft); setMinimumSize(QSize(-1, -1)); @@ -350,6 +348,9 @@ void PanelView::restore() setMaximumSize(screen()->size()); if (containment()->formFactor() == Plasma::Types::Vertical) { + m_maxLength = config().readEntry("maxLength", screen()->size().height()); + m_minLength = config().readEntry("minLength", screen()->size().height()); + const int maxSize = screen()->size().height() - m_offset; m_maxLength = qBound(MINSIZE, m_maxLength, maxSize); m_minLength = qBound(MINSIZE, m_minLength, maxSize); @@ -362,11 +363,14 @@ void PanelView::restore() //Horizontal } else { + m_maxLength = config().readEntry("maxLength", screen()->size().width()); + m_minLength = config().readEntry("minLength", screen()->size().width()); + const int maxSize = screen()->size().width() - m_offset; m_maxLength = qBound(MINSIZE, m_maxLength, maxSize); m_minLength = qBound(MINSIZE, m_minLength, maxSize); - resize(qBound(MINSIZE, config().readEntry("length", screen()->size().height()), maxSize), + resize(qBound(MINSIZE, config().readEntry("length", screen()->size().width()), maxSize), config().readEntry("thickness", 32)); setMinimumWidth(m_minLength); From 727cc5780437e7727c98aee5db5f5cdb5e2902e5 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Fri, 13 Sep 2013 04:03:10 +0000 Subject: [PATCH 20/57] SVN_SILENT made messages (.desktop file) --- examples/applets/config/metadata.desktop | 4 ++++ examples/applets/windowthumbnails/metadata.desktop | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/examples/applets/config/metadata.desktop b/examples/applets/config/metadata.desktop index a17ef60ad..67d771e85 100644 --- a/examples/applets/config/metadata.desktop +++ b/examples/applets/config/metadata.desktop @@ -2,6 +2,10 @@ Encoding=UTF-8 Keywords= Name=Configuration test +Name[pt]=Teste de configuração +Name[sv]=Inställningstest +Name[uk]=Перевірка налаштувань +Name[x-test]=xxConfiguration testxx Type=Service X-KDE-ServiceTypes=Plasma/Applet diff --git a/examples/applets/windowthumbnails/metadata.desktop b/examples/applets/windowthumbnails/metadata.desktop index f5de5c5f2..32b17655a 100644 --- a/examples/applets/windowthumbnails/metadata.desktop +++ b/examples/applets/windowthumbnails/metadata.desktop @@ -1,5 +1,9 @@ [Desktop Entry] Name=Example window thumbnails list +Name[pt]=Lista de miniaturas das janelas de exemplo +Name[sv]=Exempel på miniatyrbilder av fönster +Name[uk]=Приклад списку мініатюр вікон +Name[x-test]=xxExample window thumbnails listxx Comment=Example showing how to display window thumbnails Comment[pt]=Exemplo que demonstra como apresentar miniaturas das janelas Comment[pt_BR]=Exemplo que demostra como apresentar as miniaturas das janelas From 15d4de4b4acd602c476494ead1bb87686fd41a85 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 14:50:05 +0200 Subject: [PATCH 21/57] correctly load panels when the shell gets switched --- src/shell/shellcorona.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shell/shellcorona.cpp b/src/shell/shellcorona.cpp index 08283fd46..c9b534d28 100644 --- a/src/shell/shellcorona.cpp +++ b/src/shell/shellcorona.cpp @@ -364,6 +364,7 @@ void ShellCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Contain } else { if (containment->isUiReady()) { + d->loadingDesktops.remove(containment); checkLoadingDesktopsComplete(); } else { d->loadingDesktops.insert(containment); @@ -384,6 +385,9 @@ void ShellCorona::handleContainmentAdded(Plasma::Containment* c) { connect(c, &Plasma::Containment::showAddWidgetsInterface, this, &ShellCorona::showWidgetExplorer); + connect(c, &QObject::destroyed, [=] (QObject *o) { + d->loadingDesktops.remove(static_cast(o)); + }); } void ShellCorona::showWidgetExplorer() From 9bc1c68fcab2036d89fefe0c36852113f3b341c4 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 15:11:49 +0200 Subject: [PATCH 22/57] remove the private init --- src/plasmaquick/plasmaquickview.cpp | 46 ++++++++++++----------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/src/plasmaquick/plasmaquickview.cpp b/src/plasmaquick/plasmaquickview.cpp index 540fd58d5..480ea4de8 100644 --- a/src/plasmaquick/plasmaquickview.cpp +++ b/src/plasmaquick/plasmaquickview.cpp @@ -35,7 +35,6 @@ public: PlasmaQuickViewPrivate(Plasma::Corona *corona, PlasmaQuickView *view); ~PlasmaQuickViewPrivate(); - void init(); void setContainment(Plasma::Containment *cont); Plasma::Types::FormFactor formFactor() const; Plasma::Types::Location location() const; @@ -58,31 +57,6 @@ PlasmaQuickViewPrivate::~PlasmaQuickViewPrivate() { } -void PlasmaQuickViewPrivate::init() -{ - //FIXME: for some reason all windows must have alpha enable otherwise the ones that do won't paint. - //Probably is an architectural problem - QSurfaceFormat format; - format.setAlphaBufferSize(8); - - q->setFormat(format); - q->setColor(Qt::transparent); - - - QObject::connect(q->screen(), &QScreen::virtualGeometryChanged, - q, &PlasmaQuickView::screenGeometryChanged); - - if (!corona->package().isValid()) { - qWarning() << "Invalid home screen package"; - } - - q->setResizeMode(PlasmaQuickView::SizeRootObjectToView); - q->setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml"))); - - QObject::connect(corona, &Plasma::Corona::packageChanged, - q, &PlasmaQuickView::coronaPackageChanged); -} - void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont) { if (containment.data() == cont) { @@ -185,7 +159,25 @@ PlasmaQuickView::PlasmaQuickView(Plasma::Corona *corona, QWindow *parent) : QQuickView(parent), d(new PlasmaQuickViewPrivate(corona, this)) { - d->init(); + QSurfaceFormat format; + format.setAlphaBufferSize(8); + + setFormat(format); + setColor(Qt::transparent); + + + QObject::connect(screen(), &QScreen::virtualGeometryChanged, + this, &PlasmaQuickView::screenGeometryChanged); + + if (!corona->package().isValid()) { + qWarning() << "Invalid home screen package"; + } + + setResizeMode(PlasmaQuickView::SizeRootObjectToView); + setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml"))); + + QObject::connect(corona, &Plasma::Corona::packageChanged, + this, &PlasmaQuickView::coronaPackageChanged); } PlasmaQuickView::~PlasmaQuickView() From 5735faec036be3b843b60ba8cefcbbd30efc9f4f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 15:20:36 +0200 Subject: [PATCH 23/57] move setsource into desktopview --- src/plasmaquick/plasmaquickview.cpp | 1 - src/shell/desktopview.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plasmaquick/plasmaquickview.cpp b/src/plasmaquick/plasmaquickview.cpp index 480ea4de8..72b29747a 100644 --- a/src/plasmaquick/plasmaquickview.cpp +++ b/src/plasmaquick/plasmaquickview.cpp @@ -174,7 +174,6 @@ PlasmaQuickView::PlasmaQuickView(Plasma::Corona *corona, QWindow *parent) } setResizeMode(PlasmaQuickView::SizeRootObjectToView); - setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml"))); QObject::connect(corona, &Plasma::Corona::packageChanged, this, &PlasmaQuickView::coronaPackageChanged); diff --git a/src/shell/desktopview.cpp b/src/shell/desktopview.cpp index 0af8b1c13..3c9eee47e 100644 --- a/src/shell/desktopview.cpp +++ b/src/shell/desktopview.cpp @@ -19,11 +19,12 @@ #include "desktopview.h" #include "shellcorona.h" +#include DesktopView::DesktopView(ShellCorona *corona, QWindow *parent) : PlasmaQuickView(corona, parent) { - + setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml"))); } DesktopView::~DesktopView() From 5903d979661725a34ca7d91fcd5273134899a300 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Thu, 12 Sep 2013 15:15:59 +0200 Subject: [PATCH 24/57] regexps are expensive to create, we ask for packages a lot, cache the re --- src/plasma/pluginloader.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 9156754e1..11a8dabf0 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -51,12 +51,18 @@ static PluginLoader *s_pluginLoader = 0; class PluginLoaderPrivate { public: + PluginLoaderPrivate() + : packageRE("[^a-zA-Z0-9\\-_]") + { + } + static QSet knownCategories(); static QString parentAppConstraint(const QString &parentApp = QString()); static QSet s_customCategories; QHash > structures; bool isDefaultLoader; + QRegExp packageRE; }; QSet PluginLoaderPrivate::s_customCategories; @@ -423,9 +429,8 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s } if (!specialization.isEmpty()) { - QRegExp re("[^a-zA-Z0-9\\-_]"); // check that the provided strings are safe to use in a ServiceType query - if (re.indexIn(specialization) == -1 && re.indexIn(packageFormat) == -1) { + if (d->packageRE.indexIn(specialization) == -1 && d->packageRE.indexIn(packageFormat) == -1) { // FIXME: The query below is rather spepcific to script engines. generify if possible const QString component = packageFormat.right(packageFormat.size() - packageFormat.lastIndexOf('/') - 1); const QString constraint = QString("[X-Plasma-API] == '%1' and " "'%2' in [X-Plasma-ComponentTypes]").arg(specialization, component); From 0c68fa35bcbd1f1d5d71c10e45b2846099d3d6e7 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 13 Sep 2013 16:28:53 +0200 Subject: [PATCH 25/57] indentation is not rocket science, but without it we lose maintainability --- .../plasmaextracomponents/fallbackcomponent.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h index 1543fc4bf..58e930c8f 100644 --- a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h +++ b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.h @@ -29,20 +29,20 @@ class FallbackComponent : public QObject { Q_OBJECT -/** - * Prefix of the path - * This should be something like "plasma","kwin","plasmate",etc - * If the basePath is "plasma", it will be set for the data of plasma like, - * or it can be an absolute path - **/ -Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged) + /** + * Prefix of the path + * This should be something like "plasma","kwin","plasmate",etc + * If the basePath is "plasma", it will be set for the data of plasma like, + * or it can be an absolute path + **/ + Q_PROPERTY(QString basePath READ basePath WRITE setBasePath NOTIFY basePathChanged) -/** - * The possible candidates in order to have a complete path. - * basepath/candidate, where candidate is the first one in the list of candidates - * in order of importance that matches an existing file - **/ -Q_PROPERTY(QStringList candidates READ candidates WRITE setCandidates NOTIFY candidatesChanged) + /** + * The possible candidates in order to have a complete path. + * basepath/candidate, where candidate is the first one in the list of candidates + * in order of importance that matches an existing file + **/ + Q_PROPERTY(QStringList candidates READ candidates WRITE setCandidates NOTIFY candidatesChanged) public: FallbackComponent(QObject *parent = 0); From cb1064fd32d3ca7dea818233a5afe9a890205b3e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 16:40:22 +0200 Subject: [PATCH 26/57] the desktop view exposes a way to be desktop win the desktop shell will set the window as a "desktop" window, always behind. some other shells will have the desktop as a normal window the api can still expand --- src/shell/desktopview.cpp | 51 ++++++++++++++++++- src/shell/desktopview.h | 15 ++++++ .../desktop/contents/views/Desktop.qml | 2 + 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/shell/desktopview.cpp b/src/shell/desktopview.cpp index 3c9eee47e..8147b1e18 100644 --- a/src/shell/desktopview.cpp +++ b/src/shell/desktopview.cpp @@ -19,11 +19,20 @@ #include "desktopview.h" #include "shellcorona.h" +#include +#include +#include + +#include + #include DesktopView::DesktopView(ShellCorona *corona, QWindow *parent) - : PlasmaQuickView(corona, parent) + : PlasmaQuickView(corona, parent), + m_stayBehind(false), + m_fillScreen(false) { + engine()->rootContext()->setContextProperty("desktop", this); setSource(QUrl::fromLocalFile(corona->package().filePath("views", "Desktop.qml"))); } @@ -31,6 +40,46 @@ DesktopView::~DesktopView() { } + +bool DesktopView::stayBehind() const +{ + return m_stayBehind; +} + +void DesktopView::setStayBehind(bool stayBehind) +{ + if (stayBehind == m_stayBehind) { + return; + } + + if (stayBehind) { + KWindowSystem::setType(winId(), NET::Desktop); + } else { + KWindowSystem::setType(winId(), NET::Normal); + } + + m_stayBehind = stayBehind; + emit stayBehindChanged(); +} + +bool DesktopView::fillScreen() const +{ + return m_fillScreen; +} + +void DesktopView::setFillScreen(bool fillScreen) +{ + if (fillScreen == m_fillScreen) { + return; + } + + resize(screen()->geometry().width(), screen()->geometry().height()); + connect(screen(), &QScreen::geometryChanged, [=]{resize(screen()->geometry().width(), screen()->geometry().height());}); + + fillScreen = fillScreen; + emit fillScreenChanged(); +} + /* void DesktopView::showConfigurationInterface(Plasma::Applet *applet) { diff --git a/src/shell/desktopview.h b/src/shell/desktopview.h index 498dbd64c..f7cc6044e 100644 --- a/src/shell/desktopview.h +++ b/src/shell/desktopview.h @@ -29,19 +29,34 @@ class ShellCorona; class DesktopView : public PlasmaQuickView { Q_OBJECT + Q_PROPERTY(bool stayBehind READ stayBehind WRITE setStayBehind NOTIFY stayBehindChanged) + Q_PROPERTY(bool fillScreen READ fillScreen WRITE setFillScreen NOTIFY fillScreenChanged) public: explicit DesktopView(ShellCorona *corona, QWindow *parent = 0); virtual ~DesktopView(); + bool stayBehind() const; + void setStayBehind(bool stayBehind); + + bool fillScreen() const; + void setFillScreen(bool fillScreen); + protected Q_SLOTS: /** * It will be called when the configuration is requested + * FIXME: this should be moved here */ //virtual void showConfigurationInterface(Plasma::Applet *applet); +Q_SIGNALS: + void stayBehindChanged(); + void fillScreenChanged(); + private: QPointer m_configView; + bool m_stayBehind : 1; + bool m_fillScreen : 1; }; #endif // DESKTOVIEW_H diff --git a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml index c5bff200e..71c033de3 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml @@ -38,6 +38,8 @@ Rectangle { } Component.onCompleted: { + desktop.stayBehind = true; + desktop.fillScreen = true; print("View QML loaded") } } From ee510e5fca091b002032fff7a56419a1a3381007 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 18:34:21 +0200 Subject: [PATCH 27/57] add --windowed option if passed the destop view is windowed no matter what. probably useful only in the early stages of development --- src/shell/desktopview.cpp | 5 +++-- src/shell/main.cpp | 7 +++++++ src/shell/shellmanager.cpp | 2 ++ src/shell/shellmanager.h | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/shell/desktopview.cpp b/src/shell/desktopview.cpp index 8147b1e18..792243d01 100644 --- a/src/shell/desktopview.cpp +++ b/src/shell/desktopview.cpp @@ -18,6 +18,7 @@ #include "desktopview.h" #include "shellcorona.h" +#include "shellmanager.h" #include #include @@ -48,7 +49,7 @@ bool DesktopView::stayBehind() const void DesktopView::setStayBehind(bool stayBehind) { - if (stayBehind == m_stayBehind) { + if (ShellManager::s_forceWindowed || stayBehind == m_stayBehind) { return; } @@ -69,7 +70,7 @@ bool DesktopView::fillScreen() const void DesktopView::setFillScreen(bool fillScreen) { - if (fillScreen == m_fillScreen) { + if (ShellManager::s_forceWindowed || fillScreen == m_fillScreen) { return; } diff --git a/src/shell/main.cpp b/src/shell/main.cpp index f094d555a..70c088309 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -24,6 +24,7 @@ #include "shellmanager.h" #include +#include static const char description[] = "Plasma Shell"; static const char version[] = "2.0"; @@ -38,9 +39,13 @@ int main(int argc, char** argv) QCommandLineOption dbg = QCommandLineOption(QStringList() << QStringLiteral("d") << QStringLiteral("qmljsdebugger"), QStringLiteral("Enable QML Javascript debugger")); + QCommandLineOption windowed = QCommandLineOption(QStringList() << QStringLiteral("w") << QStringLiteral("windowed"), + QStringLiteral("force a windowed view for desktop purposes")); + parser.addVersionOption(); parser.setApplicationDescription(description); parser.addOption(dbg); + parser.addOption(windowed); parser.process(app); //enable the QML debugger only if --qmljsdebugger (or -d) is passed as a command line arg @@ -58,6 +63,8 @@ int main(int argc, char** argv) // corona->processUpdateScripts(); // corona->checkScreens(); + ShellManager::s_forceWindowed = parser.isSet(windowed); + ShellManager::instance(); return app.exec(); diff --git a/src/shell/shellmanager.cpp b/src/shell/shellmanager.cpp index ad3c708f9..b57963eec 100644 --- a/src/shell/shellmanager.cpp +++ b/src/shell/shellmanager.cpp @@ -36,6 +36,8 @@ static const QString s_shellsDir( QString(CMAKE_INSTALL_PREFIX) + "/" + DATA_INSTALL_DIR + "/" + "plasma/shells/"); static const QString s_shellLoaderPath = QString("/contents/loader.qml"); +bool ShellManager::s_forceWindowed = false; + // // ShellManager // diff --git a/src/shell/shellmanager.h b/src/shell/shellmanager.h index 9e07d0dd6..b8498d919 100644 --- a/src/shell/shellmanager.h +++ b/src/shell/shellmanager.h @@ -22,6 +22,8 @@ #include + + class ShellManager: public QObject { Q_OBJECT public: @@ -30,6 +32,8 @@ public: void loadHandlers(); + static bool s_forceWindowed; + protected Q_SLOTS: void registerHandler(QObject * handler); void deregisterHandler(QObject * handler); From 1586c1b82ab66aa5a2466c1047570b72ed2c8fa4 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 19:55:55 +0200 Subject: [PATCH 28/57] if size is empty don't do the compact check with a null size none of the representations will work anyways. an empty size may happen when the applet has just been loaded and the containment still has to adjust it --- src/scriptengines/qml/plasmoid/appletinterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 4e100d9c6..e360d1443 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -634,7 +634,8 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o void AppletInterface::compactRepresentationCheck() { - if (!m_qmlObject->rootObject() || qobject_cast(this)) { + if (width() <= 0 || height() <= 0 || !m_qmlObject->rootObject() || + qobject_cast(this)) { return; } @@ -648,7 +649,6 @@ void AppletInterface::compactRepresentationCheck() minHint.setHeight(m_qmlObject->rootObject()->property("minimumHeight").toReal()); } - //TODO: completely arbitrary for now if (width() < minHint.width() || height() < minHint.height()) { m_expanded = false; From 786bd7b7af36f03c6ea56e95fa09a0d6989e2488 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 Sep 2013 20:03:25 +0200 Subject: [PATCH 29/57] emit uiready also for empty containments --- src/plasma/private/applet_p.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index b31acf0f2..ff0fe718f 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -280,6 +280,8 @@ void AppletPrivate::setUiReady() //if we are the containment and there is still some uncomplete applet, we're still incomplete if (!c->d->loadingApplets.isEmpty()) { return; + } else if (!uiReady) { + emit c->uiReadyChanged(true); } } else { c = q->containment(); From 7cbb21fe67f26d993ba05f322ff07d3e6f624f58 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 14 Sep 2013 04:03:10 +0000 Subject: [PATCH 30/57] SVN_SILENT made messages (.desktop file) --- examples/applets/config/metadata.desktop | 2 ++ examples/applets/windowthumbnails/metadata.desktop | 1 + 2 files changed, 3 insertions(+) diff --git a/examples/applets/config/metadata.desktop b/examples/applets/config/metadata.desktop index 67d771e85..cb75f0ea3 100644 --- a/examples/applets/config/metadata.desktop +++ b/examples/applets/config/metadata.desktop @@ -2,7 +2,9 @@ Encoding=UTF-8 Keywords= Name=Configuration test +Name[nl]=Test van instellingen Name[pt]=Teste de configuração +Name[pt_BR]=Teste de configuração Name[sv]=Inställningstest Name[uk]=Перевірка налаштувань Name[x-test]=xxConfiguration testxx diff --git a/examples/applets/windowthumbnails/metadata.desktop b/examples/applets/windowthumbnails/metadata.desktop index 32b17655a..7c7cafcd9 100644 --- a/examples/applets/windowthumbnails/metadata.desktop +++ b/examples/applets/windowthumbnails/metadata.desktop @@ -1,6 +1,7 @@ [Desktop Entry] Name=Example window thumbnails list Name[pt]=Lista de miniaturas das janelas de exemplo +Name[pt_BR]=Lista de miniaturas das janelas de exemplo Name[sv]=Exempel på miniatyrbilder av fönster Name[uk]=Приклад списку мініатюр вікон Name[x-test]=xxExample window thumbnails listxx From cb69c812f53184c875edcaf0e0e48528dc487ebe Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 15 Sep 2013 04:18:15 +0000 Subject: [PATCH 31/57] SVN_SILENT made messages (.desktop file) --- examples/applets/compactrepresentation/metadata.desktop | 1 + examples/applets/config/metadata.desktop | 2 ++ examples/applets/helloworld/metadata.desktop | 1 + src/platformstatus/kded_platformstatus.desktop | 1 + src/scriptengines/qml/data/plasma-wallpaper.desktop | 2 ++ src/shell/qmlpackages/blank/metadata.desktop | 1 + 6 files changed, 8 insertions(+) diff --git a/examples/applets/compactrepresentation/metadata.desktop b/examples/applets/compactrepresentation/metadata.desktop index fd4bd14c6..bedbd5473 100644 --- a/examples/applets/compactrepresentation/metadata.desktop +++ b/examples/applets/compactrepresentation/metadata.desktop @@ -3,6 +3,7 @@ Comment= Encoding=UTF-8 Keywords= Name=hello world +Name[de]=Hallo Welt Name[nl]=hallo wereld Name[pt]=olá mundo Name[pt_BR]=Olá mundo diff --git a/examples/applets/config/metadata.desktop b/examples/applets/config/metadata.desktop index cb75f0ea3..a0ee439f0 100644 --- a/examples/applets/config/metadata.desktop +++ b/examples/applets/config/metadata.desktop @@ -2,9 +2,11 @@ Encoding=UTF-8 Keywords= Name=Configuration test +Name[de]=Einrichtungstest Name[nl]=Test van instellingen Name[pt]=Teste de configuração Name[pt_BR]=Teste de configuração +Name[sk]=Test nastavenia Name[sv]=Inställningstest Name[uk]=Перевірка налаштувань Name[x-test]=xxConfiguration testxx diff --git a/examples/applets/helloworld/metadata.desktop b/examples/applets/helloworld/metadata.desktop index e5478e010..0653761e6 100644 --- a/examples/applets/helloworld/metadata.desktop +++ b/examples/applets/helloworld/metadata.desktop @@ -3,6 +3,7 @@ Comment= Encoding=UTF-8 Keywords= Name=hello world +Name[de]=Hallo Welt Name[nl]=hallo wereld Name[pt]=olá mundo Name[pt_BR]=Olá mundo diff --git a/src/platformstatus/kded_platformstatus.desktop b/src/platformstatus/kded_platformstatus.desktop index 145364f4d..a0acba514 100644 --- a/src/platformstatus/kded_platformstatus.desktop +++ b/src/platformstatus/kded_platformstatus.desktop @@ -6,6 +6,7 @@ X-KDE-DBus-ModuleName=plaformstatus X-KDE-Kded-autoload=true X-KDE-Kded-load-on-demand=false Name=Platform Status +Name[de]=Plattform-Status Name[fr]=État de la plate-forme Name[nl]=Status van platform Name[pl]=Stan Platformy diff --git a/src/scriptengines/qml/data/plasma-wallpaper.desktop b/src/scriptengines/qml/data/plasma-wallpaper.desktop index 0c30c8a3b..ae119c1cf 100644 --- a/src/scriptengines/qml/data/plasma-wallpaper.desktop +++ b/src/scriptengines/qml/data/plasma-wallpaper.desktop @@ -4,9 +4,11 @@ X-KDE-ServiceType=Plasma/Wallpaper Comment=Plasma wallpaper Comment[cs]=Tapeta Plasmy +Comment[de]=Plasma-Hintergrundbild Comment[nl]=Plasma-bureaubladachtergrond Comment[pt]=Papel de parede do Plasma Comment[pt_BR]=Papel de parede do Plasma +Comment[sk]=Tapeta Plasma Comment[sv]=Plasma skrivbordsunderlägg Comment[uk]=Тло стільниці Плазми Comment[x-test]=xxPlasma wallpaperxx diff --git a/src/shell/qmlpackages/blank/metadata.desktop b/src/shell/qmlpackages/blank/metadata.desktop index c0711a2aa..f79c7666c 100644 --- a/src/shell/qmlpackages/blank/metadata.desktop +++ b/src/shell/qmlpackages/blank/metadata.desktop @@ -10,6 +10,7 @@ Encoding=UTF-8 Keywords= Name=Blank Desktop Name[cs]=Prázdná pracovní plocha +Name[de]=Leere Arbeitsfläche Name[fi]=Tyhjä työpöytä Name[nl]=Blanco bureaublad Name[pt]=Ambiente de Trabalho em Branco From 0ead10fe0b5a918213528e399f7a6f68188b6fef Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 16 Sep 2013 13:05:42 +0200 Subject: [PATCH 32/57] correctly save DialogHeight/DialogWidth piece needed for Popupapplet features, still has to correctly restore it --- .../qml/plasmoid/appletinterface.cpp | 22 +++++++++++++++++++ .../qml/plasmoid/appletinterface.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index e360d1443..bcd65535f 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -649,6 +649,7 @@ void AppletInterface::compactRepresentationCheck() minHint.setHeight(m_qmlObject->rootObject()->property("minimumHeight").toReal()); } + //Make it an icon if (width() < minHint.width() || height() < minHint.height()) { m_expanded = false; @@ -699,6 +700,13 @@ void AppletInterface::compactRepresentationCheck() if (m_qmlObject->rootObject()) { disconnect(m_qmlObject->rootObject(), 0, this, 0); } + + //resize of the root object means popup resize when iconified + connect(m_qmlObject->rootObject(), SIGNAL(widthChanged()), + this, SLOT(updatePopupSize())); + connect(m_qmlObject->rootObject(), SIGNAL(heightChanged()), + this, SLOT(updatePopupSize())); + if (m_compactUiObject.data()->property("minimumWidth").isValid()) { connect(m_compactUiObject.data(), SIGNAL(minimumWidthChanged()), this, SIGNAL(minimumWidthChanged())); @@ -741,6 +749,7 @@ void AppletInterface::compactRepresentationCheck() emit expandedChanged(); + //show the full UI } else { m_expanded = true; emit expandedChanged(); @@ -750,6 +759,11 @@ void AppletInterface::compactRepresentationCheck() disconnect(m_compactUiObject.data(), 0, this, 0); } + disconnect(m_qmlObject->rootObject(), SIGNAL(widthChanged()), + this, SLOT(updatePopupSize())); + disconnect(m_qmlObject->rootObject(), SIGNAL(heightChanged()), + this, SLOT(updatePopupSize())); + //Here we have to use the old connect syntax, because we don't have access to the class type if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) { connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()), @@ -799,6 +813,14 @@ void AppletInterface::compactRepresentationCheck() } } +void AppletInterface::updatePopupSize() +{ + KConfigGroup cg = applet()->config(); + cg = KConfigGroup(&cg, "PopupApplet"); + cg.writeEntry("DialogWidth", m_qmlObject->rootObject()->property("width").toInt()); + cg.writeEntry("DialogHeight", m_qmlObject->rootObject()->property("height").toInt()); +} + void AppletInterface::itemChange(ItemChange change, const ItemChangeData &value) { if (change == QQuickItem::ItemSceneChange) { diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index eb44856dd..44a27a9d0 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -317,6 +317,7 @@ protected Q_SLOTS: private Q_SLOTS: void compactRepresentationCheck(); + void updatePopupSize(); private: //Helper for minimumWidth etc. From e923afe0ee5494cd7185bd6b0dceb29816f5b983 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 16 Sep 2013 16:09:13 +0200 Subject: [PATCH 33/57] correctly restore popup size --- .../qml/plasmoid/appletinterface.cpp | 27 ++++++++++++++++--- .../desktop/contents/applet/CompactApplet.qml | 15 ++++++++--- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index bcd65535f..ab7bf1b05 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -687,12 +687,31 @@ void AppletInterface::compactRepresentationCheck() //replace the full applet with the collapsed view m_compactUiObject.data()->setProperty("visible", true); m_compactUiObject.data()->setProperty("parent", QVariant::fromValue(this)); - //set anchors - QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_compactUiObject.data(), "parent"); - QQmlProperty prop(m_compactUiObject.data(), "anchors.fill"); - prop.write(expr.evaluate()); + + { + //set anchors + QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_compactUiObject.data(), "parent"); + QQmlProperty prop(m_compactUiObject.data(), "anchors.fill"); + prop.write(expr.evaluate()); + } m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(m_compactUiObject.data())); + + + { + //reset all the anchors + QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "anchors.fill=undefined;anchors.left=undefined;anchors.right=undefined;anchors.top=undefined;anchors.bottom=undefined;"); + expr.evaluate(); + } + + KConfigGroup cg = applet()->config(); + cg = KConfigGroup(&cg, "PopupApplet"); + int width = cg.readEntry("DialogWidth", 0); + int height = cg.readEntry("DialogHeight", 0); + + m_qmlObject->rootObject()->setProperty("width", width); + m_qmlObject->rootObject()->setProperty("height", height); + m_compactUiObject.data()->setProperty("applet", QVariant::fromValue(m_qmlObject->rootObject())); //hook m_compactUiObject size hints to this size hint diff --git a/src/shell/qmlpackages/desktop/contents/applet/CompactApplet.qml b/src/shell/qmlpackages/desktop/contents/applet/CompactApplet.qml index 578663741..f9e8a9ba7 100644 --- a/src/shell/qmlpackages/desktop/contents/applet/CompactApplet.qml +++ b/src/shell/qmlpackages/desktop/contents/applet/CompactApplet.qml @@ -42,8 +42,17 @@ Item { property Item compactRepresentation onAppletChanged: { - applet.parent = appletParent - applet.anchors.fill = applet.parent + + //if the applet size was restored to a stored size, or if is dragged from the desktop, restore popup size + if (applet.width > 0) { + popupWindow.mainItem.width = applet.width; + } + if (applet.height > 0) { + popupWindow.mainItem.height = applet.height; + } + + applet.parent = appletParent; + applet.anchors.fill = applet.parent; } onCompactRepresentationChanged: { compactRepresentation.parent = root @@ -62,8 +71,6 @@ Item { width: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.mSize(theme.defaultFont).width * 35 height: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.mSize(theme.defaultFont).height * 25 - onWidthChanged: applet.width = width - onHeightChanged: applet.height = height } onActiveWindowChanged: { From 2817591beebb956f3514e8e820e5ca01120b1b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Mon, 16 Sep 2013 16:16:21 +0200 Subject: [PATCH 34/57] kcoreauthorized.h -> kauthorized.h --- src/plasma/applet.cpp | 2 +- src/plasma/containment.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index f1ae819e6..49a9635bf 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index e5a29ff71..51d3bac77 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include From 70cef222119571cdaf0eb89bc685cb1b73d5f11a Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 16 Sep 2013 17:08:48 +0200 Subject: [PATCH 35/57] expose containmentInterface::actions the toolbox will use it --- .../qml/plasmoid/containmentinterface.cpp | 18 ++++++++++++++++++ .../qml/plasmoid/containmentinterface.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index f31ad4fa4..e40e63fc3 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -555,6 +555,24 @@ QString ContainmentInterface::activity() const return containment()->activity(); } +QList ContainmentInterface::actions() const +{ + //FIXME: giving directly a QList crashes + + //use a multimap to sort by action type + QMultiMap actions; + foreach (QAction *a, containment()->actions()->actions()) { + if (a->isEnabled()) { + actions.insert(a->data().toInt(), a); + } + } + foreach (QAction *a, containment()->corona()->actions()->actions()) { + if (a->isEnabled()) { + actions.insert(a->data().toInt(), a); + } + } + return actions.values(); +} diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index fd8953321..2889d65fc 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -58,6 +58,11 @@ class ContainmentInterface : public AppletInterface */ Q_PROPERTY(QString activity READ activity NOTIFY activityChanged) + /** + * Actions associated to this containment or corona + */ + Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) + public: ContainmentInterface(DeclarativeAppletScript *parent); //Not for QML @@ -75,6 +80,8 @@ public: QString activity() const; + QList actions() const; + /** * FIXME: either a property or not accessible at all. Lock or unlock widgets */ @@ -127,6 +134,7 @@ Q_SIGNALS: void drawWallpaperChanged(); void containmentTypeChanged(); ///void immutableChanged(); + void actionsChanged(); protected Q_SLOTS: void appletAddedForward(Plasma::Applet *applet); From f654bf31eb681a04c7e4da38b4bd2f8999b37ac0 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 16 Sep 2013 17:17:57 +0200 Subject: [PATCH 36/57] action for dashboard toggle --- src/shell/shellcorona.cpp | 16 ++++++++++++++++ src/shell/shellcorona.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/shell/shellcorona.cpp b/src/shell/shellcorona.cpp index c9b534d28..172d408ba 100644 --- a/src/shell/shellcorona.cpp +++ b/src/shell/shellcorona.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -95,6 +96,16 @@ ShellCorona::ShellCorona(QObject *parent) connect(d->scriptEngine, &WorkspaceScripting::ScriptEngine::print, this, &ShellCorona::printScriptMessage); + QAction *dashboardAction = actions()->add("show dashboard"); + QObject::connect(dashboardAction, &QAction::triggered, + this, &ShellCorona::toggleDashboard); + dashboardAction->setText(i18n("Show Dashboard")); + dashboardAction->setAutoRepeat(true); + dashboardAction->setIcon(QIcon::fromTheme("dashboard-show")); + dashboardAction->setData(Plasma::Types::ControlAction); + dashboardAction->setShortcut(QKeySequence("ctrl+f12")); + dashboardAction->setShortcutContext(Qt::ApplicationShortcut); + } ShellCorona::~ShellCorona() @@ -417,6 +428,11 @@ void ShellCorona::syncAppConfig() applicationConfig()->sync(); } +void ShellCorona::toggleDashboard() +{ + qDebug() << "TODO: Toggling dashboard view"; +} + void ShellCorona::printScriptError(const QString &error) { qWarning() << error; diff --git a/src/shell/shellcorona.h b/src/shell/shellcorona.h index 4d03f99c9..0e3f3ce9a 100644 --- a/src/shell/shellcorona.h +++ b/src/shell/shellcorona.h @@ -120,6 +120,7 @@ private Q_SLOTS: void handleContainmentAdded(Plasma::Containment *c); void showWidgetExplorer(); void syncAppConfig(); + void toggleDashboard(); private: class Private; From 5c25b8675ab8caa80de7d952b9a16c1dd7957e8b Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 16 Sep 2013 19:30:34 +0200 Subject: [PATCH 37/57] a very primitive dashboard right now we have a single view, that gets brought to front and the wallpaper made translucent. probably it will eventually need splitting the walppaper and the widgets in two separate views, but needs a more complex logic --- src/shell/desktopview.cpp | 27 +++++++++++++++++++ src/shell/desktopview.h | 2 ++ .../desktop/contents/views/Desktop.qml | 2 +- src/shell/shellcorona.cpp | 14 ++++++++-- src/shell/shellcorona.h | 2 +- 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/shell/desktopview.cpp b/src/shell/desktopview.cpp index 792243d01..8b921d406 100644 --- a/src/shell/desktopview.cpp +++ b/src/shell/desktopview.cpp @@ -81,6 +81,33 @@ void DesktopView::setFillScreen(bool fillScreen) emit fillScreenChanged(); } +void DesktopView::setDashboardShown(bool shown) +{ + if (shown) { + if (m_stayBehind) { + KWindowSystem::setType(winId(), NET::Normal); + } + raise(); + KWindowSystem::raiseWindow(winId()); + + QObject *wpGraphicObject = containment()->property("wallpaperGraphicsObject").value(); + if (wpGraphicObject) { + wpGraphicObject->setProperty("opacity", 0.3); + } + } else { + if (m_stayBehind) { + KWindowSystem::setType(winId(), NET::Desktop); + } + lower(); + KWindowSystem::lowerWindow(winId()); + + QObject *wpGraphicObject = containment()->property("wallpaperGraphicsObject").value(); + if (wpGraphicObject) { + wpGraphicObject->setProperty("opacity", 1); + } + } +} + /* void DesktopView::showConfigurationInterface(Plasma::Applet *applet) { diff --git a/src/shell/desktopview.h b/src/shell/desktopview.h index f7cc6044e..58315a345 100644 --- a/src/shell/desktopview.h +++ b/src/shell/desktopview.h @@ -42,6 +42,8 @@ public: bool fillScreen() const; void setFillScreen(bool fillScreen); + void setDashboardShown(bool shown); + protected Q_SLOTS: /** * It will be called when the configuration is requested diff --git a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml index 71c033de3..cf15d67d9 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml @@ -24,7 +24,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore Rectangle { id: root - color: "black" + color: Qt.rgba(0, 0, 0, 0.2) width: 1024 height: 768 diff --git a/src/shell/shellcorona.cpp b/src/shell/shellcorona.cpp index 172d408ba..79c269de3 100644 --- a/src/shell/shellcorona.cpp +++ b/src/shell/shellcorona.cpp @@ -98,9 +98,10 @@ ShellCorona::ShellCorona(QObject *parent) QAction *dashboardAction = actions()->add("show dashboard"); QObject::connect(dashboardAction, &QAction::triggered, - this, &ShellCorona::toggleDashboard); + this, &ShellCorona::setDashboardShown); dashboardAction->setText(i18n("Show Dashboard")); dashboardAction->setAutoRepeat(true); + dashboardAction->setCheckable(true); dashboardAction->setIcon(QIcon::fromTheme("dashboard-show")); dashboardAction->setData(Plasma::Types::ControlAction); dashboardAction->setShortcut(QKeySequence("ctrl+f12")); @@ -428,9 +429,18 @@ void ShellCorona::syncAppConfig() applicationConfig()->sync(); } -void ShellCorona::toggleDashboard() +void ShellCorona::setDashboardShown(bool show) { qDebug() << "TODO: Toggling dashboard view"; + + QAction *dashboardAction = actions()->action("show dashboard"); + + if (dashboardAction) { + dashboardAction->setText(show ? i18n("Hide Dashboard") : i18n("Show Dashboard")); + } + foreach (DesktopView *view, d->views) { + view->setDashboardShown(show); + } } void ShellCorona::printScriptError(const QString &error) diff --git a/src/shell/shellcorona.h b/src/shell/shellcorona.h index 0e3f3ce9a..17c00848a 100644 --- a/src/shell/shellcorona.h +++ b/src/shell/shellcorona.h @@ -120,7 +120,7 @@ private Q_SLOTS: void handleContainmentAdded(Plasma::Containment *c); void showWidgetExplorer(); void syncAppConfig(); - void toggleDashboard(); + void setDashboardShown(bool show); private: class Private; From 8f20c41931932ff2ebe02e3c4924461f1165f058 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 16 Sep 2013 19:45:49 +0200 Subject: [PATCH 38/57] moved containmentconfigview out of libplasmaquick --- src/plasmaquick/CMakeLists.txt | 4 ++-- src/plasmaquick/plasmaquickview.cpp | 8 +------- src/shell/CMakeLists.txt | 2 ++ .../containmentconfigview.cpp} | 7 +++---- .../containmentconfigview.h} | 0 .../currentcontainmentactionsmodel.cpp} | 4 ++-- .../currentcontainmentactionsmodel.h} | 0 src/shell/desktopview.cpp | 7 ++++--- src/shell/desktopview.h | 3 +-- 9 files changed, 15 insertions(+), 20 deletions(-) rename src/{plasmaquick/private/containmentconfigview_p.cpp => shell/containmentconfigview.cpp} (97%) rename src/{plasmaquick/private/containmentconfigview_p.h => shell/containmentconfigview.h} (100%) rename src/{plasmaquick/private/currentcontainmentactionsmodel_p.cpp => shell/currentcontainmentactionsmodel.cpp} (98%) rename src/{plasmaquick/private/currentcontainmentactionsmodel_p.h => shell/currentcontainmentactionsmodel.h} (100%) diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index 46bd11894..3540e8d94 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -5,8 +5,8 @@ set(plasmaquick_LIB_SRC configmodel.cpp configview.cpp private/configcategory_p.cpp - private/containmentconfigview_p.cpp - private/currentcontainmentactionsmodel_p.cpp + #private/containmentconfigview_p.cpp + #private/currentcontainmentactionsmodel_p.cpp ) diff --git a/src/plasmaquick/plasmaquickview.cpp b/src/plasmaquick/plasmaquickview.cpp index 72b29747a..dd6e8351f 100644 --- a/src/plasmaquick/plasmaquickview.cpp +++ b/src/plasmaquick/plasmaquickview.cpp @@ -17,7 +17,6 @@ */ #include "plasmaquickview.h" -#include "private/containmentconfigview_p.h" #include "configview.h" #include @@ -141,13 +140,8 @@ void PlasmaQuickViewPrivate::showConfigurationInterface(Plasma::Applet *applet) return; } - Plasma::Containment *cont = qobject_cast(applet); + configView = new ConfigView(applet); - if (cont) { - configView = new ContainmentConfigView(cont); - } else { - configView = new ConfigView(applet); - } configView.data()->init(); configView.data()->show(); } diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt index 2c6af922b..7c610f4ed 100644 --- a/src/shell/CMakeLists.txt +++ b/src/shell/CMakeLists.txt @@ -57,6 +57,8 @@ set(widgetexplorer_SRC add_executable(plasma-shell main.cpp + containmentconfigview.cpp + currentcontainmentactionsmodel.cpp desktopview.cpp panelview.cpp panelconfigview.cpp diff --git a/src/plasmaquick/private/containmentconfigview_p.cpp b/src/shell/containmentconfigview.cpp similarity index 97% rename from src/plasmaquick/private/containmentconfigview_p.cpp rename to src/shell/containmentconfigview.cpp index 8b1deb504..ca0c559d3 100644 --- a/src/plasmaquick/private/containmentconfigview_p.cpp +++ b/src/shell/containmentconfigview.cpp @@ -17,9 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "currentcontainmentactionsmodel_p.h" -#include "containmentconfigview_p.h" -#include "configcategory_p.h" +#include "currentcontainmentactionsmodel.h" +#include "containmentconfigview.h" #include "configmodel.h" #include @@ -182,4 +181,4 @@ void ContainmentConfigView::syncWallpaperObjects() m_currentWallpaperConfig = static_cast(wallpaperGraphicsObject->property("configuration").value()); } -#include "private/moc_containmentconfigview_p.cpp" +#include "private/moc_containmentconfigview.cpp" diff --git a/src/plasmaquick/private/containmentconfigview_p.h b/src/shell/containmentconfigview.h similarity index 100% rename from src/plasmaquick/private/containmentconfigview_p.h rename to src/shell/containmentconfigview.h diff --git a/src/plasmaquick/private/currentcontainmentactionsmodel_p.cpp b/src/shell/currentcontainmentactionsmodel.cpp similarity index 98% rename from src/plasmaquick/private/currentcontainmentactionsmodel_p.cpp rename to src/shell/currentcontainmentactionsmodel.cpp index 7a15ee21b..ab9370c3b 100644 --- a/src/plasmaquick/private/currentcontainmentactionsmodel_p.cpp +++ b/src/shell/currentcontainmentactionsmodel.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "currentcontainmentactionsmodel_p.h" +#include "currentcontainmentactionsmodel.h" #include @@ -259,4 +259,4 @@ void CurrentContainmentActionsModel::save() } } -#include "private/moc_currentcontainmentactionsmodel_p.cpp" +#include "private/moc_currentcontainmentactionsmodel.cpp" diff --git a/src/plasmaquick/private/currentcontainmentactionsmodel_p.h b/src/shell/currentcontainmentactionsmodel.h similarity index 100% rename from src/plasmaquick/private/currentcontainmentactionsmodel_p.h rename to src/shell/currentcontainmentactionsmodel.h diff --git a/src/shell/desktopview.cpp b/src/shell/desktopview.cpp index 8b921d406..55db89418 100644 --- a/src/shell/desktopview.cpp +++ b/src/shell/desktopview.cpp @@ -17,6 +17,7 @@ */ #include "desktopview.h" +#include "containmentconfigview.h" #include "shellcorona.h" #include "shellmanager.h" @@ -108,7 +109,7 @@ void DesktopView::setDashboardShown(bool shown) } } -/* + void DesktopView::showConfigurationInterface(Plasma::Applet *applet) { if (m_configView) { @@ -123,13 +124,13 @@ void DesktopView::showConfigurationInterface(Plasma::Applet *applet) Plasma::Containment *cont = qobject_cast(applet); if (cont) { - m_configView = new PanelConfigView(cont, this); + m_configView = new ContainmentConfigView(cont); } else { m_configView = new ConfigView(applet); } m_configView.data()->init(); m_configView.data()->show(); -}*/ +} #include "moc_desktopview.cpp" diff --git a/src/shell/desktopview.h b/src/shell/desktopview.h index 58315a345..b8b9caafb 100644 --- a/src/shell/desktopview.h +++ b/src/shell/desktopview.h @@ -47,9 +47,8 @@ public: protected Q_SLOTS: /** * It will be called when the configuration is requested - * FIXME: this should be moved here */ - //virtual void showConfigurationInterface(Plasma::Applet *applet); + virtual void showConfigurationInterface(Plasma::Applet *applet); Q_SIGNALS: void stayBehindChanged(); From 930c8647e6b466c81891b19d0cd0a622a6f11f12 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 18 Sep 2013 12:10:03 +0200 Subject: [PATCH 39/57] add a dummy url interceptor will be used for device specific stuff --- src/scriptengines/qml/CMakeLists.txt | 1 + .../qml/declarative/packageurlinterceptor.cpp | 42 ++++++++++++ .../qml/declarative/packageurlinterceptor.h | 40 +++++++++++ .../qqmlabstracturlinterceptor_p.h | 66 +++++++++++++++++++ .../qml/plasmoid/appletinterface.cpp | 5 ++ 5 files changed, 154 insertions(+) create mode 100644 src/scriptengines/qml/declarative/packageurlinterceptor.cpp create mode 100644 src/scriptengines/qml/declarative/packageurlinterceptor.h create mode 100644 src/scriptengines/qml/declarative/qqmlabstracturlinterceptor_p.h diff --git a/src/scriptengines/qml/CMakeLists.txt b/src/scriptengines/qml/CMakeLists.txt index d21c5d2ea..7f00b99e6 100644 --- a/src/scriptengines/qml/CMakeLists.txt +++ b/src/scriptengines/qml/CMakeLists.txt @@ -15,6 +15,7 @@ include_directories(${KDE4_INCLUDE_DIR}/KDE ${PHONON_INCLUDES} ${CMAKE_CURRENT_S set(declarative_appletscript_SRCS declarative/packageaccessmanager.cpp declarative/packageaccessmanagerfactory.cpp + declarative/packageurlinterceptor.cpp plasmoid/appletinterface.cpp plasmoid/containmentinterface.cpp plasmoid/declarativeappletscript.cpp diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp new file mode 100644 index 000000000..61bb17621 --- /dev/null +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2013 Marco Martin + * + * 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 "packageurlinterceptor.h" + +#include + +PackageUrlInterceptor::PackageUrlInterceptor(const Plasma::Package &p) + : QQmlAbstractUrlInterceptor(), + m_package(p) +{ +} + +PackageUrlInterceptor::~PackageUrlInterceptor() +{ +} + +QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type) +{ + //qDebug() << "Intercepted URL:" << path; + + return path; +} + + + diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.h b/src/scriptengines/qml/declarative/packageurlinterceptor.h new file mode 100644 index 000000000..0827de090 --- /dev/null +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.h @@ -0,0 +1,40 @@ +/* + * Copyright 2013 Marco Martin + * + * 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 PACKAGEURLINTERCEPTOR_H +#define PACKAGEURLINTERCEPTOR_H + +#include "qqmlabstracturlinterceptor_p.h" + +#include + +class PackageUrlInterceptor: public QQmlAbstractUrlInterceptor +{ +public: + PackageUrlInterceptor(const Plasma::Package &p); + virtual ~PackageUrlInterceptor(); + + virtual QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type); + +private: + Plasma::Package m_package; +}; + + +#endif diff --git a/src/scriptengines/qml/declarative/qqmlabstracturlinterceptor_p.h b/src/scriptengines/qml/declarative/qqmlabstracturlinterceptor_p.h new file mode 100644 index 000000000..01ef3e65e --- /dev/null +++ b/src/scriptengines/qml/declarative/qqmlabstracturlinterceptor_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//Private API for 5.1 (at least) +#ifndef QQMLABSTRACTURLINTERCEPTOR_H +#define QQMLABSTRACTURLINTERCEPTOR_H + +#include + +QT_BEGIN_NAMESPACE + +class QQmlAbstractUrlInterceptor +{ + Q_FLAGS(InterceptionPoint) +public: + enum DataType { //Matches QQmlDataBlob::Type + QmlFile = 0, + JavaScriptFile = 1, + QmldirFile = 2, + UrlString = 0x1000 + }; + + QQmlAbstractUrlInterceptor() {} + virtual ~QQmlAbstractUrlInterceptor() {} + virtual QUrl intercept(const QUrl &path, DataType type) = 0; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index ab7bf1b05..c30ec994f 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -49,6 +49,7 @@ #include #include #include "declarative/packageaccessmanagerfactory.h" +#include "declarative/packageurlinterceptor.h" Q_DECLARE_METATYPE(AppletInterface*) @@ -112,6 +113,10 @@ void AppletInterface::init() delete factory; engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package())); + //Hook generic url resolution to the applet package as well + //TODO: same thing will have to be done for every qqmlengine: PackageUrlInterceptor is material for plasmaquick? + engine->setUrlInterceptor(new PackageUrlInterceptor(m_appletScriptEngine->package())); + m_qmlObject->setSource(QUrl::fromLocalFile(m_appletScriptEngine->mainScript())); if (!m_qmlObject->engine() || !m_qmlObject->engine()->rootContext() || !m_qmlObject->engine()->rootContext()->isValid() || m_qmlObject->mainComponent()->isError()) { From b1c49c5d4404b02407082bcd761fe1aa717108f0 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 18 Sep 2013 12:49:09 +0200 Subject: [PATCH 40/57] working package redirection for qml files --- .../qml/declarative/packageurlinterceptor.cpp | 44 ++++++++++++++++++- .../qml/declarative/packageurlinterceptor.h | 5 ++- .../qml/plasmoid/appletinterface.cpp | 2 +- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp index 61bb17621..15387231c 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp @@ -20,10 +20,12 @@ #include "packageurlinterceptor.h" #include +#include -PackageUrlInterceptor::PackageUrlInterceptor(const Plasma::Package &p) +PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p) : QQmlAbstractUrlInterceptor(), - m_package(p) + m_package(p), + m_engine(engine) { } @@ -35,6 +37,44 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept { //qDebug() << "Intercepted URL:" << path; + //TODO: security: permission for remote urls + if (!path.isLocalFile() ) { + return path; + } + + switch (type) { + case QQmlAbstractUrlInterceptor::QmlFile: + if (path.path().startsWith(m_package.path())) { + //qDebug() << "Found URL in package" << path; + QStringList components = path.toLocalFile().split("/"); + if (components.count() < 2) { + return path; + } + QString filename = components.last(); + components.pop_back(); + QString type = components.last(); + if (type == "ui" || type == "config") { + //qDebug() << "Returning" << QUrl::fromLocalFile(m_package.filePath(type.toLatin1(), filename)); + return QUrl::fromLocalFile(m_package.filePath(type.toLatin1(), filename)); + } + //forbid to load random absolute paths + } else { + foreach (const QString &import, m_engine->importPathList()) { + //it's from an import, good + //TODO: implement imports whitelist? + if (path.path().startsWith(import)) { + // qDebug() << "Found import, access granted"; + return path; + } + } + qWarning() << "Access denied for url" << path; + } + break; + + default: + break; + } + return path; } diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.h b/src/scriptengines/qml/declarative/packageurlinterceptor.h index 0827de090..b590a3a93 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.h +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.h @@ -24,16 +24,19 @@ #include +class QQmlEngine; + class PackageUrlInterceptor: public QQmlAbstractUrlInterceptor { public: - PackageUrlInterceptor(const Plasma::Package &p); + PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p); virtual ~PackageUrlInterceptor(); virtual QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type); private: Plasma::Package m_package; + QQmlEngine *m_engine; }; diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index c30ec994f..34e7913e8 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -115,7 +115,7 @@ void AppletInterface::init() //Hook generic url resolution to the applet package as well //TODO: same thing will have to be done for every qqmlengine: PackageUrlInterceptor is material for plasmaquick? - engine->setUrlInterceptor(new PackageUrlInterceptor(m_appletScriptEngine->package())); + engine->setUrlInterceptor(new PackageUrlInterceptor(engine, m_appletScriptEngine->package())); m_qmlObject->setSource(QUrl::fromLocalFile(m_appletScriptEngine->mainScript())); From 6d65ece95a377318b052d012fae9deff5f15a77c Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 18 Sep 2013 14:11:16 +0200 Subject: [PATCH 41/57] more strict in package resolution also resolve js files too --- .../qml/declarative/packageurlinterceptor.cpp | 40 +++++++++++++------ .../qml/declarative/packageurlinterceptor.h | 13 ++++++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp index 15387231c..c8e78fdb9 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp @@ -44,30 +44,44 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept switch (type) { case QQmlAbstractUrlInterceptor::QmlFile: + case QQmlAbstractUrlInterceptor::JavaScriptFile: + //asked a file inside a package: let's rewrite the url! if (path.path().startsWith(m_package.path())) { - //qDebug() << "Found URL in package" << path; - QStringList components = path.toLocalFile().split("/"); - if (components.count() < 2) { - return path; - } - QString filename = components.last(); - components.pop_back(); - QString type = components.last(); - if (type == "ui" || type == "config") { - //qDebug() << "Returning" << QUrl::fromLocalFile(m_package.filePath(type.toLatin1(), filename)); - return QUrl::fromLocalFile(m_package.filePath(type.toLatin1(), filename)); + qDebug() << "Found URL in package" << path; + + //tries to isolate the relative path asked relative to the contentsPrefixPath: like ui/foo.qml + QString relativePath; + foreach (const QString &prefix, m_package.contentsPrefixPaths()) { + if (path.path().startsWith(m_package.path()+prefix)) { + //obtain a string in the form ui/foo/bar/baz.qml + relativePath = path.path().mid(QString(m_package.path()+prefix).length()); + break; + } } + //should never happen + Q_ASSERT(!relativePath.isEmpty()); + + QStringList components = relativePath.split("/"); + Q_ASSERT(components.count() >= 2); + + components.pop_front(); + //obtain a string in the form foo/bar/baz.qml, ui/ gets discarded + QString filename = components.join("/"); + + //qDebug() << "Returning" << QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename)); + return QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename)); + //forbid to load random absolute paths } else { foreach (const QString &import, m_engine->importPathList()) { //it's from an import, good //TODO: implement imports whitelist? if (path.path().startsWith(import)) { - // qDebug() << "Found import, access granted"; + //qDebug() << "Found import, access granted"; return path; } } - qWarning() << "Access denied for url" << path; + qWarning() << "WARNING: Access denied for URL" << path; } break; diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.h b/src/scriptengines/qml/declarative/packageurlinterceptor.h index b590a3a93..28f04294e 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.h +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.h @@ -34,6 +34,19 @@ public: virtual QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type); + static inline QByteArray prefixForType(QQmlAbstractUrlInterceptor::DataType type, const QString &fileName) + { + switch (type) { + case QQmlAbstractUrlInterceptor::QmlFile: + return "ui"; + case QQmlAbstractUrlInterceptor::JavaScriptFile: + return "scripts"; + default: + break; + } + return ""; + } + private: Plasma::Package m_package; QQmlEngine *m_engine; From d567b3414b078b6cee36034df1beec18556393ef Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 18 Sep 2013 15:41:21 +0200 Subject: [PATCH 42/57] catch file types by extension too --- .../qml/declarative/packageurlinterceptor.cpp | 11 +++-------- .../qml/declarative/packageurlinterceptor.h | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp index c8e78fdb9..fc79a5832 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp @@ -42,12 +42,11 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept return path; } - switch (type) { - case QQmlAbstractUrlInterceptor::QmlFile: - case QQmlAbstractUrlInterceptor::JavaScriptFile: + if (type != QQmlAbstractUrlInterceptor::QmldirFile) { + //asked a file inside a package: let's rewrite the url! if (path.path().startsWith(m_package.path())) { - qDebug() << "Found URL in package" << path; + //qDebug() << "Found URL in package" << path; //tries to isolate the relative path asked relative to the contentsPrefixPath: like ui/foo.qml QString relativePath; @@ -83,10 +82,6 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept } qWarning() << "WARNING: Access denied for URL" << path; } - break; - - default: - break; } return path; diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.h b/src/scriptengines/qml/declarative/packageurlinterceptor.h index 28f04294e..040936bd3 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.h +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.h @@ -44,7 +44,23 @@ public: default: break; } - return ""; + + //failed by type, let's try by extension + const QString extension = fileName.mid(fileName.lastIndexOf(".") + 1).toLower(); + + if (extension == "svg" || extension == "svgz" || + extension == "png" || extension == "gif" || + extension == "jpg" || extension == "jpeg") { + return "images"; + //FIXME: are those necessary? are they *always* catched by type? + } else if (extension == "js") { + return "scripts"; + } else if (extension == "qml") { + return "ui"; + //everything else, throw it in "data" + } else { + return "data"; + } } private: From 5b0fcd8113c59a9794922c1670e6304b4747ebd6 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 18 Sep 2013 16:34:31 +0200 Subject: [PATCH 43/57] platform specific resolution of imports --- .../qml/declarative/packageurlinterceptor.cpp | 25 +++++++++++++++++-- .../qml/declarative/packageurlinterceptor.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp index fc79a5832..af7f946df 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp @@ -21,6 +21,9 @@ #include #include +#include + +#include PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p) : QQmlAbstractUrlInterceptor(), @@ -42,6 +45,9 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept return path; } + //FIXME: probably needed for QmldirFile as well. + //at the moment a qt bug prevents intercept() working with qmldirs + //see https://codereview.qt-project.org/#change,61208 if (type != QQmlAbstractUrlInterceptor::QmldirFile) { //asked a file inside a package: let's rewrite the url! @@ -61,10 +67,11 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept Q_ASSERT(!relativePath.isEmpty()); QStringList components = relativePath.split("/"); + //a path with less than 2 items should ever happen Q_ASSERT(components.count() >= 2); components.pop_front(); - //obtain a string in the form foo/bar/baz.qml, ui/ gets discarded + //obtain a string in the form foo/bar/baz.qml: ui/ gets discarded QString filename = components.join("/"); //qDebug() << "Returning" << QUrl::fromLocalFile(m_package.filePath(prefixForType(type, filename), filename)); @@ -76,7 +83,21 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept //it's from an import, good //TODO: implement imports whitelist? if (path.path().startsWith(import)) { - //qDebug() << "Found import, access granted"; + qDebug() << "Found import, access granted" << path; + + //check if there is a platform specific file that overrides this import + foreach (const QString &platform, KDeclarative::runtimePlatform()) { + qDebug() << "Trying" << platform; + + //search for a platformqml/ path sibling of this import path + QString platformPath = import+"/../platformqml/"+platform+path.path().mid(import.length()); + QFile f(platformPath); + + qDebug() << "Found a platform specific file:" << QUrl::fromLocalFile(platformPath)< Date: Wed, 18 Sep 2013 18:09:33 +0200 Subject: [PATCH 44/57] Fix include --- src/scriptengines/qml/declarative/packageurlinterceptor.cpp | 2 +- tools/port-kdebug.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp index af7f946df..e8a7a5cd8 100644 --- a/src/scriptengines/qml/declarative/packageurlinterceptor.cpp +++ b/src/scriptengines/qml/declarative/packageurlinterceptor.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include PackageUrlInterceptor::PackageUrlInterceptor(QQmlEngine *engine, const Plasma::Package &p) : QQmlAbstractUrlInterceptor(), diff --git a/tools/port-kdebug.sh b/tools/port-kdebug.sh index 4b4c55ac3..5caf46743 100755 --- a/tools/port-kdebug.sh +++ b/tools/port-kdebug.sh @@ -3,6 +3,7 @@ # kDebug() becomes qDebug() in cpp files for FS in `find $PWD -name '*.h' -o -name '*.cpp'`; do + perl -p -i -e 's/\#include \/\#include \/g' $FS perl -p -i -e 's/\#include \/\#include \/g' $FS perl -p -i -e 's/\#include \/\#include \/g' $FS perl -p -i -e 's/kDebug\(\)/qDebug()/g' $FS From 9b3b387b0b4b3e0e25dfcaa6eac84109c70781e4 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 18 Sep 2013 21:35:43 +0200 Subject: [PATCH 45/57] new install targe --- .../plasmacomponents/CMakeLists.txt | 76 +++++++++---------- .../platformcomponents/touch/TextField.qml | 2 - 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/declarativeimports/plasmacomponents/CMakeLists.txt b/src/declarativeimports/plasmacomponents/CMakeLists.txt index c7e9e96fa..75c179143 100644 --- a/src/declarativeimports/plasmacomponents/CMakeLists.txt +++ b/src/declarativeimports/plasmacomponents/CMakeLists.txt @@ -40,47 +40,47 @@ install(DIRECTORY qml/ DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/components) #The platform specific stuff, overwrites a copy of the desktop one #it does install some files on top of the old ones, has to be done file by file since if some component from the generic set is more recent than the specifc ones, it wouldn't be overwritten -install(TARGETS plasmacomponentsplugin DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) +install(TARGETS plasmacomponentsplugin DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) -install(FILES qml/BusyIndicator.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ButtonColumn.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ButtonGroup.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/Button.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ButtonRow.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/CheckBox.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/CommonDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/Dialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/Highlight.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/Label.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ListItem.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/Page.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/PageStack.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ProgressBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/QueryDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/RadioButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/SelectionDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/Slider.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/TabBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/TabButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/TabGroup.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -#install(FILES qml/TextArea.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -#install(FILES qml/TextField.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ToolBarLayout.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ToolBar.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) -install(FILES qml/ToolButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) +install(FILES qml/BusyIndicator.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ButtonColumn.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ButtonGroup.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/Button.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ButtonRow.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/CheckBox.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/CommonDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/Dialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/Highlight.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/Label.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ListItem.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/Page.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/PageStack.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ProgressBar.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/QueryDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/RadioButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/SelectionDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/Slider.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/TabBar.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/TabButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/TabGroup.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +#install(FILES qml/TextArea.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +#install(FILES qml/TextField.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ToolBarLayout.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ToolBar.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) +install(FILES qml/ToolButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) #Now install the private stuff! -install(FILES qml/private/DualStateButton.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/InlineDialog.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/PageStack.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/TabGroup.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/ScrollBarDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/ScrollDecoratorDelegate.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/SectionScroller.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/AppManager.js DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/TabBarLayout.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) -install(FILES qml/private/TextFieldFocus.qml DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components/private) +install(FILES qml/private/DualStateButton.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/InlineDialog.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/PageStack.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/TabGroup.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/ScrollBarDelegate.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/ScrollDecoratorDelegate.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/SectionScroller.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/AppManager.js DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/TabBarLayout.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) +install(FILES qml/private/TextFieldFocus.qml DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components/private) #install platform overrides -install(DIRECTORY platformcomponents/touch/ DESTINATION ${PLUGIN_INSTALL_DIR}/platformimports/touch/org/kde/plasma/components) +install(DIRECTORY platformcomponents/touch/ DESTINATION ${QML_INSTALL_DIR}/../platformqml/touch/org/kde/plasma/components) diff --git a/src/declarativeimports/plasmacomponents/platformcomponents/touch/TextField.qml b/src/declarativeimports/plasmacomponents/platformcomponents/touch/TextField.qml index d4b7cad28..811859028 100644 --- a/src/declarativeimports/plasmacomponents/platformcomponents/touch/TextField.qml +++ b/src/declarativeimports/plasmacomponents/platformcomponents/touch/TextField.qml @@ -87,8 +87,6 @@ Item { textInput.forceActiveFocus(); } - // Overriding QtQuick.Item activeFocus property. - property alias activeFocus: textInput.activeFocus // TODO: fix default size implicitWidth: theme.mSize(theme.defaultFont).width*12 From 7489fa32f8109e4db1a0e05d003de3299179e051 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 19 Sep 2013 19:37:10 +0200 Subject: [PATCH 46/57] argsrc for config that can be passed as parameter instead of args of the applet ctor, applets can define an argsrc file for what is acceptable as mimedata on drag and drop (or any other dynamic creation) --- .../applets/config/contents/config/argsrc | 2 ++ examples/applets/config/metadata.desktop | 1 + .../qml/plasmoid/containmentinterface.cpp | 27 +++++++++++++++++-- .../qml/plasmoid/containmentinterface.h | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 examples/applets/config/contents/config/argsrc diff --git a/examples/applets/config/contents/config/argsrc b/examples/applets/config/contents/config/argsrc new file mode 100644 index 000000000..1e6ab2638 --- /dev/null +++ b/examples/applets/config/contents/config/argsrc @@ -0,0 +1,2 @@ +[General] +text/plain=Test \ No newline at end of file diff --git a/examples/applets/config/metadata.desktop b/examples/applets/config/metadata.desktop index a0ee439f0..a574e3578 100644 --- a/examples/applets/config/metadata.desktop +++ b/examples/applets/config/metadata.desktop @@ -23,3 +23,4 @@ X-KDE-PluginInfo-Name=org.kde.example.configuration X-KDE-PluginInfo-Version= X-KDE-PluginInfo-Website= X-Plasma-MainScript=ui/main.qml +X-Plasma-DropMimeTypes=text/plain diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index e40e63fc3..400f66b8c 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -195,7 +195,7 @@ QVariantList ContainmentInterface::availableScreenRegion(int id) const return regVal; } -void ContainmentInterface::addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos) +Plasma::Applet *ContainmentInterface::addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos) { //HACK //This is necessary to delay the appletAdded signal (of containmentInterface) AFTER the applet graphics object has been created @@ -211,6 +211,7 @@ void ContainmentInterface::addApplet(const QString &plugin, const QVariantList & emit appletAdded(appletGraphicObject, pos.x(), pos.y()); emit appletsChanged(); + return applet; } void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) @@ -467,7 +468,29 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet m_wallpaperInterface->setUrl(tjob->url()); } } else { - addApplet(actionsToApplets[choice], args, posi); + Plasma::Applet *applet = addApplet(actionsToApplets[choice], args, posi); + //TODO: put in a function + if (applet) { + KConfig argsConf(applet->package().filePath("config", "argsrc")); + foreach (const QString &group, argsConf.groupList()) { + KConfigGroup cg(&argsConf, group); + if (cg.hasKey(mimetype)) { + QString key = cg.readEntry(mimetype); + + Plasma::ConfigLoader *config = applet->configScheme(); + if (config) { + KConfigSkeletonItem *item = config->findItemByName(key); + if (item) { + item->setProperty(tjob->url()); + config->blockSignals(true); + config->writeConfig(); + config->blockSignals(false); + m_appletScriptEngine->configNeedsSaving(); + } + } + } + } + } } clearDataForMimeJob(job); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index 2889d65fc..9a5242bc8 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -145,7 +145,7 @@ protected Q_SLOTS: private: void clearDataForMimeJob(KIO::Job *job); - void addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos); + Plasma::Applet *addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos); WallpaperInterface *m_wallpaperInterface; QList m_appletInterfaces; From 3656c416f29778e3537584dcf21278501c54290c Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 19 Sep 2013 19:52:53 +0200 Subject: [PATCH 47/57] manage args also for pasted text without urls --- .../qml/plasmoid/containmentinterface.cpp | 58 +++++++++++-------- .../qml/plasmoid/containmentinterface.h | 1 + 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 400f66b8c..fdb8ee681 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -214,6 +214,33 @@ Plasma::Applet *ContainmentInterface::addApplet(const QString &plugin, const QVa return applet; } +void ContainmentInterface::setAppletArgs(Plasma::Applet *applet, const QString &mimetype, const QString &data) +{ + if (!applet) { + return; + } + + KConfig argsConf(applet->package().filePath("config", "argsrc")); + foreach (const QString &group, argsConf.groupList()) { + KConfigGroup cg(&argsConf, group); + if (cg.hasKey(mimetype)) { + QString key = cg.readEntry(mimetype); + + Plasma::ConfigLoader *config = applet->configScheme(); + if (config) { + KConfigSkeletonItem *item = config->findItemByName(key); + if (item) { + item->setProperty(data); + config->blockSignals(true); + config->writeConfig(); + config->blockSignals(false); + m_appletScriptEngine->configNeedsSaving(); + } + } + } + } +} + void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) { if (!mimeData) { @@ -310,6 +337,7 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) if (!selectedPlugin.isEmpty()) { + //TODO: remove all this temp file logic KTemporaryFile tempFile; if (mimeData && tempFile.open()) { //TODO: what should we do with files after the applet is done with them?? @@ -326,7 +354,8 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) qDebug() << args; tempFile.close(); - addApplet(selectedPlugin, args, QPoint(x, y)); + Plasma::Applet *applet = addApplet(selectedPlugin, args, QPoint(x, y)); + setAppletArgs(applet, pluginFormats[selectedPlugin], mimeData->data(pluginFormats[selectedPlugin])); } } } @@ -395,6 +424,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet return; } + //TODO: remove assignment of applet args QVariantList args; args << tjob->url().url() << mimetype; @@ -469,28 +499,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet } } else { Plasma::Applet *applet = addApplet(actionsToApplets[choice], args, posi); - //TODO: put in a function - if (applet) { - KConfig argsConf(applet->package().filePath("config", "argsrc")); - foreach (const QString &group, argsConf.groupList()) { - KConfigGroup cg(&argsConf, group); - if (cg.hasKey(mimetype)) { - QString key = cg.readEntry(mimetype); - - Plasma::ConfigLoader *config = applet->configScheme(); - if (config) { - KConfigSkeletonItem *item = config->findItemByName(key); - if (item) { - item->setProperty(tjob->url()); - config->blockSignals(true); - config->writeConfig(); - config->blockSignals(false); - m_appletScriptEngine->configNeedsSaving(); - } - } - } - } - } + setAppletArgs(applet, mimetype, tjob->url().toString()); } clearDataForMimeJob(job); @@ -498,7 +507,8 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet } } else { // we can at least create an icon as a link to the URL - addApplet("org.kde.icon", args, posi); + Plasma::Applet *applet = addApplet("org.kde.icon", args, posi); + setAppletArgs(applet, mimetype, tjob->url().toString()); } } diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index 9a5242bc8..9048590d0 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -146,6 +146,7 @@ protected Q_SLOTS: private: void clearDataForMimeJob(KIO::Job *job); Plasma::Applet *addApplet(const QString &plugin, const QVariantList &args, const QPoint &pos); + void setAppletArgs(Plasma::Applet *applet, const QString &mimetype, const QString &data); WallpaperInterface *m_wallpaperInterface; QList m_appletInterfaces; From b14c23bed09e0f284744f6d22528cda3b6657416 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 20 Sep 2013 12:59:35 +0200 Subject: [PATCH 48/57] new way for sending data plasmoid has an externalData signal, and will be used like Connections { target: plasmoid onExternalData: { if (mimetype === "text/plain") { noteText.text = data } } } a notes example applet describes its use --- examples/applets/CMakeLists.txt | 5 ++- .../applets/config/contents/config/argsrc | 2 - examples/applets/config/metadata.desktop | 1 - .../applets/notes/contents/config/main.xml | 15 +++++++ examples/applets/notes/contents/ui/main.qml | 45 +++++++++++++++++++ examples/applets/notes/metadata.desktop | 19 ++++++++ .../qml/plasmoid/appletinterface.h | 7 +++ .../qml/plasmoid/containmentinterface.cpp | 21 +-------- 8 files changed, 91 insertions(+), 24 deletions(-) delete mode 100644 examples/applets/config/contents/config/argsrc create mode 100644 examples/applets/notes/contents/config/main.xml create mode 100644 examples/applets/notes/contents/ui/main.qml create mode 100644 examples/applets/notes/metadata.desktop diff --git a/examples/applets/CMakeLists.txt b/examples/applets/CMakeLists.txt index ef7e80689..37780fb34 100644 --- a/examples/applets/CMakeLists.txt +++ b/examples/applets/CMakeLists.txt @@ -1,11 +1,12 @@ plasma_install_package(config org.kde.example.configuration) plasma_install_package(localegallery org.kde.example.locale) +plasma_install_package(notes org.kde.example.notes) plasma_install_package(widgetgallery org.kde.example.widgetgallery) plasma_install_package(qmltasks org.kde.example.tasks) plasma_install_package(windowthumbnails org.kde.example.windowthumbnails) plasma_install_package(conditionalloader org.kde.example.conditionalloader) plasma_install_package(testcomponents org.kde.example.testcomponents) plasma_install_package(testshaders org.kde.example.testshaders) -plasma_install_package(helloworld org.kde.examples.helloworld) -plasma_install_package(compactrepresentation org.kde.examples.compactrepresentation) \ No newline at end of file +plasma_install_package(helloworld org.kde.example.helloworld) +plasma_install_package(compactrepresentation org.kde.example.compactrepresentation) diff --git a/examples/applets/config/contents/config/argsrc b/examples/applets/config/contents/config/argsrc deleted file mode 100644 index 1e6ab2638..000000000 --- a/examples/applets/config/contents/config/argsrc +++ /dev/null @@ -1,2 +0,0 @@ -[General] -text/plain=Test \ No newline at end of file diff --git a/examples/applets/config/metadata.desktop b/examples/applets/config/metadata.desktop index a574e3578..a0ee439f0 100644 --- a/examples/applets/config/metadata.desktop +++ b/examples/applets/config/metadata.desktop @@ -23,4 +23,3 @@ X-KDE-PluginInfo-Name=org.kde.example.configuration X-KDE-PluginInfo-Version= X-KDE-PluginInfo-Website= X-Plasma-MainScript=ui/main.qml -X-Plasma-DropMimeTypes=text/plain diff --git a/examples/applets/notes/contents/config/main.xml b/examples/applets/notes/contents/config/main.xml new file mode 100644 index 000000000..dc3720aa6 --- /dev/null +++ b/examples/applets/notes/contents/config/main.xml @@ -0,0 +1,15 @@ + + + + + + + + Hello! + + + + diff --git a/examples/applets/notes/contents/ui/main.qml b/examples/applets/notes/contents/ui/main.qml new file mode 100644 index 000000000..d0c5e13fc --- /dev/null +++ b/examples/applets/notes/contents/ui/main.qml @@ -0,0 +1,45 @@ +/* + * Copyright 2013 Marco Martin + * + * 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. + */ + +import QtQuick 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + +PlasmaCore.SvgItem { + property int minimumWidth: 150 + property int minimumHeight: 150 + svg: PlasmaCore.Svg("widgets/notes") + elementId: "yellow-notes" + + Connections { + target: plasmoid + onExternalData: { + if (mimetype === "text/plain") { + noteText.text = data + } + } + } + + PlasmaComponents.TextArea { + id: noteText + anchors.fill: parent + text: plasmoid.configuration.Text + onTextChanged: plasmoid.configuration.Text = text + } +} diff --git a/examples/applets/notes/metadata.desktop b/examples/applets/notes/metadata.desktop new file mode 100644 index 000000000..23e1dba45 --- /dev/null +++ b/examples/applets/notes/metadata.desktop @@ -0,0 +1,19 @@ +[Desktop Entry] +Comment=Example on how to manage Drop data +Encoding=UTF-8 +Keywords= +Name=Example notes +Type=Service +Icon=knotes +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Category=Miscellaneous +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=org.kde.example.notes +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-Plasma-MainScript=ui/main.qml +X-Plasma-DropMimeTypes=text/plain \ No newline at end of file diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 44a27a9d0..bdcdde601 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -281,6 +281,13 @@ public: qreal implicitHeight() const; Q_SIGNALS: + /** + * somebody else, usually the containment sent some data to the applet + * @param mimetype the mime type of the data such as text/plain + * @param data either the actual data or an URL representing it + */ + void externalData(const QString &mimetype, const QVariant &data); + void releaseVisualFocus(); void configNeedsSaving(); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index fdb8ee681..39194e5d0 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -220,25 +220,8 @@ void ContainmentInterface::setAppletArgs(Plasma::Applet *applet, const QString & return; } - KConfig argsConf(applet->package().filePath("config", "argsrc")); - foreach (const QString &group, argsConf.groupList()) { - KConfigGroup cg(&argsConf, group); - if (cg.hasKey(mimetype)) { - QString key = cg.readEntry(mimetype); - - Plasma::ConfigLoader *config = applet->configScheme(); - if (config) { - KConfigSkeletonItem *item = config->findItemByName(key); - if (item) { - item->setProperty(data); - config->blockSignals(true); - config->writeConfig(); - config->blockSignals(false); - m_appletScriptEngine->configNeedsSaving(); - } - } - } - } + AppletInterface *appletInterface = applet->property("graphicObject").value(); + emit appletInterface->externalData(mimetype, data); } void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) From 4767f3a8d0ef018c9603359d42142d579ec01a7b Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 20 Sep 2013 18:18:46 +0200 Subject: [PATCH 49/57] emit appletadded only when manually added when the containment's component.oncompleted is hitted, the applet list is guaranteed to be completely correctly restored from config we may want to support both cases in the future to make writing containment easier --- src/plasma/containment.cpp | 6 ++--- .../qml/plasmoid/appletinterface.h | 2 ++ .../qml/plasmoid/containmentinterface.cpp | 24 ++++++------------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp index 51d3bac77..1322b0b50 100644 --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -181,15 +181,15 @@ void Containment::restore(KConfigGroup &group) setFormFactor((Plasma::Types::FormFactor)group.readEntry("formfactor", (int)d->formFactor)); setWallpaper(group.readEntry("wallpaperplugin", ContainmentPrivate::defaultWallpaper)); - //qDebug() << "setScreen from restore"; - d->setScreen(group.readEntry("screen", d->screen)); + d->activityId = group.readEntry("activityId", QString()); flushPendingConstraintsEvents(); restoreContents(group); setImmutability((Types::ImmutabilityType)group.readEntry("immutability", (int)Types::Mutable)); - + //qDebug() << "setScreen from restore"; + d->setScreen(group.readEntry("screen", d->screen)); KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins"); cfg = KConfigGroup(&cfg, QString::number(containmentType())); diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index bdcdde601..a394ac6ad 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -192,6 +192,7 @@ public: Q_INVOKABLE QAction *action(QString name) const; /** + * FIXME: remove? * Retrieve the path of a file from the Plasmoid package * @param fileName the package-recognized name, such as "mainscript" * @returns the full absolute path of the file, if found, an empty string if not @@ -199,6 +200,7 @@ public: Q_INVOKABLE QString file(const QString &fileName); /** + * FIXME: remove? * Retrieve the path of a file from the Plasmoid package * @param fileType the type supported from the package, such as "ui", "config" or "image" * @param filePath the name of the file, such as "foo.qml" or "bar.png" diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 39194e5d0..74828f2e1 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -76,27 +76,17 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent) connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged, this, &ContainmentInterface::availableScreenRegionChanged); } -} - -void ContainmentInterface::init() -{ - AppletInterface::init(); - - foreach (QObject *appletObj, m_appletInterfaces) { - AppletInterface *applet = qobject_cast(appletObj); - if (applet) { - if (!applet->qmlObject()) { - applet->init(); - } - m_appletInterfaces << applet; - emit appletAdded(applet, 0, 0); - } - } if (!m_appletInterfaces.isEmpty()) { emit appletsChanged(); } - +} + +void ContainmentInterface::init() +{ + + AppletInterface::init(); + if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) { connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()), this, SIGNAL(minimumWidthChanged())); From e16c30142f207d364a2cd95408b1876175bb6799 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 20 Sep 2013 23:28:38 +0200 Subject: [PATCH 50/57] resize the graphics object as soon as possible it avoids many resizes that take cpu cycles and mess with the layout --- src/plasmaquick/plasmaquickview.cpp | 4 +++- src/scriptengines/qml/plasmoid/appletinterface.cpp | 6 +++++- src/scriptengines/qml/plasmoid/containmentinterface.cpp | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plasmaquick/plasmaquickview.cpp b/src/plasmaquick/plasmaquickview.cpp index dd6e8351f..b178279fe 100644 --- a/src/plasmaquick/plasmaquickview.cpp +++ b/src/plasmaquick/plasmaquickview.cpp @@ -102,7 +102,9 @@ void PlasmaQuickViewPrivate::setContainment(Plasma::Containment *cont) if (graphicObject) { qDebug() << "using as graphic containment" << graphicObject << containment.data(); - //graphicObject->setProperty("visible", false); + //by resizing before adding, it will avoid some resizes in most cases + graphicObject->setProperty("width", q->width()); + graphicObject->setProperty("height", q->height()); graphicObject->setProperty("drawWallpaper", (cont->containmentType() == Plasma::Types::DesktopContainment || cont->containmentType() == Plasma::Types::CustomContainment)); diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 34e7913e8..92b97fd84 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -143,7 +143,11 @@ void AppletInterface::init() m_qmlObject->engine()->rootContext()->setContextProperty("plasmoid", this); - m_qmlObject->completeInitialization(); + //initialize size, so an useless resize less + QVariantHash initialProperties; + initialProperties["width"] = width(); + initialProperties["height"] = height(); + m_qmlObject->completeInitialization(initialProperties); qDebug() << "Graphic object created:" << applet() << applet()->property("graphicObject"); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 74828f2e1..0c55d3059 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -55,7 +55,6 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent) m_wallpaperInterface(0) { setAcceptedMouseButtons(Qt::AllButtons); - setFlag(QQuickItem::ItemAcceptsDrops); qmlRegisterType(); From ccae8a202bae5183ae583b792c4b9168de00e4b3 Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sat, 21 Sep 2013 04:08:55 +0000 Subject: [PATCH 51/57] SVN_SILENT made messages (.desktop file) --- examples/applets/notes/metadata.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/applets/notes/metadata.desktop b/examples/applets/notes/metadata.desktop index 23e1dba45..d57587ed7 100644 --- a/examples/applets/notes/metadata.desktop +++ b/examples/applets/notes/metadata.desktop @@ -16,4 +16,4 @@ X-KDE-PluginInfo-Website= X-KDE-ServiceTypes=Plasma/Applet X-Plasma-API=declarativeappletscript X-Plasma-MainScript=ui/main.qml -X-Plasma-DropMimeTypes=text/plain \ No newline at end of file +X-Plasma-DropMimeTypes=text/plain From a94af395412b52020a4e14b3d86ad92155f042bd Mon Sep 17 00:00:00 2001 From: l10n daemon script Date: Sun, 22 Sep 2013 04:15:23 +0000 Subject: [PATCH 52/57] SVN_SILENT made messages (.desktop file) --- examples/applets/notes/metadata.desktop | 12 ++++++++++++ examples/applets/nowplaying/metadata.desktop | 1 + examples/applets/windowthumbnails/metadata.desktop | 2 ++ ...a-dataengine-example-customDataContainers.desktop | 3 +++ .../plasma-dataengine-example-simpleEngine.desktop | 1 + ...lasma-dataengine-example-sourcesOnRequest.desktop | 3 +++ examples/kpart/plasma-example-kpart-shell.desktop | 1 + .../runner/plasma-runner-example-homefiles.desktop | 2 ++ 8 files changed, 25 insertions(+) diff --git a/examples/applets/notes/metadata.desktop b/examples/applets/notes/metadata.desktop index d57587ed7..4e876e3db 100644 --- a/examples/applets/notes/metadata.desktop +++ b/examples/applets/notes/metadata.desktop @@ -1,8 +1,20 @@ [Desktop Entry] Comment=Example on how to manage Drop data +Comment[nl]=Voorbeeld van hoe gegevens van Drop te beheren +Comment[pt]=Exemplo de gestão de dados do Drop +Comment[pt_BR]=Exemplo de gerenciamento de dados do Drop +Comment[sv]=Exempel på hur Släpp data hanteras +Comment[uk]=Приклад керування скинутими даними +Comment[x-test]=xxExample on how to manage Drop dataxx Encoding=UTF-8 Keywords= Name=Example notes +Name[nl]=Voorbeeldnotities +Name[pt]=Notas de exemplo +Name[pt_BR]=Notas de exemplo +Name[sv]=Exempelanteckningar +Name[uk]=Приклад нотаток +Name[x-test]=xxExample notesxx Type=Service Icon=knotes X-KDE-ParentApp= diff --git a/examples/applets/nowplaying/metadata.desktop b/examples/applets/nowplaying/metadata.desktop index 206a440af..43d580c1b 100644 --- a/examples/applets/nowplaying/metadata.desktop +++ b/examples/applets/nowplaying/metadata.desktop @@ -1,5 +1,6 @@ [Desktop Entry] Name=Now playing (QML) +Name[de]=Musiktitel-Anzeige (QML) Name[nl]=Speelt nu (QML) Name[pt]=Agora a tocar (QML) Name[pt_BR]=Reproduzindo (QML) diff --git a/examples/applets/windowthumbnails/metadata.desktop b/examples/applets/windowthumbnails/metadata.desktop index 7c7cafcd9..658a6823c 100644 --- a/examples/applets/windowthumbnails/metadata.desktop +++ b/examples/applets/windowthumbnails/metadata.desktop @@ -1,11 +1,13 @@ [Desktop Entry] Name=Example window thumbnails list +Name[nl]=Voorbeeld van lijst met miniaturen van vensters Name[pt]=Lista de miniaturas das janelas de exemplo Name[pt_BR]=Lista de miniaturas das janelas de exemplo Name[sv]=Exempel på miniatyrbilder av fönster Name[uk]=Приклад списку мініатюр вікон Name[x-test]=xxExample window thumbnails listxx Comment=Example showing how to display window thumbnails +Comment[nl]=Voorbeeld van hoe miniaturen van vensters te tonen Comment[pt]=Exemplo que demonstra como apresentar miniaturas das janelas Comment[pt_BR]=Exemplo que demostra como apresentar as miniaturas das janelas Comment[sv]=Exempel som visar hur miniatyrbilder av fönster visas diff --git a/examples/dataengines/customDataContainers/plasma-dataengine-example-customDataContainers.desktop b/examples/dataengines/customDataContainers/plasma-dataengine-example-customDataContainers.desktop index cbd2fd6a8..af0ef4d87 100644 --- a/examples/dataengines/customDataContainers/plasma-dataengine-example-customDataContainers.desktop +++ b/examples/dataengines/customDataContainers/plasma-dataengine-example-customDataContainers.desktop @@ -1,11 +1,14 @@ [Desktop Entry] Name=Custom DataContainers +Name[de]=Benutzerdefinierte Datencontainer +Name[nl]=Aangepaste gegevenscontainers Name[pt]=Contentores Personalizados Name[pt_BR]=DataContainers personalizados Name[sv]=Egen DataContainer Name[uk]=Нетипові контейнери даних Name[x-test]=xxCustom DataContainersxx Comment=A demonstration of how to subclass DataContainer +Comment[nl]=Een demonstratie van hoe een subklasse toe te kennen aan een gegevenscontainer Comment[pt]=Um demonstração de como usar a classe DataContainer Comment[pt_BR]=Demonstração de como usar a subclasse DataContainer Comment[sv]=En demonstration av hur en delklass av DataContainer skapas diff --git a/examples/dataengines/simpleEngine/plasma-dataengine-example-simpleEngine.desktop b/examples/dataengines/simpleEngine/plasma-dataengine-example-simpleEngine.desktop index 0668d4dd9..ac95dbc6f 100644 --- a/examples/dataengines/simpleEngine/plasma-dataengine-example-simpleEngine.desktop +++ b/examples/dataengines/simpleEngine/plasma-dataengine-example-simpleEngine.desktop @@ -8,6 +8,7 @@ Name[sv]=Enkelt exempel på DataEngine Name[uk]=Простий приклад рушія даних Name[x-test]=xxSimple DataEngine Examplexx Comment=A very basic DataEngine implementation +Comment[nl]=Een erge basisimplementatie van een gegevens-engine Comment[pt]=Uma implementação muito básica do DataEngine Comment[pt_BR]=Implementação muito básica do DataEngine Comment[sv]=En mycket grundläggande implementering av DataEngine diff --git a/examples/dataengines/sourcesOnRequest/plasma-dataengine-example-sourcesOnRequest.desktop b/examples/dataengines/sourcesOnRequest/plasma-dataengine-example-sourcesOnRequest.desktop index 93cd713ba..ed1bc0e4a 100644 --- a/examples/dataengines/sourcesOnRequest/plasma-dataengine-example-sourcesOnRequest.desktop +++ b/examples/dataengines/sourcesOnRequest/plasma-dataengine-example-sourcesOnRequest.desktop @@ -1,11 +1,14 @@ [Desktop Entry] Name=Sources On Request +Name[de]=Ressourcen auf Anforderung +Name[nl]=Bronnen op verzoek Name[pt]=Fontes a Pedido Name[pt_BR]=Fontes a pedido Name[sv]=Källor på begäran Name[uk]=Джерела за запитом Name[x-test]=xxSources On Requestxx Comment=A DataEngine example showing how to respond to requests for source creation and updates +Comment[nl]=Een voorbeeld van een gegevens-engine die toont hoe te antwoorden op verzoeken voor aanmaken van een bron en bijwerken Comment[pt]=Um exemplo de DataEngine que demonstra como responder a pedidos de criação e actualização da fonte Comment[pt_BR]=Exemplo de DataEngine que demonstra como responder a solicitações de criação e atualização da fonte Comment[sv]=Ett exempel på en DataEngine som visar hur man svara på en begäran om att skapa källor och uppdateringar diff --git a/examples/kpart/plasma-example-kpart-shell.desktop b/examples/kpart/plasma-example-kpart-shell.desktop index a5350cee1..57ba29015 100755 --- a/examples/kpart/plasma-example-kpart-shell.desktop +++ b/examples/kpart/plasma-example-kpart-shell.desktop @@ -12,6 +12,7 @@ Icon=plasma-example-kpart-shell Type=Application X-DocPath=plasma-kpart-shell/index.html GenericName=A KPart shell for Plasma +GenericName[nl]=Een KPart-shell voor Plasma GenericName[pt]=Uma consola de KPart para o Plasma GenericName[pt_BR]=Shell KPart para o Plasma GenericName[sv]=Ett delprogramskal för Plasma diff --git a/examples/runner/plasma-runner-example-homefiles.desktop b/examples/runner/plasma-runner-example-homefiles.desktop index c55c59714..7fea2ae30 100644 --- a/examples/runner/plasma-runner-example-homefiles.desktop +++ b/examples/runner/plasma-runner-example-homefiles.desktop @@ -1,11 +1,13 @@ [Desktop Entry] Name=Home Files +Name[nl]=Persoonlijke bestanden Name[pt]=Ficheiros Pessoais Name[pt_BR]=Arquivos pessoais Name[sv]=Hemfiler Name[uk]=Файли у домашній теці Name[x-test]=xxHome Filesxx Comment=Part of a tutorial demonstrating how to create Runner plugins +Comment[nl]=Deel van een inleiding die demonstreert hoe Runner-plug-ins te maken Comment[pt]=Parte de um tutorial que demonstra como criar 'plugins' do Runner Comment[pt_BR]=Parte de um tutorial que demonstra como criar plugins do Runner Comment[sv]=Del av en handledning som demonstrerar hur insticksprogram till Runner skapas From 14a3bced4ada1cf46bf6fd1e9a2304108a5a931f Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 23 Sep 2013 11:39:38 +0200 Subject: [PATCH 53/57] crash-- --- src/scriptengines/qml/plasmoid/containmentinterface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 0c55d3059..382d7fd8a 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -210,7 +210,9 @@ void ContainmentInterface::setAppletArgs(Plasma::Applet *applet, const QString & } AppletInterface *appletInterface = applet->property("graphicObject").value(); - emit appletInterface->externalData(mimetype, data); + if (appletInterface) { + emit appletInterface->externalData(mimetype, data); + } } void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) From 135d4039aa903006daa2399aac6150bc12a4ba97 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 23 Sep 2013 11:56:49 +0200 Subject: [PATCH 54/57] remove temp file hack and applets args --- .../qml/plasmoid/containmentinterface.cpp | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 382d7fd8a..0c7d1d1dd 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -311,26 +311,9 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y) if (!selectedPlugin.isEmpty()) { - //TODO: remove all this temp file logic - KTemporaryFile tempFile; - if (mimeData && tempFile.open()) { - //TODO: what should we do with files after the applet is done with them?? - tempFile.setAutoRemove(false); + Plasma::Applet *applet = addApplet(selectedPlugin, QVariantList(), QPoint(x, y)); + setAppletArgs(applet, pluginFormats[selectedPlugin], mimeData->data(pluginFormats[selectedPlugin])); - { - QDataStream stream(&tempFile); - QByteArray data = mimeData->data(pluginFormats[selectedPlugin]); - stream.writeRawData(data, data.size()); - } - - QVariantList args; - args << tempFile.fileName(); - qDebug() << args; - tempFile.close(); - - Plasma::Applet *applet = addApplet(selectedPlugin, args, QPoint(x, y)); - setAppletArgs(applet, pluginFormats[selectedPlugin], mimeData->data(pluginFormats[selectedPlugin])); - } } } } @@ -398,11 +381,8 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet return; } - //TODO: remove assignment of applet args - QVariantList args; - args << tjob->url().url() << mimetype; - qDebug() << "Creating menu for:" << mimetype << posi << args; + qDebug() << "Creating menu for:" << mimetype << posi; appletList << Plasma::PluginLoader::self()->listAppletInfoForMimeType(mimetype); KPluginInfo::List wallpaperList; @@ -472,7 +452,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet m_wallpaperInterface->setUrl(tjob->url()); } } else { - Plasma::Applet *applet = addApplet(actionsToApplets[choice], args, posi); + Plasma::Applet *applet = addApplet(actionsToApplets[choice], QVariantList(), posi); setAppletArgs(applet, mimetype, tjob->url().toString()); } @@ -481,7 +461,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet } } else { // we can at least create an icon as a link to the URL - Plasma::Applet *applet = addApplet("org.kde.icon", args, posi); + Plasma::Applet *applet = addApplet("org.kde.icon", QVariantList(), posi); setAppletArgs(applet, mimetype, tjob->url().toString()); } } From fab4818c92317de0886929b2db33f5337dfa2041 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 23 Sep 2013 16:44:31 +0200 Subject: [PATCH 55/57] allow plasmoids to change icon changing icon will change the icon of the default compact representation --- src/plasma/applet.cpp | 9 +++++---- src/plasma/applet.h | 8 +++++++- src/plasma/private/applet_p.cpp | 1 + src/plasma/private/applet_p.h | 1 + .../qml/plasmoid/appletinterface.cpp | 20 ++++++++++++++----- .../qml/plasmoid/appletinterface.h | 5 +++-- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index 49a9635bf..377204eee 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -332,11 +332,12 @@ void Applet::setTitle(const QString &title) const QString Applet::icon() const { - if (!d->appletDescription.isValid()) { - return QString(); - } + return d->icon; +} - return d->appletDescription.icon(); +void Applet::setIcon(const QString &icon) +{ + d->icon = icon; } KPluginInfo Applet::pluginInfo() const diff --git a/src/plasma/applet.h b/src/plasma/applet.h index 8cdf99a6f..c91cb6e3b 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -282,10 +282,16 @@ class PLASMA_EXPORT Applet : public QObject static Applet *loadPlasmoid(const QString &path, uint appletId = 0); /** - * Returns the icon related to this applet + * @returns The icon name related to this applet + * By default is the one in the plasmoid desktop file **/ QString icon() const; + /** + * Sets an icon name for this applet + * @param icon Freedesktop compatible icon name + */ + void setIcon(const QString &icon); //ACTIONS diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp index ff0fe718f..8c448727f 100644 --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -52,6 +52,7 @@ AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int q(applet), immutability(Types::Mutable), appletDescription(info ? *info : KPluginInfo(service)), + icon(appletDescription.isValid() ? appletDescription.icon() : QString()), mainConfig(0), pendingConstraints(Types::NoConstraint), script(0), diff --git a/src/plasma/private/applet_p.h b/src/plasma/private/applet_p.h index 859acc8cd..65ec9aa06 100644 --- a/src/plasma/private/applet_p.h +++ b/src/plasma/private/applet_p.h @@ -87,6 +87,7 @@ public: // applet info we keep around in case its needed KPluginInfo appletDescription; QString customTitle; + QString icon; // bookkeeping KConfigGroup *mainConfig; diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp index 92b97fd84..60f4d19a1 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -221,21 +221,31 @@ QObject* AppletInterface::configuration() const return m_configuration; } +uint AppletInterface::id() const +{ + return applet()->id(); +} + QString AppletInterface::icon() const { return applet()->icon(); } +void AppletInterface::setIcon(const QString &icon) +{ + if (applet()->icon() == icon) { + return; + } + + applet()->setIcon(icon); + emit iconChanged(); +} + QString AppletInterface::title() const { return applet()->title(); } -uint AppletInterface::id() const -{ - return applet()->id(); -} - void AppletInterface::setTitle(const QString &title) { if (applet()->title() == title) { diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index a394ac6ad..06ad7d9ba 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -64,11 +64,10 @@ class AppletInterface : public QQuickItem */ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) - //TODO: writable icon /** * Icon to represent the plasmoid */ - Q_PROPERTY(QString icon READ icon CONSTANT) + Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged) /** * Applet id: is unique in the whole Plasma session and will never change across restarts @@ -235,6 +234,7 @@ public: //PROPERTY ACCESSORS------------------------------------------------------------------- QString icon() const; + void setIcon(const QString &icon); QString title() const; void setTitle(const QString &title); @@ -294,6 +294,7 @@ Q_SIGNALS: void configNeedsSaving(); //PROPERTY change notifiers-------------- + void iconChanged(); void titleChanged(); void formFactorChanged(); void locationChanged(); From fe2e95334b5dcbcd7bbab2c50b5897a835d1a241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Wed, 25 Sep 2013 17:42:26 +0200 Subject: [PATCH 56/57] Small addition for QWidget porting --- tools/port-qtquick.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/port-qtquick.sh b/tools/port-qtquick.sh index b894f1dbf..fdb337444 100755 --- a/tools/port-qtquick.sh +++ b/tools/port-qtquick.sh @@ -50,6 +50,7 @@ for FS in `find $PWD -name '*.h' -o -name '*.cpp'`; do # Fix up includes perl -p -i -e 's/\#include \/\#include \/g' $FS perl -p -i -e 's/\#include \/\#include \/g' $FS + perl -p -i -e 's/\#include \/\#include \/g' $FS perl -p -i -e 's/\#include \/\#include \/g' $FS perl -p -i -e 's/\#include \/\#include \/g' $FS perl -p -i -e 's/\#include \/\#include \/g' $FS From 8ba9ea0d595c573a7e2c07869b8d7c8b39b4aefd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Wed, 25 Sep 2013 17:42:37 +0200 Subject: [PATCH 57/57] Put us a taskmanager in the default panel remove testapplet and windowlist --- src/shell/qmlpackages/desktop/contents/layout.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/shell/qmlpackages/desktop/contents/layout.js b/src/shell/qmlpackages/desktop/contents/layout.js index 918acc331..5a2cb2715 100644 --- a/src/shell/qmlpackages/desktop/contents/layout.js +++ b/src/shell/qmlpackages/desktop/contents/layout.js @@ -2,8 +2,7 @@ var panel = new Panel panel.screen = 0 panel.location = 'top' -panel.addWidget("org.kde.testapplet") -panel.addWidget("org.kde.windowlist") +panel.addWidget("org.kde.taskmanager") for (var i = 0; i < screenCount; ++i) { var desktop = new Activity