26 : KQuickConfigModule(parent, data)
28 , m_model(new KPluginModel(this))
31 setButtons(Apply | Default);
32 connect(m_model, &KPluginModel::isSaveNeededChanged,
this, [
this]() {
33 setNeedsSave(m_model->isSaveNeeded() || !m_pendingDeletions.isEmpty());
35 connect(m_model, &KPluginModel::defaulted,
this, [
this](
bool defaulted) {
36 setRepresentsDefaults(defaulted);
38 m_model->setConfig(KSharedConfig::openConfig(
"kwinrc")->group(QStringLiteral(
"Plugins")));
49 QString path = QFileDialog::getOpenFileName(
nullptr, i18n(
"Import KWin Script"), QDir::homePath(),
50 i18n(
"*.kwinscript|KWin scripts (*.kwinscript)"));
56 using namespace KPackage;
58 auto job = PackageJob::update(QStringLiteral(
"KWin/Script"), path);
59 connect(job, &KJob::result,
this, [job,
this]() {
60 if (job->error() != KJob::NoError) {
61 setErrorMessage(i18nc(
"Placeholder is error message returned from the install service",
"Cannot import selected script.\n%1", job->errorString()));
65 m_infoMessage = i18nc(
"Placeholder is name of the script that was imported",
"The script \"%1\" was successfully imported.", job->package().metadata().name());
66 m_errorMessage.clear();
116 using namespace KPackage;
117 for (
const KPluginMetaData &info : std::as_const(m_pendingDeletions)) {
119 QDir root = QFileInfo(info.fileName()).dir();
121 KJob *uninstallJob = PackageJob::uninstall(QStringLiteral(
"KWin/Script"), info.pluginId(), root.absolutePath());
122 connect(uninstallJob, &KJob::result,
this, [
this, uninstallJob]() {
123 if (!uninstallJob->errorString().isEmpty()) {
124 setErrorMessage(i18n(
"Error when uninstalling KWin Script: %1", uninstallJob->errorString()));
131 m_infoMessage.clear();
133 m_pendingDeletions.clear();
137 QDBusMessage message = QDBusMessage::createMethodCall(
"org.kde.KWin",
"/Scripting",
"org.kde.kwin.Scripting",
"start");
138 QDBusConnection::sessionBus().asyncCall(message);