From 92df7037b2ad1ba5a0beffa4c005911f3805fc79 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 8 Apr 2010 16:33:10 +0000 Subject: [PATCH] Added ShareDialog for ShareManager git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2693 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/RetroShare.pro | 3 + retroshare-gui/src/gui/ShareDialog.cpp | 127 +++++++++++ retroshare-gui/src/gui/ShareDialog.h | 64 ++++++ retroshare-gui/src/gui/ShareDialog.ui | 282 ++++++++++++++++++++++++ retroshare-gui/src/gui/ShareManager.cpp | 9 +- retroshare-gui/src/gui/ShareManager.h | 4 + 6 files changed, 488 insertions(+), 1 deletion(-) create mode 100644 retroshare-gui/src/gui/ShareDialog.cpp create mode 100644 retroshare-gui/src/gui/ShareDialog.h create mode 100644 retroshare-gui/src/gui/ShareDialog.ui diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 416f7e808..2f013e468 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -164,6 +164,7 @@ HEADERS += rshare.h \ gui/SearchDialog.h \ gui/SharedFilesDialog.h \ gui/ShareManager.h \ + gui/ShareDialog.h \ gui/SFListDelegate.h \ gui/SoundManager.h \ gui/FileTransferInfoWidget.h \ @@ -276,6 +277,7 @@ FORMS += gui/StartDialog.ui \ gui/SendLinkDialog.ui \ gui/SharedFilesDialog.ui \ gui/ShareManager.ui \ + gui/ShareDialog.ui \ gui/MessagesDialog.ui \ gui/MessagesPopupDialog.ui \ gui/help/browser/helpbrowser.ui \ @@ -347,6 +349,7 @@ SOURCES += main.cpp \ gui/AddLinksDialog.cpp \ gui/SharedFilesDialog.cpp \ gui/ShareManager.cpp \ + gui/ShareDialog.cpp \ gui/SFListDelegate.cpp \ gui/SoundManager.cpp \ gui/MessagesDialog.cpp \ diff --git a/retroshare-gui/src/gui/ShareDialog.cpp b/retroshare-gui/src/gui/ShareDialog.cpp new file mode 100644 index 000000000..ed2a28fe6 --- /dev/null +++ b/retroshare-gui/src/gui/ShareDialog.cpp @@ -0,0 +1,127 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006- 2010 RetroShare Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ +#include "ShareDialog.h" + +#include "rsiface/rsfiles.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/** Default constructor */ +ShareDialog::ShareDialog(QWidget *parent, Qt::WFlags flags) + : QDialog(parent, flags) +{ + /* Invoke Qt Designer generated QObject setup routine */ + ui.setupUi(this); + + connect(ui.browseButton, SIGNAL(clicked( bool ) ), this , SLOT( browseDirectory() ) ); + connect(ui.okButton, SIGNAL(clicked( bool ) ), this , SLOT( addDirectory() ) ); + connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(closedialog())); + + load(); + + +} + +void ShareDialog::load() +{ + + ui.localpath_lineEdit->clear(); + ui.anonymouscheckBox->setChecked(false); + ui.friendscheckBox->setChecked(false); +} + +void ShareDialog::browseDirectory() +{ + + /* select a dir*/ + QString qdir = QFileDialog::getExistingDirectory(this, tr("Select A Folder To Share"), "", QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + /* add it to the server */ + std::string dir = qdir.toStdString(); + currentDir = qdir.toStdString(); + if (dir != "") + { + ui.localpath_lineEdit->setText(QString::fromStdString(dir)); + } +} + +void ShareDialog::addDirectory() +{ + + SharedDirInfo sdi ; + sdi.filename = currentDir ; + + if( ui.anonymouscheckBox->isChecked() && ui.friendscheckBox->isChecked()) + { + sdi.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ; + } + if ( ui.anonymouscheckBox->isChecked() && !ui.friendscheckBox->isChecked() ) + { + sdi.shareflags = RS_FILE_HINTS_NETWORK_WIDE; + } + if ( ui.friendscheckBox->isChecked() && !ui.anonymouscheckBox->isChecked()) + { + sdi.shareflags = RS_FILE_HINTS_BROWSABLE ; + } + + rsFiles->addSharedDirectory(sdi); + + //messageBoxOk(tr("Shared Directory Added!")); + load(); + close(); + +} + +void ShareDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) + { + load(); + } +} + +void ShareDialog::closedialog() +{ + ui.localpath_lineEdit->clear(); + ui.anonymouscheckBox->setChecked(false); + ui.friendscheckBox->setChecked(false); + + close(); +} + +bool ShareDialog::messageBoxOk(QString msg) +{ + QMessageBox mb("Share Manager InfoBox!",msg,QMessageBox::Information,QMessageBox::Ok,0,0); + mb.setButtonText( QMessageBox::Ok, "OK" ); + mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); + mb.exec(); + return true; +} diff --git a/retroshare-gui/src/gui/ShareDialog.h b/retroshare-gui/src/gui/ShareDialog.h new file mode 100644 index 000000000..df1821686 --- /dev/null +++ b/retroshare-gui/src/gui/ShareDialog.h @@ -0,0 +1,64 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2006 - 2010 RetroShare Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifndef _SHAREDIALOG_H +#define _SHAREDIALOG_H + +#include +#include + +#include "ui_ShareDialog.h" + +class ShareDialog : public QDialog +{ + Q_OBJECT + + public: + + /** Default constructor */ + ShareDialog( QWidget *parent = 0, Qt::WFlags flags = 0); + /** Default destructor */ + + bool messageBoxOk(QString); + +public slots: + + /** Loads the settings for this page */ + void load(); + +protected: + virtual void showEvent(QShowEvent * event); + +private slots: + + void browseDirectory(); + void addDirectory(); + void closedialog(); + +private: + + std::string currentDir; + /** Qt Designer generated object */ + Ui::ShareDialog ui; +}; + +#endif + diff --git a/retroshare-gui/src/gui/ShareDialog.ui b/retroshare-gui/src/gui/ShareDialog.ui new file mode 100644 index 000000000..f7c48bbb0 --- /dev/null +++ b/retroshare-gui/src/gui/ShareDialog.ui @@ -0,0 +1,282 @@ + + + ShareDialog + + + Qt::NonModal + + + + 0 + 0 + 536 + 351 + + + + RetroShare Share Folder + + + + :/images/rstray3.png:/images/rstray3.png + + + false + + + + 0 + + + 0 + + + + + + 16777215 + 60 + + + + QFrame#frame{background-image: url(:/images/connect/connectFriendBanner.png);} + + + + QFrame::NoFrame + + + QFrame::Raised + + + 1 + + + + 6 + + + 6 + + + + + + 48 + 48 + + + + + 48 + 48 + + + + + + + + + + :/images/fileshare48.png + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:26pt; font-weight:600; color:#ffffff;">Share Folder</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 6 + + + + + Share Folder + + + + + + + + Local Path + + + + + + + true + + + + + + + + 27 + 0 + + + + + 200 + 200 + + + + Browse + + + + 24 + 24 + + + + + + + + Virtual Folder + + + + + + + + + + + + Share Flags + + + + + + Anonymous shared Network Wide + + + Anonymous + + + + + + + Browseable by Friends + + + Friends + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + 0 + 0 + + + + + 200 + 200 + + + + OK + + + + 16 + 16 + + + + false + + + true + + + + + + + Qt::Horizontal + + + + 191 + 20 + + + + + + + + Cancel + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index d14e29a16..7854efdaa 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -21,6 +21,7 @@ #include "ShareManager.h" #include "rsiface/rsfiles.h" +#include "ShareDialog.h" #include #include @@ -47,7 +48,7 @@ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags) ui.setupUi(this); - connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( addShareDirectory() ) ); + connect(ui.addButton, SIGNAL(clicked( bool ) ), this , SLOT( showShareDialog() ) ); connect(ui.removeButton, SIGNAL(clicked( bool ) ), this , SLOT( removeShareDirectory() ) ); connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(close())); @@ -256,3 +257,9 @@ void ShareManager::showEvent(QShowEvent *event) load(); } } + +void ShareManager::showShareDialog() +{ + static ShareDialog *sharedlg = new ShareDialog(this); + sharedlg->show(); +} diff --git a/retroshare-gui/src/gui/ShareManager.h b/retroshare-gui/src/gui/ShareManager.h index c39146e2a..18b06beef 100644 --- a/retroshare-gui/src/gui/ShareManager.h +++ b/retroshare-gui/src/gui/ShareManager.h @@ -46,6 +46,9 @@ private: public slots: + void showShareDialog(); + + protected: virtual void showEvent(QShowEvent * event); @@ -58,6 +61,7 @@ private slots: void removeShareDirectory(); void updateFlags(bool); + private: