~ubuntu-branches/ubuntu/precise/knemo/precise

« back to all changes in this revision

Viewing changes to src/kcm/configdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell, Pino Toscano, Mark Purcell
  • Date: 2010-02-11 14:53:44 UTC
  • mfrom: (1.1.10 upstream) (2.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100211145344-3l3zu2q7fda55t1u
Tags: 0.6.1-1
* New upstream release

[ Pino Toscano ]
* net-tools and wireless-tools are no more used, so remove them from
  Build-Depends, Depends and Recommends.
* Exclude libiw-dev, and libnl-dev from Build-Depends for kFreeBSD and Hurd.
* Remove autotools-dev Build-Depends (knemo uses CMake as build system).
* Slightly adapt description to the usage of command line applications,
  no more done now.
* Enable the "as needed" linking.

[ Mark Purcell ]
* Remove obsolete debian/README.Debian & debian/dirs
* Add comment only debian/watch 
* Update to Standards 3.8.3 - no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "ui_configdlg.h"
33
33
#include "config-knemo.h"
34
34
#include "configdialog.h"
 
35
#include "themeconfig.h"
35
36
#include "utils.h"
36
37
 
37
38
#include <math.h>
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;
 
95
 
 
96
    KNemoTheme textTheme;
 
97
    textTheme.name = i18n( "Text" );
 
98
    textTheme.comment = i18n( "KNemo theme that shows the upload/download speed as text" );
 
99
    textTheme.internalName = TEXT_THEME;
 
100
 
 
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;
 
105
 
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 ) );
97
 
    KNemoTheme textTheme;
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 ) );
102
111
 
103
112
    InterfaceSettings s;
119
128
    mDlg->pushButtonAddToolTip->setIcon( SmallIcon( "arrow-right" ) );
120
129
    mDlg->pushButtonRemoveToolTip->setIcon( SmallIcon( "arrow-left" ) );
121
130
 
122
 
    mDlg->colorIncomingLabel->hide();
123
 
    mDlg->colorIncoming->hide();
124
 
    mDlg->colorOutgoingLabel->hide();
125
 
    mDlg->colorOutgoing->hide();
126
 
    mDlg->colorDisabledLabel->hide();
127
 
    mDlg->colorDisabled->hide();
128
 
    mDlg->colorUnavailable->hide();
129
 
    mDlg->colorUnavailable->hide();
 
131
    mDlg->themeColorBox->setEnabled( false );
130
132
 
131
133
    //mDlg->listViewCommands->setSorting( -1 );
132
134
 
148
150
             this, SLOT( aliasChanged( const QString& ) ) );
149
151
 
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& ) ),
164
162
             this, SLOT( colorButtonChanged() ) );
165
163
    connect( mDlg->colorUnavailable, SIGNAL( changed( const QColor& ) ),
166
164
             this, SLOT( colorButtonChanged() ) );
 
165
    connect( mDlg->advancedButton, SIGNAL( clicked() ),
 
166
             this, SLOT( advancedButtonClicked() ) );
167
167
 
168
168
    // Interface - Statistics
169
169
    connect( mDlg->checkBoxStatistics, SIGNAL( toggled( bool ) ),
180
180
             this, SLOT( warnRxTxToggled ( bool ) ) );
181
181
 
182
182
    // Interface - Context Menu
183
 
    connect( mDlg->checkBoxCustom, SIGNAL( toggled( bool ) ),
184
 
             this, SLOT( checkBoxCustomToggled ( bool ) ) );
185
183
    connect( mDlg->listViewCommands, SIGNAL( currentItemChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ),
186
184
             this, SLOT( listViewCommandsSelectionChanged( QTreeWidgetItem*, QTreeWidgetItem* ) ) );
187
185
    connect( mDlg->listViewCommands, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ),
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 );
298
302
                }
299
303
            }
300
304
 
301
 
            settings->customCommands = interfaceGroup.readEntry( conf_customCommands, s.customCommands );
302
305
            int numCommands = interfaceGroup.readEntry( conf_numCommands, s.numCommands );
303
306
            for ( int i = 0; i < numCommands; i++ )
304
307
            {
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
 
419
           )
415
420
        {
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 )
 
427
            {
 
428
                interfaceGroup.writeEntry( conf_colorIncomingMax, settings->colorIncomingMax );
 
429
                interfaceGroup.writeEntry( conf_colorOutgoingMax, settings->colorOutgoingMax );
 
430
            }
 
431
            if ( settings->iconTheme == NETLOAD_THEME )
 
432
            {
 
433
                interfaceGroup.writeEntry( conf_barScale, settings->barScale );
 
434
            }
 
435
            if ( settings->dynamicColor ||
 
436
                 ( settings->iconTheme == NETLOAD_THEME && settings->barScale )
 
437
               )
 
438
            {
 
439
                interfaceGroup.writeEntry( conf_inMaxRate, settings->inMaxRate );
 
440
                interfaceGroup.writeEntry( conf_outMaxRate, settings->outMaxRate );
 
441
            }
420
442
        }
421
443
        interfaceGroup.writeEntry( conf_activateStatistics, settings->activateStatistics );
422
444
        interfaceGroup.writeEntry( conf_customBilling, settings->customBilling );
429
451
        interfaceGroup.writeEntry( conf_billingWarnThresh, settings->warnThreshold );
430
452
        interfaceGroup.writeEntry( conf_billingWarnRxTx, settings->warnTotalTraffic );
431
453
 
432
 
        interfaceGroup.writeEntry( conf_customCommands, settings->customCommands );
433
454
        interfaceGroup.writeEntry( conf_numCommands, settings->commands.size() );
434
455
        for ( int i = 0; i < settings->commands.size(); i++ )
435
456
        {
511
532
        mDlg->listBoxInterfaces->addItem( interface );
512
533
        mDlg->listBoxInterfaces->setCurrentRow( 0 );
513
534
        mDlg->pushButtonDelete->setEnabled( true );
514
 
        mDlg->aliasLabel->setEnabled( false );
515
 
        mDlg->lineEditAlias->setEnabled( false );
 
535
        mDlg->aliasLabel->setEnabled( true );
 
536
        mDlg->lineEditAlias->setEnabled( true );
516
537
        mDlg->ifaceTab->setEnabled( true );
517
538
    }
518
539
 
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 )
 
620
        index = 1;
 
621
    else if ( settings->hideWhenUnavailable )
 
622
        index = 2;
 
623
    else
 
624
        index = 0;
 
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 )
625
651
    }
626
652
    setMaxDay();
627
653
    mDlg->billingStartInput->setDate( settings->billingStart );
628
 
    mDlg->spinBoxTrafficThreshold->setValue( settings->trafficThreshold );
629
654
 
630
655
    mDlg->listViewCommands->clear();
631
656
    QList<QTreeWidgetItem *>items;
641
666
        item->setText( 2, command.command );
642
667
        items << item;
643
668
    }
644
 
    mDlg->listViewCommands->addTopLevelItems( items );
 
669
    if ( items.count() > 0 )
 
670
    {
 
671
        mDlg->listViewCommands->addTopLevelItems( items );
 
672
        mDlg->listViewCommands->setCurrentItem( items[0] );
 
673
        mDlg->pushButtonRemoveCommand->setEnabled( true );
 
674
        setUpDownButtons( items[0] );
 
675
    }
 
676
    else
 
677
    {
 
678
        mDlg->pushButtonRemoveCommand->setEnabled( false );
 
679
        setUpDownButtons( NULL );
 
680
    }
645
681
    mLock = false;
646
682
}
647
683
 
824
860
    return sampleIcon;
825
861
}
826
862
 
827
 
void ConfigDialog::checkBoxDisconnectedToggled( bool on )
828
 
{
829
 
    InterfaceSettings* settings = getItemSettings();
830
 
    if ( !settings )
831
 
        return;
832
 
 
833
 
    settings->hideWhenDisconnected = on;
834
 
    if (!mLock) changed( true );
835
 
}
836
 
 
837
 
void ConfigDialog::checkBoxUnavailableToggled( bool on )
838
 
{
839
 
    InterfaceSettings* settings = getItemSettings();
840
 
    if ( !settings )
841
 
        return;
842
 
 
843
 
    settings->hideWhenUnavailable = on;
844
 
    if (!mLock) changed( true );
845
 
}
846
 
 
847
 
void ConfigDialog::spinBoxTrafficValueChanged( int value )
848
 
{
849
 
    InterfaceSettings* settings = getItemSettings();
850
 
    if ( !settings )
851
 
        return;
852
 
 
853
 
    settings->trafficThreshold = value;
 
863
QPixmap ConfigDialog::barIcon( int status )
 
864
{
 
865
    int barIncoming = 0;
 
866
    int barOutgoing = 0;
 
867
    QPixmap barIcon( 22, 22 );
 
868
    barIcon.fill( Qt::transparent );
 
869
    QPainter p( &barIcon );
 
870
 
 
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 );
 
875
 
 
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 );
 
884
 
 
885
    if ( status & KNemoIface::Connected )
 
886
    {
 
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() );
 
891
    }
 
892
    else if ( status & KNemoIface::Available )
 
893
    {
 
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() );
 
898
    }
 
899
    else
 
900
    {
 
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() );
 
905
    }
 
906
    if ( status & KNemoIface::Available || status & KNemoIface::Unavailable )
 
907
    {
 
908
        barIncoming = 22;
 
909
        barOutgoing = 22;
 
910
    }
 
911
    if ( status & KNemoIface::RxTraffic )
 
912
        barIncoming = 17;
 
913
    if ( status & KNemoIface::TxTraffic )
 
914
        barOutgoing = 17;
 
915
 
 
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 );
 
922
 
 
923
    QBrush brush( inGrad );
 
924
    p.setBrush( brush );
 
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 );
 
932
    return barIcon;
 
933
}
 
934
 
 
935
void ConfigDialog::comboHidingChanged( int val )
 
936
{
 
937
    InterfaceSettings* settings = getItemSettings();
 
938
    if ( !settings )
 
939
        return;
 
940
 
 
941
    switch ( val )
 
942
    {
 
943
        case 0:
 
944
            settings->hideWhenDisconnected = false;
 
945
            settings->hideWhenUnavailable = false;
 
946
            break;
 
947
        case 1:
 
948
            settings->hideWhenDisconnected = true;
 
949
            settings->hideWhenUnavailable = true;
 
950
            break;
 
951
        case 2:
 
952
            settings->hideWhenDisconnected = false;
 
953
            settings->hideWhenUnavailable = true;
 
954
            break;
 
955
    }
 
956
 
854
957
    if (!mLock) changed( true );
855
958
}
856
959
 
861
964
        return;
862
965
 
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 )
865
969
    {
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 )
 
971
        {
 
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 ) );
 
979
        }
 
980
        else
 
981
        {
 
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 ) );
 
989
        }
 
990
 
 
991
        mDlg->themeColorBox->setEnabled( true );
881
992
    }
882
993
    else
883
994
    {
893
1004
        mDlg->pixmapIncoming->setPixmap( KIcon( iconName + ICON_RX ).pixmap( 22 ) );
894
1005
        mDlg->pixmapOutgoing->setPixmap( KIcon( iconName + ICON_TX ).pixmap( 22 ) );
895
1006
        mDlg->pixmapTraffic->setPixmap( KIcon( iconName + ICON_RX_TX ).pixmap( 22 ) );
896
 
        mDlg->colorIncoming->hide();
897
 
        mDlg->colorIncomingLabel->hide();
898
 
        mDlg->colorOutgoing->hide();
899
 
        mDlg->colorOutgoingLabel->hide();
900
 
        mDlg->colorDisabled->hide();
901
 
        mDlg->colorDisabledLabel->hide();
902
 
        mDlg->colorUnavailable->hide();
903
 
        mDlg->colorUnavailableLabel->hide();
 
1007
        mDlg->themeColorBox->setEnabled( false );
904
1008
    }
905
1009
    if (!mLock) changed( true );
906
1010
}
921
1025
        settings->colorUnavailable = mDlg->colorUnavailable->color();
922
1026
 
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 );
927
1032
}
928
1033
 
 
1034
void ConfigDialog::advancedButtonClicked()
 
1035
{
 
1036
    InterfaceSettings* settings = getItemSettings();
 
1037
    if ( !settings )
 
1038
        return;
 
1039
 
 
1040
    ThemeConfig t( *settings );
 
1041
    if ( t.exec() )
 
1042
    {
 
1043
        InterfaceSettings s = t.getSettings();
 
1044
        settings->dynamicColor = s.dynamicColor;
 
1045
        settings->colorIncomingMax = s.colorIncomingMax;
 
1046
        settings->colorOutgoingMax = s.colorOutgoingMax;
 
1047
 
 
1048
        settings->barScale = s.barScale;
 
1049
        settings->inMaxRate = s.inMaxRate;
 
1050
        settings->outMaxRate = s.outMaxRate;
 
1051
 
 
1052
        changed( true );
 
1053
    }
 
1054
}
 
1055
 
929
1056
 
930
1057
/******************************************
931
1058
 *                                        *
993
1120
        return;
994
1121
 
995
1122
    settings->warnThreshold = round(val*10.0)/10.0;
 
1123
    // If single stepping through values and we go back to 0.0,
 
1124
    // we might not get the specialValueText
 
1125
    if ( val != settings->warnThreshold )
 
1126
        mDlg->warnThreshold->setValue( settings->warnThreshold );
996
1127
    bool enable = settings->warnThreshold > 0.0;
997
1128
    mDlg->warnRx->setEnabled( enable );
998
1129
    mDlg->warnRxTx->setEnabled( enable );
1017
1148
 *                                        *
1018
1149
 ******************************************/
1019
1150
 
1020
 
void ConfigDialog::checkBoxCustomToggled( bool on )
1021
 
{
1022
 
    InterfaceSettings* settings = getItemSettings();
1023
 
    if ( !settings )
1024
 
        return;
1025
 
 
1026
 
    settings->customCommands = on;
1027
 
    if ( on )
1028
 
    {
1029
 
        if ( mDlg->listViewCommands->currentItem() )
1030
 
            mDlg->pushButtonRemoveCommand->setEnabled( true );
1031
 
    }
1032
 
    else
1033
 
        mDlg->pushButtonRemoveCommand->setEnabled( false );
1034
 
 
1035
 
    if (!mLock) changed( true );
1036
 
}
1037
 
 
1038
1151
void ConfigDialog::buttonAddCommandSelected()
1039
1152
{
1040
1153
    InterfaceSettings* settings = getItemSettings();
1051
1164
    item->setCheckState( 0, Qt::Unchecked );
1052
1165
    item->setFlags( item->flags() | Qt::ItemIsEditable );
1053
1166
    mDlg->listViewCommands->addTopLevelItem( item );
 
1167
    mDlg->listViewCommands->setCurrentItem( item );
1054
1168
 
1055
1169
    if (!mLock) changed( true );
1056
1170
}
1085
1199
    if (!mLock) changed( true );
1086
1200
}
1087
1201
 
 
1202
void ConfigDialog::setUpDownButtons( QTreeWidgetItem* item )
 
1203
{
 
1204
    if ( !item )
 
1205
    {
 
1206
        mDlg->pushButtonUp->setEnabled( false );
 
1207
        mDlg->pushButtonDown->setEnabled( false );
 
1208
        return;
 
1209
    }
 
1210
 
 
1211
    if (mDlg->listViewCommands->indexOfTopLevelItem( item ) == 0 )
 
1212
        mDlg->pushButtonUp->setEnabled( false );
 
1213
    else
 
1214
        mDlg->pushButtonUp->setEnabled( true );
 
1215
 
 
1216
    if (mDlg->listViewCommands->indexOfTopLevelItem( item ) == mDlg->listViewCommands->topLevelItemCount() - 1 )
 
1217
        mDlg->pushButtonDown->setEnabled( false );
 
1218
    else
 
1219
        mDlg->pushButtonDown->setEnabled( true );
 
1220
}
 
1221
 
1088
1222
void ConfigDialog::buttonCommandUpSelected()
1089
1223
{
1090
1224
    InterfaceSettings* settings = getItemSettings();
1102
1236
    mDlg->listViewCommands->takeTopLevelItem( index );
1103
1237
    mDlg->listViewCommands->insertTopLevelItem( index - 1, item );
1104
1238
    mDlg->listViewCommands->setCurrentItem( item );
 
1239
    setUpDownButtons( item );
1105
1240
 
1106
1241
    QList<InterfaceCommand> cmds;
1107
1242
    QTreeWidgetItemIterator i( mDlg->listViewCommands );
1136
1271
    mDlg->listViewCommands->takeTopLevelItem( index );
1137
1272
    mDlg->listViewCommands->insertTopLevelItem( index + 1, item );
1138
1273
    mDlg->listViewCommands->setCurrentItem( item );
 
1274
    setUpDownButtons( item );
1139
1275
 
1140
1276
    QList<InterfaceCommand> cmds;
1141
1277
    QTreeWidgetItemIterator i( mDlg->listViewCommands );
1156
1292
void ConfigDialog::listViewCommandsSelectionChanged( QTreeWidgetItem* item, QTreeWidgetItem* )
1157
1293
{
1158
1294
    mDlg->pushButtonRemoveCommand->setEnabled( item != NULL );
 
1295
    setUpDownButtons( item );
1159
1296
}
1160
1297
 
1161
1298
void ConfigDialog::listViewCommandsChanged( QTreeWidgetItem* item, int column )
1217
1354
    mToolTips.insert( BIT_RATE, i18n( "Bit Rate" ) );
1218
1355
    mToolTips.insert( ACCESS_POINT, i18n( "Access Point" ) );
1219
1356
    mToolTips.insert( LINK_QUALITY, i18n( "Link Quality" ) );
 
1357
#ifndef __linux__
1220
1358
    mToolTips.insert( NICK_NAME, i18n( "Nickname" ) );
 
1359
#endif
1221
1360
    mToolTips.insert( ENCRYPTION, i18n( "Encryption" ) );
1222
1361
}
1223
1362