shell/containmentconfigview.h -> plasmaview/containmentconfigview.h shell/currentcontainmentactionsmodel.cpp -> plasmaview/currentcontainmentactionsmodel_p.cpp shell/currentcontainmentactionsmodel.h -> plasmaview/currentcontainmentactionsmodel_p.h shell/view.cpp -> plasmaview/view.cpp shell/view.h -> plasmaview/view.hwilder-5.14
parent
11847b6702
commit
49c2218c4e
6 changed files with 0 additions and 861 deletions
@ -1,198 +0,0 @@ |
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org> |
||||
* |
||||
* 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 "containmentconfigview.h" |
||||
#include <Plasma/Containment> |
||||
#include "currentcontainmentactionsmodel.h" |
||||
#include <kdeclarative/configpropertymap.h> |
||||
|
||||
#include <QDebug> |
||||
#include <QDir> |
||||
#include <QQmlContext> |
||||
#include <QQmlEngine> |
||||
#include <QQmlComponent> |
||||
|
||||
#include <KLocalizedString> |
||||
|
||||
#include <Plasma/Corona> |
||||
#include <Plasma/ContainmentActions> |
||||
#include <Plasma/PluginLoader> |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////ContainmentConfigView
|
||||
ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow *parent) |
||||
: ConfigView(cont, parent), |
||||
m_containment(cont), |
||||
m_wallpaperConfigModel(0), |
||||
m_containmentActionConfigModel(0), |
||||
m_currentContainmentActionsModel(0), |
||||
m_currentWallpaperConfig(0), |
||||
m_ownWallpaperConfig(0) |
||||
{ |
||||
qmlRegisterType<QStandardItemModel>(); |
||||
engine()->rootContext()->setContextProperty("configDialog", this); |
||||
setCurrentWallpaper(cont->containment()->wallpaper()); |
||||
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); |
||||
pkg.setDefaultPackageRoot("plasma/wallpapers"); |
||||
pkg.setPath(m_containment->wallpaper()); |
||||
QFile file(pkg.filePath("config", "main.xml")); |
||||
KConfigGroup cfg = m_containment->config(); |
||||
cfg = KConfigGroup(&cfg, "Wallpaper"); |
||||
|
||||
syncWallpaperObjects(); |
||||
} |
||||
|
||||
ContainmentConfigView::~ContainmentConfigView() |
||||
{ |
||||
} |
||||
|
||||
void ContainmentConfigView::init() |
||||
{ |
||||
setSource(QUrl::fromLocalFile(m_containment->containment()->corona()->package().filePath("containmentconfigurationui"))); |
||||
} |
||||
|
||||
ConfigModel *ContainmentConfigView::containmentActionConfigModel() |
||||
{ |
||||
if (!m_containmentActionConfigModel) { |
||||
m_containmentActionConfigModel = new ConfigModel(this); |
||||
|
||||
KPluginInfo::List actions = Plasma::PluginLoader::self()->listContainmentActionsInfo(QString()); |
||||
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); |
||||
|
||||
foreach (const KPluginInfo &info, actions) { |
||||
pkg.setDefaultPackageRoot(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/containmentactions", QStandardPaths::LocateDirectory)); |
||||
ConfigCategory *cat = new ConfigCategory(m_containmentActionConfigModel); |
||||
cat->setName(info.name()); |
||||
cat->setIcon(info.icon()); |
||||
cat->setSource(pkg.filePath("ui", "config.qml")); |
||||
cat->setPluginName(info.pluginName()); |
||||
m_containmentActionConfigModel->appendCategory(cat); |
||||
} |
||||
|
||||
} |
||||
return m_containmentActionConfigModel; |
||||
} |
||||
|
||||
QStandardItemModel *ContainmentConfigView::currentContainmentActionsModel() |
||||
{ |
||||
if (!m_currentContainmentActionsModel) { |
||||
m_currentContainmentActionsModel = new CurrentContainmentActionsModel(m_containment, this); |
||||
} |
||||
return m_currentContainmentActionsModel; |
||||
} |
||||
|
||||
ConfigModel *ContainmentConfigView::wallpaperConfigModel() |
||||
{ |
||||
if (!m_wallpaperConfigModel) { |
||||
m_wallpaperConfigModel = new ConfigModel(this); |
||||
QStringList dirs(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "plasma/wallpapers", QStandardPaths::LocateDirectory)); |
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); |
||||
foreach (const QString &dirPath, dirs) { |
||||
QDir dir(dirPath); |
||||
pkg.setDefaultPackageRoot(dirPath); |
||||
QStringList packages; |
||||
|
||||
foreach (const QString &sdir, dir.entryList(QDir::AllDirs | QDir::Readable)) { |
||||
QString metadata = dirPath + '/' + sdir + "/metadata.desktop"; |
||||
if (QFile::exists(metadata)) { |
||||
packages << sdir; |
||||
} |
||||
} |
||||
|
||||
foreach (const QString &package, packages) { |
||||
pkg.setPath(package); |
||||
if (!pkg.isValid()) { |
||||
continue; |
||||
} |
||||
ConfigCategory *cat = new ConfigCategory(m_wallpaperConfigModel); |
||||
cat->setName(pkg.metadata().name()); |
||||
cat->setIcon(pkg.metadata().icon()); |
||||
cat->setSource(pkg.filePath("ui", "config.qml")); |
||||
cat->setPluginName(package); |
||||
m_wallpaperConfigModel->appendCategory(cat); |
||||
} |
||||
} |
||||
} |
||||
return m_wallpaperConfigModel; |
||||
} |
||||
|
||||
ConfigPropertyMap *ContainmentConfigView::wallpaperConfiguration() const |
||||
{ |
||||
return m_currentWallpaperConfig; |
||||
} |
||||
|
||||
QString ContainmentConfigView::currentWallpaper() const |
||||
{ |
||||
return m_currentWallpaper; |
||||
} |
||||
|
||||
void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper) |
||||
{ |
||||
if (m_currentWallpaper == wallpaper) { |
||||
return; |
||||
} |
||||
|
||||
delete m_ownWallpaperConfig; |
||||
m_ownWallpaperConfig = 0; |
||||
|
||||
if (m_containment->wallpaper() == wallpaper) { |
||||
syncWallpaperObjects(); |
||||
} else { |
||||
|
||||
//we have to construct an independent ConfigPropertyMap when we want to configure wallpapers that are not the current one
|
||||
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); |
||||
pkg.setDefaultPackageRoot("plasma/wallpapers"); |
||||
pkg.setPath(wallpaper); |
||||
QFile file(pkg.filePath("config", "main.xml")); |
||||
KConfigGroup cfg = m_containment->config(); |
||||
cfg = KConfigGroup(&cfg, "Wallpaper"); |
||||
m_currentWallpaperConfig = m_ownWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this); |
||||
} |
||||
|
||||
m_currentWallpaper = wallpaper; |
||||
emit currentWallpaperChanged(); |
||||
emit wallpaperConfigurationChanged(); |
||||
} |
||||
|
||||
void ContainmentConfigView::applyWallpaper() |
||||
{ |
||||
m_containment->setWallpaper(m_currentWallpaper); |
||||
|
||||
delete m_ownWallpaperConfig; |
||||
m_ownWallpaperConfig = 0; |
||||
|
||||
syncWallpaperObjects(); |
||||
emit wallpaperConfigurationChanged(); |
||||
} |
||||
|
||||
void ContainmentConfigView::syncWallpaperObjects() |
||||
{ |
||||
QObject *wallpaperGraphicsObject = m_containment->property("wallpaperGraphicsObject").value<QObject *>(); |
||||
engine()->rootContext()->setContextProperty("wallpaper", wallpaperGraphicsObject); |
||||
|
||||
//FIXME: why m_wallpaperGraphicsObject->property("configuration").value<ConfigPropertyMap *>() doesn't work?
|
||||
m_currentWallpaperConfig = static_cast<ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>()); |
||||
} |
||||
|
||||
#include "moc_containmentconfigview.cpp" |
||||
@ -1,76 +0,0 @@ |
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org> |
||||
* |
||||
* 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 CONTAINMENTCONFIGVIEW_H |
||||
#define CONTAINMENTCONFIGVIEW_H |
||||
|
||||
|
||||
#include "configview.h" |
||||
|
||||
|
||||
namespace Plasma { |
||||
class Containment; |
||||
} |
||||
|
||||
class ConfigPropertyMap; |
||||
class CurrentContainmentActionsModel; |
||||
|
||||
//TODO: is it possible to move this in the shell?
|
||||
class ContainmentConfigView : public ConfigView |
||||
{ |
||||
Q_OBJECT |
||||
Q_PROPERTY(ConfigModel *containmentActionConfigModel READ containmentActionConfigModel CONSTANT) |
||||
Q_PROPERTY(QStandardItemModel *currentContainmentActionsModel READ currentContainmentActionsModel CONSTANT) |
||||
Q_PROPERTY(ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT) |
||||
Q_PROPERTY(ConfigPropertyMap *wallpaperConfiguration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged) |
||||
Q_PROPERTY(QString currentWallpaper READ currentWallpaper WRITE setCurrentWallpaper NOTIFY currentWallpaperChanged) |
||||
|
||||
public: |
||||
ContainmentConfigView(Plasma::Containment *interface, QWindow *parent = 0); |
||||
virtual ~ContainmentConfigView(); |
||||
|
||||
virtual void init(); |
||||
|
||||
ConfigModel *containmentActionConfigModel(); |
||||
QStandardItemModel *currentContainmentActionsModel(); |
||||
ConfigModel *wallpaperConfigModel(); |
||||
QString currentWallpaper() const; |
||||
void setCurrentWallpaper(const QString &wallpaper); |
||||
ConfigPropertyMap *wallpaperConfiguration() const; |
||||
|
||||
Q_INVOKABLE void applyWallpaper(); |
||||
|
||||
Q_SIGNALS: |
||||
void currentWallpaperChanged(); |
||||
void wallpaperConfigurationChanged(); |
||||
|
||||
protected: |
||||
void syncWallpaperObjects(); |
||||
|
||||
private: |
||||
Plasma::Containment *m_containment; |
||||
ConfigModel *m_wallpaperConfigModel; |
||||
ConfigModel *m_containmentActionConfigModel; |
||||
CurrentContainmentActionsModel *m_currentContainmentActionsModel; |
||||
QString m_currentWallpaper; |
||||
ConfigPropertyMap *m_currentWallpaperConfig; |
||||
ConfigPropertyMap *m_ownWallpaperConfig; |
||||
}; |
||||
|
||||
#endif // multiple inclusion guard
|
||||
@ -1,262 +0,0 @@ |
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org> |
||||
* |
||||
* 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 "currentcontainmentactionsmodel.h" |
||||
|
||||
#include <QMouseEvent> |
||||
|
||||
#include <QDebug> |
||||
#include <QDialog> |
||||
#include <QVBoxLayout> |
||||
#include <QDialogButtonBox> |
||||
|
||||
#include <KAboutData> |
||||
#include <KAboutApplicationDialog> |
||||
#include <KLocalizedString> |
||||
|
||||
#include <Plasma/Corona> |
||||
#include <Plasma/Containment> |
||||
#include <Plasma/ContainmentActions> |
||||
#include <Plasma/PluginLoader> |
||||
|
||||
|
||||
CurrentContainmentActionsModel::CurrentContainmentActionsModel(Plasma::Containment *cotainment, QObject *parent) |
||||
: QStandardItemModel(parent), |
||||
m_containment(cotainment), |
||||
m_tempConfigParent(QString(), KConfig::SimpleConfig) |
||||
{ |
||||
QHash<int, QByteArray> roleNames; |
||||
roleNames[ActionRole] = "action"; |
||||
roleNames[PluginNameRole] = "pluginName"; |
||||
roleNames[HasConfigurationInterfaceRole] = "hasConfigurationInterface"; |
||||
|
||||
setRoleNames(roleNames); |
||||
|
||||
m_baseCfg = KConfigGroup(m_containment->corona()->config(), "ActionPlugins"); |
||||
m_baseCfg = KConfigGroup(&m_baseCfg, QString::number(m_containment->containmentType())); |
||||
|
||||
QHash<QString, Plasma::ContainmentActions*> actions = cotainment->containmentActions(); |
||||
|
||||
|
||||
QHashIterator<QString, Plasma::ContainmentActions*> i(actions); |
||||
while (i.hasNext()) { |
||||
i.next(); |
||||
|
||||
QStandardItem *item = new QStandardItem(); |
||||
item->setData(i.key(), ActionRole); |
||||
item->setData(i.value()->pluginInfo().pluginName(), PluginNameRole); |
||||
|
||||
m_plugins[i.key()] = Plasma::PluginLoader::self()->loadContainmentActions(m_containment, i.value()->pluginInfo().pluginName()); |
||||
m_plugins[i.key()]->setContainment(m_containment); |
||||
KConfigGroup cfg(&m_baseCfg, i.key()); |
||||
m_plugins[i.key()]->restore(cfg); |
||||
item->setData(m_plugins[i.key()]->pluginInfo().property("X-Plasma-HasConfigurationInterface").toBool(), HasConfigurationInterfaceRole); |
||||
|
||||
appendRow(item); |
||||
} |
||||
} |
||||
|
||||
CurrentContainmentActionsModel::~CurrentContainmentActionsModel() |
||||
{ |
||||
} |
||||
|
||||
QString CurrentContainmentActionsModel::mouseEventString(int mouseButton, int modifiers) |
||||
{ |
||||
QMouseEvent *mouse = new QMouseEvent(QEvent::MouseButtonRelease, QPoint(), (Qt::MouseButton)mouseButton, (Qt::MouseButton)mouseButton, (Qt::KeyboardModifiers) modifiers); |
||||
|
||||
QString string = Plasma::ContainmentActions::eventToString(mouse); |
||||
|
||||
delete mouse; |
||||
|
||||
return string; |
||||
} |
||||
|
||||
QString CurrentContainmentActionsModel::wheelEventString(const QPointF &delta, int mouseButtons, int modifiers) |
||||
{ |
||||
QWheelEvent *wheel = new QWheelEvent(QPointF(), QPointF(), delta.toPoint(), QPoint(), 0, Qt::Vertical, (Qt::MouseButtons)mouseButtons, (Qt::KeyboardModifiers) modifiers); |
||||
|
||||
QString string = Plasma::ContainmentActions::eventToString(wheel); |
||||
|
||||
delete wheel; |
||||
|
||||
return string; |
||||
} |
||||
|
||||
bool CurrentContainmentActionsModel::isTriggerUsed(const QString &trigger) |
||||
{ |
||||
return m_plugins.contains(trigger); |
||||
} |
||||
|
||||
bool CurrentContainmentActionsModel::append(const QString &action, const QString &plugin) |
||||
{ |
||||
if (m_plugins.contains(action)) { |
||||
return false; |
||||
} |
||||
|
||||
QStandardItem *item = new QStandardItem(); |
||||
item->setData(action, ActionRole); |
||||
item->setData(plugin, PluginNameRole); |
||||
|
||||
m_plugins[action] = Plasma::PluginLoader::self()->loadContainmentActions(m_containment, plugin); |
||||
m_plugins[action]->setContainment(m_containment); |
||||
//empty config: the new one will ne in default state
|
||||
KConfigGroup tempConfig(&m_tempConfigParent, "test"); |
||||
m_plugins[action]->restore(tempConfig); |
||||
item->setData(m_plugins[action]->pluginInfo().property("X-Plasma-HasConfigurationInterface").toBool(), HasConfigurationInterfaceRole); |
||||
m_removedTriggers.removeAll(action); |
||||
|
||||
appendRow(item); |
||||
return true; |
||||
} |
||||
|
||||
void CurrentContainmentActionsModel::update(int row, const QString &action, const QString &plugin) |
||||
{ |
||||
const QString oldPlugin = itemData(index(row, 0)).value(PluginNameRole).toString(); |
||||
const QString oldTrigger = itemData(index(row, 0)).value(ActionRole).toString(); |
||||
|
||||
if (oldTrigger == action && oldPlugin == plugin) { |
||||
return; |
||||
} |
||||
|
||||
QModelIndex idx = index(row, 0); |
||||
|
||||
if (idx.isValid()) { |
||||
setData(idx, action, ActionRole); |
||||
setData(idx, plugin, PluginNameRole); |
||||
|
||||
delete m_plugins[oldTrigger]; |
||||
m_plugins.remove(oldTrigger); |
||||
|
||||
if (oldPlugin != plugin) { |
||||
m_removedTriggers << oldTrigger; |
||||
} |
||||
|
||||
if (!m_plugins.contains(action) || oldPlugin != plugin) { |
||||
delete m_plugins[action]; |
||||
m_plugins[action] = Plasma::PluginLoader::self()->loadContainmentActions(m_containment, plugin); |
||||
m_plugins[action]->setContainment(m_containment); |
||||
//empty config: the new one will ne in default state
|
||||
KConfigGroup tempConfig(&m_tempConfigParent, "test"); |
||||
m_plugins[action]->restore(tempConfig); |
||||
setData(idx, m_plugins[action]->pluginInfo().property("X-Plasma-HasConfigurationInterface").toBool(), HasConfigurationInterfaceRole); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void CurrentContainmentActionsModel::remove(int row) |
||||
{ |
||||
const QString action = itemData(index(row, 0)).value(ActionRole).toString(); |
||||
removeRows(row, 1); |
||||
|
||||
if (m_plugins.contains(action)) { |
||||
delete m_plugins[action]; |
||||
m_plugins.remove(action); |
||||
m_removedTriggers << action; |
||||
} |
||||
} |
||||
|
||||
void CurrentContainmentActionsModel::showConfiguration(int row) |
||||
{ |
||||
const QString action = itemData(index(row, 0)).value(ActionRole).toString(); |
||||
|
||||
if (!m_plugins.contains(action)) { |
||||
return; |
||||
} |
||||
|
||||
QDialog *configDlg = new QDialog(); |
||||
configDlg->setAttribute(Qt::WA_DeleteOnClose); |
||||
QLayout *lay = new QVBoxLayout(configDlg); |
||||
configDlg->setLayout(lay); |
||||
configDlg->setWindowModality(Qt::WindowModal); |
||||
|
||||
Plasma::ContainmentActions *pluginInstance = m_plugins[action]; |
||||
//put the config in the dialog
|
||||
QWidget *w = pluginInstance->createConfigurationInterface(configDlg); |
||||
QString title; |
||||
if (w) { |
||||
lay->addWidget(w); |
||||
title = w->windowTitle(); |
||||
} |
||||
|
||||
configDlg->setWindowTitle(title.isEmpty() ? i18n("Configure Plugin") :title); |
||||
//put buttons below
|
||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, |
||||
Qt::Horizontal, configDlg); |
||||
lay->addWidget(buttons); |
||||
|
||||
QObject::connect(buttons, &QDialogButtonBox::accepted, |
||||
[configDlg, pluginInstance] () { |
||||
pluginInstance->configurationAccepted(); |
||||
configDlg->deleteLater(); |
||||
}); |
||||
|
||||
QObject::connect(buttons, &QDialogButtonBox::rejected, |
||||
[configDlg] () { |
||||
configDlg->deleteLater(); |
||||
}); |
||||
|
||||
|
||||
configDlg->show(); |
||||
} |
||||
|
||||
void CurrentContainmentActionsModel::showAbout(int row) |
||||
{ |
||||
const QString action = itemData(index(row, 0)).value(ActionRole).toString(); |
||||
|
||||
if (!m_plugins.contains(action)) { |
||||
return; |
||||
} |
||||
|
||||
KPluginInfo info = m_plugins[action]->pluginInfo(); |
||||
|
||||
KAboutData aboutData(info.name().toUtf8(), |
||||
info.name().toUtf8(), |
||||
ki18n(info.name().toUtf8()).toString(), |
||||
info.version().toUtf8(), ki18n(info.comment().toUtf8()).toString(), |
||||
KAboutLicense::byKeyword(info.license()).key(), ki18n(QByteArray()).toString(), ki18n(QByteArray()).toString(), info.website().toLatin1(), |
||||
info.email().toLatin1()); |
||||
|
||||
aboutData.setProgramIconName(info.icon()); |
||||
|
||||
aboutData.addAuthor(ki18n(info.author().toUtf8()).toString(), ki18n(QByteArray()).toString(), info.email().toLatin1()); |
||||
|
||||
KAboutApplicationDialog *aboutDialog = new KAboutApplicationDialog(aboutData, qobject_cast<QWidget*>(parent())); |
||||
aboutDialog->show(); |
||||
} |
||||
|
||||
void CurrentContainmentActionsModel::save() |
||||
{ |
||||
|
||||
foreach (const QString &removedTrigger, m_removedTriggers) { |
||||
m_containment->setContainmentActions(removedTrigger, QString()); |
||||
} |
||||
m_removedTriggers.clear(); |
||||
|
||||
QHashIterator<QString, Plasma::ContainmentActions*> i(m_plugins); |
||||
while (i.hasNext()) { |
||||
i.next(); |
||||
|
||||
KConfigGroup cfg(&m_baseCfg, i.key()); |
||||
i.value()->save(cfg); |
||||
|
||||
m_containment->setContainmentActions(i.key(), i.value()->pluginInfo().pluginName()); |
||||
} |
||||
} |
||||
|
||||
#include "moc_currentcontainmentactionsmodel.cpp" |
||||
@ -1,66 +0,0 @@ |
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org> |
||||
* |
||||
* 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 CURRENTCONTAINMENTACTIONSMODEL_H |
||||
#define CURRENTCONTAINMENTACTIONSMODEL_H |
||||
|
||||
#include <QStandardItemModel> |
||||
|
||||
#include <KConfig> |
||||
#include <KConfigGroup> |
||||
|
||||
namespace Plasma { |
||||
class Containment; |
||||
class ContainmentActions; |
||||
} |
||||
|
||||
class CurrentContainmentActionsModel : public QStandardItemModel |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
enum Roles { |
||||
ActionRole = Qt::UserRole+1, |
||||
PluginNameRole, |
||||
HasConfigurationInterfaceRole |
||||
}; |
||||
|
||||
CurrentContainmentActionsModel(Plasma::Containment *cotainment, QObject *parent = 0); |
||||
~CurrentContainmentActionsModel(); |
||||
|
||||
Q_INVOKABLE bool isTriggerUsed(const QString &trigger); |
||||
Q_INVOKABLE QString mouseEventString(int mouseButtons, int modifiers); |
||||
Q_INVOKABLE QString wheelEventString(const QPointF &delta, int mouseButtons, int modifiers); |
||||
Q_INVOKABLE bool append(const QString &action, const QString &plugin); |
||||
Q_INVOKABLE void update(int row, const QString &action, const QString &plugin); |
||||
Q_INVOKABLE void remove(int row); |
||||
Q_INVOKABLE void showConfiguration(int row); |
||||
Q_INVOKABLE void showAbout(int row); |
||||
Q_INVOKABLE void save(); |
||||
|
||||
private: |
||||
Plasma::Containment *m_containment; |
||||
QHash<QString, Plasma::ContainmentActions *> m_plugins; |
||||
KConfigGroup m_baseCfg; |
||||
KConfigGroup m_tempConfig; |
||||
KConfig m_tempConfigParent; |
||||
QStringList m_removedTriggers; |
||||
}; |
||||
|
||||
#endif |
||||
@ -1,189 +0,0 @@ |
||||
/*
|
||||
* Copyright 2013 Marco Martin <mart@kde.org> |
||||
* |
||||
* 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 "view.h" |
||||
#include "containmentconfigview.h" |
||||
#include "panelconfigview.h" |
||||
#include "panelview.h" |
||||
|
||||
|
||||
#include <QDebug> |
||||
#include <QQuickItem> |
||||
#include <QQmlContext> |
||||
#include <QTimer> |
||||
#include <QScreen> |
||||
#include "plasma/pluginloader.h" |
||||
|
||||
|
||||
View::View(Plasma::Corona *corona, QWindow *parent) |
||||
: QQuickView(parent), |
||||
m_corona(corona) |
||||
{ |
||||
//FIXME: for some reason all windows must have alpha enable otherwise the ones that do won't paint.
|
||||
//Probably is an architectural problem
|
||||
QSurfaceFormat format; |
||||
format.setAlphaBufferSize(8); |
||||
setFormat(format); |
||||
|
||||
connect(screen(), &QScreen::virtualGeometryChanged, |
||||
this, &View::screenGeometryChanged); |
||||
|
||||
if (!m_corona->package().isValid()) { |
||||
qWarning() << "Invalid home screen package"; |
||||
} |
||||
|
||||
setResizeMode(View::SizeRootObjectToView); |
||||
setSource(QUrl::fromLocalFile(m_corona->package().filePath("views", "Desktop.qml"))); |
||||
|
||||
} |
||||
|
||||
View::~View() |
||||
{ |
||||
|
||||
} |
||||
|
||||
Plasma::Corona *View::corona() const |
||||
{ |
||||
return m_corona; |
||||
} |
||||
|
||||
KConfigGroup View::config() const |
||||
{ |
||||
if (!containment()) { |
||||
return KConfigGroup(); |
||||
} |
||||
KConfigGroup views(KSharedConfig::openConfig(), "PlasmaViews"); |
||||
return KConfigGroup(&views, QString::number(containment()->screen())); |
||||
} |
||||
|
||||
void View::setContainment(Plasma::Containment *cont) |
||||
{ |
||||
if (m_containment.data() == cont) { |
||||
return; |
||||
} |
||||
|
||||
Plasma::Types::Location oldLoc = (Plasma::Types::Location)location(); |
||||
Plasma::Types::FormFactor oldForm = formFactor(); |
||||
|
||||
if (m_containment) { |
||||
disconnect(m_containment.data(), 0, this, 0); |
||||
QObject *oldGraphicObject = m_containment.data()->property("graphicObject").value<QObject *>(); |
||||
if (oldGraphicObject) { |
||||
//make sure the graphic object won't die with us
|
||||
oldGraphicObject->setParent(cont); |
||||
} |
||||
} |
||||
|
||||
m_containment = cont; |
||||
|
||||
if (oldLoc != location()) { |
||||
emit locationChanged((Plasma::Types::Location)location()); |
||||
} |
||||
if (oldForm != formFactor()) { |
||||
emit formFactorChanged(formFactor()); |
||||
} |
||||
|
||||
emit containmentChanged(); |
||||
|
||||
if (!cont) { |
||||
return; |
||||
} |
||||
|
||||
connect(cont, &Plasma::Containment::locationChanged, |
||||
this, &View::locationChanged); |
||||
connect(cont, &Plasma::Containment::formFactorChanged, |
||||
this, &View::formFactorChanged); |
||||
connect(cont, &Plasma::Containment::configureRequested, |
||||
this, &View::showConfigurationInterface); |
||||
|
||||
QObject *graphicObject = m_containment.data()->property("graphicObject").value<QObject *>(); |
||||
|
||||
if (graphicObject) { |
||||
qDebug() << "using as graphic containment" << graphicObject << m_containment.data(); |
||||
|
||||
//graphicObject->setProperty("visible", false);
|
||||
graphicObject->setProperty("drawWallpaper", |
||||
(cont->containmentType() == Plasma::Types::DesktopContainment || |
||||
cont->containmentType() == Plasma::Types::CustomContainment)); |
||||
graphicObject->setProperty("parent", QVariant::fromValue(rootObject())); |
||||
rootObject()->setProperty("containment", QVariant::fromValue(graphicObject)); |
||||
} else { |
||||
qWarning() << "Containment graphic object not valid"; |
||||
} |
||||
} |
||||
|
||||
Plasma::Containment *View::containment() const |
||||
{ |
||||
return m_containment.data(); |
||||
} |
||||
|
||||
//FIXME: wrong types
|
||||
void View::setLocation(int location) |
||||
{ |
||||
m_containment.data()->setLocation((Plasma::Types::Location)location); |
||||
} |
||||
|
||||
//FIXME: wrong types
|
||||
int View::location() const |
||||
{ |
||||
if (!m_containment) { |
||||
return Plasma::Types::Desktop; |
||||
} |
||||
return m_containment.data()->location(); |
||||
} |
||||
|
||||
Plasma::Types::FormFactor View::formFactor() const |
||||
{ |
||||
if (!m_containment) { |
||||
return Plasma::Types::Planar; |
||||
} |
||||
return m_containment.data()->formFactor(); |
||||
} |
||||
|
||||
QRectF View::screenGeometry() |
||||
{ |
||||
return screen()->geometry(); |
||||
} |
||||
|
||||
void View::showConfigurationInterface(Plasma::Applet *applet) |
||||
{ |
||||
if (m_configView) { |
||||
m_configView.data()->hide(); |
||||
m_configView.data()->deleteLater(); |
||||
} |
||||
|
||||
if (!applet || !applet->containment()) { |
||||
return; |
||||
} |
||||
|
||||
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(applet); |
||||
PanelView *pv = qobject_cast< PanelView* >(this); |
||||
|
||||
if (cont && pv) { |
||||
m_configView = new PanelConfigView(cont, pv); |
||||
} else if (cont) { |
||||
m_configView = new ContainmentConfigView(cont); |
||||
} else { |
||||
m_configView = new ConfigView(applet); |
||||
} |
||||
m_configView.data()->init(); |
||||
|
||||
m_configView.data()->show(); |
||||
} |
||||
|
||||
#include "moc_view.cpp" |
||||
@ -1,70 +0,0 @@ |
||||
/*
|
||||
* Copyright 2012 Marco Martin <mart@kde.org> |
||||
* |
||||
* 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 VIEW_H |
||||
#define VIEW_H |
||||
|
||||
#include <QtQuick/QQuickView> |
||||
|
||||
|
||||
#include "plasma/corona.h" |
||||
#include "plasma/containment.h" |
||||
|
||||
#include "configview.h" |
||||
|
||||
class View : public QQuickView |
||||
{ |
||||
Q_OBJECT |
||||
Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged) |
||||
Q_PROPERTY(QRectF screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) |
||||
|
||||
public: |
||||
explicit View(Plasma::Corona *corona, QWindow *parent = 0); |
||||
virtual ~View(); |
||||
|
||||
Plasma::Corona *corona() const; |
||||
|
||||
virtual KConfigGroup config() const; |
||||
|
||||
void setContainment(Plasma::Containment *cont); |
||||
Plasma::Containment *containment() const; |
||||
|
||||
//FIXME: Plasma::Types::Location should be something qml can understand
|
||||
int location() const; |
||||
void setLocation(int location); |
||||
|
||||
Plasma::Types::FormFactor formFactor() const; |
||||
|
||||
QRectF screenGeometry(); |
||||
|
||||
protected Q_SLOTS: |
||||
void showConfigurationInterface(Plasma::Applet *applet); |
||||
|
||||
Q_SIGNALS: |
||||
void locationChanged(Plasma::Types::Location location); |
||||
void formFactorChanged(Plasma::Types::FormFactor formFactor); |
||||
void containmentChanged(); |
||||
void screenGeometryChanged(); |
||||
|
||||
private: |
||||
Plasma::Corona *m_corona; |
||||
QWeakPointer<Plasma::Containment> m_containment; |
||||
QWeakPointer<ConfigView> m_configView; |
||||
}; |
||||
|
||||
#endif // VIEW_H
|
||||
Loading…
Reference in new issue