[pausemusic] Add option to not unpause music once call has finished.
This commit is contained in:
parent
fbadf09fb5
commit
83a152f41f
4 changed files with 31 additions and 8 deletions
|
@ -35,6 +35,7 @@ PauseMusicConfig::PauseMusicConfig(QWidget* parent, const QVariantList& args)
|
|||
connect(m_ui->rad_talking, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->check_pause, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->check_mute, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
connect(m_ui->check_resume, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
}
|
||||
|
||||
PauseMusicConfig::~PauseMusicConfig()
|
||||
|
@ -49,6 +50,7 @@ void PauseMusicConfig::defaults()
|
|||
m_ui->rad_ringing->setChecked(true);
|
||||
m_ui->check_pause->setChecked(true);
|
||||
m_ui->check_mute->setChecked(false);
|
||||
m_ui->check_resume->setChecked(true);
|
||||
Q_EMIT changed(true);
|
||||
}
|
||||
|
||||
|
@ -64,6 +66,9 @@ void PauseMusicConfig::load()
|
|||
m_ui->check_pause->setChecked(pause);
|
||||
m_ui->check_mute->setChecked(mute);
|
||||
|
||||
const bool autoResume = config()->get(QStringLiteral("actionResume"), true);
|
||||
m_ui->check_resume->setChecked(autoResume);
|
||||
|
||||
Q_EMIT changed(false);
|
||||
}
|
||||
|
||||
|
@ -72,6 +77,7 @@ void PauseMusicConfig::save()
|
|||
config()->set(QStringLiteral("conditionTalking"), m_ui->rad_talking->isChecked());
|
||||
config()->set(QStringLiteral("actionPause"), m_ui->check_pause->isChecked());
|
||||
config()->set(QStringLiteral("actionMute"), m_ui->check_mute->isChecked());
|
||||
config()->set(QStringLiteral("actionResume"), m_ui->check_resume->isChecked());
|
||||
KCModule::save();
|
||||
Q_EMIT changed(false);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="check_resume">
|
||||
<property name="text">
|
||||
<string>Automatically resume media when call has finished</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -74,6 +74,8 @@ bool PauseMusicPlugin::receivePacket(const NetworkPacket& np)
|
|||
bool pause = config()->get(QStringLiteral("actionPause"), false);
|
||||
bool mute = config()->get(QStringLiteral("actionMute"), true);
|
||||
|
||||
const bool autoResume = config()->get(QStringLiteral("actionResume"), true);
|
||||
|
||||
if (pauseConditionFulfilled) {
|
||||
|
||||
if (mute) {
|
||||
|
@ -89,8 +91,10 @@ bool PauseMusicPlugin::receivePacket(const NetworkPacket& np)
|
|||
|
||||
if (mute) {
|
||||
qCDebug(KDECONNECT_PLUGIN_PAUSEMUSIC) << "Unmuting system volume";
|
||||
if (autoResume) {
|
||||
endpointVolume->SetMute(FALSE, &g_guidMyContext);
|
||||
}
|
||||
}
|
||||
if (pause) {
|
||||
// TODO UNPAUSING
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ bool PauseMusicPlugin::receivePacket(const NetworkPacket& np)
|
|||
bool pause = config()->get(QStringLiteral("actionPause"), true);
|
||||
bool mute = config()->get(QStringLiteral("actionMute"), false);
|
||||
|
||||
const bool autoResume = config()->get(QStringLiteral("actionResume"), true);
|
||||
|
||||
if (pauseConditionFulfilled) {
|
||||
|
||||
if (mute) {
|
||||
|
@ -98,20 +100,24 @@ bool PauseMusicPlugin::receivePacket(const NetworkPacket& np)
|
|||
|
||||
qCDebug(KDECONNECT_PLUGIN_PAUSEMUSIC) << "Unmuting system volume";
|
||||
|
||||
if (autoResume) {
|
||||
const auto sinks = PulseAudioQt::Context::instance()->sinks();
|
||||
for (const auto sink : sinks) {
|
||||
if (mutedSinks.contains(sink->name())) {
|
||||
sink->setMuted(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
mutedSinks.clear();
|
||||
}
|
||||
|
||||
if (pause && !pausedSources.empty()) {
|
||||
if (autoResume) {
|
||||
for (const QString& iface : qAsConst(pausedSources)) {
|
||||
OrgMprisMediaPlayer2PlayerInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), DBusHelper::sessionBus());
|
||||
mprisInterface.Play();
|
||||
}
|
||||
}
|
||||
pausedSources.clear();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue