3 ** Copyright 2010 Mikko Keinänen
5 ** This file is part of EmuFront.
8 ** EmuFront is free software: you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License version 2 as published by
10 ** the Free Software Foundation and appearing in the file gpl.txt included in the
11 ** packaging of this file.
13 ** EmuFront is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
18 ** You should have received a copy of the GNU General Public License
19 ** along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
22 #include "browsefilepathdialog.h"
24 BrowseFilePathDialog::BrowseFilePathDialog(QWidget *parent, EmuFrontObject *efo, Qt::Orientation orientation) :
25 DataObjectEditDialog(parent, efo, orientation)
29 void BrowseFilePathDialog::connectSignals()
31 DataObjectEditDialog::connectSignals();
32 connect(filePathButton, SIGNAL(clicked()), this, SLOT(browseFilePath()));
35 void BrowseFilePathDialog::initWidgets()
37 filePathLabel = new QLabel;
38 filePathButton = new QPushButton(tr("&Browse filepath"));
41 void BrowseFilePathDialog::browseFilePath()
43 QString startPath = filePathLabel->text();
44 if (startPath.isEmpty()) {
45 startPath = (efObject && !efObject->getName().isEmpty())
46 ? efObject->getName() : QDir::homePath();
49 QString fpath = QFileDialog::getExistingDirectory(this,
50 tr("Select a directory"), startPath,
51 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
53 if (d.exists() && d.isReadable()) {
54 filePathLabel->setText(d.path());
55 if (d.path() != startPath) emit filePathUpdated();
59 void BrowseFilePathDialog::clear()
61 filePathLabel->clear();