summaryrefslogtreecommitdiffstats
path: root/mathemagics/optiondialog.cpp
blob: aac715e3a61c6386a558b69f1a3796b94820436b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <kapp.h>
#include <tdeconfig.h>
#include <tdelocale.h>

#include <tqlayout.h>
#include <tqcheckbox.h>
#include <tqhbox.h>
#include <tqvgroupbox.h>
#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqspinbox.h>

#include "optiondialog.h"

ConfigureDialog::ConfigureDialog(TQWidget *parent, char *name, bool modal)
	: KDialogBase(KDialogBase::TreeList, i18n("Configure"), Apply | Ok | Cancel, Ok, parent, name, modal)
{
	setHelp("mathemagics/index.html", TQString::null);

	TQFrame *DisplayPage = addPage(i18n("Display"));
	TQVBoxLayout *dBox = new TQVBoxLayout(DisplayPage, marginHint(), spacingHint());

	TQVGroupBox *numBox = new TQVGroupBox(i18n("Numbers"), DisplayPage);
	dBox->addWidget(numBox);

	TQHBox *pBox = new TQHBox(numBox);
	pBox->setSpacing(spacingHint());
	NumBoxLabel = new TQLabel(i18n("Display precision:"), pBox);
	PrecNumBox = new TQSpinBox(1, 30, 3, pBox);

	FixedCheckBox = new TQCheckBox(i18n("&Fixed precision"), numBox);
	ShowPeriodCheckBox = new TQCheckBox(i18n("Always &show decimal point"), numBox);

	TQHBox *sBox = new TQHBox(DisplayPage);
	dBox->addWidget(sBox);
	sBox->setSpacing(spacingHint());
	NumBoxLabel = new TQLabel(i18n("Visible stack levels:"), sBox);
	NumLevelsNumBox = new TQSpinBox(1, 40, 1, sBox);

	BeepBox = new TQCheckBox(i18n("&Beep on error"), DisplayPage);
	dBox->addWidget(BeepBox);

	TQFrame *HistoryPage = addPage(i18n("History"));
	TQVBoxLayout *histBox = new TQVBoxLayout(HistoryPage, marginHint(), spacingHint());

	TQHBoxLayout *hBox = new TQHBoxLayout(histBox, spacingHint());

	HistDepthBox = new TQSpinBox(0, 40, 5, HistoryPage);
	HistoryLabel = new TQLabel(HistDepthBox, i18n("History &depth:"), HistoryPage);
	hBox->addWidget(HistoryLabel);
	hBox->addWidget(HistDepthBox);

	ClearHistoryButton = new TQPushButton(i18n("C&lear History"), HistoryPage);
	connect(ClearHistoryButton, TQ_SIGNAL(clicked()), this, TQ_SIGNAL(clearHistory()));
	histBox->addWidget(ClearHistoryButton);
	histBox->addStretch();

	HistDetailCheckBox = new TQCheckBox(i18n("Show &base and angle"), HistoryPage);
	histBox->addWidget(HistDetailCheckBox);


	TQFrame *StackPage = addPage(i18n("Stack"));
	TQVBoxLayout *stackBox = new TQVBoxLayout(StackPage, marginHint(), spacingHint());

	SaveStackCheckBox = new TQCheckBox(i18n("&Save stack on quit"), StackPage);
	stackBox->addWidget(SaveStackCheckBox);

	DelDrops = new TQCheckBox(i18n("&Backspace drops on line-entry"), StackPage);
	stackBox->addWidget(DelDrops);

	connect(this, TQ_SIGNAL(cancelClicked()), this, TQ_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"