diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt
index 85595eabf7..23e157d8e1 100644
--- a/effects/CMakeLists.txt
+++ b/effects/CMakeLists.txt
@@ -92,6 +92,7 @@ set( kwin4_effect_builtins_sources
resize/resize.cpp
scale/scale.cpp
showfps/showfps.cpp
+ showpaint/showpaint.cpp
slide/slide.cpp
thumbnailaside/thumbnailaside.cpp
touchpoints/touchpoints.cpp
@@ -160,7 +161,7 @@ add_subdirectory( presentwindows )
add_subdirectory( resize )
include( screenedge/CMakeLists.txt )
add_subdirectory( showfps )
-include( showpaint/CMakeLists.txt )
+add_subdirectory( showpaint )
add_subdirectory( slide )
include( slideback/CMakeLists.txt )
include( slidingpopups/CMakeLists.txt )
diff --git a/effects/showpaint/CMakeLists.txt b/effects/showpaint/CMakeLists.txt
index 64a226b094..dc1d7ef028 100644
--- a/effects/showpaint/CMakeLists.txt
+++ b/effects/showpaint/CMakeLists.txt
@@ -1,7 +1,25 @@
#######################################
-# Effect
-# Source files
-set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
- showpaint/showpaint.cpp
- )
+# Config
+set(kwin_showpaint_config_SRCS showpaint_config.cpp)
+ki18n_wrap_ui(kwin_showpaint_config_SRCS showpaint_config.ui)
+
+add_library(kwin_showpaint_config MODULE ${kwin_showpaint_config_SRCS})
+
+target_link_libraries(kwin_showpaint_config
+ KF5::ConfigWidgets
+ KF5::GlobalAccel
+ KF5::I18n
+ KF5::Service
+ KF5::XmlGui
+)
+
+kcoreaddons_desktop_to_json(kwin_showpaint_config showpaint_config.desktop SERVICE_TYPES kcmodule.desktop)
+
+install(
+ TARGETS
+ kwin_showpaint_config
+
+ DESTINATION
+ ${PLUGIN_INSTALL_DIR}/kwin/effects/configs
+)
diff --git a/effects/showpaint/showpaint.cpp b/effects/showpaint/showpaint.cpp
index 229cf05c5e..42d4d66a1d 100644
--- a/effects/showpaint/showpaint.cpp
+++ b/effects/showpaint/showpaint.cpp
@@ -26,6 +26,10 @@ along with this program. If not, see .
#include
#endif
+#include
+#include
+
+#include
#include
namespace KWin
@@ -42,6 +46,18 @@ static const QVector s_colors {
Qt::gray
};
+ShowPaintEffect::ShowPaintEffect()
+{
+ auto *toggleAction = new QAction(this);
+ toggleAction->setObjectName(QStringLiteral("Toggle"));
+ toggleAction->setText(i18n("Toggle Show Paint"));
+ KGlobalAccel::self()->setDefaultShortcut(toggleAction, {});
+ KGlobalAccel::self()->setShortcut(toggleAction, {});
+ effects->registerGlobalShortcut({}, toggleAction);
+
+ connect(toggleAction, &QAction::triggered, this, &ShowPaintEffect::toggle);
+}
+
void ShowPaintEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data)
{
m_painted = QRegion();
@@ -123,4 +139,15 @@ void ShowPaintEffect::paintQPainter()
}
}
+bool ShowPaintEffect::isActive() const
+{
+ return m_active;
+}
+
+void ShowPaintEffect::toggle()
+{
+ m_active = !m_active;
+ effects->addRepaintFull();
+}
+
} // namespace KWin
diff --git a/effects/showpaint/showpaint.h b/effects/showpaint/showpaint.h
index abd1e1933d..c2f0c83a59 100644
--- a/effects/showpaint/showpaint.h
+++ b/effects/showpaint/showpaint.h
@@ -31,14 +31,22 @@ class ShowPaintEffect : public Effect
Q_OBJECT
public:
+ ShowPaintEffect();
+
void paintScreen(int mask, QRegion region, ScreenPaintData &data) override;
void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
+ bool isActive() const override;
+
+private Q_SLOTS:
+ void toggle();
+
private:
void paintGL(const QMatrix4x4 &projection);
void paintXrender();
void paintQPainter();
+ bool m_active = false;
QRegion m_painted; // what's painted in one pass
int m_colorIndex = 0;
};
diff --git a/effects/showpaint/showpaint_config.cpp b/effects/showpaint/showpaint_config.cpp
new file mode 100644
index 0000000000..2f33e8e9a6
--- /dev/null
+++ b/effects/showpaint/showpaint_config.cpp
@@ -0,0 +1,87 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2018 Vlad Zagorodniy
+
+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 .
+*********************************************************************/
+
+#include "showpaint_config.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+K_PLUGIN_FACTORY_WITH_JSON(ShowPaintEffectConfigFactory,
+ "showpaint_config.json",
+ registerPlugin();)
+
+namespace KWin
+{
+
+ShowPaintEffectConfig::ShowPaintEffectConfig(QWidget *parent, const QVariantList &args)
+ : KCModule(KAboutData::pluginData(QStringLiteral("showpaint")), parent, args)
+ , m_ui(new Ui::ShowPaintEffectConfig)
+{
+ m_ui->setupUi(this);
+
+ auto *actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
+
+ actionCollection->setComponentDisplayName(i18n("KWin"));
+ actionCollection->setConfigGroup(QStringLiteral("ShowPaint"));
+ actionCollection->setConfigGlobal(true);
+
+ QAction *toggleAction = actionCollection->addAction(QStringLiteral("Toggle"));
+ toggleAction->setText(i18n("Toggle Show Paint"));
+ toggleAction->setProperty("isConfigurationAction", true);
+ KGlobalAccel::self()->setDefaultShortcut(toggleAction, {});
+ KGlobalAccel::self()->setShortcut(toggleAction, {});
+
+ m_ui->shortcutsEditor->addCollection(actionCollection);
+
+ connect(m_ui->shortcutsEditor, &KShortcutsEditor::keyChange,
+ this, qOverload<>(&ShowPaintEffectConfig::changed));
+
+ load();
+}
+
+ShowPaintEffectConfig::~ShowPaintEffectConfig()
+{
+ // If save() is called, undoChanges() has no effect.
+ m_ui->shortcutsEditor->undoChanges();
+
+ delete m_ui;
+}
+
+void ShowPaintEffectConfig::save()
+{
+ KCModule::save();
+ m_ui->shortcutsEditor->save();
+}
+
+void ShowPaintEffectConfig::defaults()
+{
+ m_ui->shortcutsEditor->allDefault();
+ KCModule::defaults();
+}
+
+} // namespace KWin
+
+#include "showpaint_config.moc"
diff --git a/effects/showpaint/showpaint_config.desktop b/effects/showpaint/showpaint_config.desktop
new file mode 100644
index 0000000000..b6d83dffc8
--- /dev/null
+++ b/effects/showpaint/showpaint_config.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Service
+X-KDE-ServiceTypes=KCModule
+
+X-KDE-Library=kwin_showpaint_config
+X-KDE-ParentComponents=showpaint
+
+Name=Show Paint
diff --git a/effects/showpaint/showpaint_config.h b/effects/showpaint/showpaint_config.h
new file mode 100644
index 0000000000..976f0e8dee
--- /dev/null
+++ b/effects/showpaint/showpaint_config.h
@@ -0,0 +1,46 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2018 Vlad Zagorodniy
+
+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 .
+*********************************************************************/
+
+#pragma once
+
+#include
+
+#include "ui_showpaint_config.h"
+
+namespace KWin
+{
+
+class ShowPaintEffectConfig : public KCModule
+{
+ Q_OBJECT
+
+public:
+ explicit ShowPaintEffectConfig(QWidget *parent = nullptr, const QVariantList &args = {});
+ ~ShowPaintEffectConfig() override;
+
+public Q_SLOTS:
+ void save() override;
+ void defaults() override;
+
+private:
+ Ui::ShowPaintEffectConfig *m_ui;
+};
+
+} // namespace KWin
diff --git a/effects/showpaint/showpaint_config.ui b/effects/showpaint/showpaint_config.ui
new file mode 100644
index 0000000000..93e77ba12a
--- /dev/null
+++ b/effects/showpaint/showpaint_config.ui
@@ -0,0 +1,39 @@
+
+
+ ShowPaintEffectConfig
+
+
+
+ 0
+ 0
+ 452
+ 246
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ KShortcutsEditor::GlobalAction
+
+
+
+
+
+
+
+ KShortcutsEditor
+ QWidget
+
+ 1
+
+
+
+
+