Skip to content

Commit

Permalink
Audio volumes will now be restored on start
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilInTheGaps committed Dec 6, 2023
1 parent f52de40 commit 64e4849
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/tools/audio/audiotool.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "audiotool.h"
#include "audiosaveload.h"
#include "services/spotify/spotify.h"
#include "settings/settingsmanager.h"
#include "thumbnails/audiothumbnailgenerator.h"
#include "utils/utils.h"
#include <QLoggingCategory>
Expand All @@ -11,6 +12,7 @@

using namespace Qt::Literals::StringLiterals;
using namespace Services;
using namespace Common::Settings;

Q_LOGGING_CATEGORY(gmAudioTool, "gm.audio.tool")

Expand Down Expand Up @@ -48,8 +50,11 @@ AudioTool::AudioTool(QQmlEngine *engine, QObject *parent)
connect(&mprisManager, &MprisManager::next, this, [this]() { next(); });
connect(&mprisManager, &MprisManager::previous, this, [this]() { again(); });
connect(&mprisManager, &MprisManager::changeVolume, this,
[this](double volume) { setMusicVolume(static_cast<int>(volume)); });
[this](double volume) { setMusicVolume(static_cast<float>(volume)); });
#endif

setMusicVolume(SettingsManager::instance()->get("musicVolume"_L1, DEFAULT_MUSIC_VOLUME));
setSoundVolume(SettingsManager::instance()->get("soundVolume"_L1, DEFAULT_SOUND_VOLUME));
}

auto AudioTool::create(QQmlEngine *qmlEngine, QJSEngine *jsEngine) -> AudioTool *
Expand Down Expand Up @@ -261,6 +266,8 @@ void AudioTool::setMusicVolume(float volume)
#ifndef NO_DBUS
mprisManager.setVolume(logarithmicVolume);
#endif

SettingsManager::instance()->set("musicVolume"_L1, volume);
}

/**
Expand All @@ -274,6 +281,8 @@ void AudioTool::setSoundVolume(float volume)
m_soundVolume = volume;

soundPlayerController.setVolume(linearVolume, logarithmicVolume);

SettingsManager::instance()->set("soundVolume"_L1, volume);
}

auto AudioTool::makeLinearVolume(float linearVolume) -> int
Expand Down

0 comments on commit 64e4849

Please sign in to comment.