further improvements to layouts and sizes for high DPI screens

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8554 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-06-25 20:11:39 +00:00
parent 7334e4d5de
commit 7d541318b3
8 changed files with 65 additions and 27 deletions

View File

@ -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);

View File

@ -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() ;

View File

@ -35,6 +35,7 @@
#include "retroshare/rspeers.h"
#include <QModelIndex>
#include <QHeaderView>
#include <QPainter>
#include <limits>
@ -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()

View File

@ -90,12 +90,6 @@
</property>
<widget class="OutQueueStatisticsWidget" name="_outqueue_stats_W" native="true"/>
<widget class="BWGraph" name="frmGraph" native="true">
<property name="minimumSize">
<size>
<width>120</width>
<height>80</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>

View File

@ -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);
}

View File

@ -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<nb_fields;++j)
max_column_width[j] = std::max(max_column_width[j],fm_monospace.width(strings[j])) ;
max_column_width[j] = std::max(max_column_width[j],(int)(fm_monospace.boundingRect(strings[j]).width()+cellx+2*fact)) ;
}
// compute cumulated sizes
@ -235,7 +241,7 @@ void GlobalRouterStatisticsWidget::updateContent()
for(int i=1;i<=nb_fields;++i)
{
cumulated_sizes[i] = std::max(max_column_width[i-1],fm_monospace.width(fname[i-1])) ;
cumulated_sizes[i] = std::max(max_column_width[i-1],(int)(fm_monospace.boundingRect(fname[i-1]).width()+cellx+2*fact)) ;
cumulated_sizes[i] += cumulated_sizes[i-1] ;
}
@ -247,7 +253,7 @@ void GlobalRouterStatisticsWidget::updateContent()
painter.drawLine(ox,oy,ox+cumulated_sizes.back(),oy) ;
int top_matrix_oy = oy ;
oy += celly +2;
oy += celly +2*fact;
painter.drawLine(ox,oy,ox+cumulated_sizes.back(),oy) ;
@ -259,7 +265,7 @@ void GlobalRouterStatisticsWidget::updateContent()
oy += celly ;
}
oy += 2;
oy += 2*fact;
for(int i=0;i<=nb_fields;++i)
painter.drawLine(ox+cumulated_sizes[i],top_matrix_oy,ox+cumulated_sizes[i],oy) ;
@ -275,19 +281,19 @@ void GlobalRouterStatisticsWidget::updateContent()
// draw scale
for(int i=0;i<100;++i)
for(int i=0;i<100*fact;++i)
{
painter.setPen(colorScale(i/100.0)) ;
painter.drawLine(fm_times.width(Q)+i,oy+celly+2,fm_times.width(Q)+i,oy+2) ;
painter.setPen(colorScale(i/100.0/fact)) ;
painter.drawLine(ox+fm_times.width(Q)+i,oy+fm_times.height()*0.5,ox+fm_times.width(Q)+i,oy+fm_times.height()) ;
}
painter.setPen(QColor::fromRgb(0,0,0)) ;
painter.drawText(ox+fm_times.width(Q) + 100,oy+celly,")") ;
painter.drawText(ox+fm_times.width(Q) + 102*fact,oy+celly,")") ;
oy += celly ;
oy += celly ;
static const int MaxKeySize = 20 ;
static const int MaxKeySize = 20*fact ;
painter.setFont(monospace_f) ;
for(std::map<GRouterKeyId,std::vector<float> >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it)

View File

@ -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 ;
}

View File

@ -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);