forked from MrBesen/soundboard
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
#include "settings.h"
|
|
#include "ui_settings.h"
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <Log.h>
|
|
|
|
#include "sound.h"
|
|
|
|
Settings::Settings(Config& conf, QWidget *parent) : ConfigDialog(conf, parent), ui(new Ui::Settings) {
|
|
ui->setupUi(this);
|
|
|
|
setAudioPath();
|
|
}
|
|
|
|
Settings::~Settings() {
|
|
delete ui;
|
|
}
|
|
|
|
void Settings::selectAudioPath() {
|
|
Log::info << "select Audiopath";
|
|
|
|
QFileDialog fileselector(this);
|
|
fileselector.setFileMode(QFileDialog::Directory);
|
|
fileselector.setOption(QFileDialog::Option::ShowDirsOnly, true);
|
|
fileselector.setDirectory(QString::fromStdString(Sound::FOLDER));
|
|
fileselector.exec();
|
|
|
|
QStringList filelist = fileselector.selectedFiles();
|
|
if(filelist.size() != 1) {
|
|
Log::error << "no folder selected";
|
|
return;
|
|
}
|
|
|
|
std::string folder = filelist.at(0).toStdString();
|
|
workingConfig.audioPath = folder;
|
|
setAudioPath();
|
|
}
|
|
|
|
void Settings::masterVolumeChange(int val) {
|
|
std::string text = "Master Volume: " + std::to_string(val) + "%";
|
|
ui->masterVolumeLabel->setText(QString::fromStdString(text));
|
|
workingConfig.audio.volume = (val / 100.0f);
|
|
}
|
|
|
|
void Settings::setAudioPath() {
|
|
QString path = QString::fromStdString("Audio Folder: " + workingConfig.audioPath);
|
|
ui->audioFolderLabel->setText(path);
|
|
ui->audioFolderLabel->setToolTip(path);
|
|
}
|
|
|
|
QDialogButtonBox* Settings::getButtonBox() {
|
|
return ui->buttonBox;
|
|
}
|