kdeplasma-addons: audio player control runner review

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-07-27 19:30:10 +03:00
parent 47724012d2
commit db4e43ae55
6 changed files with 247 additions and 310 deletions

View file

@ -1,3 +0,0 @@
Fix Bugs:
226119
225260

View file

@ -20,7 +20,6 @@
#ifndef AUDIOPLAYERCONTROLRUNNERCONFIGKEYS_H
#define AUDIOPLAYERCONTROLRUNNERCONFIGKEYS_H
static const char * CONFIG_COMMANDS = "useCommands";
static const char * CONFIG_PLAY = "com_play";
static const char * CONFIG_APPEND = "com_append";
static const char * CONFIG_PAUSE = "com_pause";

View file

@ -36,6 +36,7 @@
#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 */
@ -102,7 +103,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
QList<Plasma::QueryMatch> matches;
if (m_useCommands && context.isValid() ) {
if (context.isValid() ) {
QVariantList playcontrol;
playcontrol << QLatin1String("/org/mpris/MediaPlayer2") << QLatin1String("org.mpris.MediaPlayer2.Player");
@ -116,8 +117,8 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
}
if (!m_running) {
// The interface of the player is not availalbe, so the rest of the commands is not needed
context.addMatches(term,matches);
// The interface of the player is not availalbe, so the rest of the commands are not needed
context.addMatches(term, matches);
return;
}
@ -167,7 +168,7 @@ void AudioPlayerControlRunner::match(Plasma::RunnerContext &context)
// Quit player
if (m_comQuit.startsWith(term, Qt::CaseInsensitive)) {
QVariantList data;
data << QLatin1String("/org/mpris/MediaPlayer2") << QLatin1String("org.mpris.MediaPlayer2")
data << QLatin1String("/org/mpris/MediaPlayer2") << QLatin1String("org.mpris.MediaPlayer2")
<< QLatin1String("Quit") << NONE << QLatin1String("nostart");
matches << createMatch(this, i18n("Quit %1", m_identity), QLatin1String(""),
QLatin1String("quit"), KIcon(QLatin1String("application-exit")), data, 1.0);
@ -214,7 +215,7 @@ QList<QAction*> AudioPlayerControlRunner::actionsForMatch(const Plasma::QueryMat
QList<QAction*> ret;
QVariantList data = match.data().value<QVariantList>();
if (data.length() > 3 && data[3].toString().compare(NONE)) {
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"));
@ -233,7 +234,6 @@ void AudioPlayerControlRunner::reloadConfiguration()
{
KConfigGroup grp = config();
m_player = grp.readEntry(CONFIG_PLAYER, "vlc");
m_useCommands = grp.readEntry(CONFIG_COMMANDS, true);
m_comPlay = grp.readEntry(CONFIG_PLAY, i18n("play"));
m_comAppend = grp.readEntry(CONFIG_APPEND, i18n("append"));
m_comPause = grp.readEntry(CONFIG_PAUSE, i18n("pause"));

View file

@ -26,8 +26,6 @@
#include <KIcon>
#include <KUrl>
#include <QDBusPendingCallWatcher>
class AudioPlayerControlRunner : public Plasma::AbstractRunner
{
Q_OBJECT
@ -78,7 +76,6 @@ private:
/** The player this runner controls */
QString m_player;
//The commands
/** Command for play a song */
QString m_comPlay;
/** Command for append a song */
@ -96,9 +93,6 @@ private:
/** Command for quit the player */
QString m_comQuit;
/** Use the commands */
bool m_useCommands;
/** The running state of the player */
bool m_running;

View file

@ -41,7 +41,6 @@ AudioPlayerControlRunnerConfig::AudioPlayerControlRunnerConfig(QWidget* parent,
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(m_ui, 0, 0);
connect(m_ui->commands, SIGNAL(clicked(bool)),this,SLOT(changed()));
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()));
@ -81,7 +80,6 @@ void AudioPlayerControlRunnerConfig::load()
} else {
m_ui->player_combo->setCurrentIndex(index);
}
m_ui->commands->setChecked(grp.readEntry(CONFIG_COMMANDS,true));
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")));
@ -101,7 +99,6 @@ void AudioPlayerControlRunnerConfig::save()
KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QLatin1String("krunnerrc"));
KConfigGroup grp = cfg->group("Runners");
grp = KConfigGroup(&grp, "Audio Player Control Runner");
grp.writeEntry(CONFIG_COMMANDS,m_ui->commands->isChecked());
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());
@ -127,7 +124,6 @@ void AudioPlayerControlRunnerConfig::defaults()
KCModule::defaults();
m_ui->player_combo->setCurrentIndex(m_ui->player_combo->findData(QLatin1String("vlc")));
m_ui->commands->setChecked(true);
m_ui->play_edit->setText(i18n("Play"));
m_ui->append_edit->setText(i18n("Append"));
m_ui->pause_edit->setText(i18n("Pause")) ;

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>354</height>
<width>421</width>
<height>318</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -39,293 +39,255 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="commands">
<property name="locale">
<locale language="English" country="UnitedStates"/>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="title">
<string>Use Command&amp;s</string>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="play_layout">
<item>
<widget class="QLabel" name="play_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Pla&amp;y:</string>
</property>
<property name="buddy">
<cstring>play_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="play_edit">
<property name="toolTip">
<string>Can be used as &quot;Play&quot; for playing and &quot;Play &lt;song&gt;&quot; for playing a song that matches to &lt;song&gt; (in title, artist and album)</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<widget class="QLabel" name="next_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>&amp;Next song:</string>
</property>
<property name="buddy">
<cstring>next_edit</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="append_layout">
<item>
<widget class="QLabel" name="append_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Ap&amp;pend a song:</string>
</property>
<property name="buddy">
<cstring>append_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="append_edit">
<property name="toolTip">
<string>Use: append &lt;term&gt; (where &lt;term&gt; matches to artist, title or album)</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<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&amp;top:</string>
</property>
<property name="buddy">
<cstring>stop_edit</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="pause_layout">
<item>
<widget class="QLabel" name="pause_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>P&amp;ause:</string>
</property>
<property name="buddy">
<cstring>pause_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="pause_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<item row="5" column="0">
<widget class="QLabel" name="prev_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Previ&amp;ous song:</string>
</property>
<property name="buddy">
<cstring>prev_edit</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="stop_layout">
<item>
<widget class="QLabel" name="stop_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>S&amp;top:</string>
</property>
<property name="buddy">
<cstring>stop_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="stop_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<item row="2" column="1">
<widget class="KLineEdit" name="append_edit">
<property name="toolTip">
<string>Use: append &lt;term&gt; (where &lt;term&gt; matches to artist, title or album)</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="prev_layout">
<item>
<widget class="QLabel" name="prev_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Previ&amp;ous song:</string>
</property>
<property name="buddy">
<cstring>prev_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="prev_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<item row="8" column="0">
<widget class="QLabel" name="quit_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Quit player:</string>
</property>
<property name="buddy">
<cstring>quit_edit</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="next_layout">
<item>
<widget class="QLabel" name="next_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>&amp;Next song:</string>
</property>
<property name="buddy">
<cstring>next_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="next_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<item row="0" column="0">
<widget class="QLabel" name="play_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Pla&amp;y:</string>
</property>
<property name="buddy">
<cstring>play_edit</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="volume_layout">
<item>
<widget class="QLabel" name="volume_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Set &amp;volume:</string>
</property>
<property name="buddy">
<cstring>volume_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="volume_edit">
<property name="toolTip">
<string>The numbers are automatically added at the end:
<item row="4" column="1">
<widget class="KLineEdit" name="stop_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="volume_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Set &amp;volume:</string>
</property>
<property name="buddy">
<cstring>volume_edit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KLineEdit" name="play_edit">
<property name="toolTip">
<string>Can be used as &quot;Play&quot; for playing and &quot;Play &lt;song&gt;&quot; for playing a song that matches to &lt;song&gt; (in title, artist and album)</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</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&amp;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&amp;pend a song:</string>
</property>
<property name="buddy">
<cstring>append_edit</cstring>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="KLineEdit" name="volume_edit">
<property name="toolTip">
<string>The numbers are automatically added at the end:
Player:Volume=10</string>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="clickMessage">
<string/>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="clickMessage">
<string/>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="quit_layout">
<item>
<widget class="QLabel" name="quit_label">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string>Quit player:</string>
</property>
<property name="buddy">
<cstring>quit_edit</cstring>
</property>
</widget>
</item>
<item>
<widget class="KLineEdit" name="quit_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<item row="8" column="1">
<widget class="KLineEdit" name="quit_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="KLineEdit" name="prev_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KLineEdit" name="pause_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="KLineEdit" name="next_edit">
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
<property name="text">
<string/>
</property>
<property name="urlDropsEnabled">
<bool>false</bool>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
@ -352,17 +314,6 @@ Player:Volume=10</string>
<header>kcombobox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>commands</tabstop>
<tabstop>play_edit</tabstop>
<tabstop>append_edit</tabstop>
<tabstop>pause_edit</tabstop>
<tabstop>stop_edit</tabstop>
<tabstop>prev_edit</tabstop>
<tabstop>next_edit</tabstop>
<tabstop>volume_edit</tabstop>
<tabstop>quit_edit</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>