Index: kcalc.h =================================================================== --- kcalc.h +++ kcalc.h @@ -223,6 +223,8 @@ void slotBitsetChanged(quint64); void slotUpdateBitset(const KNumber &); + void slotBaseModeAmountChanged(KNumber number); + private: enum StatusField { ShiftField = 0, @@ -265,6 +267,8 @@ QList stat_buttons_; QList const_buttons_; + std::array base_conversion_labels_; + KToggleAction *action_bitset_show_; KToggleAction *action_constants_show_; Index: kcalc.cpp =================================================================== --- kcalc.cpp +++ kcalc.cpp @@ -100,6 +100,8 @@ base_choose_group_->addButton(binRadio, BinMode); connect(base_choose_group_, QOverload::of(&QButtonGroup::buttonClicked), this, &KCalculator::slotBaseSelected); + base_conversion_labels_ = { binDisplay, hexDisplay, decDisplay, octDisplay }; + angle_choose_group_ = new QButtonGroup(this); angle_choose_group_->setExclusive(true); angle_choose_group_->addButton(degRadio, DegMode); @@ -1869,6 +1871,19 @@ KCalcSettings::setCalculatorMode(KCalcSettings::EnumCalculatorMode::numeral); } +//------------------------------------------------------------------------------ +// Name: slotBaseModeAmountChanged +// Desc: updates numerical base conversions +//------------------------------------------------------------------------------ +void KCalculator::slotBaseModeAmountChanged(KNumber number) { + quint64 n = number.toUint64(); + + decDisplay->setText(QString::number(n, 10)); + binDisplay->setText(QString::number(n, 2)); + octDisplay->setText(QString::number(n, 8)); + hexDisplay->setText(QString::number(n, 16).toUpper()); +} + //------------------------------------------------------------------------------ // Name: showMemButtons // Desc: hides or shows the memory buttons @@ -1960,6 +1975,11 @@ btn->show(); } + for (QLabel* lbl : base_conversion_labels_) { + lbl->show(); + } + connect(calc_display, &KCalcDisplay::changedAmount, this, &KCalculator::slotBaseModeAmountChanged); + for (int i = 10; i < 16; ++i) { (num_button_group_->button(i))->show(); } @@ -1979,6 +1999,11 @@ btn->hide(); } + for (QLabel* lbl : base_conversion_labels_) { + lbl->hide(); + } + connect(calc_display, &KCalcDisplay::changedAmount, this, &KCalculator::slotBaseModeAmountChanged); + statusBar()->setBaseIndicatorVisible(false); calc_display->setStatusText(BaseField, QString()); for (int i = 10; i < 16; ++i) { Index: kcalc.ui =================================================================== --- kcalc.ui +++ kcalc.ui @@ -6,8 +6,8 @@ 0 0 - 701 - 320 + 1084 + 350 @@ -62,21 +62,21 @@ - Deg + &Deg - Rad + &Rad - Grad + &Grad @@ -94,44 +94,151 @@ - - - Switch base to hexadecimal. + + + 0 - - He&x + + 60 - + + + + Switch base to hexadecimal. + + + He&x + + + + + + + + 65 + 0 + + + + + 65 + 16777215 + + + + 0 + + + + - - - Switch base to decimal. - - - &Dec + + + 60 - + + + + Switch base to decimal. + + + &Dec + + + + + + + + 65 + 0 + + + + + 65 + 16777215 + + + + 0 + + + + - - - Switch base to octal. - - - &Oct + + + 60 - + + + + Switch base to octal. + + + Oc&t + + + + + + + + 65 + 0 + + + + + 65 + 16777215 + + + + 0 + + + + - - - Switch base to binary. - - - &Bin + + + 20 - + + + + Switch base to binary. + + + &Bin + + + + + + + + 65 + 0 + + + + + 65 + 16777215 + + + + 0 + + + + @@ -140,227 +247,255 @@ - + + 2 + + + 2 + + + 2 + + 2 4 - - + + - Number of data entered + Clear data store - N + CSt - - - - Hyperbolic mode - + + - Hyp + C6 - H - - - true + Alt+6 - - + + - Bitwise AND + Bitwise OR - AND + OR - - + + - Modulo + Standard deviation - Mod + SD - - + + - A + C1 - A + Alt+1 - - + + + + Hyperbolic mode + - C1 + Hyp - Alt+1 + H + + + true - - + + - Mean + Right bit shift - Mea + Rsh - - + + - Sine + Natural log - Sin + Ln - S + N - - + + + + + 0 + 0 + + - Bitwise OR + Cube - OR + x3 - - + + - Reciprocal + Cosine - 1/X + Cos - R + C - - + + + + Exponent + - B + EXP - B + E - - - - C2 + + + + Modulo - - Alt+2 + + Mod - - + + - Standard deviation + Square - SD + x2 - - + + - Cosine + Tangent - Cos + Tan - C + T - - - - Bitwise XOR + + + + D + + + D + + + + - XOR + C4 + + + Alt+4 - - + + - Factorial + Bitwise XOR - x! + XOR - - + + - C + A - C + A - - - - C3 + + + + Bitwise AND - - Alt+3 + + AND - - + + - Median + Number of data entered - Med + N - - + + - Tangent + Reciprocal - Tan + 1/X - T + R @@ -374,69 +509,59 @@ - - + + - Square - - - x2 + Enter data - - - - - D + Dat D - - + + - C4 + C3 - Alt+4 + Alt+3 - - + + - Enter data + Sine - Dat + Sin - D + S - - + + - Logarithm to base 10 + Mean - Log - - - L + Mea - - + + - Right bit shift + Median - Rsh + Med @@ -460,46 +585,36 @@ - - + + - C5 + B - Alt+5 + B - - + + - Clear data store + One's complement - CSt + Cmp - - + + - Natural log + Logarithm to base 10 - Ln + Log - N - - - - - - - One's complement - - - Cmp + L @@ -513,42 +628,43 @@ - - + + - C6 + C2 - Alt+6 + Alt+2 - - - - Exponent - + + - EXP + C - E + C - - - - - 0 - 0 - - + + - Cube + Factorial - x3 + x! + + + + + + + C5 + + + Alt+5 @@ -564,7 +680,16 @@ - + + 2 + + + 2 + + + 2 + + 2 @@ -848,7 +973,16 @@ - + + 2 + + + 2 + + + 2 + + 2 @@ -1002,6 +1136,11 @@ QPushButton
kcalc_const_button.h
+ + KSqueezedTextLabel + QWidget +
ksqueezedtextlabel.h
+
pb0 @@ -1070,10 +1209,6 @@ degRadio radRadio gradRadio - hexRadio - decRadio - octRadio - binRadio calc_display