mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-28 00:07:09 -05:00
Merge pull request #1480 from chelovechishko/rspmw
rspermissionmatrixwidget fixes
This commit is contained in:
commit
c4f951fe5e
@ -220,7 +220,7 @@ bool sortRsPeerIdByNameLocation(const RsPeerId &a, const RsPeerId &b)
|
|||||||
return stringA.toLower() < stringB.toLower();
|
return stringA.toLower() < stringB.toLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Overloads default QWidget::paintEvent. Draws the actual
|
/** Overloads default QWidget::paintEvent. Draws the actual
|
||||||
* bandwidth graph. */
|
* bandwidth graph. */
|
||||||
void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
@ -230,14 +230,14 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
|
|
||||||
/* Set current graph dimensions */
|
/* Set current graph dimensions */
|
||||||
_rec = this->frameRect();
|
_rec = this->frameRect();
|
||||||
|
|
||||||
/* Start the painter */
|
/* Start the painter */
|
||||||
_painter->begin(this);
|
_painter->begin(this);
|
||||||
|
|
||||||
/* We want antialiased lines and text */
|
/* We want antialiased lines and text */
|
||||||
_painter->setRenderHint(QPainter::Antialiasing);
|
_painter->setRenderHint(QPainter::Antialiasing);
|
||||||
_painter->setRenderHint(QPainter::TextAntialiasing);
|
_painter->setRenderHint(QPainter::TextAntialiasing);
|
||||||
|
|
||||||
/* Fill in the background */
|
/* Fill in the background */
|
||||||
_painter->fillRect(_rec, QBrush(BACK_COLOR));
|
_painter->fillRect(_rec, QBrush(BACK_COLOR));
|
||||||
_painter->drawRect(_rec);
|
_painter->drawRect(_rec);
|
||||||
@ -289,7 +289,8 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
rsPeers->getPeerDetails(*it,details) ;
|
rsPeers->getPeerDetails(*it,details) ;
|
||||||
|
|
||||||
QString name = QString::fromUtf8(details.name.c_str()) + " (" + QString::fromUtf8(details.location.c_str()) + ")";
|
QString name = QString::fromUtf8(details.name.c_str()) + " (" + QString::fromUtf8(details.location.c_str()) + ")";
|
||||||
if(name.length() > 20)
|
// TODO does not work correctly with hieroglyphs
|
||||||
|
if(name.length() > 20 + 3)
|
||||||
name = name.left(20)+"..." ;
|
name = name.left(20)+"..." ;
|
||||||
|
|
||||||
peer_name_size = std::max(peer_name_size, fm.width(name)) ;
|
peer_name_size = std::max(peer_name_size, fm.width(name)) ;
|
||||||
@ -298,7 +299,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
|
|
||||||
QPen pen ;
|
QPen pen ;
|
||||||
pen.setWidth(2) ;
|
pen.setWidth(2) ;
|
||||||
pen.setBrush(Qt::black) ;
|
pen.setBrush(FOREGROUND_COLOR) ;
|
||||||
|
|
||||||
_painter->setPen(pen) ;
|
_painter->setPen(pen) ;
|
||||||
int i=0;
|
int i=0;
|
||||||
@ -349,7 +350,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
pen.setWidth(2) ;
|
pen.setWidth(2) ;
|
||||||
|
|
||||||
if(_current_service_id == it->second.mServiceType)
|
if(_current_service_id == it->second.mServiceType)
|
||||||
pen.setBrush(Qt::black) ;
|
pen.setBrush(FOREGROUND_COLOR) ;
|
||||||
else
|
else
|
||||||
pen.setBrush(Qt::gray) ;
|
pen.setBrush(Qt::gray) ;
|
||||||
|
|
||||||
@ -363,7 +364,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
_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,S*fMATRIX_START_Y+peer_ids.size()*S*fROW_SIZE - S*fROW_SIZE+5)) ;
|
_painter->drawLine(QPointF(X+text_width/2, Y+3), QPointF(X+text_width/2,S*fMATRIX_START_Y+peer_ids.size()*S*fROW_SIZE - S*fROW_SIZE+5)) ;
|
||||||
|
|
||||||
pen.setBrush(Qt::black) ;
|
pen.setBrush(FOREGROUND_COLOR) ;
|
||||||
_painter->setPen(pen) ;
|
_painter->setPen(pen) ;
|
||||||
|
|
||||||
_painter->drawText(QPointF(X,Y),name);
|
_painter->drawText(QPointF(X,Y),name);
|
||||||
@ -496,11 +497,20 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *)
|
|||||||
|
|
||||||
QPen pen ;
|
QPen pen ;
|
||||||
pen.setWidth(2) ;
|
pen.setWidth(2) ;
|
||||||
pen.setBrush(Qt::black) ;
|
pen.setBrush(FOREGROUND_COLOR) ;
|
||||||
|
|
||||||
_painter->setPen(pen) ;
|
_painter->setPen(pen) ;
|
||||||
|
|
||||||
QRect info_pos( position.x() + 50*S/14.0, position.y() - 10*S/14.0, text_size_x + 10*S/14.0, line_height * 5 + 5*S/14.0) ;
|
int popup_x = position.x() + (50 * S / 14.0);
|
||||||
|
int popup_y = position.y() - (10 * S / 14.0);
|
||||||
|
int popup_width = text_size_x + (10 * S / 14.0);
|
||||||
|
int popup_height = (line_height * 5) + (5 * S / 14.0);
|
||||||
|
if (popup_x + popup_width > _max_width)
|
||||||
|
popup_x = position.x() - popup_width;
|
||||||
|
if (popup_y + popup_height > _max_height)
|
||||||
|
popup_y -= popup_height;
|
||||||
|
|
||||||
|
QRect info_pos(popup_x, popup_y, popup_width, popup_height) ;
|
||||||
|
|
||||||
_painter->fillRect(info_pos,brush) ;
|
_painter->fillRect(info_pos,brush) ;
|
||||||
_painter->drawRect(info_pos) ;
|
_painter->drawRect(info_pos) ;
|
||||||
|
@ -33,11 +33,12 @@
|
|||||||
#define HOR_SPC 2 /** Space between data points */
|
#define HOR_SPC 2 /** Space between data points */
|
||||||
#define SCALE_WIDTH 75 /** Width of the scale */
|
#define SCALE_WIDTH 75 /** Width of the scale */
|
||||||
|
|
||||||
#define BACK_COLOR Qt::white
|
#define BACK_COLOR Qt::white
|
||||||
#define SCALE_COLOR Qt::black
|
#define FOREGROUND_COLOR Qt::black
|
||||||
#define GRID_COLOR Qt::lightGray
|
#define SCALE_COLOR Qt::black
|
||||||
#define RSDHT_COLOR Qt::magenta
|
#define GRID_COLOR Qt::lightGray
|
||||||
#define ALLDHT_COLOR Qt::yellow
|
#define RSDHT_COLOR Qt::magenta
|
||||||
|
#define ALLDHT_COLOR Qt::yellow
|
||||||
|
|
||||||
#define FONT_SIZE 11
|
#define FONT_SIZE 11
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user