From eb4950098fca394cf25215dfd187029bcd036ca4 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Sat, 14 Feb 2009 19:20:42 +0100 Subject: [PATCH] internal refactoring: ripping identity editor and identitory settingspage apart --- src/qtui/CMakeLists.txt | 1 + .../settingspages/identitiessettingspage.cpp | 362 +------ .../settingspages/identitiessettingspage.h | 53 +- .../settingspages/identitiessettingspage.ui | 892 +----------------- src/qtui/settingspages/identityeditwidget.cpp | 358 +++++++ src/qtui/settingspages/identityeditwidget.h | 112 +++ src/qtui/settingspages/identityeditwidget.ui | 788 ++++++++++++++++ src/qtui/settingspages/settingspages.inc | 6 +- 8 files changed, 1317 insertions(+), 1255 deletions(-) create mode 100644 src/qtui/settingspages/identityeditwidget.cpp create mode 100644 src/qtui/settingspages/identityeditwidget.h create mode 100644 src/qtui/settingspages/identityeditwidget.ui diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index de9db43d..3364c57d 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -168,6 +168,7 @@ qt4_wrap_ui(UI ${FORMPATH} ${SPFRM}) include_directories(${CMAKE_SOURCE_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/client ${CMAKE_SOURCE_DIR}/src/qtui + ${CMAKE_SOURCE_DIR}/src/qtui/settingspages ${CMAKE_SOURCE_DIR}/src/uisupport ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/qtui/settingspages/identitiessettingspage.cpp b/src/qtui/settingspages/identitiessettingspage.cpp index de7a02b4..ca965aac 100644 --- a/src/qtui/settingspages/identitiessettingspage.cpp +++ b/src/qtui/settingspages/identitiessettingspage.cpp @@ -20,10 +20,6 @@ #include "identitiessettingspage.h" -#include -#include -#include -#include #include #include @@ -35,70 +31,25 @@ IdentitiesSettingsPage::IdentitiesSettingsPage(QWidget *parent) : SettingsPage(tr("General"), tr("Identities"), parent), _editSsl(false) { - ui.setupUi(this); ui.renameIdentity->setIcon(BarIcon("edit-rename")); ui.addIdentity->setIcon(BarIcon("list-add-user")); ui.deleteIdentity->setIcon(BarIcon("list-remove-user")); - ui.addNick->setIcon(SmallIcon("list-add")); - ui.deleteNick->setIcon(SmallIcon("edit-delete")); - ui.renameNick->setIcon(SmallIcon("edit-rename")); - ui.nickUp->setIcon(SmallIcon("go-up")); - ui.nickDown->setIcon(SmallIcon("go-down")); coreConnectionStateChanged(Client::isConnected()); // need a core connection! - setWidgetStates(); connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool))); + connect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(clientIdentityCreated(IdentityId))); connect(Client::instance(), SIGNAL(identityRemoved(IdentityId)), this, SLOT(clientIdentityRemoved(IdentityId))); - currentId = 0; - - // We need to know whenever the state of input widgets changes... - //connect(ui.identityList, SIGNAL(editTextChanged(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.realName, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.nicknameList, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(widgetHasChanged())); - connect(ui.awayNick, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.awayNickEnabled, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.awayReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.awayReasonEnabled, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.autoAwayEnabled, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.autoAwayTime, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); - connect(ui.autoAwayReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.autoAwayReasonEnabled, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.detachAwayEnabled, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.detachAwayReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.detachAwayReasonEnabled, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - connect(ui.ident, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.kickReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.partReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - connect(ui.quitReason, SIGNAL(textEdited(const QString &)), this, SLOT(widgetHasChanged())); - - connect(ui.nicknameList, SIGNAL(itemSelectionChanged()), this, SLOT(setWidgetStates())); - - // we would need this if we enabled drag and drop in the nicklist... - //connect(ui.nicknameList, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(setWidgetStates())); - //connect(ui.nicknameList->model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(nicklistHasChanged())); - + connect(ui.identityEditor, SIGNAL(widgetHasChanged()), this, SLOT(widgetHasChanged())); #ifdef HAVE_SSL - ui.sslKeyGroupBox->setAcceptDrops(true); - ui.sslKeyGroupBox->installEventFilter(this); - ui.sslCertGroupBox->setAcceptDrops(true); - ui.sslCertGroupBox->installEventFilter(this); + connect(ui.identityEditor, SIGNAL(requestEditSsl()), this, SLOT(continueUnsecured())); #endif -} -void IdentitiesSettingsPage::setWidgetStates() { - if(ui.nicknameList->selectedItems().count()) { - ui.renameNick->setEnabled(true); - ui.nickUp->setEnabled(ui.nicknameList->row(ui.nicknameList->selectedItems()[0]) > 0); - ui.nickDown->setEnabled(ui.nicknameList->row(ui.nicknameList->selectedItems()[0]) < ui.nicknameList->count()-1); - } else { - ui.renameNick->setDisabled(true); - ui.nickUp->setDisabled(true); - ui.nickDown->setDisabled(true); - } - ui.deleteNick->setEnabled(ui.nicknameList->count() > 1); + currentId = 0; + + //connect(ui.identityList, SIGNAL(editTextChanged(const QString &)), this, SLOT(widgetHasChanged())); } void IdentitiesSettingsPage::coreConnectionStateChanged(bool connected) { @@ -106,14 +57,14 @@ void IdentitiesSettingsPage::coreConnectionStateChanged(bool connected) { if(connected) { #ifdef HAVE_SSL if(Client::signalProxy()->isSecure()) { - ui.keyAndCertSettings->setCurrentIndex(2); + ui.identityEditor->setSslState(IdentityEditWidget::AllowSsl); _editSsl = true; } else { - ui.keyAndCertSettings->setCurrentIndex(1); + ui.identityEditor->setSslState(IdentityEditWidget::UnsecureSsl); _editSsl = false; } #else - ui.keyAndCertSettings->setCurrentIndex(0); + ui.identityEditor->setSslState(IdentityEditWidget::NoSsl); #endif load(); } else { @@ -122,6 +73,19 @@ void IdentitiesSettingsPage::coreConnectionStateChanged(bool connected) { } } +#ifdef HAVE_SSL +void IdentitiesSettingsPage::continueUnsecured() { + _editSsl = true; + + QHash::iterator idIter; + for(idIter = identities.begin(); idIter != identities.end(); idIter++) { + idIter.value()->enableEditSsl(); + } + + ui.identityEditor->setSslState(IdentityEditWidget::AllowSsl); +} +#endif + void IdentitiesSettingsPage::save() { setEnabled(false); QList toCreate, toUpdate; @@ -184,7 +148,7 @@ bool IdentitiesSettingsPage::testHasChanged() { if(currentId != 0) { changedIdentities.removeAll(currentId); CertIdentity temp(currentId, this); - saveToIdentity(&temp); + ui.identityEditor->saveToIdentity(&temp); temp.setIdentityName(identities[currentId]->identityName()); if(temp != *Client::identity(currentId) || temp.isDirty()) changedIdentities.append(currentId); @@ -194,7 +158,7 @@ bool IdentitiesSettingsPage::testHasChanged() { } bool IdentitiesSettingsPage::aboutToSave() { - saveToIdentity(identities[currentId]); + ui.identityEditor->saveToIdentity(identities[currentId]); QList errors; foreach(Identity *id, identities.values()) { if(id->identityName().isEmpty()) errors.append(1); @@ -244,7 +208,7 @@ void IdentitiesSettingsPage::clientIdentityUpdated() { identity->copyFrom(*clientIdentity); if(identity->id() == currentId) - displayIdentity(identity, true); + ui.identityEditor->displayIdentity(identity); } void IdentitiesSettingsPage::clientIdentityRemoved(IdentityId id) { @@ -292,80 +256,25 @@ void IdentitiesSettingsPage::removeIdentity(Identity *id) { } void IdentitiesSettingsPage::on_identityList_currentIndexChanged(int index) { + CertIdentity *previousIdentity = 0; + if(currentId != 0 && identities.contains(currentId)) + previousIdentity = identities[currentId]; + if(index < 0) { //ui.identityList->setEditable(false); - displayIdentity(0); + ui.identityEditor->displayIdentity(0, previousIdentity); + currentId = 0; } else { IdentityId id = ui.identityList->itemData(index).toInt(); - if(identities.contains(id)) displayIdentity(identities[id]); + if(identities.contains(id)) { + ui.identityEditor->displayIdentity(identities[id], previousIdentity); + currentId = id; + } ui.deleteIdentity->setEnabled(id != 1); // default identity cannot be deleted ui.renameIdentity->setEnabled(id != 1); // ...or renamed } } -void IdentitiesSettingsPage::displayIdentity(CertIdentity *id, bool dontsave) { - if(currentId != 0 && !dontsave && identities.contains(currentId)) { - saveToIdentity(identities[currentId]); - } - if(id) { - currentId = id->id(); - ui.realName->setText(id->realName()); - ui.nicknameList->clear(); - ui.nicknameList->addItems(id->nicks()); - //for(int i = 0; i < ui.nicknameList->count(); i++) { - // ui.nicknameList->item(i)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled); - //} - if(ui.nicknameList->count()) ui.nicknameList->setCurrentRow(0); - ui.awayNick->setText(id->awayNick()); - ui.awayNickEnabled->setChecked(id->awayNickEnabled()); - ui.awayReason->setText(id->awayReason()); - ui.awayReasonEnabled->setChecked(id->awayReasonEnabled()); - ui.autoAwayEnabled->setChecked(id->autoAwayEnabled()); - ui.autoAwayTime->setValue(id->autoAwayTime()); - ui.autoAwayReason->setText(id->autoAwayReason()); - ui.autoAwayReasonEnabled->setChecked(id->autoAwayReasonEnabled()); - ui.detachAwayEnabled->setChecked(id->detachAwayEnabled()); - ui.detachAwayReason->setText(id->detachAwayReason()); - ui.detachAwayReasonEnabled->setChecked(id->detachAwayReasonEnabled()); - ui.ident->setText(id->ident()); - ui.kickReason->setText(id->kickReason()); - ui.partReason->setText(id->partReason()); - ui.quitReason->setText(id->quitReason()); -#ifdef HAVE_SSL - showKeyState(id->sslKey()); - showCertState(id->sslCert()); -#endif - } -} - -void IdentitiesSettingsPage::saveToIdentity(CertIdentity *id) { - id->setRealName(ui.realName->text()); - QStringList nicks; - for(int i = 0; i < ui.nicknameList->count(); i++) { - nicks << ui.nicknameList->item(i)->text(); - } - id->setNicks(nicks); - id->setAwayNick(ui.awayNick->text()); - id->setAwayNickEnabled(ui.awayNickEnabled->isChecked()); - id->setAwayReason(ui.awayReason->text()); - id->setAwayReasonEnabled(ui.awayReasonEnabled->isChecked()); - id->setAutoAwayEnabled(ui.autoAwayEnabled->isChecked()); - id->setAutoAwayTime(ui.autoAwayTime->value()); - id->setAutoAwayReason(ui.autoAwayReason->text()); - id->setAutoAwayReasonEnabled(ui.autoAwayReasonEnabled->isChecked()); - id->setDetachAwayEnabled(ui.detachAwayEnabled->isChecked()); - id->setDetachAwayReason(ui.detachAwayReason->text()); - id->setDetachAwayReasonEnabled(ui.detachAwayReasonEnabled->isChecked()); - id->setIdent(ui.ident->text()); - id->setKickReason(ui.kickReason->text()); - id->setPartReason(ui.partReason->text()); - id->setQuitReason(ui.quitReason->text()); -#ifdef HAVE_SSL - id->setSslKey(QSslKey(ui.keyTypeLabel->property("sslKey").toByteArray(), (QSsl::KeyAlgorithm)(ui.keyTypeLabel->property("sslKeyType").toInt()))); - id->setSslCert(QSslCertificate(ui.certOrgLabel->property("sslCert").toByteArray())); -#endif -} - void IdentitiesSettingsPage::on_addIdentity_clicked() { CreateIdentityDlg dlg(ui.identityList->model(), this); if(dlg.exec() == QDialog::Accepted) { @@ -415,207 +324,6 @@ void IdentitiesSettingsPage::on_renameIdentity_clicked() { } } -void IdentitiesSettingsPage::on_addNick_clicked() { - QStringList existing; - for(int i = 0; i < ui.nicknameList->count(); i++) existing << ui.nicknameList->item(i)->text(); - NickEditDlg dlg(QString(), existing, this); - if(dlg.exec() == QDialog::Accepted) { - ui.nicknameList->addItem(dlg.nick()); - ui.nicknameList->setCurrentRow(ui.nicknameList->count()-1); - setWidgetStates(); - widgetHasChanged(); - } -} - -void IdentitiesSettingsPage::on_deleteNick_clicked() { - // no confirmation, since a nickname is really nothing hard to recreate - if(ui.nicknameList->selectedItems().count()) { - delete ui.nicknameList->takeItem(ui.nicknameList->row(ui.nicknameList->selectedItems()[0])); - ui.nicknameList->setCurrentRow(qMin(ui.nicknameList->currentRow()+1, ui.nicknameList->count()-1)); - setWidgetStates(); - widgetHasChanged(); - } -} - -void IdentitiesSettingsPage::on_renameNick_clicked() { - if(!ui.nicknameList->selectedItems().count()) return; - QString old = ui.nicknameList->selectedItems()[0]->text(); - QStringList existing; - for(int i = 0; i < ui.nicknameList->count(); i++) existing << ui.nicknameList->item(i)->text(); - NickEditDlg dlg(old, existing, this); - if(dlg.exec() == QDialog::Accepted) { - ui.nicknameList->selectedItems()[0]->setText(dlg.nick()); - } - -} - -void IdentitiesSettingsPage::on_nickUp_clicked() { - if(!ui.nicknameList->selectedItems().count()) return; - int row = ui.nicknameList->row(ui.nicknameList->selectedItems()[0]); - if(row > 0) { - ui.nicknameList->insertItem(row-1, ui.nicknameList->takeItem(row)); - ui.nicknameList->setCurrentRow(row-1); - setWidgetStates(); - widgetHasChanged(); - } -} - -void IdentitiesSettingsPage::on_nickDown_clicked() { - if(!ui.nicknameList->selectedItems().count()) return; - int row = ui.nicknameList->row(ui.nicknameList->selectedItems()[0]); - if(row < ui.nicknameList->count()-1) { - ui.nicknameList->insertItem(row+1, ui.nicknameList->takeItem(row)); - ui.nicknameList->setCurrentRow(row+1); - setWidgetStates(); - widgetHasChanged(); - } -} - -#ifdef HAVE_SSL -void IdentitiesSettingsPage::on_continueUnsecured_clicked() { - _editSsl = true; - - QHash::iterator idIter; - for(idIter = identities.begin(); idIter != identities.end(); idIter++) { - idIter.value()->enableEditSsl(); - } - - ui.keyAndCertSettings->setCurrentIndex(2); -} - -bool IdentitiesSettingsPage::eventFilter(QObject *watched, QEvent *event) { - bool isCert = (watched == ui.sslCertGroupBox); - switch(event->type()) { - case QEvent::DragEnter: - sslDragEnterEvent(static_cast(event)); - return true; - case QEvent::Drop: - sslDropEvent(static_cast(event), isCert); - return true; - default: - return false; - } -} - -void IdentitiesSettingsPage::sslDragEnterEvent(QDragEnterEvent *event) { - if(event->mimeData()->hasFormat("text/uri-list") || event->mimeData()->hasFormat("text/uri")) { - event->setDropAction(Qt::CopyAction); - event->accept(); - } -} - -void IdentitiesSettingsPage::sslDropEvent(QDropEvent *event, bool isCert) { - QByteArray rawUris; - if(event->mimeData()->hasFormat("text/uri-list")) - rawUris = event->mimeData()->data("text/uri-list"); - else - rawUris = event->mimeData()->data("text/uri"); - - QTextStream uriStream(rawUris); - QString filename = QUrl(uriStream.readLine()).toLocalFile(); - - if(isCert) { - QSslCertificate cert = certByFilename(filename); - if(cert.isValid()) - showCertState(cert); - } else { - QSslKey key = keyByFilename(filename); - if(!key.isNull()) - showKeyState(key); - } - event->accept(); - widgetHasChanged(); -} - -void IdentitiesSettingsPage::on_clearOrLoadKeyButton_clicked() { - QSslKey key; - - if(ui.keyTypeLabel->property("sslKey").toByteArray().isEmpty()) - key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); - - showKeyState(key); - widgetHasChanged(); -} - -QSslKey IdentitiesSettingsPage::keyByFilename(const QString &filename) { - QSslKey key; - - QFile keyFile(filename); - keyFile.open(QIODevice::ReadOnly); - QByteArray keyRaw = keyFile.read(2 << 20); - keyFile.close(); - - for(int i = 0; i < 2; i++) { - for(int j = 0; j < 2; j++) { - key = QSslKey(keyRaw, (QSsl::KeyAlgorithm)j, (QSsl::EncodingFormat)i); - if(!key.isNull()) - goto returnKey; - } - } - returnKey: - return key; -} - -void IdentitiesSettingsPage::showKeyState(const QSslKey &key) { - if(key.isNull()) { - ui.keyTypeLabel->setText(tr("No Key loaded")); - ui.clearOrLoadKeyButton->setText(tr("Load")); - } else { - switch(key.algorithm()) { - case QSsl::Rsa: - ui.keyTypeLabel->setText(tr("RSA")); - break; - case QSsl::Dsa: - ui.keyTypeLabel->setText(tr("DSA")); - break; - default: - ui.keyTypeLabel->setText(tr("No Key loaded")); - } - ui.clearOrLoadKeyButton->setText(tr("Clear")); - } - ui.keyTypeLabel->setProperty("sslKey", key.toPem()); - ui.keyTypeLabel->setProperty("sslKeyType", (int)key.algorithm()); -} - -void IdentitiesSettingsPage::on_clearOrLoadCertButton_clicked() { - QSslCertificate cert; - - if(ui.certOrgLabel->property("sslCert").toByteArray().isEmpty()) - cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); - - showCertState(cert); - widgetHasChanged(); -} - -QSslCertificate IdentitiesSettingsPage::certByFilename(const QString &filename) { - QSslCertificate cert; - QFile certFile(filename); - certFile.open(QIODevice::ReadOnly); - QByteArray certRaw = certFile.read(2 << 20); - certFile.close(); - - for(int i = 0; i < 2; i++) { - cert = QSslCertificate(certRaw, (QSsl::EncodingFormat)i); - if(cert.isValid()) - break; - } - return cert; -} - -void IdentitiesSettingsPage::showCertState(const QSslCertificate &cert) { - if(!cert.isValid()) { - ui.certOrgLabel->setText(tr("No Certificate loaded")); - ui.certCNameLabel->setText(tr("No Certificate loaded")); - ui.clearOrLoadCertButton->setText(tr("Load")); - } else { - ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization)); - ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName)); - ui.clearOrLoadCertButton->setText(tr("Clear")); - } - ui.certOrgLabel->setProperty("sslCert", cert.toPem()); - } -#endif //HAVE_SSL - /*****************************************************************************************/ CreateIdentityDlg::CreateIdentityDlg(QAbstractItemModel *model, QWidget *parent) diff --git a/src/qtui/settingspages/identitiessettingspage.h b/src/qtui/settingspages/identitiessettingspage.h index 7c97916e..a6d21b22 100644 --- a/src/qtui/settingspages/identitiessettingspage.h +++ b/src/qtui/settingspages/identitiessettingspage.h @@ -24,15 +24,11 @@ #include "clientidentity.h" #include "settingspage.h" +#include "identityeditwidget.h" + #include "ui_identitiessettingspage.h" #include "ui_createidentitydlg.h" #include "ui_saveidentitiesdlg.h" -#include "ui_nickeditdlg.h" - -#ifdef HAVE_SSL -#include -#include -#endif class QAbstractItemModel; @@ -48,11 +44,6 @@ public slots: void save(); void load(); -#ifdef HAVE_SSL -protected: - virtual bool eventFilter(QObject *watched, QEvent *event); -#endif - private slots: void coreConnectionStateChanged(bool); void clientIdentityCreated(IdentityId); @@ -65,24 +56,10 @@ private slots: void on_deleteIdentity_clicked(); void on_renameIdentity_clicked(); - void on_addNick_clicked(); - void on_deleteNick_clicked(); - void on_renameNick_clicked(); - void on_nickUp_clicked(); - void on_nickDown_clicked(); - #ifdef HAVE_SSL - void on_continueUnsecured_clicked(); - void on_clearOrLoadKeyButton_clicked(); - void on_clearOrLoadCertButton_clicked(); + void continueUnsecured(); #endif void widgetHasChanged(); - void setWidgetStates(); - -#ifdef HAVE_SSL - void sslDragEnterEvent(QDragEnterEvent *event); - void sslDropEvent(QDropEvent *event, bool isCert); -#endif private: Ui::IdentitiesSettingsPage ui; @@ -98,8 +75,6 @@ private: void insertIdentity(CertIdentity *identity); void removeIdentity(Identity *identity); void renameIdentity(IdentityId id, const QString &newName); - void displayIdentity(CertIdentity *, bool dontsave = false); - void saveToIdentity(CertIdentity *); #ifdef HAVE_SSL QSslKey keyByFilename(const QString &filename); @@ -111,6 +86,9 @@ private: bool testHasChanged(); }; +// ============================== +// Various Dialogs +// ============================== class CreateIdentityDlg : public QDialog { Q_OBJECT @@ -127,6 +105,8 @@ private: Ui::CreateIdentityDlg ui; }; + + class SaveIdentitiesDlg : public QDialog { Q_OBJECT @@ -142,23 +122,6 @@ private: int numevents, rcvevents; }; -class NickEditDlg : public QDialog { - Q_OBJECT - -public: - NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0); - - QString nick() const; -private slots: - void on_nickEdit_textChanged(const QString &); - -private: - Ui::NickEditDlg ui; - - QString oldNick; - QStringList existing; - -}; #endif diff --git a/src/qtui/settingspages/identitiessettingspage.ui b/src/qtui/settingspages/identitiessettingspage.ui index f4edd338..ed9c5b37 100644 --- a/src/qtui/settingspages/identitiessettingspage.ui +++ b/src/qtui/settingspages/identitiessettingspage.ui @@ -5,8 +5,8 @@ 0 0 - 430 - 492 + 256 + 183 @@ -91,892 +91,24 @@ - - - 0 - - - - - 0 - 0 - 400 - 399 - - - - General - - - - - - - - Real Name: - - - - - - - The "Real Name" is shown in /whois. - - - - - - - - - Nicknames - - - - - - - 1 - 0 - - - - true - - - false - - - QAbstractItemView::NoDragDrop - - - QAbstractItemView::SelectRows - - - - - - - - - - 0 - 0 - - - - Add Nickname - - - &Add... - - - - :/16x16/actions/oxygen/16x16/actions/list-add.png:/16x16/actions/oxygen/16x16/actions/list-add.png - - - - 16 - 16 - - - - - - - - - 0 - 0 - - - - Remove Nickname - - - Remove - - - - :/16x16/actions/oxygen/16x16/actions/edit-delete.png:/16x16/actions/oxygen/16x16/actions/edit-delete.png - - - - - - - - 0 - 0 - - - - Rename Identity - - - Re&name... - - - - :/16x16/actions/oxygen/16x16/actions/edit-rename.png:/16x16/actions/oxygen/16x16/actions/edit-rename.png - - - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - - - - Move upwards in list - - - ... - - - - :/16x16/actions/oxygen/16x16/actions/go-up.png:/16x16/actions/oxygen/16x16/actions/go-up.png - - - - - - - Move downwards in list - - - ... - - - - :/16x16/actions/oxygen/16x16/actions/go-down.png:/16x16/actions/oxygen/16x16/actions/go-down.png - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - - - - - - Qt::Vertical - - - - 124 - 76 - - - - - - - - - - - - - - - 0 - 0 - 400 - 399 - - - - A&way - - - - - - Default Away Settings - - - - - - - - false - - - Nick to be used when being away - - - - - - - Default away reason - - - Away Reason: - - - - - - - false - - - Default away reason - - - - - - - false - - - Nick to be used when being away - - - Away Nick: - - - - - - - - - - - - Set away when all clients have detached from the core - - - Away On Detach - - - true - - - false - - - - - - - - Override default away reason for auto-away on detach - - - Away Reason: - - - - - - - false - - - Override default away reason for auto-away on detach - - - - - - - - - - - - false - - - Not implemented yet - - - Away On Idle - - - true - - - false - - - - - - - - Set away after - - - - - - - - - - minutes of being idle - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Away Reason: - - - - - - - false - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - 0 - 400 - 399 - - - - Advanced - - - - - - - - Ident: - - - - - - - The "ident" is part of your hostmask and, together with your host, uniquely identifies you within the IRC network. - - - - - - - - - Messages - - - - - - - - Part Reason: - - - - - - - - - - - - - Quit Reason: - - - - - - - - - - Kick Reason: - - - - - - - - - - - - - - - 0 - - - 0 - - - - - 0 - - - - - - - - - - - You need an SSL Capable Client to edit your Cores SSL Key and Certificate - - - Qt::AlignCenter - - - true - - - - - - - - - - - - 0 - - - - - - - - - - - Warning: you are not connected with a secured connection to the Quassel Core! -Proceeding will cause an unencrypted transfer of your SSL Key and SSL Certificate! - - - Qt::AlignCenter - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Continue - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - 0 - 0 - 360 - 173 - - - - - 0 - - - 0 - - - - - - - - Use SSL Key - - - false - - - false - - - - - - - - Key Type: - - - - - - - No Key loaded - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Load - - - - - - - - - - - - Use SSL Certificate - - - - 0 - - - - - 0 - - - - - 8 - - - - - Organisation: - - - - - - - No Certificate loaded - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 8 - - - - - CommonName: - - - - - - - No Certificate loaded - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - Load - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - + + + + IdentityEditWidget + QWidget +
identityeditwidget.h
+ 1 +
+
identityList renameIdentity addIdentity deleteIdentity - tabWidget - realName - nicknameList - addNick - deleteNick - renameNick - nickUp - nickDown - awayNick - awayReasonEnabled - awayReason - awayNickEnabled - autoAwayEnabled - autoAwayTime - autoAwayReasonEnabled - autoAwayReason - ident - kickReason - partReason - quitReason - - - awayNickEnabled - toggled(bool) - awayNick - setEnabled(bool) - - - 71 - 128 - - - 314 - 129 - - - - - awayReasonEnabled - toggled(bool) - awayReason - setEnabled(bool) - - - 81 - 156 - - - 306 - 157 - - - - - autoAwayReasonEnabled - toggled(bool) - autoAwayReason - setEnabled(bool) - - - 157 - 382 - - - 454 - 382 - - - - - detachAwayReasonEnabled - toggled(bool) - detachAwayReason - setEnabled(bool) - - - 64 - 256 - - - 343 - 256 - - - - + diff --git a/src/qtui/settingspages/identityeditwidget.cpp b/src/qtui/settingspages/identityeditwidget.cpp new file mode 100644 index 00000000..b652c7bb --- /dev/null +++ b/src/qtui/settingspages/identityeditwidget.cpp @@ -0,0 +1,358 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "identityeditwidget.h" + +#include +#include +#include +#include +#include + +#include "iconloader.h" + +IdentityEditWidget::IdentityEditWidget(QWidget *parent) + : QWidget(parent) +{ + ui.setupUi(this); + + ui.addNick->setIcon(SmallIcon("list-add")); + ui.deleteNick->setIcon(SmallIcon("edit-delete")); + ui.renameNick->setIcon(SmallIcon("edit-rename")); + ui.nickUp->setIcon(SmallIcon("go-up")); + ui.nickDown->setIcon(SmallIcon("go-down")); + + // We need to know whenever the state of input widgets changes... + connect(ui.realName, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.nicknameList, SIGNAL(itemChanged(QListWidgetItem *)), this, SIGNAL(widgetHasChanged())); + connect(ui.awayNick, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.awayNickEnabled, SIGNAL(clicked(bool)), this, SIGNAL(widgetHasChanged())); + connect(ui.awayReason, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.awayReasonEnabled, SIGNAL(clicked(bool)), this, SIGNAL(widgetHasChanged())); + connect(ui.autoAwayEnabled, SIGNAL(clicked(bool)), this, SIGNAL(widgetHasChanged())); + connect(ui.autoAwayTime, SIGNAL(valueChanged(int)), this, SIGNAL(widgetHasChanged())); + connect(ui.autoAwayReason, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.autoAwayReasonEnabled, SIGNAL(clicked(bool)), this, SIGNAL(widgetHasChanged())); + connect(ui.detachAwayEnabled, SIGNAL(clicked(bool)), this, SIGNAL(widgetHasChanged())); + connect(ui.detachAwayReason, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.detachAwayReasonEnabled, SIGNAL(clicked(bool)), this, SIGNAL(widgetHasChanged())); + connect(ui.ident, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.kickReason, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.partReason, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + connect(ui.quitReason, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged())); + + setWidgetStates(); + connect(ui.nicknameList, SIGNAL(itemSelectionChanged()), this, SLOT(setWidgetStates())); + + connect(ui.continueUnsecured, SIGNAL(clicked()), this, SIGNAL(requestEditSsl())); + + // we would need this if we enabled drag and drop in the nicklist... + //connect(ui.nicknameList, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(setWidgetStates())); + //connect(ui.nicknameList->model(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(nicklistHasChanged())); + +#ifdef HAVE_SSL + ui.sslKeyGroupBox->setAcceptDrops(true); + ui.sslKeyGroupBox->installEventFilter(this); + ui.sslCertGroupBox->setAcceptDrops(true); + ui.sslCertGroupBox->installEventFilter(this); +#endif +} + +void IdentityEditWidget::setWidgetStates() { + if(ui.nicknameList->selectedItems().count()) { + ui.renameNick->setEnabled(true); + ui.nickUp->setEnabled(ui.nicknameList->row(ui.nicknameList->selectedItems()[0]) > 0); + ui.nickDown->setEnabled(ui.nicknameList->row(ui.nicknameList->selectedItems()[0]) < ui.nicknameList->count()-1); + } else { + ui.renameNick->setDisabled(true); + ui.nickUp->setDisabled(true); + ui.nickDown->setDisabled(true); + } + ui.deleteNick->setEnabled(ui.nicknameList->count() > 1); +} + +void IdentityEditWidget::displayIdentity(CertIdentity *id, CertIdentity *saveId) { + if(saveId) { + saveToIdentity(saveId); + } + + if(!id) + return; + + ui.realName->setText(id->realName()); + ui.nicknameList->clear(); + ui.nicknameList->addItems(id->nicks()); + //for(int i = 0; i < ui.nicknameList->count(); i++) { + // ui.nicknameList->item(i)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled); + //} + if(ui.nicknameList->count()) ui.nicknameList->setCurrentRow(0); + ui.awayNick->setText(id->awayNick()); + ui.awayNickEnabled->setChecked(id->awayNickEnabled()); + ui.awayReason->setText(id->awayReason()); + ui.awayReasonEnabled->setChecked(id->awayReasonEnabled()); + ui.autoAwayEnabled->setChecked(id->autoAwayEnabled()); + ui.autoAwayTime->setValue(id->autoAwayTime()); + ui.autoAwayReason->setText(id->autoAwayReason()); + ui.autoAwayReasonEnabled->setChecked(id->autoAwayReasonEnabled()); + ui.detachAwayEnabled->setChecked(id->detachAwayEnabled()); + ui.detachAwayReason->setText(id->detachAwayReason()); + ui.detachAwayReasonEnabled->setChecked(id->detachAwayReasonEnabled()); + ui.ident->setText(id->ident()); + ui.kickReason->setText(id->kickReason()); + ui.partReason->setText(id->partReason()); + ui.quitReason->setText(id->quitReason()); +#ifdef HAVE_SSL + showKeyState(id->sslKey()); + showCertState(id->sslCert()); +#endif + +} + +void IdentityEditWidget::saveToIdentity(CertIdentity *id) { + id->setRealName(ui.realName->text()); + QStringList nicks; + for(int i = 0; i < ui.nicknameList->count(); i++) { + nicks << ui.nicknameList->item(i)->text(); + } + id->setNicks(nicks); + id->setAwayNick(ui.awayNick->text()); + id->setAwayNickEnabled(ui.awayNickEnabled->isChecked()); + id->setAwayReason(ui.awayReason->text()); + id->setAwayReasonEnabled(ui.awayReasonEnabled->isChecked()); + id->setAutoAwayEnabled(ui.autoAwayEnabled->isChecked()); + id->setAutoAwayTime(ui.autoAwayTime->value()); + id->setAutoAwayReason(ui.autoAwayReason->text()); + id->setAutoAwayReasonEnabled(ui.autoAwayReasonEnabled->isChecked()); + id->setDetachAwayEnabled(ui.detachAwayEnabled->isChecked()); + id->setDetachAwayReason(ui.detachAwayReason->text()); + id->setDetachAwayReasonEnabled(ui.detachAwayReasonEnabled->isChecked()); + id->setIdent(ui.ident->text()); + id->setKickReason(ui.kickReason->text()); + id->setPartReason(ui.partReason->text()); + id->setQuitReason(ui.quitReason->text()); +#ifdef HAVE_SSL + id->setSslKey(QSslKey(ui.keyTypeLabel->property("sslKey").toByteArray(), (QSsl::KeyAlgorithm)(ui.keyTypeLabel->property("sslKeyType").toInt()))); + id->setSslCert(QSslCertificate(ui.certOrgLabel->property("sslCert").toByteArray())); +#endif +} + +void IdentityEditWidget::on_addNick_clicked() { + QStringList existing; + for(int i = 0; i < ui.nicknameList->count(); i++) existing << ui.nicknameList->item(i)->text(); + NickEditDlg dlg(QString(), existing, this); + if(dlg.exec() == QDialog::Accepted) { + ui.nicknameList->addItem(dlg.nick()); + ui.nicknameList->setCurrentRow(ui.nicknameList->count()-1); + setWidgetStates(); + emit widgetHasChanged(); + } +} + +void IdentityEditWidget::on_deleteNick_clicked() { + // no confirmation, since a nickname is really nothing hard to recreate + if(ui.nicknameList->selectedItems().count()) { + delete ui.nicknameList->takeItem(ui.nicknameList->row(ui.nicknameList->selectedItems()[0])); + ui.nicknameList->setCurrentRow(qMin(ui.nicknameList->currentRow()+1, ui.nicknameList->count()-1)); + setWidgetStates(); + emit widgetHasChanged(); + } +} + +void IdentityEditWidget::on_renameNick_clicked() { + if(!ui.nicknameList->selectedItems().count()) return; + QString old = ui.nicknameList->selectedItems()[0]->text(); + QStringList existing; + for(int i = 0; i < ui.nicknameList->count(); i++) existing << ui.nicknameList->item(i)->text(); + NickEditDlg dlg(old, existing, this); + if(dlg.exec() == QDialog::Accepted) { + ui.nicknameList->selectedItems()[0]->setText(dlg.nick()); + } + +} + +void IdentityEditWidget::on_nickUp_clicked() { + if(!ui.nicknameList->selectedItems().count()) return; + int row = ui.nicknameList->row(ui.nicknameList->selectedItems()[0]); + if(row > 0) { + ui.nicknameList->insertItem(row-1, ui.nicknameList->takeItem(row)); + ui.nicknameList->setCurrentRow(row-1); + setWidgetStates(); + emit widgetHasChanged(); + } +} + +void IdentityEditWidget::on_nickDown_clicked() { + if(!ui.nicknameList->selectedItems().count()) return; + int row = ui.nicknameList->row(ui.nicknameList->selectedItems()[0]); + if(row < ui.nicknameList->count()-1) { + ui.nicknameList->insertItem(row+1, ui.nicknameList->takeItem(row)); + ui.nicknameList->setCurrentRow(row+1); + setWidgetStates(); + emit widgetHasChanged(); + } +} + +#ifdef HAVE_SSL +void IdentityEditWidget::setSslState(SslState state) { + switch(state) { + case NoSsl: + ui.keyAndCertSettings->setCurrentIndex(0); + break; + case UnsecureSsl: + ui.keyAndCertSettings->setCurrentIndex(1); + break; + case AllowSsl: + ui.keyAndCertSettings->setCurrentIndex(2); + break; + } +} + +bool IdentityEditWidget::eventFilter(QObject *watched, QEvent *event) { + bool isCert = (watched == ui.sslCertGroupBox); + switch(event->type()) { + case QEvent::DragEnter: + sslDragEnterEvent(static_cast(event)); + return true; + case QEvent::Drop: + sslDropEvent(static_cast(event), isCert); + return true; + default: + return false; + } +} + +void IdentityEditWidget::sslDragEnterEvent(QDragEnterEvent *event) { + if(event->mimeData()->hasFormat("text/uri-list") || event->mimeData()->hasFormat("text/uri")) { + event->setDropAction(Qt::CopyAction); + event->accept(); + } +} + +void IdentityEditWidget::sslDropEvent(QDropEvent *event, bool isCert) { + QByteArray rawUris; + if(event->mimeData()->hasFormat("text/uri-list")) + rawUris = event->mimeData()->data("text/uri-list"); + else + rawUris = event->mimeData()->data("text/uri"); + + QTextStream uriStream(rawUris); + QString filename = QUrl(uriStream.readLine()).toLocalFile(); + + if(isCert) { + QSslCertificate cert = certByFilename(filename); + if(cert.isValid()) + showCertState(cert); + } else { + QSslKey key = keyByFilename(filename); + if(!key.isNull()) + showKeyState(key); + } + event->accept(); + emit widgetHasChanged(); +} + +void IdentityEditWidget::on_clearOrLoadKeyButton_clicked() { + QSslKey key; + + if(ui.keyTypeLabel->property("sslKey").toByteArray().isEmpty()) + key = keyByFilename(QFileDialog::getOpenFileName(this, tr("Load a Key"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); + + showKeyState(key); + emit widgetHasChanged(); +} + +QSslKey IdentityEditWidget::keyByFilename(const QString &filename) { + QSslKey key; + + QFile keyFile(filename); + keyFile.open(QIODevice::ReadOnly); + QByteArray keyRaw = keyFile.read(2 << 20); + keyFile.close(); + + for(int i = 0; i < 2; i++) { + for(int j = 0; j < 2; j++) { + key = QSslKey(keyRaw, (QSsl::KeyAlgorithm)j, (QSsl::EncodingFormat)i); + if(!key.isNull()) + goto returnKey; + } + } + returnKey: + return key; +} + +void IdentityEditWidget::showKeyState(const QSslKey &key) { + if(key.isNull()) { + ui.keyTypeLabel->setText(tr("No Key loaded")); + ui.clearOrLoadKeyButton->setText(tr("Load")); + } else { + switch(key.algorithm()) { + case QSsl::Rsa: + ui.keyTypeLabel->setText(tr("RSA")); + break; + case QSsl::Dsa: + ui.keyTypeLabel->setText(tr("DSA")); + break; + default: + ui.keyTypeLabel->setText(tr("No Key loaded")); + } + ui.clearOrLoadKeyButton->setText(tr("Clear")); + } + ui.keyTypeLabel->setProperty("sslKey", key.toPem()); + ui.keyTypeLabel->setProperty("sslKeyType", (int)key.algorithm()); +} + +void IdentityEditWidget::on_clearOrLoadCertButton_clicked() { + QSslCertificate cert; + + if(ui.certOrgLabel->property("sslCert").toByteArray().isEmpty()) + cert = certByFilename(QFileDialog::getOpenFileName(this, tr("Load a Certificate"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation))); + + showCertState(cert); + emit widgetHasChanged(); +} + +QSslCertificate IdentityEditWidget::certByFilename(const QString &filename) { + QSslCertificate cert; + QFile certFile(filename); + certFile.open(QIODevice::ReadOnly); + QByteArray certRaw = certFile.read(2 << 20); + certFile.close(); + + for(int i = 0; i < 2; i++) { + cert = QSslCertificate(certRaw, (QSsl::EncodingFormat)i); + if(cert.isValid()) + break; + } + return cert; +} + +void IdentityEditWidget::showCertState(const QSslCertificate &cert) { + if(!cert.isValid()) { + ui.certOrgLabel->setText(tr("No Certificate loaded")); + ui.certCNameLabel->setText(tr("No Certificate loaded")); + ui.clearOrLoadCertButton->setText(tr("Load")); + } else { + ui.certOrgLabel->setText(cert.subjectInfo(QSslCertificate::Organization)); + ui.certCNameLabel->setText(cert.subjectInfo(QSslCertificate::CommonName)); + ui.clearOrLoadCertButton->setText(tr("Clear")); + } + ui.certOrgLabel->setProperty("sslCert", cert.toPem()); + } +#endif //HAVE_SSL diff --git a/src/qtui/settingspages/identityeditwidget.h b/src/qtui/settingspages/identityeditwidget.h new file mode 100644 index 00000000..2879c9f4 --- /dev/null +++ b/src/qtui/settingspages/identityeditwidget.h @@ -0,0 +1,112 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef IDENTITYEDITWIDGET_H +#define IDENTITYEDITWIDGET_H + +#include "ui_identityeditwidget.h" +#include "ui_nickeditdlg.h" + +#ifdef HAVE_SSL +#include +#include +#endif + +#include "clientidentity.h" + +class IdentityEditWidget : public QWidget { + Q_OBJECT + +public: + IdentityEditWidget(QWidget *parent = 0); + + enum SslState { + NoSsl, + UnsecureSsl, + AllowSsl + }; + + void displayIdentity(CertIdentity *id, CertIdentity *saveId = 0); + void saveToIdentity(CertIdentity *id); + +public slots: + void setSslState(SslState state); + +protected: +#ifdef HAVE_SSL + virtual bool eventFilter(QObject *watched, QEvent *event); +#endif + +signals: + void requestEditSsl(); + void widgetHasChanged(); + +private slots: + void on_addNick_clicked(); + void on_deleteNick_clicked(); + void on_renameNick_clicked(); + void on_nickUp_clicked(); + void on_nickDown_clicked(); + +#ifdef HAVE_SSL + void on_clearOrLoadKeyButton_clicked(); + void on_clearOrLoadCertButton_clicked(); +#endif + void setWidgetStates(); + +#ifdef HAVE_SSL + void sslDragEnterEvent(QDragEnterEvent *event); + void sslDropEvent(QDropEvent *event, bool isCert); +#endif + +private: + Ui::IdentityEditWidget ui; + bool _editSsl; + +#ifdef HAVE_SSL + QSslKey keyByFilename(const QString &filename); + void showKeyState(const QSslKey &key); + QSslCertificate certByFilename(const QString &filename); + void showCertState(const QSslCertificate &cert); +#endif + + bool testHasChanged(); +}; + +class NickEditDlg : public QDialog { + Q_OBJECT + +public: + NickEditDlg(const QString &oldnick, const QStringList &existing = QStringList(), QWidget *parent = 0); + + QString nick() const; + +private slots: + void on_nickEdit_textChanged(const QString &); + +private: + Ui::NickEditDlg ui; + + QString oldNick; + QStringList existing; + +}; + +#endif //IDENTITYEDITWIDGET_H diff --git a/src/qtui/settingspages/identityeditwidget.ui b/src/qtui/settingspages/identityeditwidget.ui new file mode 100644 index 00000000..6f847e8e --- /dev/null +++ b/src/qtui/settingspages/identityeditwidget.ui @@ -0,0 +1,788 @@ + + IdentityEditWidget + + + + 0 + 0 + 393 + 422 + + + + + + + + 0 + + + 0 + + + + + 0 + + + + General + + + + + + + + Real Name: + + + + + + + The "Real Name" is shown in /whois. + + + + + + + + + Nicknames + + + + + + + 1 + 0 + + + + true + + + false + + + QAbstractItemView::NoDragDrop + + + QAbstractItemView::SelectRows + + + + + + + + + + 0 + 0 + + + + Add Nickname + + + &Add... + + + + :/16x16/actions/oxygen/16x16/actions/list-add.png:/16x16/actions/oxygen/16x16/actions/list-add.png + + + + 16 + 16 + + + + + + + + + 0 + 0 + + + + Remove Nickname + + + Remove + + + + :/16x16/actions/oxygen/16x16/actions/edit-delete.png:/16x16/actions/oxygen/16x16/actions/edit-delete.png + + + + + + + + 0 + 0 + + + + Rename Identity + + + Re&name... + + + + :/16x16/actions/oxygen/16x16/actions/edit-rename.png:/16x16/actions/oxygen/16x16/actions/edit-rename.png + + + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + Move upwards in list + + + ... + + + + :/16x16/actions/oxygen/16x16/actions/go-up.png:/16x16/actions/oxygen/16x16/actions/go-up.png + + + + + + + Move downwards in list + + + ... + + + + :/16x16/actions/oxygen/16x16/actions/go-down.png:/16x16/actions/oxygen/16x16/actions/go-down.png + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + + Qt::Vertical + + + + 124 + 76 + + + + + + + + + + + + + + A&way + + + + + + Default Away Settings + + + + + + + + false + + + Nick to be used when being away + + + + + + + Default away reason + + + Away Reason: + + + + + + + false + + + Default away reason + + + + + + + false + + + Nick to be used when being away + + + Away Nick: + + + + + + + + + + + + Set away when all clients have detached from the core + + + Away On Detach + + + true + + + false + + + + + + + + Override default away reason for auto-away on detach + + + Away Reason: + + + + + + + false + + + Override default away reason for auto-away on detach + + + + + + + + + + + + false + + + Not implemented yet + + + Away On Idle + + + true + + + false + + + + + + + + Set away after + + + + + + + + + + minutes of being idle + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Away Reason: + + + + + + + false + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Advanced + + + + + + + + Ident: + + + + + + + The "ident" is part of your hostmask and, together with your host, uniquely identifies you within the IRC network. + + + + + + + + + Messages + + + + + + + + Part Reason: + + + + + + + + + + + + + Quit Reason: + + + + + + + + + + Kick Reason: + + + + + + + + + + + + + + + 0 + + + 0 + + + + + 0 + + + + + + + + + + + You need an SSL Capable Client to edit your Cores SSL Key and Certificate + + + Qt::AlignCenter + + + true + + + + + + + + + + + + 0 + + + + + + + + + + + Warning: you are not connected with a secured connection to the Quassel Core! +Proceeding will cause an unencrypted transfer of your SSL Key and SSL Certificate! + + + Qt::AlignCenter + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Continue + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + 0 + + + 0 + + + + + + + + Use SSL Key + + + false + + + false + + + + + + + + Key Type: + + + + + + + No Key loaded + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Load + + + + + + + + + + + + Use SSL Certificate + + + + 0 + + + + + 0 + + + + + 8 + + + + + Organisation: + + + + + + + No Certificate loaded + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 8 + + + + + CommonName: + + + + + + + No Certificate loaded + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + Load + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + diff --git a/src/qtui/settingspages/settingspages.inc b/src/qtui/settingspages/settingspages.inc index 533d6cb4..f33ac22e 100644 --- a/src/qtui/settingspages/settingspages.inc +++ b/src/qtui/settingspages/settingspages.inc @@ -4,6 +4,6 @@ set(SETTINGSPAGES aliases appearance backlog bufferview color chatmonitor fonts general highlight identities networks) # Specify additional files (e.g. for subdialogs) here! -set(SP_SOURCES aliasesmodel.cpp notificationssettingspage.cpp) -set(SP_HEADERS aliasesmodel.h notificationssettingspage.h previewbufferview.h) -set(SP_FORMS buffervieweditdlg.ui createidentitydlg.ui saveidentitiesdlg.ui networkadddlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui) +set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp notificationssettingspage.cpp) +set(SP_HEADERS aliasesmodel.h identityeditwidget.h notificationssettingspage.h previewbufferview.h) +set(SP_FORMS buffervieweditdlg.ui createidentitydlg.ui identityeditwidget.ui saveidentitiesdlg.ui networkadddlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui) -- 2.20.1