-
Notifications
You must be signed in to change notification settings - Fork 0
/
patheditor.cpp
44 lines (36 loc) · 1017 Bytes
/
patheditor.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
#include "patheditor.h"
#include <QPushButton>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QFileDialog>
PathEditor::PathEditor(QWidget *parent) : QWidget(parent),
m_button(new QPushButton),
m_label(new QLineEdit),
m_dialog(new QFileDialog)
{
m_button->setText("Browse...");
m_label->setReadOnly(true);
setLayout(new QHBoxLayout);
layout()->setMargin(0);
layout()->addWidget(m_label);
layout()->addWidget(m_button);
connect(m_button, SIGNAL(clicked()), m_dialog, SLOT(show()));
connect(m_dialog, SIGNAL(fileSelected(QString)), SLOT(setPath(QString)));
connect(m_dialog, SIGNAL(fileSelected(QString)), SIGNAL(pathChanged(QString)));
}
PathEditor::~PathEditor()
{
}
QString PathEditor::path()
{
return m_label->text();
}
void PathEditor::setPath(const QString &path)
{
QFileInfo file(path);
m_dialog->setDirectory(file.path());
if (!file.suffix().isEmpty()) {
// m_dialog->setNameFilter("*.*");
}
m_label->setText(path);
}