KNemo – network interfaces monitor for systray
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.
 
 
 
 
 
 

128 lines
3.9 KiB

  1. /* This file is part of KNemo
  2. Copyright (C) 2004, 2005 Percy Leonhardt <percy@eris23.de>
  3. KNemo is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Library General Public License as
  5. published by the Free Software Foundation; either version 2 of
  6. the License, or (at your option) any later version.
  7. KNemo is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public License
  12. along with this library; see the file COPYING.LIB. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  14. Boston, MA 02110-1301, USA.
  15. */
  16. #include <tqwidget.h>
  17. #include <kdebug.h>
  18. #include <tdeglobal.h>
  19. #include <tdelocale.h>
  20. #include <kbugreport.h>
  21. #include <tdeaboutdata.h>
  22. #include <tdepopupmenu.h>
  23. #include <kiconloader.h>
  24. #include <tdeapplication.h>
  25. #include <tdeaboutapplication.h>
  26. #include <tdeactioncollection.h>
  27. #include "interfacetray.h"
  28. static const char description[] =
  29. I18N_NOOP( "KNemo - the TDE Network Monitor" );
  30. static const char version[] = "0.4.8";
  31. InterfaceTray::InterfaceTray( const TQString& ifname,
  32. TQWidget* parent, const char* name )
  33. : KSystemTray( parent, name )
  34. {
  35. actionCollection()->clear(); // remove the quit entry
  36. TDEPopupMenu* popup = contextMenu();
  37. int id = popup->idAt( 0 );
  38. popup->changeTitle( id, SmallIcon( "knemo" ),
  39. "KNemo - " + ifname );
  40. popup->insertItem( SmallIcon( "knemo" ),
  41. i18n( "&About KNemo" ), this,
  42. TQT_SLOT( showAboutDialog() ) );
  43. popup->insertItem( i18n( "&Report Bug..." ), this,
  44. TQT_SLOT( showReportBugDialog() ) );
  45. popup->insertSeparator();
  46. popup->insertItem( SmallIcon( "configure" ),
  47. i18n( "&Configure KNemo..." ), this,
  48. TQT_SIGNAL( configSelected() ) );
  49. popup->insertItem( SmallIcon( "ksysguard" ),
  50. i18n( "&Open Traffic Plotter" ), this,
  51. TQT_SLOT( showGraph() ) );
  52. }
  53. InterfaceTray::~InterfaceTray()
  54. {
  55. }
  56. void InterfaceTray::resizeEvent ( TQResizeEvent * )
  57. {
  58. // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes
  59. emit iconResized();
  60. }
  61. void InterfaceTray::mousePressEvent( TQMouseEvent* e )
  62. {
  63. if ( !TQT_TQRECT_OBJECT(rect()).contains( e->pos() ) )
  64. return;
  65. switch( e->button() )
  66. {
  67. case Qt::LeftButton:
  68. emit leftClicked();
  69. break;
  70. case Qt::MidButton:
  71. emit graphSelected( true );
  72. break;
  73. case Qt::RightButton:
  74. KSystemTray::mousePressEvent( e );
  75. break;
  76. default:
  77. break;
  78. }
  79. }
  80. void InterfaceTray::showAboutDialog()
  81. {
  82. TDEAboutData data ( "knemo", I18N_NOOP( "KNemo" ), version,
  83. description, TDEAboutData::License_GPL,
  84. "(c) 2004, 2005, 2006 Percy Leonhardt\n\nSignal plotter taken from KSysGuard\n(c) 1999 - 2002, Chris Schlaeger",
  85. 0,
  86. "http://extragear.kde.org/apps/knemo/"
  87. );
  88. data.addAuthor( "Percy Leonhardt", I18N_NOOP( "Author" ),
  89. "percy@eris23.de" );
  90. data.addCredit( "Michael Olbrich", I18N_NOOP( "Threshold support" ),
  91. "michael.olbrich@gmx.net" );
  92. data.addCredit( "Chris Schlaeger", I18N_NOOP( "Signal plotter" ),
  93. "cs@kde.org" );
  94. TDEAboutApplication about( &data );
  95. about.setProgramLogo( DesktopIcon( "knemo" ) );
  96. about.exec();
  97. }
  98. void InterfaceTray::showReportBugDialog()
  99. {
  100. TDEAboutData data ( "knemo", I18N_NOOP( "KNemo" ), version );
  101. KBugReport bugReport( 0, true, &data );
  102. bugReport.exec();
  103. }
  104. void InterfaceTray::showGraph()
  105. {
  106. emit graphSelected( false );
  107. }
  108. #include "interfacetray.moc"