Updated the git clone command.
[emufront] / src / dialogs / browsefilepathdialog.cpp
1 /*
2 ** EmuFront
3 ** Copyright 2010 Mikko Keinänen
4 **
5 ** This file is part of EmuFront.
6 **
7 **
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.
12 **
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.
17 **
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/>.
20 */
21 #include <QtGui>
22 #include "browsefilepathdialog.h"
23
24 BrowseFilePathDialog::BrowseFilePathDialog(QWidget *parent, EmuFrontObject *efo, Qt::Orientation orientation) :
25     DataObjectEditDialog(parent, efo, orientation)
26 {
27 }
28
29 void BrowseFilePathDialog::connectSignals()
30 {
31     DataObjectEditDialog::connectSignals();
32     connect(filePathButton, SIGNAL(clicked()), this, SLOT(browseFilePath()));
33 }
34
35 void BrowseFilePathDialog::initWidgets()
36 {
37     filePathLabel = new QLabel;
38     filePathButton = new QPushButton(tr("&Browse filepath"));
39 }
40
41 void BrowseFilePathDialog::browseFilePath()
42 {
43     QString startPath = filePathLabel->text();
44     if (startPath.isEmpty()) {
45         startPath = (efObject && !efObject->getName().isEmpty())
46             ? efObject->getName() : QDir::homePath();
47     }
48
49     QString fpath = QFileDialog::getExistingDirectory(this,
50         tr("Select a directory"), startPath,
51         QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
52     QDir d(fpath);
53     if (d.exists() && d.isReadable()) {
54         filePathLabel->setText(d.path());
55         if (d.path() != startPath) emit filePathUpdated();
56     }
57 }
58
59 void BrowseFilePathDialog::clear()
60 {
61     filePathLabel->clear();
62 }