Skip to content

Commit 872fd6d

Browse files
committed
use central KConfig
1 parent df48d0d commit 872fd6d

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/frontend_manager.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "frontend_manager.h"
22

3-
FrontendManager::FrontendManager(PipeWireManager *pipewire_manager, QObject *parent) : QObject(parent) {
3+
FrontendManager::FrontendManager(PipeWireManager *pipewire_manager, KConfig *config, QObject *parent) : QObject(parent) {
44
m_pipewire_manager = pipewire_manager;
5+
m_config = config;
56
connect(m_pipewire_manager, &PipeWireManager::error_occured, this, &FrontendManager::set_error_message);
67
load_hrir_wav_files();
78
}
@@ -84,10 +85,9 @@ void FrontendManager::set_hrir_wav_file_name_index(int index) {
8485
m_pipewire_manager->enable_routing();
8586

8687
// Write to config file
87-
KConfig config(QStringLiteral("virtual-surround-manager"));
88-
KConfigGroup group = config.group(QStringLiteral("Settings"));
88+
KConfigGroup group = m_config->group(QStringLiteral("Settings"));
8989
group.writeEntry("hrir_wav_file_path", m_hrir_wav_file_paths.value(m_hrir_wav_file_name_index));
90-
config.sync();
90+
m_config->sync();
9191

9292
Q_EMIT hrir_wav_file_name_index_changed();
9393
}
@@ -98,8 +98,7 @@ void FrontendManager::load_hrir_wav_files() {
9898

9999
// Read from config file if nothing has been selected in current session
100100
if (old_path.isEmpty()) {
101-
KConfig config(QStringLiteral("virtual-surround-manager"));
102-
KConfigGroup group = config.group(QStringLiteral("Settings"));
101+
KConfigGroup group = m_config->group(QStringLiteral("Settings"));
103102
old_path = group.readEntry("hrir_wav_file_path", QString());
104103
}
105104

src/frontend_manager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FrontendManager : public QObject {
3434
Q_PROPERTY(bool virtualSurroundAutoEnabled READ get_virtual_surround_auto_enabled WRITE set_virtual_surround_auto_enabled NOTIFY virtual_surround_auto_enabled_changed)
3535

3636
public:
37-
explicit FrontendManager(PipeWireManager *pipewire_manager, QObject *parent = nullptr);
37+
explicit FrontendManager(PipeWireManager *pipewire_manager, KConfig *config, QObject *parent = nullptr);
3838

3939
bool get_virtual_surround_enabled();
4040
void set_virtual_surround_enabled(bool value);
@@ -80,6 +80,7 @@ class FrontendManager : public QObject {
8080
bool m_virtual_surround_auto_enabled = false;
8181

8282
PipeWireManager *m_pipewire_manager;
83+
KConfig *m_config;
8384

8485
QString hrir_wav_subpath = QStringLiteral("/hrir_wav");
8586

src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ int main(int argc, char *argv[]) {
116116

117117
// Create PipeWire and frontend manager
118118
PipeWireManager pipewire_manager;
119-
FrontendManager *frontend_manager = new FrontendManager(&pipewire_manager);
119+
KConfig config(QStringLiteral("virtual-surround-manager"));
120+
FrontendManager *frontend_manager = new FrontendManager(&pipewire_manager, &config);
120121

121122
// Add main page and supply context
122123
QQmlApplicationEngine engine;

0 commit comments

Comments
 (0)