[SCM] ktp-kded-integration-module packaging branch, master, updated. debian/15.12.1-2-382-gbd961c2
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:14:10 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=6da4cfd
The following commit has been merged in the master branch:
commit 6da4cfde21e4be1d20e578827eb6b2d4702993e9
Author: Othmane Moustaouda <othmane.moustaouda at gmail.com>
Date: Thu Mar 29 17:06:09 2012 +0200
Make the 'Now listening..' presence string configurable
REVIEW: 104314
FEATURE: 282944
---
config/CMakeLists.txt | 2 ++
config/telepathy-kded-config.cpp | 51 ++++++++++++++++++++++++++++++++++------
config/telepathy-kded-config.h | 4 +++-
config/telepathy-kded-config.ui | 49 +++++++++++++++++++++++++-------------
telepathy-mpris.cpp | 20 +++++++++++++---
telepathy-mpris.h | 1 +
6 files changed, 100 insertions(+), 27 deletions(-)
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index bd0b3f8..992940a 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -1,6 +1,8 @@
set(kcm_ktp_integration_module_SRCS
column-resizer.cpp
telepathy-kded-config.cpp
+ nowplaying-lineedit.cpp
+ nowplaying-listwidget.cpp
)
set(kcm_ktp_integration_module_UI
diff --git a/config/telepathy-kded-config.cpp b/config/telepathy-kded-config.cpp
index 1fb515f..59f849c 100644
--- a/config/telepathy-kded-config.cpp
+++ b/config/telepathy-kded-config.cpp
@@ -1,6 +1,7 @@
/*
KControl Module for general Telepathy integration configs
Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ Copyright (C) 2012 Othmane Moustaouda <othmane.moustaouda at gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -23,8 +24,10 @@
#include <KPluginFactory>
#include <KLocalizedString>
+
#include <QDBusMessage>
#include <QDBusConnection>
+
#include "column-resizer.h"
K_PLUGIN_FACTORY(KCMTelepathyKDEDModuleConfigFactory, registerPlugin<TelepathyKDEDConfig>();)
@@ -36,6 +39,25 @@ TelepathyKDEDConfig::TelepathyKDEDConfig(QWidget *parent, const QVariantList& ar
ui(new Ui::TelepathyKDEDUi())
{
ui->setupUi(this);
+
+ m_tagNames << QLatin1String("%title") << QLatin1String("%artist") << QLatin1String("%album") << QLatin1String("%track");
+ m_localizedTagNames << i18nc("Title tag in now playing plugin, use one word and keep the '%' character.", "%title")
+ << i18nc("Artist tag in now playing plugin, use one word and keep the '%' character.", "%artist")
+ << i18nc("Album tag in now playing plugin, use one word and keep the '%' character.", "%album")
+ << i18nc("Track number tag in now playing plugin, use one word and keep the '%' character.", "%track");
+
+ QStringList itemsIcons;
+ itemsIcons << QLatin1String("view-media-lyrics") //%title
+ << QLatin1String("view-media-artist") //%artist
+ << QLatin1String("view-media-playlist") //%album
+ << QLatin1String("mixer-cd"); //%track
+
+ ui->m_tagListWidget->setItemsIcons(itemsIcons);
+ ui->m_tagListWidget->setLocalizedTagNames(m_localizedTagNames);
+ ui->m_tagListWidget->setupItems(); //populate the list, load items icons and set list's maximum size
+
+ ui->m_nowPlayingText->setLocalizedTagNames(m_localizedTagNames);
+
ColumnResizer *resizer = new ColumnResizer(this);
resizer->addWidgetsFromLayout(ui->incomingFilesGroupBox->layout(), 0);
resizer->addWidgetsFromLayout(ui->autoAwayGroupBox->layout(), 0);
@@ -145,11 +167,19 @@ void TelepathyKDEDConfig::load()
//now playing text
QString nowPlayingText = kdedConfig.readEntry(QLatin1String("nowPlayingText"),
- // xgettext: no-c-format
- i18nc("The text displayed by now playing plugin", "Now listening to %title by %author from album %album"));
+ i18nc("The default text displayed by now playing plugin. "
+ "track title: %1, artist: %2, album: %3",
+ "Now listening to %1 by %2 from album %3",
+ QLatin1String("%title"), QLatin1String("%artist"), QLatin1String("%album")));
+
+ //in nowPlayingText tag names aren't localized, here they're replaced with the localized ones
+ for (int i = 0; i < m_tagNames.size(); i++) {
+ nowPlayingText.replace(m_tagNames.at(i), m_localizedTagNames.at(i));
+ }
+
ui->m_nowPlayingText->setText(nowPlayingText);
- // TODO enable this
- ui->m_nowPlayingText->setEnabled(nowPlayingEnabled && false);
+ ui->m_nowPlayingText->setEnabled(nowPlayingEnabled);
+ ui->m_tagListWidget->setEnabled(nowPlayingEnabled);
}
void TelepathyKDEDConfig::save()
@@ -173,7 +203,14 @@ void TelepathyKDEDConfig::save()
kdedConfig.writeEntry(QLatin1String("xaAfter"), ui->m_xaMins->value());
kdedConfig.writeEntry(QLatin1String("xaMessage"), ui->m_xaMessage->text());
kdedConfig.writeEntry(QLatin1String("nowPlayingEnabled"), ui->m_nowPlayingCheckBox->isChecked());
- kdedConfig.writeEntry(QLatin1String("nowPlayingText"), ui->m_nowPlayingText->text());
+
+ //we store a nowPlayingText version with untranslated tag names
+ QString modifiedNowPlayingText = ui->m_nowPlayingText->text();
+ for (int i = 0; i < m_tagNames.size(); i++) {
+ modifiedNowPlayingText.replace(m_localizedTagNames.at(i), m_tagNames.at(i));
+ }
+
+ kdedConfig.writeEntry(QLatin1String("nowPlayingText"), modifiedNowPlayingText);
kdedConfig.sync();
QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/Telepathy"),
@@ -204,8 +241,8 @@ void TelepathyKDEDConfig::autoXAChecked(bool checked)
void TelepathyKDEDConfig::nowPlayingChecked(bool checked)
{
- // TODO Enable this
- ui->m_nowPlayingText->setEnabled(checked && false);
+ ui->m_nowPlayingText->setEnabled(checked);
+ ui->m_tagListWidget->setEnabled(checked);
Q_EMIT changed(true);
}
diff --git a/config/telepathy-kded-config.h b/config/telepathy-kded-config.h
index 670c513..8b27d13 100644
--- a/config/telepathy-kded-config.h
+++ b/config/telepathy-kded-config.h
@@ -1,6 +1,7 @@
/*
KControl Module for general Telepathy integration configs
Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ Copyright (C) 2012 Othmane Moustaouda <othmane.moustaouda at gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -46,8 +47,9 @@ private Q_SLOTS:
void nowPlayingChecked(bool checked);
private:
+ QStringList m_tagNames;
+ QStringList m_localizedTagNames;
Ui::TelepathyKDEDUi *ui;
-
};
#endif // TELEPATHY_KDED_CONFIG_H
diff --git a/config/telepathy-kded-config.ui b/config/telepathy-kded-config.ui
index 0d616c5..e08e717 100644
--- a/config/telepathy-kded-config.ui
+++ b/config/telepathy-kded-config.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>669</width>
- <height>517</height>
+ <width>703</width>
+ <height>560</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -283,6 +283,9 @@
<string>Now playing</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
<item row="0" column="0">
<widget class="QLabel" name="m_nowPlayingLabel">
<property name="text">
@@ -304,28 +307,32 @@
</widget>
</item>
<item row="3" column="1">
- <widget class="QLineEdit" name="m_nowPlayingText">
+ <widget class="NowPlayingLineEdit" name="m_nowPlayingText">
<property name="text">
<string/>
</property>
</widget>
</item>
+ <item row="5" column="1">
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="1">
+ <widget class="NowPlayingListWidget" name="m_tagListWidget">
+ </widget>
+ </item>
</layout>
</widget>
</item>
- <item>
- <spacer name="verticalSpacer_3">
- <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>
<customwidgets>
@@ -339,6 +346,16 @@
<extends>QFrame</extends>
<header>kurlrequester.h</header>
</customwidget>
+ <customwidget>
+ <class>NowPlayingLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>nowplaying-lineedit.h</header>
+ </customwidget>
+ <customwidget>
+ <class>NowPlayingListWidget</class>
+ <extends>QListWidget</extends>
+ <header>nowplaying-listwidget.h</header>
+ </customwidget>
</customwidgets>
<resources/>
<connections/>
diff --git a/telepathy-mpris.cpp b/telepathy-mpris.cpp
index 8dae701..543109c 100644
--- a/telepathy-mpris.cpp
+++ b/telepathy-mpris.cpp
@@ -27,6 +27,7 @@
#include <KDebug>
#include <KSharedConfig>
#include <KConfigGroup>
+#include <KLocalizedString>
#include <TelepathyQt/AccountSet>
@@ -76,6 +77,7 @@ void TelepathyMPRIS::onPlayerSignalReceived(const QString &interface, const QVar
QString artist;
QString title;
QString album;
+ QString trackNumber;
//FIXME We can do less lame parsing...maybe.
Q_FOREACH (const QVariant &property, changedProperties.values()) {
@@ -99,6 +101,7 @@ void TelepathyMPRIS::onPlayerSignalReceived(const QString &interface, const QVar
artist = metadata.value(QLatin1String("xesam:artist")).toString();
title = metadata.value(QLatin1String("xesam:title")).toString();
album = metadata.value(QLatin1String("xesam:album")).toString();
+ trackNumber = metadata.value(QLatin1String("xesam:trackNumber")).toString();
trackInfoFound = true;
break;
}
@@ -109,12 +112,19 @@ void TelepathyMPRIS::onPlayerSignalReceived(const QString &interface, const QVar
}
if (trackInfoFound) {
- Tp::Presence currentPresence = m_globalPresence->currentPresence();
+ //we replace track's info in custom nowPlayingText
+ QString statusMessage = m_nowPlayingText;
+ statusMessage.replace(QLatin1String("%title"), title, Qt::CaseInsensitive);
+ statusMessage.replace(QLatin1String("%artist"), artist, Qt::CaseInsensitive);
+ statusMessage.replace(QLatin1String("%album"), album, Qt::CaseInsensitive);
+ statusMessage.replace(QLatin1String("%track"), trackNumber, Qt::CaseInsensitive);
+ Tp::Presence currentPresence = m_globalPresence->currentPresence();
Tp::SimplePresence presence;
+
presence.type = currentPresence.type();
presence.status = currentPresence.status();
- presence.statusMessage = QString(QLatin1String("Now listening to %1 by %2 from album %3")).arg(title, artist, album);
+ presence.statusMessage = statusMessage;
setRequestedPresence(Tp::Presence(presence));
if (m_presenceActivated) {
@@ -147,7 +157,6 @@ void TelepathyMPRIS::detectPlayers()
QLatin1String("PropertiesChanged"),
this,
SLOT(onPlayerSignalReceived(QString,QVariantMap,QStringList)) );
-
}
players.append(service);
@@ -173,6 +182,11 @@ void TelepathyMPRIS::onSettingsChanged()
//if the plugin was disabled and is now enabled
if (!isEnabled() && pluginEnabled) {
setEnabled(true);
+ QString m_nowPlayingText = kdedConfig.readEntry(QLatin1String("nowPlayingText"),
+ i18nc("The default text displayed by now playing plugin. "
+ "track title: %1, artist: %2, album: %3",
+ "Now listening to %1 by %2 from album %3",
+ QLatin1String("%title"), QLatin1String("%artist"), QLatin1String("%album")));
detectPlayers();
}
}
diff --git a/telepathy-mpris.h b/telepathy-mpris.h
index d909863..f8ab6cb 100644
--- a/telepathy-mpris.h
+++ b/telepathy-mpris.h
@@ -49,6 +49,7 @@ Q_SIGNALS:
private:
QStringList m_knownPlayers;
bool m_presenceActivated;
+ QString m_nowPlayingText;
};
#endif // TELEPATHY_MPRIS_H
--
ktp-kded-integration-module packaging
More information about the pkg-kde-commits
mailing list