2008-07-15 19:21:50 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2020-08-02 22:10:35 +00:00
|
|
|
SPDX-FileCopyrightText: 2008 Martin Gräßlin <mgraesslin@kde.org>
|
2008-07-15 19:21:50 +00:00
|
|
|
|
2020-08-02 22:10:35 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
2008-07-15 19:21:50 +00:00
|
|
|
*********************************************************************/
|
|
|
|
#include "cube_config.h"
|
2012-09-12 16:39:13 +00:00
|
|
|
// KConfigSkeleton
|
|
|
|
#include "cubeconfig.h"
|
2016-12-02 19:27:43 +00:00
|
|
|
#include <config-kwin.h>
|
2014-03-18 15:09:20 +00:00
|
|
|
#include <kwineffects_interface.h>
|
2012-09-12 16:39:13 +00:00
|
|
|
|
2013-08-14 19:13:12 +00:00
|
|
|
#include <QAction>
|
2008-07-15 19:21:50 +00:00
|
|
|
|
|
|
|
#include <kconfiggroup.h>
|
|
|
|
#include <kcolorscheme.h>
|
|
|
|
#include <KActionCollection>
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KGlobalAccel>
|
2014-03-17 13:56:11 +00:00
|
|
|
#include <KLocalizedString>
|
2014-03-18 15:09:20 +00:00
|
|
|
#include <KPluginFactory>
|
2008-07-15 19:21:50 +00:00
|
|
|
|
2008-09-16 07:41:39 +00:00
|
|
|
#include <QVBoxLayout>
|
2008-07-15 19:21:50 +00:00
|
|
|
#include <QColor>
|
|
|
|
|
2014-03-17 13:56:11 +00:00
|
|
|
K_PLUGIN_FACTORY_WITH_JSON(CubeEffectConfigFactory,
|
|
|
|
"cube_config.json",
|
|
|
|
registerPlugin<KWin::CubeEffectConfig>();)
|
|
|
|
|
2008-07-15 19:21:50 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
CubeEffectConfigForm::CubeEffectConfigForm(QWidget* parent) : QWidget(parent)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
setupUi(this);
|
2008-07-15 19:21:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) :
|
2013-07-24 05:41:10 +00:00
|
|
|
KCModule(KAboutData::pluginData(QStringLiteral("cube")), parent, args)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-07-15 19:21:50 +00:00
|
|
|
m_ui = new CubeEffectConfigForm(this);
|
|
|
|
|
2008-09-16 07:41:39 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
2008-07-15 19:21:50 +00:00
|
|
|
|
2008-09-16 07:41:39 +00:00
|
|
|
layout->addWidget(m_ui);
|
2008-07-15 19:21:50 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui->tabWidget->setTabText(0, i18nc("@title:tab Basic Settings", "Basic"));
|
|
|
|
m_ui->tabWidget->setTabText(1, i18nc("@title:tab Advanced Settings", "Advanced"));
|
2008-08-28 07:42:52 +00:00
|
|
|
|
2009-02-11 00:34:09 +00:00
|
|
|
// Shortcut config. The shortcut belongs to the component "kwin"!
|
2013-08-14 19:13:12 +00:00
|
|
|
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
2015-08-12 07:19:05 +00:00
|
|
|
m_actionCollection->setComponentDisplayName(i18n("KWin"));
|
2009-02-11 00:34:09 +00:00
|
|
|
|
2013-07-23 05:02:52 +00:00
|
|
|
m_actionCollection->setConfigGroup(QStringLiteral("Cube"));
|
2008-07-15 19:21:50 +00:00
|
|
|
m_actionCollection->setConfigGlobal(true);
|
|
|
|
|
2013-08-14 19:13:12 +00:00
|
|
|
QAction* cubeAction = m_actionCollection->addAction(QStringLiteral("Cube"));
|
2011-01-30 14:34:42 +00:00
|
|
|
cubeAction->setText(i18n("Desktop Cube"));
|
2009-02-14 09:29:01 +00:00
|
|
|
cubeAction->setProperty("isConfigurationAction", true);
|
2013-08-14 19:13:12 +00:00
|
|
|
KGlobalAccel::self()->setDefaultShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11);
|
|
|
|
KGlobalAccel::self()->setShortcut(cubeAction, QList<QKeySequence>() << Qt::CTRL + Qt::Key_F11);
|
|
|
|
QAction* cylinderAction = m_actionCollection->addAction(QStringLiteral("Cylinder"));
|
2011-01-30 14:34:42 +00:00
|
|
|
cylinderAction->setText(i18n("Desktop Cylinder"));
|
2009-02-14 09:29:01 +00:00
|
|
|
cylinderAction->setProperty("isConfigurationAction", true);
|
2013-08-14 19:13:12 +00:00
|
|
|
KGlobalAccel::self()->setShortcut(cylinderAction, QList<QKeySequence>());
|
|
|
|
QAction* sphereAction = m_actionCollection->addAction(QStringLiteral("Sphere"));
|
2011-01-30 14:34:42 +00:00
|
|
|
sphereAction->setText(i18n("Desktop Sphere"));
|
2009-02-14 09:29:01 +00:00
|
|
|
sphereAction->setProperty("isConfigurationAction", true);
|
2013-08-14 19:13:12 +00:00
|
|
|
KGlobalAccel::self()->setShortcut(sphereAction, QList<QKeySequence>());
|
2008-07-15 19:21:50 +00:00
|
|
|
|
|
|
|
m_ui->editor->addCollection(m_actionCollection);
|
2013-08-14 19:13:12 +00:00
|
|
|
|
2017-01-20 23:16:30 +00:00
|
|
|
capsSelectionChanged();
|
2019-01-01 20:48:53 +00:00
|
|
|
connect(m_ui->kcfg_Caps, &QCheckBox::stateChanged, this, &CubeEffectConfig::capsSelectionChanged);
|
2013-07-23 05:02:52 +00:00
|
|
|
m_ui->kcfg_Wallpaper->setFilter(QStringLiteral("*.png *.jpeg *.jpg "));
|
2016-12-02 19:27:43 +00:00
|
|
|
CubeConfig::instance(KWIN_CONFIG);
|
2012-09-12 16:39:13 +00:00
|
|
|
addConfig(CubeConfig::self(), m_ui);
|
2008-07-15 19:21:50 +00:00
|
|
|
load();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-07-15 19:21:50 +00:00
|
|
|
|
|
|
|
void CubeEffectConfig::save()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-09-12 16:39:13 +00:00
|
|
|
KCModule::save();
|
2008-07-15 19:21:50 +00:00
|
|
|
m_ui->editor->save();
|
2014-05-15 06:39:42 +00:00
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
2014-03-18 15:09:20 +00:00
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
2014-04-04 09:49:31 +00:00
|
|
|
interface.reconfigureEffect(QStringLiteral("cube"));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-07-15 19:21:50 +00:00
|
|
|
|
|
|
|
void CubeEffectConfig::capsSelectionChanged()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-09-12 16:39:13 +00:00
|
|
|
if (m_ui->kcfg_Caps->checkState() == Qt::Checked) {
|
2008-07-15 19:21:50 +00:00
|
|
|
// activate cap color
|
2012-09-12 16:39:13 +00:00
|
|
|
m_ui->kcfg_CapColor->setEnabled(true);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui->capColorLabel->setEnabled(true);
|
2012-09-12 16:39:13 +00:00
|
|
|
m_ui->kcfg_TexturedCaps->setEnabled(true);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2008-07-15 19:21:50 +00:00
|
|
|
// deactivate cap color
|
2012-09-12 16:39:13 +00:00
|
|
|
m_ui->kcfg_CapColor->setEnabled(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui->capColorLabel->setEnabled(false);
|
2012-09-12 16:39:13 +00:00
|
|
|
m_ui->kcfg_TexturedCaps->setEnabled(false);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-17 09:11:53 +00:00
|
|
|
|
2008-07-15 19:21:50 +00:00
|
|
|
} // namespace
|
|
|
|
|
2014-03-17 13:56:11 +00:00
|
|
|
#include "cube_config.moc"
|