diff options
| author | 2016-04-29 23:57:30 +0100 | |
|---|---|---|
| committer | 2016-04-29 23:57:48 +0100 | |
| commit | 690dd7a33ddc90678367d73adf313533536e10f2 (patch) | |
| tree | 2276fe7c384ebbc222b40a19c536d5c3c5606ce8 /src/modules/options/OptionsWidget_nickserv.cpp | |
| parent | Add config for clang-format. (diff) | |
| download | KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.tar.gz KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.tar.bz2 KVIrc-690dd7a33ddc90678367d73adf313533536e10f2.zip | |
Apply clang-format
Diffstat (limited to 'src/modules/options/OptionsWidget_nickserv.cpp')
| -rw-r--r-- | src/modules/options/OptionsWidget_nickserv.cpp | 265 |
1 files changed, 136 insertions, 129 deletions
diff --git a/src/modules/options/OptionsWidget_nickserv.cpp b/src/modules/options/OptionsWidget_nickserv.cpp index dc30fb823..ebffe0fc5 100644 --- a/src/modules/options/OptionsWidget_nickserv.cpp +++ b/src/modules/options/OptionsWidget_nickserv.cpp @@ -37,104 +37,107 @@ #include <QPushButton> #include <QMessageBox> - // KviApplication.cpp extern KVIRC_API KviNickServRuleSet * g_pNickServRuleSet; - -NickServRuleEditor::NickServRuleEditor(QWidget * par,bool bUseServerMaskField) -: QDialog(par) +NickServRuleEditor::NickServRuleEditor(QWidget * par, bool bUseServerMaskField) + : QDialog(par) { - setWindowTitle(__tr2qs_ctx("NickServ Authentication Rule - KVIrc","options")); + setWindowTitle(__tr2qs_ctx("NickServ Authentication Rule - KVIrc", "options")); - QGridLayout * gl = new QGridLayout(this);//,bUseServerMaskField ? 7 : 6,4,10,5); + QGridLayout * gl = new QGridLayout(this); //,bUseServerMaskField ? 7 : 6,4,10,5); - QLabel * l = new QLabel(__tr2qs_ctx("Registered nickname:","options"),this); - gl->addWidget(l,0,0); + QLabel * l = new QLabel(__tr2qs_ctx("Registered nickname:", "options"), this); + gl->addWidget(l, 0, 0); m_pRegisteredNickEdit = new QLineEdit(this); - KviTalToolTip::add(m_pRegisteredNickEdit, __tr2qs_ctx("Put here the nickname that you have registered with NickServ","options")); - gl->addWidget(m_pRegisteredNickEdit,0,1,1,3); -// gl->addMultiCellWidget(m_pRegisteredNickEdit,0,0,1,3); + KviTalToolTip::add(m_pRegisteredNickEdit, __tr2qs_ctx("Put here the nickname that you have registered with NickServ", "options")); + gl->addWidget(m_pRegisteredNickEdit, 0, 1, 1, 3); + // gl->addMultiCellWidget(m_pRegisteredNickEdit,0,0,1,3); - l = new QLabel(__tr2qs_ctx("NickServ mask:","options"),this); - gl->addWidget(l,1,0); + l = new QLabel(__tr2qs_ctx("NickServ mask:", "options"), this); + gl->addWidget(l, 1, 0); m_pNickServMaskEdit = new QLineEdit(this); KviTalToolTip::add(m_pNickServMaskEdit, - __tr2qs_ctx("This is the mask that NickServ must match to be correctly identified as the NickServ service. " \ - "This usually will be something like <b>NickServ!service@services.dalnet</b>.<br>" \ - "You can use wildcards for this field, but generally it is a security flaw. " \ - "If you're 100%% sure that NO user on the network can use the nickname \"NickServ\", " \ - "the mask <b>NickServ!*@*</b> may be safe to use in this field.","options")); - gl->addWidget(m_pNickServMaskEdit,1,1,1,3); -// gl->addMultiCellWidget(m_pNickServMaskEdit,1,1,1,3); + __tr2qs_ctx("This is the mask that NickServ must match to be correctly identified as the NickServ service. " + "This usually will be something like <b>NickServ!service@services.dalnet</b>.<br>" + "You can use wildcards for this field, but generally it is a security flaw. " + "If you're 100%% sure that NO user on the network can use the nickname \"NickServ\", " + "the mask <b>NickServ!*@*</b> may be safe to use in this field.", + "options")); + gl->addWidget(m_pNickServMaskEdit, 1, 1, 1, 3); + // gl->addMultiCellWidget(m_pNickServMaskEdit,1,1,1,3); - l = new QLabel(__tr2qs_ctx("Message regexp:","options"),this); - gl->addWidget(l,2,0); + l = new QLabel(__tr2qs_ctx("Message regexp:", "options"), this); + gl->addWidget(l, 2, 0); m_pMessageRegexpEdit = new QLineEdit(this); - gl->addWidget(m_pMessageRegexpEdit,2,1,1,3); -// gl->addMultiCellWidget(m_pMessageRegexpEdit,2,2,1,3); + gl->addWidget(m_pMessageRegexpEdit, 2, 1, 1, 3); + // gl->addMultiCellWidget(m_pMessageRegexpEdit,2,2,1,3); KviTalToolTip::add(m_pMessageRegexpEdit, - __tr2qs_ctx("This is the simple regular expression that the identification request message " \ - "from NickServ must match in order to be correctly recognized.<br>" \ - "The message is usually something like \"To identify yourself please use /ns IDENTIFY password\" " \ - "and it is sent when the NickServ wants you to authenticate yourself. " \ - "You can use the * and ? wildcards.","options")); - l = new QLabel(__tr2qs_ctx("Identify command:","options"),this); - gl->addWidget(l,3,0); + __tr2qs_ctx("This is the simple regular expression that the identification request message " + "from NickServ must match in order to be correctly recognized.<br>" + "The message is usually something like \"To identify yourself please use /ns IDENTIFY password\" " + "and it is sent when the NickServ wants you to authenticate yourself. " + "You can use the * and ? wildcards.", + "options")); + l = new QLabel(__tr2qs_ctx("Identify command:", "options"), this); + gl->addWidget(l, 3, 0); m_pIdentifyCommandEdit = new QLineEdit(this); KviTalToolTip::add(m_pIdentifyCommandEdit, - __tr2qs_ctx("This is the command that will be executed when NickServ requests authentication " \ - "for the nickname described in this rule (if the both server and NickServ mask are matched). " \ - "This usually will be something like <b>msg NickServ identify <yourpassword></b>.<br>" \ - "You can use <b>msg -q</b> if you don't want the password echoed on the screen. " \ - "Please note that there is no leading slash in this command.","options")); - gl->addWidget(m_pIdentifyCommandEdit,3,1,1,3); -// gl->addMultiCellWidget(m_pIdentifyCommandEdit,3,3,1,3); + __tr2qs_ctx("This is the command that will be executed when NickServ requests authentication " + "for the nickname described in this rule (if the both server and NickServ mask are matched). " + "This usually will be something like <b>msg NickServ identify <yourpassword></b>.<br>" + "You can use <b>msg -q</b> if you don't want the password echoed on the screen. " + "Please note that there is no leading slash in this command.", + "options")); + gl->addWidget(m_pIdentifyCommandEdit, 3, 1, 1, 3); + // gl->addMultiCellWidget(m_pIdentifyCommandEdit,3,3,1,3); int iNextLine = 4; if(bUseServerMaskField) { - l = new QLabel(__tr2qs_ctx("Server mask:","options"),this); - gl->addWidget(l,4,0); + l = new QLabel(__tr2qs_ctx("Server mask:", "options"), this); + gl->addWidget(l, 4, 0); m_pServerMaskEdit = new QLineEdit(this); KviTalToolTip::add(m_pServerMaskEdit, - __tr2qs_ctx("This is the mask that the current server must match in order " \ - "for this rule to apply. It can contain * and ? wildcards.<br>Do NOT use simply \"*\" here...","options")); - gl->addWidget(m_pServerMaskEdit,4,1,1,3); -// gl->addMultiCellWidget(m_pServerMaskEdit,4,4,1,3); + __tr2qs_ctx("This is the mask that the current server must match in order " + "for this rule to apply. It can contain * and ? wildcards.<br>Do NOT use simply \"*\" here...", + "options")); + gl->addWidget(m_pServerMaskEdit, 4, 1, 1, 3); + // gl->addMultiCellWidget(m_pServerMaskEdit,4,4,1,3); iNextLine++; - } else { + } + else + { m_pServerMaskEdit = 0; } - - l = new QLabel(__tr2qs_ctx("Hint: Move the mouse cursor over the fields to get help","options"),this); + l = new QLabel(__tr2qs_ctx("Hint: Move the mouse cursor over the fields to get help", "options"), this); l->setMargin(10); - gl->addWidget(l,iNextLine,0,1,4); -// gl->addMultiCellWidget(l,iNextLine,iNextLine,0,3); + gl->addWidget(l, iNextLine, 0, 1, 4); + // gl->addMultiCellWidget(l,iNextLine,iNextLine,0,3); iNextLine++; - QPushButton * p = new QPushButton(__tr2qs_ctx("Cancel","options"),this); + QPushButton * p = new QPushButton(__tr2qs_ctx("Cancel", "options"), this); p->setMinimumWidth(100); - connect(p,SIGNAL(clicked()),this,SLOT(reject())); - gl->addWidget(p,iNextLine,2); + connect(p, SIGNAL(clicked()), this, SLOT(reject())); + gl->addWidget(p, iNextLine, 2); - m_pOkButton = new QPushButton(__tr2qs_ctx("OK","options"),this); + m_pOkButton = new QPushButton(__tr2qs_ctx("OK", "options"), this); m_pOkButton->setMinimumWidth(100); m_pOkButton->setDefault(true); - connect(m_pOkButton,SIGNAL(clicked()),this,SLOT(okPressed())); - gl->addWidget(m_pOkButton,iNextLine,3); + connect(m_pOkButton, SIGNAL(clicked()), this, SLOT(okPressed())); + gl->addWidget(m_pOkButton, iNextLine, 3); - gl->setColumnStretch(1,1); - gl->setRowStretch(bUseServerMaskField ? 5 : 4,1); + gl->setColumnStretch(1, 1); + gl->setRowStretch(bUseServerMaskField ? 5 : 4, 1); setMinimumWidth(250); } @@ -147,18 +150,18 @@ bool NickServRuleEditor::validate() { QString s = m_pRegisteredNickEdit->text(); - QString m = __tr2qs_ctx("Invalid NickServ Rule - KVIrc","options"); - QString o = __tr2qs_ctx("OK","options"); + QString m = __tr2qs_ctx("Invalid NickServ Rule - KVIrc", "options"); + QString o = __tr2qs_ctx("OK", "options"); if(s.isEmpty()) { - QMessageBox::warning(this,m,__tr2qs_ctx("The nickname field can't be empty!","options"),o); + QMessageBox::warning(this, m, __tr2qs_ctx("The nickname field can't be empty!", "options"), o); return false; } if(s.indexOf(QChar(' ')) != -1) { - QMessageBox::warning(this,m,__tr2qs_ctx("The nickname field can't contain spaces!","options"),o); + QMessageBox::warning(this, m, __tr2qs_ctx("The nickname field can't contain spaces!", "options"), o); return false; } @@ -166,7 +169,7 @@ bool NickServRuleEditor::validate() if(s.isEmpty()) { - QMessageBox::warning(this,m,__tr2qs_ctx("The NickServ mask can't be empty!<br>You must put at least * there.","options"),o); + QMessageBox::warning(this, m, __tr2qs_ctx("The NickServ mask can't be empty!<br>You must put at least * there.", "options"), o); return false; } @@ -174,7 +177,7 @@ bool NickServRuleEditor::validate() if(s.isEmpty()) { - QMessageBox::warning(this,m,__tr2qs_ctx("The message regexp can't be empty!<br>You must put at least * there.","options"),o); + QMessageBox::warning(this, m, __tr2qs_ctx("The message regexp can't be empty!<br>You must put at least * there.", "options"), o); return false; } @@ -182,7 +185,7 @@ bool NickServRuleEditor::validate() if(s.isEmpty()) { - QMessageBox::warning(this,m,__tr2qs_ctx("The IDENTIFY command can't be empty!","options"),o); + QMessageBox::warning(this, m, __tr2qs_ctx("The IDENTIFY command can't be empty!", "options"), o); return false; } @@ -191,7 +194,8 @@ bool NickServRuleEditor::validate() void NickServRuleEditor::okPressed() { - if(!validate())return; + if(!validate()) + return; accept(); } @@ -204,7 +208,8 @@ bool NickServRuleEditor::editRule(KviNickServRule * r) if(m_pServerMaskEdit) m_pServerMaskEdit->setText(r->serverMask().isEmpty() ? QString("irc.yourserver.org") : r->serverMask()); m_pRegisteredNickEdit->selectAll(); - if(exec() != QDialog::Accepted)return false; + if(exec() != QDialog::Accepted) + return false; r->setRegisteredNick(m_pRegisteredNickEdit->text()); r->setNickServMask(m_pNickServMaskEdit->text()); r->setMessageRegexp(m_pMessageRegexpEdit->text()); @@ -214,9 +219,8 @@ bool NickServRuleEditor::editRule(KviNickServRule * r) return true; } - OptionsWidget_nickServ::OptionsWidget_nickServ(QWidget * parent) -: KviOptionsWidget(parent) + : KviOptionsWidget(parent) { createLayout(); setObjectName("nickserv_options_widget"); @@ -226,10 +230,10 @@ OptionsWidget_nickServ::OptionsWidget_nickServ(QWidget * parent) KviNickServRuleSet * rs = g_pNickServRuleSet; bool bNickServEnabled = rs ? (rs->isEnabled() && !rs->isEmpty()) : false; - m_pNickServCheck = new QCheckBox(__tr2qs_ctx("Enable NickServ identification","options"),this); - gl->addWidget(m_pNickServCheck,0,0,1,3); -// gl->addMultiCellWidget(m_pNickServCheck,0,0,0,2); - KviTalToolTip::add(m_pNickServCheck,__tr2qs_ctx("This check enables the automatic identification with NickServ","options")); + m_pNickServCheck = new QCheckBox(__tr2qs_ctx("Enable NickServ identification", "options"), this); + gl->addWidget(m_pNickServCheck, 0, 0, 1, 3); + // gl->addMultiCellWidget(m_pNickServCheck,0,0,0,2); + KviTalToolTip::add(m_pNickServCheck, __tr2qs_ctx("This check enables the automatic identification with NickServ", "options")); m_pNickServCheck->setChecked(bNickServEnabled); m_pNickServTreeWidget = new QTreeWidget(this); @@ -237,59 +241,60 @@ OptionsWidget_nickServ::OptionsWidget_nickServ(QWidget * parent) m_pNickServTreeWidget->setAllColumnsShowFocus(true); QStringList columnLabels; - columnLabels.append(__tr2qs_ctx("Nickname","options")); - columnLabels.append(__tr2qs_ctx("Server Mask","options")); - columnLabels.append(__tr2qs_ctx("NickServ Mask","options")); - columnLabels.append(__tr2qs_ctx("NickServ Request Mask","options")); - columnLabels.append(__tr2qs_ctx("Identify Command","options")); + columnLabels.append(__tr2qs_ctx("Nickname", "options")); + columnLabels.append(__tr2qs_ctx("Server Mask", "options")); + columnLabels.append(__tr2qs_ctx("NickServ Mask", "options")); + columnLabels.append(__tr2qs_ctx("NickServ Request Mask", "options")); + columnLabels.append(__tr2qs_ctx("Identify Command", "options")); m_pNickServTreeWidget->setHeaderLabels(columnLabels); - connect(m_pNickServTreeWidget,SIGNAL(itemSelectionChanged()),this,SLOT(enableDisableNickServControls())); + connect(m_pNickServTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(enableDisableNickServControls())); - gl->addWidget(m_pNickServTreeWidget,1,0,1,3); -// gl->addMultiCellWidget(m_pNickServTreeWidget,1,1,0,2); - KviTalToolTip::add(m_pNickServTreeWidget,\ - __tr2qs_ctx("This is a list of NickServ identification rules. " \ - "KVIrc will use them to model its automatic interaction with NickServ on all the networks.<br>" \ - "Please be aware that this feature can cause your NickServ passwords to be stolen " \ - "if used improperly. Make sure that you fully understand the NickServ authentication protocol.<br>" \ - "In other words, be sure to know what you're doing.<br>" \ - "Also note that the password that you provide is stored as <b>PLAIN TEXT</b>.<br>" \ - "KVIrc supports also per-network NickServ authentication rules that can be " \ - "created in the \"Advanced...\" network options (accessible from the servers dialog)." - "","options")); + gl->addWidget(m_pNickServTreeWidget, 1, 0, 1, 3); + // gl->addMultiCellWidget(m_pNickServTreeWidget,1,1,0,2); + KviTalToolTip::add(m_pNickServTreeWidget, + __tr2qs_ctx("This is a list of NickServ identification rules. " + "KVIrc will use them to model its automatic interaction with NickServ on all the networks.<br>" + "Please be aware that this feature can cause your NickServ passwords to be stolen " + "if used improperly. Make sure that you fully understand the NickServ authentication protocol.<br>" + "In other words, be sure to know what you're doing.<br>" + "Also note that the password that you provide is stored as <b>PLAIN TEXT</b>.<br>" + "KVIrc supports also per-network NickServ authentication rules that can be " + "created in the \"Advanced...\" network options (accessible from the servers dialog)." + "", + "options")); - m_pAddRuleButton = new QPushButton(__tr2qs_ctx("Add Rule","options"),this); - connect(m_pAddRuleButton,SIGNAL(clicked()),this,SLOT(addNickServRule())); - gl->addWidget(m_pAddRuleButton,2,0); + m_pAddRuleButton = new QPushButton(__tr2qs_ctx("Add Rule", "options"), this); + connect(m_pAddRuleButton, SIGNAL(clicked()), this, SLOT(addNickServRule())); + gl->addWidget(m_pAddRuleButton, 2, 0); - m_pEditRuleButton = new QPushButton(__tr2qs_ctx("Edit Rule","options"),this); - connect(m_pEditRuleButton,SIGNAL(clicked()),this,SLOT(editNickServRule())); - gl->addWidget(m_pEditRuleButton,2,1); + m_pEditRuleButton = new QPushButton(__tr2qs_ctx("Edit Rule", "options"), this); + connect(m_pEditRuleButton, SIGNAL(clicked()), this, SLOT(editNickServRule())); + gl->addWidget(m_pEditRuleButton, 2, 1); - m_pDelRuleButton = new QPushButton(__tr2qs_ctx("Delete Rule","options"),this); - connect(m_pDelRuleButton,SIGNAL(clicked()),this,SLOT(delNickServRule())); - gl->addWidget(m_pDelRuleButton,2,2); + m_pDelRuleButton = new QPushButton(__tr2qs_ctx("Delete Rule", "options"), this); + connect(m_pDelRuleButton, SIGNAL(clicked()), this, SLOT(delNickServRule())); + gl->addWidget(m_pDelRuleButton, 2, 2); - connect(m_pNickServCheck,SIGNAL(toggled(bool)),this,SLOT(enableDisableNickServControls())); + connect(m_pNickServCheck, SIGNAL(toggled(bool)), this, SLOT(enableDisableNickServControls())); if(rs && rs->rules()) { - QTreeWidgetItem *it; + QTreeWidgetItem * it; KviPointerList<KviNickServRule> * ll = rs->rules(); - for(KviNickServRule * rule = ll->first();rule;rule = ll->next()) + for(KviNickServRule * rule = ll->first(); rule; rule = ll->next()) { it = new QTreeWidgetItem(m_pNickServTreeWidget); - it->setText(0,rule->registeredNick()); - it->setText(1,rule->serverMask()); - it->setText(2,rule->nickServMask()); - it->setText(3,rule->messageRegexp()); - it->setText(4,rule->identifyCommand()); + it->setText(0, rule->registeredNick()); + it->setText(1, rule->serverMask()); + it->setText(2, rule->nickServMask()); + it->setText(3, rule->messageRegexp()); + it->setText(4, rule->identifyCommand()); } } enableDisableNickServControls(); - gl->setRowStretch(1,1); + gl->setRowStretch(1, 1); } OptionsWidget_nickServ::~OptionsWidget_nickServ() @@ -299,38 +304,40 @@ OptionsWidget_nickServ::~OptionsWidget_nickServ() void OptionsWidget_nickServ::editNickServRule() { QTreeWidgetItem * it = (QTreeWidgetItem *)m_pNickServTreeWidget->currentItem(); - if(!it)return; - KviNickServRule r(it->text(0),it->text(2),it->text(3),it->text(4),it->text(1)); - NickServRuleEditor ed(this,true); + if(!it) + return; + KviNickServRule r(it->text(0), it->text(2), it->text(3), it->text(4), it->text(1)); + NickServRuleEditor ed(this, true); if(ed.editRule(&r)) { - it->setText(0,r.registeredNick()); - it->setText(1,r.serverMask()); - it->setText(2,r.nickServMask()); - it->setText(3,r.messageRegexp()); - it->setText(4,r.identifyCommand()); + it->setText(0, r.registeredNick()); + it->setText(1, r.serverMask()); + it->setText(2, r.nickServMask()); + it->setText(3, r.messageRegexp()); + it->setText(4, r.identifyCommand()); } } void OptionsWidget_nickServ::addNickServRule() { KviNickServRule r; - NickServRuleEditor ed(this,true); + NickServRuleEditor ed(this, true); if(ed.editRule(&r)) { - QTreeWidgetItem* it = new QTreeWidgetItem(m_pNickServTreeWidget); - it->setText(0,r.registeredNick()); - it->setText(1,r.serverMask()); - it->setText(2,r.nickServMask()); - it->setText(3,r.messageRegexp()); - it->setText(4,r.identifyCommand()); + QTreeWidgetItem * it = new QTreeWidgetItem(m_pNickServTreeWidget); + it->setText(0, r.registeredNick()); + it->setText(1, r.serverMask()); + it->setText(2, r.nickServMask()); + it->setText(3, r.messageRegexp()); + it->setText(4, r.identifyCommand()); } } void OptionsWidget_nickServ::delNickServRule() { QTreeWidgetItem * it = (QTreeWidgetItem *)m_pNickServTreeWidget->currentItem(); - if(!it)return; + if(!it) + return; delete it; enableDisableNickServControls(); } @@ -351,12 +358,12 @@ void OptionsWidget_nickServ::commit() if(m_pNickServTreeWidget->topLevelItemCount()) { g_pNickServRuleSet->setEnabled(m_pNickServCheck->isChecked()); - QTreeWidgetItem * it;// = m_pNickServTreeWidget->firstChild(); - for (int i=0;i<m_pNickServTreeWidget->topLevelItemCount();i++) -// while(it) + QTreeWidgetItem * it; // = m_pNickServTreeWidget->firstChild(); + for(int i = 0; i < m_pNickServTreeWidget->topLevelItemCount(); i++) + // while(it) { - it=(QTreeWidgetItem *)m_pNickServTreeWidget->topLevelItem(i); - g_pNickServRuleSet->addRule(KviNickServRule::createInstance(it->text(0),it->text(2),it->text(3),it->text(4),it->text(1))); + it = (QTreeWidgetItem *)m_pNickServTreeWidget->topLevelItem(i); + g_pNickServRuleSet->addRule(KviNickServRule::createInstance(it->text(0), it->text(2), it->text(3), it->text(4), it->text(1))); //it = it->nextSibling(); } } |
