cfgquery.cpp
1 //------------------------------------------------------------------------------
2 // cfgquery.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; 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) 2009 "Blzut3" <admin@maniacsvault.net>
22 //------------------------------------------------------------------------------
23 #include "cfgquery.h"
24 #include "ui_cfgquery.h"
25 #include "configuration/doomseekerconfig.h"
26 #include "configuration/queryspeed.h"
27 
28 DClass<CFGQuery> : public Ui::CFGQuery
29 {
30 public:
31  void setQuerySpeed(const QuerySpeed &speed)
32  {
33  triesBox->setValue(speed.attemptsPerServer);
34  timeoutBox->setValue(speed.delayBetweenSingleServerAttempts);
35  queryIntervalBox->setValue(speed.intervalBetweenServers);
36  }
37 
38  QuerySpeed querySpeed() const
39  {
40  QuerySpeed speed;
41  speed.attemptsPerServer = triesBox->value();
42  speed.delayBetweenSingleServerAttempts = timeoutBox->value();
43  speed.intervalBetweenServers = queryIntervalBox->value();
44  return speed;
45  }
46 };
47 
48 DPointered(CFGQuery)
49 
50 CFGQuery::CFGQuery(QWidget *parent)
51 : ConfigurationBaseBox(parent)
52 {
53  d->setupUi(this);
54 }
55 
56 CFGQuery::~CFGQuery()
57 {
58 }
59 
61 {
62  d->queryBeforeLaunch->setChecked(gConfig.doomseeker.bQueryBeforeLaunch);
63  d->queryOnStartup->setChecked(gConfig.doomseeker.bQueryOnStartup);
64  d->grbServerAutoRefresh->setChecked(gConfig.doomseeker.bQueryAutoRefreshEnabled);
65  d->numAutoRefreshEverySeconds->setValue(gConfig.doomseeker.queryAutoRefreshEverySeconds);
66  d->cbDontRefreshIfActive->setChecked(gConfig.doomseeker.bQueryAutoRefreshDontIfActive);
67  d->setQuerySpeed(gConfig.doomseeker.querySpeed());
68 }
69 
71 {
72  gConfig.doomseeker.bQueryBeforeLaunch = d->queryBeforeLaunch->isChecked();
73  gConfig.doomseeker.bQueryOnStartup = d->queryOnStartup->isChecked();
74  gConfig.doomseeker.bQueryAutoRefreshEnabled = d->grbServerAutoRefresh->isChecked();
75  gConfig.doomseeker.queryAutoRefreshEverySeconds = d->numAutoRefreshEverySeconds->value();
76  gConfig.doomseeker.bQueryAutoRefreshDontIfActive = d->cbDontRefreshIfActive->isChecked();
77  gConfig.doomseeker.setQuerySpeed(d->querySpeed());
78 }
79 
80 void CFGQuery::setCautiousQueryPreset()
81 {
82  d->setQuerySpeed(QuerySpeed::cautious());
83 }
84 
85 void CFGQuery::setModerateQueryPreset()
86 {
87  d->setQuerySpeed(QuerySpeed::moderate());
88 }
89 
90 void CFGQuery::setAggressiveQueryPreset()
91 {
92  d->setQuerySpeed(QuerySpeed::aggressive());
93 }
void saveSettings()
Reimplement this to write settings to config from widgets.
Definition: cfgquery.cpp:70
void readSettings()
Reimplement this to read settings from config into widgets.
Definition: cfgquery.cpp:60
Base class for configuration pages.