forked from mpc-qt/mpc-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openfiledialog.cpp
47 lines (40 loc) · 1.04 KB
/
openfiledialog.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
#include <QFileDialog>
#include "helpers.h"
#include "openfiledialog.h"
#include "ui_openfiledialog.h"
OpenFileDialog::OpenFileDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::OpenFileDialog)
{
ui->setupUi(this);
}
OpenFileDialog::~OpenFileDialog()
{
delete ui;
}
QString OpenFileDialog::file()
{
return ui->fileField->text();
}
QString OpenFileDialog::subs()
{
return ui->subsField->text();
}
void OpenFileDialog::on_fileBrowse_clicked()
{
static QString filter;
if (filter.isEmpty())
filter = Helpers::fileOpenFilter();
QUrl url = QFileDialog::getOpenFileUrl(this, tr("Select File"), QUrl(), filter);
if (url.isValid())
ui->fileField->setText(url.toDisplayString());
}
void OpenFileDialog::on_subsBrowse_clicked()
{
static QString subsFilter;
if (subsFilter.isEmpty())
subsFilter = Helpers::subsOpenFilter();
QUrl url = QFileDialog::getOpenFileUrl(this, tr("Select File"), QUrl(), subsFilter);
if (url.isValid())
ui->subsField->setText(url.toDisplayString());
}