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 #include <QStyle>
30 
31 DClass<IwadAndWadsPickerDialog> : public Ui::IwadAndWadsPickerDialog
32 {
33 };
34 
35 DPointered(IwadAndWadsPickerDialog)
36 
38  : QDialog(parent)
39 {
40  d->setupUi(this);
42  d->btnBrowseExecutable->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon));
43 }
44 
45 IwadAndWadsPickerDialog::~IwadAndWadsPickerDialog()
46 {
47 }
48 
49 QString IwadAndWadsPickerDialog::executable() const
50 {
51  return d->executableInput->currentText();
52 }
53 
54 void IwadAndWadsPickerDialog::setExecutables(const QStringList &paths)
55 {
56  for (const QString &path : paths)
57  {
58  if (d->executableInput->findText(path) < 0)
59  d->executableInput->addItem(path);
60  }
61 }
62 
63 void IwadAndWadsPickerDialog::browseExecutable()
64 {
65  QString path = QFileDialog::getOpenFileName(this, tr("Doomseeker - Browse executable"),
66  executable(), FileFilter::executableFilesFilter());
67  if (!path.isEmpty())
68  {
69  d->executableInput->setCurrentText(path);
70  if (d->executableInput->findText(path) < 0)
71  d->executableInput->addItem(path);
72  }
73 }
74 
76 {
77  return d->wadsPicker->filePaths();
78 }
79 
81 {
82  return d->iwadPicker->currentIwad();
83 }
84 
85 void IwadAndWadsPickerDialog::setIwadByName(const QString &iwad)
86 {
87  d->iwadPicker->setIwadByName(iwad);
88 }