23 #include "application.h" 24 #include "configuration/doomseekerconfig.h" 25 #include "doomseekerconfigurationdialog.h" 26 #include "gui/configuration/cfgappearance.h" 27 #include "gui/configuration/cfgautoupdates.h" 28 #include "gui/configuration/cfgcustomservers.h" 29 #include "gui/configuration/cfgfilepaths.h" 30 #include "gui/configuration/cfgquery.h" 31 #include "gui/configuration/cfgserverpasswords.h" 32 #include "gui/configuration/cfgwadalias.h" 33 #include "gui/configuration/cfgwadseekerappearance.h" 34 #include "gui/configuration/cfgwadseekergeneral.h" 35 #include "gui/configuration/cfgwadseekeridgames.h" 36 #include "gui/configuration/cfgwadseekersites.h" 37 #include "gui/configuration/engineconfigpage.h" 38 #include "gui/mainwindow.h" 40 #include "plugins/engineplugin.h" 41 #include "plugins/pluginloader.h" 42 #include "qtmetapointer.h" 43 #include "updater/updatechannel.h" 44 #include <QStandardItem> 47 DoomseekerConfigurationDialog::DoomseekerConfigurationDialog(QWidget *parent)
50 this->bAppearanceChanged =
false;
51 this->bCustomServersChanged =
false;
52 this->bRestartNeeded =
false;
61 connect(configPage, SIGNAL(appearanceChanged()),
62 SLOT(appearanceChangedSlot()));
63 connect(configPage, SIGNAL(restartNeeded()),
64 SLOT(restartNeededSlot()));
70 bool DoomseekerConfigurationDialog::addEngineConfiguration(
ConfigPage *configPage)
72 if (enginesRoot !=
nullptr)
77 void DoomseekerConfigurationDialog::appearanceChangedSlot()
79 this->bAppearanceChanged =
true;
80 emit appearanceChanged();
83 void DoomseekerConfigurationDialog::restartNeededSlot()
85 this->bRestartNeeded =
true;
88 void DoomseekerConfigurationDialog::appendFilePathsConfigurationBoxes()
94 void DoomseekerConfigurationDialog::appendWadseekerConfigurationBoxes()
96 QStandardItem *wadseekerRoot =
addLabel(
nullptr, tr(
"Wadseeker"));
97 wadseekerRoot->setIcon(QIcon(
":/icons/get-wad.png"));
114 void DoomseekerConfigurationDialog::doSaveSettings()
116 bCustomServersChanged = customServersCfgBox->allowSave();
117 if (gConfig.saveToFile())
118 gLog << tr(
"Settings saved!");
120 gLog << tr(
"Settings save failed!");
123 void DoomseekerConfigurationDialog::initOptionsList()
125 enginesRoot =
addLabel(
nullptr, tr(
"Games"));
126 enginesRoot->setIcon(QIcon(
":/icons/joystick.png"));
138 customServersCfgBox = configPage;
146 appendFilePathsConfigurationBoxes();
147 appendWadseekerConfigurationBoxes();
152 bool DoomseekerConfigurationDialog::isOpen()
154 if (gApp->mainWindow() ==
nullptr)
156 for (QObject *obj : gApp->mainWindow()->children())
158 if (qobject_cast<DoomseekerConfigurationDialog *>(obj) !=
nullptr)
164 void DoomseekerConfigurationDialog::openConfiguration(QWidget *parent,
const EnginePlugin *openPlugin)
169 if (mainWindow !=
nullptr)
170 mainWindow->connect(&configDialog, SIGNAL(appearanceChanged()), SLOT(updateDynamicAppearance()));
172 configDialog.initOptionsList();
174 for (
unsigned i = 0; i < gPlugins->numPlugins(); ++i)
180 configDialog.addEngineConfiguration(configPage);
183 bool bLookupHostsSettingBefore = gConfig.doomseeker.bLookupHosts;
187 if (mainWindow !=
nullptr)
188 mainWindow->stopAutoRefreshTimer();
191 configDialog.showPluginConfiguration(openPlugin);
196 if (mainWindow !=
nullptr)
202 if (updateChannelBefore != updateChannelAfter
203 || updateModeBefore != gConfig.autoUpdates.updateMode)
205 if (mainWindow !=
nullptr)
206 mainWindow->abortAutoUpdater();
207 gConfig.autoUpdates.bPerformUpdateOnNextRun =
false;
208 gConfig.saveToFile();
211 if (mainWindow !=
nullptr)
212 mainWindow->
finishConfiguration(configDialog, !bLookupHostsSettingBefore && gConfig.doomseeker.bLookupHosts);
215 void DoomseekerConfigurationDialog::showPluginConfiguration(
const EnginePlugin *plugin)
218 for (
int i = 0; i < enginesRoot->rowCount(); ++i)
220 QStandardItem *page = enginesRoot->child(i);
222 void *pointer = metaPointer;
225 if (engineConfig->plugin() == plugin)
virtual ConfigPage * configuration(QWidget *parent)
Engine's configuration widget.
QTreeView * optionsTree()
Returns pointer to the tree widget that contains configuration sections list.
static UpdateChannel fromName(const QString &name)
Creates object from its internal name.
void finishConfiguration(DoomseekerConfigurationDialog &, bool)
virtual QStandardItem * addConfigPage(QStandardItem *rootItem, ConfigPage *configPage, int position=-1)
Adds a new configuration page to the options tree view.
QStandardItem * addConfigPage(QStandardItem *rootItem, ConfigPage *configPage, int position=-1) override
Adds a new configuration page to the options tree view.
QStandardItem * addLabel(QStandardItem *rootItem, const QString &label, int position=-1)
Adds a label node to the options tree view.
Base for configuration pages for plugins; provides some default behavior.
Base class for configuration pages.
void showConfigPage(ConfigPage *widget)
void initAutoRefreshTimer()