From 8395ccefd8ea126232281bcb7588fac2acc0d50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Thu, 13 Dec 2018 18:35:41 +0100 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 (cherry picked from commit 0557917aa98c792eb316ce176c97849f3e7bdb3e) --- CMakeLists.txt | 5 +- doc/CMakeLists.txt | 3 +- doc/en/CMakeLists.txt | 1 + doc/en/Makefile.am | 18 ++ doc/en/index.docbook | 289 ++++++++++++++++++ doc/kcpuload/CMakeLists.txt | 1 - doc/kcpuload/Makefile.am | 18 -- doc/kcpuload/index.docbook | 289 ------------------ icons/CMakeLists.txt | 1 + icons/Makefile.am | 18 ++ icons/hi16-action-bars.png | Bin 0 -> 166 bytes icons/hi16-action-barson.png | Bin 0 -> 208 bytes icons/hi16-action-color.png | Bin 0 -> 210 bytes icons/hi16-action-color0.png | Bin 0 -> 222 bytes icons/hi16-action-color1.png | Bin 0 -> 225 bytes icons/hi16-action-grid.png | Bin 0 -> 149 bytes icons/hi16-action-gridon.png | Bin 0 -> 146 bytes icons/hi16-action-labels.png | Bin 0 -> 149 bytes icons/hi16-action-labelson.png | Bin 0 -> 174 bytes icons/hi16-action-lines.png | Bin 0 -> 168 bytes icons/hi16-action-lineson.png | Bin 0 -> 206 bytes icons/hi16-action-shaded.png | Bin 0 -> 358 bytes icons/hi16-action-shadedon.png | Bin 0 -> 419 bytes icons/hi16-action-smp.png | Bin 0 -> 192 bytes icons/hi16-action-smpon.png | Bin 0 -> 225 bytes icons/hi16-action-soft.png | Bin 0 -> 154 bytes icons/hi16-action-softon.png | Bin 0 -> 168 bytes icons/hi16-action-speedarrow.png | Bin 0 -> 150 bytes icons/hi16-action-split.png | Bin 0 -> 130 bytes icons/hi16-action-spliton.png | Bin 0 -> 132 bytes kcpuload/AUTHORS | 2 - kcpuload/CMakeLists.txt | 2 - kcpuload/COPYING | 280 ----------------- kcpuload/ChangeLog | 53 ---- kcpuload/INSTALL | 167 ---------- kcpuload/Makefile.am | 17 -- kcpuload/README | 29 -- kcpuload/TODO | 7 - kcpuload/icons/CMakeLists.txt | 1 - kcpuload/icons/Makefile.am | 18 -- kcpuload/icons/hi16-action-bars.png | Bin 166 -> 0 bytes kcpuload/icons/hi16-action-barson.png | Bin 208 -> 0 bytes kcpuload/icons/hi16-action-color.png | Bin 210 -> 0 bytes kcpuload/icons/hi16-action-color0.png | Bin 222 -> 0 bytes kcpuload/icons/hi16-action-color1.png | Bin 225 -> 0 bytes kcpuload/icons/hi16-action-grid.png | Bin 149 -> 0 bytes kcpuload/icons/hi16-action-gridon.png | Bin 146 -> 0 bytes kcpuload/icons/hi16-action-labels.png | Bin 149 -> 0 bytes kcpuload/icons/hi16-action-labelson.png | Bin 174 -> 0 bytes kcpuload/icons/hi16-action-lines.png | Bin 168 -> 0 bytes kcpuload/icons/hi16-action-lineson.png | Bin 206 -> 0 bytes kcpuload/icons/hi16-action-shaded.png | Bin 358 -> 0 bytes kcpuload/icons/hi16-action-shadedon.png | Bin 419 -> 0 bytes kcpuload/icons/hi16-action-smp.png | Bin 192 -> 0 bytes kcpuload/icons/hi16-action-smpon.png | Bin 225 -> 0 bytes kcpuload/icons/hi16-action-soft.png | Bin 154 -> 0 bytes kcpuload/icons/hi16-action-softon.png | Bin 168 -> 0 bytes kcpuload/icons/hi16-action-speedarrow.png | Bin 150 -> 0 bytes kcpuload/icons/hi16-action-split.png | Bin 130 -> 0 bytes kcpuload/icons/hi16-action-spliton.png | Bin 132 -> 0 bytes kcpuload/kcpuload/CMakeLists.txt | 45 --- kcpuload/kcpuload/Makefile.am | 49 --- kcpuload/kcpuload/cr16-app-kcpuload.png | Bin 318 -> 0 bytes kcpuload/kcpuload/cr32-app-kcpuload.png | Bin 581 -> 0 bytes kcpuload/kcpuload/cr48-app-kcpuload.png | Bin 1310 -> 0 bytes kcpuload/kcpuload/icontoggleaction.cpp | 63 ---- kcpuload/kcpuload/icontoggleaction.h | 62 ---- kcpuload/kcpuload/kcpudock.cpp | 32 -- kcpuload/kcpuload/kcpudock.h | 41 --- kcpuload/kcpuload/kcpuload.cpp | 177 ----------- kcpuload/kcpuload/kcpuload.desktop | 11 - kcpuload/kcpuload/kcpuload.h | 72 ----- kcpuload/kcpuload/kcpuproc.cpp | 196 ------------ kcpuload/kcpuload/kcpuproc.h | 170 ----------- kcpuload/kcpuload/lo16-app-kcpuload.png | Bin 328 -> 0 bytes kcpuload/kcpuload/lo32-app-kcpuload.png | Bin 413 -> 0 bytes kcpuload/kcpuload/main.cpp | 64 ---- kcpuload/kcpuload/speeddialog.cpp | 63 ---- kcpuload/kcpuload/speeddialog.h | 50 --- kcpuload/kcpuload/statdock.cpp | 270 ----------------- kcpuload/kcpuload/statdock.h | 164 ---------- kcpuload/kcpuload/statpopup.cpp | 485 ------------------------------ kcpuload/kcpuload/statpopup.h | 320 -------------------- src/AUTHORS | 2 + src/CMakeLists.txt | 45 +++ src/COPYING | 280 +++++++++++++++++ src/ChangeLog | 53 ++++ src/INSTALL | 167 ++++++++++ src/Makefile.am | 50 +++ src/README | 29 ++ src/TODO | 7 + src/cr16-app-kcpuload.png | Bin 0 -> 318 bytes src/cr32-app-kcpuload.png | Bin 0 -> 581 bytes src/cr48-app-kcpuload.png | Bin 0 -> 1310 bytes src/icontoggleaction.cpp | 63 ++++ src/icontoggleaction.h | 62 ++++ src/kcpudock.cpp | 32 ++ src/kcpudock.h | 41 +++ src/kcpuload.cpp | 177 +++++++++++ src/kcpuload.desktop | 11 + src/kcpuload.h | 72 +++++ src/kcpuproc.cpp | 196 ++++++++++++ src/kcpuproc.h | 170 +++++++++++ src/lo16-app-kcpuload.png | Bin 0 -> 328 bytes src/lo32-app-kcpuload.png | Bin 0 -> 413 bytes src/main.cpp | 64 ++++ src/speeddialog.cpp | 63 ++++ src/speeddialog.h | 50 +++ src/statdock.cpp | 270 +++++++++++++++++ src/statdock.h | 164 ++++++++++ src/statpopup.cpp | 485 ++++++++++++++++++++++++++++++ src/statpopup.h | 320 ++++++++++++++++++++ subdirs | 1 + 113 files changed, 3205 insertions(+), 3222 deletions(-) create mode 100644 doc/en/CMakeLists.txt create mode 100644 doc/en/Makefile.am create mode 100644 doc/en/index.docbook delete mode 100644 doc/kcpuload/CMakeLists.txt delete mode 100644 doc/kcpuload/Makefile.am delete mode 100644 doc/kcpuload/index.docbook create mode 100644 icons/CMakeLists.txt create mode 100644 icons/Makefile.am create mode 100644 icons/hi16-action-bars.png create mode 100644 icons/hi16-action-barson.png create mode 100644 icons/hi16-action-color.png create mode 100644 icons/hi16-action-color0.png create mode 100644 icons/hi16-action-color1.png create mode 100644 icons/hi16-action-grid.png create mode 100644 icons/hi16-action-gridon.png create mode 100644 icons/hi16-action-labels.png create mode 100644 icons/hi16-action-labelson.png create mode 100644 icons/hi16-action-lines.png create mode 100644 icons/hi16-action-lineson.png create mode 100644 icons/hi16-action-shaded.png create mode 100644 icons/hi16-action-shadedon.png create mode 100644 icons/hi16-action-smp.png create mode 100644 icons/hi16-action-smpon.png create mode 100644 icons/hi16-action-soft.png create mode 100644 icons/hi16-action-softon.png create mode 100644 icons/hi16-action-speedarrow.png create mode 100644 icons/hi16-action-split.png create mode 100644 icons/hi16-action-spliton.png delete mode 100644 kcpuload/AUTHORS delete mode 100644 kcpuload/CMakeLists.txt delete mode 100644 kcpuload/COPYING delete mode 100644 kcpuload/ChangeLog delete mode 100644 kcpuload/INSTALL delete mode 100644 kcpuload/Makefile.am delete mode 100644 kcpuload/README delete mode 100644 kcpuload/TODO delete mode 100644 kcpuload/icons/CMakeLists.txt delete mode 100644 kcpuload/icons/Makefile.am delete mode 100644 kcpuload/icons/hi16-action-bars.png delete mode 100644 kcpuload/icons/hi16-action-barson.png delete mode 100644 kcpuload/icons/hi16-action-color.png delete mode 100644 kcpuload/icons/hi16-action-color0.png delete mode 100644 kcpuload/icons/hi16-action-color1.png delete mode 100644 kcpuload/icons/hi16-action-grid.png delete mode 100644 kcpuload/icons/hi16-action-gridon.png delete mode 100644 kcpuload/icons/hi16-action-labels.png delete mode 100644 kcpuload/icons/hi16-action-labelson.png delete mode 100644 kcpuload/icons/hi16-action-lines.png delete mode 100644 kcpuload/icons/hi16-action-lineson.png delete mode 100644 kcpuload/icons/hi16-action-shaded.png delete mode 100644 kcpuload/icons/hi16-action-shadedon.png delete mode 100644 kcpuload/icons/hi16-action-smp.png delete mode 100644 kcpuload/icons/hi16-action-smpon.png delete mode 100644 kcpuload/icons/hi16-action-soft.png delete mode 100644 kcpuload/icons/hi16-action-softon.png delete mode 100644 kcpuload/icons/hi16-action-speedarrow.png delete mode 100644 kcpuload/icons/hi16-action-split.png delete mode 100644 kcpuload/icons/hi16-action-spliton.png delete mode 100644 kcpuload/kcpuload/CMakeLists.txt delete mode 100644 kcpuload/kcpuload/Makefile.am delete mode 100644 kcpuload/kcpuload/cr16-app-kcpuload.png delete mode 100644 kcpuload/kcpuload/cr32-app-kcpuload.png delete mode 100644 kcpuload/kcpuload/cr48-app-kcpuload.png delete mode 100644 kcpuload/kcpuload/icontoggleaction.cpp delete mode 100644 kcpuload/kcpuload/icontoggleaction.h delete mode 100644 kcpuload/kcpuload/kcpudock.cpp delete mode 100644 kcpuload/kcpuload/kcpudock.h delete mode 100644 kcpuload/kcpuload/kcpuload.cpp delete mode 100644 kcpuload/kcpuload/kcpuload.desktop delete mode 100644 kcpuload/kcpuload/kcpuload.h delete mode 100644 kcpuload/kcpuload/kcpuproc.cpp delete mode 100644 kcpuload/kcpuload/kcpuproc.h delete mode 100644 kcpuload/kcpuload/lo16-app-kcpuload.png delete mode 100644 kcpuload/kcpuload/lo32-app-kcpuload.png delete mode 100644 kcpuload/kcpuload/main.cpp delete mode 100644 kcpuload/kcpuload/speeddialog.cpp delete mode 100644 kcpuload/kcpuload/speeddialog.h delete mode 100644 kcpuload/kcpuload/statdock.cpp delete mode 100644 kcpuload/kcpuload/statdock.h delete mode 100644 kcpuload/kcpuload/statpopup.cpp delete mode 100644 kcpuload/kcpuload/statpopup.h create mode 100644 src/AUTHORS create mode 100644 src/CMakeLists.txt create mode 100644 src/COPYING create mode 100644 src/ChangeLog create mode 100644 src/INSTALL create mode 100644 src/Makefile.am create mode 100644 src/README create mode 100644 src/TODO create mode 100644 src/cr16-app-kcpuload.png create mode 100644 src/cr32-app-kcpuload.png create mode 100644 src/cr48-app-kcpuload.png create mode 100644 src/icontoggleaction.cpp create mode 100644 src/icontoggleaction.h create mode 100644 src/kcpudock.cpp create mode 100644 src/kcpudock.h create mode 100644 src/kcpuload.cpp create mode 100644 src/kcpuload.desktop create mode 100644 src/kcpuload.h create mode 100644 src/kcpuproc.cpp create mode 100644 src/kcpuproc.h create mode 100644 src/lo16-app-kcpuload.png create mode 100644 src/lo32-app-kcpuload.png create mode 100644 src/main.cpp create mode 100644 src/speeddialog.cpp create mode 100644 src/speeddialog.h create mode 100644 src/statdock.cpp create mode 100644 src/statdock.h create mode 100644 src/statpopup.cpp create mode 100644 src/statpopup.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fb8204..6c9f7bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,9 +63,10 @@ set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" ) set( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined" ) -##### @TDE_MODULE_NAME@ directories +##### directories -add_subdirectory( kcpuload ) +add_subdirectory( src ) +add_subdirectory( icons ) tde_conditional_add_subdirectory( BUILD_DOC doc ) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 7817001..6d0aa9f 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,2 +1 @@ -add_subdirectory( kcpuload ) -add_subdirectory( man ) +tde_auto_add_subdirectories( ) diff --git a/doc/en/CMakeLists.txt b/doc/en/CMakeLists.txt new file mode 100644 index 0000000..5e33248 --- /dev/null +++ b/doc/en/CMakeLists.txt @@ -0,0 +1 @@ +tde_create_handbook( DESTINATION kcpuload ) diff --git a/doc/en/Makefile.am b/doc/en/Makefile.am new file mode 100644 index 0000000..5da901b --- /dev/null +++ b/doc/en/Makefile.am @@ -0,0 +1,18 @@ + +############################################################################ +# # +# English KCPULoad documentation. # +# # +# KCPULoad is copyright (c) 1999-2000, Markus Gustavsson # +# (c) 2002, Ben Burton # +# # +# 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. # +# # +############################################################################ + +KDE_DOCS = kcpuload +KDE_LANG = en + diff --git a/doc/en/index.docbook b/doc/en/index.docbook new file mode 100644 index 0000000..0cdcf0d --- /dev/null +++ b/doc/en/index.docbook @@ -0,0 +1,289 @@ + + + + KCPULoad"> + + +]> + + + + The &kcpuload; Handbook + + + + Markus + Gustavsson + +
mighty@fragzone.se
+
+
+ + Ben + Burton + +
bab@debian.org
+
+
+
+ + 16 December 2002 + 1.99 + + + + &kcpuload; is a simple CPU meter which graphs a recent history of + CPU usage in the system tray. It has support for SMP and separate + user/system loads. + + + + + KDE + KCPULoad + +
+ + + Introduction + + + &kcpuload; is a small program for Kicker (the TDE panel). It + shows a recent history of CPU usage in the form of one or two + configurable diagrams in the system tray. + These diagrams have settings for colors and various different styles. + + + Note that it isn't the real system load that is shown, but the percent + used of the total CPU power, which is calculated from the number of + CPU ticks between each update. + + + If there is more than one CPU on the system, the combined CPU usage + from both can be shown, or you can choose to have one separate diagram + for each CPU. + + + Left click on a diagram to bring up a small information box which + will show the exact CPU usage in text form. + + + Note that using a slower update interval will give a more stable + and accurate diagram without flicker. + + + + + Configuration + + + To configure &kcpuload;, click on the diagram in the system tray + using your right mouse button. A configuration menu will appear. + + + The settings chosen in the configuration menu are saved automatically + to the &kcpuload; configuration file as soon as they are set. There + is no need to save the settings manually. + + + + + SMP (Dual CPU) Support + + + If you don't have an SMP system, none of the SMP options will + appear in the menu. If you do, you will be presented with both an + SMP on/off option at the top of the options menu, and + (when SMP is turned on) a second color settings menu for the + second diagram. + + + If you choose to have SMP off, you will only see one diagram + showing the values from both CPUs combined. If you choose to + have SMP on, there will be one diagram for each CPU showing their + individual loads. + + + + + Changing the Update Speed + + + Choose Speed from the configuration menu to + change how frequently the diagram(s) are updated. + Choose a lower value to get a more responsive diagram. + Choose a higher value to get a slower but more stable and less + flickering diagram. + + + + + Splitting the System and User Loads + + + Enable the Graph Splitting option to have the + diagram split into an upper + part and a lower part. The upper part of the diagram will + show the user load (the apps you're using on a day-to-day basis). + The lower part which is a white scale will show the system load + (which includes daemons and other low level parts of the system + and kernel). + + + + + Changing Diagram Style + + + The Style option in the configuration menu + will let you change the look of the diagram. Options include + a Lines option which only draws a straight line + across the diagram, a Bars option which draws + a bar graph, and a Shaded option which shades + the diagram in a nice black-to-color tone. + + + + + Soft Curves + + + The Soft Curves option can be used to smooth + the diagram(s). This means that diagrams won't show very fast changes, + but instead move slowly up and down with a little delay on the + movements. This feature can make the diagrams look better, + especially when the update interval is set to a fast flickering rate. + + + + + Labels and Grid + + + These options control what is displayed behind the diagram(s). + The Labels option will turn on small text + labels in the upper left corner of each diagram showing which + CPU the diagram represents. + The Grid option will toggle a background + grid of horizontal lines. + + + + + Changing Diagram Colors + + + Each CPU diagram has a corresponding Color + option in the menu; this can be used to change the color of the + diagram. + + + + + + + + Other Features + + + + Active and Clear + + + These two functions are located at the top of the options menu. + + + The Active option is the power switch + for the whole program. This can be used to suspend the diagram + so that it doesn't measure any readings. + + + The Clear option will erase all readings and + start afresh with an empty diagram. + + + + + Pop-Up Information Dialog + + + Left click on one of the diagrams to bring up a small pop-up + information box. To hide it, left click on the diagram again, + or right click on the pop-up itself. + + + While the pop-up is shown, you can move it around with the left + mouse button. This pop-up is both sticky and always on top, so + that you can have it in a corner all the time if you like. + + + + + Session Management + + + If &kcpuload; is still running when KDE is shut down, it will + restart when KDE is restarted. + + + + + + + + License + + + &kcpuload; + + + + + Copyright 1999-2000, Markus Gustavsson mighty@fragzone.se. + + + Copyright 2002, Ben Burton bab@debian.org. + + + + + See the &kcpuload; About box for a full list of + credits. + + + &underGPL; + + + + Installation + + + How to obtain &kcpuload; + &install.intro.documentation; + + + + Requirements + + + + A Linux system (using kernel 2.2 or newer) or a BSD system; + + + The Qt and the KDE libraries; + + + A running TDE panel (Kicker). + + + + + + + Compilation and Installation + &install.compile.documentation; + + +
+ diff --git a/doc/kcpuload/CMakeLists.txt b/doc/kcpuload/CMakeLists.txt deleted file mode 100644 index 5e33248..0000000 --- a/doc/kcpuload/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -tde_create_handbook( DESTINATION kcpuload ) diff --git a/doc/kcpuload/Makefile.am b/doc/kcpuload/Makefile.am deleted file mode 100644 index 5da901b..0000000 --- a/doc/kcpuload/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ - -############################################################################ -# # -# English KCPULoad documentation. # -# # -# KCPULoad is copyright (c) 1999-2000, Markus Gustavsson # -# (c) 2002, Ben Burton # -# # -# 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. # -# # -############################################################################ - -KDE_DOCS = kcpuload -KDE_LANG = en - diff --git a/doc/kcpuload/index.docbook b/doc/kcpuload/index.docbook deleted file mode 100644 index 0cdcf0d..0000000 --- a/doc/kcpuload/index.docbook +++ /dev/null @@ -1,289 +0,0 @@ - - - - KCPULoad"> - - -]> - - - - The &kcpuload; Handbook - - - - Markus - Gustavsson - -
mighty@fragzone.se
-
-
- - Ben - Burton - -
bab@debian.org
-
-
-
- - 16 December 2002 - 1.99 - - - - &kcpuload; is a simple CPU meter which graphs a recent history of - CPU usage in the system tray. It has support for SMP and separate - user/system loads. - - - - - KDE - KCPULoad - -
- - - Introduction - - - &kcpuload; is a small program for Kicker (the TDE panel). It - shows a recent history of CPU usage in the form of one or two - configurable diagrams in the system tray. - These diagrams have settings for colors and various different styles. - - - Note that it isn't the real system load that is shown, but the percent - used of the total CPU power, which is calculated from the number of - CPU ticks between each update. - - - If there is more than one CPU on the system, the combined CPU usage - from both can be shown, or you can choose to have one separate diagram - for each CPU. - - - Left click on a diagram to bring up a small information box which - will show the exact CPU usage in text form. - - - Note that using a slower update interval will give a more stable - and accurate diagram without flicker. - - - - - Configuration - - - To configure &kcpuload;, click on the diagram in the system tray - using your right mouse button. A configuration menu will appear. - - - The settings chosen in the configuration menu are saved automatically - to the &kcpuload; configuration file as soon as they are set. There - is no need to save the settings manually. - - - - - SMP (Dual CPU) Support - - - If you don't have an SMP system, none of the SMP options will - appear in the menu. If you do, you will be presented with both an - SMP on/off option at the top of the options menu, and - (when SMP is turned on) a second color settings menu for the - second diagram. - - - If you choose to have SMP off, you will only see one diagram - showing the values from both CPUs combined. If you choose to - have SMP on, there will be one diagram for each CPU showing their - individual loads. - - - - - Changing the Update Speed - - - Choose Speed from the configuration menu to - change how frequently the diagram(s) are updated. - Choose a lower value to get a more responsive diagram. - Choose a higher value to get a slower but more stable and less - flickering diagram. - - - - - Splitting the System and User Loads - - - Enable the Graph Splitting option to have the - diagram split into an upper - part and a lower part. The upper part of the diagram will - show the user load (the apps you're using on a day-to-day basis). - The lower part which is a white scale will show the system load - (which includes daemons and other low level parts of the system - and kernel). - - - - - Changing Diagram Style - - - The Style option in the configuration menu - will let you change the look of the diagram. Options include - a Lines option which only draws a straight line - across the diagram, a Bars option which draws - a bar graph, and a Shaded option which shades - the diagram in a nice black-to-color tone. - - - - - Soft Curves - - - The Soft Curves option can be used to smooth - the diagram(s). This means that diagrams won't show very fast changes, - but instead move slowly up and down with a little delay on the - movements. This feature can make the diagrams look better, - especially when the update interval is set to a fast flickering rate. - - - - - Labels and Grid - - - These options control what is displayed behind the diagram(s). - The Labels option will turn on small text - labels in the upper left corner of each diagram showing which - CPU the diagram represents. - The Grid option will toggle a background - grid of horizontal lines. - - - - - Changing Diagram Colors - - - Each CPU diagram has a corresponding Color - option in the menu; this can be used to change the color of the - diagram. - - - - - - - - Other Features - - - - Active and Clear - - - These two functions are located at the top of the options menu. - - - The Active option is the power switch - for the whole program. This can be used to suspend the diagram - so that it doesn't measure any readings. - - - The Clear option will erase all readings and - start afresh with an empty diagram. - - - - - Pop-Up Information Dialog - - - Left click on one of the diagrams to bring up a small pop-up - information box. To hide it, left click on the diagram again, - or right click on the pop-up itself. - - - While the pop-up is shown, you can move it around with the left - mouse button. This pop-up is both sticky and always on top, so - that you can have it in a corner all the time if you like. - - - - - Session Management - - - If &kcpuload; is still running when KDE is shut down, it will - restart when KDE is restarted. - - - - - - - - License - - - &kcpuload; - - - - - Copyright 1999-2000, Markus Gustavsson mighty@fragzone.se. - - - Copyright 2002, Ben Burton bab@debian.org. - - - - - See the &kcpuload; About box for a full list of - credits. - - - &underGPL; - - - - Installation - - - How to obtain &kcpuload; - &install.intro.documentation; - - - - Requirements - - - - A Linux system (using kernel 2.2 or newer) or a BSD system; - - - The Qt and the KDE libraries; - - - A running TDE panel (Kicker). - - - - - - - Compilation and Installation - &install.compile.documentation; - - -
- diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt new file mode 100644 index 0000000..54083a0 --- /dev/null +++ b/icons/CMakeLists.txt @@ -0,0 +1 @@ +tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/kcpuload/icons ) diff --git a/icons/Makefile.am b/icons/Makefile.am new file mode 100644 index 0000000..416046e --- /dev/null +++ b/icons/Makefile.am @@ -0,0 +1,18 @@ + +############################################################################ +# # +# KCPULoad action icons. # +# # +# KCPULoad is copyright (c) 1999-2000, Markus Gustavsson # +# (c) 2002, Ben Burton # +# # +# 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. # +# # +############################################################################ + +iconsdir = $(kde_datadir)/kcpuload/icons +icons_ICON = AUTO + diff --git a/icons/hi16-action-bars.png b/icons/hi16-action-bars.png new file mode 100644 index 0000000..618e5be Binary files /dev/null and b/icons/hi16-action-bars.png differ diff --git a/icons/hi16-action-barson.png b/icons/hi16-action-barson.png new file mode 100644 index 0000000..4e5561a Binary files /dev/null and b/icons/hi16-action-barson.png differ diff --git a/icons/hi16-action-color.png b/icons/hi16-action-color.png new file mode 100644 index 0000000..8a3a9e7 Binary files /dev/null and b/icons/hi16-action-color.png differ diff --git a/icons/hi16-action-color0.png b/icons/hi16-action-color0.png new file mode 100644 index 0000000..4ef62b4 Binary files /dev/null and b/icons/hi16-action-color0.png differ diff --git a/icons/hi16-action-color1.png b/icons/hi16-action-color1.png new file mode 100644 index 0000000..8c1a7a6 Binary files /dev/null and b/icons/hi16-action-color1.png differ diff --git a/icons/hi16-action-grid.png b/icons/hi16-action-grid.png new file mode 100644 index 0000000..f7765d8 Binary files /dev/null and b/icons/hi16-action-grid.png differ diff --git a/icons/hi16-action-gridon.png b/icons/hi16-action-gridon.png new file mode 100644 index 0000000..e6a3191 Binary files /dev/null and b/icons/hi16-action-gridon.png differ diff --git a/icons/hi16-action-labels.png b/icons/hi16-action-labels.png new file mode 100644 index 0000000..f7765d8 Binary files /dev/null and b/icons/hi16-action-labels.png differ diff --git a/icons/hi16-action-labelson.png b/icons/hi16-action-labelson.png new file mode 100644 index 0000000..ed1fb4c Binary files /dev/null and b/icons/hi16-action-labelson.png differ diff --git a/icons/hi16-action-lines.png b/icons/hi16-action-lines.png new file mode 100644 index 0000000..5181cac Binary files /dev/null and b/icons/hi16-action-lines.png differ diff --git a/icons/hi16-action-lineson.png b/icons/hi16-action-lineson.png new file mode 100644 index 0000000..a0321bd Binary files /dev/null and b/icons/hi16-action-lineson.png differ diff --git a/icons/hi16-action-shaded.png b/icons/hi16-action-shaded.png new file mode 100644 index 0000000..3ac634c Binary files /dev/null and b/icons/hi16-action-shaded.png differ diff --git a/icons/hi16-action-shadedon.png b/icons/hi16-action-shadedon.png new file mode 100644 index 0000000..75549a9 Binary files /dev/null and b/icons/hi16-action-shadedon.png differ diff --git a/icons/hi16-action-smp.png b/icons/hi16-action-smp.png new file mode 100644 index 0000000..1d8e6c1 Binary files /dev/null and b/icons/hi16-action-smp.png differ diff --git a/icons/hi16-action-smpon.png b/icons/hi16-action-smpon.png new file mode 100644 index 0000000..bf15af4 Binary files /dev/null and b/icons/hi16-action-smpon.png differ diff --git a/icons/hi16-action-soft.png b/icons/hi16-action-soft.png new file mode 100644 index 0000000..3a729b8 Binary files /dev/null and b/icons/hi16-action-soft.png differ diff --git a/icons/hi16-action-softon.png b/icons/hi16-action-softon.png new file mode 100644 index 0000000..1dea191 Binary files /dev/null and b/icons/hi16-action-softon.png differ diff --git a/icons/hi16-action-speedarrow.png b/icons/hi16-action-speedarrow.png new file mode 100644 index 0000000..a126af2 Binary files /dev/null and b/icons/hi16-action-speedarrow.png differ diff --git a/icons/hi16-action-split.png b/icons/hi16-action-split.png new file mode 100644 index 0000000..d956dee Binary files /dev/null and b/icons/hi16-action-split.png differ diff --git a/icons/hi16-action-spliton.png b/icons/hi16-action-spliton.png new file mode 100644 index 0000000..be42efc Binary files /dev/null and b/icons/hi16-action-spliton.png differ diff --git a/kcpuload/AUTHORS b/kcpuload/AUTHORS deleted file mode 100644 index 4af821b..0000000 --- a/kcpuload/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Markus Gustavsson -Ben Burton diff --git a/kcpuload/CMakeLists.txt b/kcpuload/CMakeLists.txt deleted file mode 100644 index 5fa7dc7..0000000 --- a/kcpuload/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_subdirectory( kcpuload ) -add_subdirectory( icons ) diff --git a/kcpuload/COPYING b/kcpuload/COPYING deleted file mode 100644 index c7aea18..0000000 --- a/kcpuload/COPYING +++ /dev/null @@ -1,280 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/kcpuload/ChangeLog b/kcpuload/ChangeLog deleted file mode 100644 index c9ce0a5..0000000 --- a/kcpuload/ChangeLog +++ /dev/null @@ -1,53 +0,0 @@ - - 02-12-20 * Added BSD support thanks to Andy Fawcett and Robbie Ward. - - 02-12-13 * v1.99. - * Ported to KDE3. - * Completely restructured, with the aims of: - - sharing as much code as possible between KCPULoad - and KNetLoad; - - looking and behaving more like other KDE apps - (including more respect for system settings and i18n); - - making the code more maintainable (such as providing - source documentation). - * Removed references to original website which is now offline. - Hopefully the new home will be KDE CVS. - * New maintainer Ben Burton . - - 00-10-01 * v1.90 Ported to QT 2.x / KDE 1.9x/2.x (prerelease). - - 99-09-15 * Added a split option, which splits the diagram up - into one system-load scale and one user-load scale. - - 99-09-13 * Added German translation thanks to Fredrik Olson. - - 99-09-09 * Added a new Soft diagram option for a smoother curve. - * Added user documentation for installation and usage. - - 99-09-07 * Finished a new specialdesigned QToolTip lookalike, - leftclick to show it, leftclick again or rightclick - on popup to hide, use left mouse on popup to move it. - * Structure changes to make the program use less CPU. - - 99-09-01 * Added colorsetting for CPU2's diagram, and changed - so that SMP options don't appear on non-SMP systems. - - 99-08-30 * Settings are now saved direcly, not only upon quit. - * Added sessionmanagement thanks to Carsten Pfeiffer, - so the program will restart when KDE is restarted. - * Removed QToolTip Popup info dialog from program - because of a mem leak which made the program hang. - * Added several icons for both Color and style menues. - - 99-08-29 * Added two translations, Swedish, and Croatian - thanks to Vladimir Vuksan - - 99-08-28 * Full SMP support with extra option for multiple - diagrams, one for each CPU or one for both. - * Added labels, so it doesn't look like knetload. - * Added Popup Tooltips with exact utilization values. - - 99-08-11 * Uses qmessagebox.h instead of `outdated' qmsgbox.h. - * Small security fixes. - - 99-08-06 * Program ready for initial release v1.0. diff --git a/kcpuload/INSTALL b/kcpuload/INSTALL deleted file mode 100644 index 02a4a07..0000000 --- a/kcpuload/INSTALL +++ /dev/null @@ -1,167 +0,0 @@ -Basic Installation -================== - - These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes a while. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Type `make install' to install the programs and any data files and - documentation. - - 4. You can remove the program binaries and object files from the - source code directory by typing `make clean'. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. - diff --git a/kcpuload/Makefile.am b/kcpuload/Makefile.am deleted file mode 100644 index f93ba97..0000000 --- a/kcpuload/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ - -############################################################################ -# # -# KCPULoad is copyright (c) 1999-2000, Markus Gustavsson # -# (c) 2002, Ben Burton # -# # -# 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. # -# # -############################################################################ - -SUBDIRS = kcpuload icons - -EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL README TODO - diff --git a/kcpuload/README b/kcpuload/README deleted file mode 100644 index ff5d0b6..0000000 --- a/kcpuload/README +++ /dev/null @@ -1,29 +0,0 @@ - -KCPULoad - -This file should only be read as a fast description. The online -KCPULoad handbook contains more detailed information. - -This is a small program for Kicker (the TDE panel). It will show the CPU -usage in the form of one or two configurable diagrams. There are settings -for colors and some different styles. Note that it isn't the real system -load that's shown, but the percent used of the total CPU power, which is -calculated from the number of CPU ticks.. don't ask me what that means :). - -To bring up the settings menu, simply right click on the diagram. Use a -slower update interval to get a more stable and accurate diagram without -flicker. - -If there is more than one CPU on the system, the total CPU usage from both -can be shown, or you can choose to have one separate diagram for each of the -CPUs. Left click on the diagram to bring up a small information box which -will show the exact CPU usage in text form. - -Install: - -./configure -make -make install - - Markus Gustavsson - diff --git a/kcpuload/TODO b/kcpuload/TODO deleted file mode 100644 index a3f1ba2..0000000 --- a/kcpuload/TODO +++ /dev/null @@ -1,7 +0,0 @@ - -DCOP support. -Change the text on colour menu items as docks are created and destroyed. -Support sticky pop-ups. -Have the default location of the pop-up being close to the system tray dock(s). -Support for more than two CPUs. - diff --git a/kcpuload/icons/CMakeLists.txt b/kcpuload/icons/CMakeLists.txt deleted file mode 100644 index 54083a0..0000000 --- a/kcpuload/icons/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/kcpuload/icons ) diff --git a/kcpuload/icons/Makefile.am b/kcpuload/icons/Makefile.am deleted file mode 100644 index 416046e..0000000 --- a/kcpuload/icons/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ - -############################################################################ -# # -# KCPULoad action icons. # -# # -# KCPULoad is copyright (c) 1999-2000, Markus Gustavsson # -# (c) 2002, Ben Burton # -# # -# 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. # -# # -############################################################################ - -iconsdir = $(kde_datadir)/kcpuload/icons -icons_ICON = AUTO - diff --git a/kcpuload/icons/hi16-action-bars.png b/kcpuload/icons/hi16-action-bars.png deleted file mode 100644 index 618e5be..0000000 Binary files a/kcpuload/icons/hi16-action-bars.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-barson.png b/kcpuload/icons/hi16-action-barson.png deleted file mode 100644 index 4e5561a..0000000 Binary files a/kcpuload/icons/hi16-action-barson.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-color.png b/kcpuload/icons/hi16-action-color.png deleted file mode 100644 index 8a3a9e7..0000000 Binary files a/kcpuload/icons/hi16-action-color.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-color0.png b/kcpuload/icons/hi16-action-color0.png deleted file mode 100644 index 4ef62b4..0000000 Binary files a/kcpuload/icons/hi16-action-color0.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-color1.png b/kcpuload/icons/hi16-action-color1.png deleted file mode 100644 index 8c1a7a6..0000000 Binary files a/kcpuload/icons/hi16-action-color1.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-grid.png b/kcpuload/icons/hi16-action-grid.png deleted file mode 100644 index f7765d8..0000000 Binary files a/kcpuload/icons/hi16-action-grid.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-gridon.png b/kcpuload/icons/hi16-action-gridon.png deleted file mode 100644 index e6a3191..0000000 Binary files a/kcpuload/icons/hi16-action-gridon.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-labels.png b/kcpuload/icons/hi16-action-labels.png deleted file mode 100644 index f7765d8..0000000 Binary files a/kcpuload/icons/hi16-action-labels.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-labelson.png b/kcpuload/icons/hi16-action-labelson.png deleted file mode 100644 index ed1fb4c..0000000 Binary files a/kcpuload/icons/hi16-action-labelson.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-lines.png b/kcpuload/icons/hi16-action-lines.png deleted file mode 100644 index 5181cac..0000000 Binary files a/kcpuload/icons/hi16-action-lines.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-lineson.png b/kcpuload/icons/hi16-action-lineson.png deleted file mode 100644 index a0321bd..0000000 Binary files a/kcpuload/icons/hi16-action-lineson.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-shaded.png b/kcpuload/icons/hi16-action-shaded.png deleted file mode 100644 index 3ac634c..0000000 Binary files a/kcpuload/icons/hi16-action-shaded.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-shadedon.png b/kcpuload/icons/hi16-action-shadedon.png deleted file mode 100644 index 75549a9..0000000 Binary files a/kcpuload/icons/hi16-action-shadedon.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-smp.png b/kcpuload/icons/hi16-action-smp.png deleted file mode 100644 index 1d8e6c1..0000000 Binary files a/kcpuload/icons/hi16-action-smp.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-smpon.png b/kcpuload/icons/hi16-action-smpon.png deleted file mode 100644 index bf15af4..0000000 Binary files a/kcpuload/icons/hi16-action-smpon.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-soft.png b/kcpuload/icons/hi16-action-soft.png deleted file mode 100644 index 3a729b8..0000000 Binary files a/kcpuload/icons/hi16-action-soft.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-softon.png b/kcpuload/icons/hi16-action-softon.png deleted file mode 100644 index 1dea191..0000000 Binary files a/kcpuload/icons/hi16-action-softon.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-speedarrow.png b/kcpuload/icons/hi16-action-speedarrow.png deleted file mode 100644 index a126af2..0000000 Binary files a/kcpuload/icons/hi16-action-speedarrow.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-split.png b/kcpuload/icons/hi16-action-split.png deleted file mode 100644 index d956dee..0000000 Binary files a/kcpuload/icons/hi16-action-split.png and /dev/null differ diff --git a/kcpuload/icons/hi16-action-spliton.png b/kcpuload/icons/hi16-action-spliton.png deleted file mode 100644 index be42efc..0000000 Binary files a/kcpuload/icons/hi16-action-spliton.png and /dev/null differ diff --git a/kcpuload/kcpuload/CMakeLists.txt b/kcpuload/kcpuload/CMakeLists.txt deleted file mode 100644 index f9d21c0..0000000 --- a/kcpuload/kcpuload/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${TDE_INCLUDE_DIR} - ${TQT_INCLUDE_DIRS} -) - -link_directories( - ${TQT_LIBRARY_DIRS} - ${TDE_LIB_DIR} -) - - -##### kcpuload (executable) - -tde_add_executable( kcpuload AUTOMOC - - SOURCES - icontoggleaction.cpp - kcpudock.cpp - kcpuload.cpp - kcpuproc.cpp - main.cpp - statdock.cpp - speeddialog.cpp - statpopup.cpp - LINK - tdecore-shared - tdeui-shared - - DESTINATION ${BIN_INSTALL_DIR} -) - - -##### icons - -tde_install_icons( kcpuload ) - - -##### other data - -install( FILES kcpuload.desktop - DESTINATION ${APPS_INSTALL_DIR}/System -) diff --git a/kcpuload/kcpuload/Makefile.am b/kcpuload/kcpuload/Makefile.am deleted file mode 100644 index f4d9dbc..0000000 --- a/kcpuload/kcpuload/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ - -############################################################################ -# # -# Main KCPULoad sources. # -# # -# KCPULoad is copyright (c) 1999-2000, Markus Gustavsson # -# (c) 2002, Ben Burton # -# # -# 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. # -# # -############################################################################ - -INCLUDES = $(all_includes) - -bin_PROGRAMS = kcpuload - -kcpuload_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor - -kcpuload_LDADD = $(LIB_TDEUI) - -kcpuload_SOURCES = \ - icontoggleaction.cpp \ - kcpudock.cpp \ - kcpuload.cpp \ - kcpuproc.cpp \ - main.cpp \ - statdock.cpp \ - speeddialog.cpp \ - statpopup.cpp - -noinst_HEADERS = \ - icontoggleaction.h \ - kcpudock.h \ - kcpuload.h \ - kcpuproc.h \ - speeddialog.h \ - statdock.h \ - statpopup.h - -METASOURCES = AUTO - -appsdir = $(kde_appsdir)/System -apps_DATA = kcpuload.desktop - -KDE_ICON = kcpuload - diff --git a/kcpuload/kcpuload/cr16-app-kcpuload.png b/kcpuload/kcpuload/cr16-app-kcpuload.png deleted file mode 100644 index aa2ad05..0000000 Binary files a/kcpuload/kcpuload/cr16-app-kcpuload.png and /dev/null differ diff --git a/kcpuload/kcpuload/cr32-app-kcpuload.png b/kcpuload/kcpuload/cr32-app-kcpuload.png deleted file mode 100644 index 03e97bf..0000000 Binary files a/kcpuload/kcpuload/cr32-app-kcpuload.png and /dev/null differ diff --git a/kcpuload/kcpuload/cr48-app-kcpuload.png b/kcpuload/kcpuload/cr48-app-kcpuload.png deleted file mode 100644 index 59aedb3..0000000 Binary files a/kcpuload/kcpuload/cr48-app-kcpuload.png and /dev/null differ diff --git a/kcpuload/kcpuload/icontoggleaction.cpp b/kcpuload/kcpuload/icontoggleaction.cpp deleted file mode 100644 index 3e73d98..0000000 --- a/kcpuload/kcpuload/icontoggleaction.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "icontoggleaction.h" - -IconToggleAction::IconToggleAction( - const TQString& useTextUnchecked, const TQString& useIconUnchecked, - const TQString& useTextChecked, const TQString& useIconChecked, - const TDEShortcut& cut, const TQObject* receiver, const char* slot, - TQObject* parent, const char* name) : - TDEToggleAction(useTextUnchecked, useIconUnchecked, cut, receiver, - slot, parent, name), - textChecked(useTextChecked), textUnchecked(useTextUnchecked), - iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { -} - -IconToggleAction::IconToggleAction(const TQString& useText, - const TQString& useIconUnchecked, const TQString& useIconChecked, - const TDEShortcut& cut, const TQObject* receiver, const char* slot, - TQObject* parent, const char* name) : - TDEToggleAction(useText, useIconUnchecked, cut, receiver, - slot, parent, name), - textChecked(useText), textUnchecked(useText), - iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { -} - -IconToggleAction::IconToggleAction( - const TQString& useTextUnchecked, const TQString& useIconUnchecked, - const TQString& useTextChecked, const TQString& useIconChecked, - const TDEShortcut& cut, TQObject* parent, const char* name) : - TDEToggleAction(useTextUnchecked, useIconUnchecked, cut, parent, name), - textChecked(useTextChecked), textUnchecked(useTextUnchecked), - iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { -} - -IconToggleAction::IconToggleAction(const TQString& useText, - const TQString& useIconUnchecked, const TQString& useIconChecked, - const TDEShortcut& cut, TQObject* parent, const char* name) : - TDEToggleAction(useText, useIconUnchecked, cut, parent, name), - textChecked(useText), textUnchecked(useText), - iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { -} - -void IconToggleAction::setChecked(bool value) { - if (value != isChecked()) { - setText(value ? textChecked : textUnchecked); - setIcon(value ? iconChecked : iconUnchecked); - } - - TDEToggleAction::setChecked(value); -} - -#include "icontoggleaction.moc" diff --git a/kcpuload/kcpuload/icontoggleaction.h b/kcpuload/kcpuload/icontoggleaction.h deleted file mode 100644 index c54f120..0000000 --- a/kcpuload/kcpuload/icontoggleaction.h +++ /dev/null @@ -1,62 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef __ICONTOGGLEACTION_H -#define __ICONTOGGLEACTION_H - -#include - -/** - * A toggle action that uses different labels and pixmaps in its - * different states. - */ -class IconToggleAction : public TDEToggleAction { - Q_OBJECT - - - public: - /** - * Constructors. - */ - IconToggleAction( - const TQString& useTextUnchecked, const TQString& useIconUnchecked, - const TQString& useTextChecked, const TQString& useIconChecked, - const TDEShortcut& cut, const TQObject* receiver, const char* slot, - TQObject* parent, const char* name = 0); - IconToggleAction(const TQString& useText, - const TQString& useIconUnchecked, const TQString& useIconChecked, - const TDEShortcut& cut, const TQObject* receiver, const char* slot, - TQObject* parent, const char* name = 0); - IconToggleAction( - const TQString& useTextUnchecked, const TQString& useIconUnchecked, - const TQString& useTextChecked, const TQString& useIconChecked, - const TDEShortcut& cut = TDEShortcut(), TQObject* parent = 0, - const char* name = 0); - IconToggleAction(const TQString& useText, - const TQString& useIconUnchecked, const TQString& useIconChecked, - const TDEShortcut& cut = TDEShortcut(), TQObject* parent = 0, - const char* name = 0); - - /** - * Overridden to include icon adjustment. - */ - virtual void setChecked(bool); - - private: - TQString textChecked, textUnchecked; - /**< The labels to use in the checked and unchecked states. */ - TQString iconChecked, iconUnchecked; - /**< The icons to use in the checked and unchecked states. */ -}; - -#endif diff --git a/kcpuload/kcpuload/kcpudock.cpp b/kcpuload/kcpuload/kcpudock.cpp deleted file mode 100644 index 998cc30..0000000 --- a/kcpuload/kcpuload/kcpudock.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "kcpudock.h" - -#include - -KCPUDock::KCPUDock(int whichCPU, StatPopup *parent, const char *name) : - StatDock(whichCPU, i18n("C"), parent, name) { -} - -void KCPUDock::setCPULabel(int set) { - if (set == 1) - setLabel(i18n("C 0")); - else if (set == 2) - setLabel(i18n("C 1")); - else - setLabel(i18n("C")); - - repaint(); -} - diff --git a/kcpuload/kcpuload/kcpudock.h b/kcpuload/kcpuload/kcpudock.h deleted file mode 100644 index f96e411..0000000 --- a/kcpuload/kcpuload/kcpudock.h +++ /dev/null @@ -1,41 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef __KCPUDOCK_H -#define __KCPUDOCK_H - -#include "statdock.h" - -/** - * A KCPULoad system tray window for a specific CPU. - */ -class KCPUDock : public StatDock { - -public: - /** - * Constructor. - */ - KCPUDock(int whichDock, StatPopup *parent = 0, const char *name = 0); - - /** - * Sets the label for this diagram. The label will reflect which - * CPU the diagram represents. - * - * If multiple CPUs are not used, argument cpu should be 0. - * Otherwise argument cpu should be 1 or 2 for the first or second - * CPU respectively. - */ - void setCPULabel(int cpu); -}; - -#endif diff --git a/kcpuload/kcpuload/kcpuload.cpp b/kcpuload/kcpuload/kcpuload.cpp deleted file mode 100644 index 6005313..0000000 --- a/kcpuload/kcpuload/kcpuload.cpp +++ /dev/null @@ -1,177 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "icontoggleaction.h" -#include "kcpudock.h" -#include "kcpuload.h" -#include "kcpuproc.h" - -#include -#include -#include -#include - -KCPULoad::KCPULoad(TQWidget *parent, const char *name) : - StatPopup(true, parent, name) { - // Create the /proc reading class and check for SMP. - proc = new KCPUProc(); - supportSMP = proc->hasSMP(); - - // Set up actions and read the config file. - setupActions(); - - // the vector must not be reallocated during resizing because the class - // that it contains (Reading) cannot be copied safely - r.reserve(proc->cpu.size()); - - // Create system tray windows. - resizeReadings(supportSMP && actSMP->isChecked() ? proc->cpu.size() : 1); - - // Initialise the pop-up window. - readPopupState(); - - // Off we go! - requestResize(); - if (isActive()) - startUpdates(); -} - -KCPULoad::~KCPULoad() { - delete proc; -} - -void KCPULoad::setSMP(bool set) { - if (! supportSMP) - return; - - resizeReadings(set ? proc->cpu.size() : 1); - - requestResize(); - if (isActive()) - takeReading(); - - config->setGroup("General Options"); - config->writeEntry("SMP", set); - config->sync(); -} - -TQString KCPULoad::dockName(int which) const { - return i18n("CPU %1").arg(which+1); -} - -TQColor KCPULoad::defaultDockColor(int which) const { - static const TQColor c[] = { - TQColor(0, 255, 0), - TQColor(255, 0, 0), - TQColor(255, 255, 0), - TQColor(0, 255, 255) - }; - return c[which % (sizeof(c)/sizeof(c[0]))]; -} - -void KCPULoad::setupCustomActions() { - if (supportSMP) { - bool bVal = config->readBoolEntry("SMP", false); - actSMP = new IconToggleAction(i18n("Enable S&MP"), "smp", - i18n("S&MP Enabled"), "smpon", 0, coll, "smp"); - actSMP->setChecked(bVal); - connect(actSMP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setSMP(bool))); - } -} - -void KCPULoad::insertCustomItems(TDEPopupMenu* menu) { - if (supportSMP) { - actSMP->plug(menu); - menu->insertSeparator(); - } -} - -void KCPULoad::takeReadingInternal() { - proc->readLoad(); - - if (r.size() > 1) { - if (isSplit()) { - for (int i = 0; i < r.size(); i++) { - r[i].upper = proc->cpu[i].userPercent(); - r[i].lower = proc->cpu[i].systemPercent(); - } - } else { - for (int i = 0; i < r.size(); i++) { - r[i].upper = proc->cpu[i].totalPercent(); - } - } - } else if (r.size() > 0) { - if (isSplit()) { - r[0].upper = proc->all.userPercent(); - r[0].lower = proc->all.systemPercent(); - } else { - r[0].upper = proc->all.totalPercent(); - } - } - - if (isVisible()) { - if (r.size() > 1) { - if (isSplit()) { - TQString user = - i18n("Current CPU User: %1%") - .arg(proc->all.userPercent()); - TQString sys = - i18n("Current CPU System: %1%") - .arg(proc->all.systemPercent()); - for (int i = 0; i < r.size(); i++) { - user += i18n(", C%1: %2%").arg(i+1).arg(r[i].upper); - sys += i18n(", C%1: %2%").arg(i+1).arg(r[i].lower); - } - fullReading = i18n("%1.\n%2.").arg(user, sys); - } else { - TQString total = - i18n("Current CPU usage: %1%") - .arg(proc->all.totalPercent()); - for (int i = 0; i < r.size(); i++) { - total += i18n(", C%1: %2%").arg(i+1).arg(r[i].upper); - } - fullReading = i18n("%1.").arg(total); - } - } else if (r.size() > 0) { - if (isSplit()) { - fullReading = i18n( - "Current CPU User: %1%.\n" - "Current CPU System: %2%.") - .arg(r[0].upper).arg(r[0].lower); - } else { - fullReading = i18n("Current CPU usage: %1%.").arg(r[0].upper); - } - } - } - } - -void KCPULoad::resizeReadings(int n) -{ - int i = r.size(); - r.resize(n); - for (; i < n; i++) { - // action is needed by KCPUDock constructor - r[i].Init(i, this); - KCPUDock* dock = new KCPUDock(i, this); - dock->setCPULabel(i+1); - r[i].dock = dock; - } - // special case single CPU or total - if (n == 1) { - static_cast(r[0].dock)->setCPULabel(0); - } else if (n > 1) { - static_cast(r[0].dock)->setCPULabel(1); - } -} - -#include "kcpuload.moc" diff --git a/kcpuload/kcpuload/kcpuload.desktop b/kcpuload/kcpuload/kcpuload.desktop deleted file mode 100644 index 8182af4..0000000 --- a/kcpuload/kcpuload/kcpuload.desktop +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Type=Application -Exec=kcpuload -Icon=kcpuload -X-DocPath=kcpuload/index.html -Terminal=0 -Name=KCPULoad -GenericName=CPU Monitor -Comment=A small CPU usage meter for Kicker -Categories=Qt;TDE;System diff --git a/kcpuload/kcpuload/kcpuload.h b/kcpuload/kcpuload/kcpuload.h deleted file mode 100644 index 892d7db..0000000 --- a/kcpuload/kcpuload/kcpuload.h +++ /dev/null @@ -1,72 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef __KCPULOAD_H -#define __KCPULOAD_H - -#include "statpopup.h" - -class KCPUProc; -class TDEToggleAction; - -/** - * The specific pop-up window used by KCPULoad. - */ -class KCPULoad : public StatPopup { - Q_OBJECT - - -public: - /** - * Constructor and destructor. - */ - KCPULoad(TQWidget *parent = 0, const char *name = 0); - ~KCPULoad(); - -public slots: - /** - * Slots for menu items. - */ - void setSMP(bool); - -protected: - /** - * Overrides from StatPopup. - */ - virtual TQString dockName(int which) const; - virtual TQColor defaultDockColor(int which) const; - virtual void setupCustomActions(); - virtual void insertCustomItems(TDEPopupMenu* menu); - virtual void takeReadingInternal(); - -private: - /** - * Changes the number of readings. - */ - void resizeReadings(int n); - - /** - * Reading raw CPU information. - */ - KCPUProc* proc; - /**< Used to obtain the raw information. */ - bool supportSMP; - /**< Does this system support SMP at all? */ - - /** - * Actions. - */ - TDEToggleAction* actSMP; -}; - -#endif diff --git a/kcpuload/kcpuload/kcpuproc.cpp b/kcpuload/kcpuload/kcpuproc.cpp deleted file mode 100644 index f7fbe4f..0000000 --- a/kcpuload/kcpuload/kcpuproc.cpp +++ /dev/null @@ -1,196 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "kcpuproc.h" - -#include -#include - -// BSD-specific includes. -#ifdef Q_OS_BSD4 -#include -#include -#include -#include -#include -#ifdef Q_OS_NETBSD -#include -#endif -#endif - -/** - * Linux - * ----- - * - * System information is read from /proc/stat. - * - * We assume /proc/stat is in one of the following formats: - * - * cpu %d %d %d %d - * .... - * - * cpu %d %d %d %d - * cpu0 %d %d %d %d - * .... - * - * cpu %d %d %d %d - * cpu0 %d %d %d %d - * cpu1 %d %d %d %d - * .... - * - * where each set of four numbers is of the form: - * - * user_ticks nice_ticks system_ticks idle_ticks - * - * We also allow sets of seven numbers instead of four (as provided by - * the 2.6 kernel); the last three of these numbers are ignored. - * - * BSD - * --- - * - * Currently only uni-processor mode is supported for BSD. - * - * BSD code by Andy Fawcett and - * Robbie Ward , licensed under GPL2. - * - * Other Operating Systems - * ----------------------- - * - * Please, send in a patch! - * - * The KCPULoad maintainer is currently Ben Burton , or - * you could submit a patch through the KDE bug tracking system - * (bugs.kde.org). - */ - -KCPUProc::CPU::Ticks::Ticks() : - U(0), S(0), N(0), I(0) -{ } - -KCPUProc::KCPUProc() { - smp = false; - - // Look for SMP support and take a current tick reading. - - // ========== BSD-specific (begin) ========== -#ifdef Q_OS_BSD4 - readLoad(); - return; -#endif - // ========== BSD-specific (end) ========== - - // ========== Linux-specific (begin) ========== -#ifdef Q_OS_LINUX - if ((fd = fopen("/proc/stat", "r")) == 0) - return; - - if (!all.parse(fd)) - return; - CPU c; - while (c.parse(fd)) - cpu.push_back(c); - smp = cpu.size() > 1; -#endif - // ========== Linux-specific (end) ========== -} - -void KCPUProc::readLoad() { - // OS-specific local variables. - - // ========== Linux-specific (begin) ========== -#ifdef Q_OS_LINUX - // Prepare to take the readings. - - if ((fd = fopen("/proc/stat", "r")) == 0) - return; - - // Take a fresh set of current readings (SMP mode). - - all.parse(fd); - for (int i = 0; i < cpu.size(); i++) { - if (!cpu[i].parse(fd)) - break; - } - - // Clean up after taking readings. - - fclose(fd); -#endif - // ========== Linux-specific (end) ========== - - // ========== BSD-specific (begin) ========== -#ifdef Q_OS_BSD4 - static int name2oid[2] = { 0, 3 }; - static int oidCpuTime[CTL_MAXNAME + 2]; - static size_t oidCpuTimeLen = sizeof(oidCpuTime); - long cpuTime[CPUSTATES]; - unsigned int cpuTimeLen = sizeof(cpuTime); - static char *name = "kern.cp_time"; - static int initialized = 0; - - if(smp) { - // Take a fresh set of current readings (SMP mode). - // TODO: Add SMP support for BSD. - } else { - // Take a fresh set of current readings (uni-processor mode). - - // The current readings must now become the previous readings. - all.p = all.c; - - if (! initialized) { - if (sysctl(name2oid, 2, oidCpuTime, &oidCpuTimeLen, name, - strlen(name)) < 0) - return; - - oidCpuTimeLen /= sizeof(int); - initialized = 1; - } - - if (sysctl(oidCpuTime, oidCpuTimeLen, cpuTime, &cpuTimeLen, 0, 0) < 0) - return; - - all.c.U = cpuTime[CP_USER]; - all.c.N = cpuTime[CP_NICE]; - all.c.S = cpuTime[CP_SYS]; - all.c.I = cpuTime[CP_IDLE]; - } -#endif - // ========== BSD-specific (end) ========== -} - -// ========== Linux-specific (begin) ========== -#ifdef Q_OS_LINUX -bool KCPUProc::CPU::parse(FILE* fd) { - char tagbuffer[32+1]; - Ticks n; // new ticks - if (fscanf(fd, "%32s%d%d%d%d", tagbuffer, &n.U, &n.N, &n.S, &n.I) != 5) { - return false; // failure - } - - if (strncmp(tagbuffer, "cpu", 3) != 0) { - return false; // tag mismatch - } - - // shift readings - p = c; - c = n; - - // ignore the rest of the line - int ch; - do { - ch = getc(fd); - } while (ch != '\n' && ch != EOF); - return true; -} -#endif -// ========== Linux-specific (end) ========== diff --git a/kcpuload/kcpuload/kcpuproc.h b/kcpuload/kcpuload/kcpuproc.h deleted file mode 100644 index 8b844f5..0000000 --- a/kcpuload/kcpuload/kcpuproc.h +++ /dev/null @@ -1,170 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef __KCPUPROC_H -#define __KCPUPROC_H - -#include -#include -#include - -/** - * A class used to read raw CPU load details from the system. - * - * See kcpuproc.cpp for details of supported operating systems. - */ -class KCPUProc { -public: - /** - * Constructor. - * - * In the constructor, a set of initial CPU tick readings are taken - * and SMP support is determined. - */ - KCPUProc(); - - /** - * Does this system appear to have SMP? - */ - bool hasSMP() const; - - /** - * Takes a fresh set of CPU tick readings. The numerical statistics - * returned refer to the time period between this reading and the - * previous (or between this reading and the object's construction - * if there was no previous reading). - */ - void readLoad(); - - /** - * Contains tick differences for a CPU. - */ - struct CPU { - /** - * Contains user/system/nice/idle tick readings. - */ - struct Ticks { - int U, S, N, I; - Ticks(); - /** Returns user ticks */ - int u() const { return U; } - /** Returns system ticks */ - int s() const { return S + N; } - /** Returns total (non-idle) ticks */ - int t() const { return U + S + N; } - /** Returns elapsed ticks */ - int e() const { return U + S + N + I; } - }; - - Ticks p; /**< The previous tick readings */ - Ticks c; /**< The last (most recent) tick readings */ - - /** - * The percentage of ticks between the last reading and the previous - * reading used by the user loop (compared to the nice, system and - * idle loops). - * - * This routine involves a short arithmetical calculation. - * If you're paranoid about running time, you might want to cache - * the result. - */ - int userPercent() const; - - /** - * The percentage of ticks between the last reading and the previous - * reading used by the system and nice loops (compared to the user and - * idle loops). - * - * This routine involves a short arithmetical calculation. - * If you're paranoid about running time, you might want to cache - * the result. - */ - int systemPercent() const; - - /** - * The percentage of ticks between the last reading and the previous - * reading used by the user, system and nice loops (compared to the - * idle loop). - * - * This routine involves a short arithmetical calculation. - * If you're paranoid about running time, you might want to cache - * the result. - */ - int totalPercent() const; - - /** - * OS-specific helper routines. - */ - - // ========== Linux-specific (begin) ========== -#ifdef Q_OS_LINUX - /** - * Parses the tick readings of the current line in #fd. - * The return value is \c false if the line does not begin with - * the tag "cpu" (optionally followed by a number). - * If the line can be parsed successfully, the last reading becomes - * the previous reading and the newly parsed reading becomes - * the last reading. - */ - bool parse(FILE* fd); -#endif - // ========== Linux-specific (end) ========== - }; - - /* - * Variables used in all modes. - */ - CPU all; /**< Tick readings for all CPUs. */ - - /* - * Variables used only with SMP. - */ - std::vector cpu; /**< Tick readings for CPUs. */ - -private: - /* - * SMP support. - */ - bool smp; - /**< Does this system appear to have SMP? */ - - /** - * OS-specific data members. - */ - - // ========== Linux-specific (begin) ========== -#ifdef Q_OS_LINUX - FILE *fd; - /**< The file /proc/stat. */ -#endif - // ========== Linux-specific (end) ========== -}; - -inline bool KCPUProc::hasSMP() const { - return smp; -} - -inline int KCPUProc::CPU::userPercent() const { - int tot = c.e() - p.e(); - return (tot > 0 ? (100 * (c.u() - p.u())) / tot : 0); -} -inline int KCPUProc::CPU::systemPercent() const { - int tot = c.e() - p.e(); - return (tot > 0 ? (100 * (c.s() - p.s())) / tot : 0); -} -inline int KCPUProc::CPU::totalPercent() const { - int tot = c.e() - p.e(); - return (tot > 0 ? (100 * (c.t() - p.t())) / tot : 0); -} - -#endif diff --git a/kcpuload/kcpuload/lo16-app-kcpuload.png b/kcpuload/kcpuload/lo16-app-kcpuload.png deleted file mode 100644 index 278a3f5..0000000 Binary files a/kcpuload/kcpuload/lo16-app-kcpuload.png and /dev/null differ diff --git a/kcpuload/kcpuload/lo32-app-kcpuload.png b/kcpuload/kcpuload/lo32-app-kcpuload.png deleted file mode 100644 index 34606e5..0000000 Binary files a/kcpuload/kcpuload/lo32-app-kcpuload.png and /dev/null differ diff --git a/kcpuload/kcpuload/main.cpp b/kcpuload/kcpuload/main.cpp deleted file mode 100644 index 6b587e5..0000000 --- a/kcpuload/kcpuload/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "kcpuload.h" - -#include -#include -#include -#include - -static const char *description = - I18N_NOOP("A small CPU usage meter for Kicker (the TDE panel)."); -static const char *message = - I18N_NOOP("KCPULoad was first released on the 8th of August, 1999."); -static const char *version = "2.00"; - -int main(int argc, char **argv) { - TDEAboutData aboutData("kcpuload", I18N_NOOP("KCPULoad"), version, - description, TDEAboutData::License_GPL, - "(c) 1999-2000, Markus Gustavsson\n" - "(c) 2002, Ben Burton\n" - "(c) 2009, Timothy Pearson", - message, 0 /* TODO: Website */, "bab@debian.org"); - - aboutData.addAuthor("Markus Gustavsson", "Original author", - "mighty@fragzone.se"); - aboutData.addAuthor("Ben Burton", "KDE3 rewrite, current maintainer", - "bab@debian.org"); - aboutData.addAuthor("Andy Fawcett", "BSD support", - "andy@athame.co.uk"); - aboutData.addAuthor("Robbie Ward", "BSD support", - "linuxphreak@gmx.co.uk"); - - aboutData.addCredit("Njaard, Charles Samuels", - "Support and help with KDE", "charles@kde.org"); - aboutData.addCredit("rikkus, Rik Hemsley", - "Support and help with KDE", "rik@kde.org"); - aboutData.addCredit("Mark Halpaap", - "Independent port to KDE3", "mark.halpaap@gmx.net"); - aboutData.addCredit("Thanks to everyone in #KDE OpenProjects for " - "being supportive and helpful!"); - - TDECmdLineArgs::init(argc, argv, &aboutData); - KUniqueApplication::addCmdLineOptions(); - - if (! KUniqueApplication::start()) { - fprintf(stderr, I18N_NOOP("KCPULoad is already running!\n")); - return 1; - } - - KUniqueApplication app; - app.setMainWidget(new KCPULoad()); - return app.exec(); -} diff --git a/kcpuload/kcpuload/speeddialog.cpp b/kcpuload/kcpuload/speeddialog.cpp deleted file mode 100644 index 845bb2a..0000000 --- a/kcpuload/kcpuload/speeddialog.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "speeddialog.h" - -#include -#include -#include -#include -#include -#include - -static int stockSpeed[] = { - 100, 150, 200, 250, 300, 400, 600, 800, 1000, 1200, 1500, 2000, 2500, - 3000, 4000, 5000, 0 -}; - -SpeedDialog::SpeedDialog(int defaultSpeed, TQWidget* parent) : - KDialogBase(parent, "speed dialog", true, - i18n("Select Speed"), Ok|Cancel, Ok), - speed(defaultSpeed) { - TQHBox* page = makeHBoxMainWidget(); - - new TQLabel(i18n("Update interval in milliseconds:"), page); - - KComboBox* speedBox = new KComboBox(true, page); - - TQIntValidator* val = new TQIntValidator(TQT_TQOBJECT(this)); - val->setBottom(1); - speedBox->setValidator(val); - - TQString speedStr; - for (int i = 0; stockSpeed[i]; i++) { - speedStr.setNum(stockSpeed[i]); - speedBox->insertItem(speedStr); - } - - speedStr.setNum(defaultSpeed); - speedBox->setCurrentText(speedStr); - - connect(speedBox, TQT_SIGNAL(textChanged(const TQString&)), - this, TQT_SLOT(updateSpeed(const TQString&))); -} - -int SpeedDialog::getSpeed() const { - return speed; -} - -void SpeedDialog::updateSpeed(const TQString& text) { - speed = atoi(text.ascii()); -} - -#include "speeddialog.moc" diff --git a/kcpuload/kcpuload/speeddialog.h b/kcpuload/kcpuload/speeddialog.h deleted file mode 100644 index 66b4380..0000000 --- a/kcpuload/kcpuload/speeddialog.h +++ /dev/null @@ -1,50 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef __SPEEDDIALOG_H -#define __SPEEDDIALOG_H - -#include - -/** - * A dialog used to select the update speed for a StatPopup. - */ -class SpeedDialog : public KDialogBase { - Q_OBJECT - - - public: - /** - * Constructor. - */ - SpeedDialog(int defaultSpeed, TQWidget* parent); - - /** - * Returns the speed currently selected in the dialog. - * This is valid after the dialog has closed. - */ - int getSpeed() const; - - private slots: - /** - * Updates the speed variable to reflect the latest changes in - * the speed combo box. - */ - virtual void updateSpeed(const TQString&); - - private: - int speed; - /**< The speed currently selected in the speed combo box. */ -}; - -#endif diff --git a/kcpuload/kcpuload/statdock.cpp b/kcpuload/kcpuload/statdock.cpp deleted file mode 100644 index 36d33cc..0000000 --- a/kcpuload/kcpuload/statdock.cpp +++ /dev/null @@ -1,270 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "statdock.h" -#include "statpopup.h" -#include - -const int StatDock::fillLines = 0; -const int StatDock::fillBars = 1; -const int StatDock::fillShaded = 2; - -const TQColor StatDock::colorGrid(120, 120, 120); -const TQColor StatDock::colorGridInactive(60, 60, 60); -const TQColor StatDock::colorLabel(255, 255, 255); -const TQColor StatDock::colorLabelInactive(125, 125, 125); -const TQColor StatDock::colorLower(255, 255, 255); -const TQColor StatDock::colorLowerInactive(125, 125, 125); -const TQColor StatDock::colorBlack(0, 0, 0); - -//#define DOCK_SIZE 24 -#define DOCK_SIZE width() -#define DOCK_SCALE (((float) 105)/((float) (DOCK_SIZE-1))) -#define SOFT_STEP 3 - -StatDock::StatDock(int whichDock, const TQString& useLabel, - StatPopup *parent, const char *name) : - KSystemTray(parent,name), - label(useLabel), - bufUpper(0), - bufLower(0), - pos(0) { - - bufUpper = new int[DOCK_SIZE]; - bufLower = new int[DOCK_SIZE]; - - // Initialise the stored readings. - for (i = 0; i < DOCK_SIZE; i++) - bufUpper[i] = bufLower[i] = 0; - - // Initialise the display. - parent->initDock(this, contextMenu(), whichDock); - setBackgroundColor(colorBlack); - resize(DOCK_SIZE, DOCK_SIZE); - show(); -} - -StatDock::~StatDock() { - delete[] bufUpper; - delete[] bufLower; -} - -void StatDock::resizeEvent ( TQResizeEvent * ) -{ - // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes - int* bufUpperOld; - int* bufLowerOld; - - bufUpperOld = bufUpper; - bufLowerOld = bufLower; - - bufUpper = new int[DOCK_SIZE]; - bufLower = new int[DOCK_SIZE]; - - // Re-initialise the stored readings. - for (i = 0; i < DOCK_SIZE; i++) - bufUpper[i] = bufLower[i] = 0; - - delete[] bufUpperOld; - delete[] bufLowerOld; - - repaint(); -} - -void StatDock::setGrid(bool set) { - grid = set; - repaint(); -} - -void StatDock::setActive(bool set) { - active = set; - repaint(); -} - -void StatDock::setSoft(bool set) { - soft = set; - repaint(); -} - -void StatDock::setSplit(bool set) { - split = set; - repaint(); -} - -void StatDock::setLabelled(bool set) { - labelled = set; - repaint(); -} - -void StatDock::setLabel(const TQString& set) { - label = set; - repaint(); -} - -void StatDock::setFill(int set) { - fill = set; - repaint(); -} - -void StatDock::setColor(const TQColor& set) { - colorUpper = set; - colorUpperInactive = colorUpper.dark(); - repaint(); -} - -void StatDock::clearHistory(void) { - for (i = 0; i < DOCK_SIZE; i++) - bufUpper[i] = bufLower[i] = 0; - repaint(); -} - -void StatDock::addPercentReading(int upper, int lower) { - // Rescale the readings to a measure in pixels. - upper = (int) (((float) upper) / DOCK_SCALE); - lower = (split ? (int) (((float) lower) / DOCK_SCALE) : 0); - - if (soft) { - // Do a bit of juggling to obtain a soft reading. - oldUpper = bufUpper[pos]; - oldLower = bufLower[pos]; - if(++pos >= DOCK_SIZE) - pos = 0; - - // Modify the upper reading. - if (upper > oldUpper + SOFT_STEP) - upper = oldUpper + SOFT_STEP; - else if (upper < oldUpper - SOFT_STEP) - upper = oldUpper - SOFT_STEP; - bufUpper[pos] = upper; - - // Modify the lower reading. - if (split) { - if (lower > oldLower + SOFT_STEP) - lower = oldLower + SOFT_STEP; - else if (lower < oldLower - SOFT_STEP) - lower = oldLower - SOFT_STEP; - } - bufLower[pos] = lower; - } else { - // Just a straight update. - if(++pos >= DOCK_SIZE) - pos = 0; - bufUpper[pos] = upper; - bufLower[pos] = lower; - } - - // Refresh the diagram. - repaint(); -} - -void StatDock::paintEvent(TQPaintEvent*) { - TQPainter p(this); - - // Start by drawing the grid. - if(grid) { - p.setPen((active) ? colorGrid : colorGridInactive); - for(i = (((DOCK_SIZE+1)/5)-1); i < (DOCK_SIZE-1); i=i+((DOCK_SIZE+1)/5)) { - p.drawLine(0, i, (DOCK_SIZE-1), i); - } - } - - if(fill == fillShaded) { - // Shaded - for(i = 0; i < DOCK_SIZE; i++) { - tmpPos = (pos + i + 1) % DOCK_SIZE; - for(j = 0; j <= bufUpper[tmpPos]; j++) { - if (bufUpper[tmpPos] == 0 || j == 0) - p.setPen(colorBlack); - else if (active) - p.setPen(colorUpper.dark((100 * bufUpper[tmpPos]) / j)); - else - p.setPen(colorUpper.dark((200 * bufUpper[tmpPos]) / j)); - - if(split) - p.drawPoint(i, DOCK_SIZE - 1 - j - bufLower[tmpPos]); - else - p.drawPoint(i, DOCK_SIZE - j); - } - - if(split) { - for(j = 0; j <= bufLower[tmpPos]; j++) { - if (bufLower[tmpPos] == 0 || j == 0) - p.setPen(colorBlack); - else if (active) - p.setPen(colorLower.dark((100 * bufLower[tmpPos]) / j)); - else - p.setPen(colorLower.dark((200 * bufLower[tmpPos]) / j)); - - p.drawPoint(i, (DOCK_SIZE-1) - j); - } - } - } - } else if (fill == fillBars) { - // Bars - if(split) { - // Draw the upper bars, then the lower to save on pen - // adjustments. - p.setPen(active ? colorUpper : colorUpperInactive); - for(i = 0; i < DOCK_SIZE; i++) { - tmpPos = (pos + i + 1) % DOCK_SIZE; - p.drawLine(i, DOCK_SIZE - 1 - bufUpper[tmpPos] - - bufLower[tmpPos], i, DOCK_SIZE - 1 - bufLower[tmpPos]); - } - p.setPen(active ? colorLower : colorLowerInactive); - for(i = 0; i < DOCK_SIZE; i++) { - tmpPos = (pos + i + 1) % DOCK_SIZE; - p.drawLine(i, DOCK_SIZE - 1 - bufLower[tmpPos], - i, DOCK_SIZE - 1); - } - } else { - p.setPen(active ? colorUpper : colorUpperInactive); - for(i = 0; i < DOCK_SIZE; i++) { - tmpPos = (pos + i + 1) % DOCK_SIZE; - p.drawLine(i, DOCK_SIZE - 1 - bufUpper[tmpPos], - i, DOCK_SIZE - 1); - } - } - } else { - // Lines - if(split) { - // Draw the upper line, then the lower to save on pen - // adjustments. - p.setPen(active ? colorUpper : colorUpperInactive); - for(i = 0; i < DOCK_SIZE; i++) { - tmpPos = (pos + i + 1) % DOCK_SIZE; - p.drawPoint(i, DOCK_SIZE - 1 - - bufUpper[tmpPos] - bufLower[tmpPos]); - } - p.setPen(active ? colorLower : colorLowerInactive); - for(i = 0; i < DOCK_SIZE; i++) { - tmpPos = (pos + i + 1) % DOCK_SIZE; - p.drawPoint(i, DOCK_SIZE - 1 - bufLower[tmpPos]); - } - } else { - p.setPen(active ? colorUpper : colorUpperInactive); - for(i = 0; i < DOCK_SIZE; i++) { - tmpPos = (pos + i + 1) % DOCK_SIZE; - p.drawPoint(i, DOCK_SIZE - 1 - bufUpper[tmpPos]); - } - } - } - - // Finally label the diagrams. - if(labelled) { - p.setFont(TQFont( "Helvetica", ((8*DOCK_SIZE)/24) )); - p.setPen((active) ? colorLabel : colorLabelInactive); - p.drawText(rect(), AlignLeft | AlignTop, label); - } -} - -#include "statdock.moc" diff --git a/kcpuload/kcpuload/statdock.h b/kcpuload/kcpuload/statdock.h deleted file mode 100644 index 1fb0552..0000000 --- a/kcpuload/kcpuload/statdock.h +++ /dev/null @@ -1,164 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef __STATDOCK_H -#define __STATDOCK_H - -#include -#include - -class StatPopup; - -/** - * A system tray window that displays a recent history of readings. - * A single application might have many of these windows. - * - * Two simultaneous sets of readings are supported; these will be - * referred to as upper and lower readings. When diagram splitting is - * switched on, these readings will be displayed together on the diagram - * with the upper readings shown above the lower readings. When diagram - * splitting is switched off, only the upper readings will be displayed. - * - * The parent window of a StatDock must be a StatPopup, which provides - * all of the actions in this window's context menu. - */ -class StatDock : public KSystemTray { - Q_OBJECT - - -public: - /** - * Fill style constants. - */ - static const int fillLines; - static const int fillBars; - static const int fillShaded; - - /** - * Colour constants. - */ - static const TQColor colorGrid; - static const TQColor colorGridInactive; - static const TQColor colorLabel; - static const TQColor colorLabelInactive; - static const TQColor colorLower; - static const TQColor colorLowerInactive; - static const TQColor colorBlack; - -public: - /** - * Constructor and destructor. - * - * Note that the constructor will call parent->initDock(). - * - * Parameter whichDock must be 0 or 1 to specify whether this dock - * will become dock[0] or dock[1] in the given StatPopup parent. - * Parameter useLabel should contain the label that will be drawn on - * the diagram if labelling is enabled. - */ - StatDock(int whichDock, const TQString& useLabel, StatPopup *parent, - const char *name = 0); - ~StatDock(); - - /** - * Setting display options. - */ - void setGrid(bool); - void setActive(bool); - void setSoft(bool); - void setSplit(bool); - void setLabelled(bool); - void setLabel(const TQString&); - void setFill(int); - void setColor(const TQColor&); - -public slots: - /** - * Clear the history of recent readings. - * All readings will be reset to zero and the diagram will be - * updated. - */ - void clearHistory(); - - /** - * Add the given pair of readings as the most recent in our list. - * The diagram will be updated accordingly. - * - * Each argument should be a percentage between 0 and 100. - * The sum of both arguments must not exceed 100. - * - * If diagram splitting is switched off, the given lower reading - * will be ignored completely and 0 will be used instead. - * - * @param upper the upper reading in this pair. - * @param lower the lower reading in this pair. - */ - void addPercentReading(int upper, int lower); - -private: - /** - * Repaint this system tray window with a fresh diagram. - */ - void paintEvent(TQPaintEvent*); - -private: - /** - * Display options. - */ - bool grid; - /**< Should the grid be displayed behind the diagram? */ - bool active; - /**< Is this meter currently active? */ - bool soft; - /**< Are we artificially modifying the readings to produce a - soft curve? */ - bool split; - /**< Are we displaying both upper and lower readings? */ - bool labelled; - /**< Should this diagram be labelled? */ - TQString label; - /**< The specific label to draw on this diagram. */ - int fill; - /**< Specifies which of the predefined fill styles to use. */ - TQColor colorUpper; - /**< Colour for displaying the upper readings. */ - TQColor colorUpperInactive; - /**< Colour for displaying the upper readings whilst the diagram - is inactive. */ - - /** - * Stored readings. - */ - int* bufUpper; - /**< Stores our list of recent upper readings. - This list begins at index (pos + 1) as the earliest reading - and cycles around to index (pos) as the latest reading. */ - int* bufLower; - /**< Stores our list of recent lower readings. - This list begins at index (pos + 1) as the earliest reading - and cycles around to index (pos) as the latest reading. */ - int pos; - /**< The index in our arrays of the most recent reading. */ - - - /** - * Temporaries. - */ - int i, j, tmpPos, oldUpper, oldLower; - /**< Temporary variables used during computations. */ - -protected: - void resizeEvent ( TQResizeEvent * ); -}; - -#endif diff --git a/kcpuload/kcpuload/statpopup.cpp b/kcpuload/kcpuload/statpopup.cpp deleted file mode 100644 index e8c3c8f..0000000 --- a/kcpuload/kcpuload/statpopup.cpp +++ /dev/null @@ -1,485 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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 "icontoggleaction.h" -#include "speeddialog.h" -#include "statdock.h" -#include "statpopup.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DEFAULT_SPEED 1000 -#define TEXT_EXPANSION_HORIZONTAL 10 -#define TEXT_EXPANSION_VERTICAL 3 - -const TQColor StatPopup::colorBorder(0, 0, 0); - -StatPopup::Reading::Reading() : - dock(0), - actColor(0) -{ } - -StatPopup::Reading::~Reading() -{ - delete actColor; - delete dock; -} - -void StatPopup::Reading::Init(int which, StatPopup* popup) -{ - char colorid[30]; - sprintf(colorid, "Color%d", which); - - color = popup->defaultDockColor(which); - color = popup->config->readColorEntry(colorid, &color); - actColor = new TDEAction(i18n("Color (%1)...").arg(popup->dockName(which)), - "color", 0, TQT_TQOBJECT(popup), TQT_SLOT(selectColor()), popup->coll, colorid); -} - - -StatPopup::StatPopup(bool useSupportSplit, TQWidget *parent, const char *name) : - TQWidget(parent, name, TQt::WStyle_Customize | TQt::WStyle_NoBorder | - TQt::WStyle_StaysOnTop | TQt::WDestructiveClose | TQt::WType_TopLevel), - supportSplit(useSupportSplit) { - // Window management. - KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); - - // TODO: Get all-desktops working, even after a hide/reshow. - //KWin::setOnAllDesktops(winId(), true); - - // Basic variable initialisation. - relX = relY = 0; - isDragged = closing = false; - - // Initialise the text contents of this pop-up. - fullReading = i18n("Inactive."); - resizeToText(); - - // Prepare for actions and the config file, but don't actually add - // any actions or read the configuration. - config = TDEGlobal::config(); - coll = new TDEActionCollection(this); - - // Set up a timer for our periodic updates. - timer = new TQTimer(this); - connect(timer, TQT_SIGNAL(timeout()), TQT_TQOBJECT(this), TQT_SLOT(takeReading())); -} - -StatPopup::~StatPopup() { -} - -void StatPopup::readPopupState() { - config->setGroup("Popup Options"); - - // Read the position. - int useX = config->readNumEntry("PopupX", 0); - int useY = config->readNumEntry("PopupY", 0); - if (useX || useY) - move(useX, useY); - - // Show the pop-up if appropriate. - if (config->readBoolEntry("PopupActive", false)) - show(); - else - hide(); -} - -void StatPopup::savePopupState() { - config->setGroup("Popup Options"); - config->writeEntry("PopupActive", isVisible()); - config->writeEntry("PopupX", x()); - config->writeEntry("PopupY", y()); - config->sync(); -} - -void StatPopup::initDock(StatDock* target, TDEPopupMenu* menu, int whichDock) { - // Initialise the menus. - actActive->plug(menu); - actClearHistory->plug(menu); - menu->insertSeparator(); - actSpeed->plug(menu); - if (supportSplit) - actSplit->plug(menu); - menu->insertSeparator(); - - insertCustomItems(menu); - - TDEPopupMenu* fillMenu = new TDEPopupMenu(menu); - actFillLines->plug(fillMenu); - actFillBars->plug(fillMenu); - actFillShaded->plug(fillMenu); - menu->insertItem(SmallIcon("style"), i18n("St&yle"), fillMenu); - - actSoft->plug(menu); - actLabelled->plug(menu); - actGrid->plug(menu); - r[whichDock].actColor->plug(menu); - menu->insertSeparator(); - menu->insertItem(SmallIcon("help"), i18n("&Help"), - (new KHelpMenu(0, TDEGlobal::instance()->aboutData(), false))->menu()); - - // Set up display properties for the dock. - target->setActive(actActive->isChecked()); - target->setSplit(isSplit()); - target->setFill(fillStyle); - target->setSoft(actSoft->isChecked()); - target->setLabelled(actLabelled->isChecked()); - target->setGrid(actGrid->isChecked()); - target->setColor(r[whichDock].color); - setCustomProperties(target); -} - -bool StatPopup::isActive() const { - return actActive->isChecked(); -} - -bool StatPopup::isSplit() const { - return (supportSplit ? actSplit->isChecked() : false); -} - -void StatPopup::setActive(bool set) { - if (set) - startUpdates(); - else - stopUpdates(); - - for (int i = 0; i < r.size(); i++) { - r[i].dock->setActive(set); - } - - config->setGroup("General Options"); - config->writeEntry("Active", set); - config->sync(); -} - -void StatPopup::clearHistory() { - for (int i = 0; i < r.size(); i++) { - r[i].dock->clearHistory(); - } -} - -void StatPopup::selectSpeed() { - SpeedDialog dlg(speed, firstDock()); - if (dlg.exec()) { - int newSpeed = dlg.getSpeed(); - if (newSpeed > 0) { - speed = newSpeed; - if (timer->isActive()) - timer->changeInterval(speed); - - config->setGroup("General Options"); - config->writeEntry("Speed", speed); - config->sync(); - } - } -} - -void StatPopup::setSplit(bool set) { - if (! supportSplit) - return; - - for (int i = 0; i < r.size(); i++) { - r[i].dock->setSplit(set); - } - - requestResize(); - - config->setGroup("General Options"); - config->writeEntry("Split", set); - config->sync(); -} - -void StatPopup::setFillLines() { - fillStyle = StatDock::fillLines; - - actFillLines->setChecked(true); - actFillBars->setChecked(false); - actFillShaded->setChecked(false); - - for (int i = 0; i < r.size(); i++) { - r[i].dock->setFill(StatDock::fillLines); - } - - config->setGroup("General Options"); - config->writeEntry("StyleID", StatDock::fillLines); - config->sync(); -} - -void StatPopup::setFillBars() { - fillStyle = StatDock::fillBars; - - actFillLines->setChecked(false); - actFillBars->setChecked(true); - actFillShaded->setChecked(false); - - for (int i = 0; i < r.size(); i++) { - r[i].dock->setFill(StatDock::fillBars); - } - - config->setGroup("General Options"); - config->writeEntry("StyleID", StatDock::fillBars); - config->sync(); -} - -void StatPopup::setFillShaded() { - fillStyle = StatDock::fillShaded; - - actFillLines->setChecked(false); - actFillBars->setChecked(false); - actFillShaded->setChecked(true); - - for (int i = 0; i < r.size(); i++) { - r[i].dock->setFill(StatDock::fillShaded); - } - - config->setGroup("General Options"); - config->writeEntry("StyleID", StatDock::fillShaded); - config->sync(); -} - -void StatPopup::setSoft(bool set) { - for (int i = 0; i < r.size(); i++) { - r[i].dock->setSoft(set); - } - - config->setGroup("General Options"); - config->writeEntry("Soft", set); - config->sync(); -} - -void StatPopup::setLabelled(bool set) { - for (int i = 0; i < r.size(); i++) { - r[i].dock->setLabelled(set); - } - - config->setGroup("General Options"); - config->writeEntry("Labelled", set); - config->sync(); -} - -void StatPopup::setGrid(bool set) { - for (int i = 0; i < r.size(); i++) { - r[i].dock->setGrid(set); - } - - config->setGroup("General Options"); - config->writeEntry("Grid", set); - config->sync(); -} - -void StatPopup::selectColor() { - // which color? - int whichDock; - if (sscanf(TQT_TQOBJECT(const_cast(sender()))->name(), "Color%d", &whichDock) != 1) - return; - if (whichDock < 0 || whichDock >= r.size()) - return; - - if (r[whichDock].dock) { - TQColor ans; - if (KColorDialog::getColor(ans, r[whichDock].color, firstDock()) == - TQDialog::Accepted) { - r[whichDock].color = ans; - r[whichDock].dock->setColor(ans); - - config->setGroup("General Options"); - TQString n; - n.sprintf("Color%d", whichDock); - config->writeEntry(n, ans); - config->sync(); - } - } -} - -StatDock* StatPopup::firstDock() { - return r.size() > 0 ? r[0].dock : 0; -} - -void StatPopup::startUpdates() { - takeReading(); - timer->start(speed); -} - -void StatPopup::stopUpdates() { - timer->stop(); - fullReading = i18n("Inactive."); -} - -void StatPopup::setupActions() { - config->setGroup("General Options"); - bool bVal; - - bVal = config->readBoolEntry("Active", true); - actActive = new TDEToggleAction(i18n("&Active"), 0, coll, "active"); - actActive->setChecked(bVal); - connect(actActive, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setActive(bool))); - - actClearHistory = new TDEAction(i18n("&Clear"), "edit-delete", 0, - TQT_TQOBJECT(this), TQT_SLOT(clearHistory()), coll, "clear"); - - speed = config->readNumEntry("Speed", DEFAULT_SPEED); - actSpeed = new TDEAction(i18n("&Speed..."), "speedarrow", 0, - TQT_TQOBJECT(this), TQT_SLOT(selectSpeed()), coll, "speed"); - - if (supportSplit) { - bVal = config->readBoolEntry("Split", true); - actSplit = new IconToggleAction(i18n("Sp&lit Graph"), "split", - i18n("Graph Sp&litting Enabled"), "spliton", 0, coll, "split"); - actSplit->setChecked(bVal); - connect(actSplit, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setSplit(bool))); - } - - fillStyle = config->readNumEntry("StyleID", StatDock::fillShaded); - actFillLines = new IconToggleAction(i18n("&Lines"), "lines", "lineson", 0, - TQT_TQOBJECT(this), TQT_SLOT(setFillLines()), coll, "filllines"); - actFillLines->setChecked(fillStyle == StatDock::fillLines); - actFillBars = new IconToggleAction(i18n("&Bars"), "bars", "barson", 0, - TQT_TQOBJECT(this), TQT_SLOT(setFillBars()), coll, "fillbars"); - actFillBars->setChecked(fillStyle == StatDock::fillBars); - actFillShaded = new IconToggleAction(i18n("&Shaded"), "shaded", "shadedon", - 0, TQT_TQOBJECT(this), TQT_SLOT(setFillShaded()), coll, "fillshaded"); - actFillShaded->setChecked(fillStyle == StatDock::fillShaded); - - bVal = config->readBoolEntry("Soft", false); - actSoft = new IconToggleAction(i18n("So&ft Curves"), "soft", - i18n("So&ft Curves Enabled"), "softon", 0, coll, "soft"); - actSoft->setChecked(bVal); - connect(actSoft, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setSoft(bool))); - - bVal = config->readBoolEntry("Labelled", true); - actLabelled= new IconToggleAction(i18n("Show &Labels"), "labels", - i18n("&Labels Enabled"), "labelson", 0, coll, "labelled"); - actLabelled->setChecked(bVal); - connect(actLabelled, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setLabelled(bool))); - - bVal = config->readBoolEntry("Grid", true); - actGrid = new IconToggleAction(i18n("Show &Grid"), "grid", - i18n("&Grid Enabled"), "gridon", 0, coll, "grid"); - actGrid->setChecked(bVal); - connect(actGrid, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setGrid(bool))); - - setupCustomActions(); -} - -void StatPopup::paintEvent(TQPaintEvent*) { - TQPainter p(this); - - // Draw the border. - p.setPen(colorBorder); - p.drawLine(0, 0, width(), 0); - p.drawLine(0, 1, width(), 1); - p.drawLine(0, 2, 0, height()); - p.drawLine(1, 2, 1, height()); - p.drawLine(width() - 2, 2, width() - 2, height()); - p.drawLine(width() - 1, 2, width() - 1, height()); - p.drawLine(2, height() - 2, width() - 2, height() - 2); - p.drawLine(2, height() - 1, width() - 2, height() - 1); - - // Draw the text. - p.setFont(font()); - p.setPen(colorGroup().foreground()); - p.drawText(rect(), AlignHCenter | AlignVCenter, fullReading); -} - -void StatPopup::mousePressEvent(TQMouseEvent* e) { - if(e->button() == Qt::RightButton) { - // Hide the pop-up. - hide(); - } else { - // Begin a drag operation. - isDragged = true; - relX = e->x(); - relY = e->y(); - repaint(); - } -} - -void StatPopup::mouseMoveEvent(TQMouseEvent* e) { - // In the middle of a drag operation. - move(e->globalX() - relX, e->globalY() - relY); -} - -void StatPopup::mouseReleaseEvent(TQMouseEvent* e) { - // The end of a drag operation. - move(e->globalX() - relX, e->globalY() - relY); - isDragged = false; - repaint(); -} - -void StatPopup::closeEvent(TQCloseEvent* e) { - // We're about to close. Save the current state for the last time. - savePopupState(); - closing = true; - TQWidget::closeEvent(e); -} - -void StatPopup::hideEvent(TQHideEvent* e) { - // We're about to hide. Save the current state if we're not - // closing altogether. - if (! closing) - savePopupState(); - TQWidget::hideEvent(e); -} - -void StatPopup::showEvent(TQShowEvent* e) { - // Make sure we're up-to-date and properly resized. - if (isActive()) - takeReading(); - else - resizeToText(); - - // Window management - fix so a taskbar button doesn't appear - KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); - - TQWidget::showEvent(e); -} - -void StatPopup::takeReading() { - takeReadingInternal(); - - for (int i = 0; i < r.size(); i++) { - r[i].dock->addPercentReading(r[i].upper, r[i].lower); - } - - if (isVisible()) { - // Only resize if the pop-up is visible; otherwise fullReading - // might be stale anyway so we'll do it when we show the pop-up. - if (resizeRequested) - resizeToText(); - - repaint(); - } -} - -void StatPopup::resizeToText() { - resizeRequested = false; - - TQSize size = fontMetrics().size(0, fullReading); - resize(size.width() + 2 * TEXT_EXPANSION_HORIZONTAL, - size.height() + 2 * TEXT_EXPANSION_VERTICAL); - repaint(); -} - -#include "statpopup.moc" diff --git a/kcpuload/kcpuload/statpopup.h b/kcpuload/kcpuload/statpopup.h deleted file mode 100644 index 1b158a6..0000000 --- a/kcpuload/kcpuload/statpopup.h +++ /dev/null @@ -1,320 +0,0 @@ - -/*************************************************************************** - * * - * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * - * (c) 2002, Ben Burton * - * * - * 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. * - * * - ***************************************************************************/ - -#ifndef __STATPOPUP_H -#define __STATPOPUP_H - -#include -#include // sorry, TQValueVector::erase() does not call destructors - -class TDEAction; -class TDEActionCollection; -class TDEConfig; -class TDEPopupMenu; -class TDERadioAction; -class TDESelectAction; -class TDEToggleAction; -class TQTimer; -class StatDock; - -/** - * A small pop-up window that contains a continually updating display of - * statistics. - * - * This pop-up will be sticky and stay-on-top by default. - * - * Up to two windows docked in the system tray (of class StatDock) can - * be maintained by this pop-up. There should only be one StatPopup - * per application. - * - * Note that initDock() \e must be called when a system tray window is - * created, though it is generally called automatically from the StatDock - * constructor. - * - * Note also that the constructor for this class does \e not call - * setupActions(), readPopupState() or startUpdates(); these must all be - * called by other routines (such as subclass constructors), since they - * require either subclass initialisation or an existing system tray - * window. - */ -class StatPopup : public TQWidget { - Q_OBJECT - - -public: - /** - * Colour constants. - */ - static const TQColor colorBorder; - -public: - /** - * Constructors and destructors. - * - * This constructor will set the config variable but will not read - * any configuration information. See the general class notes also - * for a list of other routines this constructor will not call. - */ - StatPopup(bool useSupportSplit, TQWidget *parent = 0, const char *name = 0); - ~StatPopup(); - - /** - * Geometric pop-up state management. - */ - void readPopupState(); - void savePopupState(); - - /** - * Initialises the given system tray window and its context menu. - * - * All global application properties (i.e., properties held by this - * pop-up) will be propagated to the system tray window, and all - * global application actions will be added to the given menu. - * - * Parameter whichDock must be either 0 or 1 to specify whether the - * given system tray window will become window dock[0] or dock[1]. - * - * This routine \e must be called when a system tray window is first - * created, though in general this will be done automatically by the - * StatDock constructor. - */ - virtual void initDock(StatDock* target, TDEPopupMenu* menu, int whichDock); - - /** - * Is this application currently active (i.e., taking periodic - * readings and displaying them)? - */ - bool isActive() const; - - /** - * Are split diagrams currently enabled? - */ - bool isSplit() const; - - /** - * Returns the frequency of updates in milliseconds. - */ - int getSpeed() const; - -public slots: - /** - * Slots for menu items. - */ - void setActive(bool); - void clearHistory(); - void selectSpeed(); - void setSplit(bool); - void setFillLines(); - void setFillBars(); - void setFillShaded(); - void setSoft(bool); - void setLabelled(bool); - void setGrid(bool); - void selectColor(); - -protected: - /** - * Return a human-readable name and default diagram colour for each - * system tray window. - * The argument given will be either 0 or 1, referring to window - * dock[0] or dock[1] respectively. - */ - virtual TQString dockName(int which) const = 0; - virtual TQColor defaultDockColor(int which) const = 0; - - /** - * Take a fresh reading. Subclasses must override this routine. - * - * This routine must update the array upper. - * If split readings are enabled, it must also update the array lower. - * If this pop-up is visible, it must also update the string fullReading. - */ - virtual void takeReadingInternal() = 0; - - /** - * Sets up any actions specific to subclasses of StatPopup. - * The global configuration should be read at this point to set the - * initial states of these actions. - * - * This routine will be called during setupActions(). - */ - virtual void setupCustomActions() {} - - /** - * Inserts any menu items specific to subclasses of StatPopup into - * the given menu. If any items are inserted, a separator should - * be inserted after them. - * - * This routine will be called during initDock(). - */ - virtual void insertCustomItems(TDEPopupMenu*) {} - - /** - * Propagates any properties specific to subclasses of StatPopup to - * the given system tray window during its initialisation. - * - * This routine will be called during initDock(). - */ - virtual void setCustomProperties(StatDock*) {} - - /** - * Returns the first non-null pointer out of dock[0] and dock[1], or - * returns null if both these pointers are null. - */ - StatDock* firstDock(); - - /** - * Start and stop the periodic taking of readings. - */ - void startUpdates(); - void stopUpdates(); - - /** - * Set up the collection of appliation-wide actions. - * The global configuration will be read at this point to set the - * initial states of these actions. - */ - virtual void setupActions(); - - /** - * Request that this pop-up be resized at the next reading according - * to its text contents. The pop-up will be resized \e after the - * reading is taken. - */ - void requestResize(); - - /** - * Custom painting routine. - */ - void paintEvent(TQPaintEvent *); - - /** - * Overrides for dragging support. - */ - void mousePressEvent(TQMouseEvent *); - void mouseReleaseEvent(TQMouseEvent *); - void mouseMoveEvent(TQMouseEvent *); - - /** - * Overrides for saving the popup state. - */ - void closeEvent(TQCloseEvent *); - void hideEvent(TQHideEvent *); - void showEvent(TQShowEvent *); - -protected slots: - /** - * Take a fresh reading and update all visual elements accordingly. - */ - void takeReading(); - -protected: - /** - * Configuration and GUI elements. - */ - TDEConfig* config; - /**< The configuration for the underlying application. */ - - /** - * Contains the readings per CPU. - */ - struct Reading { - StatDock* dock; - /**< The system tray window maintained by this pop-up. - May be null. */ - int upper; - /**< The upper reading taken during the last reading. */ - int lower; - /**< The lower reading taken during the last reading. */ - TQColor color; - /**< The colour used in the system tray diagram. */ - TDEAction* actColor; - /**< The menu item to change the colour of this dock. */ - Reading(); - ~Reading(); - void Init(int which, StatPopup* popup); - }; - std::vector r; - /**< The readings maintained by this pop-up. */ - TDEActionCollection* coll; - /**< The collection of all application-level actions. */ - - TQString fullReading; - /**< A full string describing the last reading taken, - to be displayed in this pop-up. */ - -private: - /** - * Resize this pop-up according to its text contents (i.e., the - * variable fullReading). A little extra room will be added to - * accomodate potential minor variations in the text. - */ - void resizeToText(); - -private: - /** - * Update support. - */ - TQTimer* timer; - /**< The timer handling periodic updates. */ - int speed; - /**< The frequency of updates in milliseconds. */ - - /* - * Diagram support. - */ - int fillStyle; - /**< The fill style used in the system tray diagrams. */ - bool supportSplit; - /**< Does this application support split diagrams? */ - - /** - * Pop-up support. - */ - int relX; - /**< The X coordinate of this pop-up at the beginning of a drag - operation. */ - int relY; - /**< The Y coordinate of this pop-up at the beginning of a drag - operation. */ - bool isDragged; - /**< Are we in the middle of a drag operation? */ - bool closing; - /**< Have we received a close event? */ - bool resizeRequested; - /**< Has a pop-up resize been requested? */ - - /** - * Actions - */ - TDEToggleAction* actActive; - TDEAction* actClearHistory; - TDEAction* actSpeed; - TDEToggleAction* actSplit; - TDEToggleAction* actFillLines; - TDEToggleAction* actFillBars; - TDEToggleAction* actFillShaded; - TDEToggleAction* actSoft; - TDEToggleAction* actLabelled; - TDEToggleAction* actGrid; -}; - -inline int StatPopup::getSpeed() const { - return speed; -} - -inline void StatPopup::requestResize() { - resizeRequested = true; -} - -#endif diff --git a/src/AUTHORS b/src/AUTHORS new file mode 100644 index 0000000..4af821b --- /dev/null +++ b/src/AUTHORS @@ -0,0 +1,2 @@ +Markus Gustavsson +Ben Burton diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..2166732 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,45 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIB_DIR} +) + + +##### kcpuload (executable) + +tde_add_executable( kcpuload AUTOMOC + + SOURCES + icontoggleaction.cpp + kcpudock.cpp + kcpuload.cpp + kcpuproc.cpp + main.cpp + statdock.cpp + speeddialog.cpp + statpopup.cpp + LINK + tdecore-shared + tdeui-shared + + DESTINATION ${BIN_INSTALL_DIR} +) + + +##### icons + +tde_install_icons( kcpuload ) + + +##### other data + +install( FILES kcpuload.desktop + DESTINATION ${APPS_INSTALL_DIR}/System +) diff --git a/src/COPYING b/src/COPYING new file mode 100644 index 0000000..c7aea18 --- /dev/null +++ b/src/COPYING @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/src/ChangeLog b/src/ChangeLog new file mode 100644 index 0000000..c9ce0a5 --- /dev/null +++ b/src/ChangeLog @@ -0,0 +1,53 @@ + + 02-12-20 * Added BSD support thanks to Andy Fawcett and Robbie Ward. + + 02-12-13 * v1.99. + * Ported to KDE3. + * Completely restructured, with the aims of: + - sharing as much code as possible between KCPULoad + and KNetLoad; + - looking and behaving more like other KDE apps + (including more respect for system settings and i18n); + - making the code more maintainable (such as providing + source documentation). + * Removed references to original website which is now offline. + Hopefully the new home will be KDE CVS. + * New maintainer Ben Burton . + + 00-10-01 * v1.90 Ported to QT 2.x / KDE 1.9x/2.x (prerelease). + + 99-09-15 * Added a split option, which splits the diagram up + into one system-load scale and one user-load scale. + + 99-09-13 * Added German translation thanks to Fredrik Olson. + + 99-09-09 * Added a new Soft diagram option for a smoother curve. + * Added user documentation for installation and usage. + + 99-09-07 * Finished a new specialdesigned QToolTip lookalike, + leftclick to show it, leftclick again or rightclick + on popup to hide, use left mouse on popup to move it. + * Structure changes to make the program use less CPU. + + 99-09-01 * Added colorsetting for CPU2's diagram, and changed + so that SMP options don't appear on non-SMP systems. + + 99-08-30 * Settings are now saved direcly, not only upon quit. + * Added sessionmanagement thanks to Carsten Pfeiffer, + so the program will restart when KDE is restarted. + * Removed QToolTip Popup info dialog from program + because of a mem leak which made the program hang. + * Added several icons for both Color and style menues. + + 99-08-29 * Added two translations, Swedish, and Croatian + thanks to Vladimir Vuksan + + 99-08-28 * Full SMP support with extra option for multiple + diagrams, one for each CPU or one for both. + * Added labels, so it doesn't look like knetload. + * Added Popup Tooltips with exact utilization values. + + 99-08-11 * Uses qmessagebox.h instead of `outdated' qmsgbox.h. + * Small security fixes. + + 99-08-06 * Program ready for initial release v1.0. diff --git a/src/INSTALL b/src/INSTALL new file mode 100644 index 0000000..02a4a07 --- /dev/null +++ b/src/INSTALL @@ -0,0 +1,167 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes a while. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Type `make install' to install the programs and any data files and + documentation. + + 4. You can remove the program binaries and object files from the + source code directory by typing `make clean'. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..2d2de37 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,50 @@ + +############################################################################ +# # +# Main KCPULoad sources. # +# # +# KCPULoad is copyright (c) 1999-2000, Markus Gustavsson # +# (c) 2002, Ben Burton # +# # +# 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. # +# # +############################################################################ + +INCLUDES = $(all_includes) + +bin_PROGRAMS = kcpuload + +kcpuload_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor + +kcpuload_LDADD = $(LIB_TDEUI) + +kcpuload_SOURCES = \ + icontoggleaction.cpp \ + kcpudock.cpp \ + kcpuload.cpp \ + kcpuproc.cpp \ + main.cpp \ + statdock.cpp \ + speeddialog.cpp \ + statpopup.cpp + +noinst_HEADERS = \ + icontoggleaction.h \ + kcpudock.h \ + kcpuload.h \ + kcpuproc.h \ + speeddialog.h \ + statdock.h \ + statpopup.h + +METASOURCES = AUTO + +appsdir = $(kde_appsdir)/System +apps_DATA = kcpuload.desktop + +KDE_ICON = kcpuload + +EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL README TODO diff --git a/src/README b/src/README new file mode 100644 index 0000000..ff5d0b6 --- /dev/null +++ b/src/README @@ -0,0 +1,29 @@ + +KCPULoad + +This file should only be read as a fast description. The online +KCPULoad handbook contains more detailed information. + +This is a small program for Kicker (the TDE panel). It will show the CPU +usage in the form of one or two configurable diagrams. There are settings +for colors and some different styles. Note that it isn't the real system +load that's shown, but the percent used of the total CPU power, which is +calculated from the number of CPU ticks.. don't ask me what that means :). + +To bring up the settings menu, simply right click on the diagram. Use a +slower update interval to get a more stable and accurate diagram without +flicker. + +If there is more than one CPU on the system, the total CPU usage from both +can be shown, or you can choose to have one separate diagram for each of the +CPUs. Left click on the diagram to bring up a small information box which +will show the exact CPU usage in text form. + +Install: + +./configure +make +make install + + Markus Gustavsson + diff --git a/src/TODO b/src/TODO new file mode 100644 index 0000000..a3f1ba2 --- /dev/null +++ b/src/TODO @@ -0,0 +1,7 @@ + +DCOP support. +Change the text on colour menu items as docks are created and destroyed. +Support sticky pop-ups. +Have the default location of the pop-up being close to the system tray dock(s). +Support for more than two CPUs. + diff --git a/src/cr16-app-kcpuload.png b/src/cr16-app-kcpuload.png new file mode 100644 index 0000000..aa2ad05 Binary files /dev/null and b/src/cr16-app-kcpuload.png differ diff --git a/src/cr32-app-kcpuload.png b/src/cr32-app-kcpuload.png new file mode 100644 index 0000000..03e97bf Binary files /dev/null and b/src/cr32-app-kcpuload.png differ diff --git a/src/cr48-app-kcpuload.png b/src/cr48-app-kcpuload.png new file mode 100644 index 0000000..59aedb3 Binary files /dev/null and b/src/cr48-app-kcpuload.png differ diff --git a/src/icontoggleaction.cpp b/src/icontoggleaction.cpp new file mode 100644 index 0000000..3e73d98 --- /dev/null +++ b/src/icontoggleaction.cpp @@ -0,0 +1,63 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "icontoggleaction.h" + +IconToggleAction::IconToggleAction( + const TQString& useTextUnchecked, const TQString& useIconUnchecked, + const TQString& useTextChecked, const TQString& useIconChecked, + const TDEShortcut& cut, const TQObject* receiver, const char* slot, + TQObject* parent, const char* name) : + TDEToggleAction(useTextUnchecked, useIconUnchecked, cut, receiver, + slot, parent, name), + textChecked(useTextChecked), textUnchecked(useTextUnchecked), + iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { +} + +IconToggleAction::IconToggleAction(const TQString& useText, + const TQString& useIconUnchecked, const TQString& useIconChecked, + const TDEShortcut& cut, const TQObject* receiver, const char* slot, + TQObject* parent, const char* name) : + TDEToggleAction(useText, useIconUnchecked, cut, receiver, + slot, parent, name), + textChecked(useText), textUnchecked(useText), + iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { +} + +IconToggleAction::IconToggleAction( + const TQString& useTextUnchecked, const TQString& useIconUnchecked, + const TQString& useTextChecked, const TQString& useIconChecked, + const TDEShortcut& cut, TQObject* parent, const char* name) : + TDEToggleAction(useTextUnchecked, useIconUnchecked, cut, parent, name), + textChecked(useTextChecked), textUnchecked(useTextUnchecked), + iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { +} + +IconToggleAction::IconToggleAction(const TQString& useText, + const TQString& useIconUnchecked, const TQString& useIconChecked, + const TDEShortcut& cut, TQObject* parent, const char* name) : + TDEToggleAction(useText, useIconUnchecked, cut, parent, name), + textChecked(useText), textUnchecked(useText), + iconChecked(useIconChecked), iconUnchecked(useIconUnchecked) { +} + +void IconToggleAction::setChecked(bool value) { + if (value != isChecked()) { + setText(value ? textChecked : textUnchecked); + setIcon(value ? iconChecked : iconUnchecked); + } + + TDEToggleAction::setChecked(value); +} + +#include "icontoggleaction.moc" diff --git a/src/icontoggleaction.h b/src/icontoggleaction.h new file mode 100644 index 0000000..c54f120 --- /dev/null +++ b/src/icontoggleaction.h @@ -0,0 +1,62 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef __ICONTOGGLEACTION_H +#define __ICONTOGGLEACTION_H + +#include + +/** + * A toggle action that uses different labels and pixmaps in its + * different states. + */ +class IconToggleAction : public TDEToggleAction { + Q_OBJECT + + + public: + /** + * Constructors. + */ + IconToggleAction( + const TQString& useTextUnchecked, const TQString& useIconUnchecked, + const TQString& useTextChecked, const TQString& useIconChecked, + const TDEShortcut& cut, const TQObject* receiver, const char* slot, + TQObject* parent, const char* name = 0); + IconToggleAction(const TQString& useText, + const TQString& useIconUnchecked, const TQString& useIconChecked, + const TDEShortcut& cut, const TQObject* receiver, const char* slot, + TQObject* parent, const char* name = 0); + IconToggleAction( + const TQString& useTextUnchecked, const TQString& useIconUnchecked, + const TQString& useTextChecked, const TQString& useIconChecked, + const TDEShortcut& cut = TDEShortcut(), TQObject* parent = 0, + const char* name = 0); + IconToggleAction(const TQString& useText, + const TQString& useIconUnchecked, const TQString& useIconChecked, + const TDEShortcut& cut = TDEShortcut(), TQObject* parent = 0, + const char* name = 0); + + /** + * Overridden to include icon adjustment. + */ + virtual void setChecked(bool); + + private: + TQString textChecked, textUnchecked; + /**< The labels to use in the checked and unchecked states. */ + TQString iconChecked, iconUnchecked; + /**< The icons to use in the checked and unchecked states. */ +}; + +#endif diff --git a/src/kcpudock.cpp b/src/kcpudock.cpp new file mode 100644 index 0000000..998cc30 --- /dev/null +++ b/src/kcpudock.cpp @@ -0,0 +1,32 @@ + +/*************************************************************************** + * * + * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "kcpudock.h" + +#include + +KCPUDock::KCPUDock(int whichCPU, StatPopup *parent, const char *name) : + StatDock(whichCPU, i18n("C"), parent, name) { +} + +void KCPUDock::setCPULabel(int set) { + if (set == 1) + setLabel(i18n("C 0")); + else if (set == 2) + setLabel(i18n("C 1")); + else + setLabel(i18n("C")); + + repaint(); +} + diff --git a/src/kcpudock.h b/src/kcpudock.h new file mode 100644 index 0000000..f96e411 --- /dev/null +++ b/src/kcpudock.h @@ -0,0 +1,41 @@ + +/*************************************************************************** + * * + * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef __KCPUDOCK_H +#define __KCPUDOCK_H + +#include "statdock.h" + +/** + * A KCPULoad system tray window for a specific CPU. + */ +class KCPUDock : public StatDock { + +public: + /** + * Constructor. + */ + KCPUDock(int whichDock, StatPopup *parent = 0, const char *name = 0); + + /** + * Sets the label for this diagram. The label will reflect which + * CPU the diagram represents. + * + * If multiple CPUs are not used, argument cpu should be 0. + * Otherwise argument cpu should be 1 or 2 for the first or second + * CPU respectively. + */ + void setCPULabel(int cpu); +}; + +#endif diff --git a/src/kcpuload.cpp b/src/kcpuload.cpp new file mode 100644 index 0000000..6005313 --- /dev/null +++ b/src/kcpuload.cpp @@ -0,0 +1,177 @@ + +/*************************************************************************** + * * + * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "icontoggleaction.h" +#include "kcpudock.h" +#include "kcpuload.h" +#include "kcpuproc.h" + +#include +#include +#include +#include + +KCPULoad::KCPULoad(TQWidget *parent, const char *name) : + StatPopup(true, parent, name) { + // Create the /proc reading class and check for SMP. + proc = new KCPUProc(); + supportSMP = proc->hasSMP(); + + // Set up actions and read the config file. + setupActions(); + + // the vector must not be reallocated during resizing because the class + // that it contains (Reading) cannot be copied safely + r.reserve(proc->cpu.size()); + + // Create system tray windows. + resizeReadings(supportSMP && actSMP->isChecked() ? proc->cpu.size() : 1); + + // Initialise the pop-up window. + readPopupState(); + + // Off we go! + requestResize(); + if (isActive()) + startUpdates(); +} + +KCPULoad::~KCPULoad() { + delete proc; +} + +void KCPULoad::setSMP(bool set) { + if (! supportSMP) + return; + + resizeReadings(set ? proc->cpu.size() : 1); + + requestResize(); + if (isActive()) + takeReading(); + + config->setGroup("General Options"); + config->writeEntry("SMP", set); + config->sync(); +} + +TQString KCPULoad::dockName(int which) const { + return i18n("CPU %1").arg(which+1); +} + +TQColor KCPULoad::defaultDockColor(int which) const { + static const TQColor c[] = { + TQColor(0, 255, 0), + TQColor(255, 0, 0), + TQColor(255, 255, 0), + TQColor(0, 255, 255) + }; + return c[which % (sizeof(c)/sizeof(c[0]))]; +} + +void KCPULoad::setupCustomActions() { + if (supportSMP) { + bool bVal = config->readBoolEntry("SMP", false); + actSMP = new IconToggleAction(i18n("Enable S&MP"), "smp", + i18n("S&MP Enabled"), "smpon", 0, coll, "smp"); + actSMP->setChecked(bVal); + connect(actSMP, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setSMP(bool))); + } +} + +void KCPULoad::insertCustomItems(TDEPopupMenu* menu) { + if (supportSMP) { + actSMP->plug(menu); + menu->insertSeparator(); + } +} + +void KCPULoad::takeReadingInternal() { + proc->readLoad(); + + if (r.size() > 1) { + if (isSplit()) { + for (int i = 0; i < r.size(); i++) { + r[i].upper = proc->cpu[i].userPercent(); + r[i].lower = proc->cpu[i].systemPercent(); + } + } else { + for (int i = 0; i < r.size(); i++) { + r[i].upper = proc->cpu[i].totalPercent(); + } + } + } else if (r.size() > 0) { + if (isSplit()) { + r[0].upper = proc->all.userPercent(); + r[0].lower = proc->all.systemPercent(); + } else { + r[0].upper = proc->all.totalPercent(); + } + } + + if (isVisible()) { + if (r.size() > 1) { + if (isSplit()) { + TQString user = + i18n("Current CPU User: %1%") + .arg(proc->all.userPercent()); + TQString sys = + i18n("Current CPU System: %1%") + .arg(proc->all.systemPercent()); + for (int i = 0; i < r.size(); i++) { + user += i18n(", C%1: %2%").arg(i+1).arg(r[i].upper); + sys += i18n(", C%1: %2%").arg(i+1).arg(r[i].lower); + } + fullReading = i18n("%1.\n%2.").arg(user, sys); + } else { + TQString total = + i18n("Current CPU usage: %1%") + .arg(proc->all.totalPercent()); + for (int i = 0; i < r.size(); i++) { + total += i18n(", C%1: %2%").arg(i+1).arg(r[i].upper); + } + fullReading = i18n("%1.").arg(total); + } + } else if (r.size() > 0) { + if (isSplit()) { + fullReading = i18n( + "Current CPU User: %1%.\n" + "Current CPU System: %2%.") + .arg(r[0].upper).arg(r[0].lower); + } else { + fullReading = i18n("Current CPU usage: %1%.").arg(r[0].upper); + } + } + } + } + +void KCPULoad::resizeReadings(int n) +{ + int i = r.size(); + r.resize(n); + for (; i < n; i++) { + // action is needed by KCPUDock constructor + r[i].Init(i, this); + KCPUDock* dock = new KCPUDock(i, this); + dock->setCPULabel(i+1); + r[i].dock = dock; + } + // special case single CPU or total + if (n == 1) { + static_cast(r[0].dock)->setCPULabel(0); + } else if (n > 1) { + static_cast(r[0].dock)->setCPULabel(1); + } +} + +#include "kcpuload.moc" diff --git a/src/kcpuload.desktop b/src/kcpuload.desktop new file mode 100644 index 0000000..8182af4 --- /dev/null +++ b/src/kcpuload.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=kcpuload +Icon=kcpuload +X-DocPath=kcpuload/index.html +Terminal=0 +Name=KCPULoad +GenericName=CPU Monitor +Comment=A small CPU usage meter for Kicker +Categories=Qt;TDE;System diff --git a/src/kcpuload.h b/src/kcpuload.h new file mode 100644 index 0000000..892d7db --- /dev/null +++ b/src/kcpuload.h @@ -0,0 +1,72 @@ + +/*************************************************************************** + * * + * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef __KCPULOAD_H +#define __KCPULOAD_H + +#include "statpopup.h" + +class KCPUProc; +class TDEToggleAction; + +/** + * The specific pop-up window used by KCPULoad. + */ +class KCPULoad : public StatPopup { + Q_OBJECT + + +public: + /** + * Constructor and destructor. + */ + KCPULoad(TQWidget *parent = 0, const char *name = 0); + ~KCPULoad(); + +public slots: + /** + * Slots for menu items. + */ + void setSMP(bool); + +protected: + /** + * Overrides from StatPopup. + */ + virtual TQString dockName(int which) const; + virtual TQColor defaultDockColor(int which) const; + virtual void setupCustomActions(); + virtual void insertCustomItems(TDEPopupMenu* menu); + virtual void takeReadingInternal(); + +private: + /** + * Changes the number of readings. + */ + void resizeReadings(int n); + + /** + * Reading raw CPU information. + */ + KCPUProc* proc; + /**< Used to obtain the raw information. */ + bool supportSMP; + /**< Does this system support SMP at all? */ + + /** + * Actions. + */ + TDEToggleAction* actSMP; +}; + +#endif diff --git a/src/kcpuproc.cpp b/src/kcpuproc.cpp new file mode 100644 index 0000000..f7fbe4f --- /dev/null +++ b/src/kcpuproc.cpp @@ -0,0 +1,196 @@ + +/*************************************************************************** + * * + * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "kcpuproc.h" + +#include +#include + +// BSD-specific includes. +#ifdef Q_OS_BSD4 +#include +#include +#include +#include +#include +#ifdef Q_OS_NETBSD +#include +#endif +#endif + +/** + * Linux + * ----- + * + * System information is read from /proc/stat. + * + * We assume /proc/stat is in one of the following formats: + * + * cpu %d %d %d %d + * .... + * + * cpu %d %d %d %d + * cpu0 %d %d %d %d + * .... + * + * cpu %d %d %d %d + * cpu0 %d %d %d %d + * cpu1 %d %d %d %d + * .... + * + * where each set of four numbers is of the form: + * + * user_ticks nice_ticks system_ticks idle_ticks + * + * We also allow sets of seven numbers instead of four (as provided by + * the 2.6 kernel); the last three of these numbers are ignored. + * + * BSD + * --- + * + * Currently only uni-processor mode is supported for BSD. + * + * BSD code by Andy Fawcett and + * Robbie Ward , licensed under GPL2. + * + * Other Operating Systems + * ----------------------- + * + * Please, send in a patch! + * + * The KCPULoad maintainer is currently Ben Burton , or + * you could submit a patch through the KDE bug tracking system + * (bugs.kde.org). + */ + +KCPUProc::CPU::Ticks::Ticks() : + U(0), S(0), N(0), I(0) +{ } + +KCPUProc::KCPUProc() { + smp = false; + + // Look for SMP support and take a current tick reading. + + // ========== BSD-specific (begin) ========== +#ifdef Q_OS_BSD4 + readLoad(); + return; +#endif + // ========== BSD-specific (end) ========== + + // ========== Linux-specific (begin) ========== +#ifdef Q_OS_LINUX + if ((fd = fopen("/proc/stat", "r")) == 0) + return; + + if (!all.parse(fd)) + return; + CPU c; + while (c.parse(fd)) + cpu.push_back(c); + smp = cpu.size() > 1; +#endif + // ========== Linux-specific (end) ========== +} + +void KCPUProc::readLoad() { + // OS-specific local variables. + + // ========== Linux-specific (begin) ========== +#ifdef Q_OS_LINUX + // Prepare to take the readings. + + if ((fd = fopen("/proc/stat", "r")) == 0) + return; + + // Take a fresh set of current readings (SMP mode). + + all.parse(fd); + for (int i = 0; i < cpu.size(); i++) { + if (!cpu[i].parse(fd)) + break; + } + + // Clean up after taking readings. + + fclose(fd); +#endif + // ========== Linux-specific (end) ========== + + // ========== BSD-specific (begin) ========== +#ifdef Q_OS_BSD4 + static int name2oid[2] = { 0, 3 }; + static int oidCpuTime[CTL_MAXNAME + 2]; + static size_t oidCpuTimeLen = sizeof(oidCpuTime); + long cpuTime[CPUSTATES]; + unsigned int cpuTimeLen = sizeof(cpuTime); + static char *name = "kern.cp_time"; + static int initialized = 0; + + if(smp) { + // Take a fresh set of current readings (SMP mode). + // TODO: Add SMP support for BSD. + } else { + // Take a fresh set of current readings (uni-processor mode). + + // The current readings must now become the previous readings. + all.p = all.c; + + if (! initialized) { + if (sysctl(name2oid, 2, oidCpuTime, &oidCpuTimeLen, name, + strlen(name)) < 0) + return; + + oidCpuTimeLen /= sizeof(int); + initialized = 1; + } + + if (sysctl(oidCpuTime, oidCpuTimeLen, cpuTime, &cpuTimeLen, 0, 0) < 0) + return; + + all.c.U = cpuTime[CP_USER]; + all.c.N = cpuTime[CP_NICE]; + all.c.S = cpuTime[CP_SYS]; + all.c.I = cpuTime[CP_IDLE]; + } +#endif + // ========== BSD-specific (end) ========== +} + +// ========== Linux-specific (begin) ========== +#ifdef Q_OS_LINUX +bool KCPUProc::CPU::parse(FILE* fd) { + char tagbuffer[32+1]; + Ticks n; // new ticks + if (fscanf(fd, "%32s%d%d%d%d", tagbuffer, &n.U, &n.N, &n.S, &n.I) != 5) { + return false; // failure + } + + if (strncmp(tagbuffer, "cpu", 3) != 0) { + return false; // tag mismatch + } + + // shift readings + p = c; + c = n; + + // ignore the rest of the line + int ch; + do { + ch = getc(fd); + } while (ch != '\n' && ch != EOF); + return true; +} +#endif +// ========== Linux-specific (end) ========== diff --git a/src/kcpuproc.h b/src/kcpuproc.h new file mode 100644 index 0000000..8b844f5 --- /dev/null +++ b/src/kcpuproc.h @@ -0,0 +1,170 @@ + +/*************************************************************************** + * * + * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef __KCPUPROC_H +#define __KCPUPROC_H + +#include +#include +#include + +/** + * A class used to read raw CPU load details from the system. + * + * See kcpuproc.cpp for details of supported operating systems. + */ +class KCPUProc { +public: + /** + * Constructor. + * + * In the constructor, a set of initial CPU tick readings are taken + * and SMP support is determined. + */ + KCPUProc(); + + /** + * Does this system appear to have SMP? + */ + bool hasSMP() const; + + /** + * Takes a fresh set of CPU tick readings. The numerical statistics + * returned refer to the time period between this reading and the + * previous (or between this reading and the object's construction + * if there was no previous reading). + */ + void readLoad(); + + /** + * Contains tick differences for a CPU. + */ + struct CPU { + /** + * Contains user/system/nice/idle tick readings. + */ + struct Ticks { + int U, S, N, I; + Ticks(); + /** Returns user ticks */ + int u() const { return U; } + /** Returns system ticks */ + int s() const { return S + N; } + /** Returns total (non-idle) ticks */ + int t() const { return U + S + N; } + /** Returns elapsed ticks */ + int e() const { return U + S + N + I; } + }; + + Ticks p; /**< The previous tick readings */ + Ticks c; /**< The last (most recent) tick readings */ + + /** + * The percentage of ticks between the last reading and the previous + * reading used by the user loop (compared to the nice, system and + * idle loops). + * + * This routine involves a short arithmetical calculation. + * If you're paranoid about running time, you might want to cache + * the result. + */ + int userPercent() const; + + /** + * The percentage of ticks between the last reading and the previous + * reading used by the system and nice loops (compared to the user and + * idle loops). + * + * This routine involves a short arithmetical calculation. + * If you're paranoid about running time, you might want to cache + * the result. + */ + int systemPercent() const; + + /** + * The percentage of ticks between the last reading and the previous + * reading used by the user, system and nice loops (compared to the + * idle loop). + * + * This routine involves a short arithmetical calculation. + * If you're paranoid about running time, you might want to cache + * the result. + */ + int totalPercent() const; + + /** + * OS-specific helper routines. + */ + + // ========== Linux-specific (begin) ========== +#ifdef Q_OS_LINUX + /** + * Parses the tick readings of the current line in #fd. + * The return value is \c false if the line does not begin with + * the tag "cpu" (optionally followed by a number). + * If the line can be parsed successfully, the last reading becomes + * the previous reading and the newly parsed reading becomes + * the last reading. + */ + bool parse(FILE* fd); +#endif + // ========== Linux-specific (end) ========== + }; + + /* + * Variables used in all modes. + */ + CPU all; /**< Tick readings for all CPUs. */ + + /* + * Variables used only with SMP. + */ + std::vector cpu; /**< Tick readings for CPUs. */ + +private: + /* + * SMP support. + */ + bool smp; + /**< Does this system appear to have SMP? */ + + /** + * OS-specific data members. + */ + + // ========== Linux-specific (begin) ========== +#ifdef Q_OS_LINUX + FILE *fd; + /**< The file /proc/stat. */ +#endif + // ========== Linux-specific (end) ========== +}; + +inline bool KCPUProc::hasSMP() const { + return smp; +} + +inline int KCPUProc::CPU::userPercent() const { + int tot = c.e() - p.e(); + return (tot > 0 ? (100 * (c.u() - p.u())) / tot : 0); +} +inline int KCPUProc::CPU::systemPercent() const { + int tot = c.e() - p.e(); + return (tot > 0 ? (100 * (c.s() - p.s())) / tot : 0); +} +inline int KCPUProc::CPU::totalPercent() const { + int tot = c.e() - p.e(); + return (tot > 0 ? (100 * (c.t() - p.t())) / tot : 0); +} + +#endif diff --git a/src/lo16-app-kcpuload.png b/src/lo16-app-kcpuload.png new file mode 100644 index 0000000..278a3f5 Binary files /dev/null and b/src/lo16-app-kcpuload.png differ diff --git a/src/lo32-app-kcpuload.png b/src/lo32-app-kcpuload.png new file mode 100644 index 0000000..34606e5 Binary files /dev/null and b/src/lo32-app-kcpuload.png differ diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6b587e5 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,64 @@ + +/*************************************************************************** + * * + * KCPULoad is copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "kcpuload.h" + +#include +#include +#include +#include + +static const char *description = + I18N_NOOP("A small CPU usage meter for Kicker (the TDE panel)."); +static const char *message = + I18N_NOOP("KCPULoad was first released on the 8th of August, 1999."); +static const char *version = "2.00"; + +int main(int argc, char **argv) { + TDEAboutData aboutData("kcpuload", I18N_NOOP("KCPULoad"), version, + description, TDEAboutData::License_GPL, + "(c) 1999-2000, Markus Gustavsson\n" + "(c) 2002, Ben Burton\n" + "(c) 2009, Timothy Pearson", + message, 0 /* TODO: Website */, "bab@debian.org"); + + aboutData.addAuthor("Markus Gustavsson", "Original author", + "mighty@fragzone.se"); + aboutData.addAuthor("Ben Burton", "KDE3 rewrite, current maintainer", + "bab@debian.org"); + aboutData.addAuthor("Andy Fawcett", "BSD support", + "andy@athame.co.uk"); + aboutData.addAuthor("Robbie Ward", "BSD support", + "linuxphreak@gmx.co.uk"); + + aboutData.addCredit("Njaard, Charles Samuels", + "Support and help with KDE", "charles@kde.org"); + aboutData.addCredit("rikkus, Rik Hemsley", + "Support and help with KDE", "rik@kde.org"); + aboutData.addCredit("Mark Halpaap", + "Independent port to KDE3", "mark.halpaap@gmx.net"); + aboutData.addCredit("Thanks to everyone in #KDE OpenProjects for " + "being supportive and helpful!"); + + TDECmdLineArgs::init(argc, argv, &aboutData); + KUniqueApplication::addCmdLineOptions(); + + if (! KUniqueApplication::start()) { + fprintf(stderr, I18N_NOOP("KCPULoad is already running!\n")); + return 1; + } + + KUniqueApplication app; + app.setMainWidget(new KCPULoad()); + return app.exec(); +} diff --git a/src/speeddialog.cpp b/src/speeddialog.cpp new file mode 100644 index 0000000..845bb2a --- /dev/null +++ b/src/speeddialog.cpp @@ -0,0 +1,63 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "speeddialog.h" + +#include +#include +#include +#include +#include +#include + +static int stockSpeed[] = { + 100, 150, 200, 250, 300, 400, 600, 800, 1000, 1200, 1500, 2000, 2500, + 3000, 4000, 5000, 0 +}; + +SpeedDialog::SpeedDialog(int defaultSpeed, TQWidget* parent) : + KDialogBase(parent, "speed dialog", true, + i18n("Select Speed"), Ok|Cancel, Ok), + speed(defaultSpeed) { + TQHBox* page = makeHBoxMainWidget(); + + new TQLabel(i18n("Update interval in milliseconds:"), page); + + KComboBox* speedBox = new KComboBox(true, page); + + TQIntValidator* val = new TQIntValidator(TQT_TQOBJECT(this)); + val->setBottom(1); + speedBox->setValidator(val); + + TQString speedStr; + for (int i = 0; stockSpeed[i]; i++) { + speedStr.setNum(stockSpeed[i]); + speedBox->insertItem(speedStr); + } + + speedStr.setNum(defaultSpeed); + speedBox->setCurrentText(speedStr); + + connect(speedBox, TQT_SIGNAL(textChanged(const TQString&)), + this, TQT_SLOT(updateSpeed(const TQString&))); +} + +int SpeedDialog::getSpeed() const { + return speed; +} + +void SpeedDialog::updateSpeed(const TQString& text) { + speed = atoi(text.ascii()); +} + +#include "speeddialog.moc" diff --git a/src/speeddialog.h b/src/speeddialog.h new file mode 100644 index 0000000..66b4380 --- /dev/null +++ b/src/speeddialog.h @@ -0,0 +1,50 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef __SPEEDDIALOG_H +#define __SPEEDDIALOG_H + +#include + +/** + * A dialog used to select the update speed for a StatPopup. + */ +class SpeedDialog : public KDialogBase { + Q_OBJECT + + + public: + /** + * Constructor. + */ + SpeedDialog(int defaultSpeed, TQWidget* parent); + + /** + * Returns the speed currently selected in the dialog. + * This is valid after the dialog has closed. + */ + int getSpeed() const; + + private slots: + /** + * Updates the speed variable to reflect the latest changes in + * the speed combo box. + */ + virtual void updateSpeed(const TQString&); + + private: + int speed; + /**< The speed currently selected in the speed combo box. */ +}; + +#endif diff --git a/src/statdock.cpp b/src/statdock.cpp new file mode 100644 index 0000000..36d33cc --- /dev/null +++ b/src/statdock.cpp @@ -0,0 +1,270 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "statdock.h" +#include "statpopup.h" +#include + +const int StatDock::fillLines = 0; +const int StatDock::fillBars = 1; +const int StatDock::fillShaded = 2; + +const TQColor StatDock::colorGrid(120, 120, 120); +const TQColor StatDock::colorGridInactive(60, 60, 60); +const TQColor StatDock::colorLabel(255, 255, 255); +const TQColor StatDock::colorLabelInactive(125, 125, 125); +const TQColor StatDock::colorLower(255, 255, 255); +const TQColor StatDock::colorLowerInactive(125, 125, 125); +const TQColor StatDock::colorBlack(0, 0, 0); + +//#define DOCK_SIZE 24 +#define DOCK_SIZE width() +#define DOCK_SCALE (((float) 105)/((float) (DOCK_SIZE-1))) +#define SOFT_STEP 3 + +StatDock::StatDock(int whichDock, const TQString& useLabel, + StatPopup *parent, const char *name) : + KSystemTray(parent,name), + label(useLabel), + bufUpper(0), + bufLower(0), + pos(0) { + + bufUpper = new int[DOCK_SIZE]; + bufLower = new int[DOCK_SIZE]; + + // Initialise the stored readings. + for (i = 0; i < DOCK_SIZE; i++) + bufUpper[i] = bufLower[i] = 0; + + // Initialise the display. + parent->initDock(this, contextMenu(), whichDock); + setBackgroundColor(colorBlack); + resize(DOCK_SIZE, DOCK_SIZE); + show(); +} + +StatDock::~StatDock() { + delete[] bufUpper; + delete[] bufLower; +} + +void StatDock::resizeEvent ( TQResizeEvent * ) +{ + // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes + int* bufUpperOld; + int* bufLowerOld; + + bufUpperOld = bufUpper; + bufLowerOld = bufLower; + + bufUpper = new int[DOCK_SIZE]; + bufLower = new int[DOCK_SIZE]; + + // Re-initialise the stored readings. + for (i = 0; i < DOCK_SIZE; i++) + bufUpper[i] = bufLower[i] = 0; + + delete[] bufUpperOld; + delete[] bufLowerOld; + + repaint(); +} + +void StatDock::setGrid(bool set) { + grid = set; + repaint(); +} + +void StatDock::setActive(bool set) { + active = set; + repaint(); +} + +void StatDock::setSoft(bool set) { + soft = set; + repaint(); +} + +void StatDock::setSplit(bool set) { + split = set; + repaint(); +} + +void StatDock::setLabelled(bool set) { + labelled = set; + repaint(); +} + +void StatDock::setLabel(const TQString& set) { + label = set; + repaint(); +} + +void StatDock::setFill(int set) { + fill = set; + repaint(); +} + +void StatDock::setColor(const TQColor& set) { + colorUpper = set; + colorUpperInactive = colorUpper.dark(); + repaint(); +} + +void StatDock::clearHistory(void) { + for (i = 0; i < DOCK_SIZE; i++) + bufUpper[i] = bufLower[i] = 0; + repaint(); +} + +void StatDock::addPercentReading(int upper, int lower) { + // Rescale the readings to a measure in pixels. + upper = (int) (((float) upper) / DOCK_SCALE); + lower = (split ? (int) (((float) lower) / DOCK_SCALE) : 0); + + if (soft) { + // Do a bit of juggling to obtain a soft reading. + oldUpper = bufUpper[pos]; + oldLower = bufLower[pos]; + if(++pos >= DOCK_SIZE) + pos = 0; + + // Modify the upper reading. + if (upper > oldUpper + SOFT_STEP) + upper = oldUpper + SOFT_STEP; + else if (upper < oldUpper - SOFT_STEP) + upper = oldUpper - SOFT_STEP; + bufUpper[pos] = upper; + + // Modify the lower reading. + if (split) { + if (lower > oldLower + SOFT_STEP) + lower = oldLower + SOFT_STEP; + else if (lower < oldLower - SOFT_STEP) + lower = oldLower - SOFT_STEP; + } + bufLower[pos] = lower; + } else { + // Just a straight update. + if(++pos >= DOCK_SIZE) + pos = 0; + bufUpper[pos] = upper; + bufLower[pos] = lower; + } + + // Refresh the diagram. + repaint(); +} + +void StatDock::paintEvent(TQPaintEvent*) { + TQPainter p(this); + + // Start by drawing the grid. + if(grid) { + p.setPen((active) ? colorGrid : colorGridInactive); + for(i = (((DOCK_SIZE+1)/5)-1); i < (DOCK_SIZE-1); i=i+((DOCK_SIZE+1)/5)) { + p.drawLine(0, i, (DOCK_SIZE-1), i); + } + } + + if(fill == fillShaded) { + // Shaded + for(i = 0; i < DOCK_SIZE; i++) { + tmpPos = (pos + i + 1) % DOCK_SIZE; + for(j = 0; j <= bufUpper[tmpPos]; j++) { + if (bufUpper[tmpPos] == 0 || j == 0) + p.setPen(colorBlack); + else if (active) + p.setPen(colorUpper.dark((100 * bufUpper[tmpPos]) / j)); + else + p.setPen(colorUpper.dark((200 * bufUpper[tmpPos]) / j)); + + if(split) + p.drawPoint(i, DOCK_SIZE - 1 - j - bufLower[tmpPos]); + else + p.drawPoint(i, DOCK_SIZE - j); + } + + if(split) { + for(j = 0; j <= bufLower[tmpPos]; j++) { + if (bufLower[tmpPos] == 0 || j == 0) + p.setPen(colorBlack); + else if (active) + p.setPen(colorLower.dark((100 * bufLower[tmpPos]) / j)); + else + p.setPen(colorLower.dark((200 * bufLower[tmpPos]) / j)); + + p.drawPoint(i, (DOCK_SIZE-1) - j); + } + } + } + } else if (fill == fillBars) { + // Bars + if(split) { + // Draw the upper bars, then the lower to save on pen + // adjustments. + p.setPen(active ? colorUpper : colorUpperInactive); + for(i = 0; i < DOCK_SIZE; i++) { + tmpPos = (pos + i + 1) % DOCK_SIZE; + p.drawLine(i, DOCK_SIZE - 1 - bufUpper[tmpPos] - + bufLower[tmpPos], i, DOCK_SIZE - 1 - bufLower[tmpPos]); + } + p.setPen(active ? colorLower : colorLowerInactive); + for(i = 0; i < DOCK_SIZE; i++) { + tmpPos = (pos + i + 1) % DOCK_SIZE; + p.drawLine(i, DOCK_SIZE - 1 - bufLower[tmpPos], + i, DOCK_SIZE - 1); + } + } else { + p.setPen(active ? colorUpper : colorUpperInactive); + for(i = 0; i < DOCK_SIZE; i++) { + tmpPos = (pos + i + 1) % DOCK_SIZE; + p.drawLine(i, DOCK_SIZE - 1 - bufUpper[tmpPos], + i, DOCK_SIZE - 1); + } + } + } else { + // Lines + if(split) { + // Draw the upper line, then the lower to save on pen + // adjustments. + p.setPen(active ? colorUpper : colorUpperInactive); + for(i = 0; i < DOCK_SIZE; i++) { + tmpPos = (pos + i + 1) % DOCK_SIZE; + p.drawPoint(i, DOCK_SIZE - 1 - + bufUpper[tmpPos] - bufLower[tmpPos]); + } + p.setPen(active ? colorLower : colorLowerInactive); + for(i = 0; i < DOCK_SIZE; i++) { + tmpPos = (pos + i + 1) % DOCK_SIZE; + p.drawPoint(i, DOCK_SIZE - 1 - bufLower[tmpPos]); + } + } else { + p.setPen(active ? colorUpper : colorUpperInactive); + for(i = 0; i < DOCK_SIZE; i++) { + tmpPos = (pos + i + 1) % DOCK_SIZE; + p.drawPoint(i, DOCK_SIZE - 1 - bufUpper[tmpPos]); + } + } + } + + // Finally label the diagrams. + if(labelled) { + p.setFont(TQFont( "Helvetica", ((8*DOCK_SIZE)/24) )); + p.setPen((active) ? colorLabel : colorLabelInactive); + p.drawText(rect(), AlignLeft | AlignTop, label); + } +} + +#include "statdock.moc" diff --git a/src/statdock.h b/src/statdock.h new file mode 100644 index 0000000..1fb0552 --- /dev/null +++ b/src/statdock.h @@ -0,0 +1,164 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef __STATDOCK_H +#define __STATDOCK_H + +#include +#include + +class StatPopup; + +/** + * A system tray window that displays a recent history of readings. + * A single application might have many of these windows. + * + * Two simultaneous sets of readings are supported; these will be + * referred to as upper and lower readings. When diagram splitting is + * switched on, these readings will be displayed together on the diagram + * with the upper readings shown above the lower readings. When diagram + * splitting is switched off, only the upper readings will be displayed. + * + * The parent window of a StatDock must be a StatPopup, which provides + * all of the actions in this window's context menu. + */ +class StatDock : public KSystemTray { + Q_OBJECT + + +public: + /** + * Fill style constants. + */ + static const int fillLines; + static const int fillBars; + static const int fillShaded; + + /** + * Colour constants. + */ + static const TQColor colorGrid; + static const TQColor colorGridInactive; + static const TQColor colorLabel; + static const TQColor colorLabelInactive; + static const TQColor colorLower; + static const TQColor colorLowerInactive; + static const TQColor colorBlack; + +public: + /** + * Constructor and destructor. + * + * Note that the constructor will call parent->initDock(). + * + * Parameter whichDock must be 0 or 1 to specify whether this dock + * will become dock[0] or dock[1] in the given StatPopup parent. + * Parameter useLabel should contain the label that will be drawn on + * the diagram if labelling is enabled. + */ + StatDock(int whichDock, const TQString& useLabel, StatPopup *parent, + const char *name = 0); + ~StatDock(); + + /** + * Setting display options. + */ + void setGrid(bool); + void setActive(bool); + void setSoft(bool); + void setSplit(bool); + void setLabelled(bool); + void setLabel(const TQString&); + void setFill(int); + void setColor(const TQColor&); + +public slots: + /** + * Clear the history of recent readings. + * All readings will be reset to zero and the diagram will be + * updated. + */ + void clearHistory(); + + /** + * Add the given pair of readings as the most recent in our list. + * The diagram will be updated accordingly. + * + * Each argument should be a percentage between 0 and 100. + * The sum of both arguments must not exceed 100. + * + * If diagram splitting is switched off, the given lower reading + * will be ignored completely and 0 will be used instead. + * + * @param upper the upper reading in this pair. + * @param lower the lower reading in this pair. + */ + void addPercentReading(int upper, int lower); + +private: + /** + * Repaint this system tray window with a fresh diagram. + */ + void paintEvent(TQPaintEvent*); + +private: + /** + * Display options. + */ + bool grid; + /**< Should the grid be displayed behind the diagram? */ + bool active; + /**< Is this meter currently active? */ + bool soft; + /**< Are we artificially modifying the readings to produce a + soft curve? */ + bool split; + /**< Are we displaying both upper and lower readings? */ + bool labelled; + /**< Should this diagram be labelled? */ + TQString label; + /**< The specific label to draw on this diagram. */ + int fill; + /**< Specifies which of the predefined fill styles to use. */ + TQColor colorUpper; + /**< Colour for displaying the upper readings. */ + TQColor colorUpperInactive; + /**< Colour for displaying the upper readings whilst the diagram + is inactive. */ + + /** + * Stored readings. + */ + int* bufUpper; + /**< Stores our list of recent upper readings. + This list begins at index (pos + 1) as the earliest reading + and cycles around to index (pos) as the latest reading. */ + int* bufLower; + /**< Stores our list of recent lower readings. + This list begins at index (pos + 1) as the earliest reading + and cycles around to index (pos) as the latest reading. */ + int pos; + /**< The index in our arrays of the most recent reading. */ + + + /** + * Temporaries. + */ + int i, j, tmpPos, oldUpper, oldLower; + /**< Temporary variables used during computations. */ + +protected: + void resizeEvent ( TQResizeEvent * ); +}; + +#endif diff --git a/src/statpopup.cpp b/src/statpopup.cpp new file mode 100644 index 0000000..e8c3c8f --- /dev/null +++ b/src/statpopup.cpp @@ -0,0 +1,485 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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 "icontoggleaction.h" +#include "speeddialog.h" +#include "statdock.h" +#include "statpopup.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_SPEED 1000 +#define TEXT_EXPANSION_HORIZONTAL 10 +#define TEXT_EXPANSION_VERTICAL 3 + +const TQColor StatPopup::colorBorder(0, 0, 0); + +StatPopup::Reading::Reading() : + dock(0), + actColor(0) +{ } + +StatPopup::Reading::~Reading() +{ + delete actColor; + delete dock; +} + +void StatPopup::Reading::Init(int which, StatPopup* popup) +{ + char colorid[30]; + sprintf(colorid, "Color%d", which); + + color = popup->defaultDockColor(which); + color = popup->config->readColorEntry(colorid, &color); + actColor = new TDEAction(i18n("Color (%1)...").arg(popup->dockName(which)), + "color", 0, TQT_TQOBJECT(popup), TQT_SLOT(selectColor()), popup->coll, colorid); +} + + +StatPopup::StatPopup(bool useSupportSplit, TQWidget *parent, const char *name) : + TQWidget(parent, name, TQt::WStyle_Customize | TQt::WStyle_NoBorder | + TQt::WStyle_StaysOnTop | TQt::WDestructiveClose | TQt::WType_TopLevel), + supportSplit(useSupportSplit) { + // Window management. + KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); + + // TODO: Get all-desktops working, even after a hide/reshow. + //KWin::setOnAllDesktops(winId(), true); + + // Basic variable initialisation. + relX = relY = 0; + isDragged = closing = false; + + // Initialise the text contents of this pop-up. + fullReading = i18n("Inactive."); + resizeToText(); + + // Prepare for actions and the config file, but don't actually add + // any actions or read the configuration. + config = TDEGlobal::config(); + coll = new TDEActionCollection(this); + + // Set up a timer for our periodic updates. + timer = new TQTimer(this); + connect(timer, TQT_SIGNAL(timeout()), TQT_TQOBJECT(this), TQT_SLOT(takeReading())); +} + +StatPopup::~StatPopup() { +} + +void StatPopup::readPopupState() { + config->setGroup("Popup Options"); + + // Read the position. + int useX = config->readNumEntry("PopupX", 0); + int useY = config->readNumEntry("PopupY", 0); + if (useX || useY) + move(useX, useY); + + // Show the pop-up if appropriate. + if (config->readBoolEntry("PopupActive", false)) + show(); + else + hide(); +} + +void StatPopup::savePopupState() { + config->setGroup("Popup Options"); + config->writeEntry("PopupActive", isVisible()); + config->writeEntry("PopupX", x()); + config->writeEntry("PopupY", y()); + config->sync(); +} + +void StatPopup::initDock(StatDock* target, TDEPopupMenu* menu, int whichDock) { + // Initialise the menus. + actActive->plug(menu); + actClearHistory->plug(menu); + menu->insertSeparator(); + actSpeed->plug(menu); + if (supportSplit) + actSplit->plug(menu); + menu->insertSeparator(); + + insertCustomItems(menu); + + TDEPopupMenu* fillMenu = new TDEPopupMenu(menu); + actFillLines->plug(fillMenu); + actFillBars->plug(fillMenu); + actFillShaded->plug(fillMenu); + menu->insertItem(SmallIcon("style"), i18n("St&yle"), fillMenu); + + actSoft->plug(menu); + actLabelled->plug(menu); + actGrid->plug(menu); + r[whichDock].actColor->plug(menu); + menu->insertSeparator(); + menu->insertItem(SmallIcon("help"), i18n("&Help"), + (new KHelpMenu(0, TDEGlobal::instance()->aboutData(), false))->menu()); + + // Set up display properties for the dock. + target->setActive(actActive->isChecked()); + target->setSplit(isSplit()); + target->setFill(fillStyle); + target->setSoft(actSoft->isChecked()); + target->setLabelled(actLabelled->isChecked()); + target->setGrid(actGrid->isChecked()); + target->setColor(r[whichDock].color); + setCustomProperties(target); +} + +bool StatPopup::isActive() const { + return actActive->isChecked(); +} + +bool StatPopup::isSplit() const { + return (supportSplit ? actSplit->isChecked() : false); +} + +void StatPopup::setActive(bool set) { + if (set) + startUpdates(); + else + stopUpdates(); + + for (int i = 0; i < r.size(); i++) { + r[i].dock->setActive(set); + } + + config->setGroup("General Options"); + config->writeEntry("Active", set); + config->sync(); +} + +void StatPopup::clearHistory() { + for (int i = 0; i < r.size(); i++) { + r[i].dock->clearHistory(); + } +} + +void StatPopup::selectSpeed() { + SpeedDialog dlg(speed, firstDock()); + if (dlg.exec()) { + int newSpeed = dlg.getSpeed(); + if (newSpeed > 0) { + speed = newSpeed; + if (timer->isActive()) + timer->changeInterval(speed); + + config->setGroup("General Options"); + config->writeEntry("Speed", speed); + config->sync(); + } + } +} + +void StatPopup::setSplit(bool set) { + if (! supportSplit) + return; + + for (int i = 0; i < r.size(); i++) { + r[i].dock->setSplit(set); + } + + requestResize(); + + config->setGroup("General Options"); + config->writeEntry("Split", set); + config->sync(); +} + +void StatPopup::setFillLines() { + fillStyle = StatDock::fillLines; + + actFillLines->setChecked(true); + actFillBars->setChecked(false); + actFillShaded->setChecked(false); + + for (int i = 0; i < r.size(); i++) { + r[i].dock->setFill(StatDock::fillLines); + } + + config->setGroup("General Options"); + config->writeEntry("StyleID", StatDock::fillLines); + config->sync(); +} + +void StatPopup::setFillBars() { + fillStyle = StatDock::fillBars; + + actFillLines->setChecked(false); + actFillBars->setChecked(true); + actFillShaded->setChecked(false); + + for (int i = 0; i < r.size(); i++) { + r[i].dock->setFill(StatDock::fillBars); + } + + config->setGroup("General Options"); + config->writeEntry("StyleID", StatDock::fillBars); + config->sync(); +} + +void StatPopup::setFillShaded() { + fillStyle = StatDock::fillShaded; + + actFillLines->setChecked(false); + actFillBars->setChecked(false); + actFillShaded->setChecked(true); + + for (int i = 0; i < r.size(); i++) { + r[i].dock->setFill(StatDock::fillShaded); + } + + config->setGroup("General Options"); + config->writeEntry("StyleID", StatDock::fillShaded); + config->sync(); +} + +void StatPopup::setSoft(bool set) { + for (int i = 0; i < r.size(); i++) { + r[i].dock->setSoft(set); + } + + config->setGroup("General Options"); + config->writeEntry("Soft", set); + config->sync(); +} + +void StatPopup::setLabelled(bool set) { + for (int i = 0; i < r.size(); i++) { + r[i].dock->setLabelled(set); + } + + config->setGroup("General Options"); + config->writeEntry("Labelled", set); + config->sync(); +} + +void StatPopup::setGrid(bool set) { + for (int i = 0; i < r.size(); i++) { + r[i].dock->setGrid(set); + } + + config->setGroup("General Options"); + config->writeEntry("Grid", set); + config->sync(); +} + +void StatPopup::selectColor() { + // which color? + int whichDock; + if (sscanf(TQT_TQOBJECT(const_cast(sender()))->name(), "Color%d", &whichDock) != 1) + return; + if (whichDock < 0 || whichDock >= r.size()) + return; + + if (r[whichDock].dock) { + TQColor ans; + if (KColorDialog::getColor(ans, r[whichDock].color, firstDock()) == + TQDialog::Accepted) { + r[whichDock].color = ans; + r[whichDock].dock->setColor(ans); + + config->setGroup("General Options"); + TQString n; + n.sprintf("Color%d", whichDock); + config->writeEntry(n, ans); + config->sync(); + } + } +} + +StatDock* StatPopup::firstDock() { + return r.size() > 0 ? r[0].dock : 0; +} + +void StatPopup::startUpdates() { + takeReading(); + timer->start(speed); +} + +void StatPopup::stopUpdates() { + timer->stop(); + fullReading = i18n("Inactive."); +} + +void StatPopup::setupActions() { + config->setGroup("General Options"); + bool bVal; + + bVal = config->readBoolEntry("Active", true); + actActive = new TDEToggleAction(i18n("&Active"), 0, coll, "active"); + actActive->setChecked(bVal); + connect(actActive, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setActive(bool))); + + actClearHistory = new TDEAction(i18n("&Clear"), "edit-delete", 0, + TQT_TQOBJECT(this), TQT_SLOT(clearHistory()), coll, "clear"); + + speed = config->readNumEntry("Speed", DEFAULT_SPEED); + actSpeed = new TDEAction(i18n("&Speed..."), "speedarrow", 0, + TQT_TQOBJECT(this), TQT_SLOT(selectSpeed()), coll, "speed"); + + if (supportSplit) { + bVal = config->readBoolEntry("Split", true); + actSplit = new IconToggleAction(i18n("Sp&lit Graph"), "split", + i18n("Graph Sp&litting Enabled"), "spliton", 0, coll, "split"); + actSplit->setChecked(bVal); + connect(actSplit, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setSplit(bool))); + } + + fillStyle = config->readNumEntry("StyleID", StatDock::fillShaded); + actFillLines = new IconToggleAction(i18n("&Lines"), "lines", "lineson", 0, + TQT_TQOBJECT(this), TQT_SLOT(setFillLines()), coll, "filllines"); + actFillLines->setChecked(fillStyle == StatDock::fillLines); + actFillBars = new IconToggleAction(i18n("&Bars"), "bars", "barson", 0, + TQT_TQOBJECT(this), TQT_SLOT(setFillBars()), coll, "fillbars"); + actFillBars->setChecked(fillStyle == StatDock::fillBars); + actFillShaded = new IconToggleAction(i18n("&Shaded"), "shaded", "shadedon", + 0, TQT_TQOBJECT(this), TQT_SLOT(setFillShaded()), coll, "fillshaded"); + actFillShaded->setChecked(fillStyle == StatDock::fillShaded); + + bVal = config->readBoolEntry("Soft", false); + actSoft = new IconToggleAction(i18n("So&ft Curves"), "soft", + i18n("So&ft Curves Enabled"), "softon", 0, coll, "soft"); + actSoft->setChecked(bVal); + connect(actSoft, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setSoft(bool))); + + bVal = config->readBoolEntry("Labelled", true); + actLabelled= new IconToggleAction(i18n("Show &Labels"), "labels", + i18n("&Labels Enabled"), "labelson", 0, coll, "labelled"); + actLabelled->setChecked(bVal); + connect(actLabelled, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setLabelled(bool))); + + bVal = config->readBoolEntry("Grid", true); + actGrid = new IconToggleAction(i18n("Show &Grid"), "grid", + i18n("&Grid Enabled"), "gridon", 0, coll, "grid"); + actGrid->setChecked(bVal); + connect(actGrid, TQT_SIGNAL(toggled(bool)), TQT_TQOBJECT(this), TQT_SLOT(setGrid(bool))); + + setupCustomActions(); +} + +void StatPopup::paintEvent(TQPaintEvent*) { + TQPainter p(this); + + // Draw the border. + p.setPen(colorBorder); + p.drawLine(0, 0, width(), 0); + p.drawLine(0, 1, width(), 1); + p.drawLine(0, 2, 0, height()); + p.drawLine(1, 2, 1, height()); + p.drawLine(width() - 2, 2, width() - 2, height()); + p.drawLine(width() - 1, 2, width() - 1, height()); + p.drawLine(2, height() - 2, width() - 2, height() - 2); + p.drawLine(2, height() - 1, width() - 2, height() - 1); + + // Draw the text. + p.setFont(font()); + p.setPen(colorGroup().foreground()); + p.drawText(rect(), AlignHCenter | AlignVCenter, fullReading); +} + +void StatPopup::mousePressEvent(TQMouseEvent* e) { + if(e->button() == Qt::RightButton) { + // Hide the pop-up. + hide(); + } else { + // Begin a drag operation. + isDragged = true; + relX = e->x(); + relY = e->y(); + repaint(); + } +} + +void StatPopup::mouseMoveEvent(TQMouseEvent* e) { + // In the middle of a drag operation. + move(e->globalX() - relX, e->globalY() - relY); +} + +void StatPopup::mouseReleaseEvent(TQMouseEvent* e) { + // The end of a drag operation. + move(e->globalX() - relX, e->globalY() - relY); + isDragged = false; + repaint(); +} + +void StatPopup::closeEvent(TQCloseEvent* e) { + // We're about to close. Save the current state for the last time. + savePopupState(); + closing = true; + TQWidget::closeEvent(e); +} + +void StatPopup::hideEvent(TQHideEvent* e) { + // We're about to hide. Save the current state if we're not + // closing altogether. + if (! closing) + savePopupState(); + TQWidget::hideEvent(e); +} + +void StatPopup::showEvent(TQShowEvent* e) { + // Make sure we're up-to-date and properly resized. + if (isActive()) + takeReading(); + else + resizeToText(); + + // Window management - fix so a taskbar button doesn't appear + KWin::setState(winId(), NET::SkipTaskbar | NET::SkipPager); + + TQWidget::showEvent(e); +} + +void StatPopup::takeReading() { + takeReadingInternal(); + + for (int i = 0; i < r.size(); i++) { + r[i].dock->addPercentReading(r[i].upper, r[i].lower); + } + + if (isVisible()) { + // Only resize if the pop-up is visible; otherwise fullReading + // might be stale anyway so we'll do it when we show the pop-up. + if (resizeRequested) + resizeToText(); + + repaint(); + } +} + +void StatPopup::resizeToText() { + resizeRequested = false; + + TQSize size = fontMetrics().size(0, fullReading); + resize(size.width() + 2 * TEXT_EXPANSION_HORIZONTAL, + size.height() + 2 * TEXT_EXPANSION_VERTICAL); + repaint(); +} + +#include "statpopup.moc" diff --git a/src/statpopup.h b/src/statpopup.h new file mode 100644 index 0000000..1b158a6 --- /dev/null +++ b/src/statpopup.h @@ -0,0 +1,320 @@ + +/*************************************************************************** + * * + * KCPULoad and KNetLoad are copyright (c) 1999-2000, Markus Gustavsson * + * (c) 2002, Ben Burton * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef __STATPOPUP_H +#define __STATPOPUP_H + +#include +#include // sorry, TQValueVector::erase() does not call destructors + +class TDEAction; +class TDEActionCollection; +class TDEConfig; +class TDEPopupMenu; +class TDERadioAction; +class TDESelectAction; +class TDEToggleAction; +class TQTimer; +class StatDock; + +/** + * A small pop-up window that contains a continually updating display of + * statistics. + * + * This pop-up will be sticky and stay-on-top by default. + * + * Up to two windows docked in the system tray (of class StatDock) can + * be maintained by this pop-up. There should only be one StatPopup + * per application. + * + * Note that initDock() \e must be called when a system tray window is + * created, though it is generally called automatically from the StatDock + * constructor. + * + * Note also that the constructor for this class does \e not call + * setupActions(), readPopupState() or startUpdates(); these must all be + * called by other routines (such as subclass constructors), since they + * require either subclass initialisation or an existing system tray + * window. + */ +class StatPopup : public TQWidget { + Q_OBJECT + + +public: + /** + * Colour constants. + */ + static const TQColor colorBorder; + +public: + /** + * Constructors and destructors. + * + * This constructor will set the config variable but will not read + * any configuration information. See the general class notes also + * for a list of other routines this constructor will not call. + */ + StatPopup(bool useSupportSplit, TQWidget *parent = 0, const char *name = 0); + ~StatPopup(); + + /** + * Geometric pop-up state management. + */ + void readPopupState(); + void savePopupState(); + + /** + * Initialises the given system tray window and its context menu. + * + * All global application properties (i.e., properties held by this + * pop-up) will be propagated to the system tray window, and all + * global application actions will be added to the given menu. + * + * Parameter whichDock must be either 0 or 1 to specify whether the + * given system tray window will become window dock[0] or dock[1]. + * + * This routine \e must be called when a system tray window is first + * created, though in general this will be done automatically by the + * StatDock constructor. + */ + virtual void initDock(StatDock* target, TDEPopupMenu* menu, int whichDock); + + /** + * Is this application currently active (i.e., taking periodic + * readings and displaying them)? + */ + bool isActive() const; + + /** + * Are split diagrams currently enabled? + */ + bool isSplit() const; + + /** + * Returns the frequency of updates in milliseconds. + */ + int getSpeed() const; + +public slots: + /** + * Slots for menu items. + */ + void setActive(bool); + void clearHistory(); + void selectSpeed(); + void setSplit(bool); + void setFillLines(); + void setFillBars(); + void setFillShaded(); + void setSoft(bool); + void setLabelled(bool); + void setGrid(bool); + void selectColor(); + +protected: + /** + * Return a human-readable name and default diagram colour for each + * system tray window. + * The argument given will be either 0 or 1, referring to window + * dock[0] or dock[1] respectively. + */ + virtual TQString dockName(int which) const = 0; + virtual TQColor defaultDockColor(int which) const = 0; + + /** + * Take a fresh reading. Subclasses must override this routine. + * + * This routine must update the array upper. + * If split readings are enabled, it must also update the array lower. + * If this pop-up is visible, it must also update the string fullReading. + */ + virtual void takeReadingInternal() = 0; + + /** + * Sets up any actions specific to subclasses of StatPopup. + * The global configuration should be read at this point to set the + * initial states of these actions. + * + * This routine will be called during setupActions(). + */ + virtual void setupCustomActions() {} + + /** + * Inserts any menu items specific to subclasses of StatPopup into + * the given menu. If any items are inserted, a separator should + * be inserted after them. + * + * This routine will be called during initDock(). + */ + virtual void insertCustomItems(TDEPopupMenu*) {} + + /** + * Propagates any properties specific to subclasses of StatPopup to + * the given system tray window during its initialisation. + * + * This routine will be called during initDock(). + */ + virtual void setCustomProperties(StatDock*) {} + + /** + * Returns the first non-null pointer out of dock[0] and dock[1], or + * returns null if both these pointers are null. + */ + StatDock* firstDock(); + + /** + * Start and stop the periodic taking of readings. + */ + void startUpdates(); + void stopUpdates(); + + /** + * Set up the collection of appliation-wide actions. + * The global configuration will be read at this point to set the + * initial states of these actions. + */ + virtual void setupActions(); + + /** + * Request that this pop-up be resized at the next reading according + * to its text contents. The pop-up will be resized \e after the + * reading is taken. + */ + void requestResize(); + + /** + * Custom painting routine. + */ + void paintEvent(TQPaintEvent *); + + /** + * Overrides for dragging support. + */ + void mousePressEvent(TQMouseEvent *); + void mouseReleaseEvent(TQMouseEvent *); + void mouseMoveEvent(TQMouseEvent *); + + /** + * Overrides for saving the popup state. + */ + void closeEvent(TQCloseEvent *); + void hideEvent(TQHideEvent *); + void showEvent(TQShowEvent *); + +protected slots: + /** + * Take a fresh reading and update all visual elements accordingly. + */ + void takeReading(); + +protected: + /** + * Configuration and GUI elements. + */ + TDEConfig* config; + /**< The configuration for the underlying application. */ + + /** + * Contains the readings per CPU. + */ + struct Reading { + StatDock* dock; + /**< The system tray window maintained by this pop-up. + May be null. */ + int upper; + /**< The upper reading taken during the last reading. */ + int lower; + /**< The lower reading taken during the last reading. */ + TQColor color; + /**< The colour used in the system tray diagram. */ + TDEAction* actColor; + /**< The menu item to change the colour of this dock. */ + Reading(); + ~Reading(); + void Init(int which, StatPopup* popup); + }; + std::vector r; + /**< The readings maintained by this pop-up. */ + TDEActionCollection* coll; + /**< The collection of all application-level actions. */ + + TQString fullReading; + /**< A full string describing the last reading taken, + to be displayed in this pop-up. */ + +private: + /** + * Resize this pop-up according to its text contents (i.e., the + * variable fullReading). A little extra room will be added to + * accomodate potential minor variations in the text. + */ + void resizeToText(); + +private: + /** + * Update support. + */ + TQTimer* timer; + /**< The timer handling periodic updates. */ + int speed; + /**< The frequency of updates in milliseconds. */ + + /* + * Diagram support. + */ + int fillStyle; + /**< The fill style used in the system tray diagrams. */ + bool supportSplit; + /**< Does this application support split diagrams? */ + + /** + * Pop-up support. + */ + int relX; + /**< The X coordinate of this pop-up at the beginning of a drag + operation. */ + int relY; + /**< The Y coordinate of this pop-up at the beginning of a drag + operation. */ + bool isDragged; + /**< Are we in the middle of a drag operation? */ + bool closing; + /**< Have we received a close event? */ + bool resizeRequested; + /**< Has a pop-up resize been requested? */ + + /** + * Actions + */ + TDEToggleAction* actActive; + TDEAction* actClearHistory; + TDEAction* actSpeed; + TDEToggleAction* actSplit; + TDEToggleAction* actFillLines; + TDEToggleAction* actFillBars; + TDEToggleAction* actFillShaded; + TDEToggleAction* actSoft; + TDEToggleAction* actLabelled; + TDEToggleAction* actGrid; +}; + +inline int StatPopup::getSpeed() const { + return speed; +} + +inline void StatPopup::requestResize() { + resizeRequested = true; +} + +#endif diff --git a/subdirs b/subdirs index b45335c..2d613ae 100644 --- a/subdirs +++ b/subdirs @@ -1,2 +1,3 @@ doc +icons kcpuload -- cgit v1.2.1