mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
kdeplasma-addons: remove audio player control runner append feature
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ac1cfae224
commit
a60449edfa
5 changed files with 39 additions and 107 deletions
|
@ -21,7 +21,6 @@
|
|||
#define AUDIOPLAYERCONTROLRUNNERCONFIGKEYS_H
|
||||
|
||||
static const char * CONFIG_PLAY = "com_play";
|
||||
static const char * CONFIG_APPEND = "com_append";
|
||||
static const char * CONFIG_PAUSE = "com_pause";
|
||||
static const char * CONFIG_NEXT = "com_next";
|
||||
static const char * CONFIG_PREV = "com_prev";
|
||||
|
|
|
@ -36,19 +36,9 @@
|
|||
#include <KRun>
|
||||
#include <KUrl>
|
||||
|
||||
// TODO: rewrite append feature to add URL to the tracks list via org.mpris.MediaPlayer2.TrackList.AddTrack
|
||||
/** The variable PLAY contains the action label for play */
|
||||
static const QString PLAY(QLatin1String("play"));
|
||||
/** The variable APPEND contains the action label for append */
|
||||
static const QString APPEND(QLatin1String("append"));
|
||||
/** The variable NONE says that no action is needed */
|
||||
static const QString NONE(QLatin1String("none"));
|
||||
|
||||
// for reference:
|
||||
// https://specifications.freedesktop.org/mpris-spec/latest/
|
||||
|
||||
typedef QList<QDBusObjectPath> TrackListType;
|
||||
|
||||
AudioPlayerControlRunner::AudioPlayerControlRunner(QObject *parent, const QVariantList& args)
|
||||
: Plasma::AbstractRunner(parent, args)
|
||||
{
|
||||
|
@ -111,7 +101,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
|
|||
if (m_comPlay.startsWith(term, Qt::CaseInsensitive) &&
|
||||
(!m_running || (m_canPlay && m_playbackStatus != QLatin1String("Playing")))) {
|
||||
QVariantList data = playcontrol;
|
||||
data << QLatin1String("Play") << NONE << QLatin1String("start");
|
||||
data << QLatin1String("Play") << QLatin1String("start");
|
||||
matches << createMatch(this, i18n("Start playing"), i18n("Audio player control"),
|
||||
QLatin1String("play"), KIcon(QLatin1String("media-playback-start")), data, 1.0);
|
||||
}
|
||||
|
@ -125,7 +115,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
|
|||
// Next song
|
||||
if (m_comNext.startsWith(term, Qt::CaseInsensitive) && m_canGoNext) {
|
||||
QVariantList data = playcontrol;
|
||||
data << QLatin1String("Next") << NONE << QLatin1String("nostart");
|
||||
data << QLatin1String("Next") << QLatin1String("nostart");
|
||||
matches << createMatch(this, i18n("Play next song"), i18n("Audio player control"),
|
||||
QLatin1String("next"), KIcon(QLatin1String("media-skip-forward")), data, 1.0);
|
||||
}
|
||||
|
@ -133,7 +123,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
|
|||
// Previous song
|
||||
if (m_comPrev.startsWith(term, Qt::CaseInsensitive) && m_canGoPrevious) {
|
||||
QVariantList data = playcontrol;
|
||||
data << QLatin1String("Previous") << NONE << QLatin1String("nostart");
|
||||
data << QLatin1String("Previous") << QLatin1String("nostart");
|
||||
matches << createMatch(this, i18n("Play previous song"), i18n("Audio player control") ,
|
||||
QLatin1String("previous"), KIcon(QLatin1String("media-skip-backward")), data, 1.0);
|
||||
}
|
||||
|
@ -141,7 +131,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
|
|||
// Pause
|
||||
if (m_comPause.startsWith(term, Qt::CaseInsensitive) && m_playbackStatus == QLatin1String("Playing")) {
|
||||
QVariantList data = playcontrol;
|
||||
data << QLatin1String("Pause") << NONE << QLatin1String("nostart");
|
||||
data << QLatin1String("Pause") << QLatin1String("nostart");
|
||||
matches << createMatch(this, i18n("Pause playing"), i18n("Audio player control"),
|
||||
QLatin1String("pause"), KIcon(QLatin1String("media-playback-pause")), data, 1.0);
|
||||
}
|
||||
|
@ -149,7 +139,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
|
|||
// Stop
|
||||
if (m_comStop.startsWith(term, Qt::CaseInsensitive) && m_playbackStatus == QLatin1String("Playing")) {
|
||||
QVariantList data = playcontrol;
|
||||
data << QLatin1String("Stop") << NONE << QLatin1String("nostart");
|
||||
data << QLatin1String("Stop") << QLatin1String("nostart");
|
||||
matches << createMatch(this, i18n("Stop playing"), i18n("Audio player control"),
|
||||
QLatin1String("stop"), KIcon(QLatin1String("media-playback-stop")), data, 1.0);
|
||||
}
|
||||
|
@ -160,7 +150,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
|
|||
if (volumeRegxp.exactMatch(term)) {
|
||||
QVariantList data = playcontrol;
|
||||
int newVolume = getNumber(term , ' ');
|
||||
data << QLatin1String("Volume") << NONE << QLatin1String("nostart") << (newVolume / 100.0);
|
||||
data << QLatin1String("Volume") << QLatin1String("nostart") << (newVolume / 100.0);
|
||||
matches << createMatch(this, i18n("Set volume to %1%" , newVolume),
|
||||
QLatin1String("volume"), i18n("Audio player control"), KIcon(QLatin1String("audio-volume-medium")), data, 1.0);
|
||||
}
|
||||
|
@ -169,7 +159,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
|
|||
if (m_comQuit.startsWith(term, Qt::CaseInsensitive)) {
|
||||
QVariantList data;
|
||||
data << QLatin1String("/org/mpris/MediaPlayer2") << QLatin1String("org.mpris.MediaPlayer2")
|
||||
<< QLatin1String("Quit") << NONE << QLatin1String("nostart");
|
||||
<< QLatin1String("Quit") << QLatin1String("nostart");
|
||||
matches << createMatch(this, i18n("Quit %1", m_identity), QLatin1String(""),
|
||||
QLatin1String("quit"), KIcon(QLatin1String("application-exit")), data, 1.0);
|
||||
}
|
||||
|
@ -184,7 +174,7 @@ void AudioPlayerControlRunner::run(const Plasma::RunnerContext &context, const P
|
|||
|
||||
QVariantList data = match.data().value<QVariantList>();
|
||||
|
||||
if (data[4].toString().compare(QLatin1String("start")) == 0) {
|
||||
if (data[3].toString().compare(QLatin1String("start")) == 0) {
|
||||
// The players's interface isn't available but it should be started
|
||||
if (!startPlayer()) {
|
||||
return;
|
||||
|
@ -195,7 +185,7 @@ void AudioPlayerControlRunner::run(const Plasma::RunnerContext &context, const P
|
|||
if (data[2].toString().compare(QLatin1String("Volume")) == 0) {
|
||||
QDBusInterface player(QString::fromLatin1("org.mpris.MediaPlayer2.%1").arg(m_player),
|
||||
data[0].toString(), data[1].toString());
|
||||
player.setProperty(data[2].toByteArray(), data[5]);
|
||||
player.setProperty(data[2].toByteArray(), data[4]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -203,39 +193,18 @@ void AudioPlayerControlRunner::run(const Plasma::RunnerContext &context, const P
|
|||
data[0].toString(), data[1].toString(), data[2].toString());
|
||||
kDebug() << msg;
|
||||
QVariantList args;
|
||||
for (int i = 5; data.length() > i;++i) {
|
||||
for (int i = 4; data.length() > i;++i) {
|
||||
args << data[i];
|
||||
}
|
||||
msg.setArguments(args);
|
||||
QDBusConnection::sessionBus().call(msg, QDBus::NoBlock);
|
||||
}
|
||||
|
||||
QList<QAction*> AudioPlayerControlRunner::actionsForMatch(const Plasma::QueryMatch &match)
|
||||
{
|
||||
QList<QAction*> ret;
|
||||
QVariantList data = match.data().value<QVariantList>();
|
||||
|
||||
if (data.length() > 3 && data[3].toString().compare(NONE) == 0) {
|
||||
if (!action(PLAY)) {
|
||||
addAction(PLAY, KIcon(QLatin1String("media-playback-start")), i18n("Play"));
|
||||
addAction(APPEND, KIcon(QLatin1String("media-track-add-amarok")), i18n("Append to playlist"));
|
||||
}
|
||||
|
||||
const QStringList actions = data[3].toString().split(QLatin1Char( ',' ));
|
||||
for (int i = 0; i < actions.length(); ++i) {
|
||||
ret << action(actions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AudioPlayerControlRunner::reloadConfiguration()
|
||||
{
|
||||
KConfigGroup grp = config();
|
||||
m_player = grp.readEntry(CONFIG_PLAYER, "vlc");
|
||||
m_comPlay = grp.readEntry(CONFIG_PLAY, i18n("play"));
|
||||
m_comAppend = grp.readEntry(CONFIG_APPEND, i18n("append"));
|
||||
m_comPause = grp.readEntry(CONFIG_PAUSE, i18n("pause"));
|
||||
m_comNext = grp.readEntry(CONFIG_NEXT, i18n("next"));
|
||||
m_comPrev = grp.readEntry(CONFIG_PREV, i18n("prev"));
|
||||
|
|
|
@ -36,7 +36,6 @@ public:
|
|||
|
||||
void match(Plasma::RunnerContext &context);
|
||||
void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match);
|
||||
QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match);
|
||||
|
||||
void reloadConfiguration();
|
||||
|
||||
|
@ -78,8 +77,6 @@ private:
|
|||
|
||||
/** Command for play a song */
|
||||
QString m_comPlay;
|
||||
/** Command for append a song */
|
||||
QString m_comAppend;
|
||||
/** Command for pause playing */
|
||||
QString m_comPause;
|
||||
/** Command for stop playing */
|
||||
|
|
|
@ -44,7 +44,6 @@ AudioPlayerControlRunnerConfig::AudioPlayerControlRunnerConfig(QWidget* parent,
|
|||
connect(m_ui->player_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->player_combo, SIGNAL(editTextChanged(QString)), this, SLOT(changed()));
|
||||
connect(m_ui->play_edit, SIGNAL(textChanged(QString)), this, SLOT(changed()));
|
||||
connect(m_ui->append_edit, SIGNAL(textChanged(QString)),this,SLOT(changed()));
|
||||
connect(m_ui->pause_edit, SIGNAL(textChanged(QString)), this, SLOT(changed()));
|
||||
connect(m_ui->next_edit, SIGNAL(textChanged(QString)), this, SLOT(changed()));
|
||||
connect(m_ui->prev_edit, SIGNAL(textChanged(QString)), this, SLOT(changed()));
|
||||
|
@ -81,7 +80,6 @@ void AudioPlayerControlRunnerConfig::load()
|
|||
m_ui->player_combo->setCurrentIndex(index);
|
||||
}
|
||||
m_ui->play_edit->setText(grp.readEntry(CONFIG_PLAY , i18n("play")));
|
||||
m_ui->append_edit->setText(grp.readEntry(CONFIG_APPEND, i18n("append")));
|
||||
m_ui->pause_edit->setText(grp.readEntry(CONFIG_PAUSE, i18n("pause")));
|
||||
m_ui->next_edit->setText(grp.readEntry(CONFIG_NEXT, i18nc("next song", "next")));
|
||||
m_ui->prev_edit->setText(grp.readEntry(CONFIG_PREV , i18nc("previous song", "prev")));
|
||||
|
@ -100,7 +98,6 @@ void AudioPlayerControlRunnerConfig::save()
|
|||
KConfigGroup grp = cfg->group("Runners");
|
||||
grp = KConfigGroup(&grp, "Audio Player Control Runner");
|
||||
grp.writeEntry(CONFIG_PLAY, m_ui->play_edit->text());
|
||||
grp.writeEntry(CONFIG_APPEND, m_ui->append_edit->text());
|
||||
grp.writeEntry(CONFIG_PAUSE, m_ui->pause_edit->text());
|
||||
grp.writeEntry(CONFIG_STOP, m_ui->stop_edit->text());
|
||||
grp.writeEntry(CONFIG_PREV, m_ui->prev_edit->text());
|
||||
|
@ -125,7 +122,6 @@ void AudioPlayerControlRunnerConfig::defaults()
|
|||
|
||||
m_ui->player_combo->setCurrentIndex(m_ui->player_combo->findData(QLatin1String("vlc")));
|
||||
m_ui->play_edit->setText(i18n("Play"));
|
||||
m_ui->append_edit->setText(i18n("Append"));
|
||||
m_ui->pause_edit->setText(i18n("Pause")) ;
|
||||
m_ui->next_edit->setText(i18n("Next"));
|
||||
m_ui->prev_edit->setText(i18n("Prev"));
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>421</width>
|
||||
<height>318</height>
|
||||
<height>292</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
|
@ -47,7 +47,7 @@
|
|||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="next_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -61,19 +61,6 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="stop_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>S&top:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>stop_edit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="prev_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -86,23 +73,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="KLineEdit" name="append_edit">
|
||||
<property name="toolTip">
|
||||
<string>Use: append <term> (where <term> matches to artist, title or album)</string>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="stop_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="urlDropsEnabled">
|
||||
<bool>false</bool>
|
||||
<property name="text">
|
||||
<string>S&top:</string>
|
||||
</property>
|
||||
<property name="showClearButton" stdset="0">
|
||||
<bool>true</bool>
|
||||
<property name="buddy">
|
||||
<cstring>stop_edit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="quit_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -128,7 +112,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="KLineEdit" name="stop_edit">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -144,7 +128,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="volume_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -157,6 +141,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="pause_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>P&ause:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>pause_edit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="KLineEdit" name="play_edit">
|
||||
<property name="toolTip">
|
||||
|
@ -176,33 +173,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="pause_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>P&ause:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>pause_edit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="append_label">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ap&pend a song:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>append_edit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="KLineEdit" name="volume_edit">
|
||||
<property name="toolTip">
|
||||
<string>The numbers are automatically added at the end:
|
||||
|
@ -225,7 +196,7 @@ Player:Volume=10</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="KLineEdit" name="quit_edit">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -241,7 +212,7 @@ Player:Volume=10</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="KLineEdit" name="prev_edit">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -257,7 +228,7 @@ Player:Volume=10</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="KLineEdit" name="pause_edit">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
@ -273,7 +244,7 @@ Player:Volume=10</string>
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="KLineEdit" name="next_edit">
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue