mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-22 05:14:31 -04: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
3 changed files with 49 additions and 1 deletions
|
@ -44,6 +44,7 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags)
|
||||||
|
|
||||||
connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
|
connect(ui.copykeyButton, SIGNAL(clicked()), this, SLOT(copyPublicKey()));
|
||||||
connect(ui.exportkeyButton, SIGNAL(clicked()), this, SLOT(exportPublicKey()));
|
connect(ui.exportkeyButton, SIGNAL(clicked()), this, SLOT(exportPublicKey()));
|
||||||
|
connect(ui.saveButton, SIGNAL(clicked()), this, SLOT(fileSaveAs()));
|
||||||
|
|
||||||
|
|
||||||
loadPublicKey();
|
loadPublicKey();
|
||||||
|
@ -120,3 +121,36 @@ CryptoPage::exportPublicKey()
|
||||||
QMessageBox::Ok, QMessageBox::Ok);
|
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);
|
||||||
|
}
|
|
@ -55,6 +55,9 @@ class CryptoPage : public ConfigPage
|
||||||
|
|
||||||
void exportPublicKey();
|
void exportPublicKey();
|
||||||
|
|
||||||
|
bool fileSave();
|
||||||
|
bool fileSaveAs();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** A RshareSettings object used for saving/loading settings */
|
/** A RshareSettings object used for saving/loading settings */
|
||||||
|
@ -62,6 +65,10 @@ class CryptoPage : public ConfigPage
|
||||||
|
|
||||||
void closeEvent (QCloseEvent * event);
|
void closeEvent (QCloseEvent * event);
|
||||||
|
|
||||||
|
void setCurrentFileName(const QString &fileName);
|
||||||
|
|
||||||
|
QString fileName;
|
||||||
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::CryptoPage ui;
|
Ui::CryptoPage ui;
|
||||||
|
|
|
@ -525,7 +525,7 @@
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QPushButton" name="exportkeyButton">
|
<widget class="QPushButton" name="exportkeyButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<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>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QPushButton" name="saveButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save Key</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue