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.
122 lines
4.1 KiB
122 lines
4.1 KiB
4 years ago
|
#include <kapp.h>
|
||
|
#include <kconfig.h>
|
||
|
#include <klocale.h>
|
||
|
|
||
|
#include <qlayout.h>
|
||
|
#include <qcheckbox.h>
|
||
|
#include <qhbox.h>
|
||
|
#include <qvgroupbox.h>
|
||
|
#include <qlabel.h>
|
||
|
#include <qpushbutton.h>
|
||
|
#include <qspinbox.h>
|
||
|
|
||
|
#include "optiondialog.h"
|
||
|
|
||
|
ConfigureDialog::ConfigureDialog(QWidget *parent, char *name, bool modal)
|
||
|
: KDialogBase(KDialogBase::TreeList, i18n("Configure"), Apply | Ok | Cancel, Ok, parent, name, modal)
|
||
|
{
|
||
|
setHelp("mathemagics/index.html", QString::null);
|
||
|
|
||
|
QFrame *DisplayPage = addPage(i18n("Display"));
|
||
|
QVBoxLayout *dBox = new QVBoxLayout(DisplayPage, marginHint(), spacingHint());
|
||
|
|
||
|
QVGroupBox *numBox = new QVGroupBox(i18n("Numbers"), DisplayPage);
|
||
|
dBox->addWidget(numBox);
|
||
|
|
||
|
QHBox *pBox = new QHBox(numBox);
|
||
|
pBox->setSpacing(spacingHint());
|
||
|
NumBoxLabel = new QLabel(i18n("Display precision:"), pBox);
|
||
|
PrecNumBox = new QSpinBox(1, 30, 3, pBox);
|
||
|
|
||
|
FixedCheckBox = new QCheckBox(i18n("&Fixed precision"), numBox);
|
||
|
ShowPeriodCheckBox = new QCheckBox(i18n("Always &show decimal point"), numBox);
|
||
|
|
||
|
QHBox *sBox = new QHBox(DisplayPage);
|
||
|
dBox->addWidget(sBox);
|
||
|
sBox->setSpacing(spacingHint());
|
||
|
NumBoxLabel = new QLabel(i18n("Visible stack levels:"), sBox);
|
||
|
NumLevelsNumBox = new QSpinBox(1, 40, 1, sBox);
|
||
|
|
||
|
BeepBox = new QCheckBox(i18n("&Beep on error"), DisplayPage);
|
||
|
dBox->addWidget(BeepBox);
|
||
|
|
||
|
QFrame *HistoryPage = addPage(i18n("History"));
|
||
|
QVBoxLayout *histBox = new QVBoxLayout(HistoryPage, marginHint(), spacingHint());
|
||
|
|
||
|
QHBoxLayout *hBox = new QHBoxLayout(histBox, spacingHint());
|
||
|
|
||
|
HistDepthBox = new QSpinBox(0, 40, 5, HistoryPage);
|
||
|
HistoryLabel = new QLabel(HistDepthBox, i18n("History &depth:"), HistoryPage);
|
||
|
hBox->addWidget(HistoryLabel);
|
||
|
hBox->addWidget(HistDepthBox);
|
||
|
|
||
|
ClearHistoryButton = new QPushButton(i18n("C&lear History"), HistoryPage);
|
||
|
connect(ClearHistoryButton, SIGNAL(clicked()), this, SIGNAL(clearHistory()));
|
||
|
histBox->addWidget(ClearHistoryButton);
|
||
|
histBox->addStretch();
|
||
|
|
||
|
HistDetailCheckBox = new QCheckBox(i18n("Show &base and angle"), HistoryPage);
|
||
|
histBox->addWidget(HistDetailCheckBox);
|
||
|
|
||
|
|
||
|
QFrame *StackPage = addPage(i18n("Stack"));
|
||
|
QVBoxLayout *stackBox = new QVBoxLayout(StackPage, marginHint(), spacingHint());
|
||
|
|
||
|
SaveStackCheckBox = new QCheckBox(i18n("&Save stack on quit"), StackPage);
|
||
|
stackBox->addWidget(SaveStackCheckBox);
|
||
|
|
||
|
DelDrops = new QCheckBox(i18n("&Backspace drops on line-entry"), StackPage);
|
||
|
stackBox->addWidget(DelDrops);
|
||
|
|
||
|
connect(this, SIGNAL(cancelClicked()), this, SLOT(readConfig()));
|
||
|
|
||
|
readConfig();
|
||
|
}
|
||
|
|
||
|
ConfigureDialog::~ConfigureDialog()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void ConfigureDialog::readConfig()
|
||
|
{
|
||
|
kapp->config()->setGroup("App");
|
||
|
PrecNumBox->setValue(kapp->config()->readNumEntry("formatPrec", 8));
|
||
|
NumLevelsNumBox->setValue(kapp->config()->readNumEntry("numStackLevels", 12));
|
||
|
BeepBox->setChecked(kapp->config()->readBoolEntry("beep", true));
|
||
|
HistDepthBox->setValue(kapp->config()->readNumEntry("histNum", 15));
|
||
|
ShowPeriodCheckBox->setChecked(kapp->config()->readBoolEntry("showPeriod", false));
|
||
|
FixedCheckBox->setChecked(kapp->config()->readBoolEntry("fixedPrec", false));
|
||
|
SaveStackCheckBox->setChecked(kapp->config()->readBoolEntry("saveStack", true));
|
||
|
DelDrops->setChecked(kapp->config()->readBoolEntry("delDrops", true));
|
||
|
HistDetailCheckBox->setChecked(kapp->config()->readBoolEntry("histDetail", false));
|
||
|
}
|
||
|
|
||
|
void ConfigureDialog::writeConfig()
|
||
|
{
|
||
|
kapp->config()->setGroup("App");
|
||
|
kapp->config()->writeEntry("formatPrec", PrecNumBox->value());
|
||
|
kapp->config()->writeEntry("numStackLevels", NumLevelsNumBox->value());
|
||
|
kapp->config()->writeEntry("beep", BeepBox->isChecked());
|
||
|
kapp->config()->writeEntry("histNum", HistDepthBox->value());
|
||
|
kapp->config()->writeEntry("showPeriod", ShowPeriodCheckBox->isChecked());
|
||
|
kapp->config()->writeEntry("fixedPrec", FixedCheckBox->isChecked());
|
||
|
kapp->config()->writeEntry("saveStack", SaveStackCheckBox->isChecked());
|
||
|
kapp->config()->writeEntry("delDrops", DelDrops->isChecked());
|
||
|
kapp->config()->writeEntry("histDetail", HistDetailCheckBox->isChecked());
|
||
|
}
|
||
|
|
||
|
void ConfigureDialog::slotOk()
|
||
|
{
|
||
|
slotApply();
|
||
|
accept();
|
||
|
}
|
||
|
|
||
|
void ConfigureDialog::slotApply()
|
||
|
{
|
||
|
writeConfig();
|
||
|
emit valueChanged();
|
||
|
}
|
||
|
|
||
|
#include "optiondialog.moc"
|
||
|
|