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);
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  for (const QString &path : paths)
54  {
55  if (d->executableInput->findText(path) < 0)
56  d->executableInput->addItem(path);
57  }
58 }
59 
60 void IwadAndWadsPickerDialog::browseExecutable()
61 {
62  QString path = QFileDialog::getOpenFileName(this, tr("Doomseeker - Browse executable"),
63  executable(), FileFilter::executableFilesFilter());
64  if (!path.isEmpty())
65  {
66  d->executableInput->setCurrentText(path);
67  if (d->executableInput->findText(path) < 0)
68  d->executableInput->addItem(path);
69  }
70 }
71 
73 {
74  return d->wadsPicker->filePaths();
75 }
76 
78 {
79  return d->iwadPicker->currentIwad();
80 }
81 
82 void IwadAndWadsPickerDialog::setIwadByName(const QString &iwad)
83 {
84  d->iwadPicker->setIwadByName(iwad);
85 }