mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 09:41:29 -05: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 ;
|
_timer = new QTimer ;
|
||||||
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(updateDisplay())) ;
|
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(updateDisplay())) ;
|
||||||
_timer->start(5000);
|
_timer->start(5000);
|
||||||
|
|
||||||
|
_max_width = 400 ;
|
||||||
|
_max_height = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSPermissionMatrixWidget::updateDisplay()
|
void RSPermissionMatrixWidget::updateDisplay()
|
||||||
@ -69,6 +72,9 @@ void RSPermissionMatrixWidget::updateDisplay()
|
|||||||
if(isHidden())
|
if(isHidden())
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
setMinimumWidth(_max_width) ;
|
||||||
|
setMinimumHeight(_max_height) ;
|
||||||
|
|
||||||
update() ;
|
update() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +89,14 @@ void RSPermissionMatrixWidget::mousePressEvent(QMouseEvent *e)
|
|||||||
{
|
{
|
||||||
std::cerr << "Peer id: " << peer_id << ", service: " << service_id << std::endl;
|
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) ;
|
switchPermission(service_id,peer_id) ;
|
||||||
update() ;
|
update() ;
|
||||||
}
|
}
|
||||||
@ -273,7 +287,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
//_painter->drawRect(info_pos) ;
|
//_painter->drawRect(info_pos) ;
|
||||||
|
|
||||||
_painter->drawLine(QPointF(X,Y+3),QPointF(X+text_width,Y+3)) ;
|
_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) ;
|
pen.setBrush(Qt::black) ;
|
||||||
_painter->setPen(pen) ;
|
_painter->setPen(pen) ;
|
||||||
@ -378,11 +392,17 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
RsPeerServiceInfo pserv_info ;
|
RsPeerServiceInfo pserv_info ;
|
||||||
rsServiceControl->getServicesAllowed(_current_peer_id,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()) ;
|
const QFont& font(_painter->font()) ;
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
@ -423,6 +443,9 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
_painter->drawText(QPointF(x,y), local_status) ; y += line_height ;
|
_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 */
|
/* Stop the painter */
|
||||||
_painter->end();
|
_painter->end();
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,8 @@ private:
|
|||||||
/** A QPainter object that handles drawing the various graph elements. */
|
/** A QPainter object that handles drawing the various graph elements. */
|
||||||
QPainter* _painter;
|
QPainter* _painter;
|
||||||
QTimer *_timer ;
|
QTimer *_timer ;
|
||||||
|
int _max_width;
|
||||||
|
int _max_height;
|
||||||
|
|
||||||
/** The current dimensions of the graph. */
|
/** The current dimensions of the graph. */
|
||||||
QRect _rec;
|
QRect _rec;
|
||||||
|
@ -51,7 +51,14 @@ ServicePermissionsPage::ServicePermissionsPage(QWidget * parent, Qt::WindowFlags
|
|||||||
QString ServicePermissionsPage::helpText() const
|
QString ServicePermissionsPage::helpText() const
|
||||||
{
|
{
|
||||||
return tr("<h1><img width=\"24\" src=\":/images/64px_help.png\"> Permissions</h1> \
|
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>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 */
|
/** Saves the changes on this page */
|
||||||
|
@ -42,23 +42,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
|
||||||
<property name="widgetResizable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</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>
|
<item>
|
||||||
<widget class="RSPermissionMatrixWidget" name="frame">
|
<widget class="RSPermissionMatrixWidget" name="frame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -69,10 +60,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>RSPermissionMatrixWidget</class>
|
<class>RSPermissionMatrixWidget</class>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user