diff --git a/retroshare-gui/src/gui/ShareManager.cpp b/retroshare-gui/src/gui/ShareManager.cpp index f3353ee7a..781405c08 100644 --- a/retroshare-gui/src/gui/ShareManager.cpp +++ b/retroshare-gui/src/gui/ShareManager.cpp @@ -22,10 +22,18 @@ #include "rsiface/rsfiles.h" - +#include +#include +#include +#include +#include +#include #include +/* Images for context menu icons */ +#define IMAGE_CANCEL ":/images/delete.png" + /** Default constructor */ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags) @@ -39,12 +47,31 @@ ShareManager::ShareManager(QWidget *parent, Qt::WFlags flags) connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect( ui.shareddirList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( shareddirListCostumPopupMenu( QPoint ) ) ); + + ui.addButton->setToolTip(tr("Add a Share Directory")); ui.removeButton->setToolTip(tr("Remove selected Shared Directory")); load(); } + +void ShareManager::shareddirListCostumPopupMenu( QPoint point ) +{ + + QMenu contextMnu( this ); + QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier ); + + removeAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Remove" ), this ); + connect( removeAct , SIGNAL( triggered() ), this, SLOT( removeShareDirectory() ) ); + + + contextMnu.clear(); + contextMnu.addAction( removeAct ); + contextMnu.exec( mevent->globalPos() ); +} + /** Loads the settings for this page */ void ShareManager::load() { diff --git a/retroshare-gui/src/gui/ShareManager.h b/retroshare-gui/src/gui/ShareManager.h index 1ba25d7a9..29047d5cc 100644 --- a/retroshare-gui/src/gui/ShareManager.h +++ b/retroshare-gui/src/gui/ShareManager.h @@ -40,14 +40,26 @@ public: /** Loads the settings for this page */ void load(); public slots: + protected: + private slots: - void addShareDirectory(); - void removeShareDirectory(); + /** Create the context popup menu and it's submenus */ + void shareddirListCostumPopupMenu( QPoint point ); + + void addShareDirectory(); + void removeShareDirectory(); private: + + + /** Define the popup menus for the Context menu */ + QMenu* contextMnu; + /** Defines the actions for the context menu */ + QAction* removeAct; + /** Qt Designer generated object */ Ui::ShareManager ui; }; diff --git a/retroshare-gui/src/gui/ShareManager.ui b/retroshare-gui/src/gui/ShareManager.ui index 835bcd8fd..0c261e373 100644 --- a/retroshare-gui/src/gui/ShareManager.ui +++ b/retroshare-gui/src/gui/ShareManager.ui @@ -10,7 +10,7 @@ - Add Share Manager + RetroShare Share Manager :/images/rstray3.png @@ -60,7 +60,11 @@ p, li { white-space: pre-wrap; } - + + + Qt::CustomContextMenu + +