kspread

configdlg.cpp

00001 /*
00002 
00003  $Id: configdlg.cpp 466447 2005-10-02 17:54:10Z zander $
00004 
00005  KCalc
00006 
00007  Copyright (C) Bernd Johannes Wuebben
00008                wuebben@math.cornell.edu
00009            wuebben@kde.org
00010 
00011  This program is free software; you can redistribute it and/or
00012  modify it under the terms of the GNU General Public License
00013  as published by the Free Software Foundation; either version 2
00014  of the License, or (at your option) any later version.
00015 
00016  This program is distributed in the hope that it will be useful,
00017  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  GNU General Public License for more details.
00020 
00021  You should have received a copy of the GNU General Public License
00022  along with this program; if not, write to the Free Software
00023  Foundation, Inc., 51 Franklin Street, Fifth Floor,
00024  * Boston, MA 02110-1301, USA.
00025 
00026  */
00027 
00028 #include "configdlg.h"
00029 
00030 #include <klocale.h>
00031 #include <kdialog.h>
00032 #include <qlayout.h>
00033 
00034 // Undefine HAVE_LONG_DOUBLE for Beta 4 since RedHat 5.0 comes with a borken
00035 // glibc
00036 
00037 #ifdef HAVE_LONG_DOUBLE
00038 #undef HAVE_LONG_DOUBLE
00039 #endif
00040 
00041 ConfigDlg::ConfigDlg(QWidget *parent, const char *name, DefStruct *defstruct)
00042   : QDialog(parent, name)
00043 {
00044   defst = defstruct;
00045 
00046   QVBoxLayout *lay1 = new QVBoxLayout( this );
00047   lay1->setMargin( KDialog::marginHint() );
00048   lay1->setSpacing( KDialog::spacingHint() );
00049 
00050   box = new QGroupBox(0, Qt::Vertical, i18n("Defaults"), this, "box");
00051   box->layout()->setSpacing(KDialog::spacingHint());
00052   box->layout()->setMargin(KDialog::marginHint());
00053 
00054   QGridLayout *grid1 = new QGridLayout(box->layout(),8,2);
00055   label1 = new QLabel(box);
00056   label1->setText(i18n("Foreground color:"));
00057   grid1->addWidget(label1,0,0);
00058 
00059   button1 = new KColorButton( box, "button1" );
00060   grid1->addWidget(button1,0,1);
00061   button1->setColor( defst->forecolor );
00062 
00063   connect(button1 , SIGNAL( changed( const QColor & ) ),
00064              this, SLOT( set_fore_color( const QColor & ) ) );
00065 
00066   label2 = new QLabel(box);
00067   grid1->addWidget(label2,1,0);
00068   label2->setText(i18n("Background color:"));
00069 
00070   button2 = new KColorButton( box, "button2" );
00071   grid1->addWidget(button2,1,1);
00072   button2->setColor( defst->backcolor );
00073 
00074   connect(button2 , SIGNAL( changed( const QColor & ) ),
00075              this, SLOT( set_background_color( const QColor & ) ) );
00076 
00077 
00078   //  connect(button2,SIGNAL(clicked()),this,SLOT(set_background_color()));
00079 
00080 
00081   label5 = new QLabel(box);
00082   grid1->addWidget(label5,2,0);
00083   label5->setText(i18n("Precision:"));
00084 
00085   int maxprec;
00086 #ifdef HAVE_LONG_DOUBLE
00087   maxprec = 16 ;
00088 #else
00089   maxprec = 12 ;
00090 #endif
00091 
00092   precspin = new QSpinBox( box );
00093   precspin->setRange( 0, maxprec );
00094   grid1->addWidget(precspin,2,1);
00095 
00096   if( defst->precision <= maxprec)
00097     precspin->setValue(defst->precision);
00098   else
00099     precspin->setValue(maxprec);
00100 
00101 
00102   cb = new QCheckBox(box);
00103   grid1->addWidget(cb,3,0);
00104   cb->setText(i18n("Set fixed precision at:"));
00105   if(defst->fixed)
00106     cb->setChecked(true);
00107 
00108   int fixprec;
00109 #ifdef HAVE_LONG_DOUBLE
00110   fixprec = 14 ;
00111 #else
00112   fixprec = 10 ;
00113 #endif
00114 
00115   precspin2 = new QSpinBox( box );
00116   precspin2->setRange(0,fixprec);
00117   grid1->addWidget(precspin2,3,1);
00118 
00119   if( defst->fixedprecision <= fixprec)
00120     precspin2->setValue(defst->fixedprecision);
00121   else
00122     precspin2->setValue(fixprec);
00123 
00124 
00125 
00126   cb2 = new QCheckBox(box);
00127   grid1->addWidget(cb2,4,0);
00128   cb2->setText(i18n("Beep on error"));
00129   if(defst->beep)
00130     cb2->setChecked(true);
00131 
00132 
00133   stylegroup = new QButtonGroup(box,"stylegroup");
00134   grid1->addMultiCellWidget(stylegroup,5,7,0,1);
00135   stylegroup->setFrameStyle(QFrame::NoFrame);
00136 
00137   QGridLayout *grid2 = new QGridLayout(stylegroup,2,2,KDialog::marginHint(), KDialog::spacingHint());
00138 
00139   trigstyle = new QRadioButton(i18n("Trigonometry mode"),stylegroup,"trigstyle");
00140   grid2->addWidget(trigstyle,0,0);
00141   trigstyle->adjustSize();
00142   trigstyle->setChecked(defst->style == 0 );
00143 
00144   statstyle = new QRadioButton(i18n("Statistical mode"),stylegroup,"Stats");
00145   grid2->addWidget(statstyle,1,0);
00146   statstyle->adjustSize();
00147   statstyle->setChecked(defst->style == 1 );
00148 
00149   sheetstyle = new QRadioButton(i18n("Sheet mode"),stylegroup,"Sheet");
00150   grid2->addWidget(sheetstyle,2,0);
00151   sheetstyle->adjustSize();
00152 
00153   sheetstyle->setChecked(defst->style == 2 );
00154   button3 = new QPushButton(stylegroup);
00155   grid2->addWidget(button3,0,1);
00156   button3->setText(i18n("Help"));
00157 
00158   connect(button3,SIGNAL(clicked()),this,SLOT(help()));
00159 
00160   lay1->addWidget(box);
00161   connect(parent,SIGNAL(applyButtonPressed()),SLOT(okButton()));
00162 }
00163 
00164 void ConfigDlg::help()
00165 {
00166 }
00167 
00168 void ConfigDlg::okButton()
00169 {
00170   defst->precision = precspin->value();
00171   defst->fixedprecision = precspin2->value();
00172   defst->fixed = cb->isChecked();
00173   defst->beep = cb2->isChecked();
00174 
00175 
00176   if( trigstyle->isChecked())
00177     defst->style = 0;
00178   else if ( statstyle->isChecked() )
00179     defst->style = 1;
00180   else
00181     defst->style = 2;
00182 }
00183 
00184 void ConfigDlg::cancelbutton()
00185 {
00186   reject();
00187 }
00188 
00189 void ConfigDlg::set_fore_color(const QColor &_color)
00190 {
00191         defst->forecolor=_color;
00192 }
00193 
00194 void ConfigDlg::set_background_color( const QColor &_color )
00195 {
00196         defst->backcolor=_color;
00197 }
00198 
00199 #include "configdlg.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys