iwadandwadspickerdialog.cpp
1 //------------------------------------------------------------------------------
2 // iwadandwadspickerdialog.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2015 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "iwadandwadspickerdialog.h"
24 
25 #include "ui_iwadandwadspickerdialog.h"
26 #include "filefilter.h"
27 #include "gui/commongui.h"
28 #include <QFileDialog>
29 
30 DClass<IwadAndWadsPickerDialog> : public Ui::IwadAndWadsPickerDialog
31 {
32 };
33 
34 DPointered(IwadAndWadsPickerDialog)
35 
37 : QDialog(parent)
38 {
39  d->setupUi(this);
40 }
41 
42 IwadAndWadsPickerDialog::~IwadAndWadsPickerDialog()
43 {
44 }
45 
46 QString IwadAndWadsPickerDialog::executable() const
47 {
48  return d->executableInput->currentText();
49 }
50 
51 void IwadAndWadsPickerDialog::setExecutables(const QStringList &paths)
52 {
53  foreach (const QString &path, paths)
54  {
55  if (d->executableInput->findText(path) < 0)
56  {
57  d->executableInput->addItem(path);
58  }
59  }
60 }
61 
62 void IwadAndWadsPickerDialog::browseExecutable()
63 {
64  QString path = QFileDialog::getOpenFileName(this, tr("Doomseeker - Browse executable"),
65  executable(), FileFilter::executableFilesFilter());
66  if (!path.isEmpty())
67  {
68  CommonGUI::setCurrentText(d->executableInput, path);
69  if (d->executableInput->findText(path) < 0)
70  {
71  d->executableInput->addItem(path);
72  }
73  }
74 }
75 
77 {
78  return d->wadsPicker->filePaths();
79 }
80 
82 {
83  return d->iwadPicker->currentIwad();
84 }
85 
86 void IwadAndWadsPickerDialog::setIwadByName(const QString &iwad)
87 {
88  d->iwadPicker->setIwadByName(iwad);
89 }
void setIwadByName(const QString &iwad)
Attempt to chose default IWAD by name.
QString iwadPath() const
Path to IWAD file that was picked by the user.
QStringList filePaths() const
List of file paths (excluding IWAD) that were picked by the user.
Simple dialog box where user can pick path to IWAD and additional game files.
static void setCurrentText(QComboBox *box, const QString &text)
Qt4 compliant implementation of Qt5&#39;s QComboBox::setCurrentText().
Definition: commongui.cpp:128