You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
296 lines
8.9 KiB
296 lines
8.9 KiB
15 years ago
|
/**********************************************************************/
|
||
|
/* TimeMon (c) 1994 Helmut Maierhofer */
|
||
|
/* KDE-ified M. Maierhofer 1998 */
|
||
|
/**********************************************************************/
|
||
|
|
||
|
/*
|
||
|
* confdlg.h
|
||
|
*
|
||
|
* Definitions for the timemon configuration dialog.
|
||
|
*/
|
||
|
|
||
|
#include <config.h>
|
||
|
#include <stdio.h>
|
||
15 years ago
|
#include <tqgroupbox.h>
|
||
|
#include <tqlineedit.h>
|
||
|
#include <tqslider.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqlabel.h>
|
||
|
#include <tqvgroupbox.h>
|
||
|
#include <tqcheckbox.h>
|
||
|
#include <tqcombobox.h>
|
||
15 years ago
|
|
||
|
#include <kcolorbutton.h>
|
||
|
#include <klineedit.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
|
#include <tdemessagebox.h>
|
||
15 years ago
|
#include <kurlrequester.h>
|
||
|
|
||
|
#include "confdlg.h"
|
||
|
#include "timemon.h"
|
||
|
|
||
|
// -- KConfDialog definition ---------------------------------------------
|
||
|
|
||
|
KConfDialog::KConfDialog(KTimeMon *t)
|
||
|
: KDialogBase( Tabbed, i18n("Configuration" ),
|
||
|
Ok|Cancel|Apply, Ok, t, 0, false ),
|
||
|
timemon(t)
|
||
|
{
|
||
15 years ago
|
TQFrame *page;
|
||
|
TQBoxLayout *bl;
|
||
|
TQGridLayout *gl;
|
||
|
TQLabel *l;
|
||
|
TQGroupBox *b;
|
||
15 years ago
|
KColorButton *cb;
|
||
|
unsigned i, j;
|
||
|
|
||
|
setIcon( SmallIcon( "ktimemon" ) );
|
||
|
|
||
|
// first tab: general
|
||
|
page = addPage( i18n( "&General" ) );
|
||
|
|
||
15 years ago
|
bl = new TQVBoxLayout(page, 0, spacingHint());
|
||
15 years ago
|
|
||
15 years ago
|
b = new TQVGroupBox(i18n("Sample &Rate"), page);
|
||
15 years ago
|
bl->addWidget(b);
|
||
|
|
||
|
intervalEdit = new KIntNumInput(250, b);
|
||
|
intervalEdit->setRange(20, 1000, 10);
|
||
|
intervalEdit->setSuffix(i18n(" msec"));
|
||
|
|
||
|
// scaling group box
|
||
15 years ago
|
b = new TQVGroupBox(i18n("Scaling"), page);
|
||
15 years ago
|
bl->addWidget(b);
|
||
|
|
||
|
bl->addStretch();
|
||
|
|
||
15 years ago
|
autoScaleBox = new TQCheckBox(i18n("&Automatic"), b);
|
||
|
connect(autoScaleBox, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(toggle(bool)));
|
||
15 years ago
|
|
||
|
pageScaleEdit = new KIntNumInput(intervalEdit, 1000, b);
|
||
|
pageScaleEdit->setRange(10, 10000, 10);
|
||
|
pageScaleEdit->setLabel(i18n("&Paging:"), AlignVCenter | AlignLeft);
|
||
|
|
||
|
swapScaleEdit = new KIntNumInput(pageScaleEdit, 1000, b);
|
||
|
swapScaleEdit->setRange(1, 10000, 5);
|
||
|
swapScaleEdit->setLabel(i18n("&Swapping:"), AlignVCenter | AlignLeft);
|
||
|
|
||
|
ctxScaleEdit = new KIntNumInput(swapScaleEdit, 10000, b);
|
||
|
ctxScaleEdit->setLabel(i18n("&Context switch:"), AlignVCenter | AlignLeft);
|
||
|
ctxScaleEdit->setRange(1, 10000, 30);
|
||
|
|
||
|
bl->addStretch(1);
|
||
|
|
||
|
// second tab: colours
|
||
|
page = addPage( i18n( "C&olors" ) );
|
||
|
|
||
15 years ago
|
gl = new TQGridLayout(page, 12, 10, 0, spacingHint());
|
||
15 years ago
|
|
||
|
gl->setColStretch(3, 1); gl->setColStretch(6, 1); // eat up horizontal space
|
||
|
gl->setRowStretch(11, 1); // eat up vertical space
|
||
|
|
||
|
gl->addRowSpacing(0, 20); gl->addRowSpacing(4, 20); gl->addRowSpacing(8, 20);
|
||
|
gl->addRowSpacing(2, 8); gl->addRowSpacing(6, 8); gl->addRowSpacing(10, 8);
|
||
|
|
||
|
gl->addColSpacing(0, 10); gl->addColSpacing(9, 25);
|
||
|
|
||
15 years ago
|
TQString cpuColourLabels[4];
|
||
15 years ago
|
cpuColourLabels[0] = i18n("Kernel:");
|
||
|
cpuColourLabels[1] = i18n("User:");
|
||
|
cpuColourLabels[2] = i18n("Nice:");
|
||
|
cpuColourLabels[3] = i18n("IOWait:");
|
||
|
|
||
15 years ago
|
TQString memColourLabels[4];
|
||
15 years ago
|
memColourLabels[0] = i18n("Kernel:");
|
||
|
memColourLabels[1] = i18n("Used:");
|
||
|
memColourLabels[2] = i18n("Buffers:");
|
||
|
memColourLabels[3] = i18n("Cached:");
|
||
|
|
||
|
KColorButton **cpuColourButtons[4] = { &kernelCB, &userCB, &niceCB, &iowaitCB };
|
||
15 years ago
|
b = new TQGroupBox(i18n("CPU"), page);
|
||
15 years ago
|
gl->addMultiCellWidget(b, 0, 2, 0, 13);
|
||
|
|
||
|
for (j = 0; j < 4; j++) {
|
||
15 years ago
|
l = new TQLabel(cpuColourLabels[j], page);
|
||
15 years ago
|
gl->addWidget(l, 1, 3*j+1, AlignVCenter | AlignRight);
|
||
|
|
||
|
cb = *cpuColourButtons[j] = new KColorButton(white, page);
|
||
|
gl->addWidget(cb, 1, 3*j+2, AlignCenter);
|
||
|
|
||
15 years ago
|
connect(cb, TQT_SIGNAL(changed(const TQColor &)),
|
||
|
this, TQT_SLOT(updateSampleWidget(const TQColor &)));
|
||
15 years ago
|
}
|
||
|
|
||
|
KColorButton **memColourButtons[4] = { &mkernelCB, &usedCB, &buffersCB, &cachedCB };
|
||
15 years ago
|
b = new TQGroupBox(i18n("Memory"), page);
|
||
15 years ago
|
gl->addMultiCellWidget(b, 4, 6, 0, 13);
|
||
|
|
||
|
for (j = 0; j < 4; j++) {
|
||
15 years ago
|
l = new TQLabel(memColourLabels[j], page);
|
||
15 years ago
|
gl->addWidget(l, 5, 3*j+1, AlignVCenter | AlignRight);
|
||
|
|
||
|
cb = *memColourButtons[j] = new KColorButton(white, page);
|
||
|
gl->addWidget(cb, 5, 3*j+2, AlignCenter);
|
||
|
|
||
15 years ago
|
connect(cb, TQT_SIGNAL(changed(const TQColor &)),
|
||
|
this, TQT_SLOT(updateSampleWidget(const TQColor &)));
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
b = new TQGroupBox(i18n("Swap"), page);
|
||
15 years ago
|
gl->addMultiCellWidget(b, 8, 10, 0, 6);
|
||
|
|
||
15 years ago
|
l = new TQLabel(i18n("Swap:"), page);
|
||
15 years ago
|
gl->addWidget(l, 9, 1, AlignVCenter | AlignRight);
|
||
|
|
||
|
cb = swapCB = new KColorButton(red, page);
|
||
|
gl->addWidget(cb, 9, 2);
|
||
|
|
||
15 years ago
|
connect(cb, TQT_SIGNAL(changed(const TQColor &)),
|
||
|
this, TQT_SLOT(updateSampleWidget(const TQColor &)));
|
||
15 years ago
|
|
||
15 years ago
|
l = new TQLabel(i18n("Backgd:"), page);
|
||
15 years ago
|
gl->addWidget(l, 9, 4, AlignVCenter | AlignRight);
|
||
|
|
||
|
cb = bgCB = new KColorButton(blue, page);
|
||
|
gl->addWidget(cb, 9, 5);
|
||
|
|
||
15 years ago
|
connect(cb, TQT_SIGNAL(changed(const TQColor &)),
|
||
|
this, TQT_SLOT(updateSampleWidget(const TQColor &)));
|
||
15 years ago
|
|
||
15 years ago
|
//b = new TQGroupBox(i18n("Sample"), page);
|
||
15 years ago
|
//gl->addMultiCellWidget(b, 8, 10, 7, 9);
|
||
|
|
||
|
// third tab: interaction
|
||
|
page = addPage( i18n( "&Interaction" ) );
|
||
|
|
||
15 years ago
|
bl = new TQVBoxLayout(page, 0, spacingHint());
|
||
15 years ago
|
|
||
15 years ago
|
b = new TQGroupBox(i18n("Mouse Events"), page);
|
||
15 years ago
|
b->setColumnLayout( 0, Qt::Vertical );
|
||
|
bl->addWidget(b);
|
||
|
bl->addStretch();
|
||
|
|
||
13 years ago
|
TQVBoxLayout *vbox = new TQVBoxLayout( b->layout() );
|
||
15 years ago
|
|
||
15 years ago
|
gl = new TQGridLayout(b, MAX_MOUSE_ACTIONS + 1, 3, 0, 6 );
|
||
15 years ago
|
|
||
|
vbox->addLayout( gl );
|
||
|
|
||
|
for (i = 1; i < MAX_MOUSE_ACTIONS + 1; i++)
|
||
|
gl->setRowStretch(i, 1);
|
||
|
gl->setColStretch(2, 1);
|
||
|
|
||
15 years ago
|
TQString buttonText[MAX_MOUSE_ACTIONS] = { i18n("Left button:"),
|
||
15 years ago
|
i18n("Middle button:"),
|
||
|
i18n("Right button:") };
|
||
|
|
||
|
for (i = 0; i < (int) MAX_MOUSE_ACTIONS; i++) {
|
||
|
|
||
15 years ago
|
l = new TQLabel(buttonText[i], b);
|
||
15 years ago
|
gl->addWidget(l, i+1, 0);
|
||
|
|
||
|
mouseC[i] = new KComboBox(false, b);
|
||
|
mouseC[i]->insertItem(i18n("Is Ignored"), KTimeMon::NOTHING);
|
||
|
// SWITCH doesn't DO anything. remove it from config dialog for now
|
||
|
// mouseC[i]->insertItem(i18n("Switches Mode"), KTimeMon::SWITCH);
|
||
|
mouseC[i]->insertItem(i18n("Pops Up Menu"), KTimeMon::MENU - 1);
|
||
|
mouseC[i]->insertItem(i18n("Starts"), KTimeMon::COMMAND - 1);
|
||
|
gl->addWidget(mouseC[i], i+1, 1);
|
||
|
|
||
15 years ago
|
connect( mouseC[ i ], TQT_SIGNAL( activated( int ) ), this,
|
||
|
TQT_SLOT( mouseCommandEnable() ) );
|
||
15 years ago
|
|
||
|
mouseLE[i] = new KURLRequester(b);
|
||
|
mouseLE[i]->lineEdit()->setText(t->mouseActionCommand[i]);
|
||
|
gl->addWidget(mouseLE[i], i+1, 2);
|
||
|
}
|
||
|
|
||
|
gl->activate();
|
||
|
|
||
|
resize(380, 300);
|
||
|
|
||
15 years ago
|
connect(this, TQT_SIGNAL(applyClicked()), timemon, TQT_SLOT(apply()));
|
||
|
connect(this, TQT_SIGNAL(okClicked()), timemon, TQT_SLOT(apply()));
|
||
15 years ago
|
}
|
||
|
|
||
|
// Adjust the colours of the sample widget in the configuration dialog.
|
||
15 years ago
|
void KConfDialog::updateSampleWidget(const TQColor &)
|
||
15 years ago
|
{
|
||
|
#if 0
|
||
|
sample->kernelColour = kernelCB->color();
|
||
|
sample->userColour = userCB->color();
|
||
|
sample->niceColour = niceCB->color();
|
||
|
sample->iowaitColour = iowaitCB->color();
|
||
|
sample->kernelColour = kernelCB->color();
|
||
|
sample->cachedColour = cachedCB->color();
|
||
|
sample->usedColour = usedCB->color();
|
||
|
sample->buffersColour = buffersCB->color();
|
||
|
sample->swapColour = swapCB->color();
|
||
|
sample->bgColour = bgCB->color();
|
||
|
sample->update();
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
// -----------------------------------------------------------------------------
|
||
|
|
||
|
// enable/disable the scale widgets
|
||
|
void KConfDialog::toggle(bool state)
|
||
|
{
|
||
|
swapScaleEdit->setEnabled(!state);
|
||
|
pageScaleEdit->setEnabled(!state);
|
||
|
ctxScaleEdit->setEnabled(!state);
|
||
|
}
|
||
|
|
||
|
void KConfDialog::mouseCommandEnable()
|
||
|
{
|
||
|
for ( int i = 0; i < MAX_MOUSE_ACTIONS; i++ ) {
|
||
|
unsigned action = mouseC[ i ]->currentItem();
|
||
|
|
||
|
// the - 1 is for compat with the no longer shown Switch option
|
||
|
mouseLE[ i ]->setEnabled( action == KTimeMon::COMMAND - 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// update the dialog fields
|
||
|
void KConfDialog::update()
|
||
|
{
|
||
|
intervalEdit->setValue(timemon->interval);
|
||
|
kernelCB->setColor(timemon->kernelColour);
|
||
|
userCB->setColor(timemon->userColour);
|
||
|
niceCB->setColor(timemon->niceColour);
|
||
|
iowaitCB->setColor(timemon->iowaitColour);
|
||
|
buffersCB->setColor(timemon->buffersColour);
|
||
|
mkernelCB->setColor(timemon->mkernelColour);
|
||
|
usedCB->setColor(timemon->usedColour);
|
||
|
cachedCB->setColor(timemon->cachedColour);
|
||
|
swapCB->setColor(timemon->swapColour);
|
||
|
bgCB->setColor(timemon->bgColour);
|
||
|
pageScaleEdit->setValue(timemon->pageScale);
|
||
|
swapScaleEdit->setValue(timemon->swapScale);
|
||
|
ctxScaleEdit->setValue(timemon->ctxScale);
|
||
|
autoScaleBox->setChecked(timemon->autoScale);
|
||
|
|
||
|
for ( int i = 0; i < MAX_MOUSE_ACTIONS; i++ )
|
||
|
{
|
||
|
int action = timemon->mouseAction[i];
|
||
|
if (action > 0)
|
||
|
--action; // compat for the no longer shown Switch action
|
||
|
mouseC[i]->setCurrentItem(action);
|
||
|
}
|
||
|
mouseCommandEnable();
|
||
|
|
||
|
updateSampleWidget(white); // fake colour
|
||
|
}
|
||
|
|
||
|
unsigned int KConfDialog::getMouseAction(int i) const
|
||
|
{
|
||
|
int action = mouseC[i]->currentItem();
|
||
|
|
||
|
if (action > 0)
|
||
|
++action; // compat for the no longer shown Switch action
|
||
|
|
||
|
return action;
|
||
|
}
|
||
|
|
||
|
#include "confdlg.moc"
|