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 : ConfigPage(parent)
52 {
53  d->setupUi(this);
54 
55  const QuerySpeed &min = QuerySpeed::MAX_SPEED;
56  d->triesBox->setMinimum(min.attemptsPerServer);
57  d->timeoutBox->setMinimum(min.delayBetweenSingleServerAttempts);
58  d->queryIntervalBox->setMinimum(min.intervalBetweenServers);
59 
60  d->setQuerySpeed(QuerySpeed::aggressive());
61 }
62 
63 CFGQuery::~CFGQuery()
64 {
65 }
66 
68 {
69  d->queryBeforeLaunch->setChecked(gConfig.doomseeker.bQueryBeforeLaunch);
70  d->queryOnStartup->setChecked(gConfig.doomseeker.bQueryOnStartup);
71  d->grbServerAutoRefresh->setChecked(gConfig.doomseeker.bQueryAutoRefreshEnabled);
72  d->numAutoRefreshEverySeconds->setValue(gConfig.doomseeker.queryAutoRefreshEverySeconds);
73  d->cbDontRefreshIfActive->setChecked(gConfig.doomseeker.bQueryAutoRefreshDontIfActive);
74  d->setQuerySpeed(gConfig.doomseeker.querySpeed());
75 }
76 
78 {
79  gConfig.doomseeker.bQueryBeforeLaunch = d->queryBeforeLaunch->isChecked();
80  gConfig.doomseeker.bQueryOnStartup = d->queryOnStartup->isChecked();
81  gConfig.doomseeker.bQueryAutoRefreshEnabled = d->grbServerAutoRefresh->isChecked();
82  gConfig.doomseeker.queryAutoRefreshEverySeconds = d->numAutoRefreshEverySeconds->value();
83  gConfig.doomseeker.bQueryAutoRefreshDontIfActive = d->cbDontRefreshIfActive->isChecked();
84  gConfig.doomseeker.setQuerySpeed(d->querySpeed());
85 }
86 
87 void CFGQuery::setCautiousQueryPreset()
88 {
89  d->setQuerySpeed(QuerySpeed::cautious());
90 }
91 
92 void CFGQuery::setModerateQueryPreset()
93 {
94  d->setQuerySpeed(QuerySpeed::moderate());
95 }
96 
97 void CFGQuery::setAggressiveQueryPreset()
98 {
99  d->setQuerySpeed(QuerySpeed::aggressive());
100 }
101 
102 void CFGQuery::setVeryAggressiveQueryPreset()
103 {
104  d->setQuerySpeed(QuerySpeed::veryAggressive());
105 }
void saveSettings()
Reimplement this to write settings to config from widgets.
Definition: cfgquery.cpp:77
void readSettings()
Reimplement this to read settings from config into widgets.
Definition: cfgquery.cpp:67
Base class for configuration pages.
Definition: configpage.h:43