diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index f07f8c7b2..b1e9c5c63 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp @@ -220,7 +220,7 @@ bool sortRsPeerIdByNameLocation(const RsPeerId &a, const RsPeerId &b) return stringA.toLower() < stringB.toLower(); } -/** Overloads default QWidget::paintEvent. Draws the actual +/** Overloads default QWidget::paintEvent. Draws the actual * bandwidth graph. */ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) { @@ -230,14 +230,14 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) /* Set current graph dimensions */ _rec = this->frameRect(); - + /* Start the painter */ _painter->begin(this); - + /* We want antialiased lines and text */ _painter->setRenderHint(QPainter::Antialiasing); _painter->setRenderHint(QPainter::TextAntialiasing); - + /* Fill in the background */ _painter->fillRect(_rec, QBrush(BACK_COLOR)); _painter->drawRect(_rec); @@ -289,7 +289,8 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) rsPeers->getPeerDetails(*it,details) ; 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)+"..." ; peer_name_size = std::max(peer_name_size, fm.width(name)) ; @@ -298,7 +299,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) QPen pen ; pen.setWidth(2) ; - pen.setBrush(Qt::black) ; + pen.setBrush(FOREGROUND_COLOR) ; _painter->setPen(pen) ; int i=0; @@ -349,7 +350,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) pen.setWidth(2) ; if(_current_service_id == it->second.mServiceType) - pen.setBrush(Qt::black) ; + pen.setBrush(FOREGROUND_COLOR) ; else 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+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->drawText(QPointF(X,Y),name); @@ -496,11 +497,20 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) QPen pen ; pen.setWidth(2) ; - pen.setBrush(Qt::black) ; + pen.setBrush(FOREGROUND_COLOR) ; _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->drawRect(info_pos) ; diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h index 6dec86389..6b64150cb 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h @@ -33,11 +33,12 @@ #define HOR_SPC 2 /** Space between data points */ #define SCALE_WIDTH 75 /** Width of the scale */ -#define BACK_COLOR Qt::white -#define SCALE_COLOR Qt::black -#define GRID_COLOR Qt::lightGray -#define RSDHT_COLOR Qt::magenta -#define ALLDHT_COLOR Qt::yellow +#define BACK_COLOR Qt::white +#define FOREGROUND_COLOR Qt::black +#define SCALE_COLOR Qt::black +#define GRID_COLOR Qt::lightGray +#define RSDHT_COLOR Qt::magenta +#define ALLDHT_COLOR Qt::yellow #define FONT_SIZE 11