mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-21 05:44:29 -05:00
Added Save Cert Button to ConnectFriend Wizard
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2294 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0a5e3c9b63
commit
2573a05dfe
@ -236,6 +236,15 @@ TextPage::TextPage(QWidget *parent)
|
||||
connect (userCertCopyButton, SIGNAL( clicked()),
|
||||
this, SLOT( copyCert()) );
|
||||
|
||||
userCertSaveButton = new QPushButton;
|
||||
userCertSaveButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
userCertSaveButton->setFixedSize(20,20);
|
||||
userCertSaveButton->setFlat(true);
|
||||
userCertSaveButton->setIcon( QIcon(":images/document_save.png") );
|
||||
userCertSaveButton->setToolTip(tr("Save your Cert into a File"));
|
||||
connect (userCertSaveButton, SIGNAL( clicked()),
|
||||
this, SLOT( fileSaveAs()) );
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
userCertMailButton = new QPushButton;
|
||||
userCertMailButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
@ -249,6 +258,7 @@ TextPage::TextPage(QWidget *parent)
|
||||
userCertButtonsLayout = new QVBoxLayout();
|
||||
userCertButtonsLayout->addWidget(userCertHelpButton);
|
||||
userCertButtonsLayout->addWidget(userCertCopyButton);
|
||||
userCertButtonsLayout->addWidget(userCertSaveButton);
|
||||
#if defined(Q_OS_WIN)
|
||||
userCertButtonsLayout->addWidget(userCertMailButton);
|
||||
#endif
|
||||
@ -338,6 +348,44 @@ TextPage::copyCert()
|
||||
//============================================================================
|
||||
//
|
||||
|
||||
bool TextPage::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 << userCertEdit->document()->toPlainText();
|
||||
userCertEdit->document()->setModified(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TextPage::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("RetroShare Certificate (*.rsc );;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
void TextPage::setCurrentFileName(const QString &fileName)
|
||||
{
|
||||
this->fileName = fileName;
|
||||
userCertEdit->document()->setModified(false);
|
||||
|
||||
setWindowModified(false);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//============================================================================
|
||||
//
|
||||
|
||||
int TextPage::nextId() const {
|
||||
|
||||
std::string certstr;
|
||||
|
@ -80,6 +80,7 @@ private:
|
||||
QVBoxLayout* userCertButtonsLayout;
|
||||
QPushButton* userCertHelpButton;
|
||||
QPushButton* userCertCopyButton;
|
||||
QPushButton* userCertSaveButton;
|
||||
#if defined(Q_OS_WIN)
|
||||
QPushButton* userCertMailButton;//! on Windows, click on this button
|
||||
//! launches default email client
|
||||
@ -89,10 +90,17 @@ private:
|
||||
|
||||
QVBoxLayout* textPageLayout;
|
||||
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
|
||||
QString fileName;
|
||||
|
||||
private slots:
|
||||
void showHelpUserCert();
|
||||
void copyCert();
|
||||
|
||||
bool fileSave();
|
||||
bool fileSaveAs();
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
//! launches default email client (on windows)
|
||||
|
||||
|
@ -114,6 +114,7 @@
|
||||
<file>images/directoryselect_24x24_shadow.png</file>
|
||||
<file>images/diskSave.png</file>
|
||||
<file>images/dlunch.png</file>
|
||||
<file>images/document_save.png</file>
|
||||
<file>images/donline.png</file>
|
||||
<file>images/down.png</file>
|
||||
<file>images/down_24x24.png</file>
|
||||
|
BIN
retroshare-gui/src/gui/images/document_save.png
Normal file
BIN
retroshare-gui/src/gui/images/document_save.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 581 B |
Loading…
Reference in New Issue
Block a user