23 #include "doomseekerconfigurationdialog.h" 24 #include "configuration/doomseekerconfig.h" 25 #include "gui/configuration/cfgappearance.h" 26 #include "gui/configuration/cfgautoupdates.h" 27 #include "gui/configuration/cfgcustomservers.h" 28 #include "gui/configuration/cfgfilepaths.h" 29 #include "gui/configuration/cfgquery.h" 30 #include "gui/configuration/cfgserverpasswords.h" 31 #include "gui/configuration/cfgwadalias.h" 32 #include "gui/configuration/cfgwadseekerappearance.h" 33 #include "gui/configuration/cfgwadseekergeneral.h" 34 #include "gui/configuration/cfgwadseekeridgames.h" 35 #include "gui/configuration/cfgwadseekersites.h" 36 #include "gui/configuration/engineconfigpage.h" 37 #include "gui/mainwindow.h" 38 #include "plugins/engineplugin.h" 39 #include "plugins/pluginloader.h" 40 #include "updater/updatechannel.h" 41 #include "application.h" 43 #include "qtmetapointer.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 != NULL)
79 void DoomseekerConfigurationDialog::appearanceChangedSlot()
81 this->bAppearanceChanged =
true;
82 emit appearanceChanged();
85 void DoomseekerConfigurationDialog::restartNeededSlot()
87 this->bRestartNeeded =
true;
90 void DoomseekerConfigurationDialog::appendFilePathsConfigurationBoxes()
96 void DoomseekerConfigurationDialog::appendWadseekerConfigurationBoxes()
98 QStandardItem* wadseekerRoot =
addLabel(NULL, tr(
"Wadseeker"));
99 wadseekerRoot->setIcon(QIcon(
":/icons/get-wad.png"));
116 void DoomseekerConfigurationDialog::doSaveSettings()
118 bCustomServersChanged = customServersCfgBox->allowSave();
119 if (gConfig.saveToFile())
121 gLog << tr(
"Settings saved!");
125 gLog << tr(
"Settings save failed!");
129 void DoomseekerConfigurationDialog::initOptionsList()
131 enginesRoot =
addLabel(NULL, tr(
"Games"));
132 enginesRoot->setIcon(QIcon(
":/icons/joystick.png"));
144 customServersCfgBox = configPage;
152 appendFilePathsConfigurationBoxes();
153 appendWadseekerConfigurationBoxes();
158 bool DoomseekerConfigurationDialog::isOpen()
160 if (gApp->mainWindow() == NULL)
162 foreach(QObject *obj, gApp->mainWindow()->children())
164 if (qobject_cast<DoomseekerConfigurationDialog*>(obj) != NULL)
170 void DoomseekerConfigurationDialog::openConfiguration(QWidget *parent,
const EnginePlugin *openPlugin)
175 if (mainWindow != NULL)
176 mainWindow->connect(&configDialog, SIGNAL(appearanceChanged()), SLOT(updateDynamicAppearance()));
178 configDialog.initOptionsList();
180 for(
unsigned i = 0; i < gPlugins->numPlugins(); ++i)
186 configDialog.addEngineConfiguration(configPage);
189 bool bLookupHostsSettingBefore = gConfig.doomseeker.bLookupHosts;
193 if (mainWindow != NULL)
194 mainWindow->stopAutoRefreshTimer();
197 configDialog.showPluginConfiguration(openPlugin);
202 if (mainWindow != NULL)
208 if (updateChannelBefore != updateChannelAfter
209 || updateModeBefore != gConfig.autoUpdates.updateMode)
211 if (mainWindow != NULL)
212 mainWindow->abortAutoUpdater();
213 gConfig.autoUpdates.bPerformUpdateOnNextRun =
false;
214 gConfig.saveToFile();
217 if (mainWindow != NULL)
218 mainWindow->
finishConfiguration(configDialog, !bLookupHostsSettingBefore && gConfig.doomseeker.bLookupHosts);
221 void DoomseekerConfigurationDialog::showPluginConfiguration(
const EnginePlugin *plugin)
224 for(
int i = 0;i < enginesRoot->rowCount();++i)
226 QStandardItem *page = enginesRoot->child(i);
228 void* pointer = metaPointer;
231 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)
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.
const EnginePlugin * plugin() const
Parent plugin handled by this page.
Base for configuration pages for plugins; provides some default behavior.
Base class for configuration pages.
void showConfigPage(ConfigPage *widget)
void initAutoRefreshTimer()