mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-19 03:41:31 -05:00
added to store own key into a file.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2151 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
af973cdf5b
commit
cf9309733b
@ -44,6 +44,7 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags)
|
||||
|
||||
connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
|
||||
connect(ui.exportkeyButton, SIGNAL(clicked()), this, SLOT(exportPublicKey()));
|
||||
connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(fileSaveAs()));
|
||||
|
||||
|
||||
loadPublicKey();
|
||||
@ -120,3 +121,36 @@ CryptoPage::exportPublicKey()
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
bool CryptoPage::fileSave()
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return fileSaveAs();
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
return false;
|
||||
QTextStream ts(&file);
|
||||
ts.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
ts << ui.certtextEdit->document()->toPlainText();
|
||||
ui.certtextEdit->document()->setModified(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CryptoPage::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("TXT-Files (*.pqi *.pem *.txt);;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
void CryptoPage::setCurrentFileName(const QString &fileName)
|
||||
{
|
||||
this->fileName = fileName;
|
||||
ui.certtextEdit->document()->setModified(false);
|
||||
|
||||
setWindowModified(false);
|
||||
}
|
@ -54,6 +54,9 @@ class CryptoPage : public ConfigPage
|
||||
void copyPublicKey();
|
||||
|
||||
void exportPublicKey();
|
||||
|
||||
bool fileSave();
|
||||
bool fileSaveAs();
|
||||
|
||||
|
||||
private:
|
||||
@ -61,6 +64,10 @@ class CryptoPage : public ConfigPage
|
||||
RshareSettings* _settings;
|
||||
|
||||
void closeEvent (QCloseEvent * event);
|
||||
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
|
||||
QString fileName;
|
||||
|
||||
|
||||
/** Qt Designer generated object */
|
||||
|
@ -525,7 +525,7 @@
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="exportkeyButton">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
@ -569,6 +569,13 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="saveButton">
|
||||
<property name="text">
|
||||
<string>Save Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
Loading…
Reference in New Issue
Block a user