annotate settings.cpp @ 6:48045176d1c6

ContactT and Ji improvments
author Goffi <goffi@goffi.org>
date Fri, 12 Aug 2011 22:08:37 +0200
parents 220e5619bf87
children c63d67895cbe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
1 /*
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
2 Bellaciao: a Salut à Toi frontend
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
3 Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
4
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
6 it under the terms of the GNU Affero General Public License as published by
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
7 the Free Software Foundation, either version 3 of the License, or
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
8 (at your option) any later version.
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
9
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
13 GNU Affero General Public License for more details.
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
14
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
15 You should have received a copy of the GNU Affero General Public License
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
17 */
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
18
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
19 #include "settings.h"
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
20 #include "bellaciao.h"
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
21
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
22 using namespace Qt;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
23
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
24 Settings* Settings::_instance = 0;
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
25
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
26 ProfileListWidgetItem::ProfileListWidgetItem(const QString & profile, QListWidget * parent, bool isDefault)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
27 :QListWidgetItem(profile, parent)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
28 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
29 m_profile = profile;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
30 if (isDefault) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
31 setText(text() + QObject::tr(" (default)"));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
32 QFont _font = font();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
33 _font.setWeight(QFont::Bold);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
34 setFont(_font);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
35 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
36
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
37 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
38
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
39 const QString& ProfileListWidgetItem::getProfile()
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
40 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
41 return m_profile;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
42 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
43
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
44 Settings::Settings(QWidget *parent)
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
45 : QWidget(parent)
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
46 {
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
47 setupUi(this);
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
48
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
49 this->setAttribute(WA_DeleteOnClose);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
50
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
51 //We fill the profiles list
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
52 m_bridge = Bridge::getBridge();
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
53 m_session = Session::getSession();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
54
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
55 const QList<QString>& profiles = m_bridge->getProfilesList();
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
56 const QString& default_profile = m_bridge->getProfileName("@DEFAULT@");
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
57 const QList<QString>& checked_profiles = m_session->getProfiles();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
58
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
59 foreach(const QString& profile, profiles) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
60 ProfileListWidgetItem *item = new ProfileListWidgetItem(profile, profileList, profile==default_profile);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
61 item->setFlags(item->flags() | ItemIsUserCheckable);
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
62 item->setCheckState(checked_profiles.contains(profile)?Checked:Unchecked);
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
63 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
64
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
65 connect(profileList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(profileChanged(QListWidgetItem*)));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
66 connect(profileList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(profileCurrentChanged(QListWidgetItem*, QListWidgetItem*)));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
67
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
68 //Confirmation buttons
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
69 connect(buttonsGroupConfirm, SIGNAL(accepted()), this, SLOT(saveSettings()));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
70 connect(buttonsGroupConfirm, SIGNAL(rejected()), this, SLOT(cancelSettings()));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
71 }
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
72
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
73 Settings::~Settings()
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
74 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
75 _instance = 0;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
76 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
77
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
78 Settings* Settings::getDialog() {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
79 if (_instance == 0) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
80 _instance = new Settings;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
81 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
82
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
83 return _instance;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
84 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
85
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
86 //Profile settings slots
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
87 void Settings::profileChanged(QListWidgetItem* item)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
88 {
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
89 }
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
90
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
91 void Settings::profileCurrentChanged(QListWidgetItem* current, QListWidgetItem* previous)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
92 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
93 if (!current) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
94 profileData->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
95 customServerGroup->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
96 customServerGroup->setChecked(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
97 buttonDelete->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
98 buttonSetDefault->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
99 jidField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
100 passwordField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
101 serverField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
102 portField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
103 return;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
104 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
105
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
106 ProfileListWidgetItem *item = dynamic_cast<ProfileListWidgetItem*>(current);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
107
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
108 profileData->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
109 customServerGroup->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
110 jidField->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
111 passwordField->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
112 buttonDelete->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
113 buttonSetDefault->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
114 const QString& jid = m_bridge->getParamA("JabberID", "Connection", "value", item->getProfile());
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
115 const QString& password = m_bridge->getParamA("Password", "Connection", "value", item->getProfile());
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
116 jidField->setText(jid);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
117 passwordField->setText(password);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
118 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
119
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
120
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
121 void Settings::on_buttonNew_clicked() {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
122 bool ok;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
123 QString name = QInputDialog::getText(this, tr("New profile"), tr("Please enter profile name: "), QLineEdit::Normal, QString(), &ok);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
124 if (ok && !name.isEmpty()) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
125 int success = m_bridge->createProfile(name);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
126 ProfileListWidgetItem *item;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
127
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
128 switch (success) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
129 case 0: //success
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
130 item = new ProfileListWidgetItem(name, profileList);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
131 item->setFlags(item->flags() | ItemIsUserCheckable);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
132 item->setCheckState(Checked);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
133 break;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
134 case 1: //profile name conflict
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
135 QMessageBox::warning(this, tr("Profile name conflict"), tr("A profile with this name already exists. Please choose an other name"));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
136 break;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
137 default:
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
138 QMessageBox::warning(this, tr("Profile creation error"), tr("Can't create profile"));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
139
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
140 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
141 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
142 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
143
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
144
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
145 void Settings::on_buttonDelete_clicked() {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
146 ProfileListWidgetItem *item = dynamic_cast<ProfileListWidgetItem*>(profileList->currentItem());
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
147
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
148 if ( QMessageBox::question (
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
149 this,
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
150 tr("Delete profile?"),
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
151 tr("Do you really want to delete profile \"%1\" ?").arg(item->getProfile()),
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
152 QMessageBox::Yes | QMessageBox::No,
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
153 QMessageBox::No
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
154 ) == QMessageBox::Yes
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
155 )
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
156 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
157 int success = m_bridge->deleteProfile(item->getProfile());
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
158 if (success==0)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
159 delete(item);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
160 else
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
161 QMessageBox::warning(this, tr("Profile deletion error"), tr("Can't delete profile"));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
162 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
163
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
164
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
165 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
166
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
167
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
168 //Global settings slots
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
169 void Settings::saveSettings() //Save settings to session
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
170 {
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
171 // We save profiles
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
172 QList<QString> previous_profiles;
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
173 QList<QString>& profiles = m_session->getProfiles();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
174 previous_profiles = profiles;
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
175 profiles.clear();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
176 for (int i=0; i<profileList->count(); i++)
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
177 {
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
178 ProfileListWidgetItem* item = dynamic_cast<ProfileListWidgetItem*>(profileList->item(i));
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
179 if (item->checkState() == Checked){
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
180 profiles.append(item->getProfile());
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
181 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
182 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
183
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
184 if (previous_profiles!=profiles) //The profiles checked are differents, we refill the contactList
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
185 Bellaciao::getInstance()->connectProfiles();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
186
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
187 close();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
188
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
189 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
190
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
191 void Settings::cancelSettings()
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
192 {
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
193 close();
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
194 }