[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
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
|
|
|
|
|
|
|
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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "animationsmodel.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
AnimationsModel::AnimationsModel(QObject *parent)
|
2019-02-03 20:04:09 +00:00
|
|
|
: EffectsModel(parent)
|
[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-02-04 14:20:33 +00:00
|
|
|
connect(this, &EffectsModel::loaded, this,
|
|
|
|
[this] {
|
|
|
|
setEnabled(modelCurrentEnabled());
|
|
|
|
setCurrentIndex(modelCurrentIndex());
|
|
|
|
}
|
|
|
|
);
|
[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(this, &AnimationsModel::currentIndexChanged, this,
|
|
|
|
[this] {
|
|
|
|
const QModelIndex index_ = index(m_currentIndex, 0);
|
|
|
|
if (!index_.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const bool configurable = index_.data(ConfigurableRole).toBool();
|
|
|
|
if (configurable != m_currentConfigurable) {
|
|
|
|
m_currentConfigurable = configurable;
|
|
|
|
emit currentConfigurableChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AnimationsModel::enabled() const
|
|
|
|
{
|
|
|
|
return m_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AnimationsModel::setEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
if (m_enabled != enabled) {
|
|
|
|
m_enabled = enabled;
|
|
|
|
emit enabledChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int AnimationsModel::currentIndex() const
|
|
|
|
{
|
|
|
|
return m_currentIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AnimationsModel::setCurrentIndex(int index)
|
|
|
|
{
|
|
|
|
if (m_currentIndex != index) {
|
|
|
|
m_currentIndex = index;
|
|
|
|
emit currentIndexChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AnimationsModel::currentConfigurable() const
|
|
|
|
{
|
|
|
|
return m_currentConfigurable;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AnimationsModel::shouldStore(const EffectData &data) const
|
|
|
|
{
|
|
|
|
return data.untranslatedCategory.contains(
|
|
|
|
QStringLiteral("Virtual Desktop Switching Animation"), Qt::CaseInsensitive);
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
EffectsModel::Status AnimationsModel::status(int row) 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-02-03 17:19:16 +00:00
|
|
|
return Status(data(index(row, 0), static_cast<int>(StatusRole)).toInt());
|
[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
|
|
|
}
|
|
|
|
|
|
|
|
bool AnimationsModel::modelCurrentEnabled() const
|
|
|
|
{
|
|
|
|
for (int i = 0; i < rowCount(); ++i) {
|
|
|
|
if (status(i) != Status::Disabled) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int AnimationsModel::modelCurrentIndex() const
|
|
|
|
{
|
|
|
|
for (int i = 0; i < rowCount(); ++i) {
|
|
|
|
if (status(i) != Status::Disabled) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AnimationsModel::load()
|
|
|
|
{
|
2019-02-03 20:04:09 +00:00
|
|
|
EffectsModel::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
|
|
|
}
|
|
|
|
|
|
|
|
void AnimationsModel::save()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < rowCount(); ++i) {
|
|
|
|
const auto status = (m_enabled && i == m_currentIndex)
|
2019-02-03 20:04:09 +00:00
|
|
|
? EffectsModel::Status::Enabled
|
|
|
|
: EffectsModel::Status::Disabled;
|
[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
|
|
|
updateEffectStatus(index(i, 0), status);
|
|
|
|
}
|
|
|
|
|
2019-02-03 20:04:09 +00:00
|
|
|
EffectsModel::save();
|
[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 AnimationsModel::defaults()
|
|
|
|
{
|
2019-02-03 20:04:09 +00:00
|
|
|
EffectsModel::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
|
|
|
setEnabled(modelCurrentEnabled());
|
|
|
|
setCurrentIndex(modelCurrentIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AnimationsModel::needsSave() const
|
|
|
|
{
|
|
|
|
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Plugins");
|
|
|
|
|
|
|
|
for (int i = 0; i < rowCount(); ++i) {
|
|
|
|
const QModelIndex index_ = index(i, 0);
|
|
|
|
const bool enabledConfig = kwinConfig.readEntry(
|
|
|
|
index_.data(ServiceNameRole).toString() + QLatin1String("Enabled"),
|
|
|
|
index_.data(EnabledByDefaultRole).toBool()
|
|
|
|
);
|
|
|
|
const bool enabled = (m_enabled && i == m_currentIndex);
|
|
|
|
|
|
|
|
if (enabled != enabledConfig) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|