Source Code (Use browser search to find items of interest.)
Class Index
ktimemon'KConfDialog (./kdeutils/ktimemon/confdlg.h:47)
class KConfDialog : public QTabDialog {
Q_OBJECT
public:
KConfDialog(KTimeMon *timemon);
~KConfDialog() {}
void update(); // get values from timemon
unsigned getInterval() const { return intervalEdit->value(); }
QColor getKernelColour() const { return kernelCB->color(); }
QColor getUserColour() const { return userCB->color(); }
QColor getNiceColour() const { return niceCB->color(); }
QColor getCachedColour() const { return cachedCB->color(); }
QColor getUsedColour() const { return usedCB->color(); }
QColor getBuffersColour() const { return buffersCB->color(); }
QColor getSwapColour() const { return swapCB->color(); }
QColor getBgColour() const { return bgCB->color(); }
bool getAutoScale() const { return autoScaleBox->isChecked(); }
bool getToolTip() const { return toolTipBox->isChecked(); }
unsigned getPageScale() const { return pageScaleEdit->value(); }
unsigned getSwapScale() const { return swapScaleEdit->value(); }
unsigned getCtxScale() const { return ctxScaleEdit->value(); }
unsigned getMouseAction(int i) const { return mouseC[i]->currentItem(); }
const char *getMouseActionCommand(int i) const { return mouseLE[i]->text(); }
private slots:
void updateSampleWidget(const QColor &); // update colours in configuration
void toggle(bool state); // enable/disable scales
void mouseInteraction(int); // check mouse interaction
private:
KTimeMon *timemon;
KIntNumInput *intervalEdit, *swapScaleEdit, *pageScaleEdit, *ctxScaleEdit;
QLineEdit *procFileEdit;
QCheckBox *autoScaleBox, *toolTipBox;
KColorButton *kernelCB, *userCB, *niceCB;
KColorButton *buffersCB, *usedCB, *cachedCB;
KColorButton *swapCB, *bgCB;
KLineEdit *mouseLE[MAX_MOUSE_ACTIONS];
QComboBox *mouseC[MAX_MOUSE_ACTIONS];
KTimeMonWidget *sample;
bool haveWarned;
friend class KTimeMon;
};
ktimemon'KConfDialog::KConfDialog() (./kdeutils/ktimemon/confdlg.cc:32)
KConfDialog::KConfDialog(KTimeMon *t)
: timemon(t), haveWarned(false)
{
QWidget *w;
QBoxLayout *bl;
QGridLayout *gl;
QLabel *l;
QGroupBox *b;
KColorButton *cb;
unsigned i, j;
setCaption(i18n("KTimeMon Configuration"));
// first tab: general
w = new QWidget(this);
bl = new QVBoxLayout(w, 5);
b = new QVGroupBox(i18n("Sample &Rate:"), w);
bl->addWidget(b);
intervalEdit = new KIntNumInput(250, b);
intervalEdit->setRange(20, 1000, 10);
intervalEdit->setSuffix(i18n("ms"));
// scaling group box
b = new QVGroupBox(i18n("Scaling"), w);
bl->addWidget(b, 5);
autoScaleBox = new QCheckBox(i18n("&Automatic"), b);
connect(autoScaleBox, SIGNAL(toggled(bool)), this, SLOT(toggle(bool)));
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);
addTab(w, i18n("&General"));
// second tab: colours
w = new QWidget(this);
gl = new QGridLayout(w, 12, 10, 5);
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);
QString colourLabels[2][3];
colourLabels[0][0] = i18n("Kernel");
colourLabels[0][1] = i18n("User");
#if defined(__sun__)
colourLabels[0][2] = i18n("Wait");
#else
colourLabels[0][2] = i18n("Nice");
#endif
colourLabels[1][0] = i18n("Used");
colourLabels[1][1] = i18n("Buffers");
#if defined(__sun__) || defined(__osf__)
colourLabels[1][2] = i18n("Kernel");
#else
colourLabels[1][2] = i18n("Cached");
#endif
#
KColorButton **colourButtons[2][3] = { { &kernelCB, &userCB, &niceCB },
{ &usedCB, &buffersCB, &cachedCB }};
for (i = 0; i < 2; i++) {
b = new QGroupBox((i ? i18n("Memory/Swapping") : i18n("CPU/Paging")), w);
gl->addMultiCellWidget(b, 4*i, 4*i+2, 0, 9);
for (j = 0; j < 3; j++) {
l = new QLabel(colourLabels[i][j], w);
gl->addWidget(l, 4*i+1, 3*j+1, AlignVCenter | AlignRight);
cb = *colourButtons[i][j] = new KColorButton(white, w);
gl->addWidget(cb, 4*i+1, 3*j+2, AlignCenter);
connect(cb, SIGNAL(changed(const QColor &)),
this, SLOT(updateSampleWidget(const QColor &)));
}
}
b = new QGroupBox(i18n("Swap/Background"), w);
gl->addMultiCellWidget(b, 8, 10, 0, 6);
l = new QLabel(i18n("Swap"), w);
gl->addWidget(l, 9, 1, AlignVCenter | AlignRight);
cb = swapCB = new KColorButton(red, w);
gl->addWidget(cb, 9, 2);
connect(cb, SIGNAL(changed(const QColor &)),
this, SLOT(updateSampleWidget(const QColor &)));
l = new QLabel(i18n("Backgd"), w);
gl->addWidget(l, 9, 4, AlignVCenter | AlignRight);
cb = bgCB = new KColorButton(blue, w);
gl->addWidget(cb, 9, 5);
connect(cb, SIGNAL(changed(const QColor &)),
this, SLOT(updateSampleWidget(const QColor &)));
b = new QGroupBox(i18n("Sample"), w);
gl->addMultiCellWidget(b, 8, 10, 7, 9);
sample = new KTimeMonWidget(0, false, true, b);
sample->setGeometry(38, 25, 35, 35);
addTab(w, i18n("&Colors"));
// third tab: interaction
w = new QWidget(this);
addTab(w, i18n("&Interaction"));
bl = new QVBoxLayout(w, 5);
b = new QGroupBox(i18n("Mouse Events"), w);
bl->addWidget(b, 5);
gl = new QGridLayout(b, MAX_MOUSE_ACTIONS + 1, 3, 10);
for (i = 1; i < MAX_MOUSE_ACTIONS + 1; i++)
gl->setRowStretch(i, 1);
gl->setColStretch(2, 1);
QString buttonText[MAX_MOUSE_ACTIONS] = { i18n("Left button"),
i18n("Middle button"),
i18n("Right button") };
for (i = 0; i < (int) MAX_MOUSE_ACTIONS; i++) {
l = new QLabel(i18n(buttonText[i]), b);
gl->addWidget(l, i+1, 0);
mouseC[i] = new QComboBox(false, b);
mouseC[i]->insertItem(i18n("is ignored"), KTimeMon::NOTHING);
mouseC[i]->insertItem(i18n("switches mode"), KTimeMon::SWITCH);
mouseC[i]->insertItem(i18n("pops up menu"), KTimeMon::MENU);
mouseC[i]->insertItem(i18n("starts"), KTimeMon::COMMAND);
mouseC[i]->setCurrentItem(t->mouseAction[i]);
gl->addWidget(mouseC[i], i+1, 1);
connect(mouseC[i], SIGNAL(activated(int)), this,
SLOT(mouseInteraction(int)));
mouseLE[i] = new KLineEdit(b);
mouseLE[i]->setText(t->mouseActionCommand[i]);
gl->addWidget(mouseLE[i], i+1, 2);
}
gl->activate();
mouseInteraction(0); // update enable/disable etc
b = new QVGroupBox(i18n("Tool Tips"), w);
bl->addWidget(b, 5);
toolTipBox = new QCheckBox(i18n("Tool Tips enabled"), b);
bl->addStretch(1);
setApplyButton();
setCancelButton();
resize(380, 300);
connect(this, SIGNAL(applyButtonPressed()), timemon, SLOT(apply()));
}
// Adjust the colours of the sample widget in the configuration dialog.
ktimemon'KConfDialog::updateSampleWidget() (./kdeutils/ktimemon/confdlg.cc:218)
void KConfDialog::updateSampleWidget(const QColor &)
{
sample->kernelColour = kernelCB->color();
sample->userColour = userCB->color();
sample->niceColour = niceCB->color();
sample->cachedColour = cachedCB->color();
sample->usedColour = usedCB->color();
sample->buffersColour = buffersCB->color();
sample->swapColour = swapCB->color();
sample->bgColour = bgCB->color();
sample->update();
}
// -----------------------------------------------------------------------------
// enable/disable the scale widgets
ktimemon'KConfDialog::toggle() (./kdeutils/ktimemon/confdlg.cc:234)
void KConfDialog::toggle(bool state)
{
swapScaleEdit->setEnabled(!state);
pageScaleEdit->setEnabled(!state);
ctxScaleEdit->setEnabled(!state);
}
// -----------------------------------------------------------------------------
// Check for valid settings.
ktimemon'KConfDialog::mouseInteraction() (./kdeutils/ktimemon/confdlg.cc:245)
void KConfDialog::mouseInteraction(int)
{
int i;
bool menuOk = false;
for (i = 0; i < MAX_MOUSE_ACTIONS; i++) {
unsigned action = mouseC[i]->currentItem();
if (action == KTimeMon::MENU) menuOk = true;
mouseLE[i]->setEnabled(action == KTimeMon::COMMAND);
}
if (!menuOk && !haveWarned) {
KMessageBox::information(timemon, i18n("KTimeMon notice"),
i18n("You have set the configuration so that\n"
"the pop-up menu cannot be invoked by a\n"
"mouse click. This is probably not such a\n"
"good idea, because you will have to edit\n"
"the configuration options manually to get\n"
"rid of this setting..."));
haveWarned = true;
}
}
// -----------------------------------------------------------------------------
// update the dialog fields
ktimemon'KConfDialog::update() (./kdeutils/ktimemon/confdlg.cc:274)
void KConfDialog::update()
{
intervalEdit->setValue(timemon->interval);
kernelCB->setColor(timemon->kernelColour);
userCB->setColor(timemon->userColour);
niceCB->setColor(timemon->niceColour);
buffersCB->setColor(timemon->buffersColour);
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);
// toggle(timemon->autoScale);
toolTipBox->setChecked(timemon->tooltip);
updateSampleWidget(white); // fake colour
}