• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kcalc

  • sources
  • kde-4.14
  • kdeutils
  • kcalc
kcalc.cpp
Go to the documentation of this file.
1 /*
2 Copyright (C) 2001 - 2013 Evan Teran
3  evan.teran@gmail.com
4 
5 Copyright (C) 2006 Michel Marti
6  mma@objectxp.com
7 
8 Copyright (C) 1996 - 2000 Bernd Johannes Wuebben
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 as
13 published by the Free Software Foundation; either version 2 of
14 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, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "kcalc.h"
26 
27 #include <clocale>
28 
29 #include <QApplication>
30 #include <QCursor>
31 #include <QKeyEvent>
32 #include <QShortcut>
33 #include <QStyle>
34 
35 #include <kaboutdata.h>
36 #include <kacceleratormanager.h>
37 #include <kaction.h>
38 #include <kactioncollection.h>
39 #include <kapplication.h>
40 #include <kbuttongroup.h>
41 #include <kcmdlineargs.h>
42 #include <kcolorbutton.h>
43 #include <kcolormimedata.h>
44 #include <kconfig.h>
45 #include <kconfigdialog.h>
46 #include <kdialog.h>
47 #include <kglobal.h>
48 #include <kglobalsettings.h>
49 #include <kmenu.h>
50 #include <kmenubar.h>
51 #include <knumvalidator.h>
52 #include <kpushbutton.h>
53 #include <kstandardaction.h>
54 #include <kstatusbar.h>
55 #include <ktoggleaction.h>
56 #include <ktoolbar.h>
57 #include <kxmlguifactory.h>
58 
59 #include "kcalc_bitset.h"
60 #include "kcalc_const_menu.h"
61 #include "kcalc_settings.h"
62 #include "kcalcdisplay.h"
63 #include "version.h"
64 
65 namespace {
66 const char description[] = I18N_NOOP("KDE Calculator");
67 const char version[] = KCALCVERSION;
68 const int maxprecision = 1000;
69 }
70 
71 
72 //------------------------------------------------------------------------------
73 // Name: KCalculator
74 // Desc: constructor
75 //------------------------------------------------------------------------------
76 KCalculator::KCalculator(QWidget *parent) :
77  KXmlGuiWindow(parent),
78  shift_mode_(false),
79  hyp_mode_(false),
80  memory_num_(0.0),
81  constants_menu_(0),
82  constants_(0),
83  core() {
84 
85  // central widget to contain all the elements
86  QWidget *const central = new QWidget(this);
87  central->setLayoutDirection(Qt::LeftToRight);
88  setCentralWidget(central);
89  KAcceleratorManager::setNoAccel(central);
90 
91  // load science constants_ from xml-file
92  KCalcConstMenu::init_consts();
93 
94  // setup interface (order is critical)
95  setupUi(central);
96  setupMainActions();
97  setupStatusbar();
98  createGUI();
99  setupKeys();
100 
101  toolBar()->hide(); // hide by default
102 
103  // create button groups
104  base_choose_group_ = new QButtonGroup(this);
105  base_choose_group_->setExclusive(true);
106  base_choose_group_->addButton(hexRadio, HexMode);
107  base_choose_group_->addButton(decRadio, DecMode);
108  base_choose_group_->addButton(octRadio, OctMode);
109  base_choose_group_->addButton(binRadio, BinMode);
110  connect(base_choose_group_, SIGNAL(buttonClicked(int)),
111  SLOT(slotBaseSelected(int)));
112 
113  angle_choose_group_ = new QButtonGroup(this);
114  angle_choose_group_->setExclusive(true);
115  angle_choose_group_->addButton(degRadio, DegMode);
116  angle_choose_group_->addButton(radRadio, RadMode);
117  angle_choose_group_->addButton(gradRadio, GradMode);
118  connect(angle_choose_group_, SIGNAL(buttonClicked(int)),
119  SLOT(slotAngleSelected(int)));
120 
121  // additional menu setup
122  constants_menu_ = createConstantsMenu();
123  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
124 
125  // misc setup
126  setColors();
127  setFonts();
128 
129  // Show the result in the app's caption in taskbar (wishlist - bug #52858)
130  if (KCalcSettings::captionResult() == true) {
131  connect(calc_display, SIGNAL(changedText(QString)), SLOT(setCaption(QString)));
132  }
133 
134  calc_display->changeSettings();
135  setPrecision();
136 
137  updateGeometry();
138 
139  setFixedSize(minimumSize());
140 
141  updateDisplay(UPDATE_FROM_CORE);
142 
143  // misc settings
144  KCalcSettings::EnumCalculatorMode::type calculatorMode = KCalcSettings::calculatorMode();
145 
146  switch (calculatorMode) {
147  case KCalcSettings::EnumCalculatorMode::science:
148  action_mode_science_->setChecked(true);
149  break;
150  case KCalcSettings::EnumCalculatorMode::statistics:
151  action_mode_statistic_->setChecked(true);
152  break;
153  case KCalcSettings::EnumCalculatorMode::numeral:
154  action_mode_numeral_->setChecked(true);
155  break;
156  case KCalcSettings::EnumCalculatorMode::simple:
157  default:
158  action_mode_simple_->setChecked(true);
159  }
160 
161  setAngle();
162  setBase();
163 
164  // connections
165  connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), SLOT(setColors()));
166  connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()), SLOT(setFonts()));
167 
168  calc_display->setFocus();
169 }
170 
171 //------------------------------------------------------------------------------
172 // Name: ~KCalculator
173 // Desc: deconstructor
174 //------------------------------------------------------------------------------
175 KCalculator::~KCalculator() {
176 
177  KCalcSettings::self()->writeConfig();
178 }
179 
180 //------------------------------------------------------------------------------
181 // Name: setupMainActions
182 // Desc: connects all of the basic actions
183 //------------------------------------------------------------------------------
184 void KCalculator::setupMainActions() {
185 
186  // file menu
187  KStandardAction::quit(this, SLOT(close()), actionCollection());
188 
189  // edit menu
190  KStandardAction::undo(calc_display, SLOT(slotHistoryBack()), actionCollection());
191  KStandardAction::redo(calc_display, SLOT(slotHistoryForward()), actionCollection());
192  KStandardAction::cut(calc_display, SLOT(slotCut()), actionCollection());
193  KStandardAction::copy(calc_display, SLOT(slotCopy()), actionCollection());
194  KStandardAction::paste(calc_display, SLOT(slotPaste()), actionCollection());
195 
196  // mode menu
197  QActionGroup *modeGroup = new QActionGroup(this);
198 
199  action_mode_simple_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_simple"));
200  action_mode_simple_->setActionGroup(modeGroup);
201  action_mode_simple_->setText(i18n("Simple Mode"));
202  connect(action_mode_simple_, SIGNAL(toggled(bool)), SLOT(slotSetSimpleMode()));
203 
204  action_mode_science_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_science"));
205  action_mode_science_->setActionGroup(modeGroup);
206  action_mode_science_->setText(i18n("Science Mode"));
207  connect(action_mode_science_, SIGNAL(toggled(bool)), SLOT(slotSetScienceMode()));
208 
209  action_mode_statistic_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_statistics"));
210  action_mode_statistic_->setActionGroup(modeGroup);
211  action_mode_statistic_->setText(i18n("Statistic Mode"));
212  connect(action_mode_statistic_, SIGNAL(toggled(bool)), SLOT(slotSetStatisticMode()));
213 
214  action_mode_numeral_ = actionCollection()->add<KToggleAction>(QLatin1String("mode_numeral"));
215  action_mode_numeral_->setActionGroup(modeGroup);
216  action_mode_numeral_->setText(i18n("Numeral System Mode"));
217  connect(action_mode_numeral_, SIGNAL(toggled(bool)), SLOT(slotSetNumeralMode()));
218 
219  // settings menu
220  action_constants_show_ = actionCollection()->add<KToggleAction>(QLatin1String("show_constants"));
221  action_constants_show_->setText(i18n("Constants &Buttons"));
222  action_constants_show_->setChecked(true);
223  connect(action_constants_show_, SIGNAL(toggled(bool)), SLOT(slotConstantsShow(bool)));
224 
225  action_bitset_show_ = actionCollection()->add<KToggleAction>(QLatin1String("show_bitset"));
226  action_bitset_show_->setText(i18n("Show B&it Edit"));
227  action_bitset_show_->setChecked(true);
228  connect(action_bitset_show_, SIGNAL(toggled(bool)), SLOT(slotBitsetshow(bool)));
229 
230  KStandardAction::preferences(this, SLOT(showSettings()), actionCollection());
231  KStandardAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection());
232 }
233 
234 //------------------------------------------------------------------------------
235 // Name: createConstantsMenu
236 // Desc: creates and returns a pointer to the constant menu
237 //------------------------------------------------------------------------------
238 KCalcConstMenu *KCalculator::createConstantsMenu() {
239 
240  KCalcConstMenu *const menu = new KCalcConstMenu(i18n("&Constants"), this);
241  connect(menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotConstantToDisplay(science_constant)));
242  return menu;
243 }
244 
245 //------------------------------------------------------------------------------
246 // Name: setupStatusbar
247 // Desc: sets up the status bar with default text
248 //------------------------------------------------------------------------------
249 void KCalculator::setupStatusbar() {
250 
251  // Status bar contents
252  statusBar()->insertPermanentFixedItem(QLatin1String(" NORM "), ShiftField);
253  statusBar()->setItemAlignment(ShiftField, Qt::AlignCenter);
254 
255  statusBar()->insertPermanentFixedItem(QLatin1String(" HEX "), BaseField);
256  statusBar()->setItemAlignment(BaseField, Qt::AlignCenter);
257 
258  statusBar()->insertPermanentFixedItem(QLatin1String(" DEG "), AngleField);
259  statusBar()->setItemAlignment(AngleField, Qt::AlignCenter);
260 
261  statusBar()->insertPermanentFixedItem(QLatin1String(" \xa0\xa0 "), MemField); // nbsp
262  statusBar()->setItemAlignment(MemField, Qt::AlignCenter);
263 }
264 
265 //------------------------------------------------------------------------------
266 // Name: setupNumberKeys
267 // Desc: sets up number keys and related shortcuts
268 //------------------------------------------------------------------------------
269 void KCalculator::setupNumberKeys() {
270 
271  num_button_group_ = new QButtonGroup(this);
272  connect(num_button_group_, SIGNAL(buttonClicked(int)), SLOT(slotNumberclicked(int)));
273 
274  num_button_group_->addButton(pb0, 0);
275  num_button_group_->addButton(pb1, 1);
276  num_button_group_->addButton(pb2, 2);
277  num_button_group_->addButton(pb3, 3);
278  num_button_group_->addButton(pb4, 4);
279  num_button_group_->addButton(pb5, 5);
280  num_button_group_->addButton(pb6, 6);
281  num_button_group_->addButton(pb7, 7);
282  num_button_group_->addButton(pb8, 8);
283  num_button_group_->addButton(pb9, 9);
284  num_button_group_->addButton(pbA, 0xA);
285  num_button_group_->addButton(pbB, 0xB);
286  num_button_group_->addButton(pbC, 0xC);
287  num_button_group_->addButton(pbD, 0xD);
288  num_button_group_->addButton(pbE, 0xE);
289  num_button_group_->addButton(pbF, 0xF);
290  connect(this, SIGNAL(switchShowAccels(bool)), pb0, SLOT(slotSetAccelDisplayMode(bool)));
291  connect(this, SIGNAL(switchShowAccels(bool)), pb1, SLOT(slotSetAccelDisplayMode(bool)));
292  connect(this, SIGNAL(switchShowAccels(bool)), pb2, SLOT(slotSetAccelDisplayMode(bool)));
293  connect(this, SIGNAL(switchShowAccels(bool)), pb3, SLOT(slotSetAccelDisplayMode(bool)));
294  connect(this, SIGNAL(switchShowAccels(bool)), pb4, SLOT(slotSetAccelDisplayMode(bool)));
295  connect(this, SIGNAL(switchShowAccels(bool)), pb5, SLOT(slotSetAccelDisplayMode(bool)));
296  connect(this, SIGNAL(switchShowAccels(bool)), pb6, SLOT(slotSetAccelDisplayMode(bool)));
297  connect(this, SIGNAL(switchShowAccels(bool)), pb7, SLOT(slotSetAccelDisplayMode(bool)));
298  connect(this, SIGNAL(switchShowAccels(bool)), pb8, SLOT(slotSetAccelDisplayMode(bool)));
299  connect(this, SIGNAL(switchShowAccels(bool)), pb9, SLOT(slotSetAccelDisplayMode(bool)));
300  connect(this, SIGNAL(switchShowAccels(bool)), pbA, SLOT(slotSetAccelDisplayMode(bool)));
301  connect(this, SIGNAL(switchShowAccels(bool)), pbB, SLOT(slotSetAccelDisplayMode(bool)));
302  connect(this, SIGNAL(switchShowAccels(bool)), pbC, SLOT(slotSetAccelDisplayMode(bool)));
303  connect(this, SIGNAL(switchShowAccels(bool)), pbD, SLOT(slotSetAccelDisplayMode(bool)));
304  connect(this, SIGNAL(switchShowAccels(bool)), pbE, SLOT(slotSetAccelDisplayMode(bool)));
305  connect(this, SIGNAL(switchShowAccels(bool)), pbF, SLOT(slotSetAccelDisplayMode(bool)));
306 }
307 
308 //------------------------------------------------------------------------------
309 // Name: setupRightKeypad
310 // Desc: sets up right keypad keys and related shortcuts
311 //------------------------------------------------------------------------------
312 void KCalculator::setupRightKeypad() {
313 
314  connect(pbShift, SIGNAL(toggled(bool)), SLOT(slotShifttoggled(bool)));
315  connect(this, SIGNAL(switchShowAccels(bool)), pbShift, SLOT(slotSetAccelDisplayMode(bool)));
316 
317  pbBackspace->setShortcut(QKeySequence(Qt::Key_Backspace));
318  new QShortcut(Qt::Key_PageUp, pbBackspace, SLOT(animateClick()));
319  connect(pbBackspace, SIGNAL(clicked()), SLOT(slotBackspaceclicked()));
320  connect(this, SIGNAL(switchShowAccels(bool)), pbBackspace, SLOT(slotSetAccelDisplayMode(bool)));
321 
322  pbClear->setShortcut(QKeySequence(Qt::Key_Escape));
323  new QShortcut(Qt::Key_PageUp, pbClear, SLOT(animateClick()));
324  connect(pbClear, SIGNAL(clicked()), SLOT(slotClearclicked()));
325  connect(this, SIGNAL(switchShowAccels(bool)), pbClear, SLOT(slotSetAccelDisplayMode(bool)));
326 
327  pbAllClear->setShortcut(QKeySequence(Qt::Key_Delete));
328  new QShortcut(Qt::Key_PageDown, pbAllClear, SLOT(animateClick()));
329  connect(pbAllClear, SIGNAL(clicked()), SLOT(slotAllClearclicked()));
330  connect(this, SIGNAL(switchShowAccels(bool)), pbAllClear, SLOT(slotSetAccelDisplayMode(bool)));
331 
332  pbParenOpen->setShortcut(QKeySequence(Qt::Key_ParenLeft));
333  connect(pbParenOpen, SIGNAL(clicked()), SLOT(slotParenOpenclicked()));
334  connect(this, SIGNAL(switchShowAccels(bool)), pbParenOpen, SLOT(slotSetAccelDisplayMode(bool)));
335 
336  pbParenClose->setShortcut(QKeySequence(Qt::Key_ParenRight));
337  connect(pbParenClose, SIGNAL(clicked()), SLOT(slotParenCloseclicked()));
338  connect(this, SIGNAL(switchShowAccels(bool)), pbParenClose, SLOT(slotSetAccelDisplayMode(bool)));
339 
340  pbMemRecall->setDisabled(true); // nothing in memory at start
341  connect(pbMemRecall, SIGNAL(clicked()), SLOT(slotMemRecallclicked()));
342  connect(this, SIGNAL(switchShowAccels(bool)), pbMemRecall, SLOT(slotSetAccelDisplayMode(bool)));
343 
344  connect(pbMemClear, SIGNAL(clicked()), SLOT(slotMemClearclicked()));
345  connect(this, SIGNAL(switchShowAccels(bool)), pbMemClear, SLOT(slotSetAccelDisplayMode(bool)));
346 
347  pbMemPlusMinus->addMode(ModeNormal, i18nc("Add display to memory", "M+"), i18n("Add display to memory"));
348  pbMemPlusMinus->addMode(ModeShift, i18nc("Subtract from memory", "M\xe2\x88\x92"), i18n("Subtract from memory"));
349  connect(pbMemPlusMinus, SIGNAL(clicked()), SLOT(slotMemPlusMinusclicked()));
350  connect(this, SIGNAL(switchShowAccels(bool)), pbMemPlusMinus, SLOT(slotSetAccelDisplayMode(bool)));
351  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbMemPlusMinus, SLOT(slotSetMode(ButtonModeFlags,bool)));
352 
353  connect(pbMemStore, SIGNAL(clicked()), SLOT(slotMemStoreclicked()));
354  connect(this, SIGNAL(switchShowAccels(bool)), pbMemStore, SLOT(slotSetAccelDisplayMode(bool)));
355 
356  pbPercent->setShortcut(QKeySequence(Qt::Key_Percent));
357  connect(pbPercent, SIGNAL(clicked()), SLOT(slotPercentclicked()));
358  connect(this, SIGNAL(switchShowAccels(bool)), pbPercent, SLOT(slotSetAccelDisplayMode(bool)));
359 
360  pbPlusMinus->setShortcut(QKeySequence(Qt::Key_Backslash));
361  connect(pbPlusMinus, SIGNAL(clicked()), SLOT(slotPlusMinusclicked()));
362  connect(this, SIGNAL(switchShowAccels(bool)), pbPlusMinus, SLOT(slotSetAccelDisplayMode(bool)));
363 }
364 
365 //------------------------------------------------------------------------------
366 // Name: setupNumericKeypad
367 // Desc: sets up numeric keys and related shortcuts
368 //------------------------------------------------------------------------------
369 void KCalculator::setupNumericKeypad() {
370 
371  pbCube->addMode(ModeNormal, i18nc("Third power", "x<sup>3</sup>"), i18n("Third power"));
372  pbCube->addMode(ModeShift, QLatin1String("<sup>3</sup>&radic;x"), i18n("Cube root"));
373  connect(pbCube, SIGNAL(clicked()), SLOT(slotCubeclicked()));
374  connect(this, SIGNAL(switchShowAccels(bool)), pbCube, SLOT(slotSetAccelDisplayMode(bool)));
375  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbCube, SLOT(slotSetMode(ButtonModeFlags,bool)));
376 
377  pbDivision->setShortcut(QKeySequence(Qt::Key_Slash));
378  new QShortcut(Qt::Key_division, pbDivision, SLOT(animateClick()));
379  connect(pbDivision, SIGNAL(clicked()), SLOT(slotDivisionclicked()));
380  connect(this, SIGNAL(switchShowAccels(bool)), pbDivision, SLOT(slotSetAccelDisplayMode(bool)));
381 
382  pbMultiplication->setShortcut(QKeySequence(Qt::Key_Asterisk));
383  new QShortcut(Qt::Key_X, pbMultiplication, SLOT(animateClick()));
384  new QShortcut(Qt::Key_multiply, pbMultiplication, SLOT(animateClick()));
385  connect(pbMultiplication, SIGNAL(clicked()), SLOT(slotMultiplicationclicked()));
386  connect(this, SIGNAL(switchShowAccels(bool)), pbMultiplication, SLOT(slotSetAccelDisplayMode(bool)));
387 
388  pbMinus->setShortcut(QKeySequence(Qt::Key_Minus));
389  connect(pbMinus, SIGNAL(clicked()), SLOT(slotMinusclicked()));
390  connect(this, SIGNAL(switchShowAccels(bool)), pbMinus, SLOT(slotSetAccelDisplayMode(bool)));
391 
392  pbPlus->setShortcut(QKeySequence(Qt::Key_Plus));
393  connect(pbPlus, SIGNAL(clicked()), SLOT(slotPlusclicked()));
394  connect(this, SIGNAL(switchShowAccels(bool)), pbPlus, SLOT(slotSetAccelDisplayMode(bool)));
395 
396  pbPeriod->setText(KGlobal::locale()->decimalSymbol());
397  pbPeriod->setShortcut(KGlobal::locale()->decimalSymbol());
398 
399  // TODO: is this needed? the above line look slike it should do the right thing?
400  /*
401  if (KGlobal::locale()->decimalSymbol() == QLatin1String(".")) {
402  new QShortcut(Qt::Key_Comma, pbPeriod, SLOT(animateClick()));
403  } else if (KGlobal::locale()->decimalSymbol() == QLatin1String(",")) {
404  new QShortcut(Qt::Key_Period, pbPeriod, SLOT(animateClick()));
405  }
406  */
407 
408  connect(pbPeriod, SIGNAL(clicked()), SLOT(slotPeriodclicked()));
409  connect(this, SIGNAL(switchShowAccels(bool)), pbPeriod, SLOT(slotSetAccelDisplayMode(bool)));
410 
411  pbEqual->setShortcut(QKeySequence(Qt::Key_Enter));
412  new QShortcut(Qt::Key_Equal, pbEqual, SLOT(animateClick()));
413  new QShortcut(Qt::Key_Return, pbEqual, SLOT(animateClick()));
414  connect(pbEqual, SIGNAL(clicked()), SLOT(slotEqualclicked()));
415  connect(this, SIGNAL(switchShowAccels(bool)), pbEqual, SLOT(slotSetAccelDisplayMode(bool)));
416 }
417 
418 //------------------------------------------------------------------------------
419 // Name: setupLogicKeys
420 // Desc: sets up logic keys and related shortcuts
421 //------------------------------------------------------------------------------
422 void KCalculator::setupLogicKeys() {
423 
424  logic_buttons_.append(pbAND);
425  logic_buttons_.append(pbOR);
426  logic_buttons_.append(pbXOR);
427  logic_buttons_.append(pbLsh);
428  logic_buttons_.append(pbRsh);
429  logic_buttons_.append(pbCmp);
430 
431  pbAND->setShortcut(QKeySequence(Qt::Key_Ampersand));
432  connect(this, SIGNAL(switchShowAccels(bool)), pbAND, SLOT(slotSetAccelDisplayMode(bool)));
433  connect(pbAND, SIGNAL(clicked()), SLOT(slotANDclicked()));
434 
435  pbOR->setShortcut(QKeySequence(Qt::Key_Bar));
436  connect(this, SIGNAL(switchShowAccels(bool)), pbOR, SLOT(slotSetAccelDisplayMode(bool)));
437  connect(pbOR, SIGNAL(clicked()), SLOT(slotORclicked()));
438 
439  connect(this, SIGNAL(switchShowAccels(bool)), pbXOR, SLOT(slotSetAccelDisplayMode(bool)));
440  connect(pbXOR, SIGNAL(clicked()), SLOT(slotXORclicked()));
441 
442  pbLsh->setShortcut(QKeySequence(Qt::Key_Less));
443  connect(this, SIGNAL(switchShowAccels(bool)), pbLsh, SLOT(slotSetAccelDisplayMode(bool)));
444  connect(pbLsh, SIGNAL(clicked()), SLOT(slotLeftShiftclicked()));
445 
446  pbRsh->setShortcut(QKeySequence(Qt::Key_Greater));
447  connect(this, SIGNAL(switchShowAccels(bool)), pbRsh, SLOT(slotSetAccelDisplayMode(bool)));
448  connect(pbRsh, SIGNAL(clicked()), SLOT(slotRightShiftclicked()));
449 
450  pbCmp->setShortcut(QKeySequence(Qt::Key_AsciiTilde));
451  connect(this, SIGNAL(switchShowAccels(bool)), pbCmp, SLOT(slotSetAccelDisplayMode(bool)));
452  connect(pbCmp, SIGNAL(clicked()), SLOT(slotNegateclicked()));
453 }
454 
455 //------------------------------------------------------------------------------
456 // Name: setupLogicKeys
457 // Desc: sets up scientific keys and related shortcuts
458 //------------------------------------------------------------------------------
459 void KCalculator::setupScientificKeys() {
460 
461  scientific_buttons_.append(pbHyp);
462  scientific_buttons_.append(pbSin);
463  scientific_buttons_.append(pbCos);
464  scientific_buttons_.append(pbTan);
465  scientific_buttons_.append(pbLog);
466  scientific_buttons_.append(pbLn);
467 
468  connect(this, SIGNAL(switchShowAccels(bool)), pbHyp, SLOT(slotSetAccelDisplayMode(bool)));
469  connect(pbHyp, SIGNAL(toggled(bool)), SLOT(slotHyptoggled(bool)));
470 
471  pbSin->addMode(ModeNormal, i18nc("Sine", "Sin"), i18n("Sine"));
472  pbSin->addMode(ModeShift, i18nc("Arc sine", "Asin"), i18n("Arc sine"));
473  pbSin->addMode(ModeHyperbolic, i18nc("Hyperbolic sine", "Sinh"), i18n("Hyperbolic sine"));
474  pbSin->addMode(ButtonModeFlags(ModeShift | ModeHyperbolic), i18nc("Inverse hyperbolic sine", "Asinh"), i18n("Inverse hyperbolic sine"));
475  connect(this, SIGNAL(switchShowAccels(bool)), pbSin, SLOT(slotSetAccelDisplayMode(bool)));
476  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbSin, SLOT(slotSetMode(ButtonModeFlags,bool)));
477  connect(pbSin, SIGNAL(clicked()), SLOT(slotSinclicked()));
478 
479  pbCos->addMode(ModeNormal, i18nc("Cosine", "Cos"), i18n("Cosine"));
480  pbCos->addMode(ModeShift, i18nc("Arc cosine", "Acos"), i18n("Arc cosine"));
481  pbCos->addMode(ModeHyperbolic, i18nc("Hyperbolic cosine", "Cosh"), i18n("Hyperbolic cosine"));
482  pbCos->addMode(ButtonModeFlags(ModeShift | ModeHyperbolic), i18nc("Inverse hyperbolic cosine", "Acosh"), i18n("Inverse hyperbolic cosine"));
483  connect(this, SIGNAL(switchShowAccels(bool)), pbCos, SLOT(slotSetAccelDisplayMode(bool)));
484  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbCos, SLOT(slotSetMode(ButtonModeFlags,bool)));
485  connect(pbCos, SIGNAL(clicked()), SLOT(slotCosclicked()));
486 
487  pbTan->addMode(ModeNormal, i18nc("Tangent", "Tan"), i18n("Tangent"));
488  pbTan->addMode(ModeShift, i18nc("Arc tangent", "Atan"), i18n("Arc tangent"));
489  pbTan->addMode(ModeHyperbolic, i18nc("Hyperbolic tangent", "Tanh"), i18n("Hyperbolic tangent"));
490  pbTan->addMode(ButtonModeFlags(ModeShift | ModeHyperbolic), i18nc("Inverse hyperbolic tangent", "Atanh"), i18n("Inverse hyperbolic tangent"));
491  connect(this, SIGNAL(switchShowAccels(bool)), pbTan, SLOT(slotSetAccelDisplayMode(bool)));
492  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbTan, SLOT(slotSetMode(ButtonModeFlags,bool)));
493  connect(pbTan, SIGNAL(clicked()), SLOT(slotTanclicked()));
494 
495  pbLog->addMode(ModeNormal, i18nc("Logarithm to base 10", "Log"), i18n("Logarithm to base 10"));
496  pbLog->addMode(ModeShift, i18nc("10 to the power of x", "10<sup>x</sup>"), i18n("10 to the power of x"));
497  connect(this, SIGNAL(switchShowAccels(bool)), pbLog, SLOT(slotSetAccelDisplayMode(bool)));
498  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbLog, SLOT(slotSetMode(ButtonModeFlags,bool)));
499  connect(pbLog, SIGNAL(clicked()), SLOT(slotLogclicked()));
500  pbLn->addMode(ModeNormal, i18nc("Natural log", "Ln"), i18n("Natural log"));
501  pbLn->addMode(ModeShift, i18nc("Exponential function", "e<sup>x</sup>"), i18n("Exponential function"));
502  connect(this, SIGNAL(switchShowAccels(bool)), pbLn, SLOT(slotSetAccelDisplayMode(bool)));
503  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbLn, SLOT(slotSetMode(ButtonModeFlags,bool)));
504  connect(pbLn, SIGNAL(clicked()), SLOT(slotLnclicked()));
505 }
506 
507 //------------------------------------------------------------------------------
508 // Name: setupStatisticKeys
509 // Desc: sets up statistical keys and related shortcuts
510 //------------------------------------------------------------------------------
511 void KCalculator::setupStatisticKeys() {
512 
513  stat_buttons_.append(pbNData);
514  stat_buttons_.append(pbMean);
515  stat_buttons_.append(pbSd);
516  stat_buttons_.append(pbMed);
517  stat_buttons_.append(pbDat);
518  stat_buttons_.append(pbCSt);
519 
520  pbNData->addMode(ModeNormal, i18nc("Number of data entered", "N"), i18n("Number of data entered"));
521  pbNData->addMode(ModeShift, QString::fromUtf8("\xce\xa3") + QLatin1Char('x'), i18n("Sum of all data items"));
522  connect(this, SIGNAL(switchShowAccels(bool)), pbNData, SLOT(slotSetAccelDisplayMode(bool)));
523  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbNData, SLOT(slotSetMode(ButtonModeFlags,bool)));
524  connect(pbNData, SIGNAL(clicked()), SLOT(slotStatNumclicked()));
525 
526  pbMean->addMode(ModeNormal, i18nc("Mean", "Mea"), i18n("Mean"));
527  pbMean->addMode(ModeShift, QString::fromUtf8("\xce\xa3") + QLatin1String("x<sup>2</sup>"), i18n("Sum of all data items squared"));
528  connect(this, SIGNAL(switchShowAccels(bool)), pbMean, SLOT(slotSetAccelDisplayMode(bool)));
529  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbMean, SLOT(slotSetMode(ButtonModeFlags,bool)));
530  connect(pbMean, SIGNAL(clicked()), SLOT(slotStatMeanclicked()));
531 
532  pbSd->addMode(ModeNormal, QString::fromUtf8("\xcf\x83") + QLatin1String("<sub>N</sub>"), i18n("Standard deviation"));
533  pbSd->addMode(ModeShift, QString::fromUtf8("\xcf\x83") + QLatin1String("<sub>N-1</sub>"), i18n("Sample standard deviation"));
534  connect(this, SIGNAL(switchShowAccels(bool)), pbSd, SLOT(slotSetAccelDisplayMode(bool)));
535  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbSd, SLOT(slotSetMode(ButtonModeFlags,bool)));
536  connect(pbSd, SIGNAL(clicked()), SLOT(slotStatStdDevclicked()));
537 
538  connect(this, SIGNAL(switchShowAccels(bool)), pbMed, SLOT(slotSetAccelDisplayMode(bool)));
539  connect(pbMed, SIGNAL(clicked()), SLOT(slotStatMedianclicked()));
540 
541  pbDat->addMode(ModeNormal, i18nc("Enter data", "Dat"), i18n("Enter data"));
542  pbDat->addMode(ModeShift, i18nc("Delete last data item", "CDat"), i18n("Delete last data item"));
543  connect(this, SIGNAL(switchShowAccels(bool)), pbDat, SLOT(slotSetAccelDisplayMode(bool)));
544  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbDat, SLOT(slotSetMode(ButtonModeFlags,bool)));
545  connect(pbDat, SIGNAL(clicked()), SLOT(slotStatDataInputclicked()));
546 
547  connect(this, SIGNAL(switchShowAccels(bool)), pbCSt, SLOT(slotSetAccelDisplayMode(bool)));
548  connect(pbCSt, SIGNAL(clicked()), SLOT(slotStatClearDataclicked()));
549 }
550 
551 //------------------------------------------------------------------------------
552 // Name: setupConstantsKeys
553 // Desc: sets up constants keys and related shortcuts
554 //------------------------------------------------------------------------------
555 void KCalculator::setupConstantsKeys() {
556 
557  const_buttons_.append(pbC1);
558  const_buttons_.append(pbC2);
559  const_buttons_.append(pbC3);
560  const_buttons_.append(pbC4);
561  const_buttons_.append(pbC5);
562  const_buttons_.append(pbC6);
563 
564  pbC1->setButtonNumber(0);
565  connect(this, SIGNAL(switchShowAccels(bool)), pbC1, SLOT(slotSetAccelDisplayMode(bool)));
566  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC1, SLOT(slotSetMode(ButtonModeFlags,bool)));
567  connect(pbC1, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
568 
569  pbC2->setButtonNumber(1);
570  connect(this, SIGNAL(switchShowAccels(bool)), pbC2, SLOT(slotSetAccelDisplayMode(bool)));
571  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC2, SLOT(slotSetMode(ButtonModeFlags,bool)));
572  connect(pbC2, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
573 
574  pbC3->setButtonNumber(2);
575  connect(this, SIGNAL(switchShowAccels(bool)), pbC3, SLOT(slotSetAccelDisplayMode(bool)));
576  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC3, SLOT(slotSetMode(ButtonModeFlags,bool)));
577  connect(pbC3, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
578 
579  pbC4->setButtonNumber(3);
580  connect(this, SIGNAL(switchShowAccels(bool)), pbC4, SLOT(slotSetAccelDisplayMode(bool)));
581  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC4, SLOT(slotSetMode(ButtonModeFlags,bool)));
582  connect(pbC4, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
583 
584  pbC5->setButtonNumber(4);
585  connect(this, SIGNAL(switchShowAccels(bool)), pbC5, SLOT(slotSetAccelDisplayMode(bool)));
586  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC5, SLOT(slotSetMode(ButtonModeFlags,bool)));
587  connect(pbC5, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
588 
589  pbC6->setButtonNumber(5);
590  connect(this, SIGNAL(switchShowAccels(bool)), pbC6, SLOT(slotSetAccelDisplayMode(bool)));
591  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbC6, SLOT(slotSetMode(ButtonModeFlags,bool)));
592  connect(pbC6, SIGNAL(clicked(int)), this, SLOT(slotConstclicked(int)));
593 
594  changeButtonNames();
595 }
596 
597 //------------------------------------------------------------------------------
598 // Name: setupMiscKeys
599 // Desc: sets up misc keys and related shortcuts
600 //------------------------------------------------------------------------------
601 void KCalculator::setupMiscKeys() {
602 
603  pbMod->addMode(ModeNormal, i18nc("Modulo", "Mod"), i18n("Modulo"));
604  pbMod->addMode(ModeShift, i18nc("Integer division", "IntDiv"), i18n("Integer division"));
605  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbMod, SLOT(slotSetMode(ButtonModeFlags,bool)));
606  connect(this, SIGNAL(switchShowAccels(bool)), pbMod, SLOT(slotSetAccelDisplayMode(bool)));
607  pbMod->setShortcut(QKeySequence(Qt::Key_Colon));
608  connect(pbMod, SIGNAL(clicked()), SLOT(slotModclicked()));
609 
610  pbReci->addMode(ModeNormal, i18nc("Reciprocal", "1/x"), i18n("Reciprocal"));
611  pbReci->addMode(ModeShift, i18nc("n Choose m", "nCm"), i18n("n Choose m"));
612  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbReci, SLOT(slotSetMode(ButtonModeFlags,bool)));
613  connect(this, SIGNAL(switchShowAccels(bool)), pbReci, SLOT(slotSetAccelDisplayMode(bool)));
614  connect(pbReci, SIGNAL(clicked()), SLOT(slotReciclicked()));
615 
616  pbFactorial->addMode(ModeNormal, i18nc("Factorial", "x!"), i18n("Factorial"));
617  pbFactorial->addMode(ModeShift, QLatin1String("&#915;"), i18n("Gamma"));
618  pbFactorial->setShortcut(QKeySequence(Qt::Key_Exclam));
619  connect(this, SIGNAL(switchShowAccels(bool)), pbFactorial, SLOT(slotSetAccelDisplayMode(bool)));
620  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbFactorial, SLOT(slotSetMode(ButtonModeFlags,bool)));
621  connect(pbFactorial, SIGNAL(clicked()), SLOT(slotFactorialclicked()));
622 
623  pbSquare->addMode(ModeNormal, i18nc("Square", "x<sup>2</sup>"), i18n("Square"));
624  pbSquare->addMode(ModeShift, QLatin1String("&radic;x"), i18n("Square root"));
625  pbSquare->setShortcut(QKeySequence(Qt::Key_BracketLeft));
626  new QShortcut(Qt::Key_twosuperior, pbSquare, SLOT(animateClick()));
627  connect(this, SIGNAL(switchShowAccels(bool)), pbSquare, SLOT(slotSetAccelDisplayMode(bool)));
628  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbSquare, SLOT(slotSetMode(ButtonModeFlags,bool)));
629  connect(pbSquare, SIGNAL(clicked()), SLOT(slotSquareclicked()));
630 
631  pbPower->addMode(ModeNormal, i18nc("x to the power of y", "x<sup>y</sup>"), i18n("x to the power of y"));
632  pbPower->addMode(ModeShift, i18nc("x to the power of 1/y", "x<sup>1/y</sup>"), i18n("x to the power of 1/y"));
633  connect(this, SIGNAL(switchShowAccels(bool)), pbPower, SLOT(slotSetAccelDisplayMode(bool)));
634  connect(this, SIGNAL(switchMode(ButtonModeFlags,bool)), pbPower, SLOT(slotSetMode(ButtonModeFlags,bool)));
635  pbPower->setShortcut(QKeySequence(Qt::Key_AsciiCircum));
636  connect(pbPower, SIGNAL(clicked()), SLOT(slotPowerclicked()));
637 
638  pbEE->addMode(ModeNormal, QLatin1String("x<small>" "\xb7" "10</small><sup>y</sup>"), i18n("Exponent"));
639  connect(this, SIGNAL(switchShowAccels(bool)), pbEE, SLOT(slotSetAccelDisplayMode(bool)));
640  connect(pbEE, SIGNAL(clicked()), SLOT(slotEEclicked()));
641 }
642 
643 //------------------------------------------------------------------------------
644 // Name: createConstantsMenu
645 // Desc: additional setup for button keys
646 // NOTE: all alphanumeric shorts set in ui file
647 //------------------------------------------------------------------------------
648 void KCalculator::setupKeys() {
649 
650  setupNumberKeys();
651  setupRightKeypad();
652  setupNumericKeypad();
653  setupLogicKeys();
654  setupScientificKeys();
655  setupStatisticKeys();
656  setupConstantsKeys();
657  setupMiscKeys();
658 
659  // other button lists
660 
661  function_button_list_.append(pbHyp);
662  function_button_list_.append(pbShift);
663  function_button_list_.append(pbEE);
664  function_button_list_.append(pbSin);
665  function_button_list_.append(pbPlusMinus);
666  function_button_list_.append(pbCos);
667  function_button_list_.append(pbReci);
668  function_button_list_.append(pbTan);
669  function_button_list_.append(pbFactorial);
670  function_button_list_.append(pbLog);
671  function_button_list_.append(pbSquare);
672  function_button_list_.append(pbLn);
673  function_button_list_.append(pbPower);
674  function_button_list_.append(pbCube);
675 
676  mem_button_list_.append(pbMemRecall);
677  mem_button_list_.append(pbMemPlusMinus);
678  mem_button_list_.append(pbMemStore);
679  mem_button_list_.append(pbMemClear);
680  mem_button_list_.append(pbClear);
681  mem_button_list_.append(pbAllClear);
682 
683  operation_button_list_.append(pbMultiplication);
684  operation_button_list_.append(pbParenOpen);
685  operation_button_list_.append(pbParenClose);
686  operation_button_list_.append(pbAND);
687  operation_button_list_.append(pbDivision);
688  operation_button_list_.append(pbOR);
689  operation_button_list_.append(pbXOR);
690  operation_button_list_.append(pbPlus);
691  operation_button_list_.append(pbMinus);
692  operation_button_list_.append(pbLsh);
693  operation_button_list_.append(pbRsh);
694  operation_button_list_.append(pbPeriod);
695  operation_button_list_.append(pbEqual);
696  operation_button_list_.append(pbPercent);
697  operation_button_list_.append(pbCmp);
698  operation_button_list_.append(pbMod);
699 }
700 
701 //------------------------------------------------------------------------------
702 // Name: updateGeometry
703 // Desc: makes all the buttons have reasonable sizes
704 //------------------------------------------------------------------------------
705 void KCalculator::updateGeometry() {
706 
707  const QSize em = pbAND->fontMetrics().size(0, QLatin1String("M"));
708  int margin = QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin, 0, 0);
709  margin = qMax(qMin(margin / 2, 3), 3);
710 
711  // left pad
712  foreach(QObject *obj, leftPad->children()) {
713  if (KCalcButton *const button = qobject_cast<KCalcButton *>(obj)) {
714  button->setFixedWidth(em.width() * 4 + margin * 2);
715  button->installEventFilter(this);
716  }
717  }
718 
719  // right pad
720  foreach(QObject *obj, rightPad->children()) {
721  KCalcButton *const button = qobject_cast<KCalcButton *>(obj);
722  // let Shift expand freely
723  if (button && button != pbShift) {
724  button->setFixedWidth(em.width() * 3 + margin * 2);
725  button->installEventFilter(this);
726  }
727  }
728 
729  // numeric pad
730  foreach(QObject *obj, numericPad->children()) {
731  if (KCalcButton *const button = qobject_cast<KCalcButton *>(obj)) {
732  // let pb0 expand freely
733  if (button != pb0) {
734  button->setFixedWidth(em.width() * 3 + margin * 2);
735  }
736  button->installEventFilter(this);
737  }
738  }
739 }
740 
741 //------------------------------------------------------------------------------
742 // Name: slotConstantToDisplay
743 // Desc: inserts a constant
744 //------------------------------------------------------------------------------
745 void KCalculator::slotConstantToDisplay(const science_constant &const_chosen) {
746 
747  QString val = const_chosen.value;
748  val.replace(QLatin1Char('.'), KNumber::decimalSeparator());
749  calc_display->setAmount(KNumber(val));
750  updateDisplay(0);
751 }
752 
753 //------------------------------------------------------------------------------
754 // Name: slotBaseSelected
755 // Desc: changes the selected numeric base
756 //------------------------------------------------------------------------------
757 void KCalculator::slotBaseSelected(int base) {
758 
759  int current_base;
760 
761  // set display & statusbar (if item exist in statusbar)
762  switch (base) {
763  case BinMode:
764  current_base = calc_display->setBase(NumBase(2));
765  statusBar()->changeItem(QLatin1String("BIN"), BaseField);
766  calc_display->setStatusText(BaseField, QLatin1String("Bin"));
767  break;
768  case OctMode:
769  current_base = calc_display->setBase(NumBase(8));
770  statusBar()->changeItem(QLatin1String("OCT"), BaseField);
771  calc_display->setStatusText(BaseField, QLatin1String("Oct"));
772  break;
773  case DecMode:
774  current_base = calc_display->setBase(NumBase(10));
775  statusBar()->changeItem(QLatin1String("DEC"), BaseField);
776  calc_display->setStatusText(BaseField, QLatin1String("Dec"));
777  break;
778  case HexMode:
779  current_base = calc_display->setBase(NumBase(16));
780  statusBar()->changeItem(QLatin1String("HEX"), BaseField);
781  calc_display->setStatusText(BaseField, QLatin1String("Hex"));
782  break;
783  default:
784  statusBar()->changeItem(QLatin1String("Error"), BaseField);
785  calc_display->setStatusText(BaseField, QLatin1String("Error"));
786  return;
787  }
788 
789  // Enable the buttons available in this base
790  for (int i = 0; i < current_base; ++i) {
791  (num_button_group_->buttons()[i])->setEnabled(true);
792  }
793 
794  // Disable the buttons not available in this base
795  for (int i = current_base; i < 16; ++i) {
796  (num_button_group_->buttons()[i])->setEnabled(false);
797  }
798 
799  // Only enable the decimal point in decimal
800  pbPeriod->setEnabled(current_base == NB_DECIMAL);
801 
802  // Only enable the x*10^y button in decimal
803  pbEE->setEnabled(current_base == NB_DECIMAL);
804 
805  // Disable buttons that make only sense with floating point numbers
806  if (current_base != NB_DECIMAL) {
807  foreach(QAbstractButton *btn, scientific_buttons_) {
808  btn->setEnabled(false);
809  }
810  } else {
811  foreach(QAbstractButton *btn, scientific_buttons_) {
812  btn->setEnabled(true);
813  }
814  }
815 
816  KCalcSettings::setBaseMode(base);
817 }
818 
819 //------------------------------------------------------------------------------
820 // Name: keyPressEvent
821 // Desc: handles keypress events
822 //------------------------------------------------------------------------------
823 void KCalculator::keyPressEvent(QKeyEvent *e) {
824 
825  // Fix for bug #314586
826  // Basically, on some keyboards such as French, even though the decimal separator
827  // is "," the numeric keypad has a "." key. So we fake it so people can more seemlessly
828  // enter numbers using the keypad
829  if(KNumber::decimalSeparator() != ".") {
830  if(e->key() == Qt::Key_Period && e->modifiers() & Qt::KeypadModifier) {
831  pbPeriod->animateClick();
832  }
833  }
834 
835 
836  if (((e->modifiers() & Qt::NoModifier) == 0) || (e->modifiers() & Qt::ShiftModifier)) {
837  switch (e->key()) {
838  case Qt::Key_Backspace:
839  calc_display->deleteLastDigit();
840  break;
841  }
842  }
843 
844  if (e->key() == Qt::Key_Control) {
845  emit switchShowAccels(true);
846  }
847 }
848 
849 //------------------------------------------------------------------------------
850 // Name: keyReleaseEvent
851 // Desc: handles keyrelease events
852 //------------------------------------------------------------------------------
853 void KCalculator::keyReleaseEvent(QKeyEvent *e) {
854 
855  if (e->key() == Qt::Key_Control) {
856  emit switchShowAccels(false);
857  }
858 }
859 
860 //------------------------------------------------------------------------------
861 // Name: slotAngleSelected
862 // Desc: changes the selected angle system
863 //------------------------------------------------------------------------------
864 void KCalculator::slotAngleSelected(int mode) {
865 
866  angle_mode_ = mode;
867 
868  switch (mode) {
869  case DegMode:
870  statusBar()->changeItem(QLatin1String("DEG"), AngleField);
871  calc_display->setStatusText(AngleField, QLatin1String("Deg"));
872  break;
873  case RadMode:
874  statusBar()->changeItem(QLatin1String("RAD"), AngleField);
875  calc_display->setStatusText(AngleField, QLatin1String("Rad"));
876  break;
877  case GradMode:
878  statusBar()->changeItem(QLatin1String("GRA"), AngleField);
879  calc_display->setStatusText(AngleField, QLatin1String("Gra"));
880  break;
881  default: // we shouldn't ever end up here
882  angle_mode_ = RadMode;
883  }
884 
885  KCalcSettings::setAngleMode(angle_mode_);
886 }
887 
888 //------------------------------------------------------------------------------
889 // Name: slotEEclicked
890 // Desc: starts the entering of numers using scientific notation
891 //------------------------------------------------------------------------------
892 void KCalculator::slotEEclicked() {
893  calc_display->newCharacter(QLatin1Char('e'));
894 }
895 
896 //------------------------------------------------------------------------------
897 // Name: slotShifttoggled
898 // Desc: updates the shift state for alternate button functionality
899 //------------------------------------------------------------------------------
900 void KCalculator::slotShifttoggled(bool flag) {
901 
902  shift_mode_ = flag;
903 
904  emit switchMode(ModeShift, flag);
905 
906  if (shift_mode_) {
907  statusBar()->changeItem(i18nc("Second button functions are active", "SHIFT"), ShiftField);
908  calc_display->setStatusText(ShiftField, i18n("Shift"));
909  } else {
910  statusBar()->changeItem(i18nc("Normal button functions are active", "NORM"), ShiftField);
911  calc_display->setStatusText(ShiftField, QString());
912  }
913 }
914 
915 //------------------------------------------------------------------------------
916 // Name: slotHyptoggled
917 // Desc: updates the Hyp state for alternate trig button functionality
918 //------------------------------------------------------------------------------
919 void KCalculator::slotHyptoggled(bool flag) {
920 
921  // toggle between hyperbolic and standart trig functions
922  hyp_mode_ = flag;
923 
924  emit switchMode(ModeHyperbolic, flag);
925 }
926 
927 //------------------------------------------------------------------------------
928 // Name: slotMemRecallclicked
929 // Desc: recalls a value from memory
930 //------------------------------------------------------------------------------
931 void KCalculator::slotMemRecallclicked() {
932 
933  // temp. work-around
934  calc_display->sendEvent(KCalcDisplay::EventReset);
935 
936  calc_display->setAmount(memory_num_);
937  updateDisplay(0);
938 }
939 
940 //------------------------------------------------------------------------------
941 // Name: slotMemStoreclicked
942 // Desc: stores a value into memory
943 //------------------------------------------------------------------------------
944 void KCalculator::slotMemStoreclicked() {
945 
946  EnterEqual();
947 
948  memory_num_ = calc_display->getAmount();
949  calc_display->setStatusText(MemField, QLatin1String("M"));
950  statusBar()->changeItem(QLatin1String("M"), MemField);
951  pbMemRecall->setEnabled(true);
952 }
953 
954 //------------------------------------------------------------------------------
955 // Name: slotNumberclicked
956 // Desc: user has entered a digit
957 //------------------------------------------------------------------------------
958 void KCalculator::slotNumberclicked(int number_clicked) {
959 
960  calc_display->enterDigit(number_clicked);
961 }
962 
963 //------------------------------------------------------------------------------
964 // Name: slotSinclicked
965 // Desc: executes the sine function
966 //------------------------------------------------------------------------------
967 void KCalculator::slotSinclicked() {
968 
969  if (hyp_mode_) {
970  // sinh or arsinh
971  if (!shift_mode_) {
972  core.SinHyp(calc_display->getAmount());
973  } else {
974  core.AreaSinHyp(calc_display->getAmount());
975  }
976  } else {
977  // sine or arcsine
978  if (!shift_mode_) {
979  switch (angle_mode_) {
980  case DegMode:
981  core.SinDeg(calc_display->getAmount());
982  break;
983  case RadMode:
984  core.SinRad(calc_display->getAmount());
985  break;
986  case GradMode:
987  core.SinGrad(calc_display->getAmount());
988  break;
989  }
990  } else {
991  switch (angle_mode_) {
992  case DegMode:
993  core.ArcSinDeg(calc_display->getAmount());
994  break;
995  case RadMode:
996  core.ArcSinRad(calc_display->getAmount());
997  break;
998  case GradMode:
999  core.ArcSinGrad(calc_display->getAmount());
1000  break;
1001  }
1002  }
1003  }
1004 
1005  updateDisplay(UPDATE_FROM_CORE);
1006 }
1007 
1008 //------------------------------------------------------------------------------
1009 // Name: slotPlusMinusclicked
1010 // Desc: changes sign of number being displayed
1011 //------------------------------------------------------------------------------
1012 void KCalculator::slotPlusMinusclicked() {
1013 
1014  // display can only change sign, when in input mode, otherwise we
1015  // need the core to do this.
1016  if (!calc_display->sendEvent(KCalcDisplay::EventChangeSign)) {
1017  core.InvertSign(calc_display->getAmount());
1018  updateDisplay(UPDATE_FROM_CORE);
1019  }
1020 }
1021 
1022 //------------------------------------------------------------------------------
1023 // Name: slotMemPlusMinusclicked
1024 // Desc: handles arithmetic on values stored in memory
1025 //------------------------------------------------------------------------------
1026 void KCalculator::slotMemPlusMinusclicked() {
1027 
1028  bool tmp_shift_mode = shift_mode_; // store this, because next command deletes shift_mode_
1029  EnterEqual(); // finish calculation so far, to store result into MEM
1030 
1031  if (!tmp_shift_mode) {
1032  memory_num_ += calc_display->getAmount();
1033  } else {
1034  memory_num_ -= calc_display->getAmount();
1035  }
1036 
1037  pbShift->setChecked(false);
1038  statusBar()->changeItem(i18n("M"), MemField);
1039  calc_display->setStatusText(MemField, i18n("M"));
1040  pbMemRecall->setEnabled(true);
1041 }
1042 
1043 //------------------------------------------------------------------------------
1044 // Name: slotSinclicked
1045 // Desc: executes the cosine function
1046 //------------------------------------------------------------------------------
1047 void KCalculator::slotCosclicked() {
1048 
1049  if (hyp_mode_) {
1050  // cosh or arcosh
1051  if (!shift_mode_) {
1052  core.CosHyp(calc_display->getAmount());
1053  } else {
1054  core.AreaCosHyp(calc_display->getAmount());
1055  }
1056  } else {
1057  // cosine or arccosine
1058  if (!shift_mode_) {
1059  switch (angle_mode_) {
1060  case DegMode:
1061  core.CosDeg(calc_display->getAmount());
1062  break;
1063  case RadMode:
1064  core.CosRad(calc_display->getAmount());
1065  break;
1066  case GradMode:
1067  core.CosGrad(calc_display->getAmount());
1068  break;
1069  }
1070  } else {
1071  switch (angle_mode_) {
1072  case DegMode:
1073  core.ArcCosDeg(calc_display->getAmount());
1074  break;
1075  case RadMode:
1076  core.ArcCosRad(calc_display->getAmount());
1077  break;
1078  case GradMode:
1079  core.ArcCosGrad(calc_display->getAmount());
1080  break;
1081  }
1082  }
1083  }
1084 
1085  updateDisplay(UPDATE_FROM_CORE);
1086 }
1087 
1088 //------------------------------------------------------------------------------
1089 // Name: slotSinclicked
1090 // Desc: executes the recipricol function
1091 //------------------------------------------------------------------------------
1092 void KCalculator::slotReciclicked() {
1093 
1094  if (shift_mode_) {
1095  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_BINOM);
1096  } else {
1097  core.Reciprocal(calc_display->getAmount());
1098  updateDisplay(UPDATE_FROM_CORE);
1099  return;
1100  }
1101 
1102  // temp. work-around
1103  KNumber tmp_num = calc_display->getAmount();
1104  calc_display->sendEvent(KCalcDisplay::EventReset);
1105  calc_display->setAmount(tmp_num);
1106  updateDisplay(0);
1107 }
1108 
1109 //------------------------------------------------------------------------------
1110 // Name: slotSinclicked
1111 // Desc: executes the tangent function
1112 //------------------------------------------------------------------------------
1113 void KCalculator::slotTanclicked() {
1114 
1115  if (hyp_mode_) {
1116  // tanh or artanh
1117  if (!shift_mode_) {
1118  core.TangensHyp(calc_display->getAmount());
1119  } else {
1120  core.AreaTangensHyp(calc_display->getAmount());
1121  }
1122  } else {
1123  // tan or arctan
1124  if (!shift_mode_) {
1125  switch (angle_mode_) {
1126  case DegMode:
1127  core.TangensDeg(calc_display->getAmount());
1128  break;
1129  case RadMode:
1130  core.TangensRad(calc_display->getAmount());
1131  break;
1132  case GradMode:
1133  core.TangensGrad(calc_display->getAmount());
1134  break;
1135  }
1136  } else {
1137  switch (angle_mode_) {
1138  case DegMode:
1139  core.ArcTangensDeg(calc_display->getAmount());
1140  break;
1141  case RadMode:
1142  core.ArcTangensRad(calc_display->getAmount());
1143  break;
1144  case GradMode:
1145  core.ArcTangensGrad(calc_display->getAmount());
1146  break;
1147  }
1148  }
1149  }
1150 
1151  updateDisplay(UPDATE_FROM_CORE);
1152 }
1153 
1154 //------------------------------------------------------------------------------
1155 // Name: slotFactorialclicked
1156 // Desc: executes the factorial function
1157 //------------------------------------------------------------------------------
1158 void KCalculator::slotFactorialclicked() {
1159 
1160  // Set WaitCursor, as this operation may take looooong
1161  // time and UI frezes with large numbers. User needs some
1162  // visual feedback.
1163  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1164  if (!shift_mode_) {
1165  core.Factorial(calc_display->getAmount());
1166  } else {
1167  core.Gamma(calc_display->getAmount());
1168  }
1169  QApplication::restoreOverrideCursor();
1170  updateDisplay(UPDATE_FROM_CORE);
1171 }
1172 
1173 //------------------------------------------------------------------------------
1174 // Name: slotLogclicked
1175 // Desc: executes the Log function
1176 //------------------------------------------------------------------------------
1177 void KCalculator::slotLogclicked() {
1178 
1179  if (!shift_mode_) {
1180  core.Log10(calc_display->getAmount());
1181  } else {
1182  core.Exp10(calc_display->getAmount());
1183  }
1184 
1185  updateDisplay(UPDATE_FROM_CORE);
1186 }
1187 
1188 //------------------------------------------------------------------------------
1189 // Name: slotSquareclicked
1190 // Desc: executes the x^2 function
1191 //------------------------------------------------------------------------------
1192 void KCalculator::slotSquareclicked() {
1193 
1194  if (!shift_mode_) {
1195  core.Square(calc_display->getAmount());
1196  } else {
1197  core.SquareRoot(calc_display->getAmount());
1198  }
1199 
1200  updateDisplay(UPDATE_FROM_CORE);
1201 }
1202 
1203 //------------------------------------------------------------------------------
1204 // Name: slotCubeclicked
1205 // Desc: executes the x^3 function
1206 //------------------------------------------------------------------------------
1207 void KCalculator::slotCubeclicked() {
1208 
1209  if (!shift_mode_) {
1210  core.Cube(calc_display->getAmount());
1211  } else {
1212  core.CubeRoot(calc_display->getAmount());
1213  }
1214 
1215  updateDisplay(UPDATE_FROM_CORE);
1216 }
1217 
1218 //------------------------------------------------------------------------------
1219 // Name: slotCubeclicked
1220 // Desc: executes the ln function
1221 //------------------------------------------------------------------------------
1222 void KCalculator::slotLnclicked() {
1223 
1224  if (!shift_mode_) {
1225  core.Ln(calc_display->getAmount());
1226  } else {
1227  core.Exp(calc_display->getAmount());
1228  }
1229 
1230  updateDisplay(UPDATE_FROM_CORE);
1231 }
1232 
1233 //------------------------------------------------------------------------------
1234 // Name: slotPowerclicked
1235 // Desc: executes the x^y function
1236 //------------------------------------------------------------------------------
1237 void KCalculator::slotPowerclicked() {
1238 
1239  if (shift_mode_) {
1240  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_PWR_ROOT);
1241  pbShift->setChecked(false);
1242  } else {
1243  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_POWER);
1244  }
1245 
1246  // temp. work-around
1247  KNumber tmp_num = calc_display->getAmount();
1248  calc_display->sendEvent(KCalcDisplay::EventReset);
1249  calc_display->setAmount(tmp_num);
1250  updateDisplay(0);
1251 }
1252 
1253 //------------------------------------------------------------------------------
1254 // Name: slotMemClearclicked
1255 // Desc: executes the MC function
1256 //------------------------------------------------------------------------------
1257 void KCalculator::slotMemClearclicked() {
1258 
1259  memory_num_ = KNumber::Zero;
1260  statusBar()->changeItem(QLatin1String(" \xa0\xa0 "), MemField); // nbsp
1261  calc_display->setStatusText(MemField, QString());
1262  pbMemRecall->setDisabled(true);
1263 }
1264 
1265 //------------------------------------------------------------------------------
1266 // Name: slotBackspaceclicked
1267 // Desc: removes the last input digit
1268 //------------------------------------------------------------------------------
1269 void KCalculator::slotBackspaceclicked() {
1270 
1271  calc_display->deleteLastDigit();
1272 }
1273 
1274 //------------------------------------------------------------------------------
1275 // Name: slotClearclicked
1276 // Desc: clears the display
1277 //------------------------------------------------------------------------------
1278 void KCalculator::slotClearclicked() {
1279 
1280  calc_display->sendEvent(KCalcDisplay::EventClear);
1281 }
1282 
1283 //------------------------------------------------------------------------------
1284 // Name: slotAllClearclicked
1285 // Desc: clears everything
1286 //------------------------------------------------------------------------------
1287 void KCalculator::slotAllClearclicked() {
1288 
1289  core.Reset();
1290  calc_display->sendEvent(KCalcDisplay::EventReset);
1291  updateDisplay(UPDATE_FROM_CORE);
1292 }
1293 
1294 //------------------------------------------------------------------------------
1295 // Name: slotParenOpenclicked
1296 // Desc: starts a sub-expression
1297 //------------------------------------------------------------------------------
1298 void KCalculator::slotParenOpenclicked() {
1299 
1300  core.ParenOpen(calc_display->getAmount());
1301 }
1302 
1303 //------------------------------------------------------------------------------
1304 // Name: slotParenCloseclicked
1305 // Desc: ends a sub-expression
1306 //------------------------------------------------------------------------------
1307 void KCalculator::slotParenCloseclicked() {
1308 
1309  core.ParenClose(calc_display->getAmount());
1310  updateDisplay(UPDATE_FROM_CORE);
1311 }
1312 
1313 //------------------------------------------------------------------------------
1314 // Name: slotANDclicked
1315 // Desc: executes a bitwise AND
1316 //------------------------------------------------------------------------------
1317 void KCalculator::slotANDclicked() {
1318 
1319  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_AND);
1320  updateDisplay(UPDATE_FROM_CORE);
1321 }
1322 
1323 //------------------------------------------------------------------------------
1324 // Name: slotMultiplicationclicked
1325 // Desc: executes multiplication
1326 //------------------------------------------------------------------------------
1327 void KCalculator::slotMultiplicationclicked() {
1328 
1329  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_MULTIPLY);
1330  updateDisplay(UPDATE_FROM_CORE);
1331 }
1332 
1333 //------------------------------------------------------------------------------
1334 // Name: slotDivisionclicked
1335 // Desc: executes division
1336 //------------------------------------------------------------------------------
1337 void KCalculator::slotDivisionclicked() {
1338 
1339  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_DIVIDE);
1340  updateDisplay(UPDATE_FROM_CORE);
1341 }
1342 
1343 //------------------------------------------------------------------------------
1344 // Name: slotORclicked
1345 // Desc: executes a bitwise OR
1346 //------------------------------------------------------------------------------
1347 void KCalculator::slotORclicked() {
1348 
1349  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_OR);
1350  updateDisplay(UPDATE_FROM_CORE);
1351 }
1352 
1353 //------------------------------------------------------------------------------
1354 // Name: slotXORclicked
1355 // Desc: executes a bitwise XOR
1356 //------------------------------------------------------------------------------
1357 void KCalculator::slotXORclicked() {
1358 
1359  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_XOR);
1360  updateDisplay(UPDATE_FROM_CORE);
1361 }
1362 
1363 //------------------------------------------------------------------------------
1364 // Name: slotPlusclicked
1365 // Desc: executes addition
1366 //------------------------------------------------------------------------------
1367 void KCalculator::slotPlusclicked() {
1368 
1369  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_ADD);
1370  updateDisplay(UPDATE_FROM_CORE);
1371 }
1372 
1373 //------------------------------------------------------------------------------
1374 // Name: slotPlusclicked
1375 // Desc: executes subtraction
1376 //------------------------------------------------------------------------------
1377 void KCalculator::slotMinusclicked() {
1378 
1379  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_SUBTRACT);
1380  updateDisplay(UPDATE_FROM_CORE);
1381 }
1382 
1383 //------------------------------------------------------------------------------
1384 // Name: slotLeftShiftclicked
1385 // Desc: executes a bitwise left shift
1386 //------------------------------------------------------------------------------
1387 void KCalculator::slotLeftShiftclicked() {
1388 
1389  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_LSH);
1390  updateDisplay(UPDATE_FROM_CORE);
1391 }
1392 
1393 //------------------------------------------------------------------------------
1394 // Name: slotLeftShiftclicked
1395 // Desc: executes a bitwise right shift
1396 //------------------------------------------------------------------------------
1397 void KCalculator::slotRightShiftclicked() {
1398 
1399  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_RSH);
1400  updateDisplay(UPDATE_FROM_CORE);
1401 }
1402 
1403 //------------------------------------------------------------------------------
1404 // Name: slotPeriodclicked
1405 // Desc: enters a decimal into the input stream
1406 //------------------------------------------------------------------------------
1407 void KCalculator::slotPeriodclicked() {
1408 
1409  // i know this isn't locale friendly, should be converted to appropriate
1410  // value at lower levels
1411  calc_display->newCharacter(KGlobal::locale()->decimalSymbol()[0]);
1412 }
1413 
1414 //------------------------------------------------------------------------------
1415 // Name: EnterEqual
1416 // Desc: calculates and displays the result of the pending operations
1417 //------------------------------------------------------------------------------
1418 void KCalculator::EnterEqual() {
1419 
1420  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_EQUAL);
1421  updateDisplay(UPDATE_FROM_CORE | UPDATE_STORE_RESULT);
1422 }
1423 
1424 //------------------------------------------------------------------------------
1425 // Name: slotEqualclicked
1426 // Desc: calculates and displays the result of the pending operations
1427 //------------------------------------------------------------------------------
1428 void KCalculator::slotEqualclicked() {
1429 
1430  EnterEqual();
1431 }
1432 
1433 //------------------------------------------------------------------------------
1434 // Name: slotPercentclicked
1435 // Desc: calculates and displays the result of the pending operations as a percent
1436 //------------------------------------------------------------------------------
1437 void KCalculator::slotPercentclicked() {
1438 
1439  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_PERCENT);
1440  updateDisplay(UPDATE_FROM_CORE);
1441 }
1442 
1443 //------------------------------------------------------------------------------
1444 // Name: slotNegateclicked
1445 // Desc: executes a bitwise 2's compliment
1446 // NOTE: implicitly converts the value to an unsigned quantity
1447 //------------------------------------------------------------------------------
1448 void KCalculator::slotNegateclicked() {
1449 
1450  core.Complement(calc_display->getAmount());
1451  updateDisplay(UPDATE_FROM_CORE);
1452 }
1453 
1454 //------------------------------------------------------------------------------
1455 // Name: slotModclicked
1456 // Desc: executes modulous (remainder division)
1457 //------------------------------------------------------------------------------
1458 void KCalculator::slotModclicked(){
1459 
1460  if (shift_mode_) {
1461  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_INTDIV);
1462  } else {
1463  core.enterOperation(calc_display->getAmount(), CalcEngine::FUNC_MOD);
1464  }
1465 
1466  updateDisplay(UPDATE_FROM_CORE);
1467 }
1468 
1469 //------------------------------------------------------------------------------
1470 // Name: slotStatNumclicked
1471 // Desc: executes Sum function
1472 //------------------------------------------------------------------------------
1473 void KCalculator::slotStatNumclicked() {
1474 
1475  if (!shift_mode_) {
1476  core.StatCount(KNumber::Zero);
1477  } else {
1478  pbShift->setChecked(false);
1479  core.StatSum(KNumber::Zero);
1480  }
1481 
1482  updateDisplay(UPDATE_FROM_CORE);
1483 }
1484 
1485 //------------------------------------------------------------------------------
1486 // Name: slotStatMeanclicked
1487 // Desc: executes Mean function
1488 //------------------------------------------------------------------------------
1489 void KCalculator::slotStatMeanclicked() {
1490 
1491  if (!shift_mode_) {
1492  core.StatMean(KNumber::Zero);
1493  } else {
1494  pbShift->setChecked(false);
1495  core.StatSumSquares(KNumber::Zero);
1496  }
1497 
1498  updateDisplay(UPDATE_FROM_CORE);
1499 }
1500 
1501 //------------------------------------------------------------------------------
1502 // Name: slotStatStdDevclicked
1503 // Desc: executes STD function
1504 //------------------------------------------------------------------------------
1505 void KCalculator::slotStatStdDevclicked() {
1506 
1507  if (shift_mode_) {
1508  // std (n-1)
1509  core.StatStdDeviation(KNumber::Zero);
1510  pbShift->setChecked(false);
1511  } else {
1512  // std (n)
1513  core.StatStdSample(KNumber::Zero);
1514  }
1515 
1516  updateDisplay(UPDATE_FROM_CORE);
1517 }
1518 
1519 //------------------------------------------------------------------------------
1520 // Name: slotStatMedianclicked
1521 // Desc: executes Median function
1522 //------------------------------------------------------------------------------
1523 void KCalculator::slotStatMedianclicked() {
1524 
1525  if (!shift_mode_) {
1526  // std (n-1)
1527  core.StatMedian(KNumber::Zero);
1528  } else {
1529  // std (n)
1530  core.StatMedian(KNumber::Zero);
1531  pbShift->setChecked(false);
1532  }
1533 
1534  // TODO: it seems two different modes should be implemented, but...?
1535  updateDisplay(UPDATE_FROM_CORE);
1536 }
1537 
1538 //------------------------------------------------------------------------------
1539 // Name: slotStatDataInputclicked
1540 // Desc: enters a value for statistical functions
1541 //------------------------------------------------------------------------------
1542 void KCalculator::slotStatDataInputclicked() {
1543 
1544  if (!shift_mode_) {
1545  core.StatDataNew(calc_display->getAmount());
1546  } else {
1547  pbShift->setChecked(false);
1548  core.StatDataDel(KNumber::Zero);
1549  statusBar()->showMessage(i18n("Last stat item erased"), 3000);
1550  }
1551 
1552  updateDisplay(UPDATE_FROM_CORE);
1553 }
1554 
1555 //------------------------------------------------------------------------------
1556 // Name: slotStatClearDataclicked
1557 // Desc: clears memory for statical functions
1558 //------------------------------------------------------------------------------
1559 void KCalculator::slotStatClearDataclicked() {
1560 
1561  if (!shift_mode_) {
1562  core.StatClearAll(KNumber::Zero);
1563  statusBar()->showMessage(i18n("Stat mem cleared"), 3000);
1564  } else {
1565  pbShift->setChecked(false);
1566  updateDisplay(0);
1567  }
1568 }
1569 
1570 //------------------------------------------------------------------------------
1571 // Name: slotConstclicked
1572 // Desc: enters a constant
1573 //------------------------------------------------------------------------------
1574 void KCalculator::slotConstclicked(int button) {
1575 
1576  if(KCalcConstButton *btn = qobject_cast<KCalcConstButton*>(const_buttons_[button])) {
1577  if (!shift_mode_) {
1578  // set the display to the configured value of constant button
1579  // internally, we deal with C locale style numbers, we need to convert
1580  QString val = btn->constant();
1581  val.replace(QLatin1Char('.'), KNumber::decimalSeparator());
1582  calc_display->setAmount(KNumber(val));
1583 
1584  } else {
1585  pbShift->setChecked(false);
1586 
1587  // internally, we deal with C locale style numbers, we need to convert
1588  QString val = calc_display->text();
1589  val.replace(KNumber::decimalSeparator(), QLatin1String("."));
1590  KCalcSettings::setValueConstant(button, val);
1591 
1592  // below set new tooltip
1593  btn->setLabelAndTooltip();
1594 
1595  // work around: after storing a number, pressing a digit should start
1596  // a new number
1597  calc_display->setAmount(calc_display->getAmount());
1598  }
1599 
1600  updateDisplay(0);
1601  }
1602 }
1603 
1604 //------------------------------------------------------------------------------
1605 // Name: showSettings
1606 // Desc: opens the shows the settings dialog
1607 //------------------------------------------------------------------------------
1608 void KCalculator::showSettings() {
1609 
1610  // Check if there is already a dialog and if so bring
1611  // it to the foreground.
1612  if (KConfigDialog::showDialog(QLatin1String("settings"))) {
1613  return;
1614  }
1615 
1616  // Create a new dialog with the same name as the above checking code.
1617  KConfigDialog *const dialog = new KConfigDialog(this, QLatin1String("settings"), KCalcSettings::self());
1618  dialog->showButtonSeparator(true);
1619 
1620  // general settings
1621  General *const general = new General(0);
1622  general->kcfg_Precision->setMaximum(maxprecision);
1623  dialog->addPage(general, i18n("General"), QLatin1String("accessories-calculator"), i18n("General Settings"));
1624 
1625  // font settings
1626  Fonts *const fonts = new Fonts(0);
1627  dialog->addPage(fonts, i18n("Font"), QLatin1String("preferences-desktop-font"), i18n("Select Display Font"));
1628 
1629  // color settings
1630  Colors *const color = new Colors(0);
1631  dialog->addPage(color, i18n("Colors"), QLatin1String("format-fill-color"), i18n("Button & Display Colors"));
1632 
1633  // constant settings
1634  if (!constants_) {
1635  constants_ = new Constants(0);
1636  }
1637 
1638  KCalcConstMenu *tmp_menu;
1639  tmp_menu = new KCalcConstMenu(this);
1640  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst0(science_constant)));
1641  constants_->pushButton0->setMenu(tmp_menu);
1642 
1643  tmp_menu = new KCalcConstMenu(this);
1644  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst1(science_constant)));
1645  constants_->pushButton1->setMenu(tmp_menu);
1646 
1647  tmp_menu = new KCalcConstMenu(this);
1648  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst2(science_constant)));
1649  constants_->pushButton2->setMenu(tmp_menu);
1650 
1651  tmp_menu = new KCalcConstMenu(this);
1652  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst3(science_constant)));
1653  constants_->pushButton3->setMenu(tmp_menu);
1654 
1655  tmp_menu = new KCalcConstMenu(this);
1656  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst4(science_constant)));
1657  constants_->pushButton4->setMenu(tmp_menu);
1658 
1659  tmp_menu = new KCalcConstMenu(this);
1660  connect(tmp_menu, SIGNAL(triggeredConstant(science_constant)), this, SLOT(slotChooseScientificConst5(science_constant)));
1661  constants_->pushButton5->setMenu(tmp_menu);
1662 
1663  dialog->addPage(constants_, i18n("Constants"), QLatin1String("preferences-kcalc-constants"), i18n("Define Constants"));
1664 
1665  // When the user clicks OK or Apply we want to update our settings.
1666  connect(dialog, SIGNAL(settingsChanged(QString)), SLOT(updateSettings()));
1667 
1668  // Display the dialog.
1669  dialog->show();
1670 }
1671 
1672 
1673 // these 6 slots are just a quick hack, instead of setting the
1674 // TextEdit fields in the configuration dialog, we are setting the
1675 // Settingvalues themselves!!
1676 
1677 //------------------------------------------------------------------------------
1678 // Name: slotChooseScientificConst0
1679 // Desc: updates constants value
1680 //------------------------------------------------------------------------------
1681 void KCalculator::slotChooseScientificConst0(const science_constant &chosen_const) {
1682  constants_->kcfg_valueConstant0->setText(chosen_const.value);
1683  constants_->kcfg_nameConstant0->setText(chosen_const.label);
1684 }
1685 
1686 //------------------------------------------------------------------------------
1687 // Name: slotChooseScientificConst1
1688 // Desc: updates constants value
1689 //------------------------------------------------------------------------------
1690 void KCalculator::slotChooseScientificConst1(const science_constant &chosen_const) {
1691  constants_->kcfg_valueConstant1->setText(chosen_const.value);
1692  constants_->kcfg_nameConstant1->setText(chosen_const.label);
1693 }
1694 
1695 //------------------------------------------------------------------------------
1696 // Name: slotChooseScientificConst2
1697 // Desc: updates constants value
1698 //------------------------------------------------------------------------------
1699 void KCalculator::slotChooseScientificConst2(const science_constant &chosen_const) {
1700  constants_->kcfg_valueConstant2->setText(chosen_const.value);
1701  constants_->kcfg_nameConstant2->setText(chosen_const.label);
1702 }
1703 
1704 //------------------------------------------------------------------------------
1705 // Name: slotChooseScientificConst3
1706 // Desc: updates constants value
1707 //------------------------------------------------------------------------------
1708 void KCalculator::slotChooseScientificConst3(const science_constant &chosen_const) {
1709  constants_->kcfg_valueConstant3->setText(chosen_const.value);
1710  constants_->kcfg_nameConstant3->setText(chosen_const.label);
1711 }
1712 
1713 //------------------------------------------------------------------------------
1714 // Name: slotChooseScientificConst4
1715 // Desc: updates constants value
1716 //------------------------------------------------------------------------------
1717 void KCalculator::slotChooseScientificConst4(const science_constant &chosen_const) {
1718  constants_->kcfg_valueConstant4->setText(chosen_const.value);
1719  constants_->kcfg_nameConstant4->setText(chosen_const.label);
1720 }
1721 
1722 //------------------------------------------------------------------------------
1723 // Name: slotChooseScientificConst5
1724 // Desc: updates constants value
1725 //------------------------------------------------------------------------------
1726 void KCalculator::slotChooseScientificConst5(const science_constant &chosen_const) {
1727  constants_->kcfg_valueConstant5->setText(chosen_const.value);
1728  constants_->kcfg_nameConstant5->setText(chosen_const.label);
1729 }
1730 
1731 //------------------------------------------------------------------------------
1732 // Name: slotSetSimpleMode
1733 // Desc: sets the calculator to have a simple layout
1734 //------------------------------------------------------------------------------
1735 void KCalculator::slotSetSimpleMode() {
1736 
1737  action_constants_show_->setChecked(false);
1738  action_constants_show_->setEnabled(false);
1739  action_bitset_show_->setChecked(false);
1740  action_bitset_show_->setEnabled(false);
1741  showMemButtons(false);
1742  showScienceButtons(false);
1743  showStatButtons(false);
1744  showLogicButtons(false);
1745 
1746  // hide some individual buttons, which are not in one of the above groups
1747  pbShift->hide();
1748  pbMod->hide();
1749  pbReci->hide();
1750  pbFactorial->hide();
1751  pbSquare->hide();
1752  pbPower->hide();
1753  pbCube->hide();
1754  pbBackspace->hide();
1755  pbEE->hide();
1756 
1757  // delete the constant menu since it doesn't fit
1758  delete constants_menu_;
1759  constants_menu_ = 0;
1760 
1761  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::simple);
1762 }
1763 
1764 //------------------------------------------------------------------------------
1765 // Name: slotSetScienceMode
1766 // Desc: sets the calculator to science mode
1767 //------------------------------------------------------------------------------
1768 void KCalculator::slotSetScienceMode() {
1769 
1770  action_constants_show_->setEnabled(true);
1771  action_constants_show_->setChecked(KCalcSettings::showConstants());
1772  action_bitset_show_->setChecked(false);
1773  action_bitset_show_->setEnabled(false);
1774 
1775  // show some individual buttons
1776  pbShift->show();
1777  pbMod->show();
1778  pbReci->show();
1779  pbFactorial->show();
1780  pbSquare->show();
1781  pbPower->show();
1782  pbCube->show();
1783  pbBackspace->show();
1784  pbEE->show();
1785 
1786  // show or hide some groups of buttons
1787  showMemButtons(true);
1788  showScienceButtons(true);
1789  showStatButtons(false);
1790  showLogicButtons(false);
1791 
1792  if(!constants_menu_) {
1793  constants_menu_ = createConstantsMenu();
1794  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
1795  }
1796 
1797  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::science);
1798 }
1799 
1800 //------------------------------------------------------------------------------
1801 // Name: slotSetStatisticMode
1802 // Desc: sets the calculator to stats mode
1803 //------------------------------------------------------------------------------
1804 void KCalculator::slotSetStatisticMode() {
1805 
1806  action_constants_show_->setEnabled(true);
1807  action_constants_show_->setChecked(KCalcSettings::showConstants());
1808  action_bitset_show_->setChecked(false);
1809  action_bitset_show_->setEnabled(false);
1810 
1811  // show some individual buttons
1812  pbShift->show();
1813  pbMod->show();
1814  pbReci->show();
1815  pbFactorial->show();
1816  pbSquare->show();
1817  pbPower->show();
1818  pbCube->show();
1819  pbBackspace->show();
1820  pbEE->show();
1821 
1822  // show or hide some groups of buttons
1823  showMemButtons(true);
1824  showScienceButtons(true);
1825  showStatButtons(true);
1826  showLogicButtons(false);
1827 
1828  if(!constants_menu_) {
1829  constants_menu_ = createConstantsMenu();
1830  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
1831  }
1832 
1833  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::statistics);
1834 }
1835 
1836 //------------------------------------------------------------------------------
1837 // Name: slotSetNumeralMode
1838 // Desc: sets the calculator to numerical ("programmers") mode
1839 //------------------------------------------------------------------------------
1840 void KCalculator::slotSetNumeralMode() {
1841 
1842  action_constants_show_->setChecked(false);
1843  action_constants_show_->setEnabled(false);
1844  action_bitset_show_->setEnabled(true);
1845  action_bitset_show_->setChecked(KCalcSettings::showBitset());
1846 
1847  // show some individual buttons
1848  pbShift->show();
1849  pbMod->show();
1850  pbReci->show();
1851  pbFactorial->show();
1852  pbSquare->show();
1853  pbPower->show();
1854  pbCube->show();
1855  pbBackspace->show();
1856  pbEE->show();
1857 
1858  // show or hide some groups of buttons
1859  showMemButtons(true);
1860  showScienceButtons(false);
1861  showStatButtons(false);
1862  showLogicButtons(true);
1863 
1864  if(!constants_menu_) {
1865  constants_menu_ = createConstantsMenu();
1866  menuBar()->insertMenu((menuBar()->actions)()[2], constants_menu_);
1867  }
1868 
1869  KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::numeral);
1870 }
1871 
1872 //------------------------------------------------------------------------------
1873 // Name: showMemButtons
1874 // Desc: hides or shows the memory buttons
1875 //------------------------------------------------------------------------------
1876 void KCalculator::showMemButtons(bool toggled) {
1877 
1878  if (toggled) {
1879  foreach(QAbstractButton *btn, mem_button_list_) {
1880  btn->show();
1881  }
1882  } else {
1883  foreach(QAbstractButton *btn, mem_button_list_) {
1884  btn->hide();
1885  }
1886 
1887  // these are in the mem_button_list_ but should not be hidden
1888  pbClear->show();
1889  pbAllClear->show();
1890  }
1891 }
1892 
1893 //------------------------------------------------------------------------------
1894 // Name: showStatButtons
1895 // Desc: hides or shows the stat buttons
1896 //------------------------------------------------------------------------------
1897 void KCalculator::showStatButtons(bool toggled) {
1898 
1899  if (toggled) {
1900  foreach(QAbstractButton *btn, stat_buttons_) {
1901  btn->show();
1902  }
1903  } else {
1904  foreach(QAbstractButton *btn, stat_buttons_) {
1905  btn->hide();
1906  }
1907  }
1908 }
1909 
1910 //------------------------------------------------------------------------------
1911 // Name: showScienceButtons
1912 // Desc: hides or shows the science buttons
1913 //------------------------------------------------------------------------------
1914 void KCalculator::showScienceButtons(bool toggled) {
1915 
1916  if (toggled) {
1917  foreach(QAbstractButton* btn, scientific_buttons_) {
1918  btn->show();
1919  }
1920 
1921  foreach(QAbstractButton* btn, angle_choose_group_->buttons()) {
1922  btn->show();
1923  }
1924 
1925  setAngle();
1926  statusBar()->setItemFixed(AngleField, -1);
1927  } else {
1928  foreach(QAbstractButton* btn, scientific_buttons_) {
1929  btn->hide();
1930  }
1931 
1932  foreach(QAbstractButton* btn, angle_choose_group_->buttons()) {
1933  btn->hide();
1934  }
1935 
1936  statusBar()->changeItem(QString(), AngleField);
1937  statusBar()->setItemFixed(AngleField, 0);
1938  calc_display->setStatusText(AngleField, QString());
1939  }
1940 }
1941 
1942 //------------------------------------------------------------------------------
1943 // Name: showLogicButtons
1944 // Desc: hides or shows the logic buttons
1945 //------------------------------------------------------------------------------
1946 void KCalculator::showLogicButtons(bool toggled) {
1947 
1948  if (toggled) {
1949  mBitset->setEnabled(true);
1950  connect(mBitset, SIGNAL(valueChanged(quint64)), this, SLOT(slotBitsetChanged(quint64)));
1951  connect(calc_display, SIGNAL(changedAmount(KNumber)), SLOT(slotUpdateBitset(KNumber)));
1952 
1953  foreach(QAbstractButton* btn, logic_buttons_) {
1954  btn->show();
1955  }
1956 
1957  setBase();
1958  statusBar()->setItemFixed(BaseField, -1);
1959 
1960  foreach(QAbstractButton *btn, base_choose_group_->buttons()) {
1961  btn->show();
1962  }
1963 
1964  for (int i = 10; i < 16; ++i) {
1965  (num_button_group_->button(i))->show();
1966  }
1967  } else {
1968  mBitset->setEnabled(false);
1969  disconnect(mBitset, SIGNAL(valueChanged(quint64)), this, SLOT(slotBitsetChanged(quint64)));
1970  disconnect(calc_display, SIGNAL(changedAmount(KNumber)), this, SLOT(slotUpdateBitset(KNumber)));
1971 
1972  foreach(QAbstractButton* btn, logic_buttons_) {
1973  btn->hide();
1974  }
1975 
1976  // Hide Hex-Buttons, but first switch back to decimal
1977  decRadio->animateClick(0);
1978 
1979  foreach(QAbstractButton *btn, base_choose_group_->buttons()) {
1980  btn->hide();
1981  }
1982 
1983  statusBar()->changeItem(QString(), BaseField);
1984  statusBar()->setItemFixed(BaseField, 0);
1985  calc_display->setStatusText(BaseField, QString());
1986  for (int i = 10; i < 16; ++i) {
1987  (num_button_group_->button(i))->hide();
1988  }
1989  }
1990 }
1991 
1992 //------------------------------------------------------------------------------
1993 // Name: slotConstantsShow
1994 // Desc: hides or shows the constants buttons
1995 //------------------------------------------------------------------------------
1996 void KCalculator::slotConstantsShow(bool toggled) {
1997 
1998  if (toggled) {
1999  foreach(QAbstractButton *btn, const_buttons_) {
2000  btn->show();
2001  }
2002  } else {
2003  foreach(QAbstractButton *btn, const_buttons_) {
2004  btn->hide();
2005  }
2006  }
2007 
2008  KCalcSettings::setShowConstants(toggled);
2009 }
2010 
2011 //------------------------------------------------------------------------------
2012 // Name: slotBitsetshow
2013 // Desc: hides or shows the bitset buttons
2014 //------------------------------------------------------------------------------
2015 void KCalculator::slotBitsetshow(bool toggled) {
2016 
2017  mBitset->setVisible(toggled);
2018  KCalcSettings::setShowBitset(toggled);
2019 }
2020 
2021 //------------------------------------------------------------------------------
2022 // Name: slotBitsetshow
2023 // Desc: This function is for setting the constant names configured in the
2024 // kcalc settings menu. If the user doesn't enter a name for the
2025 // constant C1 to C6 is used.
2026 //------------------------------------------------------------------------------
2027 void KCalculator::changeButtonNames() {
2028 
2029  foreach(QAbstractButton *btn, const_buttons_) {
2030  if (KCalcConstButton *const constbtn = qobject_cast<KCalcConstButton*>(btn)) {
2031  constbtn->setLabelAndTooltip();
2032  }
2033  }
2034 }
2035 
2036 //------------------------------------------------------------------------------
2037 // Name: slotBitsetChanged
2038 // Desc: updates the bitset display
2039 // NOTE: sets display to *unsigned* value
2040 //------------------------------------------------------------------------------
2041 void KCalculator::slotBitsetChanged(quint64 value) {
2042 
2043  calc_display->setAmount(KNumber(value));
2044  updateDisplay(0);
2045 }
2046 
2047 //------------------------------------------------------------------------------
2048 // Name: slotUpdateBitset
2049 // Desc: updates the bitset itself
2050 //------------------------------------------------------------------------------
2051 void KCalculator::slotUpdateBitset(const KNumber &nr) {
2052 
2053  mBitset->setValue(nr.toUint64());
2054 }
2055 
2056 //------------------------------------------------------------------------------
2057 // Name: updateSettings
2058 // Desc: updates the persistent settings
2059 //------------------------------------------------------------------------------
2060 void KCalculator::updateSettings() {
2061 
2062  changeButtonNames();
2063  setColors();
2064  setFonts();
2065  setPrecision();
2066 
2067  // Show the result in the app's caption in taskbar (wishlist - bug #52858)
2068  disconnect(calc_display, SIGNAL(changedText(QString)), this, 0);
2069 
2070  if (KCalcSettings::captionResult()) {
2071  connect(calc_display, SIGNAL(changedText(QString)), SLOT(setCaption(QString)));
2072  } else {
2073  setCaption(QString());
2074  }
2075 
2076  calc_display->changeSettings();
2077  updateGeometry();
2078 }
2079 
2080 //------------------------------------------------------------------------------
2081 // Name: updateDisplay
2082 // Desc: updates the display
2083 //------------------------------------------------------------------------------
2084 void KCalculator::updateDisplay(UpdateFlags flags) {
2085 
2086  if(flags & UPDATE_FROM_CORE) {
2087  calc_display->updateFromCore(core, (flags & UPDATE_STORE_RESULT) != 0);
2088  } else {
2089  calc_display->update();
2090  }
2091 
2092  pbShift->setChecked(false);
2093 
2094 }
2095 
2096 //------------------------------------------------------------------------------
2097 // Name: setColors
2098 // Desc: set the various colours
2099 //------------------------------------------------------------------------------
2100 void KCalculator::setColors() {
2101 
2102  calc_display->changeSettings();
2103 
2104  KColorScheme schemeButtons(QPalette::Active, KColorScheme::Button);
2105  const QColor defaultColor = schemeButtons.background().color();
2106 
2107  if (KCalcSettings::numberButtonsColor() == defaultColor
2108  && KCalcSettings::functionButtonsColor() == defaultColor
2109  && KCalcSettings::statButtonsColor() == defaultColor
2110  && KCalcSettings::hexButtonsColor() == defaultColor
2111  && KCalcSettings::memoryButtonsColor() == defaultColor
2112  && KCalcSettings::operationButtonsColor() == defaultColor) {
2113  return;
2114  }
2115 
2116  const QString sheet = QLatin1String("KPushButton { background-color: %1 }");
2117 
2118  const QColor numPal(KCalcSettings::numberButtonsColor());
2119  for (int i = 0; i < 10; ++i) {
2120  (num_button_group_->button(i))->setStyleSheet(sheet.arg(numPal.name()));
2121  }
2122 
2123  const QColor funcPal(KCalcSettings::functionButtonsColor());
2124  foreach(QAbstractButton *btn, function_button_list_) {
2125  btn->setStyleSheet(sheet.arg(funcPal.name()));
2126  }
2127 
2128  const QColor statPal(KCalcSettings::statButtonsColor());
2129  foreach(QAbstractButton *btn, stat_buttons_) {
2130  btn->setStyleSheet(sheet.arg(statPal.name()));
2131  }
2132 
2133  const QColor hexPal(KCalcSettings::hexButtonsColor());
2134  for (int i = 10; i < 16; ++i) {
2135  (num_button_group_->button(i))->setStyleSheet(sheet.arg(hexPal.name()));
2136  }
2137 
2138  const QColor memPal(KCalcSettings::memoryButtonsColor());
2139  foreach(QAbstractButton *btn, mem_button_list_) {
2140  btn->setStyleSheet(sheet.arg(memPal.name()));
2141  }
2142 
2143  const QColor opPal(KCalcSettings::operationButtonsColor());
2144  foreach(QAbstractButton *btn, operation_button_list_) {
2145  btn->setStyleSheet(sheet.arg(opPal.name()));
2146  }
2147 }
2148 
2149 //------------------------------------------------------------------------------
2150 // Name: setFonts
2151 // Desc: set the various fonts
2152 //------------------------------------------------------------------------------
2153 void KCalculator::setFonts() {
2154 
2155  foreach(QObject *obj, leftPad->children()) {
2156  if (KCalcButton *const button = qobject_cast<KCalcButton*>(obj)) {
2157  button->setFont(KCalcSettings::buttonFont());
2158  }
2159  }
2160 
2161  foreach(QObject *obj, numericPad->children()) {
2162  if (KCalcButton *const button = qobject_cast<KCalcButton*>(obj)) {
2163  button->setFont(KCalcSettings::buttonFont());
2164  }
2165  }
2166 
2167  foreach(QObject *obj, rightPad->children()) {
2168  if (KCalcButton *const button = qobject_cast<KCalcButton*>(obj)) {
2169  button->setFont(KCalcSettings::buttonFont());
2170  }
2171  }
2172 
2173  updateGeometry();
2174 }
2175 
2176 //------------------------------------------------------------------------------
2177 // Name: setPrecision
2178 // Desc: set the precision of the display
2179 //------------------------------------------------------------------------------
2180 void KCalculator::setPrecision() {
2181 
2182  KNumber::setDefaultFloatPrecision(KCalcSettings::precision());
2183  updateDisplay(0);
2184 }
2185 
2186 //------------------------------------------------------------------------------
2187 // Name: setAngle
2188 // Desc: sets the angle mode
2189 //------------------------------------------------------------------------------
2190 void KCalculator::setAngle() {
2191 
2192  if (QAbstractButton *const btn = angle_choose_group_->button(KCalcSettings::angleMode())) {
2193  btn->animateClick(0);
2194  }
2195 }
2196 
2197 //------------------------------------------------------------------------------
2198 // Name: setBase
2199 // Desc: sets the numeric base
2200 //------------------------------------------------------------------------------
2201 void KCalculator::setBase() {
2202  if (QAbstractButton *const btn = base_choose_group_->button(KCalcSettings::baseMode())) {
2203  btn->animateClick(0);
2204  }
2205 }
2206 
2207 //------------------------------------------------------------------------------
2208 // Name: eventFilter
2209 // Desc: general event filter used to track events like drag/drop
2210 //------------------------------------------------------------------------------
2211 bool KCalculator::eventFilter(QObject *o, QEvent *e) {
2212 
2213  switch (e->type()) {
2214  case QEvent::DragEnter: {
2215  QDragEnterEvent *const ev = reinterpret_cast<QDragEnterEvent *>(e);
2216  ev->setAccepted(KColorMimeData::canDecode(ev->mimeData()));
2217  return true;
2218  }
2219  case QEvent::DragLeave: {
2220  return true;
2221  }
2222  case QEvent::Drop: {
2223  KCalcButton *const calcButton = qobject_cast<KCalcButton *>(o);
2224  if (!calcButton) {
2225  return false;
2226  }
2227 
2228  QDropEvent *const ev = reinterpret_cast<QDropEvent *>(e);
2229  QColor c = KColorMimeData::fromMimeData(ev->mimeData());
2230 
2231  if (c.isValid()) {
2232  QString cn = c.name();
2233  QString sheet = QLatin1String("background-color: %1");
2234 
2235  QList<QAbstractButton*> *list;
2236  const int num_but = num_button_group_->buttons().indexOf(calcButton);
2237  if (num_but != -1) {
2238  // Was it hex-button or normal digit??
2239  if (num_but < 10) {
2240  for (int i = 0; i < 10; ++i) {
2241  (num_button_group_->buttons()[i])->setStyleSheet(sheet.arg(cn));
2242  }
2243  } else {
2244  for (int i = 10; i < 16; ++i) {
2245  (num_button_group_->buttons()[i])->setStyleSheet(sheet.arg(cn));
2246  }
2247  }
2248  return true;
2249  } else if (function_button_list_.contains(calcButton)) {
2250  list = &function_button_list_;
2251  } else if (stat_button_list_.contains(calcButton)) {
2252  list = &stat_button_list_;
2253  } else if (mem_button_list_.contains(calcButton)) {
2254  list = &mem_button_list_;
2255  } else if (operation_button_list_.contains(calcButton)) {
2256  list = &operation_button_list_;
2257  } else {
2258  return false;
2259  }
2260 
2261  for (int i = 0; i < list->size(); ++i) {
2262  list->at(i)->setStyleSheet(sheet.arg(cn));
2263  }
2264  }
2265  return true;
2266  }
2267  // FALL THROUGH
2268  default:
2269  return KXmlGuiWindow::eventFilter(o, e);
2270  }
2271 }
2272 
2274 // Include the meta-object code for classes in this file
2275 //
2276 #include "kcalc.moc"
2277 
2278 //------------------------------------------------------------------------------
2279 // Name: kdemain
2280 // Desc: entry point of the application
2281 //------------------------------------------------------------------------------
2282 extern "C" KDE_EXPORT int kdemain(int argc, char *argv[]) {
2283 
2284  KAboutData aboutData("kcalc",
2285  0,
2286  ki18n("KCalc"),
2287  version,
2288  ki18n(description),
2289  KAboutData::License_GPL,
2290  ki18n(
2291  "&copy; 2008-2013, Evan Teran\n"
2292  "&copy; 2000-2008, The KDE Team\n"
2293  "&copy; 2003-2005, Klaus Niederkr" "\xc3\xbc" "ger\n"
2294  "&copy; 1996-2000, Bernd Johannes Wuebben"),
2295  KLocalizedString(),
2296  "http://utils.kde.org/projects/kcalc");
2297 
2298  // Klaus Niederkrueger
2299  aboutData.addAuthor(ki18n("Klaus Niederkr" "\xc3\xbc" "ger"), KLocalizedString(), "kniederk@math.uni-koeln.de");
2300  aboutData.addAuthor(ki18n("Bernd Johannes Wuebben"), KLocalizedString(), "wuebben@kde.org");
2301  aboutData.addAuthor(ki18n("Evan Teran"), ki18n("Maintainer"), "eteran@alum.rit.edu");
2302  aboutData.addAuthor(ki18n("Espen Sand"), KLocalizedString(), "espen@kde.org");
2303  aboutData.addAuthor(ki18n("Chris Howells"), KLocalizedString(), "howells@kde.org");
2304  aboutData.addAuthor(ki18n("Aaron J. Seigo"), KLocalizedString(), "aseigo@olympusproject.org");
2305  aboutData.addAuthor(ki18n("Charles Samuels"), KLocalizedString(), "charles@altair.dhs.org");
2306  // Rene Merou
2307  aboutData.addAuthor(ki18n("Ren" "\xc3\xa9" " M" "\xc3\xa9" "rou"), KLocalizedString(), "ochominutosdearco@yahoo.es");
2308  aboutData.addAuthor(ki18n("Michel Marti"), KLocalizedString(), "mma@objectxp.com");
2309  aboutData.addAuthor(ki18n("David Johnson"), KLocalizedString(), "david@usermode.org");
2310 
2311  aboutData.setProgramIconName(QLatin1String("accessories-calculator"));
2312 
2313  KCmdLineArgs::init(argc, argv, &aboutData);
2314 
2315  KApplication app;
2316 
2317  // force system locale to "C" internally [bug 159168]
2318  setlocale(LC_NUMERIC, "C");
2319 
2320  KNumber::setGroupSeparator(KGlobal::locale()->thousandsSeparator());
2321  KNumber::setDecimalSeparator(KGlobal::locale()->decimalSymbol());
2322 
2323  KCalculator *calc = new KCalculator(0);
2324  app.setTopWidget(calc);
2325 
2326  calc->show();
2327  return app.exec();
2328 }
CalcEngine::CosGrad
void CosGrad(const KNumber &input)
Definition: kcalc_core.cpp:443
KCalcDisplay::EventReset
Definition: kcalcdisplay.h:68
CalcEngine::Square
void Square(const KNumber &input)
Definition: kcalc_core.cpp:677
CalcEngine::Complement
void Complement(const KNumber &input)
Definition: kcalc_core.cpp:394
KCalcSettings::operationButtonsColor
static QColor operationButtonsColor()
Get The color of operation buttons.
Definition: kcalc_settings.h:172
KCalculator::slotSetStatisticMode
void slotSetStatisticMode()
Definition: kcalc.cpp:1804
QWidget::setStyleSheet
void setStyleSheet(const QString &styleSheet)
QEvent
QWidget
KCalcSettings::statButtonsColor
static QColor statButtonsColor()
Get The color of statistical buttons.
Definition: kcalc_settings.h:115
QKeyEvent::modifiers
Qt::KeyboardModifiers modifiers() const
KCalcSettings::setBaseMode
static void setBaseMode(uint v)
Set Numeric base.
Definition: kcalc_settings.h:440
KCalculator::slotNegateclicked
void slotNegateclicked()
Definition: kcalc.cpp:1448
QEvent::type
Type type() const
CalcEngine::SquareRoot
void SquareRoot(const KNumber &input)
Definition: kcalc_core.cpp:682
KCalculator::slotChooseScientificConst4
void slotChooseScientificConst4(const science_constant &)
Definition: kcalc.cpp:1717
CalcEngine::AreaSinHyp
void AreaSinHyp(const KNumber &input)
Definition: kcalc_core.cpp:356
KCalcSettings::setShowConstants
static void setShowConstants(bool v)
Set Whether to show constant buttons.
Definition: kcalc_settings.h:402
QSize::width
int width() const
CalcEngine::CosDeg
void CosDeg(const KNumber &input)
Definition: kcalc_core.cpp:404
KCalcSettings::memoryButtonsColor
static QColor memoryButtonsColor()
Get The color of memory buttons.
Definition: kcalc_settings.h:153
CalcEngine::enterOperation
void enterOperation(const KNumber &num, Operation func)
Definition: kcalc_core.cpp:825
General
Definition: kcalc.h:62
QDropEvent::mimeData
const QMimeData * mimeData() const
Colors
Definition: kcalc.h:86
QActionGroup
CalcEngine::StatSumSquares
void StatSumSquares(const KNumber &input)
Definition: kcalc_core.cpp:750
KCalculator::slotBitsetChanged
void slotBitsetChanged(quint64)
Definition: kcalc.cpp:2041
KCalculator::slotRightShiftclicked
void slotRightShiftclicked()
Definition: kcalc.cpp:1397
QColor::name
QString name() const
KCalcSettings::showBitset
static bool showBitset()
Get Whether to show the bit edit widget.
Definition: kcalc_settings.h:393
CalcEngine::TangensDeg
void TangensDeg(const KNumber &input)
Definition: kcalc_core.cpp:758
QButtonGroup::addButton
void addButton(QAbstractButton *button)
KCalculator::slotORclicked
void slotORclicked()
Definition: kcalc.cpp:1347
CalcEngine::Reset
void Reset()
Definition: kcalc_core.cpp:878
KNumber::decimalSeparator
static QString decimalSeparator()
Definition: knumber.cpp:203
KCALCVERSION
#define KCALCVERSION
Definition: version.h:20
KCalculator::slotStatStdDevclicked
void slotStatStdDevclicked()
Definition: kcalc.cpp:1505
KNumber::setGroupSeparator
static void setGroupSeparator(const QString &ch)
Definition: knumber.cpp:182
CalcEngine::FUNC_INTDIV
Definition: kcalc_core.h:46
KNumber::Zero
static const KNumber Zero
Definition: knumber.h:49
QStyle::pixelMetric
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const =0
KCalculator::slotConstantsShow
void slotConstantsShow(bool toggled)
Definition: kcalc.cpp:1996
CalcEngine::Reciprocal
void Reciprocal(const KNumber &input)
Definition: kcalc_core.cpp:592
CalcEngine::TangensHyp
void TangensHyp(const KNumber &input)
Definition: kcalc_core.cpp:803
QList::at
const T & at(int i) const
KCalculator::showSettings
void showSettings()
Definition: kcalc.cpp:1608
QObject::children
const QObjectList & children() const
CalcEngine::CubeRoot
void CubeRoot(const KNumber &input)
Definition: kcalc_core.cpp:491
KCalculator::slotPercentclicked
void slotPercentclicked()
Definition: kcalc.cpp:1437
KCalcSettings::hexButtonsColor
static QColor hexButtonsColor()
Get The color of hex buttons.
Definition: kcalc_settings.h:134
KCalcSettings::EnumCalculatorMode::simple
Definition: kcalc_settings.h:19
CalcEngine::ParenOpen
void ParenOpen(const KNumber &input)
Definition: kcalc_core.cpp:587
CalcEngine::FUNC_SUBTRACT
Definition: kcalc_core.h:42
CalcEngine::Exp
void Exp(const KNumber &input)
Definition: kcalc_core.cpp:496
KCalcSettings::EnumCalculatorMode::science
Definition: kcalc_settings.h:19
KCalculator::slotConstantToDisplay
void slotConstantToDisplay(const science_constant &const_chosen)
Definition: kcalc.cpp:745
KCalculator::slotLogclicked
void slotLogclicked()
Definition: kcalc.cpp:1177
KCalcSettings::functionButtonsColor
static QColor functionButtonsColor()
Get The color of function buttons.
Definition: kcalc_settings.h:96
KCalculator::slotBackspaceclicked
void slotBackspaceclicked()
Definition: kcalc.cpp:1269
CalcEngine::SinRad
void SinRad(const KNumber &input)
Definition: kcalc_core.cpp:626
CalcEngine::StatMedian
void StatMedian(const KNumber &input)
Definition: kcalc_core.cpp:720
CalcEngine::FUNC_RSH
Definition: kcalc_core.h:40
KCalculator::slotStatClearDataclicked
void slotStatClearDataclicked()
Definition: kcalc.cpp:1559
kcalcdisplay.h
QButtonGroup::button
QAbstractButton * button(int id) const
KCalculator::~KCalculator
~KCalculator()
Definition: kcalc.cpp:175
KCalculator::slotStatDataInputclicked
void slotStatDataInputclicked()
Definition: kcalc.cpp:1542
CalcEngine::TangensRad
void TangensRad(const KNumber &input)
Definition: kcalc_core.cpp:773
kcalc_const_menu.h
KCalculator::slotModclicked
void slotModclicked()
Definition: kcalc.cpp:1458
KCalculator::slotStatNumclicked
void slotStatNumclicked()
Definition: kcalc.cpp:1473
KCalculator::slotFactorialclicked
void slotFactorialclicked()
Definition: kcalc.cpp:1158
KCalculator::slotDivisionclicked
void slotDivisionclicked()
Definition: kcalc.cpp:1337
CalcEngine::StatMean
void StatMean(const KNumber &input)
Definition: kcalc_core.cpp:712
QList::size
int size() const
QButtonGroup
ButtonModeFlags
ButtonModeFlags
Definition: kcalc_button.h:36
KCalculator::slotMultiplicationclicked
void slotMultiplicationclicked()
Definition: kcalc.cpp:1327
CalcEngine::FUNC_DIVIDE
Definition: kcalc_core.h:44
CalcEngine::FUNC_PERCENT
Definition: kcalc_core.h:34
KCalcConstMenu::init_consts
static void init_consts()
Definition: kcalc_const_menu.cpp:61
QList::indexOf
int indexOf(const T &value, int from) const
ModeNormal
Definition: kcalc_button.h:37
CalcEngine::FUNC_MULTIPLY
Definition: kcalc_core.h:43
KCalculator::slotStatMedianclicked
void slotStatMedianclicked()
Definition: kcalc.cpp:1523
KNumber::setDefaultFloatPrecision
static void setDefaultFloatPrecision(int precision)
Definition: knumber.cpp:210
NumBase
NumBase
Definition: kcalcdisplay.h:52
CalcEngine::Cube
void Cube(const KNumber &input)
Definition: kcalc_core.cpp:486
CalcEngine::SinHyp
void SinHyp(const KNumber &input)
Definition: kcalc_core.cpp:665
KCalculator::slotANDclicked
void slotANDclicked()
Definition: kcalc.cpp:1317
CalcEngine::StatStdSample
void StatStdSample(const KNumber &input)
Definition: kcalc_core.cpp:736
KCalculator::slotPlusclicked
void slotPlusclicked()
Definition: kcalc.cpp:1367
CalcEngine::SinDeg
void SinDeg(const KNumber &input)
Definition: kcalc_core.cpp:598
science_constant
Definition: kcalc_const_menu.h:36
CalcEngine::ArcCosGrad
void ArcCosGrad(const KNumber &input)
Definition: kcalc_core.cpp:217
QWidget::setEnabled
void setEnabled(bool)
CalcEngine::ArcSinDeg
void ArcSinDeg(const KNumber &input)
Definition: kcalc_core.cpp:240
QList::append
void append(const T &value)
QString::fromUtf8
QString fromUtf8(const char *str, int size)
QEvent::setAccepted
void setAccepted(bool accepted)
KXmlGuiWindow
CalcEngine::ArcTangensDeg
void ArcTangensDeg(const KNumber &input)
Definition: kcalc_core.cpp:298
KCalcSettings::setAngleMode
static void setAngleMode(uint v)
Set Degrees, radians or grads.
Definition: kcalc_settings.h:421
KCalcSettings::EnumCalculatorMode::statistics
Definition: kcalc_settings.h:19
CalcEngine::ArcCosDeg
void ArcCosDeg(const KNumber &input)
Definition: kcalc_core.cpp:184
CalcEngine::SinGrad
void SinGrad(const KNumber &input)
Definition: kcalc_core.cpp:636
QWidget::setLayoutDirection
void setLayoutDirection(Qt::LayoutDirection direction)
CalcEngine::FUNC_BINOM
Definition: kcalc_core.h:47
CalcEngine::FUNC_AND
Definition: kcalc_core.h:38
KCalculator::slotSinclicked
void slotSinclicked()
Definition: kcalc.cpp:967
KCalculator::slotChooseScientificConst5
void slotChooseScientificConst5(const science_constant &)
Definition: kcalc.cpp:1726
science_constant::label
QString label
Definition: kcalc_const_menu.h:37
KCalcSettings::EnumCalculatorMode::type
type
Definition: kcalc_settings.h:19
KCalcSettings::setShowBitset
static void setShowBitset(bool v)
Set Whether to show the bit edit widget.
Definition: kcalc_settings.h:383
Constants
Definition: kcalc.h:78
QObject
CalcEngine::CosHyp
void CosHyp(const KNumber &input)
Definition: kcalc_core.cpp:470
KCalculator::slotMemStoreclicked
void slotMemStoreclicked()
Definition: kcalc.cpp:944
QButtonGroup::setExclusive
void setExclusive(bool)
KCalculator::switchShowAccels
void switchShowAccels(bool)
QDropEvent
CalcEngine::FUNC_LSH
Definition: kcalc_core.h:39
KCalculator::slotParenCloseclicked
void slotParenCloseclicked()
Definition: kcalc.cpp:1307
NB_DECIMAL
Definition: kcalcdisplay.h:55
KCalculator::slotConstclicked
void slotConstclicked(int)
Definition: kcalc.cpp:1574
KCalculator::slotMinusclicked
void slotMinusclicked()
Definition: kcalc.cpp:1377
QApplication::setOverrideCursor
void setOverrideCursor(const QCursor &cursor)
KCalculator::slotLeftShiftclicked
void slotLeftShiftclicked()
Definition: kcalc.cpp:1387
KCalculator::slotSetNumeralMode
void slotSetNumeralMode()
Definition: kcalc.cpp:1840
QApplication::restoreOverrideCursor
void restoreOverrideCursor()
KCalculator::slotAngleSelected
void slotAngleSelected(int mode)
Definition: kcalc.cpp:864
CalcEngine::AreaTangensHyp
void AreaTangensHyp(const KNumber &input)
Definition: kcalc_core.cpp:372
CalcEngine::FUNC_XOR
Definition: kcalc_core.h:37
QShortcut
KCalcSettings::numberButtonsColor
static QColor numberButtonsColor()
Get The color of number buttons.
Definition: kcalc_settings.h:77
QString
QList< QAbstractButton * >
QWidget::hide
void hide()
QColor
ModeHyperbolic
Definition: kcalc_button.h:39
CalcEngine::CosRad
void CosRad(const KNumber &input)
Definition: kcalc_core.cpp:433
CalcEngine::Log10
void Log10(const KNumber &input)
Definition: kcalc_core.cpp:561
CalcEngine::StatSum
void StatSum(const KNumber &input)
Definition: kcalc_core.cpp:744
CalcEngine::Factorial
void Factorial(const KNumber &input)
Definition: kcalc_core.cpp:519
KCalculator::slotChooseScientificConst0
void slotChooseScientificConst0(const science_constant &)
Definition: kcalc.cpp:1681
KCalcConstMenu
Definition: kcalc_const_menu.h:44
ModeShift
Definition: kcalc_button.h:38
KCalculator::changeButtonNames
void changeButtonNames()
Definition: kcalc.cpp:2027
CalcEngine::ArcSinGrad
void ArcSinGrad(const KNumber &input)
Definition: kcalc_core.cpp:274
KCalculator::slotCubeclicked
void slotCubeclicked()
Definition: kcalc.cpp:1207
CalcEngine::ArcSinRad
void ArcSinRad(const KNumber &input)
Definition: kcalc_core.cpp:264
CalcEngine::StatClearAll
void StatClearAll(const KNumber &input)
Definition: kcalc_core.cpp:687
KCalculator::slotTanclicked
void slotTanclicked()
Definition: kcalc.cpp:1113
KCalcSettings::EnumCalculatorMode::numeral
Definition: kcalc_settings.h:19
KCalcSettings::buttonFont
static QFont buttonFont()
Get The font to use for the buttons.
Definition: kcalc_settings.h:191
KNumber
Definition: knumber.h:30
QKeyEvent::key
int key() const
CalcEngine::AreaCosHyp
void AreaCosHyp(const KNumber &input)
Definition: kcalc_core.cpp:336
Fonts
Definition: kcalc.h:70
kcalc_settings.h
KCalculator::KCalculator
KCalculator(QWidget *parent=0)
Definition: kcalc.cpp:76
QSize
QLatin1Char
CalcEngine::FUNC_PWR_ROOT
Definition: kcalc_core.h:49
QList::contains
bool contains(const T &value) const
KCalculator::slotEEclicked
void slotEEclicked()
Definition: kcalc.cpp:892
CalcEngine::TangensGrad
void TangensGrad(const KNumber &input)
Definition: kcalc_core.cpp:788
KCalculator::slotAllClearclicked
void slotAllClearclicked()
Definition: kcalc.cpp:1287
KCalculator::slotMemClearclicked
void slotMemClearclicked()
Definition: kcalc.cpp:1257
version.h
KCalculator::slotLnclicked
void slotLnclicked()
Definition: kcalc.cpp:1222
CalcEngine::FUNC_EQUAL
Definition: kcalc_core.h:33
KCalcSettings::setCalculatorMode
static void setCalculatorMode(EnumCalculatorMode::type v)
Set CalculatorMode.
Definition: kcalc_settings.h:364
KNumber::toUint64
quint64 toUint64() const
Definition: knumber.cpp:638
QString::replace
QString & replace(int position, int n, QChar after)
kdemain
KDE_EXPORT int kdemain(int argc, char *argv[])
Definition: kcalc.cpp:2282
QKeyEvent
QAbstractButton
KCalculator::slotPowerclicked
void slotPowerclicked()
Definition: kcalc.cpp:1237
KNumber::setDecimalSeparator
static void setDecimalSeparator(const QString &ch)
Definition: knumber.cpp:189
KCalcSettings::calculatorMode
static EnumCalculatorMode::type calculatorMode()
Get CalculatorMode.
Definition: kcalc_settings.h:374
KCalcSettings::setValueConstant
static void setValueConstant(int i, const QString &v)
Set List of user programmable constants.
Definition: kcalc_settings.h:535
CalcEngine::FUNC_ADD
Definition: kcalc_core.h:41
kcalc.h
QDragEnterEvent
QButtonGroup::buttons
QList< QAbstractButton * > buttons() const
KCalcSettings::showConstants
static bool showConstants()
Get Whether to show constant buttons.
Definition: kcalc_settings.h:412
QApplication::style
QStyle * style()
QLatin1String
KCalculator::EnterEqual
void EnterEqual()
Definition: kcalc.cpp:1418
QKeySequence
CalcEngine::StatDataDel
void StatDataDel(const KNumber &input)
Definition: kcalc_core.cpp:705
KCalcDisplay::EventClear
Definition: kcalcdisplay.h:69
CalcEngine::ParenClose
void ParenClose(KNumber input)
Definition: kcalc_core.cpp:574
CalcEngine::Gamma
void Gamma(const KNumber &input)
Definition: kcalc_core.cpp:531
KCalculator::slotEqualclicked
void slotEqualclicked()
Definition: kcalc.cpp:1428
KCalculator::slotBaseSelected
void slotBaseSelected(int base)
Definition: kcalc.cpp:757
KCalculator::slotSetScienceMode
void slotSetScienceMode()
Definition: kcalc.cpp:1768
CalcEngine::FUNC_OR
Definition: kcalc_core.h:36
KCalculator::setFonts
void setFonts()
Definition: kcalc.cpp:2153
KCalculator::slotStatMeanclicked
void slotStatMeanclicked()
Definition: kcalc.cpp:1489
KCalcSettings::precision
static uint precision()
Get Maximum number of digits displayed.
Definition: kcalc_settings.h:241
CalcEngine::ArcCosRad
void ArcCosRad(const KNumber &input)
Definition: kcalc_core.cpp:208
KCalculator::slotChooseScientificConst1
void slotChooseScientificConst1(const science_constant &)
Definition: kcalc.cpp:1690
KCalcButton::setFont
void setFont(const QFont &fnt)
Definition: kcalc_button.cpp:215
CalcEngine::ArcTangensRad
void ArcTangensRad(const KNumber &input)
Definition: kcalc_core.cpp:310
KCalculator::slotSquareclicked
void slotSquareclicked()
Definition: kcalc.cpp:1192
KCalculator::setColors
void setColors()
Definition: kcalc.cpp:2100
KCalculator::switchMode
void switchMode(ButtonModeFlags, bool)
KCalcSettings::baseMode
static uint baseMode()
Get Numeric base.
Definition: kcalc_settings.h:450
KCalculator::UPDATE_FROM_CORE
Definition: kcalc.h:110
KCalculator::slotClearclicked
void slotClearclicked()
Definition: kcalc.cpp:1278
science_constant::value
QString value
Definition: kcalc_const_menu.h:40
KCalculator::slotParenOpenclicked
void slotParenOpenclicked()
Definition: kcalc.cpp:1298
KCalcDisplay::EventChangeSign
Definition: kcalcdisplay.h:71
KCalcSettings::angleMode
static uint angleMode()
Get Degrees, radians or grads.
Definition: kcalc_settings.h:431
KCalculator::slotChooseScientificConst2
void slotChooseScientificConst2(const science_constant &)
Definition: kcalc.cpp:1699
QWidget::show
void show()
KCalculator::slotPeriodclicked
void slotPeriodclicked()
Definition: kcalc.cpp:1407
CalcEngine::FUNC_POWER
Definition: kcalc_core.h:48
KCalculator::slotChooseScientificConst3
void slotChooseScientificConst3(const science_constant &)
Definition: kcalc.cpp:1708
KCalculator::updateSettings
void updateSettings()
Definition: kcalc.cpp:2060
KCalcConstButton
Definition: kcalc_const_button.h:30
KCalculator::slotCosclicked
void slotCosclicked()
Definition: kcalc.cpp:1047
KCalculator::slotBitsetshow
void slotBitsetshow(bool toggled)
Definition: kcalc.cpp:2015
KCalculator::slotPlusMinusclicked
void slotPlusMinusclicked()
Definition: kcalc.cpp:1012
KCalculator::slotUpdateBitset
void slotUpdateBitset(const KNumber &)
Definition: kcalc.cpp:2051
CalcEngine::InvertSign
void InvertSign(const KNumber &input)
Definition: kcalc_core.cpp:543
CalcEngine::StatStdDeviation
void StatStdDeviation(const KNumber &input)
Definition: kcalc_core.cpp:728
CalcEngine::StatDataNew
void StatDataNew(const KNumber &input)
Definition: kcalc_core.cpp:699
QCursor
KCalculator::slotReciclicked
void slotReciclicked()
Definition: kcalc.cpp:1092
KCalculator::slotMemRecallclicked
void slotMemRecallclicked()
Definition: kcalc.cpp:931
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
KCalculator::slotMemPlusMinusclicked
void slotMemPlusMinusclicked()
Definition: kcalc.cpp:1026
KCalcSettings::captionResult
static bool captionResult()
Get Whether to show the result in the window title.
Definition: kcalc_settings.h:317
KCalculator::slotHyptoggled
void slotHyptoggled(bool flag)
Definition: kcalc.cpp:919
KCalcSettings::self
static KCalcSettings * self()
Definition: kcalc_settings.cpp:17
kcalc_bitset.h
KCalculator::slotNumberclicked
void slotNumberclicked(int number_clicked)
Definition: kcalc.cpp:958
KCalculator
Definition: kcalc.h:95
QAbstractButton::animateClick
void animateClick(int msec)
CalcEngine::Exp10
void Exp10(const KNumber &input)
Definition: kcalc_core.cpp:507
CalcEngine::StatCount
void StatCount(const KNumber &input)
Definition: kcalc_core.cpp:693
KCalculator::slotXORclicked
void slotXORclicked()
Definition: kcalc.cpp:1357
CalcEngine::FUNC_MOD
Definition: kcalc_core.h:45
QColor::isValid
bool isValid() const
KCalculator::slotShifttoggled
void slotShifttoggled(bool myboolean)
Definition: kcalc.cpp:900
CalcEngine::ArcTangensGrad
void ArcTangensGrad(const KNumber &input)
Definition: kcalc_core.cpp:324
KCalcButton
Definition: kcalc_button.h:58
KCalculator::slotSetSimpleMode
void slotSetSimpleMode()
Definition: kcalc.cpp:1735
KCalculator::UPDATE_STORE_RESULT
Definition: kcalc.h:111
CalcEngine::Ln
void Ln(const KNumber &input)
Definition: kcalc_core.cpp:548
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcalc

Skip menu "kcalc"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal