annotate settings.cpp @ 9:0d7875c26974

layout designer: hints on widget placement during drag and drop
author Goffi <goffi@goffi.org>
date Fri, 26 Aug 2011 12:15:21 +0200
parents c63d67895cbe
children
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"
8
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
21 #include "layout_designer.h"
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
22
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
23 using namespace Qt;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
24
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
25 Settings* Settings::_instance = 0;
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
26
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
27 ProfileListWidgetItem::ProfileListWidgetItem(const QString & profile, QListWidget * parent, bool isDefault)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
28 :QListWidgetItem(profile, parent)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
29 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
30 m_profile = profile;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
31 if (isDefault) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
32 setText(text() + QObject::tr(" (default)"));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
33 QFont _font = font();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
34 _font.setWeight(QFont::Bold);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
35 setFont(_font);
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
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
40 const QString& ProfileListWidgetItem::getProfile()
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
41 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
42 return m_profile;
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
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
45 Settings::Settings(QWidget *parent)
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
46 : QWidget(parent)
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
47 {
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
48 setupUi(this);
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
49
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
50 this->setAttribute(WA_DeleteOnClose);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
51
8
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
52 //We add the settings in tabs
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
53
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
54 // Contact list Layout
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
55 QVBoxLayout *layout = new QVBoxLayout;
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
56 LayoutDesigner* contact_list_layout = new LayoutDesigner;
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
57 layout->addWidget(contact_list_layout);
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
58 contactListLayoutTab->setLayout(layout);
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
59
c63d67895cbe layout designer: first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
60
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
61 //We fill the profiles list
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
62 m_bridge = Bridge::getBridge();
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
63 m_session = Session::getSession();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
64
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
65 const QList<QString>& profiles = m_bridge->getProfilesList();
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
66 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
67 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
68
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
69 foreach(const QString& profile, profiles) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
70 ProfileListWidgetItem *item = new ProfileListWidgetItem(profile, profileList, profile==default_profile);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
71 item->setFlags(item->flags() | ItemIsUserCheckable);
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
72 item->setCheckState(checked_profiles.contains(profile)?Checked:Unchecked);
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
73 }
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 connect(profileList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(profileChanged(QListWidgetItem*)));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
76 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
77
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
78 //Confirmation buttons
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
79 connect(buttonsGroupConfirm, SIGNAL(accepted()), this, SLOT(saveSettings()));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
80 connect(buttonsGroupConfirm, SIGNAL(rejected()), this, SLOT(cancelSettings()));
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
81 }
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
82
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
83 Settings::~Settings()
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 _instance = 0;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
86 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
87
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
88 Settings* Settings::getDialog() {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
89 if (_instance == 0) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
90 _instance = new Settings;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
91 }
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 return _instance;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
94 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
95
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
96 //Profile settings slots
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
97 void Settings::profileChanged(QListWidgetItem* item)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
98 {
0
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
99 }
22b44846b04b Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
100
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
101 void Settings::profileCurrentChanged(QListWidgetItem* current, QListWidgetItem* previous)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
102 {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
103 if (!current) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
104 profileData->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
105 customServerGroup->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
106 customServerGroup->setChecked(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
107 buttonDelete->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
108 buttonSetDefault->setEnabled(false);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
109 jidField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
110 passwordField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
111 serverField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
112 portField->clear();
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
113 return;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
114 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
115
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
116 ProfileListWidgetItem *item = dynamic_cast<ProfileListWidgetItem*>(current);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
117
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
118 profileData->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
119 customServerGroup->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
120 jidField->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
121 passwordField->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
122 buttonDelete->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
123 buttonSetDefault->setEnabled(true);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
124 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
125 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
126 jidField->setText(jid);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
127 passwordField->setText(password);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
128 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
129
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
130
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
131 void Settings::on_buttonNew_clicked() {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
132 bool ok;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
133 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
134 if (ok && !name.isEmpty()) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
135 int success = m_bridge->createProfile(name);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
136 ProfileListWidgetItem *item;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
137
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
138 switch (success) {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
139 case 0: //success
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
140 item = new ProfileListWidgetItem(name, profileList);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
141 item->setFlags(item->flags() | ItemIsUserCheckable);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
142 item->setCheckState(Checked);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
143 break;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
144 case 1: //profile name conflict
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
145 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
146 break;
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
147 default:
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
148 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
149
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
150 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
151 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
152 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
153
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
154
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
155 void Settings::on_buttonDelete_clicked() {
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
156 ProfileListWidgetItem *item = dynamic_cast<ProfileListWidgetItem*>(profileList->currentItem());
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
157
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
158 if ( QMessageBox::question (
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
159 this,
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
160 tr("Delete profile?"),
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
161 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
162 QMessageBox::Yes | QMessageBox::No,
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
163 QMessageBox::No
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
164 ) == QMessageBox::Yes
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 int success = m_bridge->deleteProfile(item->getProfile());
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
168 if (success==0)
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
169 delete(item);
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
170 else
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
171 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
172 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
173
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
174
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
175 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
176
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
177
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
178 //Global settings slots
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
179 void Settings::saveSettings() //Save settings to session
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
180 {
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
181 // We save profiles
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
182 QList<QString> previous_profiles;
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
183 QList<QString>& profiles = m_session->getProfiles();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
184 previous_profiles = profiles;
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
185 profiles.clear();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
186 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
187 {
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
188 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
189 if (item->checkState() == Checked){
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
190 profiles.append(item->getProfile());
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
191 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
192 }
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
193
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
194 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
195 Bellaciao::getInstance()->connectProfiles();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
196
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
197 close();
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
198
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
199 }
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
200
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
201 void Settings::cancelSettings()
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
202 {
4
220e5619bf87 Profiles selection now fill contact list + new Jid class
Goffi <goffi@goffi.org>
parents: 2
diff changeset
203 close();
2
fee291c8d42a settings: profiles management first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
204 }