Allow configuring script's screen edges from the KCM
Summary: Modify the kwinscreenedges KCM to also list scripts which support screen edge activation and read/write the appropriate value in the script's config. In order to only show relevant scripts an additional .desktop metadata field is added. Test Plan: Opened KCM set a hot corner for minimize all. Tested it unset it, and set on another corner Tested again Reviewers: #plasma, graesslin Reviewed By: #plasma, graesslin Subscribers: graesslin, plasma-devel, kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D2972icc-effect-5.14.5
parent
1ca9390253
commit
4bb12f3f01
|
@ -19,6 +19,7 @@ target_link_libraries( kcm_kwinscreenedges ${X11_LIBRARIES}
|
|||
KF5::ConfigWidgets
|
||||
KF5::I18n
|
||||
KF5::Service
|
||||
KF5::Package
|
||||
KF5::Plasma
|
||||
kwin4_effect_builtins
|
||||
)
|
||||
|
|
|
@ -27,6 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <KConfigGroup>
|
||||
#include <KLocalizedString>
|
||||
#include <KPluginFactory>
|
||||
#include <KPackage/Package>
|
||||
#include <KPackage/PackageLoader>
|
||||
#include <KPluginInfo>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin<KWin::KWinScreenEdgesConfig>();)
|
||||
|
@ -205,6 +208,22 @@ void KWinScreenEdgesConfig::monitorInit()
|
|||
monitorAddItem(i18n("Toggle window switching"));
|
||||
monitorAddItem(i18n("Toggle alternative window switching"));
|
||||
|
||||
const QString scriptFolder = QStringLiteral("kwin/scripts/");
|
||||
const auto scripts = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder);
|
||||
|
||||
KConfigGroup config(m_config, "Plugins");
|
||||
for (const KPluginMetaData &script: scripts) {
|
||||
if (script.value(QStringLiteral("X-KWin-Border-Activate")) != QLatin1String("true")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!config.readEntry(script.pluginId() + QStringLiteral("Enabled"), script.isEnabledByDefault())) {
|
||||
continue;
|
||||
}
|
||||
m_scripts << script.pluginId();
|
||||
monitorAddItem(script.name());
|
||||
}
|
||||
|
||||
monitorShowEvent();
|
||||
}
|
||||
|
||||
|
@ -303,6 +322,16 @@ void KWinScreenEdgesConfig::monitorLoad()
|
|||
foreach (int i, list) {
|
||||
monitorChangeEdge(ElectricBorder(i), int(TabBoxAlternative));
|
||||
}
|
||||
|
||||
for (int i=0; i < m_scripts.size(); i++) {
|
||||
int index = EffectCount + i;
|
||||
KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]);
|
||||
list.append(int(ElectricNone));
|
||||
list = scriptConfig.readEntry("BorderActivate", list);
|
||||
for (int i: list) {
|
||||
monitorChangeEdge(ElectricBorder(i), index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KWinScreenEdgesConfig::monitorSaveAction(int edge, const QString& configName)
|
||||
|
@ -366,6 +395,13 @@ void KWinScreenEdgesConfig::monitorSave()
|
|||
monitorCheckEffectHasEdge(int(TabBox)));
|
||||
tabBoxConfig.writeEntry("BorderAlternativeActivate",
|
||||
monitorCheckEffectHasEdge(int(TabBoxAlternative)));
|
||||
|
||||
for (int i=0; i < m_scripts.size(); i++) {
|
||||
int index = EffectCount + i;
|
||||
KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]);
|
||||
scriptConfig.writeEntry("BorderActivate",
|
||||
monitorCheckEffectHasEdge(index));
|
||||
}
|
||||
}
|
||||
|
||||
void KWinScreenEdgesConfig::monitorDefaults()
|
||||
|
|
|
@ -62,6 +62,7 @@ private Q_SLOTS:
|
|||
private:
|
||||
KWinScreenEdgesConfigForm* m_ui;
|
||||
KSharedConfigPtr m_config;
|
||||
QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu
|
||||
|
||||
enum EffectActions {
|
||||
PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions
|
||||
|
@ -72,7 +73,8 @@ private:
|
|||
Cylinder,
|
||||
Sphere,
|
||||
TabBox,
|
||||
TabBoxAlternative
|
||||
TabBoxAlternative,
|
||||
EffectCount
|
||||
};
|
||||
|
||||
bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const;
|
||||
|
|
|
@ -55,7 +55,9 @@
|
|||
<argsstring>(ElectricBorder border, QScriptValue callback)</argsstring>
|
||||
<name>registerScreenEdge</name>
|
||||
<read></read>
|
||||
<detaileddescription>Registers the callback for the screen edge. When the mouse gets pushed against the given edge the callback will be invoked.</detaileddescription>
|
||||
<detaileddescription>Registers the callback for the screen edge. When the mouse gets pushed against the given edge the callback will be invoked.
|
||||
Scripts can also add "X-KWin-Border-Activate" to their metadata file to have the effect listed in the screen edges KCM. This will write an entry BorderConfig= in the script configuration object with a list of ScreenEdges the user has selected.
|
||||
</detaileddescription>
|
||||
</memberdef>
|
||||
<memberdef kind="function">
|
||||
<type>Q_SCRIPTABLE bool</type>
|
||||
|
|
|
@ -62,3 +62,6 @@ Type=QString
|
|||
|
||||
[PropertyDef::X-KWin-Exclude-Listing]
|
||||
Type=bool
|
||||
|
||||
[PropertyDef::X-KWin-Border-Activate]
|
||||
Type=bool
|
||||
|
|
Loading…
Reference in New Issue