-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowsettings.cpp
executable file
·107 lines (62 loc) · 2.6 KB
/
windowsettings.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "windowsettings.h"
#include "ui_windowsettings.h"
WindowSettings::WindowSettings(QWidget *parent) :
QWidget(parent, Qt::Tool),
ui(new Ui::WindowSettings)
{
ui->setupUi(this);
this->initializeCurrentSettings(); // Load current settings and apply them to the controls
connect(ui->inputConcurrentDownloads, SIGNAL(valueChanged(int)), this, SLOT(on_spinboxConcurrentDownloadsChanged(int)));
}
WindowSettings::~WindowSettings()
{
delete ui;
}
// Filebrowsedialog which will be opened when the user clicks browse to select his downloadpath
void WindowSettings::on_buttonBrowseFiles_clicked()
{
QFileDialog fileBrowser(this, "Choose a download location", Settings::getInstance().get("downloadSavePath").toString());
fileBrowser.setFileMode(QFileDialog::DirectoryOnly);
if(fileBrowser.exec() == QDialog::Accepted)
{
if(fileBrowser.selectedFiles().size() > 0)
{
QString savePath = fileBrowser.selectedFiles()[0];
Settings::getInstance().set("downloadSavePath", savePath);
ui->inputSavePath->setText(savePath);
}
}
}
// Also we need to watch whether the user just enters a path by himself and write it to the config
void WindowSettings::on_inputSavePath_editingFinished()
{
Settings::getInstance().set("downloadSavePath", this->ui->inputSavePath->text());
}
void WindowSettings::on_spinboxConcurrentDownloadsChanged(int newValue)
{
Settings::getInstance().set("concurrentDownloads", QVariant(newValue));
}
void WindowSettings::on_checkboxCreateContainerSubfolder_toggled(bool checked)
{
Settings::getInstance().set("createContainerSubfolder", QVariant(checked));
}
void WindowSettings::on_checkboxOnlyAudio_toggled(bool checked)
{
Settings::getInstance().set("extractOnlyAudio", QVariant(checked));
}
void WindowSettings::on_comboAudioFormat_currentTextChanged(const QString &format)
{
Settings::getInstance().set("audioFormat", QVariant(format));
}
void WindowSettings::on_buttonCloseSettings_clicked()
{
this->close();
}
void WindowSettings::initializeCurrentSettings()
{
ui->inputSavePath->setText(Settings::getInstance().get("downloadSavePath").toString());
ui->inputConcurrentDownloads->setValue(Settings::getInstance().get("concurrentDownloads").toInt());
ui->checkboxCreateContainerSubfolder->setChecked(Settings::getInstance().get("createContainerSubfolder").toBool());
ui->checkboxOnlyAudio->setChecked(Settings::getInstance().get("extractOnlyAudio").toBool());
ui->comboAudioFormat->setItemText(0, Settings::getInstance().get("audioFormat").toString());
}