2018-11-29 15:57:35 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2018 Eike Hein <hein@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2018-11-29 15:57:35 +00:00
|
|
|
|
|
|
|
#include "virtualdesktops.h"
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
#include "animationsmodel.h"
|
2018-11-29 15:57:35 +00:00
|
|
|
#include "desktopsmodel.h"
|
2019-12-10 17:36:07 +00:00
|
|
|
#include "virtualdesktopssettings.h"
|
2018-11-29 15:57:35 +00:00
|
|
|
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
#include <KAboutApplicationDialog>
|
2018-11-29 15:57:35 +00:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KLocalizedString>
|
2020-10-01 15:50:15 +00:00
|
|
|
#include <KPluginFactory>
|
2018-11-29 15:57:35 +00:00
|
|
|
|
|
|
|
K_PLUGIN_FACTORY_WITH_JSON(VirtualDesktopsFactory, "kcm_kwin_virtualdesktops.json", registerPlugin<KWin::VirtualDesktops>();)
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args)
|
2019-12-11 10:14:02 +00:00
|
|
|
: KQuickAddons::ManagedConfigModule(parent, args)
|
2019-12-10 17:36:07 +00:00
|
|
|
, m_settings(new VirtualDesktopsSettings(this))
|
2018-11-29 15:57:35 +00:00
|
|
|
, m_desktopsModel(new KWin::DesktopsModel(this))
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
, m_animationsModel(new AnimationsModel(this))
|
2018-11-29 15:57:35 +00:00
|
|
|
{
|
|
|
|
KAboutData *about = new KAboutData(QStringLiteral("kcm_kwin_virtualdesktops"),
|
[kcmkwin/kwindesktop] Improve the look of the Virtual Desktops KCM UI
Summary:
Apply the KDE HIG, make the list headers and desktop file consistent.
{F7164659}
Test Plan: Open the Virtual Desktops KCM.
Reviewers: #kwin, #plasma, #vdg, hein, ngraham
Reviewed By: #plasma, #vdg, hein, ngraham
Subscribers: broulik, ngraham, #vdg, #plasma, kwin, #kwin
Tags: #kwin
Maniphest Tasks: T10862
Differential Revision: https://phabricator.kde.org/D22933
2019-08-04 18:57:00 +00:00
|
|
|
i18n("Virtual Desktops"),
|
2018-11-29 15:57:35 +00:00
|
|
|
QStringLiteral("2.0"), QString(), KAboutLicense::GPL);
|
|
|
|
setAboutData(about);
|
|
|
|
|
2019-12-11 10:14:02 +00:00
|
|
|
qmlRegisterType<VirtualDesktopsSettings>();
|
|
|
|
|
2018-11-29 15:57:35 +00:00
|
|
|
setButtons(Apply | Default);
|
|
|
|
|
|
|
|
QObject::connect(m_desktopsModel, &KWin::DesktopsModel::userModifiedChanged,
|
2019-12-11 10:14:02 +00:00
|
|
|
this, &VirtualDesktops::settingsChanged);
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
connect(m_animationsModel, &AnimationsModel::enabledChanged,
|
2019-12-11 10:14:02 +00:00
|
|
|
this, &VirtualDesktops::settingsChanged);
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
connect(m_animationsModel, &AnimationsModel::currentIndexChanged,
|
2019-12-11 10:14:02 +00:00
|
|
|
this, &VirtualDesktops::settingsChanged);
|
2018-11-29 15:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VirtualDesktops::~VirtualDesktops()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QAbstractItemModel *VirtualDesktops::desktopsModel() const
|
|
|
|
{
|
|
|
|
return m_desktopsModel;
|
|
|
|
}
|
|
|
|
|
2019-12-11 10:14:02 +00:00
|
|
|
QAbstractItemModel *VirtualDesktops::animationsModel() const
|
2018-11-29 15:57:35 +00:00
|
|
|
{
|
2019-12-11 10:14:02 +00:00
|
|
|
return m_animationsModel;
|
2018-11-29 15:57:35 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 10:14:02 +00:00
|
|
|
VirtualDesktopsSettings *VirtualDesktops::virtualDesktopsSettings() const
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
{
|
2019-12-11 10:14:02 +00:00
|
|
|
return m_settings;
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 15:57:35 +00:00
|
|
|
void VirtualDesktops::load()
|
|
|
|
{
|
2019-12-11 10:14:02 +00:00
|
|
|
ManagedConfigModule::load();
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
|
2019-12-11 10:14:02 +00:00
|
|
|
m_desktopsModel->load();
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
m_animationsModel->load();
|
2018-11-29 15:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktops::save()
|
|
|
|
{
|
2019-12-11 10:14:02 +00:00
|
|
|
ManagedConfigModule::save();
|
|
|
|
|
2018-11-29 15:57:35 +00:00
|
|
|
m_desktopsModel->syncWithServer();
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
m_animationsModel->save();
|
2018-11-29 15:57:35 +00:00
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"),
|
|
|
|
QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"));
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktops::defaults()
|
|
|
|
{
|
2019-12-11 10:14:02 +00:00
|
|
|
ManagedConfigModule::defaults();
|
|
|
|
|
|
|
|
m_desktopsModel->defaults();
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
m_animationsModel->defaults();
|
2019-12-11 10:14:02 +00:00
|
|
|
}
|
2018-11-29 15:57:35 +00:00
|
|
|
|
2019-12-11 10:14:02 +00:00
|
|
|
bool VirtualDesktops::isDefaults() const
|
|
|
|
{
|
|
|
|
return m_animationsModel->isDefaults() && m_desktopsModel->isDefaults();
|
2018-11-29 15:57:35 +00:00
|
|
|
}
|
|
|
|
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
void VirtualDesktops::configureAnimation()
|
|
|
|
{
|
|
|
|
const QModelIndex index = m_animationsModel->index(m_animationsModel->currentIndex(), 0);
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-03 15:18:42 +00:00
|
|
|
m_animationsModel->requestConfigure(index, nullptr);
|
[kcmkwin/desktop] Add animation option back
Summary:
The "new" animation option no longer uses hard coded effects, which
means one could install a third party virtual desktop switching animation,
for example from store.kde.org, and it will be displayed in the KCM.
Test Plan: {F6503565}
Reviewers: #kwin, #vdg, ngraham, davidedmundson
Reviewed By: #kwin, #vdg, ngraham, davidedmundson
Subscribers: davidedmundson, hein, ngraham, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D17766
2018-12-22 23:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VirtualDesktops::showAboutAnimation()
|
|
|
|
{
|
|
|
|
const QModelIndex index = m_animationsModel->index(m_animationsModel->currentIndex(), 0);
|
|
|
|
if (!index.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString name = index.data(AnimationsModel::NameRole).toString();
|
|
|
|
const QString comment = index.data(AnimationsModel::DescriptionRole).toString();
|
|
|
|
const QString author = index.data(AnimationsModel::AuthorNameRole).toString();
|
|
|
|
const QString email = index.data(AnimationsModel::AuthorEmailRole).toString();
|
|
|
|
const QString website = index.data(AnimationsModel::WebsiteRole).toString();
|
|
|
|
const QString version = index.data(AnimationsModel::VersionRole).toString();
|
|
|
|
const QString license = index.data(AnimationsModel::LicenseRole).toString();
|
|
|
|
const QString icon = index.data(AnimationsModel::IconNameRole).toString();
|
|
|
|
|
|
|
|
const KAboutLicense::LicenseKey licenseType = KAboutLicense::byKeyword(license).key();
|
|
|
|
|
|
|
|
KAboutData aboutData(
|
|
|
|
name, // Plugin name
|
|
|
|
name, // Display name
|
|
|
|
version, // Version
|
|
|
|
comment, // Short description
|
|
|
|
licenseType, // License
|
|
|
|
QString(), // Copyright statement
|
|
|
|
QString(), // Other text
|
|
|
|
website.toLatin1() // Home page
|
|
|
|
);
|
|
|
|
aboutData.setProgramLogo(icon);
|
|
|
|
|
|
|
|
const QStringList authors = author.split(',');
|
|
|
|
const QStringList emails = email.split(',');
|
|
|
|
|
|
|
|
if (authors.count() == emails.count()) {
|
|
|
|
int i = 0;
|
|
|
|
for (const QString &author : authors) {
|
|
|
|
if (!author.isEmpty()) {
|
|
|
|
aboutData.addAuthor(i18n(author.toUtf8()), QString(), emails[i]);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QPointer<KAboutApplicationDialog> aboutPlugin = new KAboutApplicationDialog(aboutData);
|
|
|
|
aboutPlugin->exec();
|
|
|
|
|
|
|
|
delete aboutPlugin;
|
|
|
|
}
|
|
|
|
|
2019-12-11 10:14:02 +00:00
|
|
|
bool VirtualDesktops::isSaveNeeded() const
|
2018-11-29 15:57:35 +00:00
|
|
|
{
|
2019-12-11 10:14:02 +00:00
|
|
|
return m_animationsModel->needsSave() || m_desktopsModel->needsSave();
|
2018-11-29 15:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "virtualdesktops.moc"
|