[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:27:11 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=2fdffd5

The following commit has been merged in the master branch:
commit 2fdffd5cfd3fa0aa59dae847199a23e0f9424fe7
Author: Albert Vaca <albertvaka at gmail.com>
Date:   Fri Nov 22 22:49:40 2013 +0100

    Added a config dialog to pausemusic plugin
    
    Before this it was not possible to change the pause condition (was a TODO).
---
 kded/plugins/pausemusic/CMakeLists.txt             | 16 +++++
 .../kdeconnect_pausemusic_config.desktop           | 10 +++
 kded/plugins/pausemusic/pausemusic_config.cpp      | 78 ++++++++++++++++++++++
 .../pausemusic_config.h}                           | 31 +++++----
 kded/plugins/pausemusic/pausemusic_config.ui       | 66 ++++++++++++++++++
 kded/plugins/pausemusic/pausemusicplugin.cpp       | 30 +++++----
 kded/plugins/pausemusic/pausemusicplugin.h         |  2 -
 7 files changed, 206 insertions(+), 27 deletions(-)

diff --git a/kded/plugins/pausemusic/CMakeLists.txt b/kded/plugins/pausemusic/CMakeLists.txt
index d49cb7b..dc49272 100644
--- a/kded/plugins/pausemusic/CMakeLists.txt
+++ b/kded/plugins/pausemusic/CMakeLists.txt
@@ -29,3 +29,19 @@ target_link_libraries(kdeconnect_pausemusic
 
 install(TARGETS kdeconnect_pausemusic DESTINATION ${PLUGIN_INSTALL_DIR} )
 install(FILES kdeconnect_pausemusic.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+#######################################
+# Config
+
+set( kdeconnect_pausemusic_config_SRCS pausemusic_config.cpp )
+kde4_add_ui_files( kdeconnect_pausemusic_config_SRCS pausemusic_config.ui )
+
+kde4_add_plugin( kdeconnect_pausemusic_config ${kdeconnect_pausemusic_config_SRCS} )
+target_link_libraries( kdeconnect_pausemusic_config
+    ${KDE4_KDECORE_LIBS}
+    ${KDE4_KDEUI_LIBS}
+)
+
+install( TARGETS kdeconnect_pausemusic_config DESTINATION ${PLUGIN_INSTALL_DIR} )
+install( FILES kdeconnect_pausemusic_config.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --git a/kded/plugins/pausemusic/kdeconnect_pausemusic_config.desktop b/kded/plugins/pausemusic/kdeconnect_pausemusic_config.desktop
new file mode 100644
index 0000000..0c12a6a
--- /dev/null
+++ b/kded/plugins/pausemusic/kdeconnect_pausemusic_config.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Service
+X-KDE-ServiceTypes=KCModule
+
+X-KDE-Library=kdeconnect_pausemusic_config
+X-KDE-ParentComponents=kdeconnect_pausemusic
+
+Name=Pause Music plugin settings
+
+Categories=Qt;KDE;X-KDE-settings-kdeconnect;
diff --git a/kded/plugins/pausemusic/pausemusic_config.cpp b/kded/plugins/pausemusic/pausemusic_config.cpp
new file mode 100644
index 0000000..9d470ea
--- /dev/null
+++ b/kded/plugins/pausemusic/pausemusic_config.cpp
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ *
+ * 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) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "pausemusic_config.h"
+
+#include <KPluginFactory>
+#include <KSharedConfig>
+#include <KConfigGroup>
+
+#include "../../kdebugnamespace.h"
+
+#include "ui_pausemusic_config.h"
+
+K_PLUGIN_FACTORY(PauseMusicConfigFactory, registerPlugin<PauseMusicConfig>();)
+K_EXPORT_PLUGIN(PauseMusicConfigFactory("kdeconnect_pausemusic_config", "kdeconnect_pausemusic_config"))
+
+PauseMusicConfig::PauseMusicConfig(QWidget *parent, const QVariantList& )
+    : KCModule(PauseMusicConfigFactory::componentData(), parent)
+    , m_ui(new Ui::PauseMusicConfigUi())
+    , m_cfg(KSharedConfig::openConfig("kdeconnect/plugins/pausemusic"))
+{
+    m_ui->setupUi(this);
+
+    connect(m_ui->rad_ringing, SIGNAL(toggled(bool)), this, SLOT(changed()));
+    connect(m_ui->rad_talking, SIGNAL(toggled(bool)), this, SLOT(changed()));
+}
+
+PauseMusicConfig::~PauseMusicConfig()
+{
+    delete m_ui;
+}
+
+void PauseMusicConfig::defaults()
+{
+    KCModule::defaults();
+    m_ui->rad_talking->setChecked(false);
+    m_ui->rad_ringing->setChecked(true);
+
+    Q_EMIT changed(true);
+}
+
+
+void PauseMusicConfig::load()
+{
+    KCModule::load();
+    bool talking = m_cfg->group("pause_condition").readEntry("talking_only", false);
+    m_ui->rad_talking->setChecked(talking);
+    m_ui->rad_ringing->setChecked(!talking);
+
+    Q_EMIT changed(false);
+}
+
+
+void PauseMusicConfig::save()
+{
+    m_cfg->group("pause_condition").writeEntry("talking_only", m_ui->rad_talking->isChecked());
+    KCModule::save();
+
+    Q_EMIT changed(false);
+}
+
diff --git a/kded/plugins/ping/pingplugin.h b/kded/plugins/pausemusic/pausemusic_config.h
similarity index 68%
copy from kded/plugins/ping/pingplugin.h
copy to kded/plugins/pausemusic/pausemusic_config.h
index 334a353..075e295 100644
--- a/kded/plugins/ping/pingplugin.h
+++ b/kded/plugins/pausemusic/pausemusic_config.h
@@ -18,25 +18,32 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef PINGPLUGIN_H
-#define PINGPLUGIN_H
+#ifndef PAUSEMUSIC_CONFIG_H
+#define PAUSEMUSIC_CONFIG_H
 
-#include <QObject>
+#include <kcmodule.h>
+#include <ksharedconfig.h>
 
-#include "../kdeconnectplugin.h"
+namespace Ui {
+    class PauseMusicConfigUi;
+}
 
-class KDE_EXPORT PingPlugin
-    : public KdeConnectPlugin
+class PauseMusicConfig
+    : public KCModule
 {
     Q_OBJECT
-
 public:
-    explicit PingPlugin(QObject *parent, const QVariantList &args);
-    virtual ~PingPlugin();
-    
+    PauseMusicConfig(QWidget *parent, const QVariantList&);
+    virtual ~PauseMusicConfig();
+
 public Q_SLOTS:
-    virtual bool receivePackage(const NetworkPackage& np);
-    virtual void connected() { };
+    virtual void save();
+    virtual void load();
+    virtual void defaults();
+
+private:
+    Ui::PauseMusicConfigUi* m_ui;
+    KSharedConfigPtr m_cfg;
 
 };
 
diff --git a/kded/plugins/pausemusic/pausemusic_config.ui b/kded/plugins/pausemusic/pausemusic_config.ui
new file mode 100644
index 0000000..8c4f5ff
--- /dev/null
+++ b/kded/plugins/pausemusic/pausemusic_config.ui
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PauseMusicConfigUi</class>
+ <widget class="QWidget" name="PauseMusicConfigUi">
+  <property name="windowModality">
+   <enum>Qt::WindowModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>252</width>
+    <height>175</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Pause music plugin</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="title">
+      <string>Pause condition</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QRadioButton" name="rad_ringing">
+        <property name="text">
+         <string>Pause as soon as phone rings</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="rad_talking">
+        <property name="text">
+         <string>Pause only while talking</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/kded/plugins/pausemusic/pausemusicplugin.cpp b/kded/plugins/pausemusic/pausemusicplugin.cpp
index 5844ea6..a0e8b16 100644
--- a/kded/plugins/pausemusic/pausemusicplugin.cpp
+++ b/kded/plugins/pausemusic/pausemusicplugin.cpp
@@ -26,6 +26,9 @@
 #include <QDBusReply>
 #include <QDBusMessage>
 
+#include <KSharedConfig>
+#include <KConfigGroup>
+
 #include "../../kdebugnamespace.h"
 
 K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< PauseMusicPlugin >(); )
@@ -33,25 +36,26 @@ K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_pausemusic", "kdeconnect_pa
 
 PauseMusicPlugin::PauseMusicPlugin(QObject* parent, const QVariantList& args)
     : KdeConnectPlugin(parent, args)
-    , pauseWhen(PauseWhenRinging) //TODO: Be able to change this from plugin settings
 {
+
 }
 
 bool PauseMusicPlugin::receivePackage(const NetworkPackage& np)
 {
-    switch(pauseWhen) {
-        case PauseWhenRinging:
-            if (np.get<QString>("event") != "ringing" && np.get<QString>("event") != "talking") {
-                return true;
-            }
-            break;
-        case PauseWhenTalking:
-            if (np.get<QString>("event") != "talking") {
-                return true;
-            }
-            break;
-        case NeverPause:
+    //FIXME: There should be a better way to listen to changes in the config file instead of reading the value each time
+    KSharedConfigPtr config = KSharedConfig::openConfig("kdeconnect/plugins/kdeconnect_pausemusic");
+    bool pauseOnlyWhenTalking = config->group("pause_condition").readEntry("talking_only", false);
+
+    if (pauseOnlyWhenTalking) {
+        qDebug() << "pause when talking";
+        if (np.get<QString>("event") != "talking") {
+            return true;
+        }
+    } else { //Pause as soon as it rings
+        qDebug() << "pause when ringing";
+        if (np.get<QString>("event") != "ringing" && np.get<QString>("event") != "talking") {
             return true;
+        }
     }
 
     bool pauseConditionFulfilled = !np.get<bool>("isCancel");
diff --git a/kded/plugins/pausemusic/pausemusicplugin.h b/kded/plugins/pausemusic/pausemusicplugin.h
index 8cd0c37..2b5b32b 100644
--- a/kded/plugins/pausemusic/pausemusicplugin.h
+++ b/kded/plugins/pausemusic/pausemusicplugin.h
@@ -40,8 +40,6 @@ public Q_SLOTS:
     virtual void connected() { };
     
 private:
-    enum PauseCondtions { PauseWhenTalking, PauseWhenRinging, NeverPause };
-    PauseCondtions pauseWhen;
     QSet<QString> pausedSources;
 
 };

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list