Changeset 6054 for branches/qt-gui_qt4/src/dialogs
- Timestamp:
- 01/18/08 21:18:10 (10 months ago)
- Location:
- branches/qt-gui_qt4/src/dialogs
- Files:
-
- 5 modified
-
ownereditdlg.cpp (modified) (5 diffs)
-
ownereditdlg.h (modified) (1 diff)
-
ownermanagerdlg.cpp (modified) (2 diffs)
-
securitydlg.cpp (modified) (7 diffs)
-
securitydlg.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/qt-gui_qt4/src/dialogs/ownereditdlg.cpp
r5837 r6054 42 42 /* TRANSLATOR LicqQtGui::OwnerEditDlg */ 43 43 44 OwnerEditDlg::OwnerEditDlg( QString id,unsigned long ppid, QWidget* parent)44 OwnerEditDlg::OwnerEditDlg(unsigned long ppid, QWidget* parent) 45 45 : QDialog(parent) 46 46 { … … 76 76 lay->addWidget(chkSave, 3, 0, 1, 3); 77 77 78 QString id; 78 79 // Fill the combo list now 79 80 FOR_EACH_PROTO_PLUGIN_START(gLicqDaemon) … … 81 82 if (ppid != 0) // Modifying a user 82 83 { 84 ICQOwner* o = gUserManager.FetchOwner(curPpid, LOCK_R); 85 if (o == NULL) 86 id = QString::null; 87 else 88 { 89 id = o->IdString(); 90 gUserManager.DropOwner(curPpid); 91 } 92 83 93 cmbProtocol->addItem( 84 iconman->iconForStatus(ICQ_STATUS_ONLINE, id.toLatin1(), ppid),85 (*_ppit)->Name(), QString::number( ppid));94 iconman->iconForStatus(ICQ_STATUS_ONLINE, id.toLatin1(), curPpid), 95 (*_ppit)->Name(), QString::number(curPpid)); 86 96 87 97 // Check if this is the current protocol … … 102 112 103 113 // Set the fields 104 if ( !id.isEmpty() &&ppid != 0)114 if (ppid != 0) 105 115 { 106 edtId->setText(id);107 116 ICQOwner* o = gUserManager.FetchOwner(ppid, LOCK_R); 108 117 if (o) 109 118 { 119 edtId->setText(o->IdString()); 110 120 edtPassword->setText(o->Password()); 111 121 chkSave->setChecked(o->SavePassword()); … … 146 156 setTabOrder(cmbProtocol, btnOk); 147 157 setTabOrder(btnOk, btnCancel); 158 159 show(); 148 160 } 149 161 -
branches/qt-gui_qt4/src/dialogs/ownereditdlg.h
r5837 r6054 34 34 Q_OBJECT 35 35 public: 36 OwnerEditDlg( QString id, unsigned long ppid, QWidget* parent = NULL);36 OwnerEditDlg(unsigned long ppid = 0, QWidget* parent = NULL); 37 37 38 38 private slots: -
branches/qt-gui_qt4/src/dialogs/ownermanagerdlg.cpp
r5899 r6054 163 163 void OwnerManagerDlg::addOwner() 164 164 { 165 OwnerEditDlg* d = new OwnerEditDlg(0, 0, this); 166 d->show(); 165 OwnerEditDlg* d = new OwnerEditDlg(0, this); 167 166 connect(d, SIGNAL(destroyed()), SLOT(updateOwners())); 168 167 } … … 213 212 return; 214 213 215 OwnerEditDlg* editDlg = new OwnerEditDlg( item->text(1),214 OwnerEditDlg* editDlg = new OwnerEditDlg( 216 215 item->data(0, Qt::UserRole).toString().toULong(), this); 217 editDlg->show();218 216 connect(editDlg, SIGNAL(destroyed()), SLOT(updateOwners())); 219 217 } -
branches/qt-gui_qt4/src/dialogs/securitydlg.cpp
r5837 r6054 23 23 #include "config.h" 24 24 25 #include <climits>26 27 25 #include <QCheckBox> 28 26 #include <QDialogButtonBox> 29 27 #include <QGroupBox> 30 #include <QLabel>31 #include <QLineEdit>32 28 #include <QPushButton> 33 29 #include <QVBoxLayout> … … 48 44 SecurityDlg::SecurityDlg(QWidget* parent) 49 45 : QDialog(parent), 50 eSecurityInfo(0),51 e PasswordChange(0)46 title(tr("ICQ Security")), 47 eSecurityInfo(0) 52 48 { 53 49 Support::setWidgetProps(this, "SecurityDialog"); 54 50 setAttribute(Qt::WA_DeleteOnClose, true); 55 56 title = tr("ICQ Security Options");57 51 setWindowTitle(title); 58 52 59 // Main dialog layout 53 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 54 if (o == NULL) 55 { 56 InformUser(this, tr("No ICQ owner found.\nPlease create one first.")); 57 close(); 58 return; 59 } 60 60 61 QVBoxLayout* top_lay = new QVBoxLayout(this); 61 62 62 // Options box63 63 QGroupBox* boxOptions = new QGroupBox(tr("Options")); 64 64 QVBoxLayout* layOptions = new QVBoxLayout(boxOptions); 65 65 66 #define ADD_CHECK(var, name, tip ) \66 #define ADD_CHECK(var, name, tip, status) \ 67 67 (var) = new QCheckBox((name)); \ 68 (var)->setChecked((status)); \ 68 69 (var)->setToolTip((tip)); \ 69 70 layOptions->addWidget((var)); … … 71 72 ADD_CHECK(chkAuthorization, tr("&Authorization Required"), tr("Determines " 72 73 "whether regular ICQ clients require\nyour authorization to add you to " 73 "their contact list.") );74 "their contact list."), o->GetAuthorization()); 74 75 ADD_CHECK(chkWebAware, tr("&Web Presence"), tr("Web Presence allows users to" 75 " see\nif you are online through your web indicator.") );76 " see\nif you are online through your web indicator."), o->WebAware()); 76 77 ADD_CHECK(chkHideIp, tr("&Hide IP"), tr("Hide IP stops users from seeing your" 77 " IP address.\nIt doesn't guarantee it will be hidden though.")); 78 " IP address.\nIt doesn't guarantee it will be hidden though."), 79 o->HideIp()); 78 80 #undef ADD_CHECK 81 82 gUserManager.DropOwner(); 79 83 80 84 top_lay->addWidget(boxOptions); 81 85 82 // Password box83 QGroupBox* boxPassword = new QGroupBox(tr("Password/UIN settings"));84 QGridLayout* layPassword = new QGridLayout(boxPassword);85 86 unsigned short row = 0;87 QLabel* label;88 89 #define ADD_LINE(var, name, tip) \90 label = new QLabel((name)); \91 (var) = new QLineEdit(); \92 label->setBuddy((var)); \93 (var)->setToolTip((tip)); \94 layPassword->addWidget(label, row, 0); \95 layPassword->addWidget((var), row++, 1);96 97 ADD_LINE(edtUin, tr("&Uin:"), tr("Enter the UIN which you want to use.\n"98 "Only available if \"Local changes only\" is checked."));99 ADD_LINE(edtFirst, tr("&Password:"), tr("Enter your ICQ password here."));100 ADD_LINE(edtSecond, tr("&Verify:"), tr("Verify your ICQ password here."));101 #undef ADD_LINE102 103 chkOnlyLocal = new QCheckBox(tr("&Local changes only"));104 chkOnlyLocal->setToolTip(tr("If checked, password/UIN changes will apply only"105 " on your local computer.\nUseful if your password is incorrectly saved"106 " in Licq."));107 connect(chkOnlyLocal, SIGNAL(toggled(bool)), SLOT(chkOnlyLocalToggled(bool)));108 layPassword->addWidget(chkOnlyLocal, row++, 0, 1, 2);109 110 // UIN111 edtUin->setEnabled(false);112 edtUin->setValidator(new QIntValidator(10000, INT_MAX, edtUin));113 114 // Owner password115 edtFirst->setEchoMode(QLineEdit::Password);116 edtSecond->setEchoMode(QLineEdit::Password);117 118 ICQOwner* o = gUserManager.FetchOwner(LOCK_R);119 if (o != NULL)120 {121 edtUin->setText(o->IdString());122 edtFirst->setText(o->Password());123 edtSecond->setText(o->Password());124 }125 else126 {127 edtFirst->setEnabled(false);128 edtSecond->setEnabled(false);129 }130 131 // do some magic ;)132 // if we are offline, we enable the checkbox "Only local changes"133 // this saves one click :)134 if (o != NULL) // Make sure we exist135 {136 chkOnlyLocal->setChecked(o->Status() == ICQ_STATUS_OFFLINE);137 chkAuthorization->setChecked(o->GetAuthorization());138 chkWebAware->setChecked(o->WebAware());139 chkHideIp->setChecked(o->HideIp());140 gUserManager.DropOwner();141 }142 else143 {144 chkOnlyLocal->setChecked(true);145 chkOnlyLocal->setEnabled(false);146 chkAuthorization->setChecked(false);147 chkWebAware->setChecked(false);148 chkHideIp->setChecked(false);149 }150 151 // remember the initial values152 // later we use these to apply only what has been changed by the user153 initAuthorization = chkAuthorization->isChecked();154 initWebAware = chkWebAware->isChecked();155 initHideIp = chkHideIp->isChecked();156 initEdtUin = edtUin->text();157 initEdtFirst = edtFirst->text();158 initEdtSecond = edtSecond->text();159 160 top_lay->addWidget(boxPassword);161 162 // Buttons163 86 QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Cancel); 164 87 … … 176 99 void SecurityDlg::ok() 177 100 { 178 ICQOwner* o = gUserManager.FetchOwner(L OCK_R);101 ICQOwner* o = gUserManager.FetchOwner(LICQ_PPID, LOCK_R); 179 102 180 103 if (o == NULL) 181 return;182 183 unsigned short status = o->Status();184 gUserManager.DropOwner();185 186 // validate password187 if ((edtFirst->text().isEmpty() && !chkOnlyLocal->isChecked()) ||188 edtFirst->text().length() > 8)189 104 { 190 InformUser(this, tr("Invalid password, must be between 1 and 8 characters.")); 105 // Even though we protected from this in constructor, 106 // it's never too bad to persuade 107 close(); 191 108 return; 192 109 } 193 110 194 if ( edtFirst->text() != edtSecond->text())111 if (o->Status() == ICQ_STATUS_OFFLINE) 195 112 { 196 InformUser(this, tr("Passwords do not match, try again.")); 113 gUserManager.DropOwner(LICQ_PPID); 114 InformUser(this, tr("You need to be connected to the\n" 115 "ICQ Network to change the settings.")); 197 116 return; 198 117 } 199 118 200 if (status == ICQ_STATUS_OFFLINE && !chkOnlyLocal->isChecked()) 119 bool auth = chkAuthorization->isChecked(); 120 bool web = chkWebAware->isChecked(); 121 bool ip = chkHideIp->isChecked(); 122 123 if (auth != o->GetAuthorization() || 124 web != o->WebAware() || 125 ip != o->HideIp()) 201 126 { 202 InformUser(this, tr("You need to be connected to the\n" 203 "ICQ Network to change the settings.")); 204 return; 127 gUserManager.DropOwner(LICQ_PPID); 128 btnUpdate->setEnabled(false); 129 130 connect(LicqGui::instance()->signalManager(), 131 SIGNAL(doneUserFcn(ICQEvent*)), SLOT(doneUserFcn(ICQEvent*))); 132 133 setWindowTitle(title + " [" + tr("Setting...") + "]"); 134 135 eSecurityInfo = gLicqDaemon->icqSetSecurityInfo(auth, ip, web); 136 137 return; // prevents the dialog from closing 205 138 } 206 139 207 // test if we really need to update anything 208 bool secUpdateNeeded = false; 209 bool pasUpdateNeeded = false; 210 211 if (chkAuthorization->isChecked() != initAuthorization || 212 chkWebAware->isChecked() != initWebAware || 213 chkHideIp->isChecked() != initHideIp) 214 { 215 secUpdateNeeded = true; 216 initAuthorization = chkAuthorization->isChecked(); 217 initWebAware = chkWebAware->isChecked(); 218 initHideIp = chkHideIp->isChecked(); 219 } 220 221 if (edtUin->text() != initEdtUin || 222 edtFirst->text() != initEdtFirst || 223 edtSecond->text() != initEdtSecond) 224 { 225 pasUpdateNeeded = true; 226 initEdtUin = edtUin->text(); 227 initEdtFirst = edtFirst->text(); 228 initEdtSecond = edtSecond->text(); 229 } 230 231 if (secUpdateNeeded || pasUpdateNeeded) 232 { 233 btnUpdate->setEnabled(false); 234 235 if (chkOnlyLocal->isChecked()) 236 { 237 o = gUserManager.FetchOwner(LOCK_W); 238 if (o == NULL) 239 InformUser(this, tr("Failed to change the settings.")); 240 else 241 { 242 o->SetId(edtUin->text().toLatin1()); 243 o->SetPassword(edtFirst->text().toLatin1()); 244 gUserManager.DropOwner(); 245 } 246 } 247 else 248 { 249 connect(LicqGui::instance()->signalManager(), 250 SIGNAL(doneUserFcn(ICQEvent*)), 251 SLOT(doneUserFcn(ICQEvent*))); 252 253 // eSecurityInfo and ePasswordChange contain the event numbers. 254 // These are used in doneUserFcn to compare if we received 255 // what we expected :) 256 if (secUpdateNeeded) 257 eSecurityInfo = gLicqDaemon->icqSetSecurityInfo( 258 chkAuthorization->isChecked(), 259 chkHideIp->isChecked(), 260 chkWebAware->isChecked()); 261 262 if (pasUpdateNeeded) 263 ePasswordChange = gLicqDaemon->icqSetPassword( 264 edtFirst->text().toLatin1()); 265 266 setWindowTitle(title + " [" + tr("Setting...") + "]"); 267 return; // prevents the dialog from closing 268 } 269 } 140 gUserManager.DropOwner(LICQ_PPID); 270 141 271 142 close(); … … 274 145 void SecurityDlg::doneUserFcn(ICQEvent* e) 275 146 { 276 // Checking if the received events correspond to one of 277 // our sent events. 278 bool bSec = e->Equals(eSecurityInfo); 279 bool bPass = e->Equals(ePasswordChange); 280 281 if (!bSec && !bPass) 147 if (!e->Equals(eSecurityInfo)) 282 148 return; 283 149 284 QString result; 150 eSecurityInfo = 0; 151 QString result = QString::null; 152 btnUpdate->setEnabled(true); 153 154 disconnect(LicqGui::instance()->signalManager(), 155 SIGNAL(doneUserFcn(ICQEvent*)), this, SLOT(doneUserFcn(ICQEvent*))); 285 156 286 157 switch (e->Result()) … … 288 159 case EVENT_FAILED: 289 160 result = tr("failed"); 290 if (bSec) 291 InformUser(this, tr("Setting security options failed.")); 292 else if (bPass) 293 InformUser(this, tr("Changing password failed.")); 161 InformUser(this, tr("Setting security options failed.")); 294 162 break; 295 163 296 164 case EVENT_TIMEDOUT: 297 165 result = tr("timed out"); 298 if (bSec) 299 InformUser(this, tr("Timeout while setting security options.")); 300 else if (bPass) 301 InformUser(this, tr("Timeout while changing password.")); 166 InformUser(this, tr("Timeout while setting security options.")); 302 167 break; 303 168 304 169 case EVENT_ERROR: 305 170 result = tr("error"); 306 if (bSec) 307 InformUser(this, tr("Internal error while setting security options.")); 308 else if (bPass) 309 InformUser(this, tr("Internal error while changing password.")); 171 InformUser(this, tr("Internal error while setting security options.")); 310 172 break; 311 173 … … 314 176 } 315 177 316 if (bSec) 317 eSecurityInfo = 0; 318 else if (bPass) 319 ePasswordChange = 0; 320 321 if (eSecurityInfo == 0 && ePasswordChange == 0) 322 btnUpdate->setEnabled(true); 323 324 if (!result.isEmpty()) 178 if (result.isEmpty()) 179 close(); 180 else 325 181 setWindowTitle(title + " [" + tr("Setting...") + " " + result + "]"); 326 else327 {328 if ((eSecurityInfo == 0) && (ePasswordChange == 0))329 {330 setWindowTitle(tr("ICQ Security Options"));331 close();332 }333 }334 182 } 335 336 void SecurityDlg::chkOnlyLocalToggled(bool b)337 {338 edtUin->setEnabled(b);339 chkAuthorization->setEnabled(!b);340 chkWebAware->setEnabled(!b);341 chkHideIp->setEnabled(!b);342 } -
branches/qt-gui_qt4/src/dialogs/securitydlg.h
r5822 r6054 24 24 25 25 class QCheckBox; 26 class QLineEdit;27 26 class QPushButton; 28 27 … … 44 43 QCheckBox* chkAuthorization; 45 44 QCheckBox* chkHideIp; 46 QCheckBox* chkOnlyLocal;47 48 QLineEdit* edtUin;49 QLineEdit* edtFirst;50 QLineEdit* edtSecond;51 45 52 46 QString title; 53 47 54 // Event tags55 48 unsigned long eSecurityInfo; 56 unsigned long ePasswordChange;57 58 // For saving initial values59 bool initAuthorization, initWebAware, initHideIp;60 QString initEdtUin, initEdtFirst, initEdtSecond;61 49 62 50 private slots: 63 51 void ok(); 64 52 void doneUserFcn(ICQEvent* e); 65 void chkOnlyLocalToggled(bool b);66 53 }; 67 54
