ircconfigurationdialog.cpp
1 //------------------------------------------------------------------------------
2 // ircconfigurationdialog.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library 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 GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; 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 "gui/commongui.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 "irc/configuration/ircconfig.h"
29 #include "ircconfigurationdialog.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  gLog << tr("Settings saved!");
42  else
43  gLog << tr("Settings save failed!");
44 }
45 
46 void IRCConfigurationDialog::initOptionsList()
47 {
48  ConfigPage *configPage = nullptr;
49 
50  configPage = new CFGIRCAppearance(this);
51  this->addConfigPage(nullptr, configPage);
52 
53  cfgNetworks = new CFGIRCNetworks(this);
54  configPage = cfgNetworks;
55  this->addConfigPage(nullptr, configPage);
56 
57  configPage = new CFGIRCSounds(this);
58  this->addConfigPage(nullptr, configPage);
59 
60  addConfigPage(nullptr, new CfgChatLogsPage(this));
61 }
62 
63 bool IRCConfigurationDialog::isNetworkAutojoinEnabled()
64 {
65  QVector<IRCNetworkEntity *> networks = cfgNetworks->networks();
66  for (IRCNetworkEntity *pNetwork : networks)
67  {
68  if (pNetwork->isAutojoinNetwork())
69  return true;
70  }
71 
72  return false;
73 }
74 
75 bool IRCConfigurationDialog::validate()
76 {
77  if (this->isNetworkAutojoinEnabled())
78  {
79  if (gIRCConfig.personal.nickname.isEmpty())
80  {
81  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."));
82  if (nick.isEmpty())
83  return false;
84 
85  gIRCConfig.personal.nickname = nick;
86  }
87  }
88 
89  return true;
90 }
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=nullptr, const QString &defaultString="")
Calls QInputDialog::getText().
Definition: commongui.cpp:31
Base class for configuration pages.
Definition: configpage.h:44