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:
defnax 2010-01-29 23:34:16 +00:00
parent af973cdf5b
commit cf9309733b
3 changed files with 49 additions and 1 deletions

View file

@ -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);
}