mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
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
This commit is contained in:
parent
88c6af3b74
commit
8e8860d1bd
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -50,8 +50,15 @@ ServicePermissionsPage::ServicePermissionsPage(QWidget * parent, Qt::WindowFlags
|
||||
|
||||
QString ServicePermissionsPage::helpText() const
|
||||
{
|
||||
return tr("<h1><img width=\"24\" src=\":/images/64px_help.png\"> Permissions</h1> \
|
||||
<p>Permissions allow you to control which services are available to which friends </p>");
|
||||
return tr("<h1><img width=\"24\" src=\":/images/64px_help.png\"> Permissions</h1> \
|
||||
<p>Permissions allow you to control which services are available to which friends</p>\
|
||||
<p>Each interruptor shows two lights, indicating whether you or your friend has enabled\
|
||||
that service. Both needs to be ON (showing <img height=20 src=\":/images/switch11.png\"/>) to\
|
||||
let information transfer for a specific service/friend combination.</p>\
|
||||
<p>For each service, the global switch <img height=20 src=\":/images/global_switch_on.png\"> / <img height=20 src=\":/images/global_switch_off.png\">\
|
||||
allow to turn a service ON/OFF for all friends at once.</p>\
|
||||
<p>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.</p>");
|
||||
}
|
||||
|
||||
/** Saves the changes on this page */
|
||||
|
@ -43,32 +43,19 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
<widget class="RSPermissionMatrixWidget" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>619</width>
|
||||
<height>276</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="RSPermissionMatrixWidget" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user