From 2573a05dfec35558038ea29fe9f4c7dc47b6971e Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 12 Feb 2010 19:11:52 +0000 Subject: [PATCH] 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 --- .../src/gui/connect/ConnectFriendWizard.cpp | 50 +++++++++++++++++- .../src/gui/connect/ConnectFriendWizard.h | 8 +++ retroshare-gui/src/gui/images.qrc | 1 + .../src/gui/images/document_save.png | Bin 0 -> 581 bytes 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 retroshare-gui/src/gui/images/document_save.png diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index d0d103b02..143281b78 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -234,7 +234,16 @@ TextPage::TextPage(QWidget *parent) userCertCopyButton->setIcon( QIcon(":images/copyrslink.png") ); userCertCopyButton->setToolTip(tr("Copy your Cert to Clipboard")); connect (userCertCopyButton, SIGNAL( clicked()), - this, SLOT( copyCert()) ); + 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; @@ -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; diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h index 74d72b2fc..2bef3aabe 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h @@ -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 @@ -88,11 +89,18 @@ private: QTextEdit* friendCertEdit; 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) diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index 6c6320157..010bc2246 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -114,6 +114,7 @@ images/directoryselect_24x24_shadow.png images/diskSave.png images/dlunch.png + images/document_save.png images/donline.png images/down.png images/down_24x24.png diff --git a/retroshare-gui/src/gui/images/document_save.png b/retroshare-gui/src/gui/images/document_save.png new file mode 100644 index 0000000000000000000000000000000000000000..076da14a4c91d5641ccb9c5cc5c66c9785e2414a GIT binary patch literal 581 zcmV-L0=oT)P)-^Cstx> zsTLNZc7li2ioK1B-Cbd!wVel+fixZ$0s+0<02XTv#(<&9moL_cqUO%}#>SBbfJDQ#onm?zDvCSZGl&QwguNCd1ibfH z3%9SF#=wk3RS7!1gOcVY-g{);AcTO3FwTmq;vaG4fGPylDuXT(1QERVOtOOapT5>w zm~BZxQC7R>@ZJ+d773C`M)&;LdG(Z{605>E&G#V)f_Tr<`*#=i{I3XMjzFXu;{Sxm z-!mvn0G_QqCyJtdDh6(?-o%S=YI(UngVKBQq5z=R>+$B*Yn*dDdh)nt(&=>A9t`jz zlvCo$pe)Jr9DpQ_Nz;_cWI`Orb?hLhD(!ZgA6r{{1}gG1N#dhXGa^nBT$YiS#e#uL z9Ys-)IX7#$0btO}$$0!Fj+0}f(THm|t^+U}4r>P6g8`s?+uX!1*&P6L(C_>kLVp_m TlH`NA00000NkvXXu0mjf5IzCm literal 0 HcmV?d00001