From e99b30d015a55b8bf205ff98d768c5da9dcf6ec9 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Mon, 29 Oct 2012 11:02:03 +0000 Subject: [PATCH] Redesigned GenCertDialog for the usage in Profile Manager. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5738 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/GenCertDialog.cpp | 57 ++-- retroshare-gui/src/gui/GenCertDialog.h | 6 +- retroshare-gui/src/gui/GenCertDialog.ui | 300 ++++++++---------- .../src/gui/profile/ProfileManager.cpp | 3 +- .../src/gui/profile/ProfileManager.ui | 2 +- retroshare-gui/src/main.cpp | 2 +- 6 files changed, 173 insertions(+), 197 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index 514a95d82..8166a98f4 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -36,8 +36,8 @@ /** Default constructor */ -GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags) - : QDialog(parent, flags) +GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent, Qt::WFlags flags) + : QDialog(parent, flags), mOnlyGenerateIdentity(onlyGenerateIdentity) { /* Invoke Qt Designer generated QObject setup routine */ ui.setupUi(this); @@ -74,17 +74,19 @@ void GenCertDialog::init() std::list pgpIds; std::list::iterator it; bool foundGPGKeys = false; - if (RsInit::GetPGPLogins(pgpIds)) { + if (!mOnlyGenerateIdentity) { + if (RsInit::GetPGPLogins(pgpIds)) { for(it = pgpIds.begin(); it != pgpIds.end(); it++) { - QVariant userData(QString::fromStdString(*it)); - std::string name, email; - RsInit::GetPGPLoginDetails(*it, name, email); - std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl; - QString gid = QString::fromStdString(*it).right(8) ; - ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData); - foundGPGKeys = true; + QVariant userData(QString::fromStdString(*it)); + std::string name, email; + RsInit::GetPGPLoginDetails(*it, name, email); + std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl; + QString gid = QString::fromStdString(*it).right(8) ; + ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData); + foundGPGKeys = true; } + } } if (foundGPGKeys) { @@ -95,7 +97,7 @@ void GenCertDialog::init() ui.headerLabel->setText(tr("Create a new Location")); genNewGPGKey = false; } else { - ui.no_gpg_key_label->show(); + ui.no_gpg_key_label->setVisible(!mOnlyGenerateIdentity); ui.new_gpg_key_checkbox->setChecked(true); ui.new_gpg_key_checkbox->setEnabled(false); setWindowTitle(tr("Create new Identity")); @@ -103,6 +105,19 @@ void GenCertDialog::init() ui.headerLabel->setText(tr("Create a new Identity")); genNewGPGKey = true; } + + QString text = ui.headerLabel2->text() + "\n"; + + if (mOnlyGenerateIdentity) { + ui.new_gpg_key_checkbox->setChecked(true); + ui.new_gpg_key_checkbox->hide(); + ui.label->hide(); + text += tr("You can create a new identity with this form."); + } else { + text += tr("You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new one with this form."); + } + ui.headerLabel2->setText(text); + newGPGKeyGenUiSetup(); } @@ -118,11 +133,8 @@ void GenCertDialog::newGPGKeyGenUiSetup() { ui.password_input->show(); ui.genPGPuserlabel->hide(); ui.genPGPuser->hide(); - - if(ui.genPGPuser->count() == 0) - ui.exportIdentity_PB->hide() ; - -// ui.importIdentity_PB->hide() ; + ui.importIdentity_PB->hide() ; + ui.exportIdentity_PB->hide(); setWindowTitle(tr("Create new Identity")); ui.genButton->setText(tr("Generate new Identity")); ui.headerLabel->setText(tr("Create a new Identity")); @@ -136,8 +148,9 @@ void GenCertDialog::newGPGKeyGenUiSetup() { ui.password_input->hide(); ui.genPGPuserlabel->show(); ui.genPGPuser->show(); - ui.exportIdentity_PB->show() ; - ui.importIdentity_PB->show() ; + ui.importIdentity_PB->setVisible(!mOnlyGenerateIdentity); + ui.exportIdentity_PB->setVisible(!mOnlyGenerateIdentity); + ui.exportIdentity_PB->setEnabled(ui.genPGPuser->count() != 0); setWindowTitle(tr("Create new Location")); ui.genButton->setText(tr("Generate new Location")); ui.headerLabel->setText(tr("Create a new Location")); @@ -368,11 +381,3 @@ void GenCertDialog::loadCertificates() default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl; } } - -void GenCertDialog::hideButtons() -{ - ui.exportIdentity_PB->hide() ; - ui.importIdentity_PB->hide() ; - ui.new_gpg_key_checkbox->setChecked(true); - newGPGKeyGenUiSetup(); -} diff --git a/retroshare-gui/src/gui/GenCertDialog.h b/retroshare-gui/src/gui/GenCertDialog.h index 8bcd224f9..640816ebd 100644 --- a/retroshare-gui/src/gui/GenCertDialog.h +++ b/retroshare-gui/src/gui/GenCertDialog.h @@ -35,12 +35,9 @@ class GenCertDialog : public QDialog public: /** Default constructor */ - GenCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0); + GenCertDialog(bool onlyGenerateIdentity, QWidget *parent = 0, Qt::WFlags flags = 0); /** Default destructor */ - void hideButtons(); - - private slots: void genPerson(); //void loadPerson(); @@ -65,6 +62,7 @@ private: Ui::GenCertDialog ui; bool genNewGPGKey; + bool mOnlyGenerateIdentity; }; #endif diff --git a/retroshare-gui/src/gui/GenCertDialog.ui b/retroshare-gui/src/gui/GenCertDialog.ui index 1439dfb75..dd1ce786b 100644 --- a/retroshare-gui/src/gui/GenCertDialog.ui +++ b/retroshare-gui/src/gui/GenCertDialog.ui @@ -7,7 +7,7 @@ 0 0 664 - 524 + 474 @@ -50,21 +50,6 @@ - - - 0 - 0 - - - - - 0 - 20 - - - - - @@ -76,6 +61,135 @@ + + + + Your profile is associated to a GPG key. RetroShare currently ignores DSA keys. + + + + + + + Name + + + + + + + Enter here your nickname + + + + + + + Email + + + + + + + Be careful: this email will be visible to your friends and friends +of your friends. This information is required by GPG, but to stay +anonymous, you can use a fake email. + + + + + + + This Password is for GPG + + + Password + + + + + + + Put a strong password here. This password protects your GPG key. + + + + + + QLineEdit::Password + + + + + + + Location + + + + + + + + + + + 0 + 30 + + + + 1 + + + Put a meaningful location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same identity (gpg key). + + + false + + + true + + + + + + + + 16777215 + 26 + + + + Generate New Identity + + + + :/images/contact_new.png:/images/contact_new.png + + + + + + + Use identity + + + + + + + Qt::Vertical + + + + 1 + 1 + + + + @@ -145,148 +259,6 @@ - - - - - 16777215 - 32 - - - - - - - - - - - Use identity - - - - - - - Your profile is associated to a GPG key. RetroShare currently ignores DSA keys. - - - - - - - Name - - - - - - - Enter here your nickname - - - - - - - Email - - - - - - - Be careful: this email will be visible to your friends and friends -of your friends. This information is required by GPG, but to stay -anonymous, you can use a fake email. - - - - - - - This Password is for GPG - - - Password - - - - - - - Put a strong password here. This password protects your GPG key. - - - - - - QLineEdit::Password - - - - - - - Location - - - - - - - - - - - 0 - 30 - - - - 1 - - - Put a meaningful location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same identity (gpg key). - - - false - - - true - - - - - - - - 16777215 - 26 - - - - Generate New Identity - - - - :/images/contact_new.png:/images/contact_new.png - - - - - - - Qt::Vertical - - - - 1 - 1 - - - - @@ -316,6 +288,12 @@ anonymous, you can use a fake email. + + + 128 + 0 + + 128 @@ -350,11 +328,7 @@ anonymous, you can use a fake email. - RetroShare uses gpg keys for identity management. -You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new one with this form. - - - true + RetroShare uses gpg keys for identity management. diff --git a/retroshare-gui/src/gui/profile/ProfileManager.cpp b/retroshare-gui/src/gui/profile/ProfileManager.cpp index f4dda2902..ed04e3620 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.cpp +++ b/retroshare-gui/src/gui/profile/ProfileManager.cpp @@ -211,8 +211,7 @@ void ProfileManager::checkChanged(int /*i*/) void ProfileManager::newIdentity() { - GenCertDialog gd; - gd.hideButtons(); + GenCertDialog gd(true); gd.exec(); fillIdentities(); } diff --git a/retroshare-gui/src/gui/profile/ProfileManager.ui b/retroshare-gui/src/gui/profile/ProfileManager.ui index ee044e930..e9d1a1f7b 100644 --- a/retroshare-gui/src/gui/profile/ProfileManager.ui +++ b/retroshare-gui/src/gui/profile/ProfileManager.ui @@ -153,7 +153,7 @@ - QDialogButtonBox::Ok + QDialogButtonBox::Close diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 4877a6c47..8a0dd9df0 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -230,7 +230,7 @@ int main(int argc, char *argv[]) if (genCert) { - GenCertDialog gd; + GenCertDialog gd(false); gd.exec (); }