You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
162 lines
6.1 KiB
162 lines
6.1 KiB
15 years ago
|
/***************************************************************************
|
||
|
* Copyright (C) 2004 by Hugo Parente Lima *
|
||
|
* hugo_pl@users.sourceforge.net *
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
* *
|
||
|
* This program 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 General Public License for more details. *
|
||
|
* *
|
||
|
* You should have received a copy of the GNU General Public License *
|
||
|
* along with this program; if not, write to the *
|
||
|
* Free Software Foundation, Inc., *
|
||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#include "configure.h"
|
||
|
#include "knetstats.h"
|
||
|
|
||
13 years ago
|
// TQt includes
|
||
|
#include <tqstringlist.h>
|
||
|
#include <tqlistbox.h>
|
||
|
#include <tqcheckbox.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqwidgetstack.h>
|
||
|
#include <tqpopupmenu.h>
|
||
15 years ago
|
// Kde includes
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
#include <kiconloader.h>
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
12 years ago
|
#include <tdefontrequester.h>
|
||
15 years ago
|
#include <knuminput.h>
|
||
|
#include <kcolorbutton.h>
|
||
|
#include <kcombobox.h>
|
||
12 years ago
|
#include <tdemessagebox.h>
|
||
15 years ago
|
#include <kpushbutton.h>
|
||
|
|
||
|
|
||
13 years ago
|
Configure::Configure(KNetStats* parent, const InterfaceMap& ifs) : ConfigureBase(parent) {
|
||
15 years ago
|
// Load configuration
|
||
12 years ago
|
TDEIconLoader* loader = kapp->iconLoader();
|
||
15 years ago
|
|
||
12 years ago
|
TQPixmap iconPCI = loader->loadIcon("icon_pci.png", TDEIcon::Small, 16);
|
||
15 years ago
|
|
||
|
// Clone the configuration.
|
||
|
for (InterfaceMap::ConstIterator it = ifs.begin(); it != ifs.end(); ++it) {
|
||
|
mInterfaces->insertItem(iconPCI, it.key());
|
||
|
mConfig[it.key()] = it.data()->options();
|
||
|
|
||
13 years ago
|
// parent->readInterfaceOptions(*it, &mConfig[*it]);
|
||
15 years ago
|
}
|
||
|
|
||
|
mInterfaces->setCurrentItem(0);
|
||
|
changeInterface(mInterfaces->selectedItem());
|
||
|
|
||
13 years ago
|
connect(mInterfaces, TQT_SIGNAL(selectionChanged(TQListBoxItem*)), this, TQT_SLOT(changeInterface(TQListBoxItem*)));
|
||
|
connect(mTheme, TQT_SIGNAL(activated(int)), this, TQT_SLOT(changeTheme(int)));
|
||
|
//connect(mInterfaces, TQT_SIGNAL(contextMenuRequested(TQListBoxItem*, const TQPoint&)), this, TQT_SLOT(showInterfaceContextMenu(TQListBoxItem*, const TQPoint&)));
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
void Configure::changeInterface(TQListBoxItem* item) {
|
||
|
TQString interface = item->text();
|
||
15 years ago
|
|
||
|
if (!mCurrentItem.isEmpty())
|
||
|
{
|
||
|
// Salvas as modificações passadas
|
||
|
KNetStatsView::Options& oldview = mConfig[mCurrentItem];
|
||
|
// general options
|
||
|
oldview.mMonitoring = mMonitoring->isChecked();
|
||
|
oldview.mUpdateInterval = mUpdateInterval->value();
|
||
|
oldview.mViewMode = (KNetStatsView::Mode) mViewMode->currentItem();
|
||
|
// txt view options
|
||
|
oldview.mTxtUplColor = mTxtUplColor->color();
|
||
|
oldview.mTxtDldColor = mTxtDldColor->color();
|
||
|
oldview.mTxtFont = mTxtFont->font();
|
||
|
// icon view
|
||
|
oldview.mTheme = mTheme->currentItem();
|
||
|
// chart view
|
||
|
oldview.mChartUplColor = mChartUplColor->color();
|
||
|
oldview.mChartDldColor = mChartDldColor->color();
|
||
|
oldview.mChartBgColor = mChartBgColor->color();
|
||
|
oldview.mChartTransparentBackground = mChartTransparentBackground->isChecked();
|
||
|
}
|
||
|
|
||
|
if (interface == mCurrentItem)
|
||
|
return;
|
||
|
// Carrega as opt. da nova interface
|
||
|
KNetStatsView::Options& view = mConfig[interface];
|
||
|
// general
|
||
|
mMonitoring->setChecked(view.mMonitoring);
|
||
|
mUpdateInterval->setValue(view.mUpdateInterval);
|
||
|
mViewMode->setCurrentItem(view.mViewMode);
|
||
|
mWdgStack->raiseWidget(view.mViewMode);
|
||
|
// txt options
|
||
|
mTxtUplColor->setColor(view.mTxtUplColor);
|
||
|
mTxtDldColor->setColor(view.mTxtDldColor);
|
||
|
mTxtFont->setFont( view.mTxtFont );
|
||
|
// icon options
|
||
|
mTheme->setCurrentItem(view.mTheme);
|
||
|
changeTheme(view.mTheme);
|
||
|
// chart options
|
||
|
mChartUplColor->setColor(view.mChartUplColor);
|
||
|
mChartDldColor->setColor(view.mChartDldColor);
|
||
|
mChartBgColor->setColor(view.mChartBgColor);
|
||
|
mChartTransparentBackground->setChecked(view.mChartTransparentBackground);
|
||
|
|
||
|
mCurrentItem = interface;
|
||
|
}
|
||
|
|
||
|
bool Configure::canSaveConfig()
|
||
|
{
|
||
|
// update the options
|
||
|
changeInterface(mInterfaces->item( mInterfaces->currentItem() ));
|
||
|
|
||
|
bool ok = false;
|
||
|
for(OptionsMap::ConstIterator i = mConfig.begin(); i != mConfig.end(); ++i)
|
||
|
if (i.data().mMonitoring) {
|
||
|
ok = true;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (!ok)
|
||
|
KMessageBox::error(this, i18n("You need to select at least one interface to monitor."));
|
||
|
return ok;
|
||
|
}
|
||
|
|
||
|
void Configure::changeTheme(int theme)
|
||
|
{
|
||
12 years ago
|
TDEIconLoader* loader = kapp->iconLoader();
|
||
13 years ago
|
mIconError->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_error.png",
|
||
12 years ago
|
TDEIcon::Panel, ICONSIZE));
|
||
13 years ago
|
mIconNone->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_none.png",
|
||
12 years ago
|
TDEIcon::Panel, ICONSIZE));
|
||
13 years ago
|
mIconTx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_tx.png",
|
||
12 years ago
|
TDEIcon::Panel, ICONSIZE));
|
||
13 years ago
|
mIconRx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_rx.png",
|
||
12 years ago
|
TDEIcon::Panel, ICONSIZE));
|
||
13 years ago
|
mIconBoth->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_both.png",
|
||
12 years ago
|
TDEIcon::Panel, ICONSIZE));
|
||
15 years ago
|
}
|
||
|
/*
|
||
13 years ago
|
void Configure::showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point) {
|
||
15 years ago
|
if (!item && mConfig.size() == 1)
|
||
|
return;
|
||
10 years ago
|
TQPixmap icon = kapp->iconLoader()->loadIcon("edit-delete", TDEIcon::Small, 16);
|
||
13 years ago
|
TQPopupMenu* menu = new TQPopupMenu(this);
|
||
|
menu->insertItem(icon, i18n("Renomve Interface"), this, TQT_SLOT(removeInterface()));
|
||
15 years ago
|
menu->exec(point);
|
||
|
}
|
||
|
|
||
|
void Configure::removeInterface() {
|
||
|
mConfig.erase(mInterfaces->currentText());
|
||
|
mInterfaces->removeItem(mInterfaces->currentItem());
|
||
|
}
|
||
|
*/
|
||
|
#include "configure.moc"
|