ircconfigurationdialog.cpp
1 //------------------------------------------------------------------------------
2 // ircconfigurationdialog.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) 2010 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "ircconfigurationdialog.h"
24 #include "gui/configuration/irc/cfgchatlogspage.h"
25 #include "gui/configuration/irc/cfgircappearance.h"
26 #include "gui/configuration/irc/cfgircnetworks.h"
27 #include "gui/configuration/irc/cfgircsounds.h"
28 #include "gui/commongui.h"
29 #include "irc/configuration/ircconfig.h"
30 #include "log.h"
31 
32 IRCConfigurationDialog::IRCConfigurationDialog(QWidget* parent)
33 : ConfigurationDialog(parent)
34 {
35  this->setWindowTitle(tr("Doomseeker - IRC Options"));
36 }
37 
38 void IRCConfigurationDialog::doSaveSettings()
39 {
40  if (gIRCConfig.saveToFile())
41  {
42  gLog << tr("Settings saved!");
43  }
44  else
45  {
46  gLog << tr("Settings save failed!");
47  }
48 }
49 
50 void IRCConfigurationDialog::initOptionsList()
51 {
52  ConfigPage* configPage = NULL;
53 
54  configPage = new CFGIRCAppearance(this);
55  this->addConfigPage(NULL, configPage);
56 
57  cfgNetworks = new CFGIRCNetworks(this);
58  configPage = cfgNetworks;
59  this->addConfigPage(NULL, configPage);
60 
61  configPage = new CFGIRCSounds(this);
62  this->addConfigPage(NULL, configPage);
63 
64  addConfigPage(NULL, new CfgChatLogsPage(this));
65 }
66 
67 bool IRCConfigurationDialog::isNetworkAutojoinEnabled()
68 {
69  QVector<IRCNetworkEntity*> networks = cfgNetworks->networks();
70  foreach (IRCNetworkEntity* pNetwork, networks)
71  {
72  if (pNetwork->isAutojoinNetwork())
73  {
74  return true;
75  }
76  }
77 
78  return false;
79 }
80 
81 bool IRCConfigurationDialog::validate()
82 {
83  if (this->isNetworkAutojoinEnabled())
84  {
85  if (gIRCConfig.personal.nickname.isEmpty())
86  {
87  QString nick = CommonGUI::askString(tr("Config validation"), tr("You have chosen one or more networks for autojoin startup but you have not defined any nickname. Please define it now."));
88  if (nick.isEmpty())
89  {
90  return false;
91  }
92 
93  gIRCConfig.personal.nickname = nick;
94  }
95  }
96 
97  return true;
98 }
bool isAutojoinNetwork() const
Join this network when Doomseeker starts up.
Data structure that describes and defines a connection to an IRC network or server.
static QString askString(const QString &title, const QString &label, bool *ok=NULL, const QString &defaultString="")
Calls QInputDialog::getText().
Definition: commongui.cpp:31
Base class for configuration pages.
Definition: configpage.h:43