From 8e8860d1bdf561dc060ae75897298dabf5798294 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 2 Feb 2015 21:42:41 +0000 Subject: [PATCH] fixed design of PermissionMatrix. Improved scroller. Fixed bug not showing permissions correctly. Added help text. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7902 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../gui/settings/RSPermissionMatrixWidget.cpp | 31 ++++++++++++++-- .../gui/settings/RSPermissionMatrixWidget.h | 2 + .../gui/settings/ServicePermissionsPage.cpp | 11 +++++- .../gui/settings/ServicePermissionsPage.ui | 37 ++++++------------- 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index a11895403..90a76d66c 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp @@ -62,6 +62,9 @@ RSPermissionMatrixWidget::RSPermissionMatrixWidget(QWidget *parent) _timer = new QTimer ; QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(updateDisplay())) ; _timer->start(5000); + + _max_width = 400 ; + _max_height = 0 ; } void RSPermissionMatrixWidget::updateDisplay() @@ -69,6 +72,9 @@ void RSPermissionMatrixWidget::updateDisplay() if(isHidden()) return ; + setMinimumWidth(_max_width) ; + setMinimumHeight(_max_height) ; + update() ; } @@ -83,6 +89,14 @@ void RSPermissionMatrixWidget::mousePressEvent(QMouseEvent *e) { std::cerr << "Peer id: " << peer_id << ", service: " << service_id << std::endl; + // make sure the service is not globally disabled + + RsServicePermissions serv_perms ; + rsServiceControl->getServicePermissions(service_id,serv_perms) ; + + if(!serv_perms.mDefaultAllowed) + return ; + switchPermission(service_id,peer_id) ; update() ; } @@ -273,7 +287,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) //_painter->drawRect(info_pos) ; _painter->drawLine(QPointF(X,Y+3),QPointF(X+text_width,Y+3)) ; - _painter->drawLine(QPointF(X+text_width/2, Y+3), QPointF(X+text_width/2,MATRIX_START_Y+5)) ; + _painter->drawLine(QPointF(X+text_width/2, Y+3), QPointF(X+text_width/2,MATRIX_START_Y+peer_ids.size()*ROW_SIZE - ROW_SIZE+5)) ; pen.setBrush(Qt::black) ; _painter->setPen(pen) ; @@ -378,11 +392,17 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) RsPeerServiceInfo pserv_info ; rsServiceControl->getServicesAllowed(_current_peer_id,pserv_info) ; - QString local_status = (pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end())?tr("Locally enabled"):tr("Locally disabled") ; + bool locally_allowed = pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end(); + bool remotely_allowed = false ; // default, if the peer is offline - rsServiceControl->getServicesProvided(_current_peer_id,pserv_info) ; + if(rsServiceControl->getServicesProvided(_current_peer_id,pserv_info)) + remotely_allowed = pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end(); - QString remote_status = (pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end())?tr("Enabled by remote peer"):tr("Disabled by remote peer") ; + QString local_status = locally_allowed ?tr("Enabled for this peer") :tr("Disabled for this peer") ; + QString remote_status = remotely_allowed?tr("Enabled by remote peer"):tr("Disabled by remote peer") ; + + if(!service_perms.mDefaultAllowed) + local_status = tr("Switched Off") ; const QFont& font(_painter->font()) ; QFontMetrics fm(font); @@ -423,6 +443,9 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) _painter->drawText(QPointF(x,y), local_status) ; y += line_height ; } + _max_height = MATRIX_START_Y + (peer_ids.size()+3) * ROW_SIZE ; + _max_width = matrix_start_x + (service_ids.size()+3) * COL_SIZE ; + /* Stop the painter */ _painter->end(); } diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h index 7f2d52f3e..df6ea132a 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h @@ -94,6 +94,8 @@ private: /** A QPainter object that handles drawing the various graph elements. */ QPainter* _painter; QTimer *_timer ; + int _max_width; + int _max_height; /** The current dimensions of the graph. */ QRect _rec; diff --git a/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp b/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp index b5871923f..abc7f62cd 100644 --- a/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp +++ b/retroshare-gui/src/gui/settings/ServicePermissionsPage.cpp @@ -50,8 +50,15 @@ ServicePermissionsPage::ServicePermissionsPage(QWidget * parent, Qt::WindowFlags QString ServicePermissionsPage::helpText() const { - return tr("

  Permissions

\ -

Permissions allow you to control which services are available to which friends

"); + return tr("

  Permissions

\ +

Permissions allow you to control which services are available to which friends

\ +

Each interruptor shows two lights, indicating whether you or your friend has enabled\ + that service. Both needs to be ON (showing ) to\ + let information transfer for a specific service/friend combination.

\ +

For each service, the global switch / \ + allow to turn a service ON/OFF for all friends at once.

\ +

Be very careful: Some services depend on each other. For instance turning turtle OFF will also\ + stop all anonymous transfer, distant chat and distant messaging.

"); } /** Saves the changes on this page */ diff --git a/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui b/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui index 7460cda4e..e61451b2e 100644 --- a/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui +++ b/retroshare-gui/src/gui/settings/ServicePermissionsPage.ui @@ -43,32 +43,19 @@ - - - true + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised - - - - 0 - 0 - 619 - 276 - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - -