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 "filefilter.h"
26 #include "gui/commongui.h"
27 #include "ui_iwadandwadspickerdialog.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);
41 }
42 
43 IwadAndWadsPickerDialog::~IwadAndWadsPickerDialog()
44 {
45 }
46 
47 QString IwadAndWadsPickerDialog::executable() const
48 {
49  return d->executableInput->currentText();
50 }
51 
52 void IwadAndWadsPickerDialog::setExecutables(const QStringList &paths)
53 {
54  for (const QString &path : paths)
55  {
56  if (d->executableInput->findText(path) < 0)
57  d->executableInput->addItem(path);
58  }
59 }
60 
61 void IwadAndWadsPickerDialog::browseExecutable()
62 {
63  QString path = QFileDialog::getOpenFileName(this, tr("Doomseeker - Browse executable"),
64  executable(), FileFilter::executableFilesFilter());
65  if (!path.isEmpty())
66  {
67  d->executableInput->setCurrentText(path);
68  if (d->executableInput->findText(path) < 0)
69  d->executableInput->addItem(path);
70  }
71 }
72 
74 {
75  return d->wadsPicker->filePaths();
76 }
77 
79 {
80  return d->iwadPicker->currentIwad();
81 }
82 
83 void IwadAndWadsPickerDialog::setIwadByName(const QString &iwad)
84 {
85  d->iwadPicker->setIwadByName(iwad);
86 }