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
This commit is contained in:
thunder2 2012-10-29 11:02:03 +00:00
parent a7c29c0f24
commit e99b30d015
6 changed files with 173 additions and 197 deletions

View File

@ -36,8 +36,8 @@
/** Default constructor */ /** Default constructor */
GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags) GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags) : QDialog(parent, flags), mOnlyGenerateIdentity(onlyGenerateIdentity)
{ {
/* Invoke Qt Designer generated QObject setup routine */ /* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this); ui.setupUi(this);
@ -74,6 +74,7 @@ void GenCertDialog::init()
std::list<std::string> pgpIds; std::list<std::string> pgpIds;
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
bool foundGPGKeys = false; bool foundGPGKeys = false;
if (!mOnlyGenerateIdentity) {
if (RsInit::GetPGPLogins(pgpIds)) { if (RsInit::GetPGPLogins(pgpIds)) {
for(it = pgpIds.begin(); it != pgpIds.end(); it++) for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{ {
@ -86,6 +87,7 @@ void GenCertDialog::init()
foundGPGKeys = true; foundGPGKeys = true;
} }
} }
}
if (foundGPGKeys) { if (foundGPGKeys) {
ui.no_gpg_key_label->hide(); ui.no_gpg_key_label->hide();
@ -95,7 +97,7 @@ void GenCertDialog::init()
ui.headerLabel->setText(tr("Create a new Location")); ui.headerLabel->setText(tr("Create a new Location"));
genNewGPGKey = false; genNewGPGKey = false;
} else { } 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->setChecked(true);
ui.new_gpg_key_checkbox->setEnabled(false); ui.new_gpg_key_checkbox->setEnabled(false);
setWindowTitle(tr("Create new Identity")); setWindowTitle(tr("Create new Identity"));
@ -103,6 +105,19 @@ void GenCertDialog::init()
ui.headerLabel->setText(tr("Create a new Identity")); ui.headerLabel->setText(tr("Create a new Identity"));
genNewGPGKey = true; 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(); newGPGKeyGenUiSetup();
} }
@ -118,11 +133,8 @@ void GenCertDialog::newGPGKeyGenUiSetup() {
ui.password_input->show(); ui.password_input->show();
ui.genPGPuserlabel->hide(); ui.genPGPuserlabel->hide();
ui.genPGPuser->hide(); ui.genPGPuser->hide();
ui.importIdentity_PB->hide() ;
if(ui.genPGPuser->count() == 0)
ui.exportIdentity_PB->hide(); ui.exportIdentity_PB->hide();
// ui.importIdentity_PB->hide() ;
setWindowTitle(tr("Create new Identity")); setWindowTitle(tr("Create new Identity"));
ui.genButton->setText(tr("Generate new Identity")); ui.genButton->setText(tr("Generate new Identity"));
ui.headerLabel->setText(tr("Create a new Identity")); ui.headerLabel->setText(tr("Create a new Identity"));
@ -136,8 +148,9 @@ void GenCertDialog::newGPGKeyGenUiSetup() {
ui.password_input->hide(); ui.password_input->hide();
ui.genPGPuserlabel->show(); ui.genPGPuserlabel->show();
ui.genPGPuser->show(); ui.genPGPuser->show();
ui.exportIdentity_PB->show() ; ui.importIdentity_PB->setVisible(!mOnlyGenerateIdentity);
ui.importIdentity_PB->show() ; ui.exportIdentity_PB->setVisible(!mOnlyGenerateIdentity);
ui.exportIdentity_PB->setEnabled(ui.genPGPuser->count() != 0);
setWindowTitle(tr("Create new Location")); setWindowTitle(tr("Create new Location"));
ui.genButton->setText(tr("Generate new Location")); ui.genButton->setText(tr("Generate new Location"));
ui.headerLabel->setText(tr("Create a 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; 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();
}

View File

@ -35,12 +35,9 @@ class GenCertDialog : public QDialog
public: public:
/** Default constructor */ /** Default constructor */
GenCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0); GenCertDialog(bool onlyGenerateIdentity, QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */ /** Default destructor */
void hideButtons();
private slots: private slots:
void genPerson(); void genPerson();
//void loadPerson(); //void loadPerson();
@ -65,6 +62,7 @@ private:
Ui::GenCertDialog ui; Ui::GenCertDialog ui;
bool genNewGPGKey; bool genNewGPGKey;
bool mOnlyGenerateIdentity;
}; };
#endif #endif

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>664</width> <width>664</width>
<height>524</height> <height>474</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -50,21 +50,6 @@
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">
<widget class="QLabel" name="no_gpg_key_label"> <widget class="QLabel" name="no_gpg_key_label">
@ -76,6 +61,135 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QComboBox" name="genPGPuser">
<property name="toolTip">
<string>Your profile is associated to a GPG key. RetroShare currently ignores DSA keys.</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="name_input">
<property name="toolTip">
<string>Enter here your nickname</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="email_label">
<property name="text">
<string>Email</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="email_input">
<property name="toolTip">
<string>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.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="password_label">
<property name="toolTip">
<string>This Password is for GPG</string>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="password_input">
<property name="toolTip">
<string>Put a strong password here. This password protects your GPG key.</string>
</property>
<property name="inputMask">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="location_label">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="location_input"/>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_location2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string>Put a meaningful location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same identity (gpg key).</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QPushButton" name="genButton">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text">
<string>Generate New Identity</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/contact_new.png</normaloff>:/images/contact_new.png</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="genPGPuserlabel">
<property name="text">
<string>Use identity</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2"> <item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,0"> <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,0">
<property name="spacing"> <property name="spacing">
@ -145,148 +259,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="progress_label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="genPGPuserlabel">
<property name="text">
<string>Use identity</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="genPGPuser">
<property name="toolTip">
<string>Your profile is associated to a GPG key. RetroShare currently ignores DSA keys.</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="name_label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="name_input">
<property name="toolTip">
<string>Enter here your nickname</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="email_label">
<property name="text">
<string>Email</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="email_input">
<property name="toolTip">
<string>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.</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="password_label">
<property name="toolTip">
<string>This Password is for GPG</string>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="password_input">
<property name="toolTip">
<string>Put a strong password here. This password protects your GPG key.</string>
</property>
<property name="inputMask">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="location_label">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="location_input"/>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_location2">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string>Put a meaningful location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same identity (gpg key).</string>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="genButton">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>26</height>
</size>
</property>
<property name="text">
<string>Generate New Identity</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/contact_new.png</normaloff>:/images/contact_new.png</iconset>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -316,6 +288,12 @@ anonymous, you can use a fake email.</string>
</property> </property>
<item> <item>
<widget class="QLabel" name="headerImage"> <widget class="QLabel" name="headerImage">
<property name="minimumSize">
<size>
<width>128</width>
<height>0</height>
</size>
</property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>128</width> <width>128</width>
@ -350,11 +328,7 @@ anonymous, you can use a fake email.</string>
<item> <item>
<widget class="QLabel" name="headerLabel2"> <widget class="QLabel" name="headerLabel2">
<property name="text"> <property name="text">
<string>RetroShare uses gpg keys for identity management. <string>RetroShare uses gpg keys for identity management.</string>
You can use an existing identity (i.e. a gpg key pair), from the list below, or create a new one with this form.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -211,8 +211,7 @@ void ProfileManager::checkChanged(int /*i*/)
void ProfileManager::newIdentity() void ProfileManager::newIdentity()
{ {
GenCertDialog gd; GenCertDialog gd(true);
gd.hideButtons();
gd.exec(); gd.exec();
fillIdentities(); fillIdentities();
} }

View File

@ -153,7 +153,7 @@
<item row="2" column="0"> <item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Close</set>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -230,7 +230,7 @@ int main(int argc, char *argv[])
if (genCert) if (genCert)
{ {
GenCertDialog gd; GenCertDialog gd(false);
gd.exec (); gd.exec ();
} }