⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kwifimanager_kickerapplet.cpp

📁 Linux/Unix下无限网卡配置和管理程序
💻 CPP
字号:
/***************************************************************************                          kwifimanager_kickerapplet.cpp  -  description                             -------------------    begin                : Mit Sep 26 14:58:20 CEST 2001    copyright            : (C) 2001 by Stefan Winter    email                : mail@stefan-winter.de ***************************************************************************//*************************************************************************** *                                                                         * *   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.                                   * *                                                                         * ***************************************************************************/#include <kglobal.h>#include <klocale.h>#include <kconfig.h>#include <ksimpleconfig.h>#include <kstandarddirs.h>#include <kapplication.h>#include <kprocess.h>#include <kmessagebox.h>#include <qtimer.h>#include <qtooltip.h>#include <qpushbutton.h>#include <qcheckbox.h>#include "kwifimanager_kickerapplet.h"extern "C"{  KPanelApplet *init (QWidget * parent, const QString configFile)  {    KGlobal::locale ()->insertCatalogue ("kwifimanager_kickerapplet");    return new Kwifimanager_kickerapplet (configFile, KPanelApplet::Normal, KPanelApplet::About | KPanelApplet::Preferences, parent, "kwifimanager_kickerapplet");  }}intsockets_open (void){  int ipx_sock = -1;		/* IPX socket                   */  int ax25_sock = -1;		/* AX.25 socket                 */  int inet_sock = -1;		/* INET socket                  */  int ddp_sock = -1;		/* Appletalk DDP socket         */  inet_sock = socket (AF_INET, SOCK_DGRAM, 0);  if (inet_sock != -1)    return inet_sock;  ipx_sock = socket (AF_IPX, SOCK_DGRAM, 0);  if (ipx_sock != -1)    return ipx_sock;  ax25_sock = socket (AF_AX25, SOCK_DGRAM, 0);  if (ax25_sock != -1)    return ax25_sock;  ddp_sock = socket (AF_APPLETALK, SOCK_DGRAM, 0);  return ddp_sock;}Kwifimanager_kickerapplet::Kwifimanager_kickerapplet (const QString & configFile, Type type, int actions, QWidget * parent, const char *name):KPanelApplet (configFile, type, 5, parent, name){  // Get the current application configuration handle  skfd = -1;			/* generic raw socket desc.     */  /* Create a channel to the NET kernel. */  if ((skfd = sockets_open ()) < 0)    {      perror ("Error opening socket!");      exit (-1);    };  ksConfig = config ();  KStandardDirs finder;  QString kdedir = finder.localkdedir ();  QString kde = kdedir + "/";  KSimpleConfig *    conffile =    new    KSimpleConfig (kde + "appletrc", true);  conffile->setGroup ("Applet");  allow_flashing_low = conffile->readBoolEntry ("Flash on low conn quality", true);  allow_flashing_crit = conffile->readBoolEntry ("Flash on critical conn quality", true);  allow_flashing_dropped = conffile->readBoolEntry ("Flash on zero conn quality", true);  mainView = new myview (skfd, allow_flashing_low, allow_flashing_crit, allow_flashing_dropped, this);  mainView->setBackgroundMode (QWidget::PaletteBackground);  mainView->setMinimumSize (QSize (0, 0));  QTimer *    counter =    new    QTimer (this);  connect (counter, SIGNAL (timeout ()), mainView, SLOT (repaint ()));  counter->start (250);  mainView->setMouseTracking (true);  mainView->show ();}Kwifimanager_kickerapplet::~Kwifimanager_kickerapplet (){}voidKwifimanager_kickerapplet::about (){  KMessageBox::information (0, i18n ("The KWiFiManager Kicker applet\n\nThis applet ist part of the KWiFiManager suite. \nPlease launch KWiFiManager itself for more\ninformation."));}voidKwifimanager_kickerapplet::preferences (){  QVBox *configurator = new QVBox (0, "Applet Configuration");  flash_low = new QCheckBox ("Applet flashes when connection is low", configurator, "no_use_for_a_name");  flash_low->setChecked (mainView->allow_flash_low);  flash_crit = new QCheckBox ("Applet flashes when connection is critical", configurator, "no_use_for_a_name2");  flash_crit->setChecked (mainView->allow_flash_crit);  flash_dropped = new QCheckBox ("Applet flashes when no connection is possible", configurator, "no_use_for_a_name3");  flash_dropped->setChecked (mainView->allow_flash_dropped);  QPushButton *launch = new QPushButton ("Configure the wireless device...", configurator,					 "launch_kcmodule");  QPushButton *ok = new QPushButton ("Save changes", configurator, "save_changes");  ok->setMaximumWidth (100);  connect (ok, SIGNAL (clicked ()), this, SLOT (saveChanges ()));  connect (launch, SIGNAL (clicked ()), this, SLOT (launchKCModule ()));  configurator->show ();}voidKwifimanager_kickerapplet::saveChanges (){  KStandardDirs finder;  QString kdedir = finder.localkdedir ();  QString kde = kdedir + "/";  KSimpleConfig *conffile = new KSimpleConfig (kde + "appletrc", false);  conffile->setGroup ("Applet");  conffile->writeEntry ("Flash on low conn quality", flash_low->isChecked ());  conffile->writeEntry ("Flash on critical conn quality", flash_crit->isChecked ());  conffile->writeEntry ("Flash on zero conn quality", flash_dropped->isChecked ());  conffile->sync ();  mainView->allow_flash_low = flash_low->isChecked ();  mainView->allow_flash_crit = flash_crit->isChecked ();  mainView->allow_flash_dropped = flash_dropped->isChecked ();}voidKwifimanager_kickerapplet::launchKCModule (){  KProcess startConf;  startConf << "kdesu" << "kcmshell" << "kwifimanager_kcmodule";  startConf.start (KProcess::DontCare);}intKwifimanager_kickerapplet::widthForHeight (int height) const{  return 25;}intKwifimanager_kickerapplet::heightForWidth (int width) const{  return width;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -