From 06772a369f2beef80bb291ded30cbe125a24af56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Fri, 26 Oct 2018 04:07:01 +0200 Subject: Fix structure of directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko --- src/configure.cpp | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 src/configure.cpp (limited to 'src/configure.cpp') diff --git a/src/configure.cpp b/src/configure.cpp new file mode 100644 index 0000000..f3ffcff --- /dev/null +++ b/src/configure.cpp @@ -0,0 +1,161 @@ +/*************************************************************************** + * 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" + +// TQt includes +#include +#include +#include +#include +#include +#include +// Kde includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +Configure::Configure(KNetStats* parent, const InterfaceMap& ifs) : ConfigureBase(parent) { + // Load configuration + TDEIconLoader* loader = kapp->iconLoader(); + + TQPixmap iconPCI = loader->loadIcon("icon_pci.png", TDEIcon::Small, 16); + + // Clone the configuration. + for (InterfaceMap::ConstIterator it = ifs.begin(); it != ifs.end(); ++it) { + mInterfaces->insertItem(iconPCI, it.key()); + mConfig[it.key()] = it.data()->options(); + +// parent->readInterfaceOptions(*it, &mConfig[*it]); + } + + mInterfaces->setCurrentItem(0); + changeInterface(mInterfaces->selectedItem()); + + 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&))); +} + +void Configure::changeInterface(TQListBoxItem* item) { + TQString interface = item->text(); + + 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) +{ + TDEIconLoader* loader = kapp->iconLoader(); + mIconError->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_error.png", + TDEIcon::Panel, ICONSIZE)); + mIconNone->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_none.png", + TDEIcon::Panel, ICONSIZE)); + mIconTx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_tx.png", + TDEIcon::Panel, ICONSIZE)); + mIconRx->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_rx.png", + TDEIcon::Panel, ICONSIZE)); + mIconBoth->setPixmap(loader->loadIcon("theme"+TQString::number(theme)+"_both.png", + TDEIcon::Panel, ICONSIZE)); +} +/* +void Configure::showInterfaceContextMenu(TQListBoxItem* item, const TQPoint& point) { + if (!item && mConfig.size() == 1) + return; + TQPixmap icon = kapp->iconLoader()->loadIcon("edit-delete", TDEIcon::Small, 16); + TQPopupMenu* menu = new TQPopupMenu(this); + menu->insertItem(icon, i18n("Renomve Interface"), this, TQT_SLOT(removeInterface())); + menu->exec(point); +} + +void Configure::removeInterface() { + mConfig.erase(mInterfaces->currentText()); + mInterfaces->removeItem(mInterfaces->currentItem()); +} +*/ +#include "configure.moc" -- cgit v1.2.1