Merge pull request #811 from PhenomRetroShare/Add_OpenCertFileInHomeAddFriend

Add Open Cert File in Home Add Friend wizard.
This commit is contained in:
csoler 2017-05-09 18:55:28 +02:00 committed by GitHub
commit 88525e48c5
3 changed files with 55 additions and 2 deletions

View File

@ -345,6 +345,7 @@ void ConnectFriendWizard::initializePage(int id)
connect(ui->userCertOldFormatButton, SIGNAL(clicked()), this, SLOT(toggleFormatState()));
connect(ui->userCertCopyButton, SIGNAL(clicked()), this, SLOT(copyCert()));
connect(ui->userCertPasteButton, SIGNAL(clicked()), this, SLOT(pasteCert()));
connect(ui->userCertOpenButton, SIGNAL(clicked()), this, SLOT(openCert()));
connect(ui->userCertSaveButton, SIGNAL(clicked()), this, SLOT(saveCert()));
connect(ui->userCertMailButton, SIGNAL(clicked()), this, SLOT(runEmailClient()));
connect(ui->friendCertEdit, SIGNAL(textChanged()), this, SLOT(friendCertChanged()));
@ -1077,6 +1078,22 @@ void ConnectFriendWizard::pasteCert()
ui->friendCertEdit->setPlainText(clipboard->text());
}
void ConnectFriendWizard::openCert()
{
QString fileName ;
if(!misc::getOpenFileName(this, RshareSettings::LASTDIR_CERT, tr("Select Certificate"), tr("RetroShare Certificate (*.rsc );;All Files (*)"),fileName))
return ;
if (!fileName.isNull()) {
QFile fileCert(fileName);
if (fileCert.open(QIODevice::ReadOnly )) {
QByteArray arrayCert(fileCert.readAll());
ui->friendCertEdit->setPlainText(QString::fromUtf8(arrayCert));
fileCert.close();
}
}
}
void ConnectFriendWizard::saveCert()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as..."), "", tr("RetroShare Certificate (*.rsc );;All Files (*)"));

View File

@ -66,6 +66,7 @@ private slots:
void showHelpUserCert();
void copyCert();
void pasteCert();
void openCert();
void saveCert();
void friendCertChanged();
void cleanFriendCert();

View File

@ -279,7 +279,7 @@
</item>
<item>
<widget class="QFrame" name="friendFrame">
<layout class="QGridLayout" name="gridLayout_3">
<layout class="QGridLayout" name="friendFrameGLayout">
<item row="0" column="0">
<widget class="QToolButton" name="userCertPasteButton">
<property name="sizePolicy">
@ -316,6 +316,41 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="userCertOpenButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>20</horstretch>
<verstretch>20</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Open Cert of your friend from File</string>
</property>
<property name="text">
<string>Open certificate</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/svg/filesharing.svg</normaloff>:/icons/svg/filesharing.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="friendCertCleanLabel">
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/accepted16.png</pixmap>
@ -325,7 +360,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="1" column="0" colspan="3">
<widget class="RSPlainTextEdit" name="friendCertEdit">
<property name="font">
<font>