diff options
Diffstat (limited to 'src/modules/reguser/RegistrationWizard.cpp')
| -rw-r--r-- | src/modules/reguser/RegistrationWizard.cpp | 232 |
1 files changed, 123 insertions, 109 deletions
diff --git a/src/modules/reguser/RegistrationWizard.cpp b/src/modules/reguser/RegistrationWizard.cpp index 0dfabd350..7cd29fea4 100644 --- a/src/modules/reguser/RegistrationWizard.cpp +++ b/src/modules/reguser/RegistrationWizard.cpp @@ -22,7 +22,6 @@ // //============================================================================= - #include "RegistrationWizard.h" #include "KviLocale.h" @@ -43,12 +42,11 @@ #include <QVariant> #include <QFrame> - extern KVIRC_API KviRegisteredUserDataBase * g_pRegisteredUserDataBase; extern KviPointerList<RegistrationWizard> * g_pRegistrationWizardList; -RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUserDataBase * db,QWidget * par,bool bModal) -: KviTalWizard(par) +RegistrationWizard::RegistrationWizard(const QString & startMask, KviRegisteredUserDataBase * db, QWidget * par, bool bModal) + : KviTalWizard(par) { m_pDb = db; @@ -60,21 +58,21 @@ RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUse g_pRegistrationWizardList->append(this); - QGridLayout* m_pPage1Layout; - QGridLayout* m_pPage2Layout; - QGridLayout* m_pPage3Layout; - QGridLayout* m_pPage4Layout; - QGridLayout* m_pPage5Layout; + QGridLayout * m_pPage1Layout; + QGridLayout * m_pPage2Layout; + QGridLayout * m_pPage3Layout; + QGridLayout * m_pPage4Layout; + QGridLayout * m_pPage5Layout; - QLabel* TextLabel10_2; - QLabel* TextLabel10; - QLabel* TextLabel10_3; - QLabel* TextLabel10_3_2; + QLabel * TextLabel10_2; + QLabel * TextLabel10; + QLabel * TextLabel10_3; + QLabel * TextLabel10_3_2; QFrame * f; -// resize( 490, 456 ); - setWindowTitle(__tr2qs_ctx("User Registration Wizard - KVIrc","register")); + // resize( 490, 456 ); + setWindowTitle(__tr2qs_ctx("User Registration Wizard - KVIrc", "register")); setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Linux))); setSizeGripEnabled(true); @@ -85,26 +83,27 @@ RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUse m_pPage1Layout->setMargin(8); m_pLabel1 = new QLabel(m_pPage1); - m_pLabel1->setText(__tr2qs_ctx("<p>Welcome to the user registration wizard.<br>This process allows you to add an IRC user to the database and set properties for that user. KVIrc will be (hopefully) able to recognize the user, add him to the notify list, and display the associated avatar.<br><br>First of all, you must insert an <b>entry name or real name</b> for the user you're going to register. The name will be used to identify the database entry and has no specific requirements, it can be a given name, nickname, or just some text to remind you of the real person.<br>Examples: \"George W Bush\", \"Dubya\".\n</p>","register")); + m_pLabel1->setText(__tr2qs_ctx("<p>Welcome to the user registration wizard.<br>This process allows you to add an IRC user to the database and set properties for that user. KVIrc will be (hopefully) able to recognize the user, add him to the notify list, and display the associated avatar.<br><br>First of all, you must insert an <b>entry name or real name</b> for the user you're going to register. The name will be used to identify the database entry and has no specific requirements, it can be a given name, nickname, or just some text to remind you of the real person.<br>Examples: \"George W Bush\", \"Dubya\".\n</p>", "register")); m_pLabel1->setWordWrap(true); - m_pPage1Layout->addWidget(m_pLabel1,0,0,1,2); + m_pPage1Layout->addWidget(m_pLabel1, 0, 0, 1, 2); m_pEditRealName = new QLineEdit(m_pPage1); //m_pEditRealName->setAlignment(int(QLineEdit::AlignHCenter)); - m_pPage1Layout->addWidget(m_pEditRealName,3,1); + m_pPage1Layout->addWidget(m_pEditRealName, 3, 1); m_pEntryNameLabel = new QLabel(m_pPage1); - m_pEntryNameLabel->setText(__tr2qs_ctx("Entry name:","register")); - m_pPage1Layout->addWidget(m_pEntryNameLabel,3,0); - m_pPage1Layout->setRowStretch(1,1); + m_pEntryNameLabel->setText(__tr2qs_ctx("Entry name:", "register")); + m_pPage1Layout->addWidget(m_pEntryNameLabel, 3, 0); + m_pPage1Layout->setRowStretch(1, 1); - addPage( m_pPage1,__tr2qs_ctx("Step 1: Entry Name","register")); + addPage(m_pPage1, __tr2qs_ctx("Step 1: Entry Name", "register")); - if(mask.nick() != "*")m_pEditRealName->setText(mask.nick()); + if(mask.nick() != "*") + m_pEditRealName->setText(mask.nick()); - connect(m_pEditRealName,SIGNAL(textChanged(const QString &)),this,SLOT(realNameChanged(const QString &))); + connect(m_pEditRealName, SIGNAL(textChanged(const QString &)), this, SLOT(realNameChanged(const QString &))); // PAGE 2 @@ -113,11 +112,11 @@ RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUse m_pPage2Layout->setSpacing(4); m_pPage2Layout->setMargin(8); - m_pLabel2 = new QLabel( m_pPage2); - m_pLabel2->setText(__tr2qs_ctx("<p>A registered user is identified by one or more <b>IRC masks</b>.<br>A mask must be in the following form:<br><b>nickname!username@hostname</b><br>and can contain wildcard characters '*' and '?'. Be careful in choosing the masks, as they are the only way to verify the identity of a registered user.<br><br>You can enter at most two masks here, if you wish to add more masks, use the \"<b>Edit</b>\" button in the Registered Users dialog. You must enter at least one mask.</p>","register")); + m_pLabel2 = new QLabel(m_pPage2); + m_pLabel2->setText(__tr2qs_ctx("<p>A registered user is identified by one or more <b>IRC masks</b>.<br>A mask must be in the following form:<br><b>nickname!username@hostname</b><br>and can contain wildcard characters '*' and '?'. Be careful in choosing the masks, as they are the only way to verify the identity of a registered user.<br><br>You can enter at most two masks here, if you wish to add more masks, use the \"<b>Edit</b>\" button in the Registered Users dialog. You must enter at least one mask.</p>", "register")); m_pLabel2->setWordWrap(true); - m_pPage2Layout->addWidget(m_pLabel2,0,0,1,5); + m_pPage2Layout->addWidget(m_pLabel2, 0, 0, 1, 5); //KviCString szMask; @@ -127,54 +126,57 @@ RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUse m_pNicknameEdit1 = new QLineEdit(m_pPage2); m_pNicknameEdit1->setAlignment(Qt::AlignRight); - if(mask.nick() != "*")m_pNicknameEdit1->setText(mask.nick()); - connect(m_pNicknameEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(maskChanged(const QString &))); - m_pPage2Layout->addWidget( m_pNicknameEdit1,3,0); + if(mask.nick() != "*") + m_pNicknameEdit1->setText(mask.nick()); + connect(m_pNicknameEdit1, SIGNAL(textChanged(const QString &)), this, SLOT(maskChanged(const QString &))); + m_pPage2Layout->addWidget(m_pNicknameEdit1, 3, 0); m_pUsernameEdit1 = new QLineEdit(m_pPage2); m_pUsernameEdit1->setAlignment(Qt::AlignHCenter); - if(mask.hasUser())m_pUsernameEdit1->setText(mask.user()); - connect(m_pUsernameEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(maskChanged(const QString &))); - m_pPage2Layout->addWidget(m_pUsernameEdit1,3,2); + if(mask.hasUser()) + m_pUsernameEdit1->setText(mask.user()); + connect(m_pUsernameEdit1, SIGNAL(textChanged(const QString &)), this, SLOT(maskChanged(const QString &))); + m_pPage2Layout->addWidget(m_pUsernameEdit1, 3, 2); m_pHostEdit1 = new QLineEdit(m_pPage2); - if(mask.hasHost())m_pHostEdit1->setText(mask.host()); - connect(m_pHostEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(maskChanged(const QString &))); - m_pPage2Layout->addWidget(m_pHostEdit1,3,4); + if(mask.hasHost()) + m_pHostEdit1->setText(mask.host()); + connect(m_pHostEdit1, SIGNAL(textChanged(const QString &)), this, SLOT(maskChanged(const QString &))); + m_pPage2Layout->addWidget(m_pHostEdit1, 3, 4); m_pNicknameEdit2 = new QLineEdit(m_pPage2); m_pNicknameEdit2->setAlignment(Qt::AlignRight); - m_pPage2Layout->addWidget(m_pNicknameEdit2,4,0); + m_pPage2Layout->addWidget(m_pNicknameEdit2, 4, 0); m_pUsernameEdit2 = new QLineEdit(m_pPage2); m_pUsernameEdit2->setAlignment(Qt::AlignHCenter); - m_pPage2Layout->addWidget(m_pUsernameEdit2,4,2); + m_pPage2Layout->addWidget(m_pUsernameEdit2, 4, 2); m_pHostEdit2 = new QLineEdit(m_pPage2); - m_pPage2Layout->addWidget(m_pHostEdit2,4,4); + m_pPage2Layout->addWidget(m_pHostEdit2, 4, 4); TextLabel10_2 = new QLabel(m_pPage2); TextLabel10_2->setText("<b>!</b>"); TextLabel10_2->setAlignment(Qt::AlignCenter); - m_pPage2Layout->addWidget(TextLabel10_2,4,1); + m_pPage2Layout->addWidget(TextLabel10_2, 4, 1); TextLabel10 = new QLabel(m_pPage2); TextLabel10->setText("<b>!</b>"); TextLabel10->setAlignment(Qt::AlignCenter); - m_pPage2Layout->addWidget(TextLabel10,3,1); + m_pPage2Layout->addWidget(TextLabel10, 3, 1); TextLabel10_3 = new QLabel(m_pPage2); TextLabel10_3->setText("<b>@</b>"); TextLabel10_3->setAlignment(Qt::AlignCenter); - m_pPage2Layout->addWidget(TextLabel10_3,3,3); + m_pPage2Layout->addWidget(TextLabel10_3, 3, 3); TextLabel10_3_2 = new QLabel(m_pPage2); TextLabel10_3_2->setText("<b>@</b>"); TextLabel10_3_2->setAlignment(Qt::AlignCenter); - m_pPage2Layout->addWidget(TextLabel10_3_2,4,3); - m_pPage2Layout->setRowStretch(1,1); + m_pPage2Layout->addWidget(TextLabel10_3_2, 4, 3); + m_pPage2Layout->setRowStretch(1, 1); - addPage(m_pPage2,__tr2qs_ctx("Step 2: Mask Selection","register")); + addPage(m_pPage2, __tr2qs_ctx("Step 2: Mask Selection", "register")); // PAGE 3 @@ -184,20 +186,20 @@ RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUse m_pPage3Layout->setMargin(8); m_pLabel3 = new QLabel(m_pPage3); - m_pLabel3->setText(__tr2qs_ctx("<p>If you want to store an avatar image for this user, you can set it here. KVIrc will show the avatar in the userlist next to the user's nickname.<br>An avatar can be in any supported image format (PNG is recommended). Keep in mind that KVIrc stores avatars in memory and has to resize them to fit in the userlist, thus it's better to use small, low-resolution images.</p>","register")); + m_pLabel3->setText(__tr2qs_ctx("<p>If you want to store an avatar image for this user, you can set it here. KVIrc will show the avatar in the userlist next to the user's nickname.<br>An avatar can be in any supported image format (PNG is recommended). Keep in mind that KVIrc stores avatars in memory and has to resize them to fit in the userlist, thus it's better to use small, low-resolution images.</p>", "register")); m_pLabel3->setWordWrap(true); - m_pPage3Layout->addWidget(m_pLabel3,0,0); + m_pPage3Layout->addWidget(m_pLabel3, 0, 0); f = new QFrame(m_pPage3); f->setFrameStyle(QFrame::HLine | QFrame::Sunken); - m_pPage3Layout->addWidget(f,1,0); + m_pPage3Layout->addWidget(f, 1, 0); m_pAvatar = new KviPixmap(); - m_pAvatarSelector = new KviPixmapSelector(m_pPage3,__tr2qs_ctx("Store an avatar for this user:","register"),m_pAvatar,true); - m_pPage3Layout->addWidget(m_pAvatarSelector,2,0); - m_pPage3Layout->setRowStretch(2,1); + m_pAvatarSelector = new KviPixmapSelector(m_pPage3, __tr2qs_ctx("Store an avatar for this user:", "register"), m_pAvatar, true); + m_pPage3Layout->addWidget(m_pAvatarSelector, 2, 0); + m_pPage3Layout->setRowStretch(2, 1); - addPage(m_pPage3,__tr2qs_ctx("Step 3: Avatar Selection","register")); + addPage(m_pPage3, __tr2qs_ctx("Step 3: Avatar Selection", "register")); // PAGE 4 @@ -207,35 +209,36 @@ RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUse m_pPage4Layout->setMargin(8); m_pLabel4 = new QLabel(m_pPage4); - m_pLabel4->setText(__tr2qs_ctx("<p>If you want to be notified when this user is online or goes offline, you must specify the list of nicknames that KVIrc will look for.<br><br>You can enter at most two nicknames here, if you wish to add more nicknames, use the \"<b>Edit</b>\" button in the \"Registered Users\" dialog.</p>","register")); + m_pLabel4->setText(__tr2qs_ctx("<p>If you want to be notified when this user is online or goes offline, you must specify the list of nicknames that KVIrc will look for.<br><br>You can enter at most two nicknames here, if you wish to add more nicknames, use the \"<b>Edit</b>\" button in the \"Registered Users\" dialog.</p>", "register")); m_pLabel4->setWordWrap(true); - m_pPage4Layout->addWidget(m_pLabel4,0,0,1,5); + m_pPage4Layout->addWidget(m_pLabel4, 0, 0, 1, 5); m_pNotifyCheck = new QCheckBox(m_pPage4); - m_pNotifyCheck->setText(__tr2qs_ctx("Add this user to the notify list","register")); + m_pNotifyCheck->setText(__tr2qs_ctx("Add this user to the notify list", "register")); m_pNotifyCheck->setChecked(false); - connect(m_pNotifyCheck,SIGNAL(toggled(bool)),this,SLOT(notifyCheckToggled(bool))); - m_pPage4Layout->addWidget(m_pNotifyCheck,3,0,1,2); + connect(m_pNotifyCheck, SIGNAL(toggled(bool)), this, SLOT(notifyCheckToggled(bool))); + m_pPage4Layout->addWidget(m_pNotifyCheck, 3, 0, 1, 2); m_pNotifyNickLabel1 = new QLabel(m_pPage4); - m_pNotifyNickLabel1->setText(__tr2qs_ctx("Nickname:","register")); - m_pPage4Layout->addWidget(m_pNotifyNickLabel1,4,0); + m_pNotifyNickLabel1->setText(__tr2qs_ctx("Nickname:", "register")); + m_pPage4Layout->addWidget(m_pNotifyNickLabel1, 4, 0); m_pNotifyNickLabel2 = new QLabel(m_pPage4); - m_pNotifyNickLabel2->setText(__tr2qs_ctx("Nickname 2:","register")); - m_pPage4Layout->addWidget(m_pNotifyNickLabel2,5,0); + m_pNotifyNickLabel2->setText(__tr2qs_ctx("Nickname 2:", "register")); + m_pPage4Layout->addWidget(m_pNotifyNickLabel2, 5, 0); m_pNotifyNickEdit1 = new QLineEdit(m_pPage4); - if(mask.nick() != "*")m_pNotifyNickEdit1->setText(mask.nick()); - connect(m_pNotifyNickEdit1,SIGNAL(textChanged(const QString &)),this,SLOT(notifyNickChanged(const QString &))); - m_pPage4Layout->addWidget(m_pNotifyNickEdit1,4,1); + if(mask.nick() != "*") + m_pNotifyNickEdit1->setText(mask.nick()); + connect(m_pNotifyNickEdit1, SIGNAL(textChanged(const QString &)), this, SLOT(notifyNickChanged(const QString &))); + m_pPage4Layout->addWidget(m_pNotifyNickEdit1, 4, 1); m_pNotifyNickEdit2 = new QLineEdit(m_pPage4); - connect(m_pNotifyNickEdit2,SIGNAL(textChanged(const QString &)),this,SLOT(notifyNickChanged(const QString &))); - m_pPage4Layout->addWidget(m_pNotifyNickEdit2,5,1); - m_pPage4Layout->setRowStretch(1,1); + connect(m_pNotifyNickEdit2, SIGNAL(textChanged(const QString &)), this, SLOT(notifyNickChanged(const QString &))); + m_pPage4Layout->addWidget(m_pNotifyNickEdit2, 5, 1); + m_pPage4Layout->setRowStretch(1, 1); - addPage(m_pPage4,__tr2qs_ctx("Step 4: Notify List","register")); + addPage(m_pPage4, __tr2qs_ctx("Step 4: Notify List", "register")); // PAGE 5 @@ -245,20 +248,20 @@ RegistrationWizard::RegistrationWizard(const QString &startMask,KviRegisteredUse m_pPage5Layout->setMargin(8); m_pTextLabel5 = new QLabel(m_pPage5); - m_pTextLabel5->setText(__tr2qs_ctx("<p>That's it. The user registration has been completed.<br><br>Click \"<b>Finish</b>\" to close this dialog.</p>","register")); + m_pTextLabel5->setText(__tr2qs_ctx("<p>That's it. The user registration has been completed.<br><br>Click \"<b>Finish</b>\" to close this dialog.</p>", "register")); m_pTextLabel5->setWordWrap(true); - m_pPage5Layout->addWidget(m_pTextLabel5,0,0); - m_pPage5Layout->setRowStretch(1,1); + m_pPage5Layout->addWidget(m_pTextLabel5, 0, 0); + m_pPage5Layout->setRowStretch(1, 1); - addPage(m_pPage5,__tr2qs_ctx("Registration Complete","register")); + addPage(m_pPage5, __tr2qs_ctx("Registration Complete", "register")); - setFinishEnabled(m_pPage5,true); + setFinishEnabled(m_pPage5, true); QString dummy; maskChanged(dummy); realNameChanged(dummy); notifyCheckToggled(false); - setMinimumSize(QSize(350,420)); + setMinimumSize(QSize(350, 420)); // signals and slots connections } @@ -274,9 +277,10 @@ RegistrationWizard::~RegistrationWizard() void RegistrationWizard::reject() { KviTalWizard::reject(); - if(!m_bModal)delete this; -// hide(); -// g_pApp->collectGarbage(this); + if(!m_bModal) + delete this; + // hide(); + // g_pApp->collectGarbage(this); } void RegistrationWizard::accept() @@ -291,16 +295,17 @@ void RegistrationWizard::accept() QString szName = m_pEditRealName->text(); KviRegisteredUser * u; - if(bLocalDb) { - if(szName.isEmpty()) szName = "user"; + if(szName.isEmpty()) + szName = "user"; QString szNameOk = szName; int idx = 1; - do { + do + { u = m_pDb->findUserByName(szNameOk); if(u) { @@ -310,10 +315,12 @@ void RegistrationWizard::accept() } while(u); u = m_pDb->addUser(szNameOk); - - } else { + } + else + { u = m_pDb->findUserByName(szName); - if(!u)u = m_pDb->addUser(szName); + if(!u) + u = m_pDb->addUser(szName); } if(!u) @@ -331,9 +338,9 @@ void RegistrationWizard::accept() QString m3 = m_pHostEdit1->text(); if(!(m1.isEmpty() && m2.isEmpty() && m3.isEmpty())) { - mk = new KviIrcMask(m1,m2,m3); + mk = new KviIrcMask(m1, m2, m3); m_pDb->removeMask(*mk); - m_pDb->addMask(u,mk); + m_pDb->addMask(u, mk); } m1 = m_pNicknameEdit2->text(); @@ -341,12 +348,15 @@ void RegistrationWizard::accept() m3 = m_pHostEdit2->text(); if(!(m1.isEmpty() && m2.isEmpty() && m3.isEmpty())) { - if(m1.isEmpty())m1 = "*"; - if(m2.isEmpty())m2 = "*"; - if(m3.isEmpty())m3 = "*"; - mk = new KviIrcMask(m1,m2,m3); + if(m1.isEmpty()) + m1 = "*"; + if(m2.isEmpty()) + m2 = "*"; + if(m3.isEmpty()) + m3 = "*"; + mk = new KviIrcMask(m1, m2, m3); m_pDb->removeMask(*mk); - m_pDb->addMask(u,mk); + m_pDb->addMask(u, mk); } m_pAvatarSelector->commit(); @@ -356,7 +366,7 @@ void RegistrationWizard::accept() if(!m_pAvatar->isNull()) { QString szPath = m_pAvatar->path(); - u->setProperty("avatar",szPath); + u->setProperty("avatar", szPath); bSetAvatar = true; } @@ -373,8 +383,9 @@ void RegistrationWizard::accept() if(!m1.isEmpty()) { - u->setProperty("notify",m1); - if(!bLocalDb)g_pApp->restartNotifyLists(); + u->setProperty("notify", m1); + if(!bLocalDb) + g_pApp->restartNotifyLists(); } } @@ -383,18 +394,18 @@ void RegistrationWizard::accept() KviTalWizard::accept(); -// if(!m_bModal)delete this; -// hide(); -// g_pApp->collectGarbage(this); + // if(!m_bModal)delete this; + // hide(); + // g_pApp->collectGarbage(this); } - -void RegistrationWizard::showEvent(QShowEvent *e) +void RegistrationWizard::showEvent(QShowEvent * e) { - if(height() < 420)resize(width(),420); + if(height() < 420) + resize(width(), 420); QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen()); - move((rect.width() - width())/2,(rect.height() - height())/2); + move((rect.width() - width()) / 2, (rect.height() - height()) / 2); KviTalWizard::showEvent(e); } @@ -406,33 +417,33 @@ void RegistrationWizard::maskChanged(const QString &) if(tmp1.isEmpty()) { - setNextEnabled(m_pPage2,false); + setNextEnabled(m_pPage2, false); return; } if(tmp2.isEmpty()) { - setNextEnabled(m_pPage2,false); + setNextEnabled(m_pPage2, false); return; } if(tmp3.isEmpty()) { - setNextEnabled(m_pPage2,false); + setNextEnabled(m_pPage2, false); return; } - KviCString mask(KviCString::Format,"%s!%s@%s",tmp1.ptr(),tmp2.ptr(),tmp3.ptr()); + KviCString mask(KviCString::Format, "%s!%s@%s", tmp1.ptr(), tmp2.ptr(), tmp3.ptr()); //KviIrcMask m(mask.ptr()); - setNextEnabled(m_pPage2,mask!="*!*@*"); + setNextEnabled(m_pPage2, mask != "*!*@*"); } void RegistrationWizard::realNameChanged(const QString &) { QString tmp = m_pEditRealName->text(); - setNextEnabled(m_pPage1,!(tmp.isEmpty() || tmp.isNull())); + setNextEnabled(m_pPage1, !(tmp.isEmpty() || tmp.isNull())); } void RegistrationWizard::notifyNickChanged(const QString &) @@ -446,13 +457,16 @@ void RegistrationWizard::notifyNickChanged(const QString &) if(tmp.hasData()) { bYes = true; - } else { + } + else + { tmp = m_pNotifyNickEdit2->text(); - if(tmp.hasData())bYes = true; + if(tmp.hasData()) + bYes = true; } } - setNextEnabled(m_pPage4,bYes); + setNextEnabled(m_pPage4, bYes); } void RegistrationWizard::notifyCheckToggled(bool) |
