From 55ff0181661e91208d0ed119b63085904bc41dcf Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Sat, 16 Feb 2019 23:32:00 +0900 Subject: [PATCH 1/3] gui: rspermissionmatrixwidget: fix name.length check with proper number --- .../src/gui/settings/RSPermissionMatrixWidget.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index f07f8c7b2..d7c623d7a 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)) ; From 209e1541ff09fb50f3cc25ad89f7a261cebe0c37 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Sun, 17 Feb 2019 18:36:09 +0900 Subject: [PATCH 2/3] gui: rspermissionmatrixwidget: use define for qt::black --- .../src/gui/settings/RSPermissionMatrixWidget.cpp | 8 ++++---- .../src/gui/settings/RSPermissionMatrixWidget.h | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index d7c623d7a..16901692d 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp @@ -299,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; @@ -350,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) ; @@ -364,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); @@ -497,7 +497,7 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) QPen pen ; pen.setWidth(2) ; - pen.setBrush(Qt::black) ; + pen.setBrush(FOREGROUND_COLOR) ; _painter->setPen(pen) ; 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 From 32e18c7f71ce9ac03e46afcdeb1228d54bc7b4dd Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Mon, 18 Feb 2019 20:53:36 +0900 Subject: [PATCH 3/3] gui: rspermissionmatrixwidget: draw permission popup to the left of the cursor instead of beyond the edge of screen --- .../src/gui/settings/RSPermissionMatrixWidget.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index 16901692d..b1e9c5c63 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp @@ -501,7 +501,16 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) _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) ;