-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettingswindow.cpp
More file actions
41 lines (35 loc) · 1.02 KB
/
settingswindow.cpp
File metadata and controls
41 lines (35 loc) · 1.02 KB
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
#include "settingswindow.h"
#include "ui_settingswindow.h"
#include <QFileDialog>
#include <QFile>
#include <QStandardPaths>
#include "mainwindow.h"
settingsWindow::settingsWindow(QWidget *parent)
: QDialog(parent)
, ui(new Ui::settingsWindow)
{
ui->setupUi(this);
// 1. Safely cast parent to a MainWindow pointer
MainWindow *main = qobject_cast<MainWindow*>(parent);
if (main)
{
// 2. Initialize the string so it's not empty if the user just clicks OK
folderDirectory = main->transfer_file_path;
// 3. Set the UI text
ui->dirPath->setText(folderDirectory);
}
}
settingsWindow::~settingsWindow()
{
delete ui;
}
void settingsWindow::on_folderButton_clicked()
{
folderDirectory = QFileDialog::getExistingDirectory();
ui->dirPath->setText(folderDirectory);
}
void settingsWindow::on_defaultButton_clicked()
{
folderDirectory = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/Files-Received";
ui->dirPath->setText(folderDirectory);
}