Commit 7a99108c authored by Chris Schlaeger's avatar Chris Schlaeger
Browse files

a lot more geometry management added; menues reworked (still going on); config management improved;

svn path=/trunk/kdeutils/ktop/; revision=17613
parent ec7a860f
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......@@ -65,6 +65,9 @@ FancyPlotter::resizeEvent(QResizeEvent*)
{
mmw = 0;
multiMeter->hide();
plotter->move(mmw + 15, 25);
plotter->resize(w - mmw - 30, h - 40);
}
else
{
......@@ -72,8 +75,7 @@ FancyPlotter::resizeEvent(QResizeEvent*)
multiMeter->show();
multiMeter->move(15, 25);
multiMeter->resize(mmw, h - 40);
plotter->move(mmw + 25, 25);
plotter->resize(w - mmw - 40, h - 40);
}
plotter->move(mmw + 25, 25);
plotter->resize(w - mmw - 40, h - 40);
}
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -8,7 +8,7 @@
nicknet@planete.net
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -8,7 +8,7 @@
nicknet@planete.net
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
/*
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@kde.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// $Id$
#include <assert.h>
#include <qstring.h>
#include <kapp.h>
#include <kstring.h>
#include "version.h"
#include "MainMenu.moc"
extern KApplication* Kapp;
MainMenu* MainMenuBar = 0;
MainMenu::MainMenu(QWidget* parent, const char* name) :
KMenuBar(parent, name)
{
assert(MainMenuBar == 0);
MainMenuBar = this;
// 'File' submenu
file = new QPopupMenu();
file->insertItem(i18n("Quit"), MENU_ID_QUIT, -1);
connect(file, SIGNAL(activated(int)), this, SLOT(handler(int)));
// 'Help' submenu
QString about;
ksprintf(&about, i18n("KDE Task Manager (KTop) Version %s\n\n"
"Copyright:\n"
"1996 : A. Sanda <alex@darkstar.ping.at>\n"
"1997 : Ralf Mueller <ralf@bj-ig.de>\n"
"1997-98 : Bernd Johannes Wuebben <wuebben@kde.org>\n"
"1998 : Nicolas Leclercq <nicknet@planete.net>\n"
"1999 : Chris Schlaeger <cs@kde.org>\n"),
KTOP_VERSION);
help = Kapp->getHelpMenu(true, about);
// 'Options' submenu
settings = new QPopupMenu();
settings->insertItem(i18n("StartUp Preferences..."),
MENU_ID_PROCSETTINGS, -1);
connect(settings, SIGNAL(activated(int)), this, SLOT(handler(int)));
// 'Refresh Rate' submenu
refresh = new QPopupMenu();
refresh->setCheckable(true);
refresh->insertItem(i18n("Manual Refresh"), MENU_ID_REFRESH_MANUAL, -1);
refresh->insertItem(i18n("Slow Refresh"), MENU_ID_REFRESH_SLOW, -1);
refresh->insertItem(i18n("Medium Refresh"), MENU_ID_REFRESH_MEDIUM, -1);
refresh->insertItem(i18n("Fast Refresh"), MENU_ID_REFRESH_FAST, -1);
connect(refresh, SIGNAL(activated(int)), this, SLOT(handler(int)));
// register submenues
setLineWidth(1);
insertItem(i18n("&File"), file, 2, -1);
insertItem(i18n("&Options"), settings, 3, -1);
insertItem(i18n("&Refresh Rate"), refresh, MENU_ID_MENU_REFRESH, -1);
insertSeparator(-1);
insertItem(i18n("&Help"), help, 2, -1);
}
void
MainMenu::handler(int id)
{
switch(id)
{
case MENU_ID_QUIT:
emit(quit());
break;
case MENU_ID_PROCSETTINGS:
// taskman->invokeSettings();
break;
case MENU_ID_REFRESH_MANUAL:
case MENU_ID_REFRESH_SLOW:
case MENU_ID_REFRESH_MEDIUM:
case MENU_ID_REFRESH_FAST:
emit(setRefreshRate(id - MENU_ID_REFRESH_MANUAL));
break;
default:
break;
}
}
void
MainMenu::checkRefreshRate(int rate)
{
// uncheck old and check new rate
for (int i = MENU_ID_REFRESH_MANUAL; i <= MENU_ID_REFRESH_FAST; i++)
refresh->setItemChecked(i, rate == i - MENU_ID_REFRESH_MANUAL);
}
/*
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@kde.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// $Id$
#ifndef _MainMenu_h_
#define _MainMenu_h_
#include <kmenubar.h>
class MainMenu : public KMenuBar
{
Q_OBJECT
public:
enum
{
MENU_ID_ABOUT = 100,
MENU_ID_PROCSETTINGS = 50,
MENU_ID_MENU_REFRESH,
MENU_ID_REFRESH_MANUAL,
MENU_ID_REFRESH_SLOW,
MENU_ID_REFRESH_MEDIUM,
MENU_ID_REFRESH_FAST,
MENU_ID_QUIT = 20,
MENU_ID_HELP = 30
};
MainMenu(QWidget* parent = 0, const char* name = 0);
~MainMenu()
{
delete file;
delete settings;
delete refresh;
delete help;
}
public slots:
void checkRefreshRate(int);
void enableRefreshMenu(bool enable)
{
setItemEnabled(MENU_ID_MENU_REFRESH, enable);
}
signals:
void quit(void);
void setRefreshRate(int);
private slots:
void handler(int);
private:
QPopupMenu* file;
QPopupMenu* settings;
QPopupMenu* refresh;
QPopupMenu* help;
} ;
extern MainMenu* MainMenuBar;
#endif
......@@ -24,7 +24,7 @@ SUBDIRS = doc pics
bin_PROGRAMS = ktop
# Which sources should be compiled for ktop.
ktop_SOURCES = ktop.cpp settings.cpp TaskMan.cpp \
ktop_SOURCES = ktop.cpp settings.cpp MainMenu.cpp TaskMan.cpp \
ProcListPage.cpp ProcTreePage.cpp IconList.cpp ProcessList.cpp \
ProcessTree.cpp OSProcessList.cpp OSProcess.cpp PerfMonPage.cpp \
FancyPlotter.cpp MultiMeter.cpp SignalPlotter.cpp OSStatus.cpp \
......@@ -39,13 +39,13 @@ ktop_LDFLAGS = $(all_libraries) $(KDE_RPATH)
ktop_LDADD = $(LIB_KFM) $(LIB_KDEUI)
# this option you can leave out. Just, if you use "make dist", you need it
noinst_HEADERS = ktop.h settings.h TaskMan.h ProcListPage.h\
noinst_HEADERS = ktop.h settings.h MainMenu.h TaskMan.h ProcListPage.h\
IconList.h ProcessList.h ProcessTree.h OSProcessList.h ProcTreePage.h \
PerfMonPage.h FancyPlotter.h MultiMeter.h SignalPlotter.h OSStatus.h \
ReniceDlg.h
# just to make sure, automake makes them
METASOURCES = ktop.moc settings.moc TaskMan.moc ProcListPage.moc ProcessList.moc ProcessTree.moc ProcTreePage.moc PerfMonPage.moc FancyPlotter.moc MultiMeter.moc SignalPlotter.moc ReniceDlg.moc
METASOURCES = ktop.moc settings.moc MainMenu.moc TaskMan.moc ProcListPage.moc ProcessList.moc ProcessTree.moc ProcTreePage.moc PerfMonPage.moc FancyPlotter.moc MultiMeter.moc SignalPlotter.moc ReniceDlg.moc
# make messages.po. Move this one to ../po/ and "make merge" in po
messages:
......
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -2,7 +2,7 @@
KTop, a taskmanager and cpu load monitor
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......@@ -81,7 +81,7 @@
#include "OSStatus.h"
// uncomment this line to fake SMP reporting on non SMP systems
//#define FAKE_SMP 1
// #define FAKE_SMP 1
#ifdef linux
......@@ -359,10 +359,11 @@ OSStatus::readCpuInfo(const char* cpu, int* u, int* s, int* n, int* i)
}
} while (strcmp(tag, cpu));
return (true);
#ifdef FAKE_SMP
#undef cpu
#endif
return (true);
}
bool
......
......@@ -2,7 +2,7 @@
KTop, the KDE Task Manager
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -8,7 +8,7 @@
nicknet@planete.net
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -8,7 +8,7 @@
nicknet@planete.net
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......
......@@ -8,7 +8,7 @@
nicknet@planete.net
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......@@ -53,7 +53,20 @@ ProcListPage::ProcListPage(QWidget* parent = 0, const char* name = 0)
box->setTitle(i18n("Running Processes"));
CHECK_PTR(box);
box->move(5, 5);
box->resize(380, 380);
// box->resize(380, 380);
/*
* Create the combo box to configure the process filter. The
* cbFilter must be created prior to constructing pList as the
* pList constructor sets cbFilter to its start value.
*/
cbFilter = new QComboBox(this,"pList_cbFilter");
CHECK_PTR(cbFilter);
cbFilter->insertItem(i18n("All processes"), 0);
cbFilter->insertItem(i18n("System processes"), 1);
cbFilter->insertItem(i18n("User processes"), 2);
cbFilter->insertItem(i18n("Own processes"), 3);
cbFilter->setMinimumSize(cbFilter->sizeHint());
// Create the table that lists the processes.
pList = new ProcessList(this, "pList");
......@@ -62,58 +75,42 @@ ProcListPage::ProcListPage(QWidget* parent = 0, const char* name = 0)
parent, SLOT(popupMenu(int, int)));
pList->move(10, 30);
pList->resize(370, 300);
// Create a combo box to configure the refresh rate.
cbRefresh = new QComboBox(this, "pList_cbRefresh");
CHECK_PTR(cbRefresh);
cbRefresh->insertItem(i18n("Refresh rate: Slow"),
(ProcessList::UPDATE_SLOW));
cbRefresh->insertItem(i18n("Refresh rate: Medium"),
(ProcessList::UPDATE_MEDIUM));
cbRefresh->insertItem(i18n("Refresh rate: Fast"),
(ProcessList::UPDATE_FAST));
cbRefresh->setCurrentItem(pList->getUpdateRate());
connect(cbRefresh, SIGNAL(activated(int)),
SLOT(cbRefreshActivated(int)));
// Create the combo box to configure the process filter.
cbFilter = new QComboBox(this,"pList_cbFilter");
CHECK_PTR(cbFilter);
cbFilter->insertItem(i18n("All processes"), -1);
cbFilter->insertItem(i18n("System processes"), -1);
cbFilter->insertItem(i18n("User processes"), -1);
cbFilter->insertItem(i18n("Own processes"), -1);
cbFilter->setCurrentItem(pList->getFilterMode());
/*
* When the both cbFilter and pList are constructed we can connect the
* missing link.
*/
connect(cbFilter, SIGNAL(activated(int)),
SLOT(cbProcessFilter(int)));
pList, SLOT(setFilterMode(int)));
// Create the 'Refresh Now' button.
bRefresh = new QPushButton(i18n("Refresh Now"), this, "pList_bRefresh");
CHECK_PTR(bRefresh);
connect(bRefresh, SIGNAL(clicked()), this, SLOT(update()));
bRefresh->setMinimumSize(bRefresh->sizeHint());
connect(bRefresh, SIGNAL(clicked()), pList, SLOT(update()));
// Create the 'Kill task' button.
bKill = new QPushButton(i18n("Kill task"), this, "pList_bKill");
CHECK_PTR(bKill);
bKill->setMinimumSize(bKill->sizeHint());
connect(bKill,SIGNAL(clicked()), this, SLOT(killTask()));
// restore refresh rate settings...
refreshRate = ProcessList::UPDATE_MEDIUM;
loadSetting(refreshRate, "pListUpdate");
cbRefresh->setCurrentItem(refreshRate);
pList->setUpdateRate(refreshRate);
gm = new QVBoxLayout(this, 10);
gm->addSpacing(15);
gm->addWidget(pList, 1);
// restore process filter settings...
int filter = pList->getFilterMode();
loadSetting(filter, "pListFilter");
cbFilter->setCurrentItem(filter);
pList->setFilterMode(filter);
gm1 = new QHBoxLayout();
gm->addLayout(gm1, 0);
gm1->addStretch();
gm1->addWidget(cbFilter);
gm1->addStretch();
gm1->addWidget(bRefresh);
gm1->addStretch();
gm1->addWidget(bKill);
gm1->addStretch();
gm->addSpacing(5);
// restore sort method for pList...
int sortby = pList->getSortColumn();
loadSetting(sortby, "pListSort");
pList->setSortColumn(sortby);
gm->activate();
// create process list
pList->update();
......@@ -122,50 +119,11 @@ ProcListPage::ProcListPage(QWidget* parent = 0, const char* name = 0)
void
ProcListPage::resizeEvent(QResizeEvent* ev)
{
QWidget::resizeEvent(ev);
box->setGeometry(5, 5, width() - 10, height() - 10);
int w = width();
int h = height();
box->setGeometry(5, 5, w - 10, h - 20);
pList->setGeometry(10,25, w - 20, h - 75);
cbRefresh->setGeometry(10, h - 45, 165, 25);
cbFilter->setGeometry(185, h - 45, 140, 25);
bRefresh->setGeometry(w - 200, h - 45, 90, 25);
bKill->setGeometry(w - 100, h - 45, 90, 25);
}
void
ProcListPage::saveSettings(void)
{
QString t;
/* save refresh rate */
Kapp->getConfig()->writeEntry("pListUpdate", t.setNum(refreshRate), TRUE);
/* save filter mode */
Kapp->getConfig()->writeEntry("pListFilter",
t.setNum(pList->getFilterMode()), TRUE);
/* save sort criterium */
Kapp->getConfig()->writeEntry("pListSort",
t.setNum(pList->getSortColumn()), TRUE);
}
void
ProcListPage::cbRefreshActivated(int indx)
{
refreshRate = indx;
pList->setUpdateRate(indx);
}
void
ProcListPage::cbProcessFilter(int indx)
{
pList->setFilterMode(indx);
pList->update();
QWidget::resizeEvent(ev);
// pList->setGeometry(box->x() + 7, box->y() + 16,
// box->width() - 14, box->height() - 23);
}
void
......
......@@ -8,7 +8,7 @@
nicknet@planete.net
Copyright (c) 1999 Chris Schlaeger
cs@axys.de
cs@kde.org
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
......@@ -33,6 +33,7 @@
#include <qwidget.h>
#include <qpushbutton.h>
#include <qcombobox.h>
#include <qlayout.h>
#include <kapp.h>
......@@ -57,9 +58,9 @@ public:
delete bKill;
delete bRefresh;
delete box;
delete cbRefresh;
delete cbFilter;
delete pList;
delete gm;
}
void resizeEvent(QResizeEvent*);
......@@ -74,39 +75,25 @@ public:
return (pList->setAutoUpdateMode(mode));
}
void saveSettings(void);
public slots:
void update()
void saveSettings(void)
{
pList->update();
pList->saveSettings();
}
void cbRefreshActivated(int);
void cbProcessFilter(int);
public slots:
void popupMenu(int, int);
void killTask();
void filterModeChanged(int filter)
{
cbFilter->setCurrentItem(filter);
}
signals:
void killProcess(int);
void setFilterMode(int);
private:
/**
* This function gets an int value from the config file. The value is
* specified with the tag string. If no value is found the 'val'
* cal-by-ref parameter is not changed.
*/
bool loadSetting(int& val, const char* tag)
{
QString tmpStr = Kapp->getConfig()->readEntry(tag);
bool res;
int tmpInt = tmpStr.toInt(&res);
if (res)
{