configdlg.cpp
1/*
2
3 $Id: configdlg.cpp 466447 2005-10-02 17:54:10Z zander $
4
5 KCalc
6
7 Copyright (C) Bernd Johannes Wuebben
8 wuebben@math.cornell.edu
9 wuebben@kde.org
10
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25
26 */
27
28#include "configdlg.h"
29
30#include <tdelocale.h>
31#include <kdialog.h>
32#include <tqlayout.h>
33
34// Undefine HAVE_LONG_DOUBLE for Beta 4 since RedHat 5.0 comes with a borken
35// glibc
36
37#ifdef HAVE_LONG_DOUBLE
38#undef HAVE_LONG_DOUBLE
39#endif
40
41ConfigDlg::ConfigDlg(TQWidget *parent, const char *name, DefStruct *defstruct)
42 : TQDialog(parent, name)
43{
44 defst = defstruct;
45
46 TQVBoxLayout *lay1 = new TQVBoxLayout( this );
47 lay1->setMargin( KDialog::marginHint() );
48 lay1->setSpacing( KDialog::spacingHint() );
49
50 box = new TQGroupBox(0, TQt::Vertical, i18n("Defaults"), this, "box");
51 box->layout()->setSpacing(KDialog::spacingHint());
52 box->layout()->setMargin(KDialog::marginHint());
53
54 TQGridLayout *grid1 = new TQGridLayout(box->layout(),8,2);
55 label1 = new TQLabel(box);
56 label1->setText(i18n("Foreground color:"));
57 grid1->addWidget(label1,0,0);
58
59 button1 = new KColorButton( box, "button1" );
60 grid1->addWidget(button1,0,1);
61 button1->setColor( defst->forecolor );
62
63 connect(button1 , TQ_SIGNAL( changed( const TQColor & ) ),
64 this, TQ_SLOT( set_fore_color( const TQColor & ) ) );
65
66 label2 = new TQLabel(box);
67 grid1->addWidget(label2,1,0);
68 label2->setText(i18n("Background color:"));
69
70 button2 = new KColorButton( box, "button2" );
71 grid1->addWidget(button2,1,1);
72 button2->setColor( defst->backcolor );
73
74 connect(button2 , TQ_SIGNAL( changed( const TQColor & ) ),
75 this, TQ_SLOT( set_background_color( const TQColor & ) ) );
76
77
78 // connect(button2,TQ_SIGNAL(clicked()),this,TQ_SLOT(set_background_color()));
79
80
81 label5 = new TQLabel(box);
82 grid1->addWidget(label5,2,0);
83 label5->setText(i18n("Precision:"));
84
85 int maxprec;
86#ifdef HAVE_LONG_DOUBLE
87 maxprec = 16 ;
88#else
89 maxprec = 12 ;
90#endif
91
92 precspin = new TQSpinBox( box );
93 precspin->setRange( 0, maxprec );
94 grid1->addWidget(precspin,2,1);
95
96 if( defst->precision <= maxprec)
97 precspin->setValue(defst->precision);
98 else
99 precspin->setValue(maxprec);
100
101
102 cb = new TQCheckBox(box);
103 grid1->addWidget(cb,3,0);
104 cb->setText(i18n("Set fixed precision at:"));
105 if(defst->fixed)
106 cb->setChecked(true);
107
108 int fixprec;
109#ifdef HAVE_LONG_DOUBLE
110 fixprec = 14 ;
111#else
112 fixprec = 10 ;
113#endif
114
115 precspin2 = new TQSpinBox( box );
116 precspin2->setRange(0,fixprec);
117 grid1->addWidget(precspin2,3,1);
118
119 if( defst->fixedprecision <= fixprec)
120 precspin2->setValue(defst->fixedprecision);
121 else
122 precspin2->setValue(fixprec);
123
124
125
126 cb2 = new TQCheckBox(box);
127 grid1->addWidget(cb2,4,0);
128 cb2->setText(i18n("Beep on error"));
129 if(defst->beep)
130 cb2->setChecked(true);
131
132
133 stylegroup = new TQButtonGroup(box,"stylegroup");
134 grid1->addMultiCellWidget(stylegroup,5,7,0,1);
135 stylegroup->setFrameStyle(TQFrame::NoFrame);
136
137 TQGridLayout *grid2 = new TQGridLayout(stylegroup,2,2,KDialog::marginHint(), KDialog::spacingHint());
138
139 trigstyle = new TQRadioButton(i18n("Trigonometry mode"),stylegroup,"trigstyle");
140 grid2->addWidget(trigstyle,0,0);
141 trigstyle->adjustSize();
142 trigstyle->setChecked(defst->style == 0 );
143
144 statstyle = new TQRadioButton(i18n("Statistical mode"),stylegroup,"Stats");
145 grid2->addWidget(statstyle,1,0);
146 statstyle->adjustSize();
147 statstyle->setChecked(defst->style == 1 );
148
149 sheetstyle = new TQRadioButton(i18n("Sheet mode"),stylegroup,"Sheet");
150 grid2->addWidget(sheetstyle,2,0);
151 sheetstyle->adjustSize();
152
153 sheetstyle->setChecked(defst->style == 2 );
154 button3 = new TQPushButton(stylegroup);
155 grid2->addWidget(button3,0,1);
156 button3->setText(i18n("Help"));
157
158 connect(button3,TQ_SIGNAL(clicked()),this,TQ_SLOT(help()));
159
160 lay1->addWidget(box);
161 connect(parent,TQ_SIGNAL(applyButtonPressed()),TQ_SLOT(okButton()));
162}
163
164void ConfigDlg::help()
165{
166}
167
168void ConfigDlg::okButton()
169{
170 defst->precision = precspin->value();
171 defst->fixedprecision = precspin2->value();
172 defst->fixed = cb->isChecked();
173 defst->beep = cb2->isChecked();
174
175
176 if( trigstyle->isChecked())
177 defst->style = 0;
178 else if ( statstyle->isChecked() )
179 defst->style = 1;
180 else
181 defst->style = 2;
182}
183
184void ConfigDlg::cancelbutton()
185{
186 reject();
187}
188
189void ConfigDlg::set_fore_color(const TQColor &_color)
190{
191 defst->forecolor=_color;
192}
193
194void ConfigDlg::set_background_color( const TQColor &_color )
195{
196 defst->backcolor=_color;
197}
198
199#include "configdlg.moc"