chiaki/gui/include/settings.h
2019-08-21 18:44:12 +02:00

86 lines
2.7 KiB
C++

/*
* This file is part of Chiaki.
*
* Chiaki is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Chiaki is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef CHIAKI_SETTINGS_H
#define CHIAKI_SETTINGS_H
#include <chiaki/session.h>
#include "host.h"
#include <QSettings>
class Settings : public QObject
{
Q_OBJECT
private:
QSettings settings;
QMap<HostMAC, RegisteredHost> registered_hosts;
QMap<int, ManualHost> manual_hosts;
int manual_hosts_id_next;
void LoadRegisteredHosts();
void SaveRegisteredHosts();
void LoadManualHosts();
void SaveManualHosts();
public:
explicit Settings(QObject *parent = nullptr);
bool GetDiscoveryEnabled() const { return settings.value("settings/auto_discovery", true).toBool(); }
void SetDiscoveryEnabled(bool enabled) { settings.setValue("settings/auto_discovery", enabled); }
bool GetLogVerbose() const { return settings.value("settings/log_verbose", false).toBool(); }
void SetLogVerbose(bool enabled) { settings.setValue("settings/log_verbose", enabled); }
uint32_t GetLogLevelMask();
ChiakiVideoResolutionPreset GetResolution() const;
void SetResolution(ChiakiVideoResolutionPreset resolution);
/**
* @return 0 if set to "automatic"
*/
ChiakiVideoFPSPreset GetFPS() const;
void SetFPS(ChiakiVideoFPSPreset fps);
unsigned int GetBitrate() const;
void SetBitrate(unsigned int bitrate);
ChiakiConnectVideoProfile GetVideoProfile();
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
void AddRegisteredHost(const RegisteredHost &host);
void RemoveRegisteredHost(const HostMAC &mac);
bool GetRegisteredHostRegistered(const HostMAC &mac) const { return registered_hosts.contains(mac); }
RegisteredHost GetRegisteredHost(const HostMAC &mac) const { return registered_hosts[mac]; }
QList<ManualHost> GetManualHosts() const { return manual_hosts.values(); }
int SetManualHost(const ManualHost &host);
void RemoveManualHost(int id);
bool GetManualHostExists(int id) { return manual_hosts.contains(id); }
ManualHost GetManualHost(int id) const { return manual_hosts[id]; }
signals:
void RegisteredHostsUpdated();
void ManualHostsUpdated();
};
#endif // CHIAKI_SETTINGS_H