23 #include "cfgwadseekergeneral.h"
24 #include "ui_cfgwadseekergeneral.h"
26 #include "configuration/doomseekerconfig.h"
27 #include "pathfinder/filesearchpath.h"
30 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
31 #include <QFileSystemModel>
35 #include <QMessageBox>
37 DClass<CFGWadseekerGeneral> :
public Ui::CFGWadseekerGeneral
42 QString targetDirectory()
const
44 return cbTargetDirectory->currentText().trimmed();
54 d->completerActive =
false;
57 d->lblDirectoryWarning->setPixmap(QPixmap(
":/icons/exclamation_16.png"));
58 d->lblDirectoryWarning->hide();
59 d->lblDirectoryWarning->setWordWrap(
true);
61 this->connect(d->cbTargetDirectory, SIGNAL(editTextChanged(QString)),
62 SIGNAL(validationRequested()));
65 CFGWadseekerGeneral::~CFGWadseekerGeneral()
69 void CFGWadseekerGeneral::activateCompleter()
78 if (!d->completerActive)
80 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
84 auto completer =
new QCompleter(
this);
85 auto model =
new QFileSystemModel(completer);
86 model->setRootPath(d->targetDirectory());
87 completer->setModel(model);
88 d->cbTargetDirectory->setCompleter(completer);
90 d->cbTargetDirectory->setCompleter(
new QCompleter(
new QDirModel()));
92 d->completerActive =
true;
96 void CFGWadseekerGeneral::fillTargetDirectoryComboBox()
98 d->cbTargetDirectory->clear();
99 d->cbTargetDirectory->addItems(gConfig.doomseeker.wadPathsOnly());
104 fillTargetDirectoryComboBox();
106 d->cbTargetDirectory->setEditText(gConfig.wadseeker.targetDirectory);
107 d->spinMaxConcurrentSiteSeeks->setValue(gConfig.wadseeker.maxConcurrentSiteDownloads);
108 d->spinMaxConcurrentWadDownloads->setValue(gConfig.wadseeker.maxConcurrentWadDownloads);
113 gConfig.wadseeker.targetDirectory = d->targetDirectory();
114 gConfig.wadseeker.maxConcurrentSiteDownloads = d->spinMaxConcurrentSiteSeeks->value();
115 gConfig.wadseeker.maxConcurrentWadDownloads = d->spinMaxConcurrentWadDownloads->value();
118 void CFGWadseekerGeneral::showEvent(QShowEvent *event)
121 ConfigPage::showEvent(event);
128 QFileInfo targetDirectory(d->targetDirectory());
129 if (error.isEmpty() && d->targetDirectory().isEmpty())
130 error = tr(
"No path specified.");
132 if (error.isEmpty() && !targetDirectory.exists())
133 error = tr(
"This path doesn't exist.");
135 if (error.isEmpty() && !targetDirectory.isDir())
136 error = tr(
"This is not a directory.");
138 if (error.isEmpty() && !targetDirectory.isWritable())
139 error = tr(
"This directory cannot be written to.");
141 d->lblDirectoryWarning->setVisible(!error.isEmpty());
142 d->lblDirectoryWarning->setText(error);