diff --git a/kcms/workspaceoptions/CMakeLists.txt b/kcms/workspaceoptions/CMakeLists.txt --- a/kcms/workspaceoptions/CMakeLists.txt +++ b/kcms/workspaceoptions/CMakeLists.txt @@ -1,16 +1,27 @@ # KI18N Translation Domain for this library -add_definitions(-DTRANSLATION_DOMAIN=\"kcmworkspaceoptions\") +add_definitions(-DTRANSLATION_DOMAIN=\"kcm_workspace\") + ########### next target ############### +set(kcm_workspace_SRCS + kcm.cpp +) -set(kcm_workspaceoptions_PART_SRCS workspaceoptions.cpp ) -ki18n_wrap_ui(kcm_workspaceoptions_PART_SRCS mainpage.ui) +add_library(kcm_workspace MODULE ${kcm_workspace_SRCS}) -add_library(kcm_workspaceoptions MODULE ${kcm_workspaceoptions_PART_SRCS}) +target_link_libraries(kcm_workspace + KF5::QuickAddons + KF5::I18n + KF5::KIOCore + KF5::ConfigWidgets + KF5::Declarative -target_link_libraries(kcm_workspaceoptions KF5::KIOCore KF5::ConfigWidgets KF5::I18n) + Qt5::QuickWidgets +) -install(TARGETS kcm_workspaceoptions DESTINATION ${KDE_INSTALL_PLUGINDIR} ) +kcoreaddons_desktop_to_json(kcm_workspace "kcm_workspace.desktop" SERVICE_TYPES kcmodule.desktop) ########### install files ############### +install( FILES kcm_workspace.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) +install(TARGETS kcm_workspace DESTINATION ${KDE_INSTALL_PLUGINDIR}/kcms) -install( FILES workspaceoptions.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) +kpackage_install_package(package kcm_workspace kcms) diff --git a/kcms/workspaceoptions/Messages.sh b/kcms/workspaceoptions/Messages.sh --- a/kcms/workspaceoptions/Messages.sh +++ b/kcms/workspaceoptions/Messages.sh @@ -1,3 +1,2 @@ #! /usr/bin/env bash -$EXTRACTRC *.ui >> rc.cpp -$XGETTEXT *.cpp -o $podir/kcmworkspaceoptions.pot +$XGETTEXT `find . -name "*.cpp" -o -name "*.qml"` -o $podir/kcm_workspaceoptions.pot diff --git a/kcms/workspaceoptions/kcm.h b/kcms/workspaceoptions/kcm.h new file mode 100644 --- /dev/null +++ b/kcms/workspaceoptions/kcm.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2018 + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef _KCM_WORKSPACE_H +#define _KCM_WORKSPACE_H + +#include + +class KCMWorkspaceOptions : public KQuickAddons::ConfigModule +{ + Q_OBJECT + Q_PROPERTY(bool toolTip READ getToolTip WRITE setToolTip NOTIFY toolTipChanged) + Q_PROPERTY(bool visualFeedback READ getVisualFeedback WRITE setVisualFeedback NOTIFY visualFeedbackChanged) + +public: + KCMWorkspaceOptions(QObject* parent, const QVariantList& args); + ~KCMWorkspaceOptions() {} + + // QML Properties + bool getToolTip() const; + void setToolTip(bool state); + + bool getVisualFeedback() const; + void setVisualFeedback(bool state); + +public Q_SLOTS: + void load(); + void save(); + void defaults(); + +Q_SIGNALS: + void toolTipChanged(); + void visualFeedbackChanged(); + +private: + void handleNeedsSave(); + + // QML variables + bool m_ostateToolTip; // Original state + bool m_stateToolTip; // Current state + + bool m_ostateVisualFeedback; + bool m_stateVisualFeedback; +}; + +#endif // _KCM_WORKSPACE_H diff --git a/kcms/workspaceoptions/kcm.cpp b/kcms/workspaceoptions/kcm.cpp new file mode 100644 --- /dev/null +++ b/kcms/workspaceoptions/kcm.cpp @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2018 + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include "kcm.h" + +#include +#include +#include +#include + +#include + +K_PLUGIN_FACTORY_WITH_JSON(KCMWorkspaceOptionsFactory, "kcm_workspace.json", registerPlugin();) + +KCMWorkspaceOptions::KCMWorkspaceOptions(QObject *parent, const QVariantList& args) + : KQuickAddons::ConfigModule(parent, args) +{ + KAboutData* about = new KAboutData(QStringLiteral("kcm_workspace"), + i18n("Plasma Workspace global options"), + QStringLiteral("1.1"), + i18n("System Settings module for managing global options for the Plasma Workspace."), + KAboutLicense::GPL); + + about->addAuthor(i18n("Furkan Tokac"), QString(), QStringLiteral("furkantokac34@gmail.com")); + setAboutData(about); + + setButtons( Default | Apply ); +} + +/*ConfigModule functions*/ +void KCMWorkspaceOptions::load() +{ + bool state = false; + KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); + + // Load toolTip + { + const KConfigGroup cg(config, QStringLiteral("PlasmaToolTips")); + state = cg.readEntry("Delay", 0.7) > 0; + setToolTip(state); + m_ostateToolTip = state; + } + + // Load visualFeedback + { + const KConfigGroup cg(config, QStringLiteral("OSD")); + state = cg.readEntry(QStringLiteral("Enabled"), true); + setVisualFeedback(state); + m_ostateVisualFeedback = state; + } + + setNeedsSave(false); +} + +void KCMWorkspaceOptions::save() +{ + KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); + + // Save toolTip + { + KConfigGroup cg(config, QStringLiteral("PlasmaToolTips")); + cg.writeEntry("Delay", getToolTip() ? 0.7 : -1); + m_ostateToolTip = getToolTip(); + } + + // Save visualFeedback + { + KConfigGroup cg(config, QStringLiteral("OSD")); + cg.writeEntry("Enabled", getVisualFeedback()); + m_ostateVisualFeedback = getVisualFeedback(); + } + + config->sync(); + setNeedsSave(false); +} + +void KCMWorkspaceOptions::defaults() +{ + setToolTip(true); + setVisualFeedback(true); + + handleNeedsSave(); +} + +/*ToolTip functions*/ +bool KCMWorkspaceOptions::getToolTip() const +{ + return m_stateToolTip; +} + +void KCMWorkspaceOptions::setToolTip(bool state) +{ + if( m_stateToolTip == state ) return; + + m_stateToolTip = state; + + emit toolTipChanged(); + handleNeedsSave(); +} + +/*VisualFeedback functions*/ +bool KCMWorkspaceOptions::getVisualFeedback() const +{ + return m_stateVisualFeedback; +} + +void KCMWorkspaceOptions::setVisualFeedback(bool state) +{ + // Prevent from binding loop + if( m_stateVisualFeedback == state ) return; + + m_stateVisualFeedback = state; + + emit visualFeedbackChanged(); + handleNeedsSave(); +} + +/*Other functions*/ +// Checks if the current states are different than the first states. +// If yes, setNeedsSave(true). +void KCMWorkspaceOptions::handleNeedsSave() +{ + setNeedsSave(m_ostateToolTip != getToolTip() || + m_ostateVisualFeedback != getVisualFeedback()); +} + +#include "kcm.moc" diff --git a/kcms/workspaceoptions/workspaceoptions.desktop b/kcms/workspaceoptions/kcm_workspace.desktop rename from kcms/workspaceoptions/workspaceoptions.desktop rename to kcms/workspaceoptions/kcm_workspace.desktop --- a/kcms/workspaceoptions/workspaceoptions.desktop +++ b/kcms/workspaceoptions/kcm_workspace.desktop @@ -1,10 +1,11 @@ [Desktop Entry] -Exec=kcmshell5 workspaceoptions Icon=plasma +Exec=kcmshell5 kcm_workspace + Type=Service X-KDE-ServiceTypes=KCModule -X-KDE-Library=kcm_workspaceoptions +X-KDE-Library=kcm_workspace X-KDE-ParentApp=kcontrol X-KDE-System-Settings-Parent-Category=desktopbehavior @@ -143,4 +144,4 @@ X-KDE-Keywords[zh_CN]=plasma,workspace,shell,formfactor,dashboard,tooltips,informational tips,tooltips,工作空间,外壳,部件版,工具提示,提示,信息提示 X-KDE-Keywords[zh_TW]=plasma,workspace,shell,formfactor,dashboard,tooltips,informational tips,tooltips -Categories=Qt;KDE;X-KDE-settings-system; +Categories=Qt;KDE;X-KDE-settings-system; diff --git a/kcms/workspaceoptions/mainpage.ui b/kcms/workspaceoptions/mainpage.ui deleted file mode 100644 --- a/kcms/workspaceoptions/mainpage.ui +++ /dev/null @@ -1,51 +0,0 @@ - - - MainPage - - - - 0 - 0 - 415 - 110 - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Display informational tooltips on mouse hover - - - true - - - - - - - Qt::Vertical - - - - 20 - 214 - - - - - - - - Display visual feedback for status changes - - - - - - - - diff --git a/kcms/workspaceoptions/package/contents/ui/main.qml b/kcms/workspaceoptions/package/contents/ui/main.qml new file mode 100644 --- /dev/null +++ b/kcms/workspaceoptions/package/contents/ui/main.qml @@ -0,0 +1,66 @@ +/* + * Copyright 2018 Furkan Tokac + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import QtQuick 2.7 +import QtQuick.Controls 1.4 as Controls +import QtQuick.Layouts 1.3 as Layouts +import QtQuick.Controls.Styles 1.4 as Styles +import org.kde.kcm 1.1 as KCM + +import org.kde.plasma.core 2.0 as PlasmaCore + +Item { + id: root + + Controls.ScrollView { + anchors.fill: parent + + Layouts.ColumnLayout { + id: maincol + spacing: units.largeSpacing + + // General Settings + Column { + spacing: units.smallSpacing + leftPadding: units.smallSpacing + + Controls.Label { + id: generalSettings + text: i18n("General Settings") + } + + Controls.CheckBox { + id: showToolTips + text: i18n("Display informational tooltips on mouse hover") + onCheckedChanged: kcm.toolTip = checked + } + + Controls.CheckBox { + id: showVisualFeedback + text: i18n("Display visual feedback for status changes") + onCheckedChanged: kcm.visualFeedback = checked + } + + Connections { + target: kcm + onToolTipChanged: showToolTips.checked = kcm.toolTip + onVisualFeedbackChanged: showVisualFeedback.checked = kcm.visualFeedback + } + } + } // END Layouts.ColumnLayout + } // END Controls.ScrollView +} // END Item diff --git a/kcms/workspaceoptions/package/metadata.desktop b/kcms/workspaceoptions/package/metadata.desktop new file mode 100644 --- /dev/null +++ b/kcms/workspaceoptions/package/metadata.desktop @@ -0,0 +1,104 @@ +[Desktop Entry] +Name=Workspace +Name[ar]=مساحة العمل +Name[bs]=Radna površina +Name[ca]=Espai de treball +Name[ca@valencia]=Espai de treball +Name[cs]=Pracovní plocha +Name[da]=Arbejdsområde +Name[de]=Arbeitsbereich +Name[el]=Χώρος εργασίας +Name[en_GB]=Workspace +Name[es]=Espacio de trabajo +Name[et]=Töötsoon +Name[eu]=Langunea +Name[fi]=Työtila +Name[fr]=Espace de travail +Name[gl]=Espazo de traballo +Name[he]=סביבת עבודה +Name[hu]=Munkaterület +Name[ia]=Spatio de labor +Name[id]=Ruang Kerja +Name[is]=Vinnurýmd +Name[it]=Spazio di lavoro +Name[ja]=ワークスペース +Name[ko]=작업 공간 +Name[lt]=Darbo erdvė +Name[nb]=Arbeidsområde +Name[nds]=Arbeitrebeet +Name[nl]=Werkruimte +Name[nn]=Arbeids­område +Name[pa]=ਵਰਕਸਪੇਸ +Name[pl]=Przestrzeń robocza +Name[pt]=Área de Trabalho +Name[pt_BR]=Espaço de trabalho +Name[ru]=Рабочая среда +Name[sk]=Pracovná plocha +Name[sl]=Delovni prostor +Name[sr]=Радни простор +Name[sr@ijekavian]=Радни простор +Name[sr@ijekavianlatin]=Radni prostor +Name[sr@latin]=Radni prostor +Name[sv]=Arbetsyta +Name[tr]=Çalışma Alanı +Name[uk]=Робочий простір +Name[x-test]=xxWorkspacexx +Name[zh_CN]=工作空间 +Name[zh_TW]=工作空間 +Comment=Workspace Behavior +Comment[ar]=سلوك مساحة العمل +Comment[bs]=Ponašanje radnog prostora +Comment[ca]=Comportament de l'espai de treball +Comment[ca@valencia]=Comportament de l'espai de treball +Comment[cs]=Chování pracovní plochy +Comment[da]=Arbejdsområdets opførsel +Comment[de]=Verhalten der Arbeitsfläche +Comment[el]=Συμπεριφορά χώρου εργασίας +Comment[en_GB]=Workspace Behaviour +Comment[es]=Comportamiento del espacio de trabajo +Comment[et]=Töötsooni käitumine +Comment[eu]=Langunearen portaera +Comment[fi]=Työtilan toiminta +Comment[fr]=Comportement de l'espace de travail +Comment[gl]=Comportamento do espazo de traballo +Comment[he]=התנהגות סביבת העבודה +Comment[hu]=Működés +Comment[id]=Perilaku Ruang Kerja +Comment[is]=Hegðun vinnurýmis +Comment[it]=Comportamento dello spazio di lavoro +Comment[ja]=ワークスペースの挙動 +Comment[ko]=작업 공간 행동 +Comment[lt]=Darbo erdvės elgsena +Comment[nb]=Oppførsel for arbeidsområdet +Comment[nds]=Arbeitrebeet-Bedregen +Comment[nl]=Gedrag van werkruimte +Comment[nn]=Åtferd til arbeids­område +Comment[pa]=ਵਰਕਸਪੇਸ ਰਵੱਈਆ +Comment[pl]=Zachowanie przestrzeni roboczej +Comment[pt]=Comportamento da Área de Trabalho +Comment[pt_BR]=Comportamento do espaço de trabalho +Comment[ru]=Настройка поведения рабочей среды +Comment[sk]=Správanie pracovnej plochy +Comment[sl]=Obnašanje delovnega prostora +Comment[sr]=Понашање радног простора +Comment[sr@ijekavian]=Понашање радног простора +Comment[sr@ijekavianlatin]=Ponašanje radnog prostora +Comment[sr@latin]=Ponašanje radnog prostora +Comment[sv]=Arbetsytans beteende +Comment[tr]=Çalışma Alanı Davranışı +Comment[uk]=Поведінка робочого простору +Comment[x-test]=xxWorkspace Behaviorxx +Comment[zh_CN]=工作空间行为 +Comment[zh_TW]=工作空間行為 + +Icon=plasma +Keywords= +Type=Service +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Furkan Tokac +X-KDE-PluginInfo-Email=furkantokac34@gmail.com +X-KDE-PluginInfo-License=GPLv2 +X-KDE-PluginInfo-Name=kcm_workspace +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-KDE-ServiceTypes=Plasma/Generic diff --git a/kcms/workspaceoptions/workspaceoptions.h b/kcms/workspaceoptions/workspaceoptions.h deleted file mode 100644 --- a/kcms/workspaceoptions/workspaceoptions.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2009 Marco Martin - * - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ -#ifndef WORKSPACEOPTIONS_H -#define WORKSPACEOPTIONS_H - -#include -#include -#include - -namespace Ui { - class MainPage; -} - -class WorkspaceOptionsModule : public KCModule -{ - Q_OBJECT - -public: - WorkspaceOptionsModule(QWidget *parent, const QVariantList &); - ~WorkspaceOptionsModule(); - void save() override; - void load() override; - void defaults() override; - -private: - KSharedConfigPtr m_kwinConfig; - KSharedConfigPtr m_ownConfig; - KAutostart m_plasmaShellAutostart; - KAutostart m_krunnerAutostart; - bool m_currentlyIsDesktop; - bool m_currentlyFixedDashboard; - - Ui::MainPage *m_ui; -}; - -#endif // WORKSPACEOPTIONS_H diff --git a/kcms/workspaceoptions/workspaceoptions.cpp b/kcms/workspaceoptions/workspaceoptions.cpp deleted file mode 100644 --- a/kcms/workspaceoptions/workspaceoptions.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2009 Marco Martin - * - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ -#include "workspaceoptions.h" - -#include "ui_mainpage.h" - -#include -#include -#include - -using namespace KAuth; - -K_PLUGIN_FACTORY(WorkspaceOptionsModuleFactory, registerPlugin();) -K_EXPORT_PLUGIN(WorkspaceOptionsModuleFactory("kcmworkspaceoptions")) - -static const QString s_osdKey = QStringLiteral("OSD"); - -WorkspaceOptionsModule::WorkspaceOptionsModule(QWidget *parent, const QVariantList &args) - : KCModule(parent, args), - m_kwinConfig( KSharedConfig::openConfig(QStringLiteral("kwinrc"))), - m_ownConfig( KSharedConfig::openConfig(QStringLiteral("workspaceoptionsrc"))), - m_plasmaShellAutostart(QStringLiteral("plasmashell")), - m_krunnerAutostart(QStringLiteral("krunner")), - m_ui(new Ui::MainPage) -{ - KAboutData *about = - new KAboutData(QStringLiteral("kcmworkspaceoptions"), i18n("Global options for the Plasma Workspace"), - QStringLiteral("1.0"), QString(), KAboutLicense::GPL, - i18n("(c) 2009 Marco Martin")); - - about->addAuthor(i18n("Marco Martin"), i18n("Maintainer"), QStringLiteral("notmart@gmail.com")); - - setAboutData(about); - - setButtons(Apply); - - m_ui->setupUi(this); - - connect(m_ui->showToolTips, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_ui->showOsd, &QCheckBox::toggled, this, static_cast(&WorkspaceOptionsModule::changed)); -} - -WorkspaceOptionsModule::~WorkspaceOptionsModule() -{ - delete m_ui; -} - - -void WorkspaceOptionsModule::save() -{ - KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); - - { - KConfigGroup cg(config, "PlasmaToolTips"); - cg.writeEntry("Delay", m_ui->showToolTips->isChecked() ? 0.7 : -1); - } - - { - KConfigGroup cg(config, QStringLiteral("OSD")); - cg.writeEntry("Enabled", m_ui->showOsd->isChecked()); - } - - config->sync(); -} - -void WorkspaceOptionsModule::load() -{ - KSharedConfig::Ptr config = KSharedConfig::openConfig(QStringLiteral("plasmarc")); - - { - const KConfigGroup cg(config, "PlasmaToolTips"); - m_ui->showToolTips->setChecked(cg.readEntry("Delay", 0.7) > 0); - } - - { - const KConfigGroup cg(config, s_osdKey); - m_ui->showOsd->setChecked(cg.readEntry(QStringLiteral("Enabled"), true)); - } -} - -void WorkspaceOptionsModule::defaults() -{ - m_ui->showToolTips->setChecked(true); - m_ui->showOsd->setChecked(true); -} - -#include "workspaceoptions.moc"