From e78ed75d36211b3bade171d8ca8ad8e8466849b6 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 9 Jun 2010 23:46:24 +0000 Subject: [PATCH] * Added Drag and Drop feature for CertificatePage, you can now drag and drop friends key file in a easy way. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3094 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../src/gui/connect/ConnectFriendWizard.cpp | 48 +++++++++++++++++-- .../src/gui/connect/ConnectFriendWizard.h | 5 ++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 8c12ff24d..fa27bd330 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -24,6 +24,7 @@ #include "rsiface/rspeers.h" //for rsPeers variable #include "rsiface/rsiface.h" +#include #include #include #include @@ -168,7 +169,7 @@ IntroPage::IntroPage(QWidget *parent) "to do this:")) ; textRadioButton = new QRadioButton(tr("&Enter the certificate manually")); - certRadioButton = new QRadioButton(tr("&Use *.rsc files with certificates" )); + certRadioButton = new QRadioButton(tr("&You get a certificate file from your friend" )); foffRadioButton = new QRadioButton(tr("&Make friend with selected friends of my friends" )); textRadioButton->setChecked(true); @@ -609,6 +610,8 @@ CertificatePage::CertificatePage(QWidget *parent) : QWizardPage(parent) { "Also, you can use a file generated " "before.")); userFileLabel->setWordWrap(true); + + setAcceptDrops(true); userFileCreateButton = new QPushButton; userFileCreateButton->setText(tr("Export my certificate...")); @@ -620,11 +623,11 @@ CertificatePage::CertificatePage(QWidget *parent) : QWizardPage(parent) { userFileFrame = new QGroupBox; userFileFrame->setFlat(true); - userFileFrame->setTitle(tr("Export my certificate...")); + userFileFrame->setTitle(tr("Import friend's certificate...")); userFileFrame->setLayout(userFileLayout); - friendFileLabel = new QLabel(tr("Specify path to your friend's " - "certificate in the box below " ) ); + friendFileLabel = new QLabel(tr("Drag and Drop your friends's certificate in this Window or specify path " + "in the box below " ) ); friendFileNameEdit = new QLineEdit; registerField("friendCertificateFile*", friendFileNameEdit); @@ -649,7 +652,7 @@ CertificatePage::CertificatePage(QWidget *parent) : QWizardPage(parent) { void CertificatePage::loadFriendCert() { QString fileName = QFileDialog::getOpenFileName(this, tr("Select Certificate"), - "", tr("RetroShare Certificates (*.rsc)")); + "", tr("RetroShare Certificate (*.rsc );;All Files (*)")); if (!fileName.isNull()) { @@ -700,6 +703,41 @@ void CertificatePage::generateCertificateCalled() { //============================================================================ +void CertificatePage::dragEnterEvent(QDragEnterEvent *event) +{ + // accept just text/uri-list mime format + if (event->mimeData()->hasFormat("text/uri-list")) + { + event->acceptProposedAction(); + } +} + + +void CertificatePage::dropEvent(QDropEvent *event) +{ + QList urlList; + QString fName; + QFileInfo info; + + if (event->mimeData()->hasUrls()) + { + urlList = event->mimeData()->urls(); // returns list of QUrls + // if just text was dropped, urlList is empty (size == 0) + + if ( urlList.size() > 0) // if at least one QUrl is present in list + { + fName = urlList[0].toLocalFile(); // convert first QUrl to local path + info.setFile( fName ); // information about file + if ( info.isFile() ) + friendFileNameEdit->setText( fName ); // if is file, setText + } + } + + event->acceptProposedAction(); +} + +//============================================================================ + bool CertificatePage::isComplete() const { return !( (friendFileNameEdit->text()).isEmpty() ); } diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h index 0e538b4c2..08aadcb60 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.h +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.h @@ -118,6 +118,9 @@ public: int nextId() const; bool isComplete() const ; + void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + private: QGroupBox* userFileFrame; QLabel *userFileLabel; @@ -134,6 +137,8 @@ private: private slots: void generateCertificateCalled(); void loadFriendCert(); + + }; //============================================================================