-
Notifications
You must be signed in to change notification settings - Fork 1
/
settingswindow.cpp
76 lines (64 loc) · 2.46 KB
/
settingswindow.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
75
76
#include <QDebug>
#include "settingswindow.h"
#include "ui_settingswindow.h"
#include "mainwindow.h" // This can't be in settingswindow.h, because mainwindow.h includes settingswindow.h
SettingsWindow::SettingsWindow(MainWindow &main_window, QWidget *parent) :
QDialog(parent),
ui(new Ui::SettingsWindow),
main_window(main_window),
settingsII(&main_window.settings)
{
ui->setupUi(this);
settingsII.join("Settings/HideStatusButton", ui->checkHideStatusButton);
settingsII.join("Settings/DarkStyle", ui->checkDarkStyle);
settingsII.join("Settings/DoNotSaveSizeAndPosition", ui->checkDoNotSaveSizeAndPosition);
settingsII.join("Settings/MediaPlayer", ui->editMediaPlayerPath);
settingsII.join("Settings/MediaPlayerArgs", ui->editMediaPlayerArgs);
settingsII.join("Settings/OutputTemplate", ui->editOutputTemplate);
settingsII.join("Settings/Youtube-dlExecutable", ui->editYoutubedlExecutable);
settingsII.join("Settings/FFMPEGPath", ui->editFFMPEGPath);
this->resize( main_window.settings.value("SettingsWindow/size",QSize(611,359)).toSize() );
}
SettingsWindow::~SettingsWindow()
{
main_window.settings.setValue("SettingsWindow/size", this->size());
delete ui;
}
void SettingsWindow::on_buttonBox_accepted()
{
settingsII.saveSettingsFromGUI();
main_window.apply_settings_while_running();
}
void SettingsWindow::on_buttonBox_clicked(QAbstractButton *button)
{
if (button->text()=="Apply")
{
settingsII.saveSettingsFromGUI();
main_window.apply_settings_while_running();
}
}
void SettingsWindow::on_btnBrowseMediaPlayer_clicked()
{
QFileDialog dialog;
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setWindowTitle("Select media player executable");
QDir dir = ui->editMediaPlayerPath->text();
if (dir.exists())
dialog.setDirectory(dir.path());
else
dialog.setDirectory(".");
if (dialog.exec())
{
ui->editMediaPlayerPath->setText(dialog.selectedFiles().at(0));
}
}
void SettingsWindow::on_btnSaveSizeAndPosition_clicked()
{
main_window.settings.setValue("MainWindow/size", main_window.size());
main_window.settings.setValue("MainWindow/position", main_window.pos());
}
void SettingsWindow::on_btnResetSizeAndPosition_clicked()
{
main_window.settings.setValue("MainWindow/size", QSize());
main_window.settings.setValue("MainWindow/position", QPoint());
}