-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathqfilepathfield.cpp
More file actions
41 lines (33 loc) · 1.25 KB
/
qfilepathfield.cpp
File metadata and controls
41 lines (33 loc) · 1.25 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
// NintyFont - Nintendo binary font editor
// Copyleft TheDzeraora 2020
// This software is provided under
// the GNU General Public License v3
// See license.txt in the root of the
// source tree for full license conditions
#include "qfilepathfield.h"
namespace NintyFont::GUI
{
QFilePathField::QFilePathField(std::string t_browseDlgTitle, std::string t_fileExtensionText)
: QWidget()
{
browseDlgTitle = t_browseDlgTitle;
fileExtensionText = t_fileExtensionText;
pathField = new QTextEdit(this);
browseButton = new QPushButton(this);
QHBoxLayout *layout = new QHBoxLayout(this);
setLayout(layout);
layout->addWidget(pathField);
layout->addWidget(browseButton);
connect(browseButton, &QPushButton::click, this, &QFilePathField::browseButtonClickEvent);
}
void QFilePathField::browseButtonClickEvent()
{
QFileDialog dlg = QFileDialog(this, QString::fromStdString(browseDlgTitle), "", QString::fromStdString(fileExtensionText));
dlg.setFileMode(QFileDialog::ExistingFile);
if (!dlg.exec()) return; //Abort if user hasn't selected a file
pathField->setText(dlg.selectedFiles()[0]);
}
QFilePathField::~QFilePathField()
{
}
}