mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-17 11:37:10 +03:00
feat: reload script after applying configuraton
This commit is contained in:
parent
d57ae30fb5
commit
e73cbce4c8
@ -19,6 +19,7 @@ include(ECMInstallIcons)
|
||||
|
||||
find_package(
|
||||
Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
|
||||
DBus
|
||||
Quick
|
||||
Svg
|
||||
)
|
||||
@ -33,16 +34,20 @@ find_package(
|
||||
|
||||
add_library(kcm_bismuth MODULE)
|
||||
|
||||
qt_add_dbus_interface(kwin_dbus_srcs org.kde.KWin.xml kwin_interface)
|
||||
|
||||
target_sources(
|
||||
kcm_bismuth
|
||||
PRIVATE
|
||||
bismuth.cpp
|
||||
${kwin_dbus_srcs}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
kcm_bismuth
|
||||
PRIVATE
|
||||
Qt5::Core
|
||||
Qt5::DBus
|
||||
KF5::CoreAddons
|
||||
KF5::I18n
|
||||
KF5::QuickAddons
|
||||
|
@ -1,46 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 21,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"displayName": "Default Config",
|
||||
"description": "Default build using Ninja generator",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/",
|
||||
"installDir": "~/.local/kde",
|
||||
"cacheVariables": {
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": {
|
||||
"type": "BOOL",
|
||||
"value": "ON"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"displayName": "Release Config",
|
||||
"description": "Release build using Ninja generator",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/release/",
|
||||
"installDir": "/usr",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"configurePreset": "default"
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"configurePreset": "release",
|
||||
"configuration": "Release"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
SPDX-FileCopyrightText: none
|
||||
|
||||
SPDX-License-Identifier: MIT
|
@ -1,68 +0,0 @@
|
||||
<!-- SPDX-FileCopyrightText: none -->
|
||||
<!-- SPDX-License-Identifier: MIT -->
|
||||
|
||||
# 🤝 Contributing
|
||||
|
||||
We glad, that you want to contribute to the project. To make things easier please read the
|
||||
following.
|
||||
|
||||
## 🏗️ Development packages
|
||||
|
||||
To make sure you can develop the script install all the tools you need:
|
||||
|
||||
- [REUSE tool](https://git.fsfe.org/reuse/tool#install)
|
||||
- [CMake](https://cmake.org/) (3.21 or later)
|
||||
- [Pre-commit](https://pre-commit.com/)
|
||||
- [Clang-format](https://clang.llvm.org/docs/ClangFormat.html)
|
||||
|
||||
## 👷 Prepare environment
|
||||
|
||||
The command will install Git pre-commit hooks you will need, such as automatic
|
||||
REUSE validation and autoformatting.
|
||||
|
||||
```bash
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
Install the dependencies on your Linux Distribution:
|
||||
|
||||
```bash
|
||||
# Ubuntu
|
||||
sudo apt install -y \
|
||||
cmake ninja-build extra-cmake-modules kirigami2-dev \
|
||||
libkf5config-dev libkf5configwidgets-dev libkf5coreaddons-dev \
|
||||
libkf5declarative-dev libkf5i18n-dev libkf5kcmutils-dev \
|
||||
libqt5svg5-dev qml-module-qtquick* qtbase5-dev \
|
||||
qtdeclarative5-dev qtquickcontrols2-5-dev g++
|
||||
```
|
||||
|
||||
```bash
|
||||
# Fedora
|
||||
sudo dnf install -y \
|
||||
kf5-kconfigwidgets-devel qt5-qtbase-devel qt5-qtbase-private-devel \
|
||||
qt5-qtdeclarative-devel qt5-qtquickcontrols2-devel qt5-qtsvg-devel \
|
||||
qt5-qtfeedback-devel cmake ninja-build extra-cmake-modules \
|
||||
kf5-kcmutils-devel kf5-ki18n-devel kf5-kdeclarative-devel
|
||||
```
|
||||
|
||||
```bash
|
||||
# OpenSUSE
|
||||
sudo zypper --non-interactive install --recommends -t pattern devel_qt5 devel_C_C++
|
||||
sudo zypper --non-interactive in -y \
|
||||
ninja extra-cmake-modules kconfig-devel kcmutils-devel kdeclarative-devel \
|
||||
ki18n-devel
|
||||
```
|
||||
|
||||
## 🛠️ Building
|
||||
|
||||
```bash
|
||||
cmake --preset default
|
||||
cmake --build --preset default
|
||||
```
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
```bash
|
||||
source build/prefix.sh
|
||||
kcmshell5 kcm_bismuth
|
||||
```
|
@ -6,10 +6,15 @@
|
||||
|
||||
#include "bismuth.h"
|
||||
#include "bismuth_config.h"
|
||||
#include "kwin_interface.h"
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QDebug>
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KLocalizedString>
|
||||
#include <KPluginFactory>
|
||||
#include <qstringliteral.h>
|
||||
|
||||
K_PLUGIN_CLASS_WITH_JSON(BismuthSettings, "metadata.json")
|
||||
|
||||
@ -17,16 +22,14 @@ BismuthSettings::BismuthSettings(QObject *parent, const QVariantList &args)
|
||||
: KQuickAddons::ManagedConfigModule(parent, args)
|
||||
, m_config(new Bismuth::Config(this))
|
||||
{
|
||||
KAboutData *aboutData =
|
||||
new KAboutData(QStringLiteral("kcm_bismuth"),
|
||||
i18nc("@title", "Window Tiling"),
|
||||
QStringLiteral("1.0"),
|
||||
QStringLiteral(""),
|
||||
KAboutLicense::LicenseKey::Custom,
|
||||
i18nc("@info:credit", "Copyright 2021 Mikhail Zolotukhin <mail@genda.life>"));
|
||||
KAboutData *aboutData = new KAboutData(QStringLiteral("kcm_bismuth"),
|
||||
i18nc("@title", "Window Tiling"),
|
||||
QStringLiteral("1.0"),
|
||||
QStringLiteral(""),
|
||||
KAboutLicense::LicenseKey::Custom,
|
||||
i18nc("@info:credit", "Copyright 2021 Mikhail Zolotukhin <mail@genda.life>"));
|
||||
|
||||
aboutData->addAuthor(
|
||||
i18nc("@info:credit", "Author"), i18nc("@info:credit", "Author"), QStringLiteral("author@domain.com"));
|
||||
aboutData->addAuthor(i18nc("@info:credit", "Author"), i18nc("@info:credit", "Author"), QStringLiteral("author@domain.com"));
|
||||
|
||||
setAboutData(aboutData);
|
||||
setButtons(Help | Apply | Default);
|
||||
@ -39,4 +42,20 @@ Bismuth::Config *BismuthSettings::config() const
|
||||
return m_config;
|
||||
}
|
||||
|
||||
void BismuthSettings::save()
|
||||
{
|
||||
KQuickAddons::ManagedConfigModule::save();
|
||||
reloadKWinScript();
|
||||
}
|
||||
|
||||
void BismuthSettings::reloadKWinScript() const
|
||||
{
|
||||
OrgKdeKwinScriptingInterface kwinInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Scripting"), QDBusConnection::sessionBus());
|
||||
|
||||
// Unload Bismuth, so that it can reload its configuration
|
||||
kwinInterface.unloadScript(QStringLiteral("bismuth")).waitForFinished(); // Sync call
|
||||
// Load unloaded scripts
|
||||
kwinInterface.start(); // Async call
|
||||
}
|
||||
|
||||
#include "bismuth.moc"
|
||||
|
@ -21,6 +21,11 @@ public:
|
||||
|
||||
Bismuth::Config *config() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void save() override;
|
||||
|
||||
private:
|
||||
void reloadKWinScript() const;
|
||||
|
||||
Bismuth::Config *m_config;
|
||||
};
|
||||
|
12
src/kcm/org.kde.KWin.xml
Normal file
12
src/kcm/org.kde.KWin.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life> -->
|
||||
<!-- SPDX-License-Identifier: MIT -->
|
||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.kde.kwin.Scripting">
|
||||
<method name="unloadScript">
|
||||
<arg name="pluginName" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="start"/>
|
||||
</interface>
|
||||
</node>
|
Loading…
Reference in New Issue
Block a user