From: Jordan Lee Date: Thu, 3 Jan 2013 04:21:45 +0000 (+0000) Subject: (qt) tweak the network status icon's tooltip again. This is a followup to r13727 X-Git-Tag: 2.80~310 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08187ef98463c34d24d185485988330046bc88f7;p=transmission (qt) tweak the network status icon's tooltip again. This is a followup to r13727 --- diff --git a/qt/mainwin.cc b/qt/mainwin.cc index 330683048..b0fe87686 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -1326,38 +1326,38 @@ TrMainWindow :: removeTorrents( const bool deleteFiles ) void TrMainWindow :: updateNetworkIcon( ) { - const time_t now = time( NULL ); - const int period = 3; - const time_t secondsSinceLastSend = now - myLastSendTime; - const time_t secondsSinceLastRead = now - myLastReadTime; - const bool isSending = secondsSinceLastSend <= period; - const bool isReading = secondsSinceLastRead <= period; - const char * key; - - if( isSending && isReading ) - key = "network-transmit-receive"; - else if( isSending ) - key = "network-transmit"; - else if( isReading ) - key = "network-receive"; - else - key = "network-idle"; - - QIcon icon = getStockIcon( key, QStyle::SP_DriveNetIcon ); - QPixmap pixmap = icon.pixmap ( 16, 16 ); - myNetworkLabel->setPixmap( pixmap ); - - QString tip; - const QString url = mySession.getRemoteUrl().host(); - if( !myLastReadTime ) - tip = tr( "Server '%1' has not responded yet" ).arg (url); - else if( secondsSinceLastRead < 60 ) - tip = tr( "Server '%1' is responding" ).arg (url); - else if( secondsSinceLastRead < (60*10) ) - tip = tr( "Server '%1' last responded %2 ago" ).arg(url).arg(Formatter::timeToString(secondsSinceLastRead)); - else - tip = tr( "Server '%1' is not responding" ).arg (url); - myNetworkLabel->setToolTip (tip); + const time_t now = time( NULL ); + const int period = 3; + const time_t secondsSinceLastSend = now - myLastSendTime; + const time_t secondsSinceLastRead = now - myLastReadTime; + const bool isSending = secondsSinceLastSend <= period; + const bool isReading = secondsSinceLastRead <= period; + const char * key; + + if( isSending && isReading ) + key = "network-transmit-receive"; + else if( isSending ) + key = "network-transmit"; + else if( isReading ) + key = "network-receive"; + else + key = "network-idle"; + const QIcon icon = getStockIcon (key, QStyle::SP_DriveNetIcon); + const QPixmap pixmap = icon.pixmap (16, 16); + + QString tip; + const QString url = mySession.getRemoteUrl().host(); + if( !myLastReadTime ) + tip = tr( "%1 has not responded yet" ).arg (url); + else if( secondsSinceLastRead < 60 ) + tip = tr( "%1 is responding" ).arg (url); + else if( secondsSinceLastRead < (60*10) ) + tip = tr( "%1 last responded %2 ago" ).arg(url).arg(Formatter::timeToString(secondsSinceLastRead)); + else + tip = tr( "%1 is not responding" ).arg (url); + + myNetworkLabel->setPixmap (pixmap); + myNetworkLabel->setToolTip (tip); } void