From 344e4bedc5bab9924e1da0bb6fe49bbc296300a2 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 31 Jul 2010 06:20:17 +0000 Subject: [PATCH] (trunk) set minimum widths for the upload/download labels in the statusbar --- gtk/tr-window.c | 8 +++++--- qt/mainwin.cc | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gtk/tr-window.c b/gtk/tr-window.c index 32437cb73..bbeb2073b 100644 --- a/gtk/tr-window.c +++ b/gtk/tr-window.c @@ -728,10 +728,12 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core ) } { - int w=0, h=0; /* this is to determine the maximum width/height for the label */ - PangoLayout * pango_layout = - gtk_widget_create_pango_layout( p->ul_lb, _( "999.99 KiB/s" ) ); + int w=0, h=0; + char buf[64]; + PangoLayout * pango_layout; + tr_formatter_speed_KBps( buf, 999.99, sizeof( buf ) ); + pango_layout = gtk_widget_create_pango_layout( p->ul_lb, buf ); pango_layout_get_pixel_size( pango_layout, &w, &h ); gtk_widget_set_size_request( p->ul_lb, w, h ); gtk_widget_set_size_request( p->dl_lb, w, h ); diff --git a/qt/mainwin.cc b/qt/mainwin.cc index d063a7165..405d2dc87 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -425,6 +425,9 @@ TrMainWindow :: createStatusBar( ) w->setMaximumSize( HIG::PAD_BIG, 1 ); h->addWidget( w ); l = myDownloadSpeedLabel = new QLabel( this ); + const int minimumSpeedWidth = l->fontMetrics().width( Formatter::speedToString(Speed::fromKBps(999.99))); + l->setMinimumWidth( minimumSpeedWidth ); + l->setAlignment( Qt::AlignRight|Qt::AlignVCenter ); h->addWidget( l ); l = new QLabel( this ); l->setPixmap( getStockIcon( "go-down", QStyle::SP_ArrowDown ).pixmap( smallIconSize ) ); @@ -437,6 +440,8 @@ TrMainWindow :: createStatusBar( ) w->setMaximumSize( HIG::PAD_BIG, 1 ); h->addWidget( w ); l = myUploadSpeedLabel = new QLabel; + l->setMinimumWidth( minimumSpeedWidth ); + l->setAlignment( Qt::AlignRight|Qt::AlignVCenter ); h->addWidget( l ); l = new QLabel; l->setPixmap( getStockIcon( "go-up", QStyle::SP_ArrowUp ).pixmap( smallIconSize ) ); -- 2.40.0