diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.cpp b/retroshare-gui/src/gui/common/RSGraphWidget.cpp index d2b36727f..3bef7f3b9 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.cpp +++ b/retroshare-gui/src/gui/common/RSGraphWidget.cpp @@ -235,6 +235,9 @@ RSGraphWidget::RSGraphWidget(QWidget *parent) _y_scale = 1.0f ; _timer->start(1000); + + float FS = QFontMetricsF(font()).height(); + setMinimumHeight(12*FS); } void RSGraphWidget::updateIfPossible() @@ -320,6 +323,22 @@ void RSGraphWidget::paintEvent(QPaintEvent *) _painter->end(); } +QSizeF RSGraphWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + float FS = QFontMetricsF(font()).height(); + float fact = FS/14.0 ; + + switch(which) + { +defaut: + case Qt::MinimumSize: + case Qt::PreferredSize: + return QSizeF(70*FS,12*FS); + case Qt::MaximumSize: + return QSizeF(700*FS,120*FS); + } +} + QColor RSGraphWidget::getColor(int i) { // shuffle the colors a little bit @@ -598,7 +617,7 @@ void RSGraphWidget::paintLegend() QPen oldPen = _painter->pen(); _painter->setPen(QPen(getColor(i), Qt::SolidLine)); - _painter->drawLine(QPointF(SCALE_WIDTH*fact+10.0*fact, pos), QPointF(SCALE_WIDTH*fact+30.0*fact, pos)); + _painter->drawLine(QPointF(SCALE_WIDTH*fact+10.0*fact, pos+FS/3), QPointF(SCALE_WIDTH*fact+30.0*fact, pos+FS/3)); _painter->setPen(oldPen); _painter->setPen(SCALE_COLOR); diff --git a/retroshare-gui/src/gui/common/RSGraphWidget.h b/retroshare-gui/src/gui/common/RSGraphWidget.h index 5f6c18b39..fb05da67d 100644 --- a/retroshare-gui/src/gui/common/RSGraphWidget.h +++ b/retroshare-gui/src/gui/common/RSGraphWidget.h @@ -153,6 +153,8 @@ class RSGraphWidget: public QFrame /** Overloaded QWidget::paintEvent() */ void paintEvent(QPaintEvent *event); + virtual QSizeF sizeHint( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; + protected slots: void updateIfPossible() ; diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp index e70d4266f..f937ea502 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.cpp @@ -35,6 +35,7 @@ #include "retroshare/rspeers.h" #include +#include #include #include @@ -166,12 +167,15 @@ void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti painter->restore(); } -QSize BWListDelegate::sizeHint(const QStyleOptionViewItem & option/*option*/, const QModelIndex & /*index*/) const +QSize BWListDelegate::sizeHint(const QStyleOptionViewItem & option/*option*/, const QModelIndex & index) const { float FS = QFontMetricsF(option.font).height(); float fact = FS/14.0 ; - return QSize(50*fact,17*fact); + float w = QFontMetricsF(option.font).width(index.data(Qt::DisplayRole).toString()); + + return QSize(w,FS*1.2); + //return QSize(50*fact,17*fact); } BwCtrlWindow::BwCtrlWindow(QWidget *parent) @@ -187,7 +191,8 @@ BwCtrlWindow::BwCtrlWindow(QWidget *parent) /* Set header resize modes and initial section sizes Peer TreeView*/ QHeaderView * _header = bwTreeWidget->header () ; - _header->resizeSection ( COLUMN_RSNAME, 170*fact ); +// _header->resizeSection ( COLUMN_RSNAME, 170*fact ); + _header->setResizeMode(QHeaderView::ResizeToContents); } BwCtrlWindow::~BwCtrlWindow() diff --git a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui index 725e95e41..55fb7a04b 100644 --- a/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui +++ b/retroshare-gui/src/gui/statistics/BwCtrlWindow.ui @@ -90,12 +90,6 @@ - - - 120 - 80 - - Qt::NoContextMenu diff --git a/retroshare-gui/src/gui/statistics/DhtWindow.cpp b/retroshare-gui/src/gui/statistics/DhtWindow.cpp index 5dd531491..9087b8b85 100644 --- a/retroshare-gui/src/gui/statistics/DhtWindow.cpp +++ b/retroshare-gui/src/gui/statistics/DhtWindow.cpp @@ -75,6 +75,10 @@ void DhtWindow::updateDisplay() updateRelays(); RsAutoUpdatePage::unlockAllEvents() ; + + ui.peerTreeWidget->header()->setResizeMode(QHeaderView::ResizeToContents); + ui.dhtTreeWidget->header()->setResizeMode(QHeaderView::ResizeToContents); + ui.relayTreeWidget->header()->setResizeMode(QHeaderView::ResizeToContents); } diff --git a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp index 52508673d..ea48a2727 100644 --- a/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/GlobalRouterStatistics.cpp @@ -115,7 +115,10 @@ QString GlobalRouterStatistics::getPeerName(const RsPeerId &peer_id) GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent) : QWidget(parent) { - maxWidth = 400 ; + float size = QFontMetricsF(font()).height() ; + float fact = size/14.0 ; + + maxWidth = 400*fact ; maxHeight = 0 ; } @@ -127,6 +130,9 @@ void GlobalRouterStatisticsWidget::updateContent() rsGRouter->getRoutingCacheInfo(cache_infos) ; rsGRouter->getRoutingMatrixInfo(matrix_info) ; + float size = QFontMetricsF(font()).height() ; + float fact = size/14.0 ; + // What do we need to draw? // // Routing matrix @@ -149,21 +155,21 @@ void GlobalRouterStatisticsWidget::updateContent() painter.initFrom(this); painter.setPen(QColor::fromRgb(0,0,0)) ; - QFont times_f("Times") ; - QFont monospace_f("Monospace") ; + QFont times_f(font());//"Times") ; + QFont monospace_f(font());//"Monospace") ; monospace_f.setStyleHint(QFont::TypeWriter) ; - QFontMetrics fm_monospace(monospace_f) ; - QFontMetrics fm_times(times_f) ; + QFontMetricsF fm_monospace(monospace_f) ; + QFontMetricsF fm_times(times_f) ; static const int cellx = fm_monospace.width(QString(" ")) ; static const int celly = fm_monospace.height() ; - maxHeight = 500 ; + maxHeight = 500*fact ; // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; // draw... - int ox=5,oy=5 ; + int ox=5*fact,oy=5*fact ; painter.setFont(times_f) ; @@ -226,7 +232,7 @@ void GlobalRouterStatisticsWidget::updateContent() // now compute max column sizes for(int j=0;j >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it) diff --git a/retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp b/retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp index e01ff6fc4..9985d5cf9 100644 --- a/retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/OutQueueStatistics.cpp @@ -11,7 +11,10 @@ OutQueueStatisticsWidget::OutQueueStatisticsWidget(QWidget *parent) : QWidget(parent) { - maxWidth = 200 ; + float fontHeight = QFontMetricsF(font()).height(); + float fact = fontHeight/14.0; + + maxWidth = 200*fact ; maxHeight = 0 ; } diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp index 9dea5ba16..7b432e597 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterStatistics.cpp @@ -196,6 +196,11 @@ TurtleRouterStatistics::TurtleRouterStatistics(QWidget *parent) _tunnel_statistics_F->setFocusPolicy(Qt::NoFocus); routertabWidget->addTab(new TurtleRouterDialog(),QString(tr("Tunnel Requests"))); + + + float fontHeight = QFontMetricsF(font()).height(); + float fact = fontHeight/14.0; + frmGraph->setMinimumHeight(200*fact); // load settings processSettings(true);