diff --git a/autotests/coronatest.h b/autotests/coronatest.h index 2010b0bbb..d1d91d71f 100644 --- a/autotests/coronatest.h +++ b/autotests/coronatest.h @@ -1,98 +1,98 @@ /****************************************************************************** * Copyright 2014 Marco Martin * * * * This library 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 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *******************************************************************************/ #ifndef CORONATEST_H #define CORONATEST_H #include #include #include "plasma/corona.h" #include "plasma/pluginloader.h" class SimpleLoader : public Plasma::PluginLoader { protected: virtual Plasma::Applet *internalLoadApplet(const QString &name, uint appletId = 0, - const QVariantList &args = QVariantList()) Q_DECL_OVERRIDE; + const QVariantList &args = QVariantList()) override; }; class SimpleCorona : public Plasma::Corona { Q_OBJECT public: explicit SimpleCorona(QObject * parent = nullptr); ~SimpleCorona(); - QRect screenGeometry(int) const Q_DECL_OVERRIDE; - int screenForContainment(const Plasma::Containment *) const Q_DECL_OVERRIDE; + QRect screenGeometry(int) const override; + int screenForContainment(const Plasma::Containment *) const override; }; class SimpleApplet : public Plasma::Applet { Q_OBJECT public: explicit SimpleApplet(QObject *parent = nullptr, const QString &serviceId = QString(), uint appletId = 0); private: QTimer m_timer; }; class SimpleContainment : public Plasma::Containment { Q_OBJECT public: explicit SimpleContainment(QObject *parent = nullptr, const QString &serviceId = QString(), uint appletId = 0); private: QTimer m_timer; }; class SimpleNoScreenContainment : public Plasma::Containment { Q_OBJECT public: explicit SimpleNoScreenContainment(QObject *parent = nullptr, const QString &serviceId = QString(), uint appletId = 0); }; class CoronaTest : public QObject { Q_OBJECT public Q_SLOTS: void initTestCase(); void cleanupTestCase(); private Q_SLOTS: void restore(); void checkOrder(); void startupCompletion(); void addRemoveApplets(); void immutability(); private: SimpleCorona *m_corona; QDir m_configDir; }; #endif diff --git a/src/declarativeimports/calendar/calendarplugin.h b/src/declarativeimports/calendar/calendarplugin.h index bf96ef80b..14f387530 100644 --- a/src/declarativeimports/calendar/calendarplugin.h +++ b/src/declarativeimports/calendar/calendarplugin.h @@ -1,36 +1,36 @@ /* Copyright (C) 2013 Mark Gaiser 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 02110-1301 USA. */ #ifndef CALENDARPLUGIN_H #define CALENDARPLUGIN_H #include class QQmlEngine; class CalendarPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - void registerTypes(const char *uri) Q_DECL_OVERRIDE; + void registerTypes(const char *uri) override; }; #endif diff --git a/src/declarativeimports/calendar/daysmodel.h b/src/declarativeimports/calendar/daysmodel.h index 2df896597..8e03c4eae 100644 --- a/src/declarativeimports/calendar/daysmodel.h +++ b/src/declarativeimports/calendar/daysmodel.h @@ -1,87 +1,87 @@ /* Copyright (C) 2013 Mark Gaiser Copyright (C) 2016 Martin Klapetek 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 02110-1301 USA. */ #ifndef DAYSMODEL_H #define DAYSMODEL_H #include #include "daydata.h" #include class EventPluginsManager; class DaysModel : public QAbstractListModel { Q_OBJECT public: enum Roles { isCurrent = Qt::UserRole + 1, //containsHolidayItems, containsEventItems, containsMajorEventItems, containsMinorEventItems, //containsTodoItems, //containsJournalItems, dayNumber, monthNumber, yearNumber }; explicit DaysModel(QObject *parent = nullptr); virtual ~DaysModel(); void setSourceData(QList *data); - int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; Q_INVOKABLE void setPluginsManager(QObject *manager); Q_INVOKABLE QList eventsForDate(const QDate &date); - QHash roleNames() const Q_DECL_OVERRIDE; + QHash roleNames() const override; Q_SIGNALS: void agendaUpdated(const QDate &updatedDate); public Q_SLOTS: void update(); private Q_SLOTS: void onDataReady(const QMultiHash &data); void onEventModified(const CalendarEvents::EventData &data); void onEventRemoved(const QString &uid); private: QModelIndex indexForDate(const QDate &date); bool hasMajorEventAtDate(const QDate &date) const; bool hasMinorEventAtDate(const QDate &date) const; EventPluginsManager *m_pluginsManager = nullptr; QList *m_data = nullptr; QList m_qmlData; QDate m_lastRequestedAgendaDate; QList m_eventPlugins; QMultiHash m_eventsData; QDate m_lastRequestedEventsStartDate; // this is always this+42 days bool m_agendaNeedsUpdate; }; #endif // DAYSMODEL_H diff --git a/src/declarativeimports/calendar/eventpluginsmanager.cpp b/src/declarativeimports/calendar/eventpluginsmanager.cpp index c7301c413..0858bafd5 100644 --- a/src/declarativeimports/calendar/eventpluginsmanager.cpp +++ b/src/declarativeimports/calendar/eventpluginsmanager.cpp @@ -1,277 +1,277 @@ /* Copyright (C) 2015 Martin Klapetek 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 02110-1301 USA. */ #include "eventpluginsmanager.h" #include #include #include #include #include #include #include #include #include class EventPluginsModel : public QAbstractListModel { Q_OBJECT public: EventPluginsModel(EventPluginsManager *manager) : QAbstractListModel(manager) { m_manager = manager; m_roles = QAbstractListModel::roleNames(); m_roles.insert(Qt::EditRole, QByteArrayLiteral("checked")); m_roles.insert(Qt::UserRole, QByteArrayLiteral("configUi")); m_roles.insert(Qt::UserRole + 1, QByteArrayLiteral("pluginPath")); } // make these two available to the manager void beginResetModel() { QAbstractListModel::beginResetModel(); } void endResetModel() { QAbstractListModel::endResetModel(); } - virtual QHash roleNames() const Q_DECL_OVERRIDE + virtual QHash roleNames() const override { return m_roles; } - Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE + Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent); return m_manager->m_availablePlugins.size(); } - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { if (!index.isValid() && !m_manager) { return QVariant(); } const auto it = m_manager->m_availablePlugins.cbegin() + index.row(); const QString currentPlugin = it.key(); const EventPluginsManager::PluginData metadata = it.value(); switch (role) { case Qt::DisplayRole: return metadata.name; case Qt::ToolTipRole: return metadata.desc; case Qt::DecorationRole: return metadata.icon; case Qt::UserRole: { // The currentPlugin path contains the full path including // the plugin filename, so it needs to be cut off from the last '/' const QStringRef pathRef = currentPlugin.leftRef(currentPlugin.lastIndexOf(QLatin1Char('/'))); const QString qmlFilePath = metadata.configUi; return QString(pathRef % QLatin1Char('/') % qmlFilePath); } case Qt::UserRole + 1: return currentPlugin; case Qt::EditRole: return m_manager->m_enabledPlugins.contains(currentPlugin); } return QVariant(); } - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override { if (role != Qt::EditRole || !index.isValid()) { return false; } bool enabled = value.toBool(); const QString pluginPath = m_manager->m_availablePlugins.keys().at(index.row()); if (enabled) { if (!m_manager->m_enabledPlugins.contains(pluginPath)) { m_manager->m_enabledPlugins << pluginPath; } } else { m_manager->m_enabledPlugins.removeOne(pluginPath); } emit dataChanged(index, index); return true; } Q_INVOKABLE QVariant get(int row, const QByteArray &role) { return data(createIndex(row, 0), roleNames().key(role)); } private: EventPluginsManager *m_manager; QHash m_roles; }; EventPluginsManager::EventPluginsManager(QObject *parent) : QObject(parent) { auto plugins = KPluginLoader::findPlugins( QStringLiteral("plasmacalendarplugins"), [](const KPluginMetaData &md) { return md.serviceTypes().contains(QLatin1String("PlasmaCalendar/Plugin")); }); Q_FOREACH (const KPluginMetaData &plugin, plugins) { m_availablePlugins.insert(plugin.fileName(), { plugin.name(), plugin.description(), plugin.iconName(), plugin.value(QStringLiteral("X-KDE-PlasmaCalendar-ConfigUi")) }); } // Fallback for legacy pre-KPlugin plugins so we can still load them const QStringList paths = QCoreApplication::libraryPaths(); Q_FOREACH (const QString &libraryPath, paths) { const QString path(libraryPath + QStringLiteral("/plasmacalendarplugins")); QDir dir(path); if (!dir.exists()) { continue; } QStringList entryList = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); Q_FOREACH (const QString &fileName, entryList) { const QString absolutePath = dir.absoluteFilePath(fileName); if (m_availablePlugins.contains(absolutePath)) { continue; } QPluginLoader loader(absolutePath); // Load only our own plugins if (loader.metaData().value(QStringLiteral("IID")) == QLatin1String("org.kde.CalendarEventsPlugin")) { const auto md = loader.metaData().value(QStringLiteral("MetaData")).toObject(); m_availablePlugins.insert(absolutePath, { md.value(QStringLiteral("Name")).toString(), md.value(QStringLiteral("Description")).toString(), md.value(QStringLiteral("Icon")).toString(), md.value(QStringLiteral("ConfigUi")).toString() }); } } } m_model = new EventPluginsModel(this); } EventPluginsManager::~EventPluginsManager() { qDeleteAll(m_plugins); } void EventPluginsManager::populateEnabledPluginsList(const QStringList &pluginsList) { m_model->beginResetModel(); m_enabledPlugins = pluginsList; m_model->endResetModel(); } void EventPluginsManager::setEnabledPlugins(QStringList &pluginsList) { m_model->beginResetModel(); m_enabledPlugins = pluginsList; // Remove all already loaded plugins from the pluginsList // and unload those plugins that are not in the pluginsList auto i = m_plugins.begin(); while (i != m_plugins.end()) { const QString pluginPath = (*i)->property("pluginPath").toString(); if (pluginsList.contains(pluginPath)) { pluginsList.removeAll(pluginPath); ++i; } else { (*i)->deleteLater(); i = m_plugins.erase(i); } } // Now load all the plugins left in pluginsList Q_FOREACH (const QString &pluginPath, pluginsList) { loadPlugin(pluginPath); } m_model->endResetModel(); Q_EMIT pluginsChanged(); } QStringList EventPluginsManager::enabledPlugins() const { return m_enabledPlugins; } void EventPluginsManager::loadPlugin(const QString &absolutePath) { QPluginLoader loader(absolutePath); if (!loader.load()) { qWarning() << "Could not create Plasma Calendar Plugin: " << absolutePath; qWarning() << loader.errorString(); return; } QObject *obj = loader.instance(); if (obj) { CalendarEvents::CalendarEventsPlugin *eventsPlugin = qobject_cast(obj); if (eventsPlugin) { qDebug() << "Loading Calendar plugin" << eventsPlugin; eventsPlugin->setProperty("pluginPath", absolutePath); m_plugins << eventsPlugin; // Connect the relay signals connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::dataReady, this, &EventPluginsManager::dataReady); connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::eventModified, this, &EventPluginsManager::eventModified); connect(eventsPlugin, &CalendarEvents::CalendarEventsPlugin::eventRemoved, this, &EventPluginsManager::eventRemoved); } else { // not our/valid plugin, so unload it loader.unload(); } } else { loader.unload(); } } QList EventPluginsManager::plugins() const { return m_plugins; } QAbstractListModel* EventPluginsManager::pluginsModel() const { return m_model; } #include "eventpluginsmanager.moc" diff --git a/src/declarativeimports/core/colorscope.h b/src/declarativeimports/core/colorscope.h index 2596352dc..f0cc4470d 100644 --- a/src/declarativeimports/core/colorscope.h +++ b/src/declarativeimports/core/colorscope.h @@ -1,138 +1,138 @@ /*************************************************************************** * Copyright 2014 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 02110-1301 USA . * ***************************************************************************/ #ifndef COLORSCOPE_H #define COLORSCOPE_H #include #include #include #include #include class QQuickItem; /** * @class ColorScope * * @short Sets the colour scheme to be used by all child items * * It is exposed as org.kde.plasma.core.ColorScope */ class ColorScope : public QQuickItem { Q_OBJECT /** * Specifies the color group to use for this ColorScope */ Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) /** * The main foreground color within this colorscope */ Q_PROPERTY(QColor textColor READ textColor NOTIFY colorsChanged) /** * The highlight color within this colorscope */ Q_PROPERTY(QColor highlightColor READ highlightColor NOTIFY colorsChanged) /** * The highlighted text color within this colorscope */ Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor NOTIFY colorsChanged) /** * The background color that should be used within this colorscope */ Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY colorsChanged) /** * Color of foreground objects with a "positive message" connotation (usually green) */ Q_PROPERTY(QColor positiveTextColor READ positiveTextColor NOTIFY colorsChanged) /** * Color of foreground objects with a "neutral message" connotation (usually yellow) */ Q_PROPERTY(QColor neutralTextColor READ neutralTextColor NOTIFY colorsChanged) /** * Color of foreground objects with a "negative message" connotation (usually red) */ Q_PROPERTY(QColor negativeTextColor READ negativeTextColor NOTIFY colorsChanged) /** * true if the scope inherits from its parent scope * @since 5.39 */ Q_PROPERTY(bool inherit READ inherit WRITE setInherit NOTIFY inheritChanged) public: /// @cond INTERNAL_DOCS explicit ColorScope(QQuickItem *parent = nullptr, QObject *parentObject = nullptr); - ~ColorScope() Q_DECL_OVERRIDE; + ~ColorScope() override; void setColorGroup(Plasma::Theme::ColorGroup group); Plasma::Theme::ColorGroup colorGroup() const; QColor textColor() const; QColor highlightColor() const; QColor highlightedTextColor() const; QColor backgroundColor() const; QColor positiveTextColor() const; QColor neutralTextColor() const; QColor negativeTextColor() const; bool inherit() const; void setInherit(bool inherit); ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES static ColorScope *qmlAttachedProperties(QObject *object); /// @endcond ColorScope *findParentScope(); - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) override; bool eventFilter(QObject * watched, QEvent * event) override; Q_SIGNALS: void colorGroupChanged(); void colorsChanged(); void inheritChanged(); private: void checkColorGroupChanged(); void setParentScope(ColorScope * parentScope); bool m_inherit; Plasma::Theme m_theme; Plasma::Theme::ColorGroup m_group; QPointer m_parentScope; QObject *const m_parent; Plasma::Theme::ColorGroup m_actualGroup; static QHash s_attachedScopes; }; QML_DECLARE_TYPEINFO(ColorScope, QML_HAS_ATTACHED_PROPERTIES) #endif diff --git a/src/declarativeimports/core/corebindingsplugin.h b/src/declarativeimports/core/corebindingsplugin.h index c6f5887f8..84e142fc7 100644 --- a/src/declarativeimports/core/corebindingsplugin.h +++ b/src/declarativeimports/core/corebindingsplugin.h @@ -1,41 +1,41 @@ /* * Copyright 2009 by Alan Alpert * Copyright 2010 by Ménard Alexis * Copyright 2010 by Marco Martin * Copyright 2013 by Sebastian Kügler * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef COREBINDINGSPLUGIN_H #define COREBINDINGSPLUGIN_H #include #include #include class CoreBindingsPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE; - void registerTypes(const char *uri) Q_DECL_OVERRIDE; + void initializeEngine(QQmlEngine *engine, const char *uri) override; + void registerTypes(const char *uri) override; }; #endif diff --git a/src/declarativeimports/core/datamodel.h b/src/declarativeimports/core/datamodel.h index 52bb83e05..f48c4087e 100644 --- a/src/declarativeimports/core/datamodel.h +++ b/src/declarativeimports/core/datamodel.h @@ -1,262 +1,262 @@ /* * Copyright 2010 by 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 DATAMODEL_H #define DATAMODEL_H #include #include #include #include #include class QTimer; namespace Plasma { class DataSource; class DataModel; /** * @class SortFilterModel * @short Filter and sort an existing QAbstractItemModel */ class SortFilterModel : public QSortFilterProxyModel { Q_OBJECT /** * The source model of this sorting proxy model. It has to inherit QAbstractItemModel (ListModel is not supported) */ Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel WRITE setModel NOTIFY sourceModelChanged) /** * The regular expression for the filter, only items with their filterRole matching filterRegExp will be displayed */ Q_PROPERTY(QString filterRegExp READ filterRegExp WRITE setFilterRegExp NOTIFY filterRegExpChanged) /** * The string for the filter, only items with their filterRole matching filterString will be displayed */ Q_PROPERTY(QString filterString READ filterString WRITE setFilterString NOTIFY filterStringChanged REVISION 1) /** * A JavaScript callable that is passed the source model row index as first argument and the value * of filterRole as second argument. The callable's return value is evaluated as boolean to determine * whether the row is accepted (true) or filtered out (false). It overrides the default implementation * that uses filterRegExp or filterString; while filterCallable is set those two properties are * ignored. Attempts to write a non-callable to this property are silently ignored, but you can set * it to null. */ Q_PROPERTY(QJSValue filterCallback READ filterCallback WRITE setFilterCallback NOTIFY filterCallbackChanged REVISION 1) /** * The role of the sourceModel on which filterRegExp must be applied. */ Q_PROPERTY(QString filterRole READ filterRole WRITE setFilterRole) /** * The role of the sourceModel that will be used for sorting. if empty the order will be left unaltered */ Q_PROPERTY(QString sortRole READ sortRole WRITE setSortRole) /** * One of Qt.Ascending or Qt.Descending */ Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder) /** * How many items are in this model */ Q_PROPERTY(int count READ count NOTIFY countChanged) friend class DataModel; public: explicit SortFilterModel(QObject *parent = nullptr); ~SortFilterModel(); void setModel(QAbstractItemModel *source); void setFilterRegExp(const QString &exp); QString filterRegExp() const; void setFilterString(const QString &filterString); QString filterString() const; void setFilterCallback(const QJSValue &callback); QJSValue filterCallback() const; void setFilterRole(const QString &role); QString filterRole() const; void setSortRole(const QString &role); QString sortRole() const; void setSortOrder(const Qt::SortOrder order); int count() const { return QSortFilterProxyModel::rowCount(); } /** * Returns the item at index in the list model. * This allows the item data to be accessed (but not modified) from JavaScript. * It returns an Object with a property for each role. * * @param i the row we want */ Q_INVOKABLE QVariantMap get(int i) const; Q_INVOKABLE int mapRowToSource(int i) const; Q_INVOKABLE int mapRowFromSource(int i) const; Q_SIGNALS: void countChanged(); void sourceModelChanged(QObject *); void filterRegExpChanged(const QString &); Q_REVISION(1) void filterStringChanged(const QString &); Q_REVISION(1) void filterCallbackChanged(const QJSValue &); protected: int roleNameToId(const QString &name) const; - bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const Q_DECL_OVERRIDE; + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; protected Q_SLOTS: void syncRoleNames(); private: QString m_filterRole; QString m_sortRole; QString m_filterString; QJSValue m_filterCallback; QHash m_roleIds; }; /** * @class DataModel * @short DataSource data as a model */ class DataModel : public QAbstractItemModel { Q_OBJECT /** * The instance of DataSource to construct this model on */ Q_PROPERTY(QObject *dataSource READ dataSource WRITE setDataSource) /** * It's a regular expression. Only data with keys that match this filter expression will be inserted in the model */ Q_PROPERTY(QString keyRoleFilter READ keyRoleFilter WRITE setKeyRoleFilter) /** * it's a regular expression. If the DataSource is connected to more than one source, only inserts data from sources matching this filter expression in the model. * If we want to have a source watch all sources beginning with say "name:", the required regexp would be sourceFilter: "name:.*" */ Q_PROPERTY(QString sourceFilter READ sourceFilter WRITE setSourceFilter) /** * How many items are in this model */ Q_PROPERTY(int count READ count NOTIFY countChanged) public: DataModel(QObject *parent = nullptr); ~DataModel(); void setDataSource(QObject *source); QObject *dataSource() const; /** * Include only items with a key that matches this regexp in the model */ void setKeyRoleFilter(const QString &key); QString keyRoleFilter() const; /** * Include only sources that matches this regexp in the model */ void setSourceFilter(const QString &key); QString sourceFilter() const; //Reimplemented - QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role) const override; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + int role = Qt::DisplayRole) const override; QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; - int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; - int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; int count() const { return countItems(); } /** * Returns the item at index in the list model. * This allows the item data to be accessed (but not modified) from JavaScript. * It returns an Object with a property for each role. * * @param i the row we want */ Q_INVOKABLE QVariantMap get(int i) const; protected: void setItems(const QString &sourceName, const QVariantList &list); inline int countItems() const; Q_SIGNALS: void countChanged(); void sourceModelChanged(QObject *); void filterRegExpChanged(const QString &); private Q_SLOTS: void dataUpdated(const QString &sourceName, const QVariantMap &data); void removeSource(const QString &sourceName); private: DataSource *m_dataSource; QString m_keyRoleFilter; QRegExp m_keyRoleFilterRE; QString m_sourceFilter; QRegExp m_sourceFilterRE; QMap > m_items; QHash m_roleNames; QHash m_roleIds; int m_maxRoleId; }; int DataModel::countItems() const { int count = 0; foreach (const QVector &v, m_items) { count += v.count(); } return count; } } #endif diff --git a/src/declarativeimports/core/datasource.h b/src/declarativeimports/core/datasource.h index 42b662a54..253d3c927 100644 --- a/src/declarativeimports/core/datasource.h +++ b/src/declarativeimports/core/datasource.h @@ -1,201 +1,201 @@ /* * Copyright 2009 by Alan Alpert * Copyright 2010 by Ménard Alexis * Copyright 2010 by Marco MArtin * Copyright 2013 by Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DATASOURCE_H #define DATASOURCE_H #include #include #include #include #include #include class QQmlPropertyMap; namespace Plasma { class DataEngine; /** * @class DataSource * @short Provides data from a range of plugins */ class DataSource : public QObject, public QQmlParserStatus, DataEngineConsumer { Q_OBJECT Q_INTERFACES(QQmlParserStatus) public: enum Change { NoChange = 0, DataEngineChanged = 1, SourcesChanged = 2 }; Q_DECLARE_FLAGS(Changes, Change) typedef QMap Data; explicit DataSource(QObject *parent = nullptr); - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; + void classBegin() override; + void componentComplete() override; /** * true if the connection to the Plasma DataEngine is valid */ Q_PROPERTY(bool valid READ valid) bool valid() const { return m_dataEngine && m_dataEngine->isValid(); } /** * Polling interval in milliseconds when the data will be fetched again. If 0 no polling will be done. */ Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) int interval() const { return m_interval; } void setInterval(const int interval); /** * The interval to align polling to */ Q_PROPERTY(Plasma::Types::IntervalAlignment intervalAlignment READ intervalAlignment WRITE setIntervalAlignment NOTIFY intervalAlignmentChanged) Plasma::Types::IntervalAlignment intervalAlignment() const { return m_intervalAlignment; } void setIntervalAlignment(Plasma::Types::IntervalAlignment intervalAlignment); /** * Plugin name of the Plasma DataEngine */ Q_PROPERTY(QString dataEngine READ engine WRITE setEngine NOTIFY engineChanged) Q_PROPERTY(QString engine READ engine WRITE setEngine NOTIFY engineChanged) QString engine() const { return m_engine; } void setEngine(const QString &e); /** * String array of all the source names connected to the DataEngine */ Q_PROPERTY(QStringList connectedSources READ connectedSources WRITE setConnectedSources NOTIFY connectedSourcesChanged) QStringList connectedSources() const { return m_connectedSources; } void setConnectedSources(const QStringList &s); /** * Read only string array of all the sources available from the DataEngine (connected or not) */ Q_PROPERTY(QStringList sources READ sources NOTIFY sourcesChanged) QStringList sources() const { return m_sources; } /** * All the data fetched by this dataengine. * This is a map of maps. At the first level, there are the source names, at the second, they keys set by the DataEngine */ Q_PROPERTY(QQmlPropertyMap *data READ data CONSTANT) QQmlPropertyMap *data() const { return m_data; } /** * All the models associated to this DataEngine, indexed by source. * In order for a model to be present, besides being implemented in the DataEngine, * The user has to be connected to its source, so the source name has to be present in the connectedSources property. */ Q_PROPERTY(QQmlPropertyMap *models READ models CONSTANT) QQmlPropertyMap *models() const { return m_models; } /** * @returns a Plasma::Service given a source name * @param source source name we want a service of */ Q_INVOKABLE QObject *serviceForSource(const QString &source); /** * Connect a new source. It adds it to connectedSources */ Q_INVOKABLE void connectSource(const QString &source); /** * Disconnects from a DataEngine Source. It also removes it from connectedSources */ Q_INVOKABLE void disconnectSource(const QString &source); public Q_SLOTS: void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); void modelChanged(const QString &sourceName, QAbstractItemModel *model); protected Q_SLOTS: void removeSource(const QString &source); void setupData(); void updateSources(); Q_SIGNALS: void newData(const QString &sourceName, const QVariantMap &data); void sourceAdded(const QString &source); void sourceRemoved(const QString &source); void sourceConnected(const QString &source); void sourceDisconnected(const QString &source); void intervalChanged(); void intervalAlignmentChanged(); void engineChanged(); void dataChanged(); void connectedSourcesChanged(); void sourcesChanged(); private: bool m_ready; QString m_id; int m_interval; Plasma::Types::IntervalAlignment m_intervalAlignment; QString m_engine; QQmlPropertyMap *m_data = nullptr; QQmlPropertyMap *m_models = nullptr; Plasma::DataEngine *m_dataEngine = nullptr; Plasma::DataEngineConsumer *m_dataEngineConsumer = nullptr; QStringList m_sources; QStringList m_connectedSources; QStringList m_oldSources; QStringList m_newSources; Changes m_changes; QHash m_services; }; Q_DECLARE_OPERATORS_FOR_FLAGS(DataSource::Changes) } #endif diff --git a/src/declarativeimports/core/fadingnode.cpp b/src/declarativeimports/core/fadingnode.cpp index 7e5c381cd..690f3c9e4 100644 --- a/src/declarativeimports/core/fadingnode.cpp +++ b/src/declarativeimports/core/fadingnode.cpp @@ -1,136 +1,136 @@ /* * Copyright (C) 2014 David Edmundson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "fadingnode_p.h" #include #include #include struct FadingMaterialState { QSGTexture *source = nullptr; QSGTexture *target = nullptr; qreal progress; }; class FadingMaterialShader : public QSGSimpleMaterialShader { QSG_DECLARE_SIMPLE_SHADER(FadingMaterialShader, FadingMaterialState) public: FadingMaterialShader(); using QSGSimpleMaterialShader::updateState; virtual void updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState) override; - QList attributes() const Q_DECL_OVERRIDE; + QList attributes() const override; - void initialize() Q_DECL_OVERRIDE; + void initialize() override; private: QOpenGLFunctions *glFuncs = nullptr; int m_progressId = 0; int m_sourceRectId = 0; int m_targetRectId = 0; }; FadingMaterialShader::FadingMaterialShader() { setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/plasma-framework/shaders/fadingmaterial.frag")); setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/plasma-framework/shaders/fadingmaterial.vert")); } QList FadingMaterialShader::attributes() const { return {QByteArrayLiteral("qt_Vertex"), QByteArrayLiteral("qt_MultiTexCoord0")}; } void FadingMaterialShader::updateState(const FadingMaterialState* newState, const FadingMaterialState* oldState) { if (!oldState || oldState->source != newState->source) { glFuncs->glActiveTexture(GL_TEXTURE1); newState->source->bind(); QRectF rect = newState->source->normalizedTextureSubRect(); program()->setUniformValue(m_sourceRectId, QVector4D(rect.x(), rect.y(), rect.width(), rect.height())); // reset the active texture back to 0 after we changed it to something else glFuncs->glActiveTexture(GL_TEXTURE0); } if (!oldState || oldState->target != newState->target) { glFuncs->glActiveTexture(GL_TEXTURE0); newState->target->bind(); QRectF rect = newState->target->normalizedTextureSubRect(); program()->setUniformValue(m_targetRectId, QVector4D(rect.x(), rect.y(), rect.width(), rect.height())); } if (!oldState || oldState->progress != newState->progress) { program()->setUniformValue(m_progressId, (GLfloat) newState->progress); } } void FadingMaterialShader::initialize() { if (!program()->isLinked()) { // shader not linked, exit otherwise we crash, BUG: 336272 return; } QSGSimpleMaterialShader< FadingMaterialState >::initialize(); glFuncs = QOpenGLContext::currentContext()->functions(); program()->bind(); program()->setUniformValue("u_src", 0); program()->setUniformValue("u_target", 1); m_progressId = program()->uniformLocation("u_transitionProgress"); m_sourceRectId = program()->uniformLocation("u_src_rect"); m_targetRectId = program()->uniformLocation("u_target_rect"); } FadingNode::FadingNode(QSGTexture *source, QSGTexture *target): m_source(source), m_target(target) { QSGSimpleMaterial *m = FadingMaterialShader::createMaterial(); m->setFlag(QSGMaterial::Blending); setMaterial(m); setFlag(OwnsMaterial, true); setProgress(1.0); QSGGeometry *g = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4); QSGGeometry::updateTexturedRectGeometry(g, QRect(), QRect()); setGeometry(g); setFlag(QSGNode::OwnsGeometry, true); } FadingNode::~FadingNode() { } void FadingNode::setRect(const QRectF &bounds) { QSGGeometry::updateTexturedRectGeometry(geometry(), bounds, QRectF(0, 0, 1, 1)); markDirty(QSGNode::DirtyGeometry); } void FadingNode::setProgress(qreal progress) { QSGSimpleMaterial *m = static_cast*>(material()); m->state()->source = m_source.data(); m->state()->target = m_target.data(); m->state()->progress = progress; markDirty(QSGNode::DirtyMaterial); } diff --git a/src/declarativeimports/core/framesvgitem.h b/src/declarativeimports/core/framesvgitem.h index c929b6da3..8bd64d11f 100644 --- a/src/declarativeimports/core/framesvgitem.h +++ b/src/declarativeimports/core/framesvgitem.h @@ -1,266 +1,266 @@ /*************************************************************************** * Copyright 2010 Marco Martin * * Copyright 2014 David Edmundson * * * * * * 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 02110-1301 USA . * ***************************************************************************/ #ifndef FRAMESVGITEM_P #define FRAMESVGITEM_P #include #include #include #include "units.h" namespace Plasma { class FrameSvg; /** * @class FrameSvgItemMargins * * @short The sizes of a frame's margins. */ class FrameSvgItemMargins : public QObject { Q_OBJECT /** * Width in pixels of the left margin. */ Q_PROPERTY(qreal left READ left NOTIFY marginsChanged) /** * Height in pixels of the top margin. */ Q_PROPERTY(qreal top READ top NOTIFY marginsChanged) /** * Width in pixels of the right margin. */ Q_PROPERTY(qreal right READ right NOTIFY marginsChanged) /** * Height in pixels of the bottom margin. */ Q_PROPERTY(qreal bottom READ bottom NOTIFY marginsChanged) /** * Width in pixels of the left and right margins combined. */ Q_PROPERTY(qreal horizontal READ horizontal NOTIFY marginsChanged) /** * Height in pixels of the top and bottom margins combined. */ Q_PROPERTY(qreal vertical READ vertical NOTIFY marginsChanged) public: FrameSvgItemMargins(Plasma::FrameSvg *frameSvg, QObject *parent = nullptr); qreal left() const; qreal top() const; qreal right() const; qreal bottom() const; qreal horizontal() const; qreal vertical() const; /// returns a vector with left, top, right, bottom QVector margins() const; void setFixed(bool fixed); bool isFixed() const; public Q_SLOTS: void update(); Q_SIGNALS: void marginsChanged(); private: FrameSvg *m_frameSvg; bool m_fixed; }; /** * @class FrameSvgItem * * @short Provides an SVG with borders. * * It is exposed as org.kde.plasma.core.FrameSvgItem */ class FrameSvgItem : public QQuickItem { Q_OBJECT Q_INTERFACES(QQmlParserStatus) /** * Theme relative path of the svg, like "widgets/background" */ Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged) /** * prefix for the 9 piece svg, like "pushed" or "normal" for the button * see http://techbase.kde.org/Development/Tutorials/Plasma/ThemeDetails * for a list of paths and prefixes * It can also be an array of strings, specifying a fallback chain in case * the first element isn't found in the theme, eg ["toolbutton-normal", "normal"] * so it's easy to keep backwards compatibility with old themes * (Note: fallback chain is supported only @since 5.32) */ Q_PROPERTY(QVariant prefix READ prefix WRITE setPrefix NOTIFY prefixChanged) /** * the actual prefix that was used, if a fallback chain array was set as "prefix" * @since 5.34 */ Q_PROPERTY(QString usedPrefix READ usedPrefix NOTIFY usedPrefixChanged) /** * The margins of the frame, read only * @see FrameSvgItemMargins */ Q_PROPERTY(QObject *margins READ margins CONSTANT) /** * The margins of the frame, regardless if they are enabled or not * read only * @see FrameSvgItemMargins */ Q_PROPERTY(QObject *fixedMargins READ fixedMargins CONSTANT) /** * The borders that will be rendered, it's a flag combination of: * NoBorder * TopBorder * BottomBorder * LeftBorder * RightBorder */ Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders WRITE setEnabledBorders NOTIFY enabledBordersChanged) /** * Holds whether the current svg is present in the current theme and NO fallback is involved */ Q_PROPERTY(bool fromCurrentTheme READ fromCurrentTheme NOTIFY fromCurrentThemeChanged) /** * Set a color group for the FrameSvgItem. * if the Svg uses stylesheets and has elements * that are eithe TextColor or BackgroundColor class, * make them use ButtonTextColor/ButtonBackgroundColor * or ViewTextColor/ViewBackgroundColor, ComplementaryTextColor etc. */ Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) /** * Sets the image in a selected status. * Svgs can be colored with system color themes, if the status is selected, * the TextColor will become HighlightedText color and BackgroundColor * will become HighlightColor, making the svg graphics (for instance an icon) * will look correct together selected text * @see Plasma::Svg::status * @since 5.23 */ Q_PROPERTY(Plasma::Svg::Status status READ status WRITE setStatus NOTIFY statusChanged) public: /** * @return true if the svg has the necessary elements with the given prefix * to draw a frame * @param prefix the given prefix we want to check if drawable */ Q_INVOKABLE bool hasElementPrefix(const QString &prefix) const; /// @cond INTERNAL_DOCS FrameSvgItem(QQuickItem *parent = nullptr); ~FrameSvgItem(); void setImagePath(const QString &path); QString imagePath() const; void setPrefix(const QVariant &prefix); QVariant prefix() const; QString usedPrefix() const; void setEnabledBorders(const Plasma::FrameSvg::EnabledBorders borders); Plasma::FrameSvg::EnabledBorders enabledBorders() const; FrameSvgItemMargins *margins(); FrameSvgItemMargins *fixedMargins(); void setColorGroup(Plasma::Theme::ColorGroup group); Plasma::Theme::ColorGroup colorGroup() const; bool fromCurrentTheme() const; void setStatus(Plasma::Svg::Status status); Plasma::Svg::Status status() const; void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; /** * Only to be used from inside this library, is not intended to be invokable */ Plasma::FrameSvg *frameSvg() const; - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override; void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData & data) override; protected: - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; + void classBegin() override; + void componentComplete() override; /// @endcond Q_SIGNALS: void imagePathChanged(); void prefixChanged(); void enabledBordersChanged(); void fromCurrentThemeChanged(); void colorGroupChanged(); void repaintNeeded(); void statusChanged(); void usedPrefixChanged(); private Q_SLOTS: void doUpdate(); void updateDevicePixelRatio(); private: void applyPrefixes(); Plasma::FrameSvg *m_frameSvg; FrameSvgItemMargins *m_margins; FrameSvgItemMargins *m_fixedMargins; QStringList m_prefixes; bool m_textureChanged; bool m_sizeChanged; bool m_fastPath; }; } #endif diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index bf7ff25dc..5378e2acb 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -1,235 +1,235 @@ /* * Copyright 2012 Marco Martin * Copyright 2014 David Edmundson * * 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 ICONITEM_H #define ICONITEM_H #include #include #include #include #include #include class QPropertyAnimation; /** * @class IconItem * @short Displays an icon, either from the standard QIcon system or where applicable from the theme SVG files */ class IconItem : public QQuickItem { Q_OBJECT /** * Sets the icon to be displayed. Source can be one of: * - iconName (as a string) * - URL * - QImage * - QPixmap * - QIcon * * When passing an icon name (or a QIcon with an icon name set) it will: * - load the plasma variant if usesPlasmaTheme is set and exists * - otherwise try to load the icon as an SVG so colorscopes apply * - load the icon as normal */ Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged) /** * Specifies the color group to use for this icon * This only applies to icons loaded from the plasma theme */ Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) /** * Specifies the overlay(s) for this icon */ Q_PROPERTY(QStringList overlays READ overlays WRITE setOverlays NOTIFY overlaysChanged) /** * See QQuickItem::smooth */ //KF6 Remove, this just shadows QQuickItem::smooth Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) /** * Apply a visual indication that this icon is active. * Typically used to indicate that it is hovered */ Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) /** * Sets the image in a selected status. * Svgs can be colored with system color themes, if the status is selected, * the TextColor will become HighlightedText color and BackgroundColor * will become HighlightColor, making the svg graphics (for instance an icon) * will look correct together selected text * @see Plasma::Svg::status * @since 5.23 */ Q_PROPERTY(Plasma::Svg::Status status READ status WRITE setStatus NOTIFY statusChanged) /** * If set, icon will blend when the source is changed */ Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated NOTIFY animatedChanged) /** * If set, icon will try and use icons from the Plasma theme if possible */ Q_PROPERTY(bool usesPlasmaTheme READ usesPlasmaTheme WRITE setUsesPlasmaTheme NOTIFY usesPlasmaThemeChanged) /** * If set, icon will round the painted size to defined icon sizes. Default is true. */ Q_PROPERTY(bool roundToIconSize READ roundToIconSize WRITE setRoundToIconSize NOTIFY roundToIconSizeChanged) /** * True if a valid icon is set. False otherwise. */ Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) /** * The width of the icon that is actually painted * Icons are drawn at standard icon sizes (eg. 16,32,64) centered within the item */ Q_PROPERTY(int paintedWidth READ paintedWidth NOTIFY paintedSizeChanged) /** * The height of the icon actually being drawn. * Icons are drawn at standard icon sizes (eg. 16,32,64) centered within the item */ Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged) Q_PROPERTY(int implicitHeight READ implicitHeight WRITE setImplicitHeight2 NOTIFY implicitHeightChanged2) Q_PROPERTY(int implicitWidth READ implicitWidth WRITE setImplicitWidth2 NOTIFY implicitWidthChanged2) public: explicit IconItem(QQuickItem *parent = nullptr); - ~IconItem() Q_DECL_OVERRIDE; + ~IconItem() override; void setSource(const QVariant &source); QVariant source() const; void setColorGroup(Plasma::Theme::ColorGroup group); Plasma::Theme::ColorGroup colorGroup() const; void setOverlays(const QStringList &overlays); QStringList overlays() const; bool isActive() const; void setActive(bool active); void setSmooth(const bool smooth); bool smooth() const; bool isAnimated() const; void setAnimated(bool animated); bool usesPlasmaTheme() const; void setUsesPlasmaTheme(bool usesPlasmaTheme); bool roundToIconSize() const; void setRoundToIconSize(bool roundToIconSize); bool isValid() const; int paintedWidth() const; int paintedHeight() const; void setStatus(Plasma::Svg::Status status); Plasma::Svg::Status status() const; void setImplicitHeight2(int height); void setImplicitWidth2(int height); - void updatePolish() Q_DECL_OVERRIDE; - QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE; + void updatePolish() override; + QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) override; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) override; void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) Q_DECL_OVERRIDE; + const QRectF &oldGeometry) override; - void componentComplete() Q_DECL_OVERRIDE; + void componentComplete() override; Q_SIGNALS: void overlaysChanged(); void activeChanged(); void sourceChanged(); void smoothChanged(); void animatedChanged(); void usesPlasmaThemeChanged(); void roundToIconSizeChanged(); void validChanged(); void colorGroupChanged(); void paintedSizeChanged(); void statusChanged(); void implicitHeightChanged2(); void implicitWidthChanged2(); private Q_SLOTS: void schedulePixmapUpdate(); void animationFinished(); void valueChanged(const QVariant &value); void onEnabledChanged(); private: void loadPixmap(); QSize paintedSize(const QSizeF &containerSize = QSizeF()) const; void updateImplicitSize(); //all the ways we can set an source. Only one of them will be valid QIcon m_icon; Plasma::Svg *m_svgIcon; QString m_svgIconName; QImage m_imageIcon; //this contains the raw variant it was passed QVariant m_source; Plasma::Svg::Status m_status; bool m_smooth; bool m_active; bool m_animated; bool m_usesPlasmaTheme; bool m_roundToIconSize; bool m_textureChanged; bool m_sizeChanged; bool m_allowNextAnimation; bool m_blockNextAnimation; bool m_implicitHeightSetByUser; bool m_implicitWidthSetByUser; QPixmap m_iconPixmap; QPixmap m_oldIconPixmap; QStringList m_overlays; Plasma::Theme::ColorGroup m_colorGroup; //animation on pixmap change QPropertyAnimation *m_animation; qreal m_animValue; }; #endif diff --git a/src/declarativeimports/core/svgitem.h b/src/declarativeimports/core/svgitem.h index 2a814096a..4f3654f57 100644 --- a/src/declarativeimports/core/svgitem.h +++ b/src/declarativeimports/core/svgitem.h @@ -1,113 +1,113 @@ /*************************************************************************** * Copyright 2010 Marco Martin * * Copyright 2014 David Edmundson * * * * 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 02110-1301 USA . * ***************************************************************************/ #ifndef SVGITEM_P #define SVGITEM_P #include #include #include "units.h" namespace Plasma { class Svg; /** * @class SvgItem * @short Displays an SVG or an element from an SVG file */ class SvgItem : public QQuickItem { Q_OBJECT /** * The sub element of the svg we want to render. If empty the whole svg document will be painted. */ Q_PROPERTY(QString elementId READ elementId WRITE setElementId NOTIFY elementIdChanged) /** * Svg class that is the source of the image, use it like that: * * SvgItem { * svg: Svg {imagePath: "widgets/arrows"} * elementId: "arrow-left" * } * * Instead of a Svg declaration it can also be the id of a Svg declared elsewhere, useful to share Svg instances. */ Q_PROPERTY(Plasma::Svg *svg READ svg WRITE setSvg NOTIFY svgChanged) /** * The natural, unscaled size of the svg document or the element. useful if a pixel perfect rendering of outlines is needed. */ Q_PROPERTY(QSizeF naturalSize READ naturalSize NOTIFY naturalSizeChanged) /** * If true enable antialiasing in paint: default off, better quality but less performance. */ Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) public: /// @cond INTERNAL_DOCS explicit SvgItem(QQuickItem *parent = nullptr); ~SvgItem(); void setElementId(const QString &elementID); QString elementId() const; void setSvg(Plasma::Svg *svg); Plasma::Svg *svg() const; void setSmooth(const bool smooth); bool smooth() const; QSizeF naturalSize() const; - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) Q_DECL_OVERRIDE; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; /// @endcond Q_SIGNALS: void elementIdChanged(); void svgChanged(); void naturalSizeChanged(); void smoothChanged(); protected Q_SLOTS: /// @cond INTERNAL_DOCS void updateNeeded(); void updateDevicePixelRatio(); /// @endcond private: void scheduleImageUpdate(); - void updatePolish() Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; + void updatePolish() override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; QWeakPointer m_svg; QString m_elementID; bool m_smooth; bool m_textureChanged; QImage m_image; }; } #endif diff --git a/src/declarativeimports/core/tooltip.h b/src/declarativeimports/core/tooltip.h index 543b6c5c6..efed9b8bd 100644 --- a/src/declarativeimports/core/tooltip.h +++ b/src/declarativeimports/core/tooltip.h @@ -1,226 +1,226 @@ /*************************************************************************** * Copyright 2011 Marco Martin * * Copyright 2011 Artur Duque de Souza * * Copyright 2013 Sebastian Kügler * * * * 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 02110-1301 USA . * ***************************************************************************/ #ifndef TOOLTIPOBJECT_H #define TOOLTIPOBJECT_H #include #include #include #include class QQuickItem; class QGraphicsWidget; class ToolTipDialog; /** * @class ToolTip * * An Item managing a Plasma-themed tooltip. It is rendered in its own window. * You can either specify icon, mainText and subText, or a custom Component * that will be put inside the tooltip. By default the tooltip will be * rendered when hovering over the parent item. * * The item inside the ToolTipArea is loaded on demand and will be destroyed when the * tooltip is being hidden. * * Example usage: * @code * import org.kde.plasma.core 2.0 as PlasmaCore * * [...] * PlasmaCore.IconItem { * ... * PlasmaCore.ToolTipArea { * mainText: i18n("Tooltip Title") * subText: i18n("Some explanation.") * icon: "plasma" * // alternatively, you can specify your own component * // to be loaded when the tooltip shows * mainItem: Component { * YourCustomItem { ... } * } * ... } * } * @endcode * */ class ToolTip : public QQuickItem { Q_OBJECT /** * The item shown inside the tooltip. */ Q_PROPERTY(QQuickItem *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged) /** * The main text of this tooltip */ Q_PROPERTY(QString mainText READ mainText WRITE setMainText NOTIFY mainTextChanged) /** * The description of this tooltip */ Q_PROPERTY(QString subText READ subText WRITE setSubText NOTIFY subTextChanged) /** * how to handle the text format of the tooltip subtext: * * Text.AutoText (default) * * Text.PlainText * * Text.StyledText * * Text.RichText * Note: in the default implementation the main text is always plain text */ Q_PROPERTY(int textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) /** * An icon for this tooltip, accepted values are an icon name, a QIcon, QImage or QPixmap */ Q_PROPERTY(QVariant icon READ icon WRITE setIcon NOTIFY iconChanged) /** * Returns whether the mouse is inside the item */ Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) /** * Plasma Location of the dialog window. Useful if this dialog is a popup for a panel */ Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged) /** * TODO: single property for images? * An image for this tooltip, accepted values are an icon name, a QIcon, QImage or QPixmap */ Q_PROPERTY(QVariant image READ image WRITE setImage NOTIFY imageChanged) /** * Property that controls if a tooltips will show on mouse over. * The default is true. */ Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged) /** * if interactive is false (default), the tooltip will automatically hide * itself as soon as the mouse leaves the tooltiparea, if is true, if the mouse leaves tooltiparea and goes over the tooltip itself, the tooltip won't hide, so it will be possible to interact with tooltip contents */ Q_PROPERTY(bool interactive MEMBER m_interactive WRITE setInteractive NOTIFY interactiveChanged) public: /// @cond INTERNAL_DOCS explicit ToolTip(QQuickItem *parent = nullptr); - ~ToolTip() Q_DECL_OVERRIDE; + ~ToolTip() override; QQuickItem *mainItem() const; void setMainItem(QQuickItem *mainItem); void showToolTip(); QString mainText() const; void setMainText(const QString &mainText); QString subText() const; void setSubText(const QString &subText); int textFormat() const; void setTextFormat(int format); QVariant icon() const; void setIcon(const QVariant &icon); QVariant image() const; void setImage(const QVariant &image); Plasma::Types::Location location() const; void setLocation(Plasma::Types::Location location); bool containsMouse() const; void setContainsMouse(bool contains); void setActive(bool active); void setInteractive(bool interactive); /// @endcond public Q_SLOTS: /** * Hides the tooltip if shown. Does not affect whether the tooltip area is active. */ void hideToolTip(); protected: /// @cond INTERNAL_DOCS - bool childMouseEventFilter(QQuickItem *item, QEvent *event) Q_DECL_OVERRIDE; - void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; - void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; + bool childMouseEventFilter(QQuickItem *item, QEvent *event) override; + void hoverEnterEvent(QHoverEvent *event) override; + void hoverLeaveEvent(QHoverEvent *event) override; ToolTipDialog *tooltipDialogInstance(); /// @endcond Q_SIGNALS: void mainItemChanged(); void mainTextChanged(); void subTextChanged(); void textFormatChanged(); void iconChanged(); void imageChanged(); void containsMouseChanged(); void locationChanged(); void activeChanged(); void interactiveChanged(); /** * Emitted just before the tooltip dialog is shown. * * @since 5.45 */ void aboutToShow(); private Q_SLOTS: void settingsChanged(const QString &file); private: bool isValid() const; void loadSettings(); bool m_tooltipsEnabledGlobally; bool m_containsMouse; Plasma::Types::Location m_location; QWeakPointer m_mainItem; QTimer *m_showTimer; QString m_mainText; QString m_subText; int m_textFormat; QVariant m_image; QVariant m_icon; bool m_active; bool m_interactive; int m_interval; //ToolTipDialog is not a Q_GLOBAL_STATIC because QQuickwindows as global static //are deleted too later after some stuff in the qml runtime has already been deleted, //causing a crash on exit bool m_usingDialog : 1; static ToolTipDialog *s_dialog; static int s_dialogUsers; }; #endif diff --git a/src/declarativeimports/core/tooltipdialog.h b/src/declarativeimports/core/tooltipdialog.h index ce9011f7a..63c88a62d 100644 --- a/src/declarativeimports/core/tooltipdialog.h +++ b/src/declarativeimports/core/tooltipdialog.h @@ -1,83 +1,83 @@ /*************************************************************************** * Copyright 2013 Sebastian Kügler * * * * 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 02110-1301 USA . * ***************************************************************************/ #ifndef TOOLTIPDIALOG_H #define TOOLTIPDIALOG_H #include "dialog.h" #include #include #include #include class QQuickItem; class QGraphicsWidget; namespace KDeclarative { class QmlObject; } /** * Internally used by Tooltip */ class ToolTipDialog : public PlasmaQuick::Dialog { Q_OBJECT public: explicit ToolTipDialog(QQuickItem *parent = nullptr); - ~ToolTipDialog() Q_DECL_OVERRIDE; + ~ToolTipDialog() override; QQuickItem *loadDefaultItem(); Plasma::Types::Direction direction() const; void setDirection(Plasma::Types::Direction loc); void dismiss(); void keepalive(); bool interactive(); void setInteractive(bool interactive); /** * Basically the last one who has shown the dialog */ QObject *owner() const; void setOwner(QObject *owner); protected: - void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *re) Q_DECL_OVERRIDE; - bool event(QEvent *e) Q_DECL_OVERRIDE; + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; + void resizeEvent(QResizeEvent *re) override; + bool event(QEvent *e) override; private Q_SLOTS: void valueChanged(const QVariant &value); private: KDeclarative::QmlObject *m_qmlObject; QTimer *m_showTimer; int m_hideTimeout; bool m_interactive; QObject *m_owner; }; #endif diff --git a/src/declarativeimports/core/units.h b/src/declarativeimports/core/units.h index a0a7e9f28..c373d566e 100644 --- a/src/declarativeimports/core/units.h +++ b/src/declarativeimports/core/units.h @@ -1,239 +1,239 @@ /*************************************************************************** * Copyright 2013 Marco Martin * * Copyright 2014 Sebastian Kügler * * * * 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 02110-1301 USA . * ***************************************************************************/ #ifndef UNITS_H #define UNITS_H #include #include #include class QQuickItem; class SharedAppFilter : public QObject { Q_OBJECT public: explicit SharedAppFilter(QObject *parent = nullptr); - ~SharedAppFilter() Q_DECL_OVERRIDE; + ~SharedAppFilter() override; Q_SIGNALS: void fontChanged(); protected: - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *event) override; }; /** * @class Units * @short Expose sizes to QML */ class Units : public QObject { Q_OBJECT /** * The fundamental unit of space that should be used for sizes, expressed in pixels. * Given the screen has an accurate DPI settings, it corresponds to a width of * the capital letter M */ Q_PROPERTY(int gridUnit READ gridUnit NOTIFY gridUnitChanged) /** * units.iconSizes provides access to platform-dependent icon sizing * * The icon sizes provided are normalized for different DPI, so icons * will scale depending on the DPI. * * Icon sizes from KIconLoader, adjusted to devicePixelRatio: * * small * * smallMedium * * medium * * large * * huge * * enormous * * desktop (DEPRECATED: use iconSizeHints instead) * */ //note the iconSizeChanged signal indicates that one (or more) of these icons have changed //but the property map itself remains constant Q_PROPERTY(QQmlPropertyMap *iconSizes READ iconSizes CONSTANT) /** * units.iconSizeHints provides access to user-configurable icon size hints, * to be used where appropriate in the user interface. * * Conceptually, an icon size hint is a key that has one of the sizes from * @iconSizes property as value. * * Currently available hints: * * panel * * desktop */ //note the iconSizeHintsChanged signal indicates that one (or more) of these icons have changed //but the property map itself remains constant Q_PROPERTY(QQmlPropertyMap *iconSizeHints READ iconSizeHints CONSTANT) // layout hints /** * units.smallSpacing is the amount of spacing that should be used around smaller UI elements, * for example as spacing in Columns. Internally, this size depends on the size of * the default font as rendered on the screen, so it takes user-configured font size and DPI * into account. */ Q_PROPERTY(int smallSpacing READ smallSpacing NOTIFY spacingChanged) /** * units.largeSpacing is the amount of spacing that should be used inside bigger UI elements, * for example between an icon and the corresponding text. Internally, this size depends on * the size of the default font as rendered on the screen, so it takes user-configured font * size and DPI into account. */ Q_PROPERTY(int largeSpacing READ largeSpacing NOTIFY spacingChanged) /** * The ratio between physical and device-independent pixels. This value does not depend on the \ * size of the configured font. If you want to take font sizes into account when scaling elements, * use theme.mSize(theme.defaultFont), units.smallSpacing and units.largeSpacing. * The devicePixelRatio follows the definition of "device independent pixel" by Microsoft. */ Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged) /** * units.longDuration should be used for longer, screen-covering animations, for opening and * closing of dialogs and other "not too small" animations */ Q_PROPERTY(int longDuration READ longDuration NOTIFY durationChanged) /** * units.shortDuration should be used for short animations, such as accentuating a UI event, * hover events, etc.. */ Q_PROPERTY(int shortDuration READ shortDuration NOTIFY durationChanged) public: /// @cond INTERNAL_DOCS ~Units(); /** * @return a reference to the global Units instance * @since 5.31 */ static Units &instance(); /** * @return pixel value for a grid Unit. Depends on DPI and font size. */ int gridUnit() const; /** * @return The ratio between physical and device-independent pixels. */ qreal devicePixelRatio() const; /** * @return map with iconsizes, indexed by name */ QQmlPropertyMap *iconSizes() const; /** * @return map with user-configurable icon size hints, indexed by name * @since 5.33 */ QQmlPropertyMap *iconSizeHints() const; /** * @return Pixel value for large spacing between elements. * @since 5.0 */ int smallSpacing() const; /** * @return Pixel value for large spacing between elements. * @since 5.0 */ int largeSpacing() const; /** * @return Duration for long animations, in milliseconds. * @since 5.0 */ int longDuration() const; /** * @return Duration for short animations, in milliseconds. * @since 5.0 */ int shortDuration() const; /// @endcond /** * @return a size rounded tothe nearest inferior standard icon size. * sizes larger than iconSizes.huge, it will be returned unmodified * @param int size the size we want to be rounded down * @see iconSizes */ Q_INVOKABLE static int roundToIconSize(int size); Q_SIGNALS: void devicePixelRatioChanged(); void gridUnitChanged(); void iconSizesChanged(); void iconSizeHintsChanged(); void spacingChanged(); void durationChanged(); private Q_SLOTS: void iconLoaderSettingsChanged(); void settingsFileChanged(const QString &file); void updateSpacing(); private: Units(QObject *parent = nullptr); Units(Units const&) = delete; // Copy construct Units(Units&&) = delete; // Move construct Units& operator=(Units const&) = delete; // Copy assign Units& operator=(Units &&) = delete; // Move assign void updateDevicePixelRatio(); void updatePlasmaRCSettings(); /** * @return The dpi-adjusted size for a given icon size */ int devicePixelIconSize(const int size) const; int m_gridUnit; qreal m_devicePixelRatio; QQmlPropertyMap *m_iconSizes; QQmlPropertyMap *m_iconSizeHints; static SharedAppFilter *s_sharedAppFilter; int m_smallSpacing; int m_largeSpacing; int m_longDuration; }; #endif //UNITS_H diff --git a/src/declarativeimports/core/windowthumbnail.cpp b/src/declarativeimports/core/windowthumbnail.cpp index f9e955479..c6dcf90c8 100644 --- a/src/declarativeimports/core/windowthumbnail.cpp +++ b/src/declarativeimports/core/windowthumbnail.cpp @@ -1,899 +1,899 @@ /* * Copyright 2013 by Martin Gräßlin * 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 "windowthumbnail.h" // KF5 #include // Qt #include #include #include #include #include // X11 #if HAVE_XCB_COMPOSITE #include #include #if HAVE_GLX #include typedef void (*glXBindTexImageEXT_func)(Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); typedef void (*glXReleaseTexImageEXT_func)(Display *dpy, GLXDrawable drawable, int buffer); #endif #if HAVE_EGL typedef EGLImageKHR(*eglCreateImageKHR_func)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *); typedef EGLBoolean(*eglDestroyImageKHR_func)(EGLDisplay, EGLImageKHR); typedef GLvoid(*glEGLImageTargetTexture2DOES_func)(GLenum, GLeglImageOES); #endif // HAVE_EGL #endif #include namespace Plasma { #if HAVE_XCB_COMPOSITE #if HAVE_GLX class DiscardGlxPixmapRunnable : public QRunnable { public: DiscardGlxPixmapRunnable( uint, QFunctionPointer, xcb_pixmap_t ); - void run() Q_DECL_OVERRIDE; + void run() override; private: uint m_texture; QFunctionPointer m_releaseTexImage; xcb_pixmap_t m_glxPixmap; }; DiscardGlxPixmapRunnable::DiscardGlxPixmapRunnable(uint texture, QFunctionPointer deleteFunction, xcb_pixmap_t pixmap) : QRunnable(), m_texture(texture), m_releaseTexImage(deleteFunction), m_glxPixmap(pixmap) {} void DiscardGlxPixmapRunnable::run() { if (m_glxPixmap != XCB_PIXMAP_NONE) { Display *d = QX11Info::display(); ((glXReleaseTexImageEXT_func)(m_releaseTexImage))(d, m_glxPixmap, GLX_FRONT_LEFT_EXT); glXDestroyPixmap(d, m_glxPixmap); glDeleteTextures(1, &m_texture); } } #endif //HAVE_GLX #if HAVE_EGL class DiscardEglPixmapRunnable : public QRunnable { public: DiscardEglPixmapRunnable( uint, QFunctionPointer, EGLImageKHR ); - void run() Q_DECL_OVERRIDE; + void run() override; private: uint m_texture; QFunctionPointer m_eglDestroyImageKHR; EGLImageKHR m_image; }; DiscardEglPixmapRunnable::DiscardEglPixmapRunnable(uint texture, QFunctionPointer deleteFunction, EGLImageKHR image) : QRunnable(), m_texture(texture), m_eglDestroyImageKHR(deleteFunction), m_image(image) {} void DiscardEglPixmapRunnable::run() { if (m_image != EGL_NO_IMAGE_KHR) { ((eglDestroyImageKHR_func)(m_eglDestroyImageKHR))(eglGetCurrentDisplay(), m_image); glDeleteTextures(1, &m_texture); } } #endif//HAVE_EGL #endif //HAVE_XCB_COMPOSITE WindowTextureNode::WindowTextureNode() : QSGSimpleTextureNode() { } WindowTextureNode::~WindowTextureNode() { } void WindowTextureNode::reset(QSGTexture *texture) { setTexture(texture); m_texture.reset(texture); } WindowThumbnail::WindowThumbnail(QQuickItem *parent) : QQuickItem(parent) , QAbstractNativeEventFilter() , m_xcb(false) , m_composite(false) , m_winId(0) , m_paintedSize(QSizeF()) , m_thumbnailAvailable(false) , m_damaged(false) , m_depth(0) #if HAVE_XCB_COMPOSITE , m_openGLFunctionsResolved(false) , m_damageEventBase(0) , m_damage(XCB_NONE) , m_pixmap(XCB_PIXMAP_NONE) , m_texture(0) #if HAVE_GLX , m_glxPixmap(XCB_PIXMAP_NONE) , m_bindTexImage(nullptr) , m_releaseTexImage(nullptr) #endif // HAVE_GLX #if HAVE_EGL , m_eglFunctionsResolved(false) , m_image(EGL_NO_IMAGE_KHR) , m_eglCreateImageKHR(nullptr) , m_eglDestroyImageKHR(nullptr) , m_glEGLImageTargetTexture2DOES(nullptr) #endif // HAVE_EGL #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(); update(); }); connect(this, &QQuickItem::enabledChanged, [this]() { if (!isEnabled()) { stopRedirecting(); releaseResources(); } else if (isVisible()) { startRedirecting(); update(); } }); connect(this, &QQuickItem::visibleChanged, [this]() { if (!isVisible()) { stopRedirecting(); releaseResources(); } else if (isEnabled()) { startRedirecting(); update(); } }); if (QGuiApplication *gui = dynamic_cast(QCoreApplication::instance())) { m_xcb = (gui->platformName() == QStringLiteral("xcb")); if (m_xcb) { gui->installNativeEventFilter(this); #if HAVE_XCB_COMPOSITE xcb_connection_t *c = QX11Info::connection(); xcb_prefetch_extension_data(c, &xcb_composite_id); const auto *compositeReply = xcb_get_extension_data(c, &xcb_composite_id); m_composite = (compositeReply && compositeReply->present); xcb_prefetch_extension_data(c, &xcb_damage_id); const auto *reply = xcb_get_extension_data(c, &xcb_damage_id); m_damageEventBase = reply->first_event; if (reply->present) { xcb_damage_query_version_unchecked(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION); } #endif } } } WindowThumbnail::~WindowThumbnail() { if (m_xcb) { QCoreApplication::instance()->removeNativeEventFilter(this); stopRedirecting(); } } void WindowThumbnail::releaseResources() { #if HAVE_XCB_COMPOSITE #if HAVE_GLX && HAVE_EGL //only one (or none) should be set, but never both Q_ASSERT(m_glxPixmap == XCB_PIXMAP_NONE || m_image == EGL_NO_IMAGE_KHR); #endif #if HAVE_GLX || HAVE_EGL QQuickWindow::RenderStage m_renderStage = QQuickWindow::NoStage; #endif //data is deleted in the render thread (with relevant GLX calls) //note runnable may be called *after* this is deleted //but the pointer is held by the WindowThumbnail which is in the main thread #if HAVE_GLX if (m_glxPixmap != XCB_PIXMAP_NONE) { window()->scheduleRenderJob(new DiscardGlxPixmapRunnable(m_texture, m_releaseTexImage, m_glxPixmap), m_renderStage); m_glxPixmap = XCB_PIXMAP_NONE; m_texture = 0; } #endif #if HAVE_EGL if (m_image != EGL_NO_IMAGE_KHR) { window()->scheduleRenderJob(new DiscardEglPixmapRunnable(m_texture, m_eglDestroyImageKHR, m_image), m_renderStage); m_image = EGL_NO_IMAGE_KHR; m_texture = 0; } #endif #endif } uint32_t WindowThumbnail::winId() const { return m_winId; } void WindowThumbnail::setWinId(uint32_t winId) { if (m_winId == winId) { return; } if (!KWindowSystem::self()->hasWId(winId)) { // invalid Id, don't updated return; } if (window() && winId == window()->winId()) { // don't redirect to yourself return; } stopRedirecting(); m_winId = winId; if (isEnabled() && isVisible()) { startRedirecting(); } emit winIdChanged(); } qreal WindowThumbnail::paintedWidth() const { return m_paintedSize.width(); } qreal WindowThumbnail::paintedHeight() const { return m_paintedSize.height(); } bool WindowThumbnail::thumbnailAvailable() const { return m_thumbnailAvailable; } QSGNode *WindowThumbnail::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) { Q_UNUSED(updatePaintNodeData) auto *node = static_cast(oldNode); if (!node) { node = new WindowTextureNode(); node->setFiltering(QSGTexture::Linear); } if (!m_xcb || m_winId == 0 || (window() && window()->winId() == m_winId)) { iconToTexture(node); } else { windowToTexture(node); } node->setRect(boundingRect()); const QSizeF size(node->texture()->textureSize().scaled(boundingRect().size().toSize(), Qt::KeepAspectRatio)); if (size != m_paintedSize) { m_paintedSize = size; emit paintedSizeChanged(); } const qreal x = boundingRect().x() + (boundingRect().width() - size.width()) / 2; const qreal y = boundingRect().y() + (boundingRect().height() - size.height()) / 2; node->setRect(QRectF(QPointF(x, y), size)); return node; } bool WindowThumbnail::nativeEventFilter(const QByteArray &eventType, void *message, long int *result) { Q_UNUSED(result) if (!m_xcb || !m_composite || eventType != QByteArrayLiteral("xcb_generic_event_t")) { // currently we are only interested in XCB events return false; } #if HAVE_XCB_COMPOSITE xcb_generic_event_t *event = static_cast(message); const uint8_t responseType = event->response_type & ~0x80; if (responseType == m_damageEventBase + XCB_DAMAGE_NOTIFY) { if (reinterpret_cast(event)->drawable == m_winId) { m_damaged = true; update(); } } else if (responseType == XCB_CONFIGURE_NOTIFY) { if (reinterpret_cast(event)->window == m_winId) { releaseResources(); m_damaged = true; update(); } } else if (responseType == XCB_MAP_NOTIFY) { if (reinterpret_cast(event)->window == m_winId) { releaseResources(); m_damaged = true; update(); } } #else Q_UNUSED(message) #endif // do not filter out any events, there might be further WindowThumbnails for the same window return false; } void WindowThumbnail::iconToTexture(WindowTextureNode *textureNode) { QIcon icon; if (KWindowSystem::self()->hasWId(m_winId)) { icon = KWindowSystem::self()->icon(m_winId, boundingRect().width(), boundingRect().height()); } else { // fallback to plasma icon icon = QIcon::fromTheme(QStringLiteral("plasma")); } QImage image = icon.pixmap(boundingRect().size().toSize()).toImage(); textureNode->reset(window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas)); } #if HAVE_XCB_COMPOSITE #if HAVE_GLX bool WindowThumbnail::windowToTextureGLX(WindowTextureNode *textureNode) { if (glXGetCurrentContext()) { if (!m_openGLFunctionsResolved) { resolveGLXFunctions(); } if (!m_bindTexImage || !m_releaseTexImage) { return false; } if (m_glxPixmap == XCB_PIXMAP_NONE) { xcb_connection_t *c = QX11Info::connection(); auto attrCookie = xcb_get_window_attributes_unchecked(c, m_winId); auto geometryCookie = xcb_get_geometry_unchecked(c, m_pixmap); QScopedPointer attr(xcb_get_window_attributes_reply(c, attrCookie, nullptr)); QScopedPointer geo(xcb_get_geometry_reply(c, geometryCookie, nullptr)); if (attr.isNull()) { return false; } if (geo.isNull()) { return false; } m_depth = geo->depth; m_visualid = attr->visual; if (!loadGLXTexture()) { return false; } textureNode->reset(window()->createTextureFromId(m_texture, QSize(geo->width, geo->height), QQuickWindow::TextureCanUseAtlas)); } textureNode->texture()->bind(); bindGLXTexture(); return true; } return false; } #endif // HAVE_GLX #if HAVE_EGL bool WindowThumbnail::xcbWindowToTextureEGL(WindowTextureNode *textureNode) { EGLContext context = eglGetCurrentContext(); if (context != EGL_NO_CONTEXT) { if (!m_eglFunctionsResolved) { resolveEGLFunctions(); } if (QByteArray((char *)glGetString(GL_RENDERER)).contains("llvmpipe")) { return false; } if (!m_eglCreateImageKHR || !m_eglDestroyImageKHR || !m_glEGLImageTargetTexture2DOES) { return false; } if (m_image == EGL_NO_IMAGE_KHR) { xcb_connection_t *c = QX11Info::connection(); auto geometryCookie = xcb_get_geometry_unchecked(c, m_pixmap); const EGLint attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; m_image = ((eglCreateImageKHR_func)(m_eglCreateImageKHR))(eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)m_pixmap, attribs); if (m_image == EGL_NO_IMAGE_KHR) { qDebug() << "failed to create egl image"; return false; } glGenTextures(1, &m_texture); QScopedPointer geo(xcb_get_geometry_reply(c, geometryCookie, nullptr)); QSize size; if (!geo.isNull()) { size.setWidth(geo->width); size.setHeight(geo->height); } textureNode->reset(window()->createTextureFromId(m_texture, size, QQuickWindow::TextureCanUseAtlas)); } textureNode->texture()->bind(); bindEGLTexture(); return true; } return false; } void WindowThumbnail::resolveEGLFunctions() { EGLDisplay display = eglGetCurrentDisplay(); if (display == EGL_NO_DISPLAY) { return; } auto *context = window()->openglContext(); QList extensions = QByteArray(eglQueryString(display, EGL_EXTENSIONS)).split(' '); if (extensions.contains(QByteArrayLiteral("EGL_KHR_image")) || (extensions.contains(QByteArrayLiteral("EGL_KHR_image_base")) && extensions.contains(QByteArrayLiteral("EGL_KHR_image_pixmap")))) { if (context->hasExtension(QByteArrayLiteral("GL_OES_EGL_image"))) { qDebug() << "Have EGL texture from pixmap"; m_eglCreateImageKHR = context->getProcAddress(QByteArrayLiteral("eglCreateImageKHR")); m_eglDestroyImageKHR = context->getProcAddress(QByteArrayLiteral("eglDestroyImageKHR")); m_glEGLImageTargetTexture2DOES = context->getProcAddress(QByteArrayLiteral("glEGLImageTargetTexture2DOES")); } } m_eglFunctionsResolved = true; } void WindowThumbnail::bindEGLTexture() { ((glEGLImageTargetTexture2DOES_func)(m_glEGLImageTargetTexture2DOES))(GL_TEXTURE_2D, (GLeglImageOES)m_image); resetDamaged(); } #endif // HAVE_EGL #endif // HAVE_XCB_COMPOSITE void WindowThumbnail::windowToTexture(WindowTextureNode *textureNode) { if (!m_damaged && textureNode->texture()) { return; } #if HAVE_XCB_COMPOSITE if (!textureNode->texture()) { // the texture got discarded by the scene graph, but our mapping is still valid // let's discard the pixmap to have a clean state again releaseResources(); } if (m_pixmap == XCB_PIXMAP_NONE) { m_pixmap = pixmapForWindow(); } if (m_pixmap == XCB_PIXMAP_NONE) { // create above failed iconToTexture(textureNode); setThumbnailAvailable(false); return; } bool fallbackToIcon = true; #if HAVE_GLX fallbackToIcon = !windowToTextureGLX(textureNode); #endif // HAVE_GLX #if HAVE_EGL if (fallbackToIcon) { // if glx succeeded fallbackToIcon is false, thus we shouldn't try egl fallbackToIcon = !xcbWindowToTextureEGL(textureNode); } #endif // HAVE_EGL if (fallbackToIcon) { // just for safety to not crash iconToTexture(textureNode); } setThumbnailAvailable(!fallbackToIcon); textureNode->markDirty(QSGNode::DirtyForceUpdate); #else iconToTexture(textureNode); #endif } #if HAVE_XCB_COMPOSITE xcb_pixmap_t WindowThumbnail::pixmapForWindow() { if (!m_composite) { return XCB_PIXMAP_NONE; } xcb_connection_t *c = QX11Info::connection(); xcb_pixmap_t pix = xcb_generate_id(c); auto cookie = xcb_composite_name_window_pixmap_checked(c, m_winId, pix); QScopedPointer error(xcb_request_check(c, cookie)); if (error) { return XCB_PIXMAP_NONE; } return pix; } #if HAVE_GLX void WindowThumbnail::resolveGLXFunctions() { auto *context = window()->openglContext(); QList extensions = QByteArray(glXQueryExtensionsString(QX11Info::display(), QX11Info::appScreen())).split(' '); if (extensions.contains(QByteArrayLiteral("GLX_EXT_texture_from_pixmap"))) { m_bindTexImage = context->getProcAddress(QByteArrayLiteral("glXBindTexImageEXT")); m_releaseTexImage = context->getProcAddress(QByteArrayLiteral("glXReleaseTexImageEXT")); } else qWarning() << "couldn't resolve GLX_EXT_texture_from_pixmap functions"; m_openGLFunctionsResolved = true; } void WindowThumbnail::bindGLXTexture() { Display *d = QX11Info::display(); ((glXReleaseTexImageEXT_func)(m_releaseTexImage))(d, m_glxPixmap, GLX_FRONT_LEFT_EXT); ((glXBindTexImageEXT_func)(m_bindTexImage))(d, m_glxPixmap, GLX_FRONT_LEFT_EXT, NULL); resetDamaged(); } struct FbConfigInfo { GLXFBConfig fbConfig; int textureFormat; }; struct GlxGlobalData { GlxGlobalData() { xcb_connection_t * const conn = QX11Info::connection(); // Fetch the render pict formats reply = xcb_render_query_pict_formats_reply(conn, xcb_render_query_pict_formats_unchecked(conn), nullptr); // Init the visual ID -> format ID hash table for (auto screens = xcb_render_query_pict_formats_screens_iterator(reply); screens.rem; xcb_render_pictscreen_next(&screens)) { for (auto depths = xcb_render_pictscreen_depths_iterator(screens.data); depths.rem; xcb_render_pictdepth_next(&depths)) { const xcb_render_pictvisual_t *visuals = xcb_render_pictdepth_visuals(depths.data); const int len = xcb_render_pictdepth_visuals_length(depths.data); for (int i = 0; i < len; i++) visualPictFormatHash.insert(visuals[i].visual, visuals[i].format); } } // Init the format ID -> xcb_render_directformat_t* hash table const xcb_render_pictforminfo_t *formats = xcb_render_query_pict_formats_formats(reply); const int len = xcb_render_query_pict_formats_formats_length(reply); for (int i = 0; i < len; i++) { if (formats[i].type == XCB_RENDER_PICT_TYPE_DIRECT) formatInfoHash.insert(formats[i].id, &formats[i].direct); } // Init the visual ID -> depth hash table const xcb_setup_t *setup = xcb_get_setup(conn); for (auto screen = xcb_setup_roots_iterator(setup); screen.rem; xcb_screen_next(&screen)) { for (auto depth = xcb_screen_allowed_depths_iterator(screen.data); depth.rem; xcb_depth_next(&depth)) { const int len = xcb_depth_visuals_length(depth.data); const xcb_visualtype_t *visuals = xcb_depth_visuals(depth.data); for (int i = 0; i < len; i++) visualDepthHash.insert(visuals[i].visual_id, depth.data->depth); } } } ~GlxGlobalData() { qDeleteAll(visualFbConfigHash); std::free(reply); } xcb_render_query_pict_formats_reply_t *reply; QHash visualPictFormatHash; QHash visualDepthHash; QHash visualFbConfigHash; QHash formatInfoHash; }; Q_GLOBAL_STATIC(GlxGlobalData, g_glxGlobalData) static xcb_render_pictformat_t findPictFormat(xcb_visualid_t visual) { GlxGlobalData *d = g_glxGlobalData; return d->visualPictFormatHash.value(visual); } static const xcb_render_directformat_t *findPictFormatInfo(xcb_render_pictformat_t format) { GlxGlobalData *d = g_glxGlobalData; return d->formatInfoHash.value(format); } static int visualDepth(xcb_visualid_t visual) { GlxGlobalData *d = g_glxGlobalData; return d->visualDepthHash.value(visual); } FbConfigInfo *getConfig(xcb_visualid_t visual) { Display *dpy = QX11Info::display(); const xcb_render_pictformat_t format = findPictFormat(visual); const xcb_render_directformat_t *direct = findPictFormatInfo(format); if (!direct) { return nullptr; } const int red_bits = qPopulationCount(direct->red_mask); const int green_bits = qPopulationCount(direct->green_mask); const int blue_bits = qPopulationCount(direct->blue_mask); const int alpha_bits = qPopulationCount(direct->alpha_mask); const int depth = visualDepth(visual); const auto rgb_sizes = std::tie(red_bits, green_bits, blue_bits); const int attribs[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT, GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, GLX_X_RENDERABLE, True, GLX_CONFIG_CAVEAT, int(GLX_DONT_CARE), // The ARGB32 visual is marked non-conformant in Catalyst GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, int(GLX_DONT_CARE), GLX_BUFFER_SIZE, red_bits + green_bits + blue_bits + alpha_bits, GLX_RED_SIZE, red_bits, GLX_GREEN_SIZE, green_bits, GLX_BLUE_SIZE, blue_bits, GLX_ALPHA_SIZE, alpha_bits, GLX_STENCIL_SIZE, 0, GLX_DEPTH_SIZE, 0, 0 }; if (QByteArray((char *)glGetString(GL_RENDERER)).contains("llvmpipe")) { return nullptr; } int count = 0; GLXFBConfig *configs = glXChooseFBConfig(dpy, QX11Info::appScreen(), attribs, &count); if (count < 1) { return nullptr; } struct FBConfig { GLXFBConfig config; int depth; int stencil; int format; }; QList candidates; for (int i = 0; i < count; i++) { int red, green, blue; glXGetFBConfigAttrib(dpy, configs[i], GLX_RED_SIZE, &red); glXGetFBConfigAttrib(dpy, configs[i], GLX_GREEN_SIZE, &green); glXGetFBConfigAttrib(dpy, configs[i], GLX_BLUE_SIZE, &blue); if (std::tie(red, green, blue) != rgb_sizes) continue; xcb_visualid_t visual; glXGetFBConfigAttrib(dpy, configs[i], GLX_VISUAL_ID, (int *) &visual); if (visualDepth(visual) != depth) continue; int bind_rgb, bind_rgba; glXGetFBConfigAttrib(dpy, configs[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, &bind_rgba); glXGetFBConfigAttrib(dpy, configs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &bind_rgb); if (!bind_rgb && !bind_rgba) continue; int texture_targets; glXGetFBConfigAttrib(dpy, configs[i], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &texture_targets); if ((texture_targets & GLX_TEXTURE_2D_BIT_EXT) == 0) continue; int depth, stencil; glXGetFBConfigAttrib(dpy, configs[i], GLX_DEPTH_SIZE, &depth); glXGetFBConfigAttrib(dpy, configs[i], GLX_STENCIL_SIZE, &stencil); int texture_format; if (alpha_bits) texture_format = bind_rgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT; else texture_format = bind_rgb ? GLX_TEXTURE_FORMAT_RGB_EXT : GLX_TEXTURE_FORMAT_RGBA_EXT; candidates.append(FBConfig{configs[i], depth, stencil, texture_format}); } if (count > 0) XFree(configs); std::stable_sort(candidates.begin(), candidates.end(), [](const FBConfig &left, const FBConfig &right) { if (left.depth < right.depth) return true; if (left.stencil < right.stencil) return true; return false; }); FbConfigInfo *info = nullptr; if (candidates.size() > 0) { const FBConfig &candidate = candidates.front(); info = new FbConfigInfo; info->fbConfig = candidate.config; info->textureFormat = candidate.format; } return info; } bool WindowThumbnail::loadGLXTexture() { GLXContext glxContext = glXGetCurrentContext(); if (!glxContext) { return false; } FbConfigInfo *info = nullptr; auto &hashTable = g_glxGlobalData->visualFbConfigHash; auto it = hashTable.constFind(m_visualid); if (it != hashTable.constEnd()) { info = *it; } else { info = getConfig(m_visualid); hashTable.insert(m_visualid, info); } if (!info) { return false; } glGenTextures(1, &m_texture); const int attrs[] = { GLX_TEXTURE_FORMAT_EXT, info->textureFormat, GLX_MIPMAP_TEXTURE_EXT, false, GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, XCB_NONE }; m_glxPixmap = glXCreatePixmap(QX11Info::display(), info->fbConfig, m_pixmap, attrs); return true; } #endif #endif void WindowThumbnail::resetDamaged() { m_damaged = false; #if HAVE_XCB_COMPOSITE if (m_damage == XCB_NONE) { return; } xcb_damage_subtract(QX11Info::connection(), m_damage, XCB_NONE, XCB_NONE); #endif } void WindowThumbnail::stopRedirecting() { if (!m_xcb || !m_composite) { return; } #if HAVE_XCB_COMPOSITE xcb_connection_t *c = QX11Info::connection(); if (m_pixmap != XCB_PIXMAP_NONE) { xcb_free_pixmap(c, m_pixmap); m_pixmap = XCB_PIXMAP_NONE; } if (m_winId == XCB_WINDOW_NONE) { return; } xcb_composite_unredirect_window(c, m_winId, XCB_COMPOSITE_REDIRECT_AUTOMATIC); if (m_damage == XCB_NONE) { return; } xcb_damage_destroy(c, m_damage); m_damage = XCB_NONE; #endif } void WindowThumbnail::startRedirecting() { if (!m_xcb || !m_composite || !window() || window()->winId() == m_winId) { return; } #if HAVE_XCB_COMPOSITE if (m_winId == XCB_WINDOW_NONE) { return; } xcb_connection_t *c = QX11Info::connection(); // need to get the window attributes for the existing event mask const auto attribsCookie = xcb_get_window_attributes_unchecked(c, m_winId); // redirect the window xcb_composite_redirect_window(c, m_winId, XCB_COMPOSITE_REDIRECT_AUTOMATIC); // generate the damage handle m_damage = xcb_generate_id(c); xcb_damage_create(c, m_damage, m_winId, XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY); QScopedPointer attr(xcb_get_window_attributes_reply(c, attribsCookie, nullptr)); uint32_t events = XCB_EVENT_MASK_STRUCTURE_NOTIFY; if (!attr.isNull()) { events = events | attr->your_event_mask; } // the event mask will not be removed again. We cannot track whether another component also needs STRUCTURE_NOTIFY (e.g. KWindowSystem). // if we would remove the event mask again, other areas will break. xcb_change_window_attributes(c, m_winId, XCB_CW_EVENT_MASK, &events); // force to update the texture m_damaged = true; #endif } void WindowThumbnail::setThumbnailAvailable(bool thumbnailAvailable) { if (m_thumbnailAvailable != thumbnailAvailable) { m_thumbnailAvailable = thumbnailAvailable; emit thumbnailAvailableChanged(); } } } // namespace diff --git a/src/declarativeimports/core/windowthumbnail.h b/src/declarativeimports/core/windowthumbnail.h index bd667af58..d63e0ffd9 100644 --- a/src/declarativeimports/core/windowthumbnail.h +++ b/src/declarativeimports/core/windowthumbnail.h @@ -1,168 +1,168 @@ /* * Copyright 2013 by Martin Gräßlin * 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 PLASMA_WINDOWTHUMBNAIL_H #define PLASMA_WINDOWTHUMBNAIL_H #include #include #include // Qt #include #include #include // xcb #if HAVE_XCB_COMPOSITE #include #if HAVE_EGL #include #include #include // egl.h could include XLib.h #endif // HAVE_EGL #endif // HAVE_XCB_COMPOSITE class KWindowInfo; namespace Plasma { class WindowTextureNode; /** * @brief Renders a thumbnail for the window specified by the @c winId property. * * This declarative item is able to render a live updating thumbnail for the * window specified by the given @c winId property. If it is not possible to get * the thumbnail, the window's icon is rendered instead or in case that the window * Id is invalid a generic fallback icon is used. * * The thumbnail does not necessarily fill out the complete geometry as the * thumbnail gets scaled keeping the aspect ratio. This means the thumbnail gets * rendered into the center of the item's geometry. * * Note: live updating thumbnails are only implemented on the X11 platform. On X11 * a running compositor is not required as this item takes care of redirecting the * window. For technical reasons the window's frame is not included on X11. * * If the window closes, the thumbnail does not get destroyed, which allows to have * a window close animation. * * Example usage: * @code * WindowThumbnail { * winId: 102760466 * } * @endcode * */ class WindowThumbnail : public QQuickItem, public QAbstractNativeEventFilter { Q_OBJECT Q_PROPERTY(uint winId READ winId WRITE setWinId NOTIFY winIdChanged) Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged) Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged) Q_PROPERTY(bool thumbnailAvailable READ thumbnailAvailable NOTIFY thumbnailAvailableChanged) public: WindowThumbnail(QQuickItem *parent = nullptr); virtual ~WindowThumbnail(); - bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) Q_DECL_OVERRIDE; - QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) Q_DECL_OVERRIDE; + bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; uint32_t winId() const; void setWinId(uint32_t winId); qreal paintedWidth() const; qreal paintedHeight() const; bool thumbnailAvailable() const; Q_SIGNALS: void winIdChanged(); void paintedSizeChanged(); void thumbnailAvailableChanged(); protected: - void releaseResources() Q_DECL_OVERRIDE; + void releaseResources() override; private: void iconToTexture(WindowTextureNode *textureNode); void windowToTexture(WindowTextureNode *textureNode); void startRedirecting(); void stopRedirecting(); void resetDamaged(); void setThumbnailAvailable(bool thumbnailAvailable); bool m_xcb; bool m_composite; uint32_t m_winId; QSizeF m_paintedSize; bool m_thumbnailAvailable; bool m_damaged; int m_depth; #if HAVE_XCB_COMPOSITE xcb_pixmap_t pixmapForWindow(); bool m_openGLFunctionsResolved; uint8_t m_damageEventBase; xcb_damage_damage_t m_damage; xcb_pixmap_t m_pixmap; /*The following must *only* be used from the render thread*/ uint m_texture; #if HAVE_GLX bool windowToTextureGLX(WindowTextureNode *textureNode); void resolveGLXFunctions(); bool loadGLXTexture(); void bindGLXTexture(); xcb_pixmap_t m_glxPixmap; xcb_visualid_t m_visualid; QFunctionPointer m_bindTexImage; QFunctionPointer m_releaseTexImage; #endif // HAVE_GLX #if HAVE_EGL bool xcbWindowToTextureEGL(WindowTextureNode *textureNode); void resolveEGLFunctions(); void bindEGLTexture(); bool m_eglFunctionsResolved; EGLImageKHR m_image; QFunctionPointer m_eglCreateImageKHR; QFunctionPointer m_eglDestroyImageKHR; QFunctionPointer m_glEGLImageTargetTexture2DOES; #endif // HAVE_EGL #endif }; /** * @brief SimpleTextureNode which cleans up the texture * */ class WindowTextureNode : public QSGSimpleTextureNode { public: WindowTextureNode(); virtual ~WindowTextureNode(); void reset(QSGTexture *texture); private: QScopedPointer m_texture; }; } #endif // PLASMA_WINDOWTHUMBNAIL_H diff --git a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h index 72ad046d0..2c46afa8c 100644 --- a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h +++ b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.h @@ -1,58 +1,58 @@ /* * Copyright 2011 by 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 PLASMACOMPONENTSPLUGIN_H #define PLASMACOMPONENTSPLUGIN_H #include #include class QQmlEngine; class QQuickItem; class PlasmaComponentsPlugin; class EngineBookKeeping : public QObject { Q_OBJECT public: EngineBookKeeping(); static EngineBookKeeping *self(); void insertEngine(QQmlEngine *engine); QQmlEngine *engine() const; private Q_SLOTS: void engineDestroyed(QObject *deleted); private: QSet m_engines; }; class PlasmaComponentsPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE; - void registerTypes(const char *uri) Q_DECL_OVERRIDE; + void initializeEngine(QQmlEngine *engine, const char *uri) override; + void registerTypes(const char *uri) override; }; #endif diff --git a/src/declarativeimports/plasmacomponents/qmenu.h b/src/declarativeimports/plasmacomponents/qmenu.h index 8a40b7751..a19768397 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.h +++ b/src/declarativeimports/plasmacomponents/qmenu.h @@ -1,197 +1,197 @@ /*************************************************************************** * Copyright 2011 Viranch Mehta * * * * 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 02110-1301 USA . * ***************************************************************************/ #ifndef QMENU_PROXY_H #define QMENU_PROXY_H #include #include #include #include "qmenuitem.h" #include "enums.h" #include "plasma.h" class QDeclarativeItem; /** * @class Menu * * An Item provides a menu for use in context specific situations. * You can specify the position for the menu to open by setting its visualParent. * MenuItems should be used to draw entries in the menu. * The open() function opens up the menu at the given visualParent. * * * Example usage: * @code * import org.kde.plasma.components 2.0 as PlasmaComponents * * [...] * PlasmaComponents.Menu { * id: menu * ... * PlasmaComponents.MenuItem { * text: "Delete" * onClicked: { * myListItem.remove(); * } * } * } * PlasmaComponents.Button { * id: btn * onClicked: { * menu.visualParent = btn * menu.open() * } * } * [...] * @endcode * */ class QMenuProxy : public QObject { Q_OBJECT Q_PROPERTY(QQmlListProperty content READ content CONSTANT) Q_CLASSINFO("DefaultProperty", "content") /** * This is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window. */ Q_PROPERTY(QWindow *transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged) /** * the visualParent is used to position the menu. it can be an item on the scene, like a button (that will open the menu on clicked) or another menuitem (in this case this will be a submenu) */ Q_PROPERTY(QObject *visualParent READ visualParent WRITE setVisualParent NOTIFY visualParentChanged()) Q_PROPERTY(DialogStatus::Status status READ status NOTIFY statusChanged) /** * The default placement for the menu. */ Q_PROPERTY(Plasma::Types::PopupPlacement placement READ placement WRITE setPlacement NOTIFY placementChanged) /** * A minimum width for the menu. */ Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) /** * A maximum width for the menu. * * @since 5.31 */ Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth RESET resetMaximumWidth NOTIFY maximumWidthChanged) public: explicit QMenuProxy(QObject *parent = nullptr); - ~QMenuProxy() Q_DECL_OVERRIDE; + ~QMenuProxy() override; QQmlListProperty content(); int actionCount() const; QMenuItem *action(int) const; DialogStatus::Status status() const; QObject *visualParent() const; void setVisualParent(QObject *parent); QWindow *transientParent(); void setTransientParent(QWindow *parent); Plasma::Types::PopupPlacement placement() const; void setPlacement(Plasma::Types::PopupPlacement placement); int minimumWidth() const; void setMinimumWidth(int width); int maximumWidth() const; void setMaximumWidth(int maximumWidth); void resetMaximumWidth(); /** * This opens the menu at position x,y on the given visualParent. By default x and y are set to 0 */ Q_INVOKABLE void open(int x = 0, int y = 0); /** * This opens the menu at the specified placement relative to the visualParent. */ Q_INVOKABLE void openRelative(); /** * This closes the menu */ Q_INVOKABLE void close(); /** * This removes all menuItems inside the menu */ Q_INVOKABLE void clearMenuItems(); /** * This adds a menu item from a String */ Q_INVOKABLE void addMenuItem(const QString &text); /** * This adds MenuItem 'item' to the menu before MenuItem 'before'. * If MenuItem 'before' is 0 or does not exist in the menu, 'item' * is appended to the menu instead. * If MenuItem 'item' already exists in the menu, it is removed and * inserted at the new position. */ Q_INVOKABLE void addMenuItem(QMenuItem *item, QMenuItem *before = nullptr); /** * This adds a section header with a string used as name for the section */ Q_INVOKABLE void addSection(const QString &text); /** * This removes MenuItem 'item' * * @since 5.27 */ Q_INVOKABLE void removeMenuItem(QMenuItem *item); protected: - bool event(QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; Q_SIGNALS: void statusChanged(); void visualParentChanged(); void transientParentChanged(); void placementChanged(); void minimumWidthChanged(); void maximumWidthChanged(); void triggered(QMenuItem *item); void triggeredIndex(int index); private Q_SLOTS: void itemTriggered(QAction *item); private: void rebuildMenu(); void openInternal(QPoint pos); QQuickItem *parentItem() const; QList m_items; QMenu *m_menu; DialogStatus::Status m_status; QWeakPointer m_visualParent; Plasma::Types::PopupPlacement m_placement; }; #endif //QMENU_PROXY_H diff --git a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h index fbd1d5655..6d1bed52f 100644 --- a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h +++ b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider_p.h @@ -1,46 +1,46 @@ /* Copyright 2011 Marco Martin This library 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 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef APPBACKGROUND_PROVIDER_H #define APPBACKGROUND_PROVIDER_H #include namespace Plasma { class Theme; } //TODO: should be possible to remove without significant breakages as is just an image provider /** * image provider for textures used for applications * @deprecated don't use it */ class AppBackgroundProvider : public QQuickImageProvider { public: AppBackgroundProvider(); - ~AppBackgroundProvider() Q_DECL_OVERRIDE; - QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) Q_DECL_OVERRIDE; + ~AppBackgroundProvider() override; + QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override; private: Plasma::Theme *m_theme; }; #endif diff --git a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.h b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.h index c4cdd50d3..e1e2ecadf 100644 --- a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.h +++ b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.h @@ -1,38 +1,38 @@ /* * Copyright 2011 by Marco Martin * Copyright 2012 by Sebastian Kügler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PLASMAEXTRACOMPONENTSPLUGIN_H #define PLASMAEXTRACOMPONENTSPLUGIN_H #include class QQmlEngine; class PlasmaExtraComponentsPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE; - void registerTypes(const char *uri) Q_DECL_OVERRIDE; + void initializeEngine(QQmlEngine *engine, const char *uri) override; + void registerTypes(const char *uri) override; }; #endif diff --git a/src/declarativeimports/platformcomponents/platformextensionplugin.cpp b/src/declarativeimports/platformcomponents/platformextensionplugin.cpp index 388480f90..1ee9d00c4 100644 --- a/src/declarativeimports/platformcomponents/platformextensionplugin.cpp +++ b/src/declarativeimports/platformcomponents/platformextensionplugin.cpp @@ -1,48 +1,48 @@ /* * Copyright (C) 2013 Ivan Cukic * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * or (at your option) any later version, as published by the Free * Software Foundation * * 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 02110-1301, USA. */ #include #include #include #include "application.h" #include "icondialog.h" class PlatformComponentsPlugin: public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.plasma.platformcomponents") public: PlatformComponentsPlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } - void registerTypes(const char *uri) Q_DECL_OVERRIDE { + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.platformcomponents")); qmlRegisterType (uri, 2, 0, "Application"); qmlRegisterType (uri, 2, 0, "IconDialog"); } }; #include "platformextensionplugin.moc" diff --git a/src/plasma/applet.h b/src/plasma/applet.h index a03eb792d..a48b68dec 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -1,726 +1,726 @@ /* * Copyright 2006-2007 by Aaron Seigo * Copyright 2007 by Riccardo Iaconelli * Copyright 2008 by Ménard Alexis * 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 PLASMA_APPLET_H #define PLASMA_APPLET_H #include #include #include #include #include #include #include #include #include class KActionCollection; class KConfigLoader; namespace Plasma { class AppletPrivate; class Containment; class DataEngine; class Package; /** * @class Applet plasma/applet.h * * @short The base Applet class * * Applet provides several important roles for add-ons widgets in Plasma. * * First, it is the base class for the plugin system and therefore is the * interface to applets for host applications. It also handles the life time * management of data engines (e.g. all data engines accessed via * Applet::dataEngine(const QString&) are properly deref'd on Applet * destruction), background painting (allowing for consistent and complex * look and feel in just one line of code for applets), loading and starting * of scripting support for each applet, providing access to the associated * plasmoid package (if any) and access to configuration data. * * See techbase.kde.org for tutorials on writing Applets using this class. */ class PLASMA_EXPORT Applet : public QObject { Q_OBJECT Q_PROPERTY(Plasma::Types::ItemStatus status READ status WRITE setStatus NOTIFY statusChanged) Q_PROPERTY(Plasma::Types::ImmutabilityType immutability READ immutability WRITE setImmutability NOTIFY immutabilityChanged) Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged) Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged) Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged FINAL) Q_PROPERTY(bool busy READ isBusy WRITE setBusy NOTIFY busyChanged FINAL) public: //CONSTRUCTORS /** * @param parent the QObject this applet is parented to * @param serviceId the name of the .desktop file containing the * information about the widget * @param appletId a unique id used to differentiate between multiple * instances of the same Applet type */ explicit Applet(QObject *parent = nullptr, const QString &serviceId = QString(), uint appletId = 0); /** * @param parent the QObject this applet is parented to * @param info the plugin information object for this Applet * @param appletId a unique id used to differentiate between multiple * instances of the same Applet type * @since 4.6 * * @deprecated prefer using KPluginMetaData */ PLASMA_DEPRECATED explicit Applet(const KPluginInfo &info, QObject *parent = nullptr, uint appletId = 0); /** * @param parent the QObject this applet is parented to * @param metadata the plugin information object for this Applet * @param appletId a unique id used to differentiate between multiple * instances of the same Applet type * @since 5.27 */ explicit Applet(const KPluginMetaData &metadata, QObject *parent = nullptr, uint appletId = 0); - ~Applet() Q_DECL_OVERRIDE; + ~Applet() override; //BOOKKEEPING /** * @return the id of this applet */ uint id() const; /** * @return The type of immutability of this applet */ Types::ImmutabilityType immutability() const; /** * If for some reason, the applet fails to get up on its feet (the * library couldn't be loaded, necessary hardware support wasn't found, * etc..) this method returns the reason why, in an user-readable way. * @since 5.0 **/ QString launchErrorMessage() const; /** * If for some reason, the applet fails to get up on its feet (the * library couldn't be loaded, necessary hardware support wasn't found, * etc..) this method returns true. **/ bool failedToLaunch() const; /** * @return true if destroy() was called; useful for Applets which should avoid * certain tasks if they are about to be deleted permanently */ bool destroyed() const; /** * @return the Containment, if any, this applet belongs to **/ Containment *containment() const; /** * @return true if this Applet is currently being used as a Containment, false otherwise */ bool isContainment() const; /** * @return the status of the applet * @since 4.4 */ Types::ItemStatus status() const; /** * Returns the current form factor the applet is being displayed in. * * @see Plasma::FormFactor */ Types::FormFactor formFactor() const; /** * Returns the location of the scene which is displaying applet. * * @see Plasma::Types::Location */ Types::Location location() const; //CONFIGURATION /** * Returns the KConfigGroup to access the applets configuration. * * This config object will write to an instance * specific config file named \\rc * in the Plasma appdata directory. **/ KConfigGroup config() const; /** * Returns a KConfigGroup object to be shared by all applets of this * type. * * This config object will write to an applet-specific config object * named plasma_\rc in the local config directory. */ KConfigGroup globalConfig() const; /** * Returns the config skeleton object from this applet's package, * if any. * * @return config skeleton object, or 0 if none **/ KConfigLoader *configScheme() const; /** * Saves state information about this applet that will * be accessed when next instantiated in the restore(KConfigGroup&) method. * * This method does not need to be reimplmented by Applet * subclasses, but can be useful for Applet specializations * (such as Containment) to do so. * * Applet subclasses may instead want to reimplement saveState(). **/ virtual void save(KConfigGroup &group) const; /** * Restores state information about this applet saved previously * in save(KConfigGroup&). * * This method does not need to be reimplmented by Applet * subclasses, but can be useful for Applet specializations * (such as Containment) to do so. **/ virtual void restore(KConfigGroup &group); /** * @return true if the applet currently needs to be configured, * otherwise, false */ bool configurationRequired() const; /** * @return A translated message for the user explaining that the * applet needs configuring; this should note what needs * to be configured * * @see setConfigurationRequired * @since 5.20 */ QString configurationRequiredReason() const; /** * @return true when the configuration interface is being shown * @since 4.5 */ bool isUserConfiguring() const; /** * Tells the applet the user is configuring * @param configuring true if the configuration ui is showing */ void setUserConfiguring(bool configuring); //UTILS #ifndef PLASMA_NO_DEPRECATED /** * Accessor for the associated Package object if any. * Generally, only Plasmoids come in a Package. * * @deprecated use kPackage() instead * @return the Package object, or an invalid one if none **/ PLASMA_DEPRECATED Package package() const; #endif /** * Accessor for the associated Package object if any. * Generally, only Plasmoids come in a Package. * * @return the Package object, or an invalid one if none * @since 5.6 **/ KPackage::Package kPackage() const; /** * Called when any of the geometry constraints have been updated. * This method calls constraintsEvent, which may be reimplemented, * once the Applet has been prepared for updating the constraints. * * @param constraints the type of constraints that were updated */ void updateConstraints(Plasma::Types::Constraints constraints = Plasma::Types::AllConstraints); //METADATA /** * @return metadata information about this plugin * @see KPluginInfo, pluginMetaData * @since 5.0 * @deprecated use pluginMetaData instead */ PLASMA_DEPRECATED KPluginInfo pluginInfo() const; /** * @return metadata information about this plugin * * @since 5.27 */ KPluginMetaData pluginMetaData() const; /** * Returns the user-visible title for the applet, as specified in the * Name field of the .desktop file. Can be changed with @see setTitle * * @since 5.0 * @return the user-visible title for the applet. **/ QString title() const; /** * Sets a custom title for this instance of the applet. E.g. a clock might * use the timezone as its name rather than the .desktop file * * @since 5.0 * @param title the user-visible title for the applet. */ void setTitle(const QString &title); /** * Attempts to load an applet from a package * * Returns a pointer to the applet if successful. * The caller takes responsibility for the applet, including * deleting it when no longer needed. * If you instance a plasmoid with this deprecated API, the * automated default setup scripts won't be executed for that plasmoid * * @param path the path to the package * @param appletId unique ID to assign the applet, or zero to have one * assigned automatically. * @return a pointer to the loaded applet, or 0 on load failure * @since 4.3 * * @deprecated use Containment::createApplet() instead, you are not * supposed to have applets without containments **/ PLASMA_DEPRECATED static Applet *loadPlasmoid(const QString &path, uint appletId = 0); /** * @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); /** * @returns true if the applet should show a busy status, for instance doing * some network operation * @since 5.21 */ bool isBusy() const; /** * Sets the Applet to have a busy status hint, for instance the applet doing * some network operation. * The graphical representation of the busy status depends completely from * the visualization. * @param busy true if the applet is busy * @since 5.21 */ void setBusy(bool busy); //ACTIONS /** * Returns a list of context-related QAction instances. * * This is used e.g. within the \a DesktopView to display a * contextmenu. * * @return A list of actions. The default implementation returns an * empty list. **/ virtual QList contextualActions(); /** * Returns the collection of actions for this Applet */ KActionCollection *actions() const; /** * Sets the global shortcut to associate with this widget. */ void setGlobalShortcut(const QKeySequence &shortcut); /** * @return the global shortcut associated with this wiget, or * an empty shortcut if no global shortcut is associated. */ QKeySequence globalShortcut() const; // ASSOCIATED APPLICATION /** * Sets an application associated to this applet, that will be * regarded as a full view of what is represented in the applet * * @param string the name of the application. it can be * \li a name understood by KService::serviceByDesktopName * (e.g. "konqueror") * \li a command in $PATH * \li or an absolute path to an executable * @since 4.4 */ void setAssociatedApplication(const QString &string); /** * Sets a list of urls associated to this application, * they will be used as parameters for the associated application * @see setAssociatedApplication() * * @param urls */ void setAssociatedApplicationUrls(const QList &urls); /** * @return the application associated to this applet * @since 4.4 */ QString associatedApplication() const; /** * @return the urls associated to this applet * @since 4.4 */ QList associatedApplicationUrls() const; /** * @return true if the applet has a valid associated application or urls * @since 4.4 */ bool hasValidAssociatedApplication() const; //Completely UI-specific, remove or move to scriptengine /** * @return true if this plasmoid provides a GUI configuration **/ bool hasConfigurationInterface() const; Q_SIGNALS: //BOOKEEPING /** * Emitted when the immutability changes * @since 4.4 */ void immutabilityChanged(Plasma::Types::ImmutabilityType immutable); /** * Emitted when the applet status changes * @since 4.4 */ void statusChanged(Plasma::Types::ItemStatus status); /** * Emitted when the applet has been scheduled for destruction * or the destruction has been undone * @since 5.4 */ void destroyedChanged(bool destroyed); /** * Emitted when the title has changed * @since 5.20 */ void titleChanged(const QString &title); /** * Emitted when the icon name for the applet has changed * @since 5.20 */ void iconChanged(const QString &icon); /** * Emitted when the busy status has changed * @since 5.21 */ void busyChanged(bool busy); //CONFIGURATION /** * Emitted when an applet has changed values in its configuration * and wishes for them to be saved at the next save point. As this implies * disk activity, this signal should be used with care. * * @note This does not need to be emitted from saveState by individual * applets. */ void configNeedsSaving(); /** * emitted when the config ui appears or disappears */ void userConfiguringChanged(bool configuring); //ACTIONS /** * Emitted just before the contextual actions are about to show * For instance just before the context menu containing the actions * added with setAction() is shown */ void contextualActionsAboutToShow(); /** * Emitted when activation is requested due to, for example, a global * keyboard shortcut. By default the wiget is given focus. */ void activated(); //TODO: fix usage in containment, port to QObject::destroyed /** * Emitted when the applet is deleted */ void appletDeleted(Plasma::Applet *applet); /** * Emitted when the formfactor changes */ void formFactorChanged(Plasma::Types::FormFactor formFactor); /** * Emitted when the location changes */ void locationChanged(Plasma::Types::Location location); /** * Emitted when setConfigurationRequired was called * @see setConfigurationRequired * @since 5.20 */ void configurationRequiredChanged(bool needsConfig, const QString &reason); public Q_SLOTS: //BOOKKEEPING /** * Call this method when the applet fails to launch properly. An * optional reason can be provided. * * Not that all children items will be deleted when this method is * called. If you have pointers to these items, you will need to * reset them after calling this method. * * @param failed true when the applet failed, false when it succeeded * @param reason an optional reason to show the user why the applet * failed to launch * @since 5.0 **/ void setLaunchErrorMessage(const QString &reason = QString()); /** * Sets the immutability type for this applet (not immutable, * user immutable or system immutable) * @param immutable the new immutability type of this applet */ void setImmutability(const Types::ImmutabilityType immutable); /** * Destroys the applet; it will be removed nicely and deleted. * Its configuration will also be deleted. * If you want to remove the Applet configuration, use this, don't just delete the Applet * */ void destroy(); /** * sets the status for this applet * @since 4.4 */ void setStatus(const Types::ItemStatus stat); //CONFIGURATION /** * Called when applet configuration values have changed. */ virtual void configChanged(); //UTILS /** * Sends all pending constraints updates to the applet. Will usually * be called automatically, but can also be called manually if needed. */ void flushPendingConstraintsEvents(); /** * This method is called once the applet is loaded and added to a Corona. * If the applet requires a Scene or has an particularly intensive * set of initialization routines to go through, consider implementing it * in this method instead of the constructor. * * Note: paintInterface may get called before init() depending on initialization * order. Painting is managed by the canvas (QGraphisScene), and may schedule a * paint event prior to init() being called. **/ virtual void init(); //ASSOCIATED APPLICATION /** * Open the application associated to this applet, if it's not set * but some urls are, open those urls with the proper application * for their mimetype * @see setAssociatedApplication() * @see setAssociatedApplicationUrls() * @since 4.4 */ void runAssociatedApplication(); protected: //CONSTRUCTORS /** * This constructor is to be used with the plugin loading systems * found in KPluginInfo and KService. The argument list is expected * to have two elements: the KService service ID for the desktop entry * and an applet ID which must be a base 10 number. * * @param parent a QObject parent; you probably want to pass in 0 * @param args a list of strings containing two entries: the service id * and the applet id */ Applet(QObject *parent, const QVariantList &args); //CONFIGURATION /** * When called, the Applet should write any information needed as part * of the Applet's running state to the configuration object in config() * and/or globalConfig(). * * Applets that always sync their settings/state with the config * objects when these settings/states change do not need to reimplement * this method. **/ virtual void saveState(KConfigGroup &config) const; /** * Sets whether or not this applet provides a user interface for * configuring the applet. * * It defaults to false, and if true is passed in you should * also reimplement createConfigurationInterface() * * @param hasInterface whether or not there is a user interface available **/ void setHasConfigurationInterface(bool hasInterface); /** * When the applet needs to be configured before being usable, this * method can be called to show a standard interface prompting the user * to configure the applet * * @param needsConfiguring true if the applet needs to be configured, * or false if it doesn't * @param reason a translated message for the user explaining that the * applet needs configuring; this should note what needs * to be configured */ void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); //UTILS /** * Called when any of the constraints for the applet have been updated. These constraints * range from notifying when the applet has officially "started up" to when geometry changes * to when the form factor changes. * * Each constraint that has been changed is passed in the constraints flag. * All of the constraints and how they work is documented in the @see Plasma::Constraints * enumeration. * * On applet creation, this is always called prior to painting and can be used as an * opportunity to layout the widget, calculate sizings, etc. * * Do not call update() from this method; an update() will be triggered * at the appropriate time for the applet. * * @param constraints the type of constraints that were updated * @property constraint */ virtual void constraintsEvent(Plasma::Types::Constraints constraints); //TODO: timerEvent should go into AppletPrivate /** * Reimplemented from QObject */ - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) override; private: /** * @internal This constructor is to be used with the Package loading system. * * @param parent a QObject parent; you probably want to pass in 0 * @param args a list of strings containing two entries: the service id * and the applet id * @since 4.3 */ Applet(const QString &packagePath, uint appletId); Q_PRIVATE_SLOT(d, void cleanUpAndDelete()) Q_PRIVATE_SLOT(d, void askDestroy()) Q_PRIVATE_SLOT(d, void updateShortcuts()) Q_PRIVATE_SLOT(d, void globalShortcutChanged()) Q_PRIVATE_SLOT(d, void propagateConfigChanged()) Q_PRIVATE_SLOT(d, void requestConfiguration()) AppletPrivate *const d; //Corona needs to access setLaunchErrorMessage and init friend class Corona; friend class CoronaPrivate; friend class Containment; friend class ContainmentPrivate; friend class AppletScript; friend class AppletPrivate; friend class AccessAppletJobPrivate; friend class GraphicsViewAppletPrivate; friend class PluginLoader; friend class AssociatedApplicationManager; }; } // Plasma namespace /** * Register an applet when it is contained in a loadable module */ #define K_EXPORT_PLASMA_APPLET(libname, classname) \ K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #define K_EXPORT_PLASMA_APPLET_WITH_JSON(libname, classname, jsonFile) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #endif // multiple inclusion guard diff --git a/src/plasma/containment.h b/src/plasma/containment.h index 792910b4d..258ef409e 100644 --- a/src/plasma/containment.h +++ b/src/plasma/containment.h @@ -1,349 +1,349 @@ /* * Copyright 2007 by Aaron Seigo * Copyright 2008 by Ménard Alexis * Copyright (c) 2009 Chani Armitage * * 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 PLASMA_CONTAINMENT_H #define PLASMA_CONTAINMENT_H #include #include namespace Plasma { class DataEngine; class Package; class Corona; class ContainmentActions; class ContainmentPrivate; /** * @class Containment plasma/containment.h * * @short The base class for plugins that provide backgrounds and applet grouping containers * * Containment objects provide the means to group applets into functional sets. * They also provide the following: * * creation of focussing event * - drawing of the background image (which can be interactive) * - form factors (e.g. panel, desktop, full screen, etc) * - applet layout management * * Since containment is actually just a Plasma::Applet, all the techniques used * for writing the visual presentation of Applets is applicable to Containtments. * Containments are differentiated from Applets by being marked with the ServiceType * of Plasma/Containment. Plugins registered with both the Applet and the Containment * ServiceTypes can be loaded for us in either situation. * * See techbase.kde.org for a tutorial on writing Containments using this class. */ class PLASMA_EXPORT Containment : public Applet { Q_OBJECT Q_PROPERTY(QString wallpaper READ wallpaper WRITE setWallpaper NOTIFY wallpaperChanged) Q_PROPERTY(bool isUiReady READ isUiReady NOTIFY uiReadyChanged) public: /** * @param parent the QObject this applet is parented to * @param serviceId the name of the .desktop file containing the * information about the widget * @param containmentId a unique id used to differentiate between multiple * instances of the same Applet type */ explicit Containment(QObject *parent = nullptr, const QString &serviceId = QString(), uint containmentId = 0); /** * This constructor is to be used with the plugin loading systems * found in KPluginInfo and KService. The argument list is expected * to have two elements: the KService service ID for the desktop entry * and an applet ID which must be a base 10 number. * * @param parent a QObject parent; you probably want to pass in 0 * @param args a list of strings containing two entries: the service id * and the applet id */ Containment(QObject *parent, const QVariantList &args); - ~Containment() Q_DECL_OVERRIDE; + ~Containment() override; /** * Reimplemented from Applet */ - void init() Q_DECL_OVERRIDE; + void init() override; /** * Returns the type of containment */ Plasma::Types::ContainmentType containmentType() const; /** * Returns the Corona (if any) that this Containment is hosted by */ Corona *corona() const; /** * Adds an applet to this Containment * * @param name the plugin name for the applet, as given by * KPluginInfo::pluginName() * @param args argument list to pass to the plasmoid * @param geometry where to place the applet, or to auto-place it if an invalid * is provided * * @return a pointer to the applet on success, or 0 on failure */ Applet *createApplet(const QString &name, const QVariantList &args = QVariantList()); /** * Add an existing applet to this Containment * * @param applet the applet that should be added * @param pos the containment-relative position */ void addApplet(Applet *applet); /** * @return the applets currently in this Containment */ QList applets() const; /** * @return the screen number this containment is serving as the desktop for * or -1 if none */ int screen() const; /** * @return the last screen number this containment had * only returns -1 if it's never ever been on a screen * @since 4.5 */ int lastScreen() const; /** * @reimp * @sa Applet::save(KConfigGroup &) */ - void save(KConfigGroup &group) const Q_DECL_OVERRIDE; + void save(KConfigGroup &group) const override; /** * @reimp * @sa Applet::restore(KConfigGroup &) */ - void restore(KConfigGroup &group) Q_DECL_OVERRIDE; + void restore(KConfigGroup &group) override; /** * Sets wallpaper plugin. * * @param pluginName the name of the wallpaper to attempt to load */ void setWallpaper(const QString &pluginName); /** * Return wallpaper plugin. */ QString wallpaper() const; /** * Sets the current activity by id * * @param activity the id of the activity */ void setActivity(const QString &activityId); /** * @return the current activity id associated with this containment */ QString activity() const; /** * Sets a containmentactions plugin. * * @param trigger the mouse button (and optional modifier) to associate the plugin with * @param pluginName the name of the plugin to attempt to load. blank = set no plugin. * @since 4.4 */ void setContainmentActions(const QString &trigger, const QString &pluginName); /** * @return All the loaded containment action plugins, indexed by trigger name * @since 5.0 */ QHash &containmentActions(); /** * @returns true when the ui of this containment is fully loaded, as well the ui of every applet in it */ bool isUiReady() const; Q_SIGNALS: /** * This signal is emitted when a new applet is added in the containment * It may happen in the following situations: * * The user created the applet * * The applet was moved in from another containment * * The applet got restored at startup */ void appletAdded(Plasma::Applet *applet); /** * This signal is emitted when an applet is destroyed */ void appletRemoved(Plasma::Applet *applet); /** * This signal is emitted when a new applet is created by the containment. * Compared to appletAdded, this gets emitted only when the user explicitly * creates a new applet, either via the widget explorer or the scripting * environment. * @see appletAdded * @since 5.16 */ void appletCreated(Plasma::Applet *applet); /** * Emitted when the activity id has changed */ void activityChanged(const QString &activity); /** * Emitted when the containment requests an add widgets dialog is shown. * Usually only used for desktop containments. * * @param pos where in the containment this request was made from, or * an invalid position (QPointF()) is not location specific */ void showAddWidgetsInterface(const QPointF &pos); /** * This signal indicates that a containment has been * associated (or dissociated) with a physical screen. * * @param newScreen the screen it is now associated with */ void screenChanged(int newScreen); /** * Emitted when the user wants to configure/change the containment, or an applet inside it. */ void configureRequested(Plasma::Applet *applet); /** * Emitted when the user wants to chose an alternative for this applet or containment. */ void appletAlternativesRequested(Plasma::Applet *applet); /** * Emitted when the wallpaper plugin is changed */ void wallpaperChanged(); /** * Emitted when the location has changed * @since 5.0 */ void locationChanged(Plasma::Types::Location location); /** * Emitted when the formFactor has changed * @since 5.0 */ void formFactorChanged(Plasma::Types::FormFactor formFactor); /** * Emitted when the ui has been fully loaded and is fully working * @param uiReady true when the ui of the containment is ready, as well the ui of each applet in it */ void uiReadyChanged(bool uiReady); /** * emitted when the containment type changed */ void containmentTypeChanged(); public Q_SLOTS: /** * Informs the Corona as to what position it is in. This is informational * only, as the Corona doesn't change its actual location. This is, * however, passed on to Applets that may be managed by this Corona. * * @param location the new location of this Corona */ void setLocation(Plasma::Types::Location location); /** * Sets the form factor for this Containment. This may cause changes in both * the arrangement of Applets as well as the display choices of individual * Applets. */ void setFormFactor(Plasma::Types::FormFactor formFactor); /** * Sets the type of this containment. */ void setContainmentType(Plasma::Types::ContainmentType type); void reactToScreenChange(); protected: /** * Called when the contents of the containment should be saved. By default this saves * all loaded Applets * * @param group the KConfigGroup to save settings under */ virtual void saveContents(KConfigGroup &group) const; /** * Called when the contents of the containment should be loaded. By default this loads * all previously saved Applets * * @param group the KConfigGroup to save settings under */ virtual void restoreContents(KConfigGroup &group); private: /** * @internal This constructor is to be used with the Package loading system. * * @param parent a QObject parent; you probably want to pass in 0 * @since 4.3 */ Containment(const KPluginMetaData &md, uint appletId); Q_PRIVATE_SLOT(d, void appletDeleted(Plasma::Applet *)) Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) Q_PRIVATE_SLOT(d, void checkStatus(Plasma::Types::ItemStatus)) friend class Applet; friend class AppletPrivate; friend class CoronaPrivate; friend class ContainmentPrivate; friend class ContainmentActions; ContainmentPrivate *const d; }; } // Plasma namespace #endif // multiple inclusion guard diff --git a/src/plasma/datacontainer.h b/src/plasma/datacontainer.h index e8a54a8fd..3d680584f 100644 --- a/src/plasma/datacontainer.h +++ b/src/plasma/datacontainer.h @@ -1,293 +1,293 @@ /* * Copyright 2006-2007 Aaron Seigo * * 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 PLASMA_DATACONTAINER_H #define PLASMA_DATACONTAINER_H #include #include #include #include #include #include class QAbstractItemModel; namespace Plasma { class DataContainerPrivate; /** * @class DataContainer plasma/datacontainer.h * * @brief A set of data exported via a DataEngine * * Plasma::DataContainer wraps the data exported by a DataEngine * implementation, providing a generic wrapper for the data. * * A DataContainer may have zero or more associated pieces of data which * are keyed by strings. The data itself is stored as QVariants. This allows * easy and flexible retrieval of the information associated with this object * without writing DataContainer or DataEngine specific code in visualizations. * * If you are creating your own DataContainer objects (and are passing them to * DataEngine::addSource()), you normally just need to listen to the * updateRequested() signal (as well as any other methods you might have of * being notified of new data) and call setData() to actually update the data. * Then you need to either trigger the scheduleSourcesUpdated signal of the * parent DataEngine or call checkForUpdate() on the DataContainer. * * You also need to set a suitable name for the source with setObjectName(). * See DataEngine::addSource() for more information. * * Note that there is normally no need to subclass DataContainer, except as * a way of encapsulating the data retrieval for a source, since all notifications * are done via signals rather than virtual methods. **/ class PLASMA_EXPORT DataContainer : public QObject { friend class DataEngine; friend class DataEnginePrivate; Q_OBJECT public: /** * Constructs a default DataContainer that has no name or data * associated with it **/ explicit DataContainer(QObject *parent = nullptr); - ~DataContainer() Q_DECL_OVERRIDE; + ~DataContainer() override; /** * Returns the data for this DataContainer **/ const DataEngine::Data data() const; /** * Set a value for a key. * * This also marks this source as needing to signal an update. * * If you call setData() directly on a DataContainer, you need to * either trigger the scheduleSourcesUpdated() slot for the * data engine it belongs to or call checkForUpdate() on the * DataContainer. * * @param key a string used as the key for the data * @param value a QVariant holding the actual data. If a invalid * QVariant is passed in and the key currently exists in the * data, then the data entry is removed **/ void setData(const QString &key, const QVariant &value); /** * Removes all data currently associated with this source * * If you call removeAllData() on a DataContainer, you need to * either trigger the scheduleSourcesUpdated() slot for the * data engine it belongs to or call checkForUpdate() on the * DataContainer. **/ void removeAllData(); /** * Associates a model with this DataContainer. Use this for data * that is intended to be a long list of items. * * The ownership of the model is transferred to the DataContainer, * so the model will be deletd when a new one is set or when the * DataContainer itself is deleted, so it will be deleted when there won't be any * visualization associated to this source. * * Normally you should set the model from DataEngine::setModel instead from here. * * @param model the model that will be associated with this DataContainer */ void setModel(QAbstractItemModel *model); /** * @return the model owned by this DataSource */ QAbstractItemModel *model(); /** * @return true if the visualization is currently connected */ bool visualizationIsConnected(QObject *visualization) const; /** * Connects an object to this DataContainer. * * May be called repeatedly for the same visualization without * side effects * * @param visualization the object to connect to this DataContainer * @param pollingInterval the time in milliseconds between updates * @param alignment the clock position to align updates to **/ void connectVisualization(QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment alignment); /** * sets this data container to be automatically stored. * @param whether this data container should be stored * @since 4.6 */ void setStorageEnabled(bool store); /** * @return true if the data container has been marked for storage * @since 4.6 */ bool isStorageEnabled() const; /** * @return true if the data container has been updated, but not stored */ bool needsToBeStored() const; /** * sets that the data container needs to be stored or not. * @param whether the data container needs to be stored */ void setNeedsToBeStored(bool store); /** * @return the DataEngine that the DataContainer is * a child of. */ DataEngine *getDataEngine(); /** * @return true if one or more visualizations is connected to this DataContainer */ bool isUsed() const; public Q_SLOTS: /** * Disconnects an object from this DataContainer. * * Note that if this source was created by DataEngine::sourceRequestEvent(), * it will be deleted by DataEngine once control returns to the event loop. **/ void disconnectVisualization(QObject *visualization); /** * Forces immediate update signals to all visualizations * @since 4.4 */ void forceImmediateUpdate(); Q_SIGNALS: /** * Emitted when the data has been updated, allowing visualizations to * reflect the new data. * * Note that you should not normally emit this directly. Instead, use * checkForUpdate() or the DataEngine::scheduleSourcesUpdated() slot. * * @param source the objectName() of the DataContainer (and hence the name * of the source) that updated its data * @param data the updated data **/ void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data); /** * A new model has been associated to this source, * visualizations can safely use it as long they are connected to this source. * * @param source the objectName() of the DataContainer (and hence the name * of the source) that owns the model * @param model the QAbstractItemModel instance */ void modelChanged(const QString &source, QAbstractItemModel *model); /** * Emitted when the last visualization is disconnected. * * Note that if this source was created by DataEngine::sourceRequestEvent(), * it will be deleted by DataEngine once control returns to the event loop * after this signal is emitted. * * @param source the name of the source that became unused **/ void becameUnused(const QString &source); /** * Emitted when an update is requested. * * If a polling interval was passed connectVisualization(), this signal * will be emitted every time the interval expires. * * Note that if you create your own DataContainer (and pass it to * DataEngine::addSource()), you will need to listen to this signal * and refresh the data when it is triggered. * * @param source the datacontainer the update was requested for. Useful * for classes that update the data for several containers. **/ void updateRequested(DataContainer *source); protected: /** * Checks whether any data has changed and, if so, emits dataUpdated(). **/ void checkForUpdate(); /** * Returns how long ago, in msecs, that the data in this container was last updated. * * This is used by DataEngine to compress updates that happen more quickly than the * minimum polling interval by calling setNeedsUpdate() instead of calling * updateSourceEvent() immediately. **/ uint timeSinceLastUpdate() const; /** * Indicates that the data should be treated as dirty the next time hasUpdates() is called. * * This is needed for the case where updateRequested() is triggered but we don't want to * update the data immediately because it has just been updated. The second request won't * be fulfilled in this case, because we never updated the data and so never called * checkForUpdate(). So we claim it needs an update anyway. **/ void setNeedsUpdate(bool update = true); protected Q_SLOTS: /** * @reimp from QObject */ - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) override; private: friend class SignalRelay; friend class DataContainerPrivate; friend class DataEngineManager; DataContainerPrivate *const d; Q_PRIVATE_SLOT(d, void storeJobFinished(KJob *job)) Q_PRIVATE_SLOT(d, void populateFromStoredData(KJob *job)) Q_PRIVATE_SLOT(d, void retrieve()) }; } // Plasma namespace #endif // multiple inclusion guard diff --git a/src/plasma/dataengine.h b/src/plasma/dataengine.h index 932a47202..497779ecb 100644 --- a/src/plasma/dataengine.h +++ b/src/plasma/dataengine.h @@ -1,465 +1,465 @@ /* * Copyright 2006-2007 Aaron Seigo * * 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 PLASMA_DATAENGINE_H #define PLASMA_DATAENGINE_H #include #include #include #include #include #include #include #include class QAbstractItemModel; namespace Plasma { class DataContainer; class DataEngineScript; class Package; class Service; class DataEnginePrivate; /** * @class DataEngine plasma/dataengine.h * * @short Data provider for plasmoids (Plasma plugins) * * This is the base class for DataEngines, which provide access to bodies of * data via a common and consistent interface. The common use of a DataEngine * is to provide data to a widget for display. This allows a user interface * element to show all sorts of data: as long as there is a DataEngine, the * data is retrievable. * * DataEngines are loaded as plugins on demand and provide zero, one or more * data sources which are identified by name. For instance, a network * DataEngine might provide a data source for each network interface. **/ class PLASMA_EXPORT DataEngine : public QObject { Q_OBJECT public: typedef QHash Dict; typedef QMap Data; typedef QMapIterator DataIterator; typedef QHash SourceDict; /** * Constructor. * * @param parent The parent object. * @param plugin plugin info that describes the engine **/ explicit DataEngine(const KPluginInfo &plugin, QObject *parent = nullptr); explicit DataEngine(QObject *parent = nullptr, const QVariantList &args = QVariantList()); - ~DataEngine() Q_DECL_OVERRIDE; + ~DataEngine() override; /** * @return a list of all the data sources available via this DataEngine * Whether these sources are currently available (which is what * the default implementation provides) or not is up to the * DataEngine to decide. **/ virtual QStringList sources() const; /** * @param source the source to target the Service at * @return a Service that has the source as a destination. The service * is parented to the DataEngine, but should be deleted by the * caller when finished with it */ Q_INVOKABLE virtual Service *serviceForSource(const QString &source); /** * @return description of the plugin that implements this DataEngine */ KPluginInfo pluginInfo() const; /** * Connects a source to an object for data updates. The object must * have a slot with the following signature: * @code * void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); * @endcode * * The data is a QHash of QVariants keyed by QString names, allowing * one data source to provide sets of related data. * * @param source the name of the data source * @param visualization the object to connect the data source to * @param pollingInterval the frequency, in milliseconds, with which to check for updates; * a value of 0 (the default) means to update only * when there is new data spontaneously generated * (e.g. by the engine); any other value results in * periodic updates from this source. This value is * per-visualization and can be handy for items that require * constant updates such as scrolling graphs or clocks. * If the data has not changed, no update will be sent. * @param intervalAlignment the number of ms to align the interval to **/ Q_INVOKABLE void connectSource( const QString &source, QObject *visualization, uint pollingInterval = 0, Plasma::Types::IntervalAlignment intervalAlignment = Types::NoAlignment) const; /** * Connects all currently existing sources to an object for data updates. * The object must have a slot with the following signature: * @code * void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); * @endcode * * The data is a QHash of QVariants keyed by QString names, allowing * one data source to provide sets of related data. * * This method may be called multiple times for the same visualization * without side-effects. This can be useful to change the pollingInterval. * * Note that this method does not automatically connect sources that * may appear later on. Connecting and responding to the sourceAdded signal * is still required to achieve that. * * @param visualization the object to connect the data source to * @param pollingInterval the frequency, in milliseconds, with which to check for updates; * a value of 0 (the default) means to update only * when there is new data spontaneously generated * (e.g. by the engine); any other value results in * periodic updates from this source. This value is * per-visualization and can be handy for items that require * constant updates such as scrolling graphs or clocks. * If the data has not changed, no update will be sent. * @param intervalAlignment the number of ms to align the interval to **/ Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0, Plasma::Types::IntervalAlignment intervalAlignment = Types::NoAlignment) const; /** * Disconnects a source from an object that was receiving data updates. * * @param source the name of the data source * @param visualization the object to connect the data source to **/ Q_INVOKABLE void disconnectSource(const QString &source, QObject *visualization) const; /** * Retrieves a pointer to the DataContainer for a given source. This method * should not be used if possible. An exception is for script engines that * can not provide a QMetaObject as required by connectSource for the initial * call to dataUpdated. Using this method, such engines can provide their own * connectSource API. * * @param source the name of the source. * @return pointer to a DataContainer, or zero on failure **/ Q_INVOKABLE DataContainer *containerForSource(const QString &source); /** * @return The model associated to a source if any. The ownership of the model stays with the DataContainer. * Returns 0 if there isn't any model associated or if the source doesn't exists. */ QAbstractItemModel *modelForSource(const QString &source); /** * Returns true if this engine is valid, otherwise returns false * * @return true if the engine is valid **/ bool isValid() const; /** * Returns true if the data engine is empty, which is to say that it has no * data sources currently. * * @return true if the engine has no sources currently */ bool isEmpty() const; /** * @return the name of the icon for this data engine; and empty string * is returned if there is no associated icon. **/ QString icon() const; /** * Accessor for the associated Package object if any. * * @return the Package object, or 0 if none **/ Package package() const; Q_SIGNALS: /** * Emitted when a new data source is created * * Note that you do not need to emit this yourself unless * you are reimplementing sources() and want to advertise * that a new source is available (but hasn't been created * yet). * * @param source the name of the new data source **/ void sourceAdded(const QString &source); /** * Emitted when a data source is removed. * * Note that you do not need to emit this yourself unless * you have reimplemented sources() and want to signal that * a source that was available but was never created is no * longer available. * * @param source the name of the data source that was removed **/ void sourceRemoved(const QString &source); protected: /** * When a source that does not currently exist is requested by the * consumer, this method is called to give the DataEngine the * opportunity to create one. * * The name of the data source (e.g. the source parameter passed into * setData) must be the same as the name passed to sourceRequestEvent * otherwise the requesting visualization may not receive notice of a * data update. * * If the source can not be populated with data immediately (e.g. due to * an asynchronous data acquisition method such as an HTTP request) * the source must still be created, even if it is empty. This can * be accomplished in these cases with the follow line: * * setData(name, DataEngine::Data()); * * @param source the name of the source that has been requested * @return true if a DataContainer was set up, false otherwise */ virtual bool sourceRequestEvent(const QString &source); /** * Called by internal updating mechanisms to trigger the engine * to refresh the data contained in a given source. Reimplement this * method when using facilities such as setPollingInterval. * @see setPollingInterval * * @param source the name of the source that should be updated * @return true if the data was changed, or false if there was no * change or if the change will occur later **/ virtual bool updateSourceEvent(const QString &source); /** * Sets a value for a data source. If the source * doesn't exist then it is created. * * @param source the name of the data source * @param value the data to associated with the source **/ void setData(const QString &source, const QVariant &value); /** * Sets a value for a data source. If the source * doesn't exist then it is created. * * @param source the name of the data source * @param key the key to use for the data * @param value the data to associated with the source **/ void setData(const QString &source, const QString &key, const QVariant &value); /** * Adds a set of data to a data source. If the source * doesn't exist then it is created. * * @param source the name of the data source * @param data the data to add to the source **/ void setData(const QString &source, const QVariantMap &data); /** * Removes all the data associated with a data source. * * @param source the name of the data source **/ void removeAllData(const QString &source); /** * Removes a data entry from a source * * @param source the name of the data source * @param key the data entry to remove **/ void removeData(const QString &source, const QString &key); /** * Associates a model to a data source. If the source * doesn't exist then it is created. The source will have the key "HasModel" to easily indicate there is a model present. * * The ownership of the model is transferred to the DataContainer, * so the model will be deletd when a new one is set or when the * DataContainer itself is deleted. As the DataContainer, it will be * deleted when there won't be any * visualization associated to this source. * * @param source the name of the data source * @param model the model instance */ void setModel(const QString &source, QAbstractItemModel *model); /** * Adds an already constructed data source. The DataEngine takes * ownership of the DataContainer object. The objectName of the source * is used for the source name. * * @param source the DataContainer to add to the DataEngine **/ void addSource(DataContainer *source); /** * Sets the minimum amount of time, in milliseconds, that must pass between * successive updates of data. This can help prevent too many updates happening * due to multiple update requests coming in, which can be useful for * expensive (time- or resource-wise) update mechanisms. * * The default minimumPollingInterval is -1, or "never perform automatic updates" * * @param minimumMs the minimum time lapse, in milliseconds, between updates. * A value less than 0 means to never perform automatic updates, * a value of 0 means update immediately on every update request, * a value >0 will result in a minimum time lapse being enforced. **/ void setMinimumPollingInterval(int minimumMs); /** * @return the minimum time between updates. @see setMinimumPollingInterval **/ int minimumPollingInterval() const; /** * Sets up an internal update tick for all data sources. On every update, * updateSourceEvent will be called for each applicable source. * @see updateSourceEvent * * @param frequency the time, in milliseconds, between updates. A value of 0 * will stop internally triggered updates. **/ void setPollingInterval(uint frequency); /** * Removes all data sources **/ void removeAllSources(); /** * Sets whether or not this engine is valid, e.g. can be used. * In practice, only the internal fall-back engine, the NullEngine * should have need for this. * * @param valid whether or not the engine is valid **/ void setValid(bool valid); /** * @return the list of active DataContainers. */ QHash containerDict() const; /** * Reimplemented from QObject **/ - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) override; /** * Sets the icon for this data engine **/ void setIcon(const QString &icon); /** * Sets a source to be stored for easy retrieval * when the real source of the data (usually a network connection) * is unavailable. * @param source the name of the source * @param store if source should be stored * @since 4.6 */ void setStorageEnabled(const QString &source, bool store); protected Q_SLOTS: /** * Removes a data source. * @param source the name of the data source to remove **/ void removeSource(const QString &source); /** * Immediately updates all existing sources when called */ void updateAllSources(); /** * Forces an immediate update to all connected sources, even those with * timeouts that haven't yet expired. This should _only_ be used when * there was no data available, e.g. due to network non-availability, * and then it becomes available. Normal changes in data values due to * calls to updateSource or in the natural progression of the monitored * object (e.g. CPU heat) should not result in a call to this method! * * @since 4.4 */ void forceImmediateUpdateOfAllVisualizations(); private: friend class DataEnginePrivate; friend class DataEngineScript; friend class DataEngineManager; friend class PlasmoidServiceJob; friend class NullEngine; Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source)) Q_PRIVATE_SLOT(d, void sourceDestroyed(QObject *object)) Q_PRIVATE_SLOT(d, void scheduleSourcesUpdated()) DataEnginePrivate *const d; }; } // Plasma namespace /** * Register a data engine when it is contained in a loadable module */ #define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \ K_PLUGIN_FACTORY(factory, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) #define K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(libname, classname, jsonFile) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) Q_DECLARE_METATYPE(Plasma::DataEngine *) #endif // multiple inclusion guard diff --git a/src/plasma/framesvg.h b/src/plasma/framesvg.h index 562edd95b..778b6cf33 100644 --- a/src/plasma/framesvg.h +++ b/src/plasma/framesvg.h @@ -1,323 +1,323 @@ /* * Copyright 2008 by Aaron Seigo * Copyright 2008 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 PLASMA_FRAMESVG_H #define PLASMA_FRAMESVG_H #include #include #include #include #include class QPainter; class QPoint; class QPointF; class QRect; class QRectF; class QSize; class QSizeF; class QMatrix; namespace Plasma { class FrameSvgPrivate; /** * @class FrameSvg plasma/framesvg.h * * @short Provides an SVG with borders. * * When using SVG images for a background of an object that may change * its aspect ratio, such as a dialog, simply scaling a single image * may not be enough. * * FrameSvg allows SVGs to provide several elements for borders as well * as a central element, each of which are scaled individually. These * elements should be named * * - @c center - the central element, which will be scaled in both directions * - @c top - the top border; the height is fixed, but it will be scaled * horizontally to the same width as @c center * - @c bottom - the bottom border; scaled in the same way as @c top * - @c left - the left border; the width is fixed, but it will be scaled * vertically to the same height as @c center * - @c right - the right border; scaled in the same way as @c left * - @c topleft - fixed size; must be the same height as @c top and the same * width as @c left * - @c bottomleft, @c topright, @c bottomright - similar to @c topleft * * @c center must exist, but all the others are optional. @c topleft and * @c topright will be ignored if @c top does not exist, and similarly for * @c bottomleft and @c bottomright. * * @see Plasma::Svg **/ class PLASMA_EXPORT FrameSvg : public Svg { Q_OBJECT Q_PROPERTY(EnabledBorders enabledBorders READ enabledBorders WRITE setEnabledBorders) public: /** * These flags represents what borders should be drawn */ enum EnabledBorder { NoBorder = 0, TopBorder = 1, BottomBorder = 2, LeftBorder = 4, RightBorder = 8, AllBorders = TopBorder | BottomBorder | LeftBorder | RightBorder }; Q_DECLARE_FLAGS(EnabledBorders, EnabledBorder) Q_FLAG(EnabledBorders) /** * Constructs a new FrameSvg that paints the proper named subelements * as borders. It may also be used as a regular Plasma::Svg object * for direct access to elements in the Svg. * * @param parent options QObject to parent this to * * @related Plasma::Theme */ explicit FrameSvg(QObject *parent = nullptr); - ~FrameSvg() Q_DECL_OVERRIDE; + ~FrameSvg() override; /** * Loads a new Svg * @param imagePath the new file */ - Q_INVOKABLE void setImagePath(const QString &path) Q_DECL_OVERRIDE; + Q_INVOKABLE void setImagePath(const QString &path) override; /** * Sets what borders should be painted * @param flags borders we want to paint */ void setEnabledBorders(const EnabledBorders borders); /** * Convenience method to get the enabled borders * @return what borders are painted */ EnabledBorders enabledBorders() const; /** * Resize the frame maintaining the same border size * @param size the new size of the frame */ Q_INVOKABLE void resizeFrame(const QSizeF &size); /** * @returns the size of the frame */ Q_INVOKABLE QSizeF frameSize() const; /** * Returns the margin size given the margin edge we want * If the given margin is disabled, it will return 0. * If you don't care about the margin being on or off, use fixedMarginSize() * @param edge the margin edge we want, top, bottom, left or right * @return the margin size */ Q_INVOKABLE qreal marginSize(const Plasma::Types::MarginEdge edge) const; /** * Convenience method that extracts the size of the four margins * in the four output parameters * The disabled margins will be 0. * If you don't care about the margins being on or off, use getFixedMargins() * @param left left margin size * @param top top margin size * @param right right margin size * @param bottom bottom margin size */ Q_INVOKABLE void getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; /** * Returns the margin size given the margin edge we want. * Compared to marginSize(), this doesn't depend whether the margin is enabled or not * @param edge the margin edge we want, top, bottom, left or right * @return the margin size */ Q_INVOKABLE qreal fixedMarginSize(const Plasma::Types::MarginEdge edge) const; /** * Convenience method that extracts the size of the four margins * in the four output parameters * Compared to getMargins(), this doesn't depend whether the margins are enabled or not * @param left left margin size * @param top top margin size * @param right right margin size * @param bottom bottom margin size */ Q_INVOKABLE void getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; /** * @return the rectangle of the center element, taking the margins into account. */ Q_INVOKABLE QRectF contentsRect() const; /** * Sets the prefix (@see setElementPrefix) to 'north', 'south', 'west' and 'east' * when the location is TopEdge, BottomEdge, LeftEdge and RightEdge, * respectively. Clears the prefix in other cases. * * The prefix must exist in the SVG document, which means that this can only be * called successfully after setImagePath is called. * @param location location in the UI this frame will be drawn */ Q_INVOKABLE void setElementPrefix(Plasma::Types::Location location); /** * Sets the prefix for the SVG elements to be used for painting. For example, * if prefix is 'active', then instead of using the 'top' element of the SVG * file to paint the top border, 'active-top' element will be used. The same * goes for other SVG elements. * * If the elements with prefixes are not present, the default ones are used. * (for the sake of speed, the test is present only for the 'center' element) * * Setting the prefix manually resets the location to Floating. * * The prefix must exist in the SVG document, which means that this can only be * called successfully after setImagePath is called. * * @param prefix prefix for the SVG elements that make up the frame */ Q_INVOKABLE void setElementPrefix(const QString &prefix); /** * @return true if the svg has the necessary elements with the given prefix * to draw a frame * @param prefix the given prefix we want to check if drawable */ Q_INVOKABLE bool hasElementPrefix(const QString &prefix) const; /** * This is an overloaded method provided for convenience equivalent to * hasElementPrefix("north"), hasElementPrefix("south") * hasElementPrefix("west") and hasElementPrefix("east") * @return true if the svg has the necessary elements with the given prefix * to draw a frame. * @param location the given prefix we want to check if drawable */ Q_INVOKABLE bool hasElementPrefix(Plasma::Types::Location location) const; /** * Returns the prefix for SVG elements of the FrameSvg * @return the prefix */ Q_INVOKABLE QString prefix(); /** * Returns a mask that tightly contains the fully opaque areas of the svg * @return a region of opaque areas */ Q_INVOKABLE QRegion mask() const; /** * @return a pixmap whose alpha channel is the opacity of the frame. It may be the frame itself or a special frame with the mask- prefix */ QPixmap alphaMask() const; /** * Sets whether saving all the rendered prefixes in a cache or not * @param cache if use the cache or not */ Q_INVOKABLE void setCacheAllRenderedFrames(bool cache); /** * @return if all the different prefixes should be kept in a cache when rendered */ Q_INVOKABLE bool cacheAllRenderedFrames() const; /** * Deletes the internal cache freeing memory: use this if you want to switch the rendered * element and you don't plan to switch back to the previous one for a long time and you * used setUsingRenderingCache(true) */ Q_INVOKABLE void clearCache(); /** * Returns a pixmap of the SVG represented by this object. * * @param elelementId the ID string of the element to render, or an empty * string for the whole SVG (the default) * @return a QPixmap of the rendered SVG */ Q_INVOKABLE QPixmap framePixmap(); /** * Paints the loaded SVG with the elements that represents the border * @param painter the QPainter to use * @param target the target rectangle on the paint device * @param source the portion rectangle of the source image */ Q_INVOKABLE void paintFrame(QPainter *painter, const QRectF &target, const QRectF &source = QRectF()); /** * Paints the loaded SVG with the elements that represents the border * This is an overloaded member provided for convenience * @param painter the QPainter to use * @param pos where to paint the svg */ Q_INVOKABLE void paintFrame(QPainter *painter, const QPointF &pos = QPointF(0, 0)); /** * @returns the prefix that is actually used */ QString actualPrefix() const; /** * @returns true if we are in a transaction of many changes at once * and we don't want to rebuild the generated graphics for each change yet * @since 5.31 */ bool isRepaintBlocked() const; /** * If we will do several changes at once in the frame properties, * such as prefix, enabled borders and size, in order to not regenerate * the graphics for each change, set this property to true, and set * it to false again after applying all the changes needed. * Note that any change will not be visible in the painted frame while this property is set to true. * @since 5.31 */ void setRepaintBlocked(bool blocked); private: FrameSvgPrivate *const d; friend class FrameData; //Q_PRIVATE_SLOT(d, void updateSizes()) }; } // Plasma namespace Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::FrameSvg::EnabledBorders) #endif // multiple inclusion guard diff --git a/src/plasma/packagestructure/containmentactionspackage.cpp b/src/plasma/packagestructure/containmentactionspackage.cpp index 3258d6958..ebb34261a 100644 --- a/src/plasma/packagestructure/containmentactionspackage.cpp +++ b/src/plasma/packagestructure/containmentactionspackage.cpp @@ -1,43 +1,43 @@ /****************************************************************************** * Copyright 2007-2009 by Aaron Seigo * * * * This library 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 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *******************************************************************************/ #include "plasma.h" #include #include #include "packages_p.h" #include "config-plasma.h" class ContainmentActionsPackage : public Plasma::ChangeableMainScriptPackage { Q_OBJECT public: ContainmentActionsPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {} - void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE + void initPackage(KPackage::Package *package) override { ChangeableMainScriptPackage::initPackage(package); package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/containmentactions/")); } }; K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(ContainmentActionsPackage, "containmentactions-packagestructure.json") #include "containmentactionspackage.moc" diff --git a/src/plasma/packagestructure/dataenginepackage.cpp b/src/plasma/packagestructure/dataenginepackage.cpp index ebde02974..79a42bb9b 100644 --- a/src/plasma/packagestructure/dataenginepackage.cpp +++ b/src/plasma/packagestructure/dataenginepackage.cpp @@ -1,56 +1,56 @@ /****************************************************************************** * Copyright 2007-2009 by Aaron Seigo * * * * This library 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 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *******************************************************************************/ #include "plasma.h" #include #include #include #include "packages_p.h" #include "config-plasma.h" class DataEnginePackage : public Plasma::ChangeableMainScriptPackage { Q_OBJECT public: DataEnginePackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {} - void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE + void initPackage(KPackage::Package *package) override { ChangeableMainScriptPackage::initPackage(package); package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/dataengines/")); package->addDirectoryDefinition("data", QStringLiteral("data"), i18n("Data Files")); package->addDirectoryDefinition("scripts", QStringLiteral("code"), i18n("Executable Scripts")); QStringList mimetypes; mimetypes << QStringLiteral("text/plain"); package->setMimeTypes("scripts", mimetypes); package->addDirectoryDefinition("services", QStringLiteral("services/"), i18n("Service Descriptions")); package->setMimeTypes("services", mimetypes); package->addDirectoryDefinition("translations", QStringLiteral("locale"), i18n("Translations")); } }; K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(DataEnginePackage, "dataengine-packagestructure.json") #include "dataenginepackage.moc" diff --git a/src/plasma/packagestructure/packages_p.h b/src/plasma/packagestructure/packages_p.h index 53ed9a44f..ec2e939fb 100644 --- a/src/plasma/packagestructure/packages_p.h +++ b/src/plasma/packagestructure/packages_p.h @@ -1,54 +1,54 @@ /****************************************************************************** * Copyright 2007 by Aaron Seigo * * * * This library 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 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *******************************************************************************/ #ifndef LIBS_PLASMA_PACKAGES_P_H #define LIBS_PLASMA_PACKAGES_P_H #include "plasma.h" #include #include namespace Plasma { class ChangeableMainScriptPackage : public KPackage::PackageStructure { Q_OBJECT public: ChangeableMainScriptPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : KPackage::PackageStructure(parent, args) {} - void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE; - void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE; + void initPackage(KPackage::Package *package) override; + void pathChanged(KPackage::Package *package) override; protected: virtual QString mainScriptConfigKey() const; }; class GenericPackage : public ChangeableMainScriptPackage { Q_OBJECT public: GenericPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : ChangeableMainScriptPackage(parent, args) {} - void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE; + void initPackage(KPackage::Package *package) override; }; } // namespace Plasma #endif // LIBS_PLASMA_PACKAGES_P_H diff --git a/src/plasma/packagestructure/plasmathemepackage.cpp b/src/plasma/packagestructure/plasmathemepackage.cpp index 2321150f4..c375d4b45 100644 --- a/src/plasma/packagestructure/plasmathemepackage.cpp +++ b/src/plasma/packagestructure/plasmathemepackage.cpp @@ -1,105 +1,105 @@ /****************************************************************************** * Copyright 2007-2009 by Aaron Seigo * * * * This library 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 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *******************************************************************************/ #include "plasma.h" #include #include #include #include "config-plasma.h" class ThemePackage : public KPackage::PackageStructure { Q_OBJECT public: ThemePackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : KPackage::PackageStructure(parent, args) {} - void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE + void initPackage(KPackage::Package *package) override { // by default the packages have "contents/" as contentsPrefixPaths // but for the themes we don't want that, so unset it. package->setContentsPrefixPaths(QStringList()); package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/")); package->addDirectoryDefinition("dialogs", QStringLiteral("dialogs/"), i18n("Images for dialogs")); package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svg"), i18n("Generic dialog background")); package->addFileDefinition("dialogs/background", QStringLiteral("dialogs/background.svgz"), i18n("Generic dialog background")); package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svg"), i18n("Theme for the logout dialog")); package->addFileDefinition("dialogs/shutdowndialog", QStringLiteral("dialogs/shutdowndialog.svgz"), i18n("Theme for the logout dialog")); package->addDirectoryDefinition("wallpapers", QStringLiteral("wallpapers/"), i18n("Wallpaper packages")); package->addDirectoryDefinition("widgets", QStringLiteral("widgets/"), i18n("Images for widgets")); package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svg"), i18n("Background image for widgets")); package->addFileDefinition("widgets/background", QStringLiteral("widgets/background.svgz"), i18n("Background image for widgets")); package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svg"), i18n("Analog clock face")); package->addFileDefinition("widgets/clock", QStringLiteral("widgets/clock.svgz"), i18n("Analog clock face")); package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svg"), i18n("Background image for panels")); package->addFileDefinition("widgets/panel-background", QStringLiteral("widgets/panel-background.svgz"), i18n("Background image for panels")); package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svg"), i18n("Background for graphing widgets")); package->addFileDefinition("widgets/plot-background", QStringLiteral("widgets/plot-background.svgz"), i18n("Background for graphing widgets")); package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svg"), i18n("Background image for tooltips")); package->addFileDefinition("widgets/tooltip", QStringLiteral("widgets/tooltip.svgz"), i18n("Background image for tooltips")); package->addDirectoryDefinition("opaque/dialogs", QStringLiteral("opaque/dialogs/"), i18n("Opaque images for dialogs")); package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svg"), i18n("Opaque generic dialog background")); package->addFileDefinition("opaque/dialogs/background", QStringLiteral("opaque/dialogs/background.svgz"), i18n("Opaque generic dialog background")); package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svg"), i18n("Opaque theme for the logout dialog")); package->addFileDefinition("opaque/dialogs/shutdowndialog", QStringLiteral("opaque/dialogs/shutdowndialog.svgz"), i18n("Opaque theme for the logout dialog")); package->addDirectoryDefinition("opaque/widgets", QStringLiteral("opaque/widgets/"), i18n("Opaque images for widgets")); package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svg"), i18n("Opaque background image for panels")); package->addFileDefinition("opaque/widgets/panel-background", QStringLiteral("opaque/widgets/panel-background.svgz"), i18n("Opaque background image for panels")); package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svg"), i18n("Opaque background image for tooltips")); package->addFileDefinition("opaque/widgets/tooltip", QStringLiteral("opaque/widgets/tooltip.svgz"), i18n("Opaque background image for tooltips")); package->addFileDefinition("colors", QStringLiteral("colors"), i18n("KColorScheme configuration file")); QStringList mimetypes; mimetypes << QStringLiteral("image/svg+xml"); package->setDefaultMimeTypes(mimetypes); } }; K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(ThemePackage, "plasmatheme-packagestructure.json") #include "plasmathemepackage.moc" diff --git a/src/plasma/packagestructure/plasmoidpackage.cpp b/src/plasma/packagestructure/plasmoidpackage.cpp index 9adc68dcb..53366c1ab 100644 --- a/src/plasma/packagestructure/plasmoidpackage.cpp +++ b/src/plasma/packagestructure/plasmoidpackage.cpp @@ -1,60 +1,60 @@ /****************************************************************************** * Copyright 2007-2009 by Aaron Seigo * * * * This library 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 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *******************************************************************************/ #include "plasma.h" #include #include #include #include "packages_p.h" #include "config-plasma.h" class PlasmoidPackage : public Plasma::GenericPackage { Q_OBJECT public: PlasmoidPackage(QObject *parent = nullptr, const QVariantList &args = QVariantList()) : GenericPackage(parent, args) {} - void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE + void initPackage(KPackage::Package *package) override { GenericPackage::initPackage(package); package->setDefaultPackageRoot(QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/plasmoids/")); package->addFileDefinition("configmodel", QStringLiteral("config/config.qml"), i18n("Configuration UI pages model")); package->addFileDefinition("mainconfigxml", QStringLiteral("config/main.xml"), i18n("Configuration XML file")); } - void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE + void pathChanged(KPackage::Package *package) override { ChangeableMainScriptPackage::pathChanged(package); if (!package->metadata().isValid()) { return; } if (package->metadata().serviceTypes().contains(QStringLiteral("Plasma/Containment"))) { package->addFileDefinition("compactapplet", QStringLiteral("applet/CompactApplet.qml"), i18n("Custom expander for compact applets")); } else { package->removeDefinition("compactapplet"); } } }; K_EXPORT_KPACKAGE_PACKAGE_WITH_JSON(PlasmoidPackage, "plasmoid-packagestructure.json") #include "plasmoidpackage.moc" diff --git a/src/plasma/private/datacontainer_p.h b/src/plasma/private/datacontainer_p.h index 58b83ca19..13d1c1dfa 100644 --- a/src/plasma/private/datacontainer_p.h +++ b/src/plasma/private/datacontainer_p.h @@ -1,133 +1,133 @@ /* * Copyright 2006-2007 Aaron Seigo * * 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 PLASMA_DATACONTAINER_P_H #define PLASMA_DATACONTAINER_P_H #include "servicejob.h" #include "storage_p.h" #include #include #include #include class QTimer; namespace Plasma { class ServiceJob; class SignalRelay; class DataContainerPrivate { public: DataContainerPrivate(DataContainer *container) : q(container), storage(nullptr), storageCount(0), dirty(false), cached(false), enableStorage(false), isStored(true) { } /** * Check if the DataContainer is still in use. * * If not the signal "becameUnused" will be emitted. * * Warning: The DataContainer may be invalid after calling this function, because a listener * to becameUnused() may have deleted it. **/ void checkUsage(); SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization, uint pollingInterval, Plasma::Types::IntervalAlignment align, bool immediateUpdate); bool hasUpdates(); /** * Deletes the store member of DataContainerPrivate if * there are no more references to it. */ void storeJobFinished(KJob *job); /** * Does the work of putting the data from disk into the DataContainer * after retrieve() sets it up. */ void populateFromStoredData(KJob *job); void store(); void retrieve(); DataContainer *q; DataEngine::Data data; QMap relayObjects; QMap relays; QElapsedTimer updateTimer; Storage *storage; QBasicTimer storageTimer; QBasicTimer checkUsageTimer; QWeakPointer model; int storageCount; bool dirty : 1; bool cached : 1; bool enableStorage : 1; bool isStored : 1; }; class SignalRelay : public QObject { Q_OBJECT public: SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint ival, Plasma::Types::IntervalAlignment align, bool immediateUpdate); int receiverCount() const; bool isUnused() const; void checkAlignment(); void checkQueueing(); void forceImmediateUpdate(); DataContainer *dc; DataContainerPrivate *d; uint m_interval; Plasma::Types::IntervalAlignment m_align; int m_timerId; bool m_resetTimer; bool m_queued; Q_SIGNALS: void dataUpdated(const QString &, const Plasma::DataEngine::Data &); protected: - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) override; }; } // Plasma namespace #endif // multiple inclusion guard diff --git a/src/plasma/private/dataenginemanager_p.h b/src/plasma/private/dataenginemanager_p.h index 850c526ba..ffe6dee10 100644 --- a/src/plasma/private/dataenginemanager_p.h +++ b/src/plasma/private/dataenginemanager_p.h @@ -1,94 +1,94 @@ /* * Copyright 2006-2007 Aaron Seigo * * 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 PLASMA_DATAENGINEMANAGER_H #define PLASMA_DATAENGINEMANAGER_H #include namespace Plasma { class DataEngineManagerPrivate; /** * @class DataEngineManager plasma/dataenginemanager.h * * @short DataEngine loader and life time manager * * Plasma::DataEngineManager provides facilities for listing, loading and * according to reference count unloading of DataEngines. **/ class DataEngineManager: public QObject { Q_OBJECT public: /** * Singleton pattern accessor. */ static DataEngineManager *self(); /** * Returns a data engine object if one is loaded and available. * On failure, the fallback NullEngine (which does nothing and * !isValid()) is returned. * * @param name the name of the engine */ Plasma::DataEngine *engine(const QString &name) const; /** * Loads a data engine and increases the reference count on it. * This should be called once per object (or set of objects) using the * DataEngine. Afterwards, dataEngine should be used or the return * value cached. Call unloadDataEngine when finished with the engine. * * @param name the name of the engine * @return the data engine that was loaded, or the NullEngine on failure. */ Plasma::DataEngine *loadEngine(const QString &name); /** * Decreases the reference count on the engine. If the count reaches * zero, then the engine is deleted to save resources. */ void unloadEngine(const QString &name); protected: /** * Reimplemented from QObject **/ - void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; + void timerEvent(QTimerEvent *event) override; private: /** * Default constructor. The singleton method self() is the * preferred access mechanism. */ DataEngineManager(); - ~DataEngineManager() Q_DECL_OVERRIDE; + ~DataEngineManager() override; DataEngineManagerPrivate *const d; friend class DataEngineManagerSingleton; }; } // namespace Plasma #endif // multiple inclusion guard diff --git a/src/plasma/private/effectwatcher_p.h b/src/plasma/private/effectwatcher_p.h index 378cf4dea..47b464a45 100644 --- a/src/plasma/private/effectwatcher_p.h +++ b/src/plasma/private/effectwatcher_p.h @@ -1,56 +1,56 @@ /* * Copyright 2011 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 BLURWATCHER_H #define BLURWATCHER_H #include #include #include namespace Plasma { class EffectWatcher: public QObject, public QAbstractNativeEventFilter { Q_OBJECT public: explicit EffectWatcher(const QString &property, QObject *parent = nullptr); protected: bool isEffectActive() const; - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; + bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; Q_SIGNALS: void effectChanged(bool on); private: void init(const QString &property); xcb_atom_t m_property; bool m_effectActive; bool m_isX11; }; } // namespace Plasma #endif diff --git a/src/plasma/private/packagestructure_p.h b/src/plasma/private/packagestructure_p.h index 7ee95d32c..6ab99890c 100644 --- a/src/plasma/private/packagestructure_p.h +++ b/src/plasma/private/packagestructure_p.h @@ -1,72 +1,72 @@ /* * Copyright © 2009 Rob Scheepmaker * Copyright 2014 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 PLASMA_PACKAGESTRUCTURE_P_H #define PLASMA_PACKAGESTRUCTURE_P_H #include "../packagestructure.h" #include #include #include namespace Plasma { class PackageStructureWrapper : public KPackage::PackageStructure { Q_OBJECT public: PackageStructureWrapper(Plasma::PackageStructure *structure, QObject *parent = nullptr, const QVariantList &args = QVariantList()); ~PackageStructureWrapper(); - void initPackage(KPackage::Package *package) Q_DECL_OVERRIDE; + void initPackage(KPackage::Package *package) override; - void pathChanged(KPackage::Package *package) Q_DECL_OVERRIDE; + void pathChanged(KPackage::Package *package) override; - KJob *install(KPackage::Package *package, const QString &archivePath, const QString &packageRoot) Q_DECL_OVERRIDE; - KJob *uninstall(KPackage::Package *package, const QString &packageRoot) Q_DECL_OVERRIDE; + KJob *install(KPackage::Package *package, const QString &archivePath, const QString &packageRoot) override; + KJob *uninstall(KPackage::Package *package, const QString &packageRoot) override; private: QPointer m_struct; static QHash s_packagesMap; friend class Package; }; class PackageStructurePrivate { public: PackageStructurePrivate(PackageStructure *str) : q(str), internalStructure(0) {} ~PackageStructurePrivate() {} void installPathChanged(const QString &path); PackageStructure *q; KPackage::PackageStructure *internalStructure; }; } #endif diff --git a/src/plasma/private/service_p.h b/src/plasma/private/service_p.h index ce1d9e3af..4e9dd3bf0 100644 --- a/src/plasma/private/service_p.h +++ b/src/plasma/private/service_p.h @@ -1,95 +1,95 @@ /* * Copyright 2008 Aaron Seigo * * 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 SERVICE_P_H #define SERVICE_P_H #include "servicejob.h" #include "service.h" #include #include #include #include #include #include namespace Plasma { class NullServiceJob : public ServiceJob { public: NullServiceJob(const QString &destination, const QString &operation, QObject *parent) : ServiceJob(destination, operation, QVariantMap(), parent) { } - void start() Q_DECL_OVERRIDE + void start() override { setErrorText(i18nc("Error message, tried to start an invalid service", "Invalid (null) service, can not perform any operations.")); emitResult(); } }; class NullService : public Service { public: NullService(const QString &target, QObject *parent) : Service(parent) { setDestination(target); setName(QStringLiteral("NullService")); } - ServiceJob *createJob(const QString &operation, QVariantMap &) Q_DECL_OVERRIDE + ServiceJob *createJob(const QString &operation, QVariantMap &) override { return new NullServiceJob(destination(), operation, this); } }; class ServicePrivate { public: ServicePrivate(Service *service) : q(service) { } ~ServicePrivate() { } void associatedWidgetDestroyed(QObject *obj); void associatedItemDestroyed(QObject *obj); Service *q; QString destination; QString name; QString resourcename; QMap operationsMap; QSet disabledOperations; }; } // namespace Plasma #endif diff --git a/src/plasma/private/storage_p.h b/src/plasma/private/storage_p.h index f92fd4c41..5c951e183 100644 --- a/src/plasma/private/storage_p.h +++ b/src/plasma/private/storage_p.h @@ -1,75 +1,75 @@ ///////////////////////////////////////////////////////////////////////// // storage.h // // // // Copyright (C) 2010 Brian Pritchett // // Copyright (C) 2010 Marco Martin // // // // This library is free software; you can redistribute it and/or // // modify it under the terms of the GNU Lesser General Public // // License as published by the Free Software Foundation; either // // version 2.1 of the License, or (at your option) any later version. // // // // This library is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // // Lesser General Public License for more details. // // // // You should have received a copy of the GNU Lesser General Public // // License along with this library; if not, write to the Free Software // // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA // // 02110-1301 USA // ///////////////////////////////////////////////////////////////////////// #ifndef PLASMA_STORAGE_H #define PLASMA_STORAGE_H #include #include #include //Begin StorageJob class StorageJob : public Plasma::ServiceJob { Q_OBJECT Q_PROPERTY(QVariantMap data READ data WRITE setData) public: StorageJob(const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent = nullptr); - ~StorageJob() Q_DECL_OVERRIDE; + ~StorageJob() override; void setData(const QVariantMap &data); QVariantMap data() const; - void start() Q_DECL_OVERRIDE; + void start() override; QString clientName() const; protected Q_SLOTS: void resultSlot(StorageJob *job, const QVariant &result); private: QString m_clientName; QVariantMap m_data; }; //End StorageJob Q_DECLARE_METATYPE(StorageJob *) Q_DECLARE_METATYPE(QWeakPointer) class Storage : public Plasma::Service { Q_OBJECT public: explicit Storage(QObject *parent = nullptr); - ~Storage() Q_DECL_OVERRIDE; + ~Storage() override; protected: - Plasma::ServiceJob *createJob(const QString &operation, QVariantMap ¶meters) Q_DECL_OVERRIDE; + Plasma::ServiceJob *createJob(const QString &operation, QVariantMap ¶meters) override; private: QString m_clientName; }; #endif //PLASMA_STORAGE_H diff --git a/src/plasma/private/storagethread_p.h b/src/plasma/private/storagethread_p.h index b6850e3d3..c5ae8d933 100644 --- a/src/plasma/private/storagethread_p.h +++ b/src/plasma/private/storagethread_p.h @@ -1,61 +1,61 @@ /* * Copyright 2011 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 STORAGETHREAD_H #define STORAGETHREAD_H #include #include #include #include "storage_p.h" namespace Plasma { class StorageThread : public QThread { Q_OBJECT public: explicit StorageThread(QObject *parent = nullptr); - ~StorageThread() Q_DECL_OVERRIDE; + ~StorageThread() override; - void run() Q_DECL_OVERRIDE; + void run() override; static Plasma::StorageThread *self(); void closeDb(); public Q_SLOTS: void save(QWeakPointer caller, const QVariantMap ¶meters); void retrieve(QWeakPointer caller, const QVariantMap ¶meters); void deleteEntry(QWeakPointer caller, const QVariantMap ¶meters); void expire(QWeakPointer caller, const QVariantMap ¶meters); Q_SIGNALS: void newResult(StorageJob *caller, const QVariant &result); private: void initializeDb(StorageJob *caller); QSqlDatabase m_db; }; } #endif diff --git a/src/plasma/private/theme_p.h b/src/plasma/private/theme_p.h index a4e3161ad..68f3cfd22 100644 --- a/src/plasma/private/theme_p.h +++ b/src/plasma/private/theme_p.h @@ -1,170 +1,170 @@ /* * Copyright 2006-2007 Aaron Seigo * 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 PLASMA_THEME_P_H #define PLASMA_THEME_P_H #include "theme.h" #include "svg.h" #include #include #include #include #include #include #include #include #if HAVE_X11 #include "private/effectwatcher_p.h" #endif #include "libplasma-theme-global.h" namespace Plasma { class Theme; //NOTE: Default wallpaper can be set from the theme configuration #define DEFAULT_WALLPAPER_THEME "default" #define DEFAULT_WALLPAPER_SUFFIX ".png" static const int DEFAULT_WALLPAPER_WIDTH = 1920; static const int DEFAULT_WALLPAPER_HEIGHT = 1200; enum CacheType { NoCache = 0, PixmapCache = 1, SvgElementsCache = 2 }; Q_DECLARE_FLAGS(CacheTypes, CacheType) Q_DECLARE_OPERATORS_FOR_FLAGS(CacheTypes) class ThemePrivate : public QObject { Q_OBJECT public: explicit ThemePrivate(QObject *parent = nullptr); - ~ThemePrivate() Q_DECL_OVERRIDE; + ~ThemePrivate() override; KConfigGroup &config(); QString imagePath(const QString &theme, const QString &type, const QString &image); QString findInTheme(const QString &image, const QString &theme, bool cache = true); void discardCache(CacheTypes caches); void scheduleThemeChangeNotification(CacheTypes caches); bool useCache(); void setThemeName(const QString &themeName, bool writeSettings, bool emitChanged); void processWallpaperSettings(KConfigBase *metadata); void processContrastSettings(KConfigBase *metadata); const QString processStyleSheet(const QString &css, Plasma::Svg::Status status); const QString svgStyleSheet(Plasma::Theme::ColorGroup group, Plasma::Svg::Status status); QColor color(Theme::ColorRole role, Theme::ColorGroup group = Theme::NormalColorGroup) const; public Q_SLOTS: void compositingChanged(bool active); void colorsChanged(); void settingsFileChanged(const QString &settings); void scheduledCacheUpdate(); void onAppExitCleanup(); void notifyOfChanged(); void settingsChanged(bool emitChanges); void saveSvgElementsCache(); Q_SIGNALS: void themeChanged(); void defaultFontChanged(); void smallestFontChanged(); void applicationPaletteChange(); public: static const char defaultTheme[]; static const char systemColorsTheme[]; static const char themeRcFile[]; #if HAVE_X11 static EffectWatcher *s_backgroundContrastEffectWatcher; #endif //Ref counting of ThemePrivate instances static ThemePrivate *globalTheme; static QAtomicInt globalThemeRefCount; static QHash themes; static QHash themesRefCount; QString themeName; KPluginInfo pluginInfo; QList fallbackThemes; KSharedConfigPtr colors; KColorScheme colorScheme; KColorScheme selectionColorScheme; KColorScheme buttonColorScheme; KColorScheme viewColorScheme; KColorScheme complementaryColorScheme; - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *event) override; KConfigGroup cfg; QString defaultWallpaperTheme; QString defaultWallpaperSuffix; int defaultWallpaperWidth; int defaultWallpaperHeight; KImageCache *pixmapCache; KSharedConfigPtr svgElementsCache; QString cachedDefaultStyleSheet; QHash > invalidElements; QHash pixmapsToCache; QHash keysToCache; QHash idsToCache; QHash cachedSvgStyleSheets; QHash cachedSelectedSvgStyleSheets; QHash discoveries; QTimer *pixmapSaveTimer; QTimer *rectSaveTimer; QTimer *updateNotificationTimer; unsigned cacheSize; CacheTypes cachesToDiscard; QString themeVersion; QString themeMetadataPath; QString iconThemeMetadataPath; bool compositingActive : 1; bool backgroundContrastActive : 1; bool isDefault : 1; bool useGlobal : 1; bool hasWallpapers : 1; bool cacheTheme : 1; bool fixedName : 1; qreal backgroundContrast; qreal backgroundIntensity; qreal backgroundSaturation; bool backgroundContrastEnabled; //Version number of Plasma the Theme has been designed for int apiMajor; int apiMinor; int apiRevision; }; } #endif extern const QString s; diff --git a/src/plasma/scripting/appletscript.h b/src/plasma/scripting/appletscript.h index 1e9c38feb..fe3bbc808 100644 --- a/src/plasma/scripting/appletscript.h +++ b/src/plasma/scripting/appletscript.h @@ -1,178 +1,178 @@ /* * Copyright 2007 by Aaron Seigo * * 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 PLASMA_APPLETSCRIPT_H #define PLASMA_APPLETSCRIPT_H #include #include #include #include #include #include #include class QAction; class QPainter; namespace Plasma { class AppletScriptPrivate; class Extender; /** * @class AppletScript plasma/scripting/appletscript.h * * @short Provides a restricted interface for scripted applets. */ class PLASMA_EXPORT AppletScript : public ScriptEngine { Q_OBJECT public: /** * Default constructor for an AppletScript. * * Subclasses should not attempt to access the Plasma::Applet * associated with this AppletScript in the constructor. All * such set up that requires the Applet itself should be done * in the init() method. */ explicit AppletScript(QObject *parent = nullptr); - ~AppletScript() Q_DECL_OVERRIDE; + ~AppletScript() override; /** * Sets the applet associated with this AppletScript */ void setApplet(Plasma::Applet *applet); /** * Returns the Plasma::Applet associated with this script component */ Plasma::Applet *applet() const; /** * Called when any of the geometry constraints have been updated. * * This is always called prior to painting and should be used as an * opportunity to layout the widget, calculate sizings, etc. * * Do not call update() from this method; an update() will be triggered * at the appropriate time for the applet. * * @param constraints the type of constraints that were updated */ virtual void constraintsEvent(Plasma::Types::Constraints constraints); /** * Returns a list of context-related QAction instances. * * @return A list of actions. The default implementation returns an * empty list. */ virtual QList contextualActions(); /** * Sets whether or not this script has a configuration interface or not * * @param hasInterface true if the applet is user configurable */ void setHasConfigurationInterface(bool hasInterface); /** * @see Applet */ void setConfigurationRequired(bool req, const QString &reason = QString()); /** * @see Applet */ void setLaunchErrorMessage(const QString &reason = QString()); /** * @see Applet */ void configNeedsSaving() const; /** * @see Containment * @since 4.7 */ Plasma::Types::ContainmentType containmentType() const; /** * @see Containment * @since 4.7 */ void setContainmentType(Plasma::Types::ContainmentType type); Q_SIGNALS: /** * @see Applet */ void saveState(KConfigGroup &group) const; /** * @param uiReady true if the UI for this applet is ready */ void uiReadyChanged(bool uiReady); public Q_SLOTS: /** * Configure was changed. */ virtual void configChanged(); protected: /** * @return absolute path to the main script file for this plasmoid */ - QString mainScript() const Q_DECL_OVERRIDE; + QString mainScript() const override; /** * @return the Package associated with this plasmoid which can * be used to request resources, such as images and * interface files. */ - Package package() const Q_DECL_OVERRIDE; + Package package() const override; /** * @return the KPluginInfo associated with this plasmoid */ KPluginInfo description() const; private: friend class Applet; AppletScriptPrivate *const d; }; #define K_EXPORT_PLASMA_APPLETSCRIPTENGINE(libname, classname) \ K_PLUGIN_FACTORY(factory, registerPlugin();) #define K_EXPORT_PLASMA_APPLETSCRIPTENGINE_WITH_JSON(libname, classname, jsonFile) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) } //Plasma namespace #endif diff --git a/src/plasma/scripting/dataenginescript.h b/src/plasma/scripting/dataenginescript.h index b790fa222..aadcc3d3a 100644 --- a/src/plasma/scripting/dataenginescript.h +++ b/src/plasma/scripting/dataenginescript.h @@ -1,154 +1,154 @@ /* * Copyright 2007 by Aaron Seigo * * 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 PLASMA_DATAENGINESCRIPT_H #define PLASMA_DATAENGINESCRIPT_H #include #include #include #include namespace Plasma { class DataEngineScriptPrivate; class Service; /** * @class DataEngineScript plasma/scripting/dataenginescript.h * * @short Provides a restricted interface for scripting a DataEngine */ class PLASMA_EXPORT DataEngineScript : public ScriptEngine { Q_OBJECT public: /** * Default constructor for a DataEngineScript. * Subclasses should not attempt to access the Plasma::DataEngine * associated with this DataEngineScript in the constructor. All * such set up that requires the DataEngine itself should be done * in the init() method. */ explicit DataEngineScript(QObject *parent = nullptr); - ~DataEngineScript() Q_DECL_OVERRIDE; + ~DataEngineScript() override; /** * Sets the Plasma::DataEngine associated with this DataEngineScript */ void setDataEngine(DataEngine *dataEngine); /** * Returns the Plasma::DataEngine associated with this script component */ DataEngine *dataEngine() const; /** * @return a list of all the data sources available via this DataEngine * Whether these sources are currently available (which is what * the default implementation provides) or not is up to the * DataEngine to decide. By default, this returns dataEngine()->sources() */ virtual QStringList sources() const; /** * Called when the script should create a source that does not currently * exist. * * @param name the name of the source that should be created * @return true if a DataContainer was set up, false otherwise */ virtual bool sourceRequestEvent(const QString &name); /** * Called when the script should refresh the data contained in a given * source. * * @param source the name of the source that should be updated * @return true if the data was changed, or false if there was no * change or if the change will occur later **/ virtual bool updateSourceEvent(const QString &source); /** * @param source the source to targe the Service at * @return a Service that has the source as a destination. The service * is parented to the DataEngine, but may be deleted by the * caller when finished with it */ virtual Service *serviceForSource(const QString &source); protected: /** * @return absolute path to the main script file for this plasmoid */ - QString mainScript() const Q_DECL_OVERRIDE; + QString mainScript() const override; /** * @return the Package associated with this plasmoid which can * be used to request resources, such as images and * interface files. */ - Package package() const Q_DECL_OVERRIDE; + Package package() const override; /** * @return the KPluginInfo associated with this plasmoid */ KPluginInfo description() const; void setData(const QString &source, const QString &key, const QVariant &value); void setData(const QString &source, const QVariant &value); /** * Adds a set of values to a source * @param source the name of the source to set the data on * @values a key/value collection to add to the source * @since 4.5 */ void setData(const QString &source, const DataEngine::Data &values); void removeAllData(const QString &source); void removeData(const QString &source, const QString &key); void setMinimumPollingInterval(int minimumMs); int minimumPollingInterval() const; void setPollingInterval(uint frequency); void removeAllSources(); void addSource(DataContainer *source); DataEngine::SourceDict containerDict() const; void removeSource(const QString &source); void updateAllSources(); void forceImmediateUpdateOfAllVisualizations(); private: DataEngineScriptPrivate *const d; }; #define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(libname, classname) \ K_PLUGIN_FACTORY(factory, registerPlugin();) #define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE_WITH_JSON(libname, classname, jsonFile) \ K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin();) \ K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION) } //Plasma namespace #endif diff --git a/src/plasma/servicejob.h b/src/plasma/servicejob.h index b0624b24d..33908c494 100644 --- a/src/plasma/servicejob.h +++ b/src/plasma/servicejob.h @@ -1,128 +1,128 @@ /* * Copyright 2008 Aaron Seigo * * 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 PLASMA_SERVICEJOB_H #define PLASMA_SERVICEJOB_H #include #include #include namespace Plasma { class ServiceJobPrivate; /** * @class ServiceJob plasma/servicejob.h * * @short This class provides jobs for use with Plasma::Service * * Unlike KJob, you can do the work in start(), since Plasma::Service already * delays the call to start() until the event loop is reached. * * If the job is quick enough that it is not worth reporting the progress, * you just need to implement start() to do the task, then call emitResult() * at the end of it. If the task does not complete successfully, you should * set a non-zero error code with setError(int) and an error message with * setErrorText(QString). * * If the job is longer (involving network access, for instance), you should * report the progress at regular intervals. See the KJob documentation for * information on how to do this. */ class PLASMA_EXPORT ServiceJob : public KJob { Q_OBJECT Q_PROPERTY(QString destination READ destination) Q_PROPERTY(QString operationName READ operationName) Q_PROPERTY(QVariant result READ result) public: /** * Default constructor * * @param destination the subject that the job is acting on * @param operation the action that the job is performing on the @p destination * @param parameters the parameters of the @p action * @param parent the parent object for this service */ ServiceJob(const QString &destination, const QString &operation, const QVariantMap ¶meters, QObject *parent = nullptr); /** * Destructor */ - ~ServiceJob() Q_DECL_OVERRIDE; + ~ServiceJob() override; /** * @return the subject that the job is acting on */ QString destination() const; /** * @return the operation the job is performing on the destination */ QString operationName() const; /** * @return the parameters for the operation */ QVariantMap parameters() const; /** * Returns the result of the operation * * The result will be invalid if the job has not completed yet, or * if the job does not have a meaningful result. * * Note that this should not be used to find out whether the operation * was successful. Instead, you should check the value of error(). * * @return the result of the operation */ QVariant result() const; /** * Default implementation of start, which simply sets the results to false. * This makes it easy to create a "failure" job. */ - Q_INVOKABLE void start() Q_DECL_OVERRIDE; + Q_INVOKABLE void start() override; protected: /** * Sets the result for an operation. */ void setResult(const QVariant &result); private: Q_PRIVATE_SLOT(d, void autoStart()) Q_PRIVATE_SLOT(d, void preventAutoStart()) ServiceJobPrivate *const d; }; } // namespace Plasma Q_DECLARE_METATYPE(Plasma::ServiceJob *) #endif // multiple inclusion guard diff --git a/src/plasma/svg.h b/src/plasma/svg.h index 6c3475d4f..d3ca3ea59 100644 --- a/src/plasma/svg.h +++ b/src/plasma/svg.h @@ -1,517 +1,517 @@ /* * Copyright 2006-2007 Aaron Seigo * * 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 PLASMA_SVG_H #define PLASMA_SVG_H #include #include #include #include class QPainter; class QPoint; class QPointF; class QRect; class QRectF; class QSize; class QSizeF; class QMatrix; namespace Plasma { class FrameSvgPrivate; class SvgPrivate; /** * @class Svg plasma/svg.h * * @short A theme aware image-centric SVG class * * Plasma::Svg provides a class for rendering SVG images to a QPainter in a * convenient manner. Unless an absolute path to a file is provided, it loads * the SVG document using Plasma::Theme. It also provides a number of internal * optimizations to help lower the cost of painting SVGs, such as caching. * * @see Plasma::FrameSvg **/ class PLASMA_EXPORT Svg : public QObject { Q_OBJECT Q_PROPERTY(QSize size READ size WRITE resize NOTIFY sizeChanged) Q_PROPERTY(bool multipleImages READ containsMultipleImages WRITE setContainsMultipleImages) Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged) Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache) Q_PROPERTY(bool fromCurrentTheme READ fromCurrentTheme NOTIFY fromCurrentThemeChanged) Q_PROPERTY(Plasma::Theme::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY colorGroupChanged) Q_PROPERTY(Plasma::Svg::Status status READ status WRITE setStatus NOTIFY statusChanged) public: enum Status { Normal = 0, Selected }; Q_ENUM(Status) /** * Constructs an SVG object that implicitly shares and caches rendering. * * Unlike QSvgRenderer, which this class uses internally, * Plasma::Svg represents an image generated from an SVG. As such, it * has a related size and transform matrix (the latter being provided * by the painter used to paint the image). * * The size is initialized to be the SVG's native size. * * @param parent options QObject to parent this to * * @related Plasma::Theme */ explicit Svg(QObject *parent = nullptr); - ~Svg() Q_DECL_OVERRIDE; + ~Svg() override; /** * Set the device pixel ratio for the Svg. This is the ratio between * image pixels and device-independent pixels. * The Svg will produce pixmaps scaled by devicePixelRatio, but all the sizes and element * rects will not be altered. * The default value is 1.0 and the scale will be done rounded to the floor integer * Setting it to something more, will make all the elements of this svg appear bigger. */ void setDevicePixelRatio(qreal ratio); /** * @return the device pixel ratio for this Svg. */ qreal devicePixelRatio(); /** * Settng a scale factor greater than one it will result in final images scaled by it. * Unlike devicePixelRatio, every size and element rect will be scaled accordingly. * @return how much to scale the rendered image. */ qreal scaleFactor() const; /** * Settng a scale factor greater than one it will result in final images scaled by it. * Unlike devicePixelRatio, every size and element rect will be scaled accordingly. * The default value is 1.0 and the scale will be done rounded to the floor integer. * @param how much to scale the Svg */ void setScaleFactor(qreal factor); /** * Set a color group for the Svg. * if the Svg uses stylesheets and has elements * that are eithe TextColor or BackgroundColor class, * make them use ButtonTextColor/ButtonBackgroundColor * or ViewTextColor/ViewBackgroundColor */ void setColorGroup(Plasma::Theme::ColorGroup group); /** * @return the color group for this Svg */ Plasma::Theme::ColorGroup colorGroup() const; /** * Returns a pixmap of the SVG represented by this object. * * The size of the pixmap will be the size of this Svg object (size()) * if containsMultipleImages is @c true; otherwise, it will be the * size of the requested element after the whole SVG has been scaled * to size(). * * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) * @return a QPixmap of the rendered SVG */ Q_INVOKABLE QPixmap pixmap(const QString &elementID = QString()); /** * Returns an image of the SVG represented by this object. * * The size of the image will be the size of this Svg object (size()) * if containsMultipleImages is @c true; otherwise, it will be the * size of the requested element after the whole SVG has been scaled * to size(). * * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) * @return a QPixmap of the rendered SVG */ Q_INVOKABLE QImage image(const QSize &size, const QString &elementID = QString()); /** * Paints all or part of the SVG represented by this object * * The size of the painted area will be the size of this Svg object * (size()) if containsMultipleImages is @c true; otherwise, it will * be the size of the requested element after the whole SVG has been * scaled to size(). * * @param painter the QPainter to use * @param point the position to start drawing; the entire svg will be * drawn starting at this point. * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ Q_INVOKABLE void paint(QPainter *painter, const QPointF &point, const QString &elementID = QString()); /** * Paints all or part of the SVG represented by this object * * The size of the painted area will be the size of this Svg object * (size()) if containsMultipleImages is @c true; otherwise, it will * be the size of the requested element after the whole SVG has been * scaled to size(). * * @param painter the QPainter to use * @param x the horizontal coordinate to start painting from * @param y the vertical coordinate to start painting from * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ Q_INVOKABLE void paint(QPainter *painter, int x, int y, const QString &elementID = QString()); /** * Paints all or part of the SVG represented by this object * * @param painter the QPainter to use * @param rect the rect to draw into; if smaller than the current size * the drawing is starting at this point. * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect, const QString &elementID = QString()); /** * Paints all or part of the SVG represented by this object * * @param painter the QPainter to use * @param x the horizontal coordinate to start painting from * @param y the vertical coordinate to start painting from * @param width the width of the element to draw * @param height the height of the element do draw * @param elementId the ID string of the element to render, or an empty * string for the whole SVG (the default) */ Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width, int height, const QString &elementID = QString()); /** * The size of the SVG. * * If the SVG has been resized with resize(), that size will be * returned; otherwise, the natural size of the SVG will be returned. * * If containsMultipleImages is @c true, each element of the SVG * will be rendered at this size by default. * * @return the current size of the SVG **/ QSize size() const; /** * Resizes the rendered image. * * Rendering will actually take place on the next call to paint. * * If containsMultipleImages is @c true, each element of the SVG * will be rendered at this size by default; otherwise, the entire * image will be scaled to this size and each element will be * scaled appropriately. * * @param width the new width * @param height the new height **/ Q_INVOKABLE void resize(qreal width, qreal height); /** * Resizes the rendered image. * * Rendering will actually take place on the next call to paint. * * If containsMultipleImages is @c true, each element of the SVG * will be rendered at this size by default; otherwise, the entire * image will be scaled to this size and each element will be * scaled appropriately. * * @param size the new size of the image **/ Q_INVOKABLE void resize(const QSizeF &size); /** * Resizes the rendered image to the natural size of the SVG. * * Rendering will actually take place on the next call to paint. **/ Q_INVOKABLE void resize(); /** * Find the size of a given element. * * This is the size of the element with ID @p elementId after the SVG * has been scaled (see resize()). Note that this is unaffected by * the containsMultipleImages property. * * @param elementId the id of the element to check * @return the size of a given element, given the current size of the SVG **/ Q_INVOKABLE QSize elementSize(const QString &elementId) const; /** * The bounding rect of a given element. * * This is the bounding rect of the element with ID @p elementId after * the SVG has been scaled (see resize()). Note that this is * unaffected by the containsMultipleImages property. * * @param elementId the id of the element to check * @return the current rect of a given element, given the current size of the SVG **/ Q_INVOKABLE QRectF elementRect(const QString &elementId) const; /** * Check whether an element exists in the loaded SVG. * * @param elementId the id of the element to check for * @return @c true if the element is defined in the SVG, otherwise @c false **/ Q_INVOKABLE bool hasElement(const QString &elementId) const; /** * Check whether this object is backed by a valid SVG file. * * This method can be expensive as it causes disk access. * * @return @c true if the SVG file exists and the document is valid, * otherwise @c false. **/ Q_INVOKABLE bool isValid() const; /** * Set whether the SVG contains a single image or multiple ones. * * If this is set to @c true, the SVG will be treated as a * collection of related images, rather than a consistent * drawing. * * In particular, when individual elements are rendered, this * affects whether the elements are resized to size() by default. * See paint() and pixmap(). * * @param multiple true if the svg contains multiple images */ void setContainsMultipleImages(bool multiple); /** * Whether the SVG contains multiple images. * * If this is @c true, the SVG will be treated as a * collection of related images, rather than a consistent * drawing. * * @return @c true if the SVG will be treated as containing * multiple images, @c false if it will be treated * as a coherent image. */ bool containsMultipleImages() const; /** * Set the SVG file to render. * * Relative paths are looked for in the current Plasma theme, * and should not include the file extension (.svg and .svgz * files will be searched for). See Theme::imagePath(). * * If the parent object of this Svg is a Plasma::Applet, * relative paths will be searched for in the applet's package * first. * * @param svgFilePath either an absolute path to an SVG file, or * an image name */ virtual void setImagePath(const QString &svgFilePath); /** * The SVG file to render. * * If this SVG is themed, this will be a relative path, and will not * include a file extension. * * @return either an absolute path to an SVG file, or an image name * @see Theme::imagePath() */ QString imagePath() const; /** * Sets whether or not to cache the results of rendering to pixmaps. * * If the SVG is resized and re-rendered often (and does not keep using the * same small set of pixmap dimensions), then it may be less efficient to do * disk caching. A good example might be a progress meter that uses an Svg * object to paint itself: the meter will be changing often enough, with * enough unpredictability and without re-use of the previous pixmaps to * not get a gain from caching. * * Most Svg objects should use the caching feature, however. * Therefore, the default is to use the render cache. * * @param useCache true to cache rendered pixmaps * @since 4.3 */ void setUsingRenderingCache(bool useCache); /** * Whether the rendering cache is being used. * * @return @c true if the Svg object is using caching for rendering results * @since 4.3 */ bool isUsingRenderingCache() const; /** * Whether the current theme has this Svg, without any fallback * to the default theme involved * * @return true if the svg is loaded from the current theme * @see Theme::currentThemeHasImage */ bool fromCurrentTheme() const; /** * Sets wether the Svg uses the global system theme for its colors or * the Plasma theme. Default is False. * * @since 5.16 */ void setUseSystemColors(bool system); /** * @returns True if colors from the system theme are used. * Default is False * @since 5.16 */ bool useSystemColors() const; /** * Sets the Plasma::Theme to use with this Svg object. * * By default, Svg objects use Plasma::Theme::default(). * * This determines how relative image paths are interpreted. * * @param theme the theme object to use * @since 4.3 */ void setTheme(Plasma::Theme *theme); /** * The Plasma::Theme used by this Svg object. * * This determines how relative image paths are interpreted. * * @return the theme used by this Svg */ Theme *theme() const; /** * Sets the image in a selected status. * Svgs can be colored with system color themes, if the status is selected, * the TextColor will become HighlightedText color and BackgroundColor * will become HighlightColor, making the svg graphics (for instance an icon) * will look correct together selected text * Supported statuss as of 5.23 are Normal and Selected * @since 5.23 */ void setStatus(Svg::Status status); /** * @return the status of the Svg * @since 5.23 */ Svg::Status status() const; Q_SIGNALS: /** * Emitted whenever the SVG data has changed in such a way that a repaint is required. * Any usage of an Svg object that does the painting itself must connect to this signal * and respond by updating the painting. Note that connected to Theme::themeChanged is * incorrect in such a use case as the Svg itself may not be updated yet nor may theme * change be the only case when a repaint is needed. Also note that classes or QML code * which take Svg objects as parameters for their own painting all respond to this signal * so that in those cases manually responding to the signal is unnecessary; ONLY when * direct, manual painting with an Svg object is done in application code is this signal * used. */ void repaintNeeded(); /** * Emitted whenever the size of the Svg is changed. @see resize() */ void sizeChanged(); /** * Emitted whenever the image path of the Svg is changed. */ void imagePathChanged(); /** * Emitted whenever the color hint has changed. */ void colorHintChanged(); /** * Emitted whenever the color group has changed. */ void colorGroupChanged(); /** * Emitted when fromCurrentTheme() value has changed */ void fromCurrentThemeChanged(bool fromCurrentTheme); /** * Emitted when the status changes * @since 5.23 */ void statusChanged(Plasma::Svg::Status status); private: SvgPrivate *const d; - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *watched, QEvent *event) override; Q_PRIVATE_SLOT(d, void themeChanged()) Q_PRIVATE_SLOT(d, void colorsChanged()) friend class SvgPrivate; friend class FrameSvgPrivate; friend class FrameSvg; }; } // Plasma namespace #endif // multiple inclusion guard diff --git a/src/plasmaquick/appletquickitem.h b/src/plasmaquick/appletquickitem.h index 9bb8be969..7c88b500c 100644 --- a/src/plasmaquick/appletquickitem.h +++ b/src/plasmaquick/appletquickitem.h @@ -1,181 +1,181 @@ /* * Copyright 2014 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 APPLETQUICKITEM_H #define APPLETQUICKITEM_H #include #include #include #include #include #include #include // // W A R N I N G // ------------- // // This file is not part of the public Plasma API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // namespace Plasma { class Applet; } namespace KDeclarative { class QmlObject; } namespace PlasmaQuick { class AppletQuickItemPrivate; class PLASMAQUICK_EXPORT AppletQuickItem : public QQuickItem { Q_OBJECT Q_PROPERTY(int switchWidth READ switchWidth WRITE setSwitchWidth NOTIFY switchWidthChanged) Q_PROPERTY(int switchHeight READ switchHeight WRITE setSwitchHeight NOTIFY switchHeightChanged) Q_PROPERTY(QQmlComponent *compactRepresentation READ compactRepresentation WRITE setCompactRepresentation NOTIFY compactRepresentationChanged) Q_PROPERTY(QQuickItem *compactRepresentationItem READ compactRepresentationItem NOTIFY compactRepresentationItemChanged) Q_PROPERTY(QQmlComponent *fullRepresentation READ fullRepresentation WRITE setFullRepresentation NOTIFY fullRepresentationChanged) Q_PROPERTY(QQuickItem *fullRepresentationItem READ fullRepresentationItem NOTIFY fullRepresentationItemChanged) /** * this is supposed to be either one between compactRepresentation or fullRepresentation */ Q_PROPERTY(QQmlComponent *preferredRepresentation READ preferredRepresentation WRITE setPreferredRepresentation NOTIFY preferredRepresentationChanged) /** * True when the applet is showing its full representation. either as the main only view, or in a popup. * Setting it will open or close the popup if the plasmoid is iconified, however it won't have effect if the applet is open */ Q_PROPERTY(bool expanded WRITE setExpanded READ isExpanded NOTIFY expandedChanged) /** * True when the applet wants the activation signal act in toggle mode, i.e. while being expanded * the signal shrinks the applet to its not exanded state instead of reexpanding it. */ Q_PROPERTY(bool activationTogglesExpanded WRITE setActivationTogglesExpanded READ isActivationTogglesExpanded NOTIFY activationTogglesExpandedChanged) /** * the applet root QML item: sometimes is the same as fullRepresentationItem * if a fullrepresentation was not declared explicitly */ Q_PROPERTY(QObject *rootItem READ rootItem CONSTANT) public: AppletQuickItem(Plasma::Applet *applet, QQuickItem *parent = nullptr); - ~AppletQuickItem() Q_DECL_OVERRIDE; + ~AppletQuickItem() override; ////API NOT SUPPOSED TO BE USED BY QML Plasma::Applet *applet() const; //Make the constructor lighter and delay the actual instantiation of the qml in the applet virtual void init(); PLASMA_DEPRECATED Plasma::Package appletPackage() const; PLASMA_DEPRECATED void setAppletPackage(const Plasma::Package &package); PLASMA_DEPRECATED Plasma::Package coronaPackage() const; PLASMA_DEPRECATED void setCoronaPackage(const Plasma::Package &package); QQuickItem *compactRepresentationItem(); QQuickItem *fullRepresentationItem(); QObject *rootItem(); QObject *testItem(); ////PROPERTY ACCESSORS int switchWidth() const; void setSwitchWidth(int width); int switchHeight() const; void setSwitchHeight(int width); QQmlComponent *compactRepresentation(); void setCompactRepresentation(QQmlComponent *component); QQmlComponent *fullRepresentation(); void setFullRepresentation(QQmlComponent *component); QQmlComponent *preferredRepresentation(); void setPreferredRepresentation(QQmlComponent *component); bool isExpanded() const; void setExpanded(bool expanded); bool isActivationTogglesExpanded() const; void setActivationTogglesExpanded(bool activationTogglesExpanded); ////NEEDED BY QML TO CREATE ATTACHED PROPERTIES static AppletQuickItem *qmlAttachedProperties(QObject *object); Q_SIGNALS: //Property signals void switchWidthChanged(int width); void switchHeightChanged(int height); void expandedChanged(bool expanded); void activationTogglesExpandedChanged(bool activationTogglesExpanded); void compactRepresentationChanged(QQmlComponent *compactRepresentation); void fullRepresentationChanged(QQmlComponent *fullRepresentation); void preferredRepresentationChanged(QQmlComponent *preferredRepresentation); void compactRepresentationItemChanged(QObject *compactRepresentationItem); void fullRepresentationItemChanged(QObject *fullRepresentationItem); protected: KDeclarative::QmlObject *qmlObject(); //Reimplementation - void childEvent(QChildEvent *event) Q_DECL_OVERRIDE; - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; - void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void childEvent(QChildEvent *event) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void itemChange(ItemChange change, const ItemChangeData &value) override; private: AppletQuickItemPrivate *const d; Q_PRIVATE_SLOT(d, void minimumWidthChanged()) Q_PRIVATE_SLOT(d, void minimumHeightChanged()) Q_PRIVATE_SLOT(d, void preferredWidthChanged()) Q_PRIVATE_SLOT(d, void preferredHeightChanged()) Q_PRIVATE_SLOT(d, void maximumWidthChanged()) Q_PRIVATE_SLOT(d, void maximumHeightChanged()) Q_PRIVATE_SLOT(d, void fillWidthChanged()) Q_PRIVATE_SLOT(d, void fillHeightChanged()) }; } QML_DECLARE_TYPEINFO(PlasmaQuick::AppletQuickItem, QML_HAS_ATTACHED_PROPERTIES) #endif diff --git a/src/plasmaquick/configmodel.h b/src/plasmaquick/configmodel.h index dbf4841ec..fb5b571ad 100644 --- a/src/plasmaquick/configmodel.h +++ b/src/plasmaquick/configmodel.h @@ -1,134 +1,134 @@ /* * Copyright 2013 Marco Martin * Copyright 2015 Eike Hein * * 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 // // W A R N I N G // ------------- // // This file is not part of the public Plasma API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // namespace Plasma { class Applet; } namespace PlasmaQuick { class ConfigPropertyMap; 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 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, VisibleRole, KCMRole }; explicit ConfigModel(QObject *parent = nullptr); - ~ConfigModel() Q_DECL_OVERRIDE; + ~ConfigModel() override; /** * add a new category in the model * @param ConfigCategory the new category **/ void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName); Q_INVOKABLE void appendCategory(const QString &iconName, const QString &name, const QString &path, const QString &pluginName, bool visible); // QML Engine isn't particulary smart resolving namespaces, hence fully qualified signature Q_INVOKABLE void appendCategory(PlasmaQuick::ConfigCategory *category); Q_INVOKABLE void removeCategory(PlasmaQuick::ConfigCategory *category); Q_INVOKABLE void removeCategoryAt(int index); /** * clears the model **/ void clear(); void setApplet(Plasma::Applet *interface); Plasma::Applet *applet() const; int count() { return rowCount(); } - int rowCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE; - QVariant data(const QModelIndex &, int) const Q_DECL_OVERRIDE; - QHash roleNames() const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &index = QModelIndex()) const override; + QVariant data(const QModelIndex &, int) const override; + QHash roleNames() const override; /** * @param row the row for which the data will be returned * @return the data of the specified row **/ Q_INVOKABLE QVariant get(int row) const; /** * @return the categories of the model **/ QQmlListProperty categories(); 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.h b/src/plasmaquick/configview.h index 985c5d8bf..52dea11c8 100644 --- a/src/plasmaquick/configview.h +++ b/src/plasmaquick/configview.h @@ -1,94 +1,94 @@ /* * 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 CONFIGVIEW_H #define CONFIGVIEW_H #include #include // // W A R N I N G // ------------- // // This file is not part of the public Plasma API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // namespace Plasma { class Applet; } namespace PlasmaQuick { class ConfigViewPrivate; class ConfigModel; class PLASMAQUICK_EXPORT ConfigView : public QQuickView { Q_OBJECT Q_PROPERTY(PlasmaQuick::ConfigModel *configModel READ configModel CONSTANT) Q_PROPERTY(QString appletGlobalShortcut READ appletGlobalShortcut WRITE setAppletGlobalShortcut NOTIFY appletGlobalShortcutChanged) public: /** * @param applet the applet of this ConfigView * @param parent the QWindow in which this ConfigView is parented to **/ ConfigView(Plasma::Applet *applet, QWindow *parent = nullptr); - ~ConfigView() Q_DECL_OVERRIDE; + ~ConfigView() override; virtual void init(); Plasma::Applet *applet(); QString appletGlobalShortcut() const; void setAppletGlobalShortcut(const QString &shortcut); /** * @return the ConfigModel of the ConfigView **/ PlasmaQuick::ConfigModel *configModel() const; Q_SIGNALS: void appletGlobalShortcutChanged(); protected: - void hideEvent(QHideEvent *ev) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *re) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent *ev) override; + void resizeEvent(QResizeEvent *re) override; private: ConfigViewPrivate *const d; Q_PRIVATE_SLOT(d, void updateMinimumWidth()) Q_PRIVATE_SLOT(d, void updateMinimumHeight()) Q_PRIVATE_SLOT(d, void updateMaximumWidth()) Q_PRIVATE_SLOT(d, void updateMaximumHeight()) }; } #endif // multiple inclusion guard diff --git a/src/plasmaquick/dialog.h b/src/plasmaquick/dialog.h index 5482b6d8f..27eb84a98 100644 --- a/src/plasmaquick/dialog.h +++ b/src/plasmaquick/dialog.h @@ -1,260 +1,260 @@ /*************************************************************************** * Copyright 2011 Marco Martin * * Copyright 2013 Sebastian Kügler * * * * 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 02110-1301 USA . * ***************************************************************************/ #ifndef DIALOG_PROXY_P #define DIALOG_PROXY_P #include #include #include #include #include #include #include #include // // W A R N I N G // ------------- // // This file is not part of the public Plasma API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // class QQuickItem; class QScreen; namespace PlasmaQuick { class DialogPrivate; /** * @class Dialog * * Dialog creates a Plasma themed top level window that can contain any QML component. * * It can be automatically positioned relative to a visual parent * The dialog will resize to the size of the main item * * @code{.qml} * import QtQuick 2.0 * import org.kde.plasma.core 2.0 as PlasmaCore * Item { * PlasmaCore.Dialog { * visible: true * mainItem: Item { * width: 500 * height: 500 * * Text { * anchors.centerIn: parent * color: "red" * text: "text" * } * } * } * } * @endcode * */ class PLASMAQUICK_EXPORT Dialog : public QQuickWindow, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) /** * The main QML item that will be displayed in the Dialog */ Q_PROPERTY(QQuickItem *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged) /** * The main QML item that will be displayed in the Dialog */ Q_PROPERTY(QQuickItem *visualParent READ visualParent WRITE setVisualParent NOTIFY visualParentChanged) /** * Margins of the dialog around the mainItem. * @see DialogMargins */ Q_PROPERTY(QObject *margins READ margins CONSTANT) /** * Plasma Location of the dialog window. Useful if this dialog is a popup for a panel */ Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged) /** * Type of the window */ Q_PROPERTY(WindowType type READ type WRITE setType NOTIFY typeChanged) /** * Whether the dialog should be hidden when the dialog loses focus. * * The default value is @c false. **/ Q_PROPERTY(bool hideOnWindowDeactivate READ hideOnWindowDeactivate WRITE setHideOnWindowDeactivate NOTIFY hideOnWindowDeactivateChanged) /** * Whether the dialog is output only. Default value is @c false. If it is @c true * the dialog does not accept input and all pointer events are not accepted, thus the dialog * is click through. * * This property is currently only supported on the X11 platform. On any other platform the * property has no effect. **/ Q_PROPERTY(bool outputOnly READ isOutputOnly WRITE setOutputOnly NOTIFY outputOnlyChanged) /** * This property holds the window flags of the window. * The window flags control the window's appearance in the windowing system, * whether it's a dialog, popup, or a regular window, and whether it should * have a title bar, etc. * Regardless to what the user sets, the flags will always have the * FramelessWindowHint flag set */ Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFramelessFlags NOTIFY flagsChanged) /** * This property holds how (and if at all) the dialog should draw its own background * or if it is complete responsibility of the content item to render a background. * Note that in case of NoBackground it loses kwin side shadows and blur */ Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints NOTIFY backgroundHintsChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChangedProxy) Q_CLASSINFO("DefaultProperty", "mainItem") public: enum WindowType { Normal = NET::Normal, Dock = NET::Dock, DialogWindow = NET::Dialog, PopupMenu = NET::PopupMenu, Tooltip = NET::Tooltip, Notification = NET::Notification, OnScreenDisplay = NET::OnScreenDisplay }; Q_ENUM(WindowType) enum BackgroundHints { NoBackground = 0, /**< Not drawing a background under the applet, the dialog has its own implementation */ StandardBackground = 1 /**< The standard background from the theme is drawn */ }; Q_ENUM(BackgroundHints) explicit Dialog(QQuickItem *parent = nullptr); - ~Dialog() Q_DECL_OVERRIDE; + ~Dialog() override; //PROPERTIES ACCESSORS QQuickItem *mainItem() const; void setMainItem(QQuickItem *mainItem); QQuickItem *visualParent() const; void setVisualParent(QQuickItem *visualParent); Plasma::Types::Location location() const; void setLocation(Plasma::Types::Location location); QObject *margins() const; void setFramelessFlags(Qt::WindowFlags flags); void setType(WindowType type); WindowType type() const; bool hideOnWindowDeactivate() const; void setHideOnWindowDeactivate(bool hide); void setOutputOnly(bool outputOnly); bool isOutputOnly() const; BackgroundHints backgroundHints() const; void setBackgroundHints(BackgroundHints hints); bool isVisible() const; void setVisible(bool visible); /** * @returns The suggested screen position for the popup * @param item the item the popup has to be positioned relatively to. if null, the popup will be positioned in the center of the window * @param size the size that the popup will have, which influences the final position */ virtual QPoint popupPosition(QQuickItem *item, const QSize &size); Q_SIGNALS: void mainItemChanged(); void locationChanged(); void visualParentChanged(); void typeChanged(); void hideOnWindowDeactivateChanged(); void outputOnlyChanged(); void flagsChanged(); void backgroundHintsChanged(); void visibleChangedProxy(); //redeclaration of QQuickWindow::visibleChanged /** * Emitted when the @see hideOnWindowDeactivate property is @c true and this dialog lost focus to a * window that is neither a parent dialog to nor a child dialog of this dialog. */ void windowDeactivated(); protected: /** * set the dialog position. subclasses may change it. ToolTipDialog adjusts the position in an animated way */ virtual void adjustGeometry(const QRect &geom); //Reimplementations - void classBegin() Q_DECL_OVERRIDE; - void componentComplete() Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *re) Q_DECL_OVERRIDE; - void focusInEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; - void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE; - void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; - void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE; - bool event(QEvent *event) Q_DECL_OVERRIDE; + void classBegin() override; + void componentComplete() override; + void resizeEvent(QResizeEvent *re) override; + void focusInEvent(QFocusEvent *ev) override; + void focusOutEvent(QFocusEvent *ev) override; + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; + bool event(QEvent *event) override; private: friend class DialogPrivate; DialogPrivate *const d; Q_PRIVATE_SLOT(d, void updateInputShape()) Q_PRIVATE_SLOT(d, void updateTheme()) Q_PRIVATE_SLOT(d, void updateVisibility(bool visible)) Q_PRIVATE_SLOT(d, void updateMinimumWidth()) Q_PRIVATE_SLOT(d, void updateMinimumHeight()) Q_PRIVATE_SLOT(d, void updateMaximumWidth()) Q_PRIVATE_SLOT(d, void updateMaximumHeight()) Q_PRIVATE_SLOT(d, void updateLayoutParameters()) Q_PRIVATE_SLOT(d, void slotMainItemSizeChanged()) }; } #endif diff --git a/src/plasmaquick/packageurlinterceptor.h b/src/plasmaquick/packageurlinterceptor.h index 5816bb154..b97ef038a 100644 --- a/src/plasmaquick/packageurlinterceptor.h +++ b/src/plasmaquick/packageurlinterceptor.h @@ -1,98 +1,98 @@ /* * 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 #include #include // // W A R N I N G // ------------- // // This file is not part of the public Plasma API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // class QQmlEngine; namespace PlasmaQuick { class PackageUrlInterceptorPrivate; //depends from https://codereview.qt-project.org/#change,65626 class PLASMAQUICK_EXPORT PackageUrlInterceptor: public QQmlAbstractUrlInterceptor { public: PackageUrlInterceptor(QQmlEngine *engine, const KPackage::Package &p); - ~PackageUrlInterceptor() Q_DECL_OVERRIDE; + ~PackageUrlInterceptor() override; void addAllowedPath(const QString &path); void removeAllowedPath(const QString &path); QStringList allowedPaths() const; bool forcePlasmaStyle() const; void setForcePlasmaStyle(bool force); - QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type) Q_DECL_OVERRIDE; + QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type) override; static inline QByteArray prefixForType(QQmlAbstractUrlInterceptor::DataType type, const QString &fileName) { switch (type) { case QQmlAbstractUrlInterceptor::QmlFile: return QByteArray("ui"); case QQmlAbstractUrlInterceptor::JavaScriptFile: return QByteArray("code"); default: break; } //failed by type, let's try by extension const QString &extension = fileName.mid(fileName.lastIndexOf(QLatin1Char('.')) + 1).toLower(); if (extension == QStringLiteral("svg") || extension == QStringLiteral("svgz") || extension == QStringLiteral("png") || extension == QStringLiteral("gif") || extension == QStringLiteral("jpg") || extension == QStringLiteral("jpeg")) { return QByteArray("images"); //FIXME: are those necessary? are they *always* catched by type? } else if (extension == QStringLiteral("js")) { return QByteArray("code"); } else if (extension == QStringLiteral("qml") || extension == QStringLiteral("qmldir")) { return QByteArray("ui"); //everything else, throw it in "data" } else { return QByteArray("data"); } } private: PackageUrlInterceptorPrivate *const d; }; } #endif diff --git a/src/plasmaquick/private/packages.h b/src/plasmaquick/private/packages.h index 144f5009c..bdd02b7b7 100644 --- a/src/plasmaquick/private/packages.h +++ b/src/plasmaquick/private/packages.h @@ -1,49 +1,49 @@ /****************************************************************************** * Copyright 2007 by Aaron Seigo * * Copyright 2013 by Marco Martin * * Copyright 2013 by Sebastian Kügler * * * * This library 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 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public License * * along with this library; see the file COPYING.LIB. If not, write to * * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301, USA. * *******************************************************************************/ #ifndef SHELLPACKAGES_H #define SHELLPACKAGES_H #include #include class LookAndFeelPackage : public Plasma::PackageStructure { Q_OBJECT public: - void initPackage(Plasma::Package *package) Q_DECL_OVERRIDE; + void initPackage(Plasma::Package *package) override; }; class QmlWallpaperPackage : public Plasma::PackageStructure { Q_OBJECT public: - void initPackage(Plasma::Package *package) Q_DECL_OVERRIDE; + void initPackage(Plasma::Package *package) override; }; class LayoutTemplatePackage : public Plasma::PackageStructure { Q_OBJECT public: - void initPackage(Plasma::Package *package) Q_DECL_OVERRIDE; + void initPackage(Plasma::Package *package) override; }; #endif // LOOKANDFEELPACKAGE_H diff --git a/src/plasmaquick/shellpluginloader.h b/src/plasmaquick/shellpluginloader.h index e7cfae75d..18a8815f3 100644 --- a/src/plasmaquick/shellpluginloader.h +++ b/src/plasmaquick/shellpluginloader.h @@ -1,42 +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 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 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 SHELLPLUGINLOADER_H #define SHELLPLUGINLOADER_H #include #include /** * @deprecated, don't use */ class PLASMAQUICK_DEPRECATED_EXPORT ShellPluginLoader : public Plasma::PluginLoader { public: ShellPluginLoader(); - ~ShellPluginLoader() Q_DECL_OVERRIDE; + ~ShellPluginLoader() override; static void init(); protected: - Plasma::Package internalLoadPackage(const QString &packageFormat, const QString &specialization) Q_DECL_OVERRIDE; + Plasma::Package internalLoadPackage(const QString &packageFormat, const QString &specialization) override; }; #endif diff --git a/src/scriptengines/qml/plasmoid/appletinterface.h b/src/scriptengines/qml/plasmoid/appletinterface.h index 005826966..7423c43cf 100644 --- a/src/scriptengines/qml/plasmoid/appletinterface.h +++ b/src/scriptengines/qml/plasmoid/appletinterface.h @@ -1,480 +1,480 @@ /* * Copyright 2008 Chani Armitage * Copyright 2008, 2009 Aaron Seigo * Copyright 2010 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 APPLETINTERFACE_H #define APPLETINTERFACE_H #include #include #include #include #include #include "declarativeappletscript.h" class QAction; class QmlAppletScript; class QSizeF; namespace KDeclarative { class ConfigPropertyMap; class QmlObject; } namespace Plasma { class ConfigLoader; } // namespace Plasma /** * @class AppletInterface * * @short This class is exposed to applets in QML as the attached property Plasmoid * * \@import org.kde.plasma.Plasmoid */ class AppletInterface : public PlasmaQuick::AppletQuickItem { Q_OBJECT /** * The QML root object defined in the applet main.qml will be direct child of an AppletInterface instance */ /** * Version of the QML2 script engine */ Q_PROPERTY(int apiVersion READ apiVersion CONSTANT) /** * Plugin name of the plasmoid */ Q_PROPERTY(QString pluginName READ pluginName CONSTANT) /** * User friendly title for the plasmoid: it's the localized applet name by default */ Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) /** * Main title for the plasmoid tooltip or other means of quick information: * it's the same as the title property by default, but it can be personalized */ Q_PROPERTY(QString toolTipMainText READ toolTipMainText WRITE setToolTipMainText NOTIFY toolTipMainTextChanged) /** * Description for the plasmoid tooltip or other means of quick information: * it comes from the pluginifo comment by default, but it can be personalized */ Q_PROPERTY(QString toolTipSubText READ toolTipSubText WRITE setToolTipSubText NOTIFY toolTipSubTextChanged) /** * how to handle the text format of the tooltip subtext: * * Text.AutoText (default) * * Text.PlainText * * Text.StyledText * * Text.RichText * Note: in the default implementation the main text is always plain text */ Q_PROPERTY(int toolTipTextFormat READ toolTipTextFormat WRITE setToolTipTextFormat NOTIFY toolTipTextFormatChanged) /** * This allows to set custom full QML items as the tooltip. * It will ignore all texts set by setToolTipMainText or setToolTipSubText * * @since: 5.19 */ Q_PROPERTY(QQuickItem *toolTipItem READ toolTipItem WRITE setToolTipItem NOTIFY toolTipItemChanged) /** * Icon to represent the plasmoid */ 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 */ Q_PROPERTY(uint id READ id CONSTANT) /** * FormFactor for the plasmoid */ Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged) /** * Location for the plasmoid */ Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged) /** * Current activity name the plasmoid is in */ Q_PROPERTY(QString currentActivity READ currentActivity NOTIFY contextChanged) /** * Configuration object: each config key will be a writable property of this object. property bindings work. */ Q_PROPERTY(QObject *configuration READ configuration CONSTANT) /** * When true the plasmoid is busy. The containment may graphically indicate that drawing for instance a spinner busy widget over it */ Q_PROPERTY(bool busy WRITE setBusy READ isBusy NOTIFY busyChanged) /** * How the applet wants its background to be drawn. The containment may chose to ignore this hint. */ Q_PROPERTY(Plasma::Types::BackgroundHints backgroundHints WRITE setBackgroundHints READ backgroundHints NOTIFY backgroundHintsChanged) /** * Whether the Corona is immutable. The plasmoid implementation should avoid allowing "dangerous" modifications from the user when in an immutable mode * * This is true when immutability is not Mutable */ Q_PROPERTY(bool immutable READ immutable NOTIFY immutabilityChanged) /** * The immutability of the Corona. * * Use this if you need more granular control than just using the immutable property * * @see immutable * @since 5.23 */ Q_PROPERTY(Plasma::Types::ImmutabilityType immutability READ immutability NOTIFY immutabilityChanged) /** * True when the user is configuring, for instance when the configuration dialog is open. */ Q_PROPERTY(bool userConfiguring READ userConfiguring NOTIFY userConfiguringChanged) /** * Status of the plasmoid: useful to instruct the shell if this plasmoid is requesting attention, if is accepting input, or if is in an idle, inactive state */ Q_PROPERTY(Plasma::Types::ItemStatus status READ status WRITE setStatus NOTIFY statusChanged) /** * Sets the associated application of this plasmoid, if the plasmoid is representing the "compact" view for some application or for some document type. */ Q_PROPERTY(QString associatedApplication WRITE setAssociatedApplication READ associatedApplication NOTIFY associatedApplicationChanged) /** * Sets the associated application of this plasmoid, if the plasmoid is representing the "compact" view for some application or for some document type. */ Q_PROPERTY(QList associatedApplicationUrls WRITE setAssociatedApplicationUrls READ associatedApplicationUrls NOTIFY associatedApplicationUrlsChanged) // TODO: This was moved up from ContainmentInterface because it is required by the // Task Manager applet (for "Show only tasks from this screen") and no Qt API exposes // screen numbering. An alternate solution that doesn't extend the applet interface // would be preferable if found. Q_PROPERTY(int screen READ screen NOTIFY screenChanged) /** * Provides access to the geometry of the applet is in. * Can be useful to figure out what's the absolute position of the applet. */ Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) /** * Whether the dialog should be hidden when the dialog loses focus. * * The default value is @c false. **/ Q_PROPERTY(bool hideOnWindowDeactivate READ hideOnWindowDeactivate WRITE setHideOnWindowDeactivate NOTIFY hideOnWindowDeactivateChanged) /** * The global shortcut to activate the plasmoid * * This is typically only used by the default configuration module * */ Q_PROPERTY(QKeySequence globalShortcut READ globalShortcut WRITE setGlobalShortcut NOTIFY globalShortcutChanged) /** * An interface to the native C++ plasmoid, if implemented */ Q_PROPERTY(QObject *nativeInterface READ nativeInterface CONSTANT) /** * If true the applet requires manual configuration from the user */ Q_PROPERTY(bool configurationRequired READ configurationRequired WRITE setConfigurationRequiredProperty NOTIFY configurationRequiredChanged) /** * Reason why the manual user configuration is required */ Q_PROPERTY(QString configurationRequiredReason READ configurationRequiredReason WRITE setConfigurationRequiredReason NOTIFY configurationRequiredReasonChanged) /** * screen area free of panels: the coordinates are relative to the containment, * it's independent from the screen position * For more precise available geometry use availableScreenRegion() */ Q_PROPERTY(QRect availableScreenRect READ availableScreenRect NOTIFY availableScreenRectChanged) /** * The available region of this screen, panels excluded. It's a list of rectangles */ Q_PROPERTY(QVariantList availableScreenRegion READ availableScreenRegion NOTIFY availableScreenRegionChanged) public: AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = nullptr); - ~AppletInterface() Q_DECL_OVERRIDE; + ~AppletInterface() override; //API not intended for the QML part DeclarativeAppletScript *appletScript() const; QList contextualActions() const; void executeAction(const QString &name); //QML API------------------------------------------------------------------- /** * Set this to true if the plasmoid needs to be configured in order to work. The containment will display reason as a message to ask the user to configure. * @param needsConfiguring If the plasmoid needs configuration * @param reason The user readable (and localized) reason the plasmoid needs */ Q_INVOKABLE void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); Q_INVOKABLE void setActionSeparator(const QString &name); /** * Add an action to the Plasmoid contextual menu. * When the action is triggered a function called action_ will be called, if there is no function with that name actionTriggered(name) will be called instead. * @param: action name * @text: user visible displayed text * @icon: user visible optional displayed icon * @shortcut: shortcut to trigger this action */ Q_INVOKABLE void setAction(const QString &name, const QString &text, const QString &icon = QString(), const QString &shortcut = QString()); Q_INVOKABLE void removeAction(const QString &name); Q_INVOKABLE void clearActions(); 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 */ 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" * @returns the full absolute path of the file, if found, an empty string if not */ Q_INVOKABLE QString file(const QString &fileType, const QString &filePath); /** * @returns A path where it is safe to write on disk downloaded files. * @since 5.23 */ Q_INVOKABLE QString downloadPath() const; /** * @returns A path where it is safe to write on disk downloaded files. * @param file that name of the file to download (unused). * @deprecated Use downloadPath() instead. */ Q_INVOKABLE PLASMA_DEPRECATED QString downloadPath(const QString &file); /** * @returns The list of files that have been downloaded */ Q_INVOKABLE QStringList downloadedFiles() const; QVariantList availableScreenRegion() const; QRect availableScreenRect() const; static AppletInterface *qmlAttachedProperties(QObject *object) { return qobject_cast(AppletQuickItem::qmlAttachedProperties(object)); } //PROPERTY ACCESSORS------------------------------------------------------------------- QString pluginName() const; QString icon() const; void setIcon(const QString &icon); QString title() const; void setTitle(const QString &title); QString toolTipMainText() const; void setToolTipMainText(const QString &text); QString toolTipSubText() const; void setToolTipSubText(const QString &text); int toolTipTextFormat() const; void setToolTipTextFormat(int format); QQuickItem *toolTipItem() const; void setToolTipItem(QQuickItem *toolTipItem); uint id() const; Plasma::Types::FormFactor formFactor() const; Plasma::Types::Location location() const; QString currentActivity() const; QObject *configuration() const; bool isBusy() const; void setBusy(bool busy); Plasma::Types::BackgroundHints backgroundHints() const; void setBackgroundHints(Plasma::Types::BackgroundHints hint); void setAssociatedApplication(const QString &string); QString associatedApplication() const; void setAssociatedApplicationUrls(const QList &urls); QList associatedApplicationUrls() const; void setStatus(const Plasma::Types::ItemStatus &status); Plasma::Types::ItemStatus status() const; int screen() const; QRect screenGeometry() const; bool immutable() const; Plasma::Types::ImmutabilityType immutability() const; bool userConfiguring() const; int apiVersion() const; bool hideOnWindowDeactivate() const; void setHideOnWindowDeactivate(bool hide); QKeySequence globalShortcut() const; void setGlobalShortcut(const QKeySequence &keySequence); QObject *nativeInterface(); //NOTE: setConfigurationRequiredProperty because ambiguous with the // setConfigurationRequired invokable bool configurationRequired() const; void setConfigurationRequiredProperty(bool required); QString configurationRequiredReason() const; void setConfigurationRequiredReason(const QString &reason); 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 configNeedsSaving(); /** * Emitted when the applet's activation action is triggered */ void activated(); /** * Emitted just before the contextual actions are about to show * For instance just before the context menu containing the actions * added with setAction() is shown */ void contextualActionsAboutToShow(); //PROPERTY change notifiers-------------- void iconChanged(); void titleChanged(); void toolTipMainTextChanged(); void toolTipSubTextChanged(); void toolTipTextFormatChanged(); void toolTipItemChanged(); void formFactorChanged(); void locationChanged(); void contextChanged(); void immutabilityChanged(); void statusChanged(); void backgroundHintsChanged(); void busyChanged(); void screenChanged(); void screenGeometryChanged(); void hideOnWindowDeactivateChanged(); void associatedApplicationChanged(); void associatedApplicationUrlsChanged(); void availableScreenRegionChanged(); void availableScreenRectChanged(); void userConfiguringChanged(); void globalShortcutChanged(); void configurationRequiredChanged(); void configurationRequiredReasonChanged(); protected Q_SLOTS: - void init() Q_DECL_OVERRIDE; + void init() override; protected: - bool event(QEvent *event) Q_DECL_OVERRIDE; - bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + bool event(QEvent *event) override; + bool eventFilter(QObject *watched, QEvent *event) override; private Q_SLOTS: void destroyedChanged(bool destroyed); private: QStringList m_actions; KDeclarative::ConfigPropertyMap *m_configuration; DeclarativeAppletScript *m_appletScriptEngine; //UI-specific members ------------------ QString m_toolTipMainText; QString m_toolTipSubText; int m_toolTipTextFormat; QPointer m_toolTipItem; QVariantList m_args; Plasma::Types::BackgroundHints m_backgroundHints; bool m_hideOnDeactivate : 1; //this is used to build an emacs style shortcut int m_oldKeyboardShortcut; QObject *m_dummyNativeInterface; friend class ContainmentInterface; //This is used by ContainmentInterface QPointF m_positionBeforeRemoval; }; QML_DECLARE_TYPEINFO(AppletInterface, QML_HAS_ATTACHED_PROPERTIES) #endif diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index 4f4008dc2..ea2245375 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -1,226 +1,226 @@ /* * Copyright 2008-2013 Aaron Seigo * Copyright 2010-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 CONTAINMENTINTERFACE_H #define CONTAINMENTINTERFACE_H #include #include #include "appletinterface.h" class WallpaperInterface; namespace KIO { class Job; class DropJob; } namespace KActivities { class Info; } /** * @class ContainmentInterface * * @brief This class is exposed to containments QML as the attached property Plasmoid * * */ class ContainmentInterface : public AppletInterface { Q_OBJECT /** * List of applets this containment has: the containments */ Q_PROPERTY(QList applets READ applets NOTIFY appletsChanged) /** * Type of this containment TODO: notify */ Q_PROPERTY(Plasma::Types::ContainmentType containmentType READ containmentType WRITE setContainmentType NOTIFY containmentTypeChanged) /** * Activity name of this containment */ Q_PROPERTY(QString activity READ activity NOTIFY activityChanged) /** * Activity name of this containment */ Q_PROPERTY(QString activityName READ activityName NOTIFY activityNameChanged) /** * Actions associated to this containment or corona */ Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) /** * True when the containment is in an edit mode that allows to move * things around: it's different from userConfiguring as it's about * editing plasmoids inside the containment, rather than the containment * settings dialog itself */ Q_PROPERTY(bool editMode READ isEditMode WRITE setEditMode NOTIFY editModeChanged) public: ContainmentInterface(DeclarativeAppletScript *parent, const QVariantList &args = QVariantList()); //Not for QML Plasma::Containment *containment() const { return m_containment.data(); } inline WallpaperInterface *wallpaperInterface() const { return m_wallpaperInterface; } //For QML use QList applets(); Plasma::Types::ContainmentType containmentType() const; void setContainmentType(Plasma::Types::ContainmentType type); QString activity() const; QString activityName() const; QList actions() const; /** * Process the mime data arrived to a particular coordinate, either with a drag and drop or paste with middle mouse button */ Q_INVOKABLE void processMimeData(QMimeData *data, int x, int y, KIO::DropJob *dropJob = nullptr); /** * Process the mime data arrived to a particular coordinate, either with a drag and drop or paste with middle mouse button */ Q_INVOKABLE void processMimeData(QObject *data, int x, int y, KIO::DropJob *dropJob = nullptr); /** * Search for a containment at those coordinates. * the coordinates are passed as local coordinates of *this* containment */ Q_INVOKABLE QObject *containmentAt(int x, int y); /** * Add an existing applet to this containment. * The coordinates are passed as local coordinates of this containment */ Q_INVOKABLE void addApplet(AppletInterface *applet, int x, int y); /** * Map coordinates from relative to the given applet to relative to this containment */ Q_INVOKABLE QPointF mapFromApplet(AppletInterface *applet, int x, int y); /** *Map coordinates from relative to this containment to relative to the given applet */ Q_INVOKABLE QPointF mapToApplet(AppletInterface *applet, int x, int y); /** * Given a geometry, it adjusts it moving it completely inside of the boundaries * of availableScreenRegion * @return the toLeft point of the rectangle */ Q_INVOKABLE QPointF adjustToAvailableScreenRegion(int x, int y, int w, int h) const; bool isEditMode() const; void setEditMode(bool edit); static ContainmentInterface *qmlAttachedProperties(QObject *object) { return qobject_cast(AppletQuickItem::qmlAttachedProperties(object)); } protected: - void init() Q_DECL_OVERRIDE; - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; - void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; + void init() override; + void mousePressEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event); void addContainmentActions(QMenu *desktopMenu, QEvent *event); Q_SIGNALS: /** * Emitted when an applet is added * @param applet the applet object: it's a qml graphical object and an instance of AppletInterface * @param x coordinate containment relative * @param y coordinate containment relative */ void appletAdded(QObject *applet, int x, int y); /** * Emitted when an applet is removed * @param applet the applet object: it's a qml graphical object and an instance of AppletInterface. * It's still valid, even if it will be deleted shortly */ void appletRemoved(QObject *applet); //Property notifiers void activityChanged(); void activityNameChanged(); void appletsChanged(); void drawWallpaperChanged(); void containmentTypeChanged(); void actionsChanged(); void editModeChanged(); protected Q_SLOTS: void appletAddedForward(Plasma::Applet *applet); void appletRemovedForward(Plasma::Applet *applet); void loadWallpaper(); void dropJobResult(KJob *job); void mimeTypeRetrieved(KIO::Job *job, const QString &mimetype); private Q_SLOTS: Plasma::Applet *createApplet(const QString &plugin, const QVariantList &args, const QPoint &pos); Plasma::Applet *createApplet(const QString &plugin, const QVariantList &args, const QRectF &geom); private: void clearDataForMimeJob(KIO::Job *job); void setAppletArgs(Plasma::Applet *applet, const QString &mimetype, const QString &data); WallpaperInterface *m_wallpaperInterface; QList m_appletInterfaces; QHash m_dropPoints; QHash m_dropMenus; QHash m_dropCallbacks; QHash m_dropJobs; KActivities::Info *m_activityInfo; QPointer m_containment; QWeakPointer m_contextMenu; int m_wheelDelta; bool m_editMode : 1; friend class AppletInterface; }; QML_DECLARE_TYPEINFO(ContainmentInterface, QML_HAS_ATTACHED_PROPERTIES) #endif diff --git a/src/scriptengines/qml/plasmoid/declarativeappletscript.h b/src/scriptengines/qml/plasmoid/declarativeappletscript.h index a7d81398d..66d35dcea 100644 --- a/src/scriptengines/qml/plasmoid/declarativeappletscript.h +++ b/src/scriptengines/qml/plasmoid/declarativeappletscript.h @@ -1,64 +1,64 @@ /* * Copyright 2009 by Alan Alpert * Copyright 2010 by Ménard Alexis * 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 DECLARATIVE_APPLETSCRIPT_H #define DECLARATIVE_APPLETSCRIPT_H #include #include #include class AppletInterface; class DeclarativeAppletScript : public Plasma::AppletScript { Q_OBJECT public: DeclarativeAppletScript(QObject *parent, const QVariantList &args); - ~DeclarativeAppletScript() Q_DECL_OVERRIDE; + ~DeclarativeAppletScript() override; QString filePath(const QString &type, const QString &file) const; - QList contextualActions() Q_DECL_OVERRIDE; + QList contextualActions() override; - void constraintsEvent(Plasma::Types::Constraints constraints) Q_DECL_OVERRIDE; + void constraintsEvent(Plasma::Types::Constraints constraints) override; public Q_SLOTS: void executeAction(const QString &name); protected: - bool init() Q_DECL_OVERRIDE; + bool init() override; Q_SIGNALS: void formFactorChanged(); void locationChanged(); void contextChanged(); private: AppletInterface *m_interface; QVariantList m_args; friend class AppletLoader; friend class AppletInterface; friend class ContainmentInterface; }; #endif diff --git a/tests/testengine/testengine.h b/tests/testengine/testengine.h index ade92bcdb..1c5b55751 100644 --- a/tests/testengine/testengine.h +++ b/tests/testengine/testengine.h @@ -1,47 +1,47 @@ /* * Copyright (C) 2008 Gilles CHAUVIN * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License either version 2, or * (at your option) any later version as published by the Free Software * Foundation. * * 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 02110-1301, USA. */ /* * A data engine meant to test the Plasma data engine explorer. */ #ifndef __TESTDATAENGINE_H__ #define __TESTDATAENGINE_H__ #include "plasma/dataengine.h" class TestEngine : public Plasma::DataEngine { Q_OBJECT public: struct MyUserType { int a; QString b; }; TestEngine(QObject *parent, const QVariantList &args); ~TestEngine(); protected: void init(); - bool sourceRequestEvent(const QString &source) Q_DECL_OVERRIDE; + bool sourceRequestEvent(const QString &source) override; }; #endif // __TESTDATAENGINE_H__