Commit 87188e11 authored by Leander Schulten's avatar Leander Schulten

New feature: Startup Volume: You can set a volume that is set when you start the Lichtsteuerung

parent 64b18201
Pipeline #199323 passed with stage
in 6 minutes and 20 seconds
......@@ -267,6 +267,11 @@ int main(int argc, char *argv[]) {
Settings::setLocalSettingFile(QFileInfo(QStringLiteral("settings.ini")));
Settings settings;
RemoteVolume remoteVolume(settings);
if (settings.isStartupVolumeEnabled()) {
SystemVolume::get().setVolume(settings.getStartupVolume());
}
QString file(settings.getJsonSettingsFilePath());
if (!QFile::exists(file)) {
file = QStringLiteral("QTJSONFile.json");
......
......@@ -293,6 +293,36 @@ ScrollView{
}
Label {
text: "Startup Volume"
}
RowLayout {
Layout.topMargin: -10
Layout.bottomMargin: -10
Layout.leftMargin: -7
enabled: UserManagment.currentUser.havePermission(Permission.CHANGE_STARTUP_VOLUME)
CheckBox {
text: "enabled"
checked: Settings.isStartupVolumeEnabled
onCheckedChanged: Settings.isStartupVolumeEnabled = checked
}
Label {
visible: Settings.isStartupVolumeEnabled
Layout.leftMargin: 10
Layout.preferredWidth: 100
text: "Volume: " + (Settings.startupVolume * 100).toFixed(0) + "%"
}
Slider {
visible: Settings.isStartupVolumeEnabled
from: 0
to: 1
Layout.preferredWidth: 200
value: Settings.startupVolume
onValueChanged: Settings.startupVolume = value;
}
}
}
Loader {
......
......@@ -57,6 +57,20 @@ void Settings::remoteVolumeControl(bool enable) {
}
}
void Settings::setStartupVolumeEnabled(bool enabled) {
if (enabled != isStartupVolumeEnabled()) {
setValue(QStringLiteral("isStartupVolumeEnabled"), enabled);
emit isStartupVolumeEnabledChanged();
}
}
void Settings::setStartupVolume(double volume) {
if (volume != getStartupVolume()) {
setValue(QStringLiteral("StartupVolume"), volume);
emit startupVolumeChanged();
}
}
void Settings::setValue(const QString &key, const QVariant &value){
if (localSettings) {
if (localSettings->contains(key)) {
......
......@@ -59,6 +59,8 @@ class Settings : public QObject {
Q_PROPERTY(QString includePath READ getIncludePath WRITE setIncludePath NOTIFY includePathChanged)
Q_PROPERTY(QString computerName READ getComputerName WRITE setComputerName NOTIFY computerNameChanged)
Q_PROPERTY(bool remoteVolumeControl READ remoteVolumeControl WRITE remoteVolumeControl NOTIFY remoteVolumeControlChanged)
Q_PROPERTY(bool isStartupVolumeEnabled READ isStartupVolumeEnabled WRITE setStartupVolumeEnabled NOTIFY isStartupVolumeEnabledChanged)
Q_PROPERTY(double startupVolume READ getStartupVolume WRITE setStartupVolume NOTIFY startupVolumeChanged)
Q_PROPERTY(int theme READ getTheme WRITE setTheme NOTIFY themeChanged)
Q_PROPERTY(unsigned int updatePauseInMs READ getUpdatePauseInMs WRITE setUpdatePauseInMs NOTIFY updatePauseInMsChanged)
static inline QFileInfo localSettingsFile;
......@@ -187,6 +189,28 @@ public:
void remoteVolumeControl(bool enable);
[[nodiscard]] bool remoteVolumeControl() const { return value(QStringLiteral("remoteVolumeControl"), false).toBool(); }
/**
* @brief setStartupVolumeEnabled enables or disables the functionality described here: isStartupVolumeEnabled()
* @param enabled true if enabled, false if disabled
*/
void setStartupVolumeEnabled(bool enabled);
/**
* @brief isStartupVolumeEnabled if true, the system volume should be set to getStartupVolume() when the Lichtsteuerung starts
* @return true if should set, false otherwise
*/
[[nodiscard]] bool isStartupVolumeEnabled() const { return value(QStringLiteral("isStartupVolumeEnabled"), false).toBool(); }
/**
* @brief setStartupVolume sets the system volume that should be set when the Lichtsteuerung starts, valid values: 0.0 - 1.0
* @param volume the new startup volume
*/
void setStartupVolume(double volume);
/**
* @brief getStartupVolume the system volume that should be set when the Lichtsteuerung starts, valid values: 0.0 - 1.0
* @return the startup volume, 0.0 - 1.0
*/
[[nodiscard]] double getStartupVolume() const { return value(QStringLiteral("StartupVolume"), -.5).toDouble(); }
void setTheme(int theme) {
if (theme != getTheme()) {
setValue(QStringLiteral("theme"), theme);
......@@ -236,6 +260,8 @@ signals:
void saveAs(QString path);
void computerNameChanged();
void remoteVolumeControlChanged();
void isStartupVolumeEnabledChanged();
void startupVolumeChanged();
public slots:
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment