@ -55,12 +55,10 @@ StatusBar::StatusBar(QStatusBar *bar)
@@ -55,12 +55,10 @@ StatusBar::StatusBar(QStatusBar *bar)
connecStatusLblIcon = new QPushButton ( bar ) ;
connecStatusLblIcon - > setFlat ( true ) ;
connecStatusLblIcon - > setFocusPolicy ( Qt : : NoFocus ) ;
connecStatusLblIcon - > setFixedWidth ( 32 ) ;
connecStatusLblIcon - > setCursor ( Qt : : PointingHandCursor ) ;
connecStatusLblIcon - > setIcon ( QIcon ( " :/Icons/skin/firewalled.png " ) ) ;
connecStatusLblIcon - > setToolTip ( QString : : fromUtf8 ( " <b> " ) + tr ( " Connection status: " ) + QString : : fromUtf8 ( " </b><br> " ) + QString : : fromUtf8 ( " <i> " ) + tr ( " No direct connections. This may indicate network configuration problems. " ) + QString : : fromUtf8 ( " </i> " ) ) ;
dlSpeedLbl = new QPushButton ( bar ) ;
dlSpeedLbl - > setIconSize ( QSize ( 16 , 16 ) ) ;
dlSpeedLbl - > setIcon ( QIcon ( " :/Icons/skin/download.png " ) ) ;
//dlSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
connect ( dlSpeedLbl , SIGNAL ( clicked ( ) ) , this , SLOT ( capDownloadSpeed ( ) ) ) ;
@ -68,18 +66,7 @@ StatusBar::StatusBar(QStatusBar *bar)
@@ -68,18 +66,7 @@ StatusBar::StatusBar(QStatusBar *bar)
dlSpeedLbl - > setFocusPolicy ( Qt : : NoFocus ) ;
dlSpeedLbl - > setCursor ( Qt : : PointingHandCursor ) ;
altSpeedsBtn = new QPushButton ( bar ) ;
altSpeedsBtn - > setFixedWidth ( 36 ) ;
altSpeedsBtn - > setIconSize ( QSize ( 32 , 32 ) ) ;
altSpeedsBtn - > setFlat ( true ) ;
altSpeedsBtn - > setFocusPolicy ( Qt : : NoFocus ) ;
altSpeedsBtn - > setCursor ( Qt : : PointingHandCursor ) ;
updateAltSpeedsBtn ( pref - > isAltBandwidthEnabled ( ) ) ;
connect ( altSpeedsBtn , SIGNAL ( clicked ( ) ) , this , SLOT ( toggleAlternativeSpeeds ( ) ) ) ;
upSpeedLbl = new QPushButton ( bar ) ;
upSpeedLbl - > setIconSize ( QSize ( 16 , 16 ) ) ;
upSpeedLbl - > setIcon ( QIcon ( " :/Icons/skin/seeding.png " ) ) ;
//upSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
connect ( upSpeedLbl , SIGNAL ( clicked ( ) ) , this , SLOT ( capUploadSpeed ( ) ) ) ;
@ -88,20 +75,39 @@ StatusBar::StatusBar(QStatusBar *bar)
@@ -88,20 +75,39 @@ StatusBar::StatusBar(QStatusBar *bar)
upSpeedLbl - > setCursor ( Qt : : PointingHandCursor ) ;
DHTLbl = new QLabel ( tr ( " DHT: %1 nodes " ) . arg ( 0 ) , bar ) ;
DHTLbl - > setSizePolicy ( QSizePolicy : : Maximum , QSizePolicy : : Preferred ) ;
altSpeedsBtn = new QPushButton ( bar ) ;
altSpeedsBtn - > setFlat ( true ) ;
altSpeedsBtn - > setFocusPolicy ( Qt : : NoFocus ) ;
altSpeedsBtn - > setCursor ( Qt : : PointingHandCursor ) ;
updateAltSpeedsBtn ( pref - > isAltBandwidthEnabled ( ) ) ;
connect ( altSpeedsBtn , SIGNAL ( clicked ( ) ) , this , SLOT ( toggleAlternativeSpeeds ( ) ) ) ;
QRect labelRect = dlSpeedLbl - > fontMetrics ( ) . boundingRect ( " XX [0.000,0 XiX/s] 0.000,00 XiX/s (000,0 XiX) " ) ;
if ( labelRect . height ( ) < 26 )
labelRect . setHeight ( 26 ) ;
dlSpeedLbl - > setIconSize ( QSize ( 16 , 16 ) ) ;
upSpeedLbl - > setIconSize ( QSize ( 16 , 16 ) ) ;
connecStatusLblIcon - > setFixedHeight ( labelRect . height ( ) ) ;
altSpeedsBtn - > setIconSize ( QSize ( 30 , 30 ) ) ; // cut out blank parts
altSpeedsBtn - > setFixedHeight ( labelRect . height ( ) ) ;
dlSpeedLbl - > setMinimumSize ( labelRect . width ( ) , labelRect . height ( ) ) ;
upSpeedLbl - > setMinimumSize ( labelRect . width ( ) , labelRect . height ( ) ) ;
statusSep1 = new QFrame ( bar ) ;
statusSep1 - > setFixedSize ( 3 , dlSpeedLbl - > fontMetrics ( ) . height ( ) ) ;
statusSep1 - > setFixedSize ( 3 , labelRect . height ( ) ) ;
statusSep1 - > setFrameStyle ( QFrame : : VLine ) ;
statusSep1 - > setFrameShadow ( QFrame : : Raised ) ;
statusSep2 = new QFrame ( bar ) ;
statusSep2 - > setFixedSize ( 3 , dlSpeedLbl - > fontMetrics ( ) . height ( ) ) ;
statusSep2 - > setFixedSize ( 3 , labelRect . height ( ) ) ;
statusSep2 - > setFrameStyle ( QFrame : : VLine ) ;
statusSep2 - > setFrameShadow ( QFrame : : Raised ) ;
statusSep3 = new QFrame ( bar ) ;
statusSep3 - > setFixedSize ( 3 , dlSpeedLbl - > fontMetrics ( ) . height ( ) ) ;
statusSep3 - > setFixedSize ( 3 , labelRect . height ( ) ) ;
statusSep3 - > setFrameStyle ( QFrame : : VLine ) ;
statusSep3 - > setFrameShadow ( QFrame : : Raised ) ;
statusSep4 = new QFrame ( bar ) ;
statusSep4 - > setFixedSize ( 3 , dlSpeedLbl - > fontMetrics ( ) . height ( ) ) ;
statusSep4 - > setFixedSize ( 3 , labelRect . height ( ) ) ;
statusSep4 - > setFrameStyle ( QFrame : : VLine ) ;
statusSep4 - > setFrameShadow ( QFrame : : Raised ) ;
layout - > addWidget ( DHTLbl ) ;
@ -116,11 +122,9 @@ StatusBar::StatusBar(QStatusBar *bar)
@@ -116,11 +122,9 @@ StatusBar::StatusBar(QStatusBar *bar)
bar - > addPermanentWidget ( container ) ;
container - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Preferred ) ;
//bar->setStyleSheet("QWidget {padding-top: 0; padding-bottom: 0; margin-top: 0; margin-bottom: 0;}\n");
container - > setContentsMargins ( 0 , 0 , 0 , 1 ) ;
bar - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
container - > setFixedHeight ( dlSpeedLbl - > fontMetrics ( ) . height ( ) + 7 ) ;
bar - > setFixedHeight ( dlSpeedLbl - > fontMetrics ( ) . height ( ) + 9 ) ;
bar - > setStyleSheet ( " QWidget {padding: 0; margin: 0;} \n QPushButton {padding: 3px;} \n " ) ;
container - > adjustSize ( ) ;
bar - > adjustSize ( ) ;
// Is DHT enabled
DHTLbl - > setVisible ( pref - > isDHTEnabled ( ) ) ;
refreshTimer = new QTimer ( bar ) ;
@ -182,8 +186,16 @@ void StatusBar::refreshStatusBar() {
@@ -182,8 +186,16 @@ void StatusBar::refreshStatusBar() {
//statusSep1->setVisible(false);
}
// Update speed labels
dlSpeedLbl - > setText ( tr ( " %1/s " , " Per second " ) . arg ( misc : : friendlyUnit ( sessionStatus . payload_download_rate ) ) + " ( " + misc : : friendlyUnit ( sessionStatus . total_payload_download ) + " ) " ) ;
upSpeedLbl - > setText ( tr ( " %1/s " , " Per second " ) . arg ( misc : : friendlyUnit ( sessionStatus . payload_upload_rate ) ) + " ( " + misc : : friendlyUnit ( sessionStatus . total_payload_upload ) + " ) " ) ;
QString speedLbl = misc : : friendlyUnit ( sessionStatus . payload_download_rate , true ) + " ( " + misc : : friendlyUnit ( sessionStatus . total_payload_download ) + " ) " ;
int speedLimit = QBtSession : : instance ( ) - > getSession ( ) - > settings ( ) . download_rate_limit ;
if ( speedLimit )
speedLbl = " [ " + misc : : friendlyUnit ( speedLimit , true ) + " ] " + speedLbl ;
dlSpeedLbl - > setText ( speedLbl ) ;
speedLimit = QBtSession : : instance ( ) - > getSession ( ) - > settings ( ) . upload_rate_limit ;
speedLbl = misc : : friendlyUnit ( sessionStatus . payload_upload_rate , true ) + " ( " + misc : : friendlyUnit ( sessionStatus . total_payload_upload ) + " ) " ;
if ( speedLimit )
speedLbl = " [ " + misc : : friendlyUnit ( speedLimit , true ) + " ] " + speedLbl ;
upSpeedLbl - > setText ( speedLbl ) ;
}
void StatusBar : : updateAltSpeedsBtn ( bool alternative ) {
@ -196,6 +208,7 @@ void StatusBar::updateAltSpeedsBtn(bool alternative) {
@@ -196,6 +208,7 @@ void StatusBar::updateAltSpeedsBtn(bool alternative) {
altSpeedsBtn - > setToolTip ( tr ( " Click to switch to alternative speed limits " ) ) ;
altSpeedsBtn - > setDown ( false ) ;
}
refreshStatusBar ( ) ;
}
void StatusBar : : toggleAlternativeSpeeds ( ) {
@ -225,6 +238,7 @@ void StatusBar::capDownloadSpeed() {
@@ -225,6 +238,7 @@ void StatusBar::capDownloadSpeed() {
if ( ! alt )
pref - > setGlobalDownloadLimit ( new_limit / 1024. ) ;
}
refreshStatusBar ( ) ;
}
}
@ -246,5 +260,6 @@ void StatusBar::capUploadSpeed() {
@@ -246,5 +260,6 @@ void StatusBar::capUploadSpeed() {
if ( ! alt )
Preferences : : instance ( ) - > setGlobalUploadLimit ( new_limit / 1024. ) ;
}
refreshStatusBar ( ) ;
}
}