summaryrefslogtreecommitdiffstats
path: root/src/preferences/broadcastsettings.h
blob: 6af26e568bf71601037dcaf1b152e7c67cecdb99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once

#include <QMap>
#include <QSharedPointer>
#include <QString>

#include "preferences/usersettings.h"
#include "preferences/broadcastsettingsmodel.h"
#include "preferences/broadcastprofile.h"

class BroadcastSettings : public QObject {
  Q_OBJECT

  public:
    BroadcastSettings(UserSettingsPointer pConfig, QObject* parent = nullptr);

    bool saveProfile(BroadcastProfilePtr profile);
    void saveAll();
    QList<BroadcastProfilePtr> profiles();
    BroadcastProfilePtr profileAt(int index);

    void applyModel(BroadcastSettingsModel* pModel);

  signals:
    void profileAdded(BroadcastProfilePtr profile);
    void profileRemoved(BroadcastProfilePtr profile);
    void profileRenamed(const QString& oldName, BroadcastProfilePtr profile);
    void profilesChanged();

  private slots:
    void onProfileNameChanged(const QString& oldName, const QString& newName);
    void onConnectionStatusChanged(int newStatus);

  private:
    void loadProfiles();
    bool addProfile(BroadcastProfilePtr profile);

    QString filePathForProfile(BroadcastProfilePtr profile);
    QString filePathForProfile(const QString& profileName);
    bool deleteFileForProfile(BroadcastProfilePtr profile);
    QString getProfilesFolder();

    void loadLegacySettings(BroadcastProfilePtr profile);

    // Pointer to config object
    UserSettingsPointer m_pConfig;
    QMap<QString, BroadcastProfilePtr> m_profiles;
};

typedef QSharedPointer<BroadcastSettings> BroadcastSettingsPointer;