91
92
systemTheme.name = i18n( "System Theme" );
92
93
systemTheme.comment = i18n( "Use the current icon theme's network status icons" );
93
94
systemTheme.internalName = SYSTEM_THEME;
97
textTheme.name = i18n( "Text" );
98
textTheme.comment = i18n( "KNemo theme that shows the upload/download speed as text" );
99
textTheme.internalName = TEXT_THEME;
101
KNemoTheme netloadTheme;
102
netloadTheme.name = i18n( "Netload" );
103
netloadTheme.comment = i18n( "KNemo theme that shows the upload/download speed as bar graphs" );
104
netloadTheme.internalName = NETLOAD_THEME;
94
106
// Leave this out for now. Looks like none of the KDE icon themes provide
95
107
// status/network-* icons.
96
108
//mDlg->comboBoxIconTheme->addItem( systemTheme.name, QVariant::fromValue( systemTheme ) );
98
textTheme.name = i18n( "Text Icon" );
99
textTheme.comment = i18n( "KNemo theme that shows text of upload/download speed" );
100
textTheme.internalName = TEXT_THEME;
109
mDlg->comboBoxIconTheme->addItem( netloadTheme.name, QVariant::fromValue( netloadTheme ) );
101
110
mDlg->comboBoxIconTheme->addItem( textTheme.name, QVariant::fromValue( textTheme ) );
103
112
InterfaceSettings s;
148
150
this, SLOT( aliasChanged( const QString& ) ) );
150
152
// Interface - Icon Appearance
151
connect( mDlg->checkBoxDisconnected, SIGNAL( toggled( bool ) ),
152
this, SLOT( checkBoxDisconnectedToggled ( bool ) ) );
153
connect( mDlg->checkBoxUnavailable, SIGNAL( toggled( bool ) ),
154
this, SLOT( checkBoxUnavailableToggled ( bool ) ) );
155
connect( mDlg->spinBoxTrafficThreshold, SIGNAL( valueChanged( int ) ),
156
this, SLOT( spinBoxTrafficValueChanged ( int ) ) );
153
connect( mDlg->comboHiding, SIGNAL( activated( int ) ),
154
this, SLOT( comboHidingChanged( int ) ) );
157
155
connect( mDlg->comboBoxIconTheme, SIGNAL( activated( int ) ),
158
156
this, SLOT( iconThemeChanged( int ) ) );
159
157
connect( mDlg->colorIncoming, SIGNAL( changed( const QColor& ) ),
272
270
KColorScheme scheme(QPalette::Active, KColorScheme::View);
273
271
settings->colorDisabled = interfaceGroup.readEntry( conf_colorDisabled, scheme.foreground( KColorScheme::InactiveText ).color() );
274
272
settings->colorUnavailable = interfaceGroup.readEntry( conf_colorUnavailable, scheme.foreground( KColorScheme::InactiveText ).color() );
273
settings->dynamicColor = interfaceGroup.readEntry( conf_dynamicColor, s.dynamicColor );
274
settings->colorIncomingMax = interfaceGroup.readEntry( conf_colorIncomingMax, s.colorIncomingMax );
275
settings->colorOutgoingMax = interfaceGroup.readEntry( conf_colorOutgoingMax, s.colorOutgoingMax );
276
settings->barScale = interfaceGroup.readEntry( conf_barScale, s.barScale );
277
settings->inMaxRate = interfaceGroup.readEntry( conf_inMaxRate, s.inMaxRate );
278
settings->outMaxRate = interfaceGroup.readEntry( conf_outMaxRate, s.outMaxRate );
275
279
settings->activateStatistics = interfaceGroup.readEntry( conf_activateStatistics, s.activateStatistics );
276
280
settings->customBilling = interfaceGroup.readEntry( conf_customBilling, s.customBilling );
277
281
settings->calendar = interfaceGroup.readEntry( conf_calendar, mDefaultCalendarType );
411
414
interfaceGroup.writeEntry( conf_hideWhenNotExist, settings->hideWhenUnavailable );
412
415
interfaceGroup.writeEntry( conf_trafficThreshold, settings->trafficThreshold );
413
416
interfaceGroup.writeEntry( conf_iconTheme, settings->iconTheme );
414
if ( settings->iconTheme == TEXT_THEME )
417
if ( settings->iconTheme == TEXT_THEME ||
418
settings->iconTheme == NETLOAD_THEME
416
421
interfaceGroup.writeEntry( conf_colorIncoming, settings->colorIncoming );
417
422
interfaceGroup.writeEntry( conf_colorOutgoing, settings->colorOutgoing );
418
423
interfaceGroup.writeEntry( conf_colorDisabled, settings->colorDisabled );
419
424
interfaceGroup.writeEntry( conf_colorUnavailable, settings->colorUnavailable );
425
interfaceGroup.writeEntry( conf_dynamicColor, settings->dynamicColor );
426
if ( settings->dynamicColor )
428
interfaceGroup.writeEntry( conf_colorIncomingMax, settings->colorIncomingMax );
429
interfaceGroup.writeEntry( conf_colorOutgoingMax, settings->colorOutgoingMax );
431
if ( settings->iconTheme == NETLOAD_THEME )
433
interfaceGroup.writeEntry( conf_barScale, settings->barScale );
435
if ( settings->dynamicColor ||
436
( settings->iconTheme == NETLOAD_THEME && settings->barScale )
439
interfaceGroup.writeEntry( conf_inMaxRate, settings->inMaxRate );
440
interfaceGroup.writeEntry( conf_outMaxRate, settings->outMaxRate );
421
443
interfaceGroup.writeEntry( conf_activateStatistics, settings->activateStatistics );
422
444
interfaceGroup.writeEntry( conf_customBilling, settings->customBilling );
595
616
mDlg->colorOutgoing->setColor( settings->colorOutgoing );
596
617
mDlg->colorDisabled->setColor( settings->colorDisabled );
597
618
mDlg->colorUnavailable->setColor( settings->colorUnavailable );
598
mDlg->checkBoxCustom->setChecked( settings->customCommands );
599
mDlg->checkBoxDisconnected->setChecked( settings->hideWhenDisconnected );
600
mDlg->checkBoxUnavailable->setChecked( settings->hideWhenUnavailable );
619
if ( settings->hideWhenDisconnected )
621
else if ( settings->hideWhenUnavailable )
625
mDlg->comboHiding->setCurrentIndex( index );
626
comboHidingChanged( index );
601
627
mDlg->checkBoxStatistics->setChecked( settings->activateStatistics );
602
628
mDlg->warnThreshold->setValue( settings->warnThreshold );
603
629
if ( settings->warnTotalTraffic )
824
860
return sampleIcon;
827
void ConfigDialog::checkBoxDisconnectedToggled( bool on )
829
InterfaceSettings* settings = getItemSettings();
833
settings->hideWhenDisconnected = on;
834
if (!mLock) changed( true );
837
void ConfigDialog::checkBoxUnavailableToggled( bool on )
839
InterfaceSettings* settings = getItemSettings();
843
settings->hideWhenUnavailable = on;
844
if (!mLock) changed( true );
847
void ConfigDialog::spinBoxTrafficValueChanged( int value )
849
InterfaceSettings* settings = getItemSettings();
853
settings->trafficThreshold = value;
863
QPixmap ConfigDialog::barIcon( int status )
867
QPixmap barIcon( 22, 22 );
868
barIcon.fill( Qt::transparent );
869
QPainter p( &barIcon );
871
QLinearGradient inGrad( 12, 0, 19, 0 );
872
QLinearGradient topInGrad( 12, 0, 19, 0 );
873
QLinearGradient outGrad( 3, 0, 10, 0 );
874
QLinearGradient topOutGrad( 3, 0, 10, 0 );
876
QColor topColor = mDlg->colorUnavailable->color();
877
QColor topColorD = mDlg->colorUnavailable->color().darker();
878
topColor.setAlpha( 128 );
879
topColorD.setAlpha( 128 );
880
topInGrad.setColorAt(0, topColorD);
881
topInGrad.setColorAt(1, topColor );
882
topOutGrad.setColorAt(0, topColorD);
883
topOutGrad.setColorAt(1, topColor );
885
if ( status & KNemoIface::Connected )
887
inGrad.setColorAt(0, mDlg->colorIncoming->color() );
888
inGrad.setColorAt(1, mDlg->colorIncoming->color().darker() );
889
outGrad.setColorAt(0, mDlg->colorOutgoing->color() );
890
outGrad.setColorAt(1, mDlg->colorOutgoing->color().darker() );
892
else if ( status & KNemoIface::Available )
894
inGrad.setColorAt(0, mDlg->colorDisabled->color());
895
inGrad.setColorAt(1, mDlg->colorDisabled->color().darker() );
896
outGrad.setColorAt(0, mDlg->colorDisabled->color() );
897
outGrad.setColorAt(1, mDlg->colorDisabled->color().darker() );
901
inGrad.setColorAt(0, mDlg->colorUnavailable->color() );
902
inGrad.setColorAt(1, mDlg->colorUnavailable->color().darker() );
903
outGrad.setColorAt(0, mDlg->colorUnavailable->color() );
904
outGrad.setColorAt(1, mDlg->colorUnavailable->color().darker() );
906
if ( status & KNemoIface::Available || status & KNemoIface::Unavailable )
911
if ( status & KNemoIface::RxTraffic )
913
if ( status & KNemoIface::TxTraffic )
916
int top = 22 - barOutgoing;
917
QRect topLeftRect( 3, 0, 7, top );
918
QRect leftRect( 3, top, 7, 22 );
919
top = 22 - barIncoming;
920
QRect topRightRect( 12, 0, 7, top );
921
QRect rightRect( 12, top, 7, 22 );
923
QBrush brush( inGrad );
925
p.fillRect( rightRect, inGrad );
926
brush = QBrush( topInGrad );
927
p.fillRect( topRightRect, topInGrad );
928
brush = QBrush( outGrad );
929
p.fillRect( leftRect, outGrad );
930
brush = QBrush( topOutGrad );
931
p.fillRect( topLeftRect, topOutGrad );
935
void ConfigDialog::comboHidingChanged( int val )
937
InterfaceSettings* settings = getItemSettings();
944
settings->hideWhenDisconnected = false;
945
settings->hideWhenUnavailable = false;
948
settings->hideWhenDisconnected = true;
949
settings->hideWhenUnavailable = true;
952
settings->hideWhenDisconnected = false;
953
settings->hideWhenUnavailable = true;
854
957
if (!mLock) changed( true );
863
966
KNemoTheme curTheme = mDlg->comboBoxIconTheme->itemData( mDlg->comboBoxIconTheme->currentIndex() ).value<KNemoTheme>();
864
if ( curTheme.internalName == TEXT_THEME )
967
if ( curTheme.internalName == TEXT_THEME ||
968
curTheme.internalName == NETLOAD_THEME )
866
settings->iconTheme = TEXT_THEME;
867
mDlg->pixmapError->setPixmap( textIcon( "0.0K", "0.0K", KNemoIface::Unavailable ) );
868
mDlg->pixmapDisconnected->setPixmap( textIcon( "0.0K", "0.0K", KNemoIface::Available ) );
869
mDlg->pixmapConnected->setPixmap( textIcon( "0.0K", "0.0K", KNemoIface::Connected ) );
870
mDlg->pixmapIncoming->setPixmap( textIcon( "123K", "0.0K", KNemoIface::Connected ) );
871
mDlg->pixmapOutgoing->setPixmap( textIcon( "0.0K", "12K", KNemoIface::Connected ) );
872
mDlg->pixmapTraffic->setPixmap( textIcon( "123K", "12K", KNemoIface::Connected ) );
873
mDlg->colorIncoming->show();
874
mDlg->colorIncomingLabel->show();
875
mDlg->colorOutgoing->show();
876
mDlg->colorOutgoingLabel->show();
877
mDlg->colorDisabled->show();
878
mDlg->colorDisabledLabel->show();
879
mDlg->colorUnavailable->show();
880
mDlg->colorUnavailableLabel->show();
970
if ( curTheme.internalName == TEXT_THEME )
972
settings->iconTheme = TEXT_THEME;
973
mDlg->pixmapError->setPixmap( textIcon( "0.0K", "0.0K", KNemoIface::Unavailable ) );
974
mDlg->pixmapDisconnected->setPixmap( textIcon( "0.0K", "0.0K", KNemoIface::Available ) );
975
mDlg->pixmapConnected->setPixmap( textIcon( "0.0K", "0.0K", KNemoIface::Connected ) );
976
mDlg->pixmapIncoming->setPixmap( textIcon( "123K", "0.0K", KNemoIface::Connected ) );
977
mDlg->pixmapOutgoing->setPixmap( textIcon( "0.0K", "12K", KNemoIface::Connected ) );
978
mDlg->pixmapTraffic->setPixmap( textIcon( "123K", "12K", KNemoIface::Connected ) );
982
settings->iconTheme = NETLOAD_THEME;
983
mDlg->pixmapError->setPixmap( barIcon( KNemoIface::Unavailable ) );
984
mDlg->pixmapDisconnected->setPixmap( barIcon( KNemoIface::Available ) );
985
mDlg->pixmapConnected->setPixmap( barIcon( KNemoIface::Connected ) );
986
mDlg->pixmapIncoming->setPixmap( barIcon( KNemoIface::Connected | KNemoIface::RxTraffic ) );
987
mDlg->pixmapOutgoing->setPixmap( barIcon( KNemoIface::Connected | KNemoIface::TxTraffic ) );
988
mDlg->pixmapTraffic->setPixmap( barIcon( KNemoIface::Connected | KNemoIface::RxTraffic | KNemoIface::TxTraffic ) );
991
mDlg->themeColorBox->setEnabled( true );
921
1025
settings->colorUnavailable = mDlg->colorUnavailable->color();
923
1027
KNemoTheme curTheme = mDlg->comboBoxIconTheme->itemData( mDlg->comboBoxIconTheme->currentIndex() ).value<KNemoTheme>();
924
if ( curTheme.internalName == TEXT_THEME )
1028
if ( curTheme.internalName == TEXT_THEME ||
1029
curTheme.internalName == NETLOAD_THEME )
925
1030
iconThemeChanged( mDlg->comboBoxIconTheme->currentIndex() );
926
1031
if ( !mLock) changed( true );
1034
void ConfigDialog::advancedButtonClicked()
1036
InterfaceSettings* settings = getItemSettings();
1040
ThemeConfig t( *settings );
1043
InterfaceSettings s = t.getSettings();
1044
settings->dynamicColor = s.dynamicColor;
1045
settings->colorIncomingMax = s.colorIncomingMax;
1046
settings->colorOutgoingMax = s.colorOutgoingMax;
1048
settings->barScale = s.barScale;
1049
settings->inMaxRate = s.inMaxRate;
1050
settings->outMaxRate = s.outMaxRate;
930
1057
/******************************************