diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 01:06:58 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 01:06:58 +0000 |
commit | ccceabd36ed168eefd785fb4fb720a577482fec1 (patch) | |
tree | 643927e0ff83170395fa3be8f50c69dae48be1ca /src/kcm | |
download | knemo-ccceabd36ed168eefd785fb4fb720a577482fec1.tar.gz knemo-ccceabd36ed168eefd785fb4fb720a577482fec1.zip |
Added KDE3 version of knemo
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knemo@1091560 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/kcm')
-rw-r--r-- | src/kcm/Makefile.am | 28 | ||||
-rw-r--r-- | src/kcm/configdialog.cpp | 1199 | ||||
-rw-r--r-- | src/kcm/configdialog.h | 150 | ||||
-rw-r--r-- | src/kcm/configdlg.ui | 1299 | ||||
-rw-r--r-- | src/kcm/kcm_knemo.desktop | 89 |
5 files changed, 2765 insertions, 0 deletions
diff --git a/src/kcm/Makefile.am b/src/kcm/Makefile.am new file mode 100644 index 0000000..15440a0 --- /dev/null +++ b/src/kcm/Makefile.am @@ -0,0 +1,28 @@ +## Makefile.am for kcm_knemo + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kcm_knemo.pot + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +kde_module_LTLIBRARIES = kcm_knemo.la + +# set the include path for X, qt and KDE +INCLUDES = -I$(srcdir)/../common -I$(srcdir)/../knemod/backends $(all_includes) + +# the library search path. +kcm_knemo_la_LDFLAGS = -module -avoid-version $(all_libraries) + +# the libraries to link against. +kcm_knemo_la_LIBADD = $(LIB_KDEUI) + +# which sources should be compiled for knemo +kcm_knemo_la_SOURCES = configdialog.cpp configdlg.ui + +# these are the headers for your project +noinst_HEADERS = configdialog.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +xdg_apps_DATA = kcm_knemo.desktop diff --git a/src/kcm/configdialog.cpp b/src/kcm/configdialog.cpp new file mode 100644 index 0000000..9c5ca9a --- /dev/null +++ b/src/kcm/configdialog.cpp @@ -0,0 +1,1199 @@ +/* This file is part of KNemo + Copyright (C) 2004, 2006 Percy Leonhardt <[email protected]> + + KNemo is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + KNemo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qfile.h> +#include <qdict.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qcstring.h> +#include <qlistbox.h> +#include <qcheckbox.h> +#include <qlineedit.h> +#include <qcombobox.h> +#include <qgroupbox.h> +#include <qwhatsthis.h> +#include <qtabwidget.h> +#include <qpushbutton.h> +#include <qstringlist.h> +#include <qdatastream.h> + +#include <kglobal.h> +#include <kconfig.h> +#include <klocale.h> +#include <knuminput.h> +#include <dcopclient.h> +#include <kiconloader.h> +#include <kfiledialog.h> +#include <kdesktopfile.h> +#include <kcolorbutton.h> +#include <kinputdialog.h> +#include <kapplication.h> +#include <knotifydialog.h> +#include <kstandarddirs.h> +#include <kgenericfactory.h> +#include <kdirselectdialog.h> + +#include "configdlg.h" +#include "kcmregistry.h" +#include "configdialog.h" + +const QString ConfigDialog::ICON_DISCONNECTED = "network_disconnected"; +const QString ConfigDialog::ICON_CONNECTED = "network_connected"; +const QString ConfigDialog::ICON_INCOMING = "network_incoming"; +const QString ConfigDialog::ICON_OUTGOING = "network_outgoing"; +const QString ConfigDialog::ICON_TRAFFIC = "network_traffic"; +const QString ConfigDialog::SUFFIX_PPP = "_ppp"; +const QString ConfigDialog::SUFFIX_LAN = "_lan"; +const QString ConfigDialog::SUFFIX_WLAN = "_wlan"; + +typedef KGenericFactory<ConfigDialog, QWidget> KNemoFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_knemo, KNemoFactory("kcm_knemo") ) + +ConfigDialog::ConfigDialog( QWidget *parent, const char *name, const QStringList& ) + : KCModule( KNemoFactory::instance(), parent, name ), + mLock( false ), + mDlg( new ConfigDlg( this ) ), + mColorVLines( 0x04FB1D ), + mColorHLines( 0x04FB1D ), + mColorIncoming( 0x1889FF ), + mColorOutgoing( 0xFF7F08 ), + mColorBackground( 0x313031 ) +{ + KGlobal::locale()->insertCatalogue("kcm_knemo"); + setupToolTipArray(); + + // fill the backends combobox + for ( int i = 0; KCMRegistry[i].name != QString::null; i++ ) + { + mDlg->comboBoxBackends->insertItem( KCMRegistry[i].name ); + } + + load(); + + QVBoxLayout* top = new QVBoxLayout(this); + mDlg->pushButtonNew->setPixmap( SmallIcon( "filenew" ) ); + mDlg->pushButtonDelete->setPixmap( SmallIcon( "editdelete" ) ); + mDlg->pushButtonAddCommand->setPixmap( SmallIcon( "filenew" ) ); + mDlg->pushButtonRemoveCommand->setPixmap( SmallIcon( "editdelete" ) ); + mDlg->pushButtonUp->setPixmap( SmallIcon( "1uparrow" ) ); + mDlg->pushButtonDown->setPixmap( SmallIcon( "1downarrow" ) ); + mDlg->pushButtonAddToolTip->setPixmap( SmallIcon( "1rightarrow" ) ); + mDlg->pushButtonRemoveToolTip->setPixmap( SmallIcon( "1leftarrow" ) ); + mDlg->listViewCommands->setSorting( -1 ); + QWhatsThis::add( mDlg->listViewCommands, + i18n("<p>In this area you can add the custom entries " \ + "for your context menu: <ol><li>check <b>Display " \ + "custom entries in context menu</b>;</li>" \ + "<li>push on the <b>Add</b> button to add a new " \ + "entry in the list;</li><li>edit the entry by " \ + "double clicking in column <b>Menu text</b> and " \ + "<b>Command</b>;</li><li>start from step 2 for " \ + "every new entry</li>.</ol>If you need to execute " \ + "the command as root user check the corresponding " \ + "<b>Root</b> CheckBox.") ); + + mSettingsDict.setAutoDelete( true ); + setButtons( KCModule::Default | KCModule::Apply ); + + connect( mDlg->pushButtonNew, SIGNAL( clicked() ), + this, SLOT( buttonNewSelected() ) ); + connect( mDlg->pushButtonDelete, SIGNAL( clicked() ), + this, SLOT( buttonDeleteSelected() ) ); + connect( mDlg->pushButtonAddCommand, SIGNAL( clicked() ), + this, SLOT( buttonAddCommandSelected() ) ); + connect( mDlg->pushButtonRemoveCommand, SIGNAL( clicked() ), + this, SLOT( buttonRemoveCommandSelected() ) ); + connect( mDlg->pushButtonUp, SIGNAL( clicked() ), + this, SLOT( buttonCommandUpSelected() ) ); + connect( mDlg->pushButtonDown, SIGNAL( clicked() ), + this, SLOT( buttonCommandDownSelected() ) ); + connect( mDlg->pushButtonAddToolTip, SIGNAL( clicked() ), + this, SLOT( buttonAddToolTipSelected() ) ); + connect( mDlg->pushButtonRemoveToolTip, SIGNAL( clicked() ), + this, SLOT( buttonRemoveToolTipSelected() ) ); + connect( mDlg->pushButtonNotifications, SIGNAL( clicked() ), + this, SLOT( buttonNotificationsSelected() ) ); + connect( mDlg->pushButtonStatisticsDir, SIGNAL( clicked() ), + this, SLOT( buttonStatisticsDirSelected() ) ); + connect( mDlg->lineEditAlias, SIGNAL( textChanged( const QString& ) ), + this, SLOT( aliasChanged( const QString& ) ) ); + connect( mDlg->comboBoxIconSet, SIGNAL( activated( int ) ), + this, SLOT( iconSetChanged( int ) ) ); + connect( mDlg->comboBoxBackends, SIGNAL( activated( int ) ), + this, SLOT( backendChanged( int ) ) ); + connect( mDlg->checkBoxNotConnected, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxNotConnectedToggled ( bool ) ) ); + connect( mDlg->checkBoxNotExisting, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxNotExistingToggled ( bool ) ) ); + connect( mDlg->checkBoxStatistics, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxStatisticsToggled ( bool ) ) ); + connect( mDlg->checkBoxStartKNemo, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxStartKNemoToggled( bool ) ) ); + connect( mDlg->spinBoxTrafficThreshold, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxTrafficValueChanged ( int ) ) ); + connect( mDlg->checkBoxCustom, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxCustomToggled ( bool ) ) ); + connect( mDlg->listBoxInterfaces, SIGNAL( highlighted( const QString& ) ), + this, SLOT( interfaceSelected( const QString& ) ) ); + connect( mDlg->listViewCommands, SIGNAL( selectionChanged() ), + this, SLOT( listViewCommandsSelectionChanged() ) ); + connect( mDlg->listViewCommands, SIGNAL( itemRenamed( QListViewItem*, int, const QString& ) ), + this, SLOT( listViewCommandsRenamed( QListViewItem*, int, const QString& ) ) ); + + // connect the plotter widgets + connect( mDlg->checkBoxTopBar, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->checkBoxLabels, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->checkBoxVLines, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->checkBoxHLines, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->checkBoxIncoming, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->checkBoxOutgoing, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->checkBoxVLinesScroll, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->checkBoxAutoDetection, SIGNAL( toggled( bool ) ), + this, SLOT( checkBoxToggled( bool ) ) ); + connect( mDlg->spinBoxCount, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->spinBoxPixel, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->spinBoxDistance, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->spinBoxFontSize, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->spinBoxMinValue, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->spinBoxMaxValue, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->numInputPollInterval, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->numInputSaveInterval, SIGNAL( valueChanged( int ) ), + this, SLOT( spinBoxValueChanged( int ) ) ); + connect( mDlg->kColorButtonVLines, SIGNAL( changed( const QColor& ) ), + this, SLOT( kColorButtonChanged( const QColor& ) ) ); + connect( mDlg->kColorButtonHLines, SIGNAL( changed( const QColor& ) ), + this, SLOT( kColorButtonChanged( const QColor& ) ) ); + connect( mDlg->kColorButtonIncoming, SIGNAL( changed( const QColor& ) ), + this, SLOT( kColorButtonChanged( const QColor& ) ) ); + connect( mDlg->kColorButtonOutgoing, SIGNAL( changed( const QColor& ) ), + this, SLOT( kColorButtonChanged( const QColor& ) ) ); + connect( mDlg->kColorButtonBackground, SIGNAL( changed( const QColor& ) ), + this, SLOT( kColorButtonChanged( const QColor& ) ) ); + + // No dcop call if KNemo is not activated by the user. Otherwise + // load-on-demand will start KNemo. + if ( mDlg->checkBoxStartKNemo->isChecked() ) + { + // In case the user opened the control center via the context menu + // this call to the daemon will deliver the interface the menu + // belongs to. This way we can preselect the appropriate entry in the list. + QCString replyType; + QByteArray replyData, arg; + QString selectedInterface = QString::null; + if ( kapp->dcopClient()->call( "kded", "knemod", "getSelectedInterface()", arg, replyType, replyData ) ) + { + QDataStream reply( replyData, IO_ReadOnly ); + reply >> selectedInterface; + } + + if ( selectedInterface != QString::null ) + { + // Try to preselect the interface. + unsigned int i; + for ( i = 0; i < mDlg->listBoxInterfaces->count(); i++ ) + { + QListBoxItem* item = mDlg->listBoxInterfaces->item( i ); + if ( item->text() == selectedInterface ) + { + // Found it. + mDlg->listBoxInterfaces->setSelected( i, true ); + break; + } + } + if ( i == mDlg->listBoxInterfaces->count() ) + // Not found. Select first entry in list. + mDlg->listBoxInterfaces->setSelected( 0, true ); + } + else + // No interface from daemon. Select first entry in list. + mDlg->listBoxInterfaces->setSelected( 0, true ); + } + else + { + // Started from control center. Select first entry in list. + mDlg->listBoxInterfaces->setSelected( 0, true ); + } + + top->add( mDlg ); +} + +ConfigDialog::~ConfigDialog() +{ + delete mDlg; +} + +void ConfigDialog::load() +{ + mSettingsDict.clear(); + mDlg->listBoxInterfaces->clear(); + KConfig* config = new KConfig( "knemorc", true ); + + config->setGroup( "General" ); + bool startKNemo = config->readBoolEntry( "StartKNemo", false ); + mDlg->checkBoxStartKNemo->setChecked( startKNemo ); + mDlg->tabWidgetConfiguration->setEnabled( startKNemo ); + mDlg->numInputPollInterval->setValue( config->readNumEntry( "PollInterval", 1 ) ); + mDlg->numInputSaveInterval->setValue( config->readNumEntry( "SaveInterval", 60 ) ); + mDlg->lineEditStatisticsDir->setText( config->readEntry( "StatisticsDir", KGlobal::dirs()->saveLocation( "data", "knemo/" ) ) ); + mToolTipContent = config->readNumEntry( "ToolTipContent", 2 ); + + // select the backend from the config file + bool foundBackend = false; + QString backend = config->readEntry( "Backend", "Nettools" ); + int i; + for ( i = 0; KCMRegistry[i].name != QString::null; i++ ) + { + if ( KCMRegistry[i].name == backend ) + { + foundBackend = true; + break; + } + } + + if ( !foundBackend ) + { + i = 0; // use the first backend (Nettools) + } + mDlg->comboBoxBackends->setCurrentItem( i ); + mDlg->textLabelBackendDescription->setText( KCMRegistry[i].description ); + + QStrList list; + int numEntries = config->readListEntry( "Interfaces", list ); + + if ( numEntries == 0 ) + return; + + char* interface; + for ( interface = list.first(); interface; interface = list.next() ) + { + QString group( "Interface_" ); + group += interface; + InterfaceSettings* settings = new InterfaceSettings(); + if ( config->hasGroup( group ) ) + { + config->setGroup( group ); + settings->alias = config->readEntry( "Alias" ); + settings->iconSet = config->readNumEntry( "IconSet", 0 ); + settings->customCommands = config->readBoolEntry( "CustomCommands" ); + settings->hideWhenNotAvailable = config->readBoolEntry( "HideWhenNotAvailable" ); + settings->hideWhenNotExisting = config->readBoolEntry( "HideWhenNotExisting" ); + settings->activateStatistics = config->readBoolEntry( "ActivateStatistics" ); + settings->trafficThreshold = config->readNumEntry( "TrafficThreshold", 0 ); + int numCommands = config->readNumEntry( "NumCommands" ); + for ( int i = 0; i < numCommands; i++ ) + { + QString entry; + InterfaceCommand cmd; + entry = QString( "RunAsRoot%1" ).arg( i + 1 ); + cmd.runAsRoot = config->readBoolEntry( entry ); + entry = QString( "Command%1" ).arg( i + 1 ); + cmd.command = config->readEntry( entry ); + entry = QString( "MenuText%1" ).arg( i + 1 ); + cmd.menuText = config->readEntry( entry ); + settings->commands.append( cmd ); + } + } + mSettingsDict.insert( interface, settings ); + mDlg->listBoxInterfaces->insertItem( interface ); + } + + // enable or disable statistics entries + updateStatisticsEntries(); + + // Set the plotter widgets + config->setGroup( "PlotterSettings" ); + mDlg->spinBoxPixel->setValue( config->readNumEntry( "Pixel", 1 ) ); + mDlg->spinBoxCount->setValue( config->readNumEntry( "Count", 5 ) ); + mDlg->spinBoxDistance->setValue( config->readNumEntry( "Distance", 30 ) ); + mDlg->spinBoxFontSize->setValue( config->readNumEntry( "FontSize", 8 ) ); + mDlg->spinBoxMinValue->setValue( config->readNumEntry( "MinimumValue", 0 ) ); + mDlg->spinBoxMaxValue->setValue( config->readNumEntry( "MaximumValue", 1 ) ); + mDlg->checkBoxLabels->setChecked( config->readBoolEntry( "Labels", true ) ); + mDlg->checkBoxTopBar->setChecked( config->readBoolEntry( "TopBar", false ) ); + mDlg->checkBoxVLines->setChecked( config->readBoolEntry( "VerticalLines", true ) ); + mDlg->checkBoxHLines->setChecked( config->readBoolEntry( "HorizontalLines", true ) ); + mDlg->checkBoxIncoming->setChecked( config->readBoolEntry( "ShowIncoming", true ) ); + mDlg->checkBoxOutgoing->setChecked( config->readBoolEntry( "ShowOutgoing", true ) ); + mDlg->checkBoxAutoDetection->setChecked( config->readBoolEntry( "AutomaticDetection", true ) ); + mDlg->checkBoxVLinesScroll->setChecked( config->readBoolEntry( "VerticalLinesScroll", true ) ); + mDlg->kColorButtonVLines->setColor( config->readColorEntry( "ColorVLines", &mColorVLines ) ); + mDlg->kColorButtonHLines->setColor( config->readColorEntry( "ColorHLines", &mColorHLines ) ); + mDlg->kColorButtonIncoming->setColor( config->readColorEntry( "ColorIncoming", &mColorIncoming ) ); + mDlg->kColorButtonOutgoing->setColor( config->readColorEntry( "ColorOutgoing", &mColorOutgoing ) ); + mDlg->kColorButtonBackground->setColor( config->readColorEntry( "ColorBackground", &mColorBackground ) ); + + delete config; + + // These things need to be here so that 'Reset' from the control + // center is handled correctly. + setupToolTipTab(); +} + +void ConfigDialog::save() +{ + KConfig* config = new KConfig( "knemorc", false ); + + QStringList list; + QDictIterator<InterfaceSettings> it( mSettingsDict ); + for ( ; it.current(); ++it ) + { + list.append( it.currentKey() ); + InterfaceSettings* settings = it.current(); + config->setGroup( "Interface_" + it.currentKey() ); + if ( settings->alias.isEmpty() ) + config->deleteEntry( "Alias" ); + else + config->writeEntry( "Alias", settings->alias ); + config->writeEntry( "IconSet", settings->iconSet ); + config->writeEntry( "CustomCommands", settings->customCommands ); + config->writeEntry( "HideWhenNotAvailable", settings->hideWhenNotAvailable ); + config->writeEntry( "HideWhenNotExisting", settings->hideWhenNotExisting ); + config->writeEntry( "ActivateStatistics", settings->activateStatistics ); + config->writeEntry( "TrafficThreshold", settings->trafficThreshold ); + config->writeEntry( "NumCommands", settings->commands.size() ); + for ( uint i = 0; i < settings->commands.size(); i++ ) + { + QString entry; + entry = QString( "RunAsRoot%1" ).arg( i + 1 ); + config->writeEntry( entry, settings->commands[i].runAsRoot ); + entry = QString( "Command%1" ).arg( i + 1 ); + config->writeEntry( entry, settings->commands[i].command ); + entry = QString( "MenuText%1" ).arg( i + 1 ); + config->writeEntry( entry, settings->commands[i].menuText ); + } + } + + config->setGroup( "General" ); + config->writeEntry( "StartKNemo", mDlg->checkBoxStartKNemo->isChecked() ); + config->writeEntry( "PollInterval", mDlg->numInputPollInterval->value() ); + config->writeEntry( "SaveInterval", mDlg->numInputSaveInterval->value() ); + config->writeEntry( "StatisticsDir", mDlg->lineEditStatisticsDir->text() ); + config->writeEntry( "Backend", mDlg->comboBoxBackends->text( mDlg->comboBoxBackends->currentItem() ) ); + config->writeEntry( "ToolTipContent", mToolTipContent ); + config->writeEntry( "Interfaces", list ); + + config->setGroup( "PlotterSettings" ); + config->writeEntry( "Pixel", mDlg->spinBoxPixel->value() ); + config->writeEntry( "Count", mDlg->spinBoxCount->value() ); + config->writeEntry( "Distance", mDlg->spinBoxDistance->value() ); + config->writeEntry( "FontSize", mDlg->spinBoxFontSize->value() ); + config->writeEntry( "MinimumValue", mDlg->spinBoxMinValue->value() ); + config->writeEntry( "MaximumValue", mDlg->spinBoxMaxValue->value() ); + config->writeEntry( "Labels", mDlg->checkBoxLabels->isChecked() ); + config->writeEntry( "TopBar", mDlg->checkBoxTopBar->isChecked() ); + config->writeEntry( "VerticalLines", mDlg->checkBoxVLines->isChecked() ); + config->writeEntry( "HorizontalLines", mDlg->checkBoxHLines->isChecked() ); + config->writeEntry( "ShowIncoming", mDlg->checkBoxIncoming->isChecked() ); + config->writeEntry( "ShowOutgoing", mDlg->checkBoxOutgoing->isChecked() ); + config->writeEntry( "AutomaticDetection", mDlg->checkBoxAutoDetection->isChecked() ); + config->writeEntry( "VerticalLinesScroll", mDlg->checkBoxVLinesScroll->isChecked() ); + config->writeEntry( "ColorVLines", mDlg->kColorButtonVLines->color() ); + config->writeEntry( "ColorHLines", mDlg->kColorButtonHLines->color() ); + config->writeEntry( "ColorIncoming", mDlg->kColorButtonIncoming->color() ); + config->writeEntry( "ColorOutgoing", mDlg->kColorButtonOutgoing->color() ); + config->writeEntry( "ColorBackground", mDlg->kColorButtonBackground->color() ); + + config->sync(); + delete config; + + KDesktopFile* desktop = new KDesktopFile( "kded/knemod.desktop", false, "services" ); + if ( mDlg->checkBoxStartKNemo->isChecked() ) + { + // This call will implicitly start KNemo if it is not yet running. + kapp->dcopClient()->send( "kded", "knemod", "reparseConfiguration()", "" ); + desktop->writeEntry( "X-KDE-Kded-autoload", true ); + } + else + { + QByteArray data; + QDataStream arg(data, IO_WriteOnly); + arg << "knemod"; + kapp->dcopClient()->send("kded", "kded", "unloadModule(QCString)", data); + desktop->deleteEntry( "X-KDE-Kded-autoload" ); + } + desktop->sync(); + delete desktop; +} + +void ConfigDialog::defaults() +{ + // Default interfaces + QFile proc( "/proc/net/dev" ); + if ( proc.open( IO_ReadOnly ) ) + { + mSettingsDict.clear(); + mDlg->listBoxInterfaces->clear(); + + QString file = proc.readAll(); + QStringList content = QStringList::split( "\n", file ); + if ( content.count() > 2 ) + { + for ( unsigned int i = 2; i < content.count(); i++ ) + { + QString interface = content[i].simplifyWhiteSpace(); + interface = interface.left( interface.find( ':' ) ); + if ( interface == "lo" ) + continue; + + InterfaceSettings* settings = new InterfaceSettings(); + settings->customCommands = false; + settings->hideWhenNotAvailable = false; + settings->hideWhenNotExisting = false; + settings->activateStatistics = false; + mSettingsDict.insert( interface, settings ); + mDlg->listBoxInterfaces->insertItem( interface ); + } + if ( mDlg->listBoxInterfaces->count() > 0 ) + { + mDlg->listBoxInterfaces->setSelected( 0, true ); + } + else + { + mDlg->lineEditAlias->setText( QString::null ); + mDlg->comboBoxIconSet->setCurrentItem( 0 ); + mDlg->checkBoxNotConnected->setChecked( false ); + mDlg->checkBoxNotExisting->setChecked( false ); + mDlg->checkBoxStatistics->setChecked( false ); + mDlg->checkBoxCustom->setChecked( false ); + } + } + proc.close(); + } + + // Default misc settings + mDlg->numInputPollInterval->setValue( 1 ); + mDlg->numInputSaveInterval->setValue( 60 ); + mDlg->lineEditStatisticsDir->setText( KGlobal::dirs()->saveLocation( "data", "knemo/" ) ); + mDlg->comboBoxBackends->setCurrentItem( 0 ); + mDlg->textLabelBackendDescription->setText( KCMRegistry[0].description ); + + // Default tool tips + mToolTipContent = 2; + setupToolTipTab(); + + // Default plotter settings + mDlg->spinBoxPixel->setValue( 1 ); + mDlg->spinBoxCount->setValue( 5 ); + mDlg->spinBoxDistance->setValue( 30 ); + mDlg->spinBoxFontSize->setValue( 8 ); + mDlg->spinBoxMinValue->setValue( 0 ); + mDlg->spinBoxMaxValue->setValue( 1 ); + mDlg->checkBoxLabels->setChecked( true ); + mDlg->checkBoxTopBar->setChecked( false ); + mDlg->checkBoxVLines->setChecked( true ); + mDlg->checkBoxHLines->setChecked( true ); + mDlg->checkBoxIncoming->setChecked( true ); + mDlg->checkBoxOutgoing->setChecked( true ); + mDlg->checkBoxAutoDetection->setChecked( true ); + mDlg->checkBoxVLinesScroll->setChecked( true ); + mDlg->kColorButtonVLines->setColor( mColorVLines ); + mDlg->kColorButtonHLines->setColor( mColorHLines ); + mDlg->kColorButtonIncoming->setColor( mColorIncoming ); + mDlg->kColorButtonOutgoing->setColor( mColorOutgoing ); + mDlg->kColorButtonBackground->setColor( mColorBackground ); + + changed( true ); +} + +void ConfigDialog::buttonNewSelected() +{ + bool ok = false; + QString ifname = KInputDialog::getText( i18n( "Add new interface" ), + i18n( "Please enter the name of the interface to be monitored.\nIt should be something like 'eth1', 'wlan2' or 'ppp0'." ), + QString::null, + &ok ); + + if ( ok ) + { + mDlg->listBoxInterfaces->insertItem( ifname ); + mSettingsDict.insert( ifname, new InterfaceSettings() ); + mDlg->listBoxInterfaces->setSelected( mDlg->listBoxInterfaces->count() - 1, true ); + changed( true ); + } +} + +void ConfigDialog::buttonDeleteSelected() +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + // TODO: find a better way than blocking signals + mSettingsDict.remove( selected->text() ); + mDlg->lineEditAlias->blockSignals( true ); + mDlg->lineEditAlias->setText( QString::null ); + mDlg->lineEditAlias->blockSignals( false ); + mDlg->comboBoxIconSet->blockSignals( true ); + mDlg->comboBoxIconSet->setCurrentItem( 0 ); + mDlg->comboBoxIconSet->blockSignals( false ); + mDlg->checkBoxNotConnected->blockSignals( true ); + mDlg->checkBoxNotConnected->setChecked( false ); + mDlg->checkBoxNotConnected->blockSignals( false ); + mDlg->checkBoxNotExisting->blockSignals( true ); + mDlg->checkBoxNotExisting->setChecked( false ); + mDlg->checkBoxNotExisting->blockSignals( false ); + mDlg->checkBoxStatistics->blockSignals( true ); + mDlg->checkBoxStatistics->setChecked( false ); + mDlg->checkBoxStatistics->blockSignals( false ); + mDlg->checkBoxCustom->blockSignals( true ); + mDlg->checkBoxCustom->setChecked( false ); + mDlg->checkBoxCustom->blockSignals( false ); + mDlg->listBoxInterfaces->removeItem( mDlg->listBoxInterfaces->index( selected ) ); + changed( true ); +} + +void ConfigDialog::buttonAddCommandSelected() +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + KNemoCheckListItem* item = new KNemoCheckListItem( mDlg->listViewCommands ); + item->setRenameEnabled( 1, true ); + item->setRenameEnabled( 2, true ); + connect( item, SIGNAL( stateChanged( KNemoCheckListItem*, bool ) ), + this, SLOT( listViewCommandsCheckListItemChanged( KNemoCheckListItem*, bool ) ) ); + InterfaceSettings* settings = mSettingsDict[selected->text()]; + + QValueVector<InterfaceCommand> cmds; + QListViewItem* i = mDlg->listViewCommands->firstChild(); + for ( ; i != 0; i = i->nextSibling() ) + { + InterfaceCommand cmd; + cmd.runAsRoot = static_cast<KNemoCheckListItem*>( i )->isOn(); + cmd.menuText = i->text( 1 ); + cmd.command = i->text( 2 ); + cmds.append( cmd ); + } + + settings->commands = cmds; + if (!mLock) changed( true ); +} + +void ConfigDialog::buttonRemoveCommandSelected() +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + delete mDlg->listViewCommands->selectedItem(); + InterfaceSettings* settings = mSettingsDict[selected->text()]; + + QValueVector<InterfaceCommand> cmds; + QListViewItem* i = mDlg->listViewCommands->firstChild(); + for ( ; i != 0; i = i->nextSibling() ) + { + InterfaceCommand cmd; + cmd.runAsRoot = static_cast<KNemoCheckListItem*>( i )->isOn(); + cmd.menuText = i->text( 1 ); + cmd.command = i->text( 2 ); + cmds.append( cmd ); + } + + settings->commands = cmds; + if (!mLock) changed( true ); +} + +void ConfigDialog::buttonCommandUpSelected() +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + QListViewItem* item = mDlg->listViewCommands->selectedItem(); + if ( item ) + { + QListViewItem* previous = item->itemAbove(); + if ( previous ) + { + // We can move one up. + previous = previous->itemAbove(); + if ( previous ) + item->moveItem( previous ); + else + { + mDlg->listViewCommands->takeItem( item ); + mDlg->listViewCommands->insertItem( item ); + mDlg->listViewCommands->setSelected( item, true ); + } + } + } + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + + QValueVector<InterfaceCommand> cmds; + QListViewItem* i = mDlg->listViewCommands->firstChild(); + for ( ; i != 0; i = i->nextSibling() ) + { + InterfaceCommand cmd; + cmd.runAsRoot = static_cast<KNemoCheckListItem*>( i )->isOn(); + cmd.menuText = i->text( 1 ); + cmd.command = i->text( 2 ); + cmds.append( cmd ); + } + + settings->commands = cmds; + if (!mLock) changed( true ); +} + +void ConfigDialog::buttonCommandDownSelected() +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + QListViewItem* item = mDlg->listViewCommands->selectedItem(); + if ( item ) + { + QListViewItem* next = item->itemBelow(); + if ( next ) + { + // We can move one down. + item->moveItem( next ); + } + } + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + + QValueVector<InterfaceCommand> cmds; + QListViewItem* i = mDlg->listViewCommands->firstChild(); + for ( ; i != 0; i = i->nextSibling() ) + { + InterfaceCommand cmd; + cmd.runAsRoot = static_cast<KNemoCheckListItem*>( i )->isOn(); + cmd.menuText = i->text( 1 ); + cmd.command = i->text( 2 ); + cmds.append( cmd ); + } + + settings->commands = cmds; + if (!mLock) changed( true ); +} + +void ConfigDialog::buttonAddToolTipSelected() +{ + // Support extended selection + for ( int k = mDlg->listBoxAvailable->count() - 1; k >= 0; k-- ) + { + if ( !mDlg->listBoxAvailable->isSelected( k ) ) + continue; + + QListBoxItem* selected = mDlg->listBoxAvailable->item( k ); + + if ( selected == 0 ) + continue; + + // Find the index of the selected item in the tooltip array. + int itemIndex = 0; + for ( int i = 0; mToolTips[i].first != QString::null; i++ ) + { + if ( mToolTips[i].first == selected->text() ) + { + itemIndex = i; + break; + } + } + + // Find the first item in the display list which has a larger + // index in the tooltip array. We have to insert the selected + // item just before this one. + int newIndex = -1; + for ( unsigned int i = 0; i < mDlg->listBoxDisplay->count(); i++ ) + { + // For every item in the display list find its index in + // the tooltip array. + int siblingIndex = 0; + QListBoxItem* item = mDlg->listBoxDisplay->item( i ); + for ( int j = 0; mToolTips[j].first != QString::null; j++ ) + { + if ( mToolTips[j].first == item->text() ) + { + siblingIndex = j; + break; + } + } + + // Check if the index of this item is larger than the index + // of the selected item. + if ( siblingIndex > itemIndex ) + { + // Insert the selected item at position newIndex placing it + // directly in front of the sibling. + newIndex = i; + break; + } + } + + mDlg->listBoxAvailable->setSelected( selected, false ); + mDlg->listBoxAvailable->takeItem( selected ); + mDlg->listBoxDisplay->insertItem( selected, newIndex ); + if ( mDlg->listBoxAvailable->count() == 0 ) + mDlg->pushButtonAddToolTip->setEnabled( false ); + if ( mDlg->listBoxDisplay->count() == 1 ) + mDlg->pushButtonRemoveToolTip->setEnabled( true ); + + mToolTipContent += mToolTips[itemIndex].second; + changed( true ); + } +} + +void ConfigDialog::buttonRemoveToolTipSelected() +{ + // Support extended selection + for ( int k = mDlg->listBoxDisplay->count() - 1; k >= 0; k-- ) + { + if ( !mDlg->listBoxDisplay->isSelected( k ) ) + continue; + + QListBoxItem* selected = mDlg->listBoxDisplay->item( k ); + + if ( selected == 0 ) + continue; + + // Find the index of the selected item in the tooltip array. + int itemIndex = 0; + for ( int i = 0; mToolTips[i].first != QString::null; i++ ) + { + if ( mToolTips[i].first == selected->text() ) + { + itemIndex = i; + break; + } + } + + // Find the first item in the available list which has a larger + // index in the tooltip array. We have to insert the selected + // item just before this one. + int newIndex = -1; + for ( unsigned int i = 0; i < mDlg->listBoxAvailable->count(); i++ ) + { + // For every item in the available list find its index in + // the tooltip array. + int siblingIndex = 0; + QListBoxItem* item = mDlg->listBoxAvailable->item( i ); + for ( int j = 0; mToolTips[j].first != QString::null; j++ ) + { + if ( mToolTips[j].first == item->text() ) + { + siblingIndex = j; + break; + } + } + + // Check if the index of this item is larger than the index + // of the selected item. + if ( siblingIndex > itemIndex ) + { + // Insert the selected item at position newIndex placing it + // directly in front of the sibling. + newIndex = i; + break; + } + } + + mDlg->listBoxDisplay->setSelected( selected, false ); + mDlg->listBoxDisplay->takeItem( selected ); + mDlg->listBoxAvailable->insertItem( selected, newIndex ); + if ( mDlg->listBoxDisplay->count() == 0 ) + mDlg->pushButtonRemoveToolTip->setEnabled( false ); + if ( mDlg->listBoxAvailable->count() == 1 ) + mDlg->pushButtonAddToolTip->setEnabled( true ); + + mToolTipContent -= mToolTips[itemIndex].second; + changed( true ); + } +} + +void ConfigDialog::buttonNotificationsSelected() +{ + KNotifyDialog dialog( this ); + dialog.addApplicationEvents( "knemo" ); + dialog.exec(); +} + +void ConfigDialog:: buttonStatisticsDirSelected() +{ + KURL url = KDirSelectDialog::selectDirectory(); + if ( url.path() != QString::null ) + { + mDlg->lineEditStatisticsDir->setText( url.path() ); + changed( true ); + } +} + +void ConfigDialog::interfaceSelected( const QString& interface ) +{ + InterfaceSettings* settings = mSettingsDict[interface]; + mLock = true; + mDlg->lineEditAlias->setText( settings->alias ); + mDlg->comboBoxIconSet->setCurrentItem( settings->iconSet ); + mDlg->checkBoxCustom->setChecked( settings->customCommands ); + mDlg->checkBoxNotConnected->setChecked( settings->hideWhenNotAvailable ); + mDlg->checkBoxNotExisting->setChecked( settings->hideWhenNotExisting ); + mDlg->checkBoxStatistics->setChecked( settings->activateStatistics ); + mDlg->spinBoxTrafficThreshold->setValue( settings->trafficThreshold ); + + mDlg->listViewCommands->clear(); + for ( int i = settings->commands.size() - 1; i >= 0; i-- ) + { + KNemoCheckListItem* item = new KNemoCheckListItem( mDlg->listViewCommands ); + item->setOn( settings->commands[i].runAsRoot ); + item->setText( 1, settings->commands[i].menuText ); + item->setRenameEnabled( 1, true ); + item->setText( 2, settings->commands[i].command ); + item->setRenameEnabled( 2, true ); + connect( item, SIGNAL( stateChanged( KNemoCheckListItem*, bool ) ), + this, SLOT( listViewCommandsCheckListItemChanged( KNemoCheckListItem*, bool ) ) ); + } + + iconSetChanged( settings->iconSet ); // to update iconset preview + mLock = false; +} + +void ConfigDialog::aliasChanged( const QString& text ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + settings->alias = text; + if (!mLock) changed( true ); +} + +void ConfigDialog::iconSetChanged( int set ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + settings->iconSet = set; + + // Update the preview of the iconset. + QString suffix; + switch ( set ) + { + case NETWORK: + suffix = SUFFIX_LAN; + break; + case WIRELESS: + suffix = SUFFIX_WLAN; + break; + case MODEM: + suffix = SUFFIX_PPP; + break; + default: + suffix = ""; // use standard icons + } + + mDlg->pixmapDisconnected->setPixmap( SmallIcon( ICON_DISCONNECTED + suffix ) ); + mDlg->pixmapConnected->setPixmap( SmallIcon( ICON_CONNECTED + suffix ) ); + mDlg->pixmapIncoming->setPixmap( SmallIcon( ICON_INCOMING + suffix ) ); + mDlg->pixmapOutgoing->setPixmap( SmallIcon( ICON_OUTGOING + suffix ) ); + mDlg->pixmapTraffic->setPixmap( SmallIcon( ICON_TRAFFIC + suffix ) ); + if (!mLock) changed( true ); +} + +void ConfigDialog::backendChanged( int backend ) +{ + mDlg->textLabelBackendDescription->setText( KCMRegistry[backend].description ); + if (!mLock) changed( true ); +} + +void ConfigDialog::checkBoxNotConnectedToggled( bool on ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + settings->hideWhenNotAvailable = on; + if (!mLock) changed( true ); +} + +void ConfigDialog::checkBoxNotExistingToggled( bool on ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + settings->hideWhenNotExisting = on; + if (!mLock) changed( true ); +} + + +void ConfigDialog::checkBoxStatisticsToggled( bool on ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + settings->activateStatistics = on; + if (!mLock) changed( true ); + + // enable or disable statistics entries + updateStatisticsEntries(); +} + +void ConfigDialog::checkBoxStartKNemoToggled( bool on ) +{ + if ( on ) + { + KConfig* config = new KConfig( "knemorc", false ); + config->setGroup( "General" ); + if ( config->readBoolEntry( "FirstStart", true ) ) + { + config->writeEntry( "FirstStart", false ); + config->sync(); + delete config; + + // Populate the dialog with some default values if the user starts + // KNemo for the very first time. + defaults(); + } + } + + if (!mLock) changed( true ); +} + +void ConfigDialog::spinBoxTrafficValueChanged( int value ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + settings->trafficThreshold = value; + if (!mLock) changed( true ); +} + +void ConfigDialog::checkBoxCustomToggled( bool on ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + InterfaceSettings* settings = mSettingsDict[selected->text()]; + settings->customCommands = on; + if ( on ) + if ( mDlg->listViewCommands->selectedItem() ) + mDlg->pushButtonRemoveCommand->setEnabled( true ); + else + mDlg->pushButtonRemoveCommand->setEnabled( false ); + + if (!mLock) changed( true ); +} + +void ConfigDialog::setupToolTipTab() +{ + mDlg->listBoxDisplay->clear(); + mDlg->listBoxAvailable->clear(); + + for ( int i = 0; mToolTips[i].first != QString::null; i++ ) + { + if ( mToolTipContent & mToolTips[i].second ) + mDlg->listBoxDisplay->insertItem( mToolTips[i].first ); + else + mDlg->listBoxAvailable->insertItem( mToolTips[i].first ); + } + + if ( mDlg->listBoxDisplay->count() > 0 ) + { + mDlg->listBoxDisplay->setSelected( 0, true ); + mDlg->pushButtonRemoveToolTip->setEnabled( true ); + } + else + mDlg->pushButtonRemoveToolTip->setEnabled( false ); + + if ( mDlg->listBoxAvailable->count() > 0 ) + { + mDlg->listBoxAvailable->setSelected( 0, true ); + mDlg->pushButtonAddToolTip->setEnabled( true ); + } + else + mDlg->pushButtonAddToolTip->setEnabled( false ); +} + +void ConfigDialog::setupToolTipArray() +{ + // Cannot make this data static as the i18n macro doesn't seem + // to work when called to early i.e. before setting the catalogue. + mToolTips[0] = QPair<QString, int>( i18n( "Interface" ), INTERFACE ); + mToolTips[1] = QPair<QString, int>( i18n( "Alias" ), ALIAS ); + mToolTips[2] = QPair<QString, int>( i18n( "Status" ), STATUS ); + mToolTips[3] = QPair<QString, int>( i18n( "Uptime" ), UPTIME ); + mToolTips[4] = QPair<QString, int>( i18n( "IP-Address" ), IP_ADDRESS ); + mToolTips[5] = QPair<QString, int>( i18n( "Subnet Mask" ), SUBNET_MASK ); + mToolTips[6] = QPair<QString, int>( i18n( "HW-Address" ), HW_ADDRESS ); + mToolTips[7] = QPair<QString, int>( i18n( "Broadcast Address" ), BCAST_ADDRESS ); + mToolTips[8] = QPair<QString, int>( i18n( "Default Gateway" ), GATEWAY ); + mToolTips[9] = QPair<QString, int>( i18n( "PtP-Address" ), PTP_ADDRESS ); + mToolTips[10] = QPair<QString, int>( i18n( "Packets Received" ), RX_PACKETS ); + mToolTips[11] = QPair<QString, int>( i18n( "Packets Sent" ), TX_PACKETS ); + mToolTips[12] = QPair<QString, int>( i18n( "Bytes Received" ), RX_BYTES ); + mToolTips[13] = QPair<QString, int>( i18n( "Bytes Sent" ), TX_BYTES ); + mToolTips[14] = QPair<QString, int>( i18n( "Download Speed" ), DOWNLOAD_SPEED ); + mToolTips[15] = QPair<QString, int>( i18n( "Upload Speed" ), UPLOAD_SPEED ); + mToolTips[16] = QPair<QString, int>( i18n( "ESSID" ), ESSID ); + mToolTips[17] = QPair<QString, int>( i18n( "Mode" ), MODE ); + mToolTips[18] = QPair<QString, int>( i18n( "Frequency" ), FREQUENCY ); + mToolTips[19] = QPair<QString, int>( i18n( "Bit Rate" ), BIT_RATE ); + mToolTips[20] = QPair<QString, int>( i18n( "Access Point" ), ACCESS_POINT ); + mToolTips[21] = QPair<QString, int>( i18n( "Link Quality" ), LINK_QUALITY ); + mToolTips[22] = QPair<QString, int>( i18n( "Nickname" ), NICK_NAME ); + mToolTips[23] = QPair<QString, int>( i18n( "Encryption" ), ENCRYPTION ); + mToolTips[24] = QPair<QString, int>(); +} + +void ConfigDialog::updateStatisticsEntries( void ) +{ + bool statisticsActive = false; + QDictIterator<InterfaceSettings> it( mSettingsDict ); + for ( ; it.current(); ++it ) + { + if ( it.current()->activateStatistics ) + { + statisticsActive = true; + break; + } + } + + mDlg->groupBoxStatistics->setEnabled( statisticsActive ); + mDlg->groupBoxUpdateInterval->setEnabled( statisticsActive ); +} + +void ConfigDialog::checkBoxToggled( bool ) +{ + changed( true ); +} + +void ConfigDialog::spinBoxValueChanged( int ) +{ + changed( true ); +} + +void ConfigDialog::kColorButtonChanged( const QColor& ) +{ + changed( true ); +} + +void ConfigDialog::listViewCommandsSelectionChanged() +{ + QListViewItem* item = mDlg->listViewCommands->selectedItem(); + if ( item ) + mDlg->pushButtonRemoveCommand->setEnabled( true ); + else + mDlg->pushButtonRemoveCommand->setEnabled( false ); +} + +void ConfigDialog::listViewCommandsCheckListItemChanged( KNemoCheckListItem* item, bool state ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + // Find the row of the item. + int row = 0; + bool foundItem = false; + QListViewItem* i = mDlg->listViewCommands->firstChild(); + for ( ; i != 0; i = i->nextSibling() ) + { + if ( i == item ) + { + foundItem = true; + break; + } + row++; + } + + if ( foundItem ) + { + InterfaceSettings* settings = mSettingsDict[selected->text()]; + InterfaceCommand& cmd = settings->commands[row]; + cmd.runAsRoot = state; + + if (!mLock) changed( true ); + } +} + +void ConfigDialog::listViewCommandsRenamed( QListViewItem* item, int col, const QString & text ) +{ + QListBoxItem* selected = mDlg->listBoxInterfaces->selectedItem(); + + if ( selected == 0 ) + return; + + // Find the row of the item. + int row = 0; + bool foundItem = false; + QListViewItem* i = mDlg->listViewCommands->firstChild(); + for ( ; i != 0; i = i->nextSibling() ) + { + if ( i == item ) + { + foundItem = true; + break; + } + row++; + } + + if ( foundItem ) + { + InterfaceSettings* settings = mSettingsDict[selected->text()]; + InterfaceCommand& cmd = settings->commands[row]; + if ( col == 1 ) + cmd.menuText = text; + else if ( col == 2 ) + cmd.command = text; + + if (!mLock) changed( true ); + } +} + +#include "configdialog.moc" diff --git a/src/kcm/configdialog.h b/src/kcm/configdialog.h new file mode 100644 index 0000000..a4ff764 --- /dev/null +++ b/src/kcm/configdialog.h @@ -0,0 +1,150 @@ +/* This file is part of KNemo + Copyright (C) 2004, 2005, 2006 Percy Leonhardt <[email protected]> + + KNemo is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + KNemo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef CONFIGDIALOG_H +#define CONFIGDIALOG_H + +#include <qdict.h> +#include <qpair.h> +#include <qstring.h> +#include <qlistview.h> + +#include <kcmodule.h> + +#include "data.h" + +class QTimer; +class ConfigDlg; +class KNemoCheckListItem; + +/** + * This is the configuration dialog for KNemo + * It is implemented as a control center module so that it is still + * possible to configure KNemo even when there is no icon visible + * in the system tray. + * + * @short Configuration dialog for KNemo + * @author Percy Leonhardt <[email protected]> + */ + +class ConfigDialog : public KCModule +{ + Q_OBJECT +public: + /** + * Default Constructor + */ + ConfigDialog( QWidget *parent, const char *name, const QStringList& ); + + /** + * Default Destructor + */ + virtual ~ConfigDialog(); + + void load(); + void save(); + void defaults(); + +private slots: + void buttonNewSelected(); + void buttonDeleteSelected(); + void buttonAddCommandSelected(); + void buttonRemoveCommandSelected(); + void buttonCommandUpSelected(); + void buttonCommandDownSelected(); + void buttonAddToolTipSelected(); + void buttonRemoveToolTipSelected(); + void buttonNotificationsSelected(); + void buttonStatisticsDirSelected(); + void interfaceSelected( const QString& interface ); + void aliasChanged( const QString& text ); + void iconSetChanged( int set ); + void backendChanged( int set ); + void checkBoxNotConnectedToggled( bool on ); + void checkBoxNotExistingToggled( bool on ); + void checkBoxStatisticsToggled( bool on ); + void checkBoxStartKNemoToggled( bool on ); + void spinBoxTrafficValueChanged( int value ); + void checkBoxCustomToggled( bool on ); + void listViewCommandsSelectionChanged(); + void listViewCommandsCheckListItemChanged( KNemoCheckListItem* item, bool state ); + void listViewCommandsRenamed( QListViewItem* item, int col, const QString & text ); + + /** + * These three are generic. + * They are used for all plotter settings to activate the + * 'Apply' button when something was changed by the user. + */ + void checkBoxToggled( bool ); + void spinBoxValueChanged( int ); + void kColorButtonChanged( const QColor& ); + +private: + void setupToolTipTab(); + void setupToolTipArray(); + void updateStatisticsEntries( void ); + + enum IconSet + { + MONITOR = 0, + MODEM, + NETWORK, + WIRELESS + }; + + int mToolTipContent; + bool mLock; + ConfigDlg* mDlg; + QColor mColorVLines; + QColor mColorHLines; + QColor mColorIncoming; + QColor mColorOutgoing; + QColor mColorBackground; + QDict<InterfaceSettings> mSettingsDict; + QPair<QString, int> mToolTips[25]; + + static const QString ICON_DISCONNECTED; + static const QString ICON_CONNECTED; + static const QString ICON_INCOMING; + static const QString ICON_OUTGOING; + static const QString ICON_TRAFFIC; + static const QString SUFFIX_PPP; + static const QString SUFFIX_LAN; + static const QString SUFFIX_WLAN; +}; + +class KNemoCheckListItem : public QObject, public QCheckListItem +{ + Q_OBJECT +public: + KNemoCheckListItem( QListView* view ) + : QCheckListItem( view, QString::null, QCheckListItem::CheckBox ) + {} + +signals: + void stateChanged( KNemoCheckListItem*, bool ); + +protected: + void stateChange( bool state ) + { + emit stateChanged( this, state ); + } +}; + +#endif // CONFIGDIALOG_H diff --git a/src/kcm/configdlg.ui b/src/kcm/configdlg.ui new file mode 100644 index 0000000..6c578ad --- /dev/null +++ b/src/kcm/configdlg.ui @@ -0,0 +1,1299 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>ConfigDlg</class> +<widget class="QWidget"> + <property name="name"> + <cstring>ConfigDlg</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>447</width> + <height>465</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxStartKNemo</cstring> + </property> + <property name="text"> + <string>Use KNemo to monitor your interfaces</string> + </property> + </widget> + <widget class="QTabWidget"> + <property name="name"> + <cstring>tabWidgetConfiguration</cstring> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>interfaces</cstring> + </property> + <attribute name="title"> + <string>&Interfaces</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget" row="0" column="0" rowspan="2" colspan="1"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="1" column="0"> + <property name="name"> + <cstring>pushButtonNew</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Add a new interface</string> + </property> + </widget> + <widget class="QListBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>listBoxInterfaces</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>This is the list of icons you wish to monitor. Please +use the names understood by the command 'ifconfig', +for example 'eth0', 'wlan0' or 'ppp0'.</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>pushButtonDelete</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Delete the selected interface</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="1" column="1"> + <property name="name"> + <cstring>groupBox6</cstring> + </property> + <property name="title"> + <string>&Context Menu</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>checkBoxCustom</cstring> + </property> + <property name="text"> + <string>&Display custom entries in context menu</string> + </property> + </widget> + <widget class="QListView" row="1" column="0"> + <column> + <property name="text"> + <string>Root</string> + </property> + <property name="clickable"> + <bool>false</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Menu text</string> + </property> + <property name="clickable"> + <bool>false</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Command</string> + </property> + <property name="clickable"> + <bool>false</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>listViewCommands</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="resizeMode"> + <enum>LastColumn</enum> + </property> + </widget> + <widget class="QLayoutWidget" row="1" column="1"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButtonAddCommand</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Add a new entry</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButtonRemoveCommand</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Remove the selected entry</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>41</width> + <height>61</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButtonUp</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Move the selected entry up</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButtonDown</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Move the selected entry down</string> + </property> + </widget> + </vbox> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="0" column="1"> + <property name="name"> + <cstring>groupBox3</cstring> + </property> + <property name="title"> + <string>Misce&llaneous</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Alias:</string> + </property> + </widget> + <widget class="QLineEdit"> + <property name="name"> + <cstring>lineEditAlias</cstring> + </property> + <property name="whatsThis" stdset="0"> + <string>You can enter an alias for the interface. +It will be used in the tooltip of the system +tray icon for better differentiation of the +icons.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxNotConnected</cstring> + </property> + <property name="text"> + <string>Hide icon when &not connected</string> + </property> + <property name="whatsThis" stdset="0"> + <string>When selected the icon for this interface will be +hidden when the interface is not connected. +When reconnected the icon will be shown again.</string> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer4_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxNotExisting</cstring> + </property> + <property name="text"> + <string>Hide icon &when not existing</string> + </property> + <property name="whatsThis" stdset="0"> + <string>When selected the icon for this interface will be +hidden when the interface does not exist. +This is useful for interfaces that are dynamically +created and destroyed, for example interfaces +of bluetooth adaptors.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxStatistics</cstring> + </property> + <property name="text"> + <string>Activate statistics</string> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout7_2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_3_2</cstring> + </property> + <property name="text"> + <string>Traffic activity threshold:</string> + </property> + <property name="whatsThis" stdset="0"> + <string>Use this for networks with high noise i.e. many packets coming in and out all the time. Set this value high enough so that KNemo won't show incoming and outgoing traffic all the time.</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>spinBoxTrafficThreshold</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="suffix"> + <string> packets/s</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Iconset:</string> + </property> + </widget> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>Monitor</string> + </property> + </item> + <item> + <property name="text"> + <string>Modem</string> + </property> + </item> + <item> + <property name="text"> + <string>Network</string> + </property> + </item> + <item> + <property name="text"> + <string>Wireless</string> + </property> + </item> + <property name="name"> + <cstring>comboBoxIconSet</cstring> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>pixmapDisconnected</cstring> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>pixmapConnected</cstring> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>pixmapIncoming</cstring> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>pixmapOutgoing</cstring> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>pixmapTraffic</cstring> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>tooltip</cstring> + </property> + <attribute name="title"> + <string>&ToolTip</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="4" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string><b>Note: Adding wireless specific information will only show up in the tooltips +of wireless devices not in the tooltips of standard interfaces.</b></string> + </property> + </widget> + <spacer row="3" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>70</width> + <height>129</height> + </size> + </property> + </spacer> + <widget class="QPushButton" row="2" column="1"> + <property name="name"> + <cstring>pushButtonRemoveToolTip</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Remove the selected entry from the list of displayed information</string> + </property> + </widget> + <spacer row="1" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>70</width> + <height>130</height> + </size> + </property> + </spacer> + <widget class="QPushButton" row="2" column="2"> + <property name="name"> + <cstring>pushButtonAddToolTip</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip" stdset="0"> + <string>Add the selected entry to the list of displayed information.</string> + </property> + </widget> + <widget class="QListBox" row="1" column="0" rowspan="3" colspan="1"> + <property name="name"> + <cstring>listBoxAvailable</cstring> + </property> + <property name="selectionMode"> + <enum>Extended</enum> + </property> + </widget> + <widget class="QListBox" row="1" column="3" rowspan="3" colspan="1"> + <property name="name"> + <cstring>listBoxDisplay</cstring> + </property> + <property name="selectionMode"> + <enum>Extended</enum> + </property> + </widget> + <widget class="QLabel" row="0" column="3"> + <property name="name"> + <cstring>textLabel2_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Display:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Available:</string> + </property> + </widget> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>misc</cstring> + </property> + <attribute name="title"> + <string>&Misc</string> + </attribute> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox6_2</cstring> + </property> + <property name="title"> + <string>&Notifications</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButtonNotifications</cstring> + </property> + <property name="text"> + <string>&Configure Sounds && Events...</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBoxUpdateInterval</cstring> + </property> + <property name="title"> + <string>Update interval</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1_3</cstring> + </property> + <property name="text"> + <string>Update interface information every</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>60</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>numInputPollInterval</cstring> + </property> + <property name="value"> + <number>1</number> + </property> + <property name="suffix"> + <string>s</string> + </property> + <property name="whatsThis" stdset="0"> + <string>How often should KNemo poll for interface information. Lower number means more CPU load but faster reaction on changes. Larger number means less CPU load but slow reaction on changes.</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBoxStatistics</cstring> + </property> + <property name="title"> + <string>Statistics</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="2" column="3"> + <property name="name"> + <cstring>pushButtonStatisticsDir</cstring> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>textLabel1_5</cstring> + </property> + <property name="text"> + <string>Statistics are stored in the following directory:</string> + </property> + </widget> + <widget class="QLineEdit" row="2" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>lineEditStatisticsDir</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1_6</cstring> + </property> + <property name="text"> + <string>Save statistics every</string> + </property> + </widget> + <spacer row="0" column="1"> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>131</width> + <height>21</height> + </size> + </property> + </spacer> + <widget class="KIntNumInput" row="0" column="2" rowspan="1" colspan="2"> + <property name="name"> + <cstring>numInputSaveInterval</cstring> + </property> + <property name="value"> + <number>60</number> + </property> + <property name="suffix"> + <string>s</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox11_2</cstring> + </property> + <property name="title"> + <string>Backend</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel1_7</cstring> + </property> + <property name="text"> + <string>Use the following backend</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Description:</string> + </property> + <property name="alignment"> + <set>AlignTop</set> + </property> + </widget> + <widget class="QLabel" row="1" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>textLabelBackendDescription</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter</set> + </property> + </widget> + <widget class="QComboBox" row="0" column="3"> + <property name="name"> + <cstring>comboBoxBackends</cstring> + </property> + </widget> + <spacer row="0" column="2"> + <property name="name"> + <cstring>spacer8</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>100</width> + <height>21</height> + </size> + </property> + </spacer> + </grid> + </widget> + <spacer> + <property name="name"> + <cstring>spacer21</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>31</width> + <height>30</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>trafficplotter</cstring> + </property> + <attribute name="title"> + <string>Traffic &Plotter</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>groupBox7</cstring> + </property> + <property name="title"> + <string>Scale</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntSpinBox" row="0" column="3"> + <property name="name"> + <cstring>spinBoxPixel</cstring> + </property> + <property name="maxValue"> + <number>50</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>textLabel8_2</cstring> + </property> + <property name="text"> + <string>Pixel per time period:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="2"> + <property name="name"> + <cstring>textLabel9_2_2</cstring> + </property> + <property name="text"> + <string>Ma&ximum value:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>spinBoxMaxValue</cstring> + </property> + </widget> + <widget class="KIntSpinBox" row="1" column="3"> + <property name="name"> + <cstring>spinBoxMaxValue</cstring> + </property> + <property name="maxValue"> + <number>50000</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>checkBoxAutoDetection</cstring> + </property> + <property name="text"> + <string>Automatic &range detection</string> + </property> + </widget> + <widget class="KIntSpinBox" row="1" column="1"> + <property name="name"> + <cstring>spinBoxMinValue</cstring> + </property> + <property name="maxValue"> + <number>49999</number> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel9_3</cstring> + </property> + <property name="text"> + <string>&Minimum value:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>spinBoxMinValue</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="2" column="1"> + <property name="name"> + <cstring>groupBox9</cstring> + </property> + <property name="title"> + <string>Text</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>checkBoxLabels</cstring> + </property> + <property name="text"> + <string>&Labels</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkBoxTopBar</cstring> + </property> + <property name="text"> + <string>Top &bar</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel3_2</cstring> + </property> + <property name="text"> + <string>Fo&nt size:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>spinBoxFontSize</cstring> + </property> + </widget> + <widget class="KIntSpinBox" row="2" column="1"> + <property name="name"> + <cstring>spinBoxFontSize</cstring> + </property> + <property name="maxValue"> + <number>24</number> + </property> + <property name="minValue"> + <number>5</number> + </property> + <property name="value"> + <number>8</number> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="2" column="0"> + <property name="name"> + <cstring>groupBox8</cstring> + </property> + <property name="title"> + <string>Lines</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntSpinBox" row="0" column="2"> + <property name="name"> + <cstring>spinBoxDistance</cstring> + </property> + <property name="maxValue"> + <number>120</number> + </property> + <property name="minValue"> + <number>10</number> + </property> + <property name="value"> + <number>30</number> + </property> + </widget> + <widget class="QLabel" row="0" column="1"> + <property name="name"> + <cstring>textLabel1_2_2</cstring> + </property> + <property name="text"> + <string>&Distance:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>spinBoxDistance</cstring> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0"> + <property name="name"> + <cstring>checkBoxVLines</cstring> + </property> + <property name="text"> + <string>Vertic&al lines</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkBoxVLinesScroll</cstring> + </property> + <property name="text"> + <string>V&ertical lines scroll</string> + </property> + </widget> + <widget class="KIntSpinBox" row="2" column="2"> + <property name="name"> + <cstring>spinBoxCount</cstring> + </property> + <property name="maxValue"> + <number>20</number> + </property> + <property name="minValue"> + <number>2</number> + </property> + <property name="value"> + <number>5</number> + </property> + </widget> + <widget class="QLabel" row="2" column="1"> + <property name="name"> + <cstring>textLabel2_4</cstring> + </property> + <property name="text"> + <string>Co&unt:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>spinBoxCount</cstring> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0"> + <property name="name"> + <cstring>checkBoxHLines</cstring> + </property> + <property name="text"> + <string>Hori&zontal lines</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>groupBox10</cstring> + </property> + <property name="title"> + <string>&Colors</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel4_2</cstring> + </property> + <property name="text"> + <string>Vertical lines:</string> + </property> + </widget> + <widget class="KColorButton" row="0" column="1"> + <property name="name"> + <cstring>kColorButtonVLines</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>kColorButtonHLines</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="KColorButton" row="0" column="3"> + <property name="name"> + <cstring>kColorButtonIncoming</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel6_2</cstring> + </property> + <property name="text"> + <string>Background:</string> + </property> + </widget> + <widget class="KColorButton" row="2" column="1"> + <property name="name"> + <cstring>kColorButtonBackground</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel5_2</cstring> + </property> + <property name="text"> + <string>Horizontal lines:</string> + </property> + </widget> + <widget class="QLabel" row="1" column="2"> + <property name="name"> + <cstring>textLabel7_2_2</cstring> + </property> + <property name="text"> + <string>Outgoing traffic:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>textLabel7_3</cstring> + </property> + <property name="text"> + <string>Incoming traffic:</string> + </property> + </widget> + <widget class="KColorButton" row="1" column="3"> + <property name="name"> + <cstring>kColorButtonOutgoing</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>groupBox15</cstring> + </property> + <property name="title"> + <string>Traffic</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxIncoming</cstring> + </property> + <property name="text"> + <string>Sho&w incoming traffic</string> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>checkBoxOutgoing</cstring> + </property> + <property name="text"> + <string>Show &outgoing traffic</string> + </property> + </widget> + </hbox> + </widget> + </grid> + </widget> + </widget> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>checkBoxNotConnected</sender> + <signal>toggled(bool)</signal> + <receiver>checkBoxNotExisting</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxAutoDetection</sender> + <signal>toggled(bool)</signal> + <receiver>spinBoxMinValue</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxAutoDetection</sender> + <signal>toggled(bool)</signal> + <receiver>spinBoxMaxValue</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxVLines</sender> + <signal>toggled(bool)</signal> + <receiver>checkBoxVLinesScroll</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxVLines</sender> + <signal>toggled(bool)</signal> + <receiver>spinBoxDistance</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxVLines</sender> + <signal>toggled(bool)</signal> + <receiver>kColorButtonVLines</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxHLines</sender> + <signal>toggled(bool)</signal> + <receiver>spinBoxCount</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxHLines</sender> + <signal>toggled(bool)</signal> + <receiver>checkBoxLabels</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxHLines</sender> + <signal>toggled(bool)</signal> + <receiver>kColorButtonHLines</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxIncoming</sender> + <signal>toggled(bool)</signal> + <receiver>kColorButtonIncoming</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxOutgoing</sender> + <signal>toggled(bool)</signal> + <receiver>kColorButtonOutgoing</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxCustom</sender> + <signal>toggled(bool)</signal> + <receiver>listViewCommands</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxCustom</sender> + <signal>toggled(bool)</signal> + <receiver>pushButtonAddCommand</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>checkBoxStartKNemo</sender> + <signal>toggled(bool)</signal> + <receiver>tabWidgetConfiguration</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<tabstops> + <tabstop>tabWidgetConfiguration</tabstop> + <tabstop>listBoxInterfaces</tabstop> + <tabstop>pushButtonNew</tabstop> + <tabstop>pushButtonDelete</tabstop> + <tabstop>lineEditAlias</tabstop> + <tabstop>checkBoxNotConnected</tabstop> + <tabstop>checkBoxCustom</tabstop> + <tabstop>listBoxAvailable</tabstop> + <tabstop>listBoxDisplay</tabstop> + <tabstop>pushButtonRemoveToolTip</tabstop> + <tabstop>pushButtonAddToolTip</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/src/kcm/kcm_knemo.desktop b/src/kcm/kcm_knemo.desktop new file mode 100644 index 0000000..b29b94a --- /dev/null +++ b/src/kcm/kcm_knemo.desktop @@ -0,0 +1,89 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=kcmshell kcm_knemo +Icon=knemo + +X-KDE-ModuleType=Library +X-KDE-Library=knemo +X-KDE-FactoryName=knemo +X-KDE-ParentApp=kcontrol + +Name=Network Monitor +Name[bg]=Монитор на мрежата +Name[br]=Eveshaer ar rouedad +Name[cs]=Monitor sítě +Name[da]=Netværkovervågning +Name[de]=Netzwerkmonitor +Name[el]=Επίβλεψη δικτύου +Name[es]=Monitor de red +Name[et]=Võrgumonitor +Name[ga]=Monatóir Líonra +Name[gl]=Monitor da Rede +Name[it]=Monitor di rete +Name[ja]=ネットワークモニタ +Name[ka]=ქსელის მონიტორი +Name[lt]=Tinklo stebėjimas +Name[nl]=Netwerkmonitor +Name[pa]=ਨੈਟਵਰਕ ਨਿਗਰਾਨ +Name[pl]=Monitor sieci +Name[pt]=Monitor da Rede +Name[pt_BR]=Monitor de Rede +Name[ru]=Монитор сети +Name[sr]=Надгледање мреже +Name[sr@Latn]=Nadgledanje mreže +Name[sv]=Nätverksövervakare +Name[tr]=Ağ İzleyici +Name[uk]=Монітор мережі +Name[xx]=xxNetwork Monitorxx +Name[zh_CN]=网络监视器 +Comment=Monitor network interfaces +Comment[bg]=Показване на информация за мрежовите интерфейси +Comment[br]=Eveshaer etrefasoù ar rouedad +Comment[cs]=Rozhraní monitoru sítě +Comment[da]=Overvåger netværkgrænseflader +Comment[de]=Überwachung von Netzwerkschnittstellen +Comment[el]=Επίβλεψη διασυνδέσεων δικτύου +Comment[es]=Monitor de interfaces de red +Comment[et]=Võrguliideste monitor +Comment[ga]=Déan monatóireacht ar chomhéadain líonra +Comment[gl]=Fai seguimento das interfaces de rede +Comment[it]=Controlla le interfacce di rete +Comment[ja]=ネットワークインターフェースを監視 +Comment[ka]=ქსელის ინტერფეისების მონიტორინგი +Comment[lt]=Stebėti tinklo įrenginius +Comment[nl]=Volg netwerkinterfaces +Comment[pa]=ਨੈਟਵਰਕ ਇੰਟਰਫੇਸ ਲਈ ਨਿਗਰਾਨੀ +Comment[pl]=Monitorowanie interfejsów sieciowych +Comment[pt]=Vigia interfaces de rede +Comment[pt_BR]=Monitor das interfaces de rede +Comment[ru]=Наблюдение за сетевыми интерфейсами +Comment[sr]=Интерфејс надгледања мреже +Comment[sr@Latn]=Interfejs nadgledanja mreže +Comment[sv]=Övervaka nätverksgränssnitt +Comment[tr]=Ağ arayüzlerini izler +Comment[uk]=Нагляд за мережними інтерфейсами +Comment[xx]=xxMonitor network interfacesxx +Comment[zh_CN]=监视网络接口 + +Keywords=knemo,network monitor,wlan monitor,wifi monitor,ethernet monitor,wireless monitor,systray +Keywords[cs]=knemo,monitor sítě,monitor wlan,monitor wifi,monitor ethernetu,monitor bezdrátového připojení,systray +Keywords[da]=knemo,netværksovervågning,WLAN-overvågning,WIFI-overvågning,Ethernet-overvågning,trådløs overvågning,statusfelt +Keywords[de]=knemo,netzwerk-monitor,wlan-monitor,wifi-monitor,ethernet-monitor,wireless-monitor,kontrollleiste,überwachung,netzwerk,drahtlos-monitor +Keywords[el]=knemo,επόπτης δικτύου,επόπτης wlan,επόπτης wifi,επόπτης ethernet, επόπτης wireless,πλαίσιο συστήματος +Keywords[es]=knemo,monitor de red,monitor de wlan,monitor wifi,monitor de ethernet,monitor inalámbrico,bandeja del sistema +Keywords[et]=knemo,võrgumonitor,wlan monitor,wifi monitor,ethernet monitor,traadita võrgu monitor,süsteemne salv +Keywords[ga]=knemo,monatóir líonra,monatóir wlan,monatóir wifi,monatóir ethernet,monatóir líonra gan sreang,tráidire an chórais +Keywords[gl]=knemo,monitor, rede, wlan, wifi, ethernet, wireless,systray +Keywords[it]=knemo,monitor di rete,wlan monitor,monitor senza fili,ethernet monitor,vassoio di sistema +Keywords[ja]=knemo,ネットワークモニタ,wlan モニタ,wifi モニタ,ethernet モニタ,ワイヤレスモニタ,システムトレイ +Keywords[nl]=knemo,netwerkmonitor,wlan-monitor,wifi-monitor,ethernetmonitor,wireless-monitor,systeemvak +Keywords[pt]=knemo,monitor da rede,monitor de wlan,monitor wifi,monitor de ethernet,monitor sem-fios,bandeja do sistema +Keywords[pt_BR]=knemo,monitor de rede,wlan,monitor de wifi monitor,monitor ethernet monitor,monitor de wireless,painel do sistema, mini-aplicativo +Keywords[ru]=knemo,мониторинг сети,мониторинг беспроводной сети,wifi монитор,монитор локальной сети,системный лоток,сеть,беспроводная сеть +Keywords[sv]=knemo,nätverksövervakning,WLAN-övervakning,WIFI-övervakning,Ethernet-övervakning,trådlös övervakning,systembricka +Keywords[uk]=knemo,network monitor,wlan monitor,wifi monitor,ethernet monitor,wireless monitor,systray,мережа,монітор,системний лоток,монітор wifi +Keywords[xx]=xxknemo,network monitor,wlan monitor,wifi monitor,ethernet monitor,wireless monitor,systrayxx +Keywords[zh_CN]=knemo,network monitor,wlan monitor,wifi monitor,ethernet monitor,wireless monitor,systray,网络监视器,无限局域网监视器,wifi 监视器以太网监视器,无线网络监视器,系统托盘 + +Categories=Qt;KDE;X-KDE-settings-network;X-KDE-systemsettings-network |