From cf9309733b4bf7d7b3c6ef3fe7dd3a3a5d8ff623 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 29 Jan 2010 23:34:16 +0000 Subject: [PATCH] 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 --- .../src/gui/settings/CryptoPage.cpp | 34 +++++++++++++++++++ retroshare-gui/src/gui/settings/CryptoPage.h | 7 ++++ retroshare-gui/src/gui/settings/CryptoPage.ui | 9 ++++- 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index 269acde79..6f1081a82 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -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); +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/settings/CryptoPage.h b/retroshare-gui/src/gui/settings/CryptoPage.h index 0d06c3cc9..0d2b5daa2 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.h +++ b/retroshare-gui/src/gui/settings/CryptoPage.h @@ -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 */ diff --git a/retroshare-gui/src/gui/settings/CryptoPage.ui b/retroshare-gui/src/gui/settings/CryptoPage.ui index 0aff0812b..7be252f6d 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.ui +++ b/retroshare-gui/src/gui/settings/CryptoPage.ui @@ -525,7 +525,7 @@ - + <!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; } + + + + Save Key + + +