Changeset 11234


Ignore:
Timestamp:
Sep 19, 2010, 5:33:25 PM (13 years ago)
Author:
charles
Message:

(trunk qt,gtk) #3549 "torrent properties window doesn't fix netbook screen" -- merge the "Uploaded" and "Ratio" rows to save a little vertical space

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r11216 r11234  
    6565    GtkWidget * dl_lb;
    6666    GtkWidget * ul_lb;
    67     GtkWidget * ratio_lb;
    6867    GtkWidget * error_lb;
    6968    GtkWidget * date_started_lb;
     
    861860        str = no_torrent;
    862861    else {
    863         uint64_t sum = 0;
    864         for( i=0; i<n; ++i ) sum += stats[i]->uploadedEver;
    865         str = tr_strlsize( buf, sum, sizeof( buf ) );
    866     }
    867     gtr_label_set_text( GTK_LABEL( di->ul_lb ), str );
    868 
    869 
    870     /* ratio */
    871     if( n <= 0 )
    872         str = no_torrent;
    873     else {
    874862        uint64_t up = 0;
    875863        uint64_t down = 0;
     864        char upstr[64];
     865        char ratiostr[64];
    876866        for( i=0; i<n; ++i ) {
    877867            up += stats[i]->uploadedEver;
    878868            down += stats[i]->downloadedEver;
    879869        }
    880         str = tr_strlratio( buf, tr_getRatio( up, down ), sizeof( buf ) );
    881     }
    882     gtr_label_set_text( GTK_LABEL( di->ratio_lb ), str );
     870        tr_strlsize( upstr, up, sizeof( upstr ) );
     871        tr_strlratio( ratiostr, tr_getRatio( up, down ), sizeof( ratiostr ) );
     872        g_snprintf( buf, sizeof( buf ), _( "%s (Ratio: %s)" ), upstr, ratiostr );
     873        str = buf;
     874    }
     875    gtr_label_set_text( GTK_LABEL( di->ul_lb ), str );
    883876
    884877    /* hash_lb */
     
    962955        l = di->ul_lb = gtk_label_new( NULL );
    963956        hig_workarea_add_row( t, &row, _( "Uploaded:" ), l, NULL );
    964 
    965         /* ratio */
    966         l = di->ratio_lb = gtk_label_new( NULL );
    967         hig_workarea_add_row( t, &row, _( "Ratio:" ), l, NULL );
    968957
    969958        /* state */
  • trunk/qt/details.cc

    r11222 r11234  
    4646#include <libtransmission/transmission.h>
    4747#include <libtransmission/bencode.h>
     48#include <libtransmission/utils.h> // tr_getRatio()
    4849
    4950#include "details.h"
     
    427428    myDownloadedLabel->setText( string );
    428429
    429     uint64_t u = 0;
    430     if( torrents.empty( ) )
    431         string = none;
    432     else {
    433         foreach( const Torrent * t, torrents ) u += t->uploadedEver( );
    434         string = QString( Formatter::sizeToString( u ) );
     430    if( torrents.empty( ) )
     431        string = none;
     432    else {
     433        uint64_t u = 0;
     434        uint64_t d = 0;
     435        foreach( const Torrent * t, torrents ) {
     436            u += t->uploadedEver( );
     437            d += t->downloadedEver( );
     438        }
     439        string = tr( "%1 (Ratio: %2)" )
     440                   .arg( Formatter::sizeToString( u ) )
     441                   .arg( Formatter::ratioToString( tr_getRatio( u, d ) ) );
    435442    }
    436443    myUploadedLabel->setText( string );
    437 
    438     if( torrents.empty( ) )
    439         string = none;
    440     else if( torrents.count() == 1 )
    441         string = Formatter::ratioToString( torrents.first()->ratio() );
    442     else {
    443         bool isMixed = false;
    444         int ratioType = (int) torrents.first()->ratio();
    445         if( ratioType > 0 ) ratioType = 0;
    446         foreach( const Torrent *t, torrents )
    447         {
    448             if( ratioType != ( t->ratio() >= 0 ? 0 : t->ratio() ) )
    449             {
    450                 isMixed = true;
    451                 break;
    452             }
    453         }
    454         if( isMixed )
    455             string = mixed;
    456         else if( ratioType < 0 )
    457             string = Formatter::ratioToString( ratioType );
    458         else
    459             string = Formatter::ratioToString( (double)u / d );
    460     }
    461     myRatioLabel->setText( string );
    462444
    463445    const QDateTime qdt_now = QDateTime::currentDateTime( );
     
    861843    hig->addRow( tr( "Downloaded:" ), myDownloadedLabel = new SqueezeLabel );
    862844    hig->addRow( tr( "Uploaded:" ), myUploadedLabel = new SqueezeLabel );
    863     hig->addRow( tr( "Ratio:" ), myRatioLabel = new SqueezeLabel );
    864845    hig->addRow( tr( "State:" ), myStateLabel = new SqueezeLabel );
    865846    hig->addRow( tr( "Running time:" ), myRunTimeLabel = new SqueezeLabel );
  • trunk/qt/details.h

    r11092 r11234  
    8484        QLabel * myDownloadedLabel;
    8585        QLabel * myUploadedLabel;
    86         QLabel * myRatioLabel;
    8786        QLabel * myErrorLabel;
    8887        QLabel * myRunTimeLabel;
Note: See TracChangeset for help on using the changeset viewer.