23 #include "cfgwadseekergeneral.h"
24 #include "ui_cfgwadseekergeneral.h"
26 #include "configuration/doomseekerconfig.h"
27 #include "pathfinder/filesearchpath.h"
28 #include "templatedpathresolver.h"
31 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
32 #include <QFileSystemModel>
36 #include <QMessageBox>
38 DClass<CFGWadseekerGeneral> :
public Ui::CFGWadseekerGeneral
43 QString targetDirectory()
const
45 return cbTargetDirectory->currentText().trimmed();
55 d->completerActive =
false;
58 d->lblDirectoryWarning->setPixmap(QPixmap(
":/icons/exclamation_16.png"));
59 d->lblDirectoryWarning->hide();
60 d->lblDirectoryWarning->setWordWrap(
true);
62 this->connect(d->cbTargetDirectory, SIGNAL(editTextChanged(QString)),
63 SIGNAL(validationRequested()));
66 CFGWadseekerGeneral::~CFGWadseekerGeneral()
70 void CFGWadseekerGeneral::activateCompleter()
79 if (!d->completerActive)
81 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
85 auto completer =
new QCompleter(
this);
86 auto model =
new QFileSystemModel(completer);
88 completer->setModel(model);
89 d->cbTargetDirectory->setCompleter(completer);
91 d->cbTargetDirectory->setCompleter(
new QCompleter(
new QDirModel()));
93 d->completerActive =
true;
97 void CFGWadseekerGeneral::fillTargetDirectoryComboBox()
99 d->cbTargetDirectory->clear();
100 d->cbTargetDirectory->addItems(gConfig.doomseeker.wadPathsOnly());
105 fillTargetDirectoryComboBox();
107 d->cbTargetDirectory->setEditText(gConfig.wadseeker.targetDirectory);
108 d->spinMaxConcurrentSiteSeeks->setValue(gConfig.wadseeker.maxConcurrentSiteDownloads);
109 d->spinMaxConcurrentWadDownloads->setValue(gConfig.wadseeker.maxConcurrentWadDownloads);
114 gConfig.wadseeker.targetDirectory = d->targetDirectory();
115 gConfig.wadseeker.maxConcurrentSiteDownloads = d->spinMaxConcurrentSiteSeeks->value();
116 gConfig.wadseeker.maxConcurrentWadDownloads = d->spinMaxConcurrentWadDownloads->value();
119 void CFGWadseekerGeneral::showEvent(QShowEvent *event)
122 ConfigPage::showEvent(event);
130 if (error.isEmpty() && d->targetDirectory().isEmpty())
131 error = tr(
"No path specified.");
133 if (error.isEmpty() && !targetDirectory.exists())
134 error = tr(
"This path doesn't exist.");
136 if (error.isEmpty() && !targetDirectory.isDir())
137 error = tr(
"This is not a directory.");
139 if (error.isEmpty() && !targetDirectory.isWritable())
140 error = tr(
"This directory cannot be written to.");
142 d->lblDirectoryWarning->setVisible(!error.isEmpty());
143 d->lblDirectoryWarning->setText(error);