diff -urN kcalc-19.12.3/CMakeLists.txt kcalc-19.12.4/CMakeLists.txt --- kcalc-19.12.3/CMakeLists.txt 2020-03-02 21:15:28.000000000 -0300 +++ kcalc-19.12.4/CMakeLists.txt 2021-03-13 11:24:04.826137926 -0300 @@ -3,7 +3,7 @@ # KDE Application Version, managed by release script set (KDE_APPLICATIONS_VERSION_MAJOR "19") set (KDE_APPLICATIONS_VERSION_MINOR "12") -set (KDE_APPLICATIONS_VERSION_MICRO "3") +set (KDE_APPLICATIONS_VERSION_MICRO "4") set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") project(kcalc VERSION ${KDE_APPLICATIONS_VERSION}) diff -urN kcalc-19.12.3/bitbutton.cpp kcalc-19.12.4/bitbutton.cpp --- kcalc-19.12.3/bitbutton.cpp 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/bitbutton.cpp 2021-02-28 02:17:57.000000000 -0300 @@ -42,7 +42,7 @@ size.setWidth(size.height()); } - setFixedSize(size.expandedTo(QApplication::globalStrut())); + setFixedSize(size); this->setAttribute(Qt::WA_Hover, true); } diff -urN kcalc-19.12.3/kcalc.cpp kcalc-19.12.4/kcalc.cpp --- kcalc-19.12.3/kcalc.cpp 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/kcalc.cpp 2021-02-28 02:17:57.000000000 -0300 @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -44,7 +45,7 @@ #include #include #include -#include +#include #include #include @@ -98,7 +99,7 @@ base_choose_group_->addButton(decRadio, DecMode); base_choose_group_->addButton(octRadio, OctMode); base_choose_group_->addButton(binRadio, BinMode); - connect(base_choose_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalculator::slotBaseSelected); + connect(base_choose_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalculator::slotBaseSelected); base_conversion_labels_ = { binDisplay, hexDisplay, decDisplay, octDisplay }; @@ -107,7 +108,7 @@ angle_choose_group_->addButton(degRadio, DegMode); angle_choose_group_->addButton(radRadio, RadMode); angle_choose_group_->addButton(gradRadio, GradMode); - connect(angle_choose_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalculator::slotAngleSelected); + connect(angle_choose_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalculator::slotAngleSelected); // additional menu setup constants_menu_ = createConstantsMenu(); @@ -178,7 +179,7 @@ KStandardAction::redo(calc_display, SLOT(slotHistoryForward()), actionCollection()); KStandardAction::cut(calc_display, SLOT(slotCut()), actionCollection()); KStandardAction::copy(calc_display, SLOT(slotCopy()), actionCollection()); - KStandardAction::paste(calc_display, SLOT(slotPaste()), actionCollection()); + KStandardAction::paste(this, SLOT(slotPaste()), actionCollection()); // mode menu QActionGroup *modeGroup = new QActionGroup(this); @@ -245,7 +246,7 @@ void KCalculator::setupNumberKeys() { num_button_group_ = new QButtonGroup(this); - connect(num_button_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalculator::slotNumberclicked); + connect(num_button_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalculator::slotNumberclicked); num_button_group_->addButton(pb0, 0); num_button_group_->addButton(pb1, 1); @@ -654,6 +655,7 @@ mem_button_list_.append(pbMemClear); mem_button_list_.append(pbClear); mem_button_list_.append(pbAllClear); + mem_button_list_.append(pbBackspace); operation_button_list_.append(pbMultiplication); operation_button_list_.append(pbParenOpen); @@ -723,14 +725,16 @@ val.replace(QLatin1Char('.'), KNumber::decimalSeparator()); calc_display->setAmount(KNumber(val)); updateDisplay({}); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ // Name: slotBaseSelected // Desc: changes the selected numeric base //------------------------------------------------------------------------------ -void KCalculator::slotBaseSelected(int base) { - +void KCalculator::slotBaseSelected(QAbstractButton *button) { + if (button) { + const int base = base_choose_group_->id(button); int current_base; // set display & statusbar (if item exist in statusbar) @@ -759,12 +763,12 @@ // Enable the buttons available in this base for (int i = 0; i < current_base; ++i) { - (num_button_group_->buttons()[i])->setEnabled(true); + (num_button_group_->buttons().at(i))->setEnabled(true); } // Disable the buttons not available in this base for (int i = current_base; i < 16; ++i) { - (num_button_group_->buttons()[i])->setEnabled(false); + (num_button_group_->buttons().at(i))->setEnabled(false); } // Only enable the decimal point in decimal @@ -785,6 +789,7 @@ } KCalcSettings::setBaseMode(base); + } } //------------------------------------------------------------------------------ @@ -860,8 +865,10 @@ // Name: slotAngleSelected // Desc: changes the selected angle system //------------------------------------------------------------------------------ -void KCalculator::slotAngleSelected(int mode) { +void KCalculator::slotAngleSelected(QAbstractButton *button) { + if (button) { + const int mode = angle_choose_group_->id(button); angle_mode_ = mode; statusBar()->setAngleMode(KCalcStatusBar::AngleMode(mode)); @@ -880,6 +887,7 @@ } KCalcSettings::setAngleMode(angle_mode_); + } } //------------------------------------------------------------------------------ @@ -931,6 +939,7 @@ calc_display->setAmount(memory_num_); updateDisplay({}); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ @@ -951,10 +960,13 @@ // Name: slotNumberclicked // Desc: user has entered a digit //------------------------------------------------------------------------------ -void KCalculator::slotNumberclicked(int number_clicked) { +void KCalculator::slotNumberclicked(QAbstractButton *button) { + if (button) { + const int number_clicked = num_button_group_->id(button); calc_display->enterDigit(number_clicked); core.setOnlyUpdateOperation(false); + } } //------------------------------------------------------------------------------ @@ -1477,6 +1489,7 @@ } updateDisplay(UPDATE_FROM_CORE); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ @@ -1493,6 +1506,7 @@ } updateDisplay(UPDATE_FROM_CORE); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ @@ -1503,14 +1517,15 @@ if (shift_mode_) { // std (n-1) - core.StatStdDeviation(KNumber::Zero); + core.StatStdSample(KNumber::Zero); pbShift->setChecked(false); } else { // std (n) - core.StatStdSample(KNumber::Zero); + core.StatStdDeviation(KNumber::Zero); } updateDisplay(UPDATE_FROM_CORE); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ @@ -1520,16 +1535,15 @@ void KCalculator::slotStatMedianclicked() { if (!shift_mode_) { - // std (n-1) core.StatMedian(KNumber::Zero); } else { - // std (n) core.StatMedian(KNumber::Zero); pbShift->setChecked(false); } // TODO: it seems two different modes should be implemented, but...? updateDisplay(UPDATE_FROM_CORE); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ @@ -1547,6 +1561,7 @@ } updateDisplay(UPDATE_FROM_CORE); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ @@ -1595,6 +1610,7 @@ } updateDisplay({}); + core.setOnlyUpdateOperation(false); } } @@ -1746,7 +1762,6 @@ pbSquare->hide(); pbPower->hide(); pbCube->hide(); - pbBackspace->hide(); pbEE->hide(); // delete the constant menu since it doesn't fit @@ -1777,7 +1792,6 @@ pbSquare->show(); pbPower->show(); pbCube->show(); - pbBackspace->show(); pbEE->show(); // show or hide some groups of buttons @@ -1815,7 +1829,6 @@ pbSquare->show(); pbPower->show(); pbCube->show(); - pbBackspace->show(); pbEE->show(); // show or hide some groups of buttons @@ -1854,7 +1867,6 @@ pbSquare->show(); pbPower->show(); pbCube->show(); - pbBackspace->show(); pbEE->show(); // show or hide some groups of buttons @@ -1875,7 +1887,7 @@ // Name: slotBaseModeAmountChanged // Desc: updates numerical base conversions //------------------------------------------------------------------------------ -void KCalculator::slotBaseModeAmountChanged(KNumber number) { +void KCalculator::slotBaseModeAmountChanged(const KNumber &number) { quint64 n = number.toUint64(); decDisplay->setText(QString::number(n, 10)); @@ -2067,6 +2079,7 @@ calc_display->setAmount(KNumber(value)); updateDisplay({}); + core.setOnlyUpdateOperation(false); } //------------------------------------------------------------------------------ @@ -2110,7 +2123,6 @@ if(flags & UPDATE_FROM_CORE) { calc_display->updateFromCore(core, (flags & UPDATE_STORE_RESULT) != 0); - core.setOnlyUpdateOperation(true); } else { calc_display->update(); } @@ -2314,11 +2326,11 @@ // Was it hex-button or normal digit?? if (num_but < 10) { for (int i = 0; i < 10; ++i) { - (num_button_group_->buttons()[i])->setStyleSheet(sheet.arg(cn)); + (num_button_group_->buttons().at(i))->setStyleSheet(sheet.arg(cn)); } } else { for (int i = 10; i < 16; ++i) { - (num_button_group_->buttons()[i])->setStyleSheet(sheet.arg(cn)); + (num_button_group_->buttons().at(i))->setStyleSheet(sheet.arg(cn)); } } return true; @@ -2346,6 +2358,15 @@ } } +//------------------------------------------------------------------------------ +// Name: slotPaste +// Desc: paste a number from the clipboard +//------------------------------------------------------------------------------ +void KCalculator::slotPaste() { + calc_display->slotPaste(); + core.setOnlyUpdateOperation(false); +} + //////////////////////////////////////////////////////////////// // Include the meta-object code for classes in this file // @@ -2380,7 +2401,7 @@ "Copyright © 2000-2008, The KDE Team\n" "Copyright © 2003-2005, Klaus Niederkr" "\xc3\xbc" "ger\n" "Copyright © 1996-2000, Bernd Johannes Wuebben"), - QStringLiteral(), + QString(), QStringLiteral("https://utils.kde.org/projects/kcalc")); // Klaus Niederkrueger diff -urN kcalc-19.12.3/kcalc.h kcalc-19.12.4/kcalc.h --- kcalc-19.12.3/kcalc.h 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/kcalc.h 2021-02-28 02:17:57.000000000 -0300 @@ -106,7 +106,6 @@ ~KCalculator(); Q_SIGNALS: - void switchShift(bool); void switchMode(ButtonModeFlags, bool); void switchShowAccels(bool); @@ -165,9 +164,9 @@ void slotConstantsShow(bool toggled); void slotBitsetshow(bool toggled); - void slotAngleSelected(int mode); - void slotBaseSelected(int base); - void slotNumberclicked(int number_clicked); + void slotAngleSelected(QAbstractButton *button); + void slotBaseSelected(QAbstractButton *button); + void slotNumberclicked(QAbstractButton *button); void slotEEclicked(); void slotShifttoggled(bool myboolean); void slotMemRecallclicked(); @@ -224,7 +223,9 @@ void slotBitsetChanged(quint64); void slotUpdateBitset(const KNumber &); - void slotBaseModeAmountChanged(KNumber number); + void slotBaseModeAmountChanged(const KNumber &number); + + void slotPaste(); private: enum StatusField { diff -urN kcalc-19.12.3/kcalc_bitset.cpp kcalc-19.12.4/kcalc_bitset.cpp --- kcalc-19.12.3/kcalc_bitset.cpp 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/kcalc_bitset.cpp 2021-02-28 02:17:57.000000000 -0300 @@ -27,7 +27,7 @@ #include #include #include -#include +#include @@ -73,7 +73,7 @@ setFrameStyle(QFrame::Panel | QFrame::Sunken); - connect(bit_button_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalcBitset::slotToggleBit); + connect(bit_button_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalcBitset::slotToggleBit); // smaller label font QFont fnt = font(); @@ -98,7 +98,7 @@ for (int bit = 0; bit < 8; bit++) { BitButton *const tmpBitButton = new BitButton(this); - tmpBitButton->setToolTip(i18n("Bit %1", bitCounter)); + tmpBitButton->setToolTip(i18n("Bit %1 = %2", bitCounter, 1ULL << bitCounter)); wordlayout->addWidget(tmpBitButton); bit_button_group_->addButton(tmpBitButton, bitCounter); bitCounter--; @@ -147,10 +147,13 @@ // Name: slotToggleBit // Desc: inverts the value of a single bit //------------------------------------------------------------------------------ -void KCalcBitset::slotToggleBit(int bit) { +void KCalcBitset::slotToggleBit(QAbstractButton *button) { - const quint64 nv = getValue() ^(1LL << bit); - setValue(nv); - emit valueChanged(value_); + if (button) { + const int bit = bit_button_group_->id(button); + const quint64 nv = getValue() ^(1LL << bit); + setValue(nv); + emit valueChanged(value_); + } } diff -urN kcalc-19.12.3/kcalc_bitset.h kcalc-19.12.4/kcalc_bitset.h --- kcalc-19.12.3/kcalc_bitset.h 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/kcalc_bitset.h 2021-02-28 02:17:57.000000000 -0300 @@ -25,7 +25,7 @@ #include class QButtonGroup; - +class QAbstractButton; class KCalcBitset : public QFrame { Q_OBJECT @@ -35,7 +35,7 @@ public Q_SLOTS: void setValue(quint64 value); - void slotToggleBit(int bit); + void slotToggleBit(QAbstractButton *button); Q_SIGNALS: void valueChanged(quint64 value); diff -urN kcalc-19.12.3/kcalc_core.cpp kcalc-19.12.4/kcalc_core.cpp --- kcalc-19.12.3/kcalc_core.cpp 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/kcalc_core.cpp 2021-02-28 02:17:57.000000000 -0300 @@ -872,6 +872,10 @@ else stack_.push(tmp_node); + // The check for '=' or '%' is unnecessary; it is just a safety measure + if (!((func == FUNC_EQUAL) || (func == FUNC_PERCENT))) + setOnlyUpdateOperation(true); + evalStack(); } diff -urN kcalc-19.12.3/kcalcdisplay.cpp kcalc-19.12.4/kcalcdisplay.cpp --- kcalc-19.12.3/kcalcdisplay.cpp 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/kcalcdisplay.cpp 2021-02-28 02:17:57.000000000 -0300 @@ -29,7 +29,7 @@ #include #include -#include +#include #include "kcalc_core.h" #include "kcalc_settings.h" @@ -391,7 +391,7 @@ lit_ = !lit_; button_ = Qt::LeftButton; } else { - button_ = Qt::MidButton; + button_ = Qt::MiddleButton; } emit clicked(); @@ -1023,5 +1023,5 @@ QStyleOptionFrame option; initStyleOption(&option); - return (style()->sizeFromContents(QStyle::CT_LineEdit, &option, sz.expandedTo(QApplication::globalStrut()), this)); + return (style()->sizeFromContents(QStyle::CT_LineEdit, &option, sz, this)); } diff -urN kcalc-19.12.3/knumber/knumber.cpp kcalc-19.12.4/knumber/knumber.cpp --- kcalc-19.12.3/knumber/knumber.cpp 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/knumber/knumber.cpp 2021-02-28 02:17:57.000000000 -0300 @@ -295,7 +295,6 @@ const QString ipart = list[1]; const QString fpart = list[2]; - const QString epart = list[3]; const int e_val = list[4].toInt(); QString num = ipart + fpart.mid(1); diff -urN kcalc-19.12.3/org.kde.kcalc.appdata.xml kcalc-19.12.4/org.kde.kcalc.appdata.xml --- kcalc-19.12.3/org.kde.kcalc.appdata.xml 2020-03-01 06:38:06.000000000 -0300 +++ kcalc-19.12.4/org.kde.kcalc.appdata.xml 2021-03-13 10:35:32.918775086 -0300 @@ -303,6 +303,7 @@ KDE +