Skip to content

Commit

Permalink
Change "Hide number pad" to "Always show number pad", and add separat…
Browse files Browse the repository at this point in the history
…e number pad when the option is not enabled; Disable "Always show number pad" automatically if available screen width is insufficient; Use scrollbars in preferences dialog if the dialog does not available screen size (issue #156); Improve handling of current result (use value not text) and initial focus in floating point conversion dialog; Show language selection on all platforms; Allow unit expressions (and not only single units) for insert unit action (for custom shortcuts and buttons); Fix compilation on Windows
  • Loading branch information
hanna-kn committed Aug 14, 2024
1 parent ff6782e commit 55eff02
Show file tree
Hide file tree
Showing 22 changed files with 8,583 additions and 8,402 deletions.
12 changes: 1 addition & 11 deletions src/expressionedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,7 @@ void ExpressionTipLabel::timerEvent(QTimerEvent *e) {
}
}
bool ExpressionTipLabel::placeTip(const QPoint &pos, const QRect &completion_rect) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QScreen *scr = widget->screen();
# else
QScreen *scr = QGuiApplication::screenAt(pos);
# endif
if(!scr) scr = QGuiApplication::primaryScreen();
QRect screen = scr->availableGeometry();
#else
QRect screen = QApplication::desktop()->availableGeometry(widget);
#endif
QRect screen = get_screen_geometry(widget);
QPoint p = pos;
p += QPoint(2, 16);
if(!completion_rect.isNull() && completion_rect.intersects(QRect(p, this->size()))) {
Expand Down
82 changes: 49 additions & 33 deletions src/fpconversiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,52 @@ unsigned int FPConversionDialog::getSignPosition() {
void FPConversionDialog::formatChanged() {
updateFields(10);
}
void FPConversionDialog::updateFields(int base) {
void FPConversionDialog::updateFields(int base, const MathStructure *v) {
std::string sbin;
Number decnum;
bool use_decnum = false;
unsigned int bits = getBits();
unsigned int expbits = getExponentBits();
unsigned int sgnpos = getSignPosition();
if(base == 10) {
std::string str = valueEdit->text().toStdString();
remove_blank_ends(str);
if(str.empty()) return;
if(last_is_operator(str, true)) return;
EvaluationOptions eo;
eo.parse_options = settings->evalops.parse_options;
eo.parse_options.read_precision = DONT_READ_PRECISION;
if(eo.parse_options.parsing_mode == PARSING_MODE_RPN || eo.parse_options.parsing_mode == PARSING_MODE_CHAIN) eo.parse_options.parsing_mode = PARSING_MODE_ADAPTIVE;
if(!settings->simplified_percentage) eo.parse_options.parsing_mode = (ParsingMode) (eo.parse_options.parsing_mode | PARSE_PERCENT_AS_ORDINARY_CONSTANT);
eo.parse_options.base = 10;
PrintOptions po;
po.number_fraction_format = FRACTION_DECIMAL;
po.interval_display = INTERVAL_DISPLAY_SIGNIFICANT_DIGITS;
po.use_unicode_signs = settings->printops.use_unicode_signs;
po.exp_display = settings->printops.exp_display;
po.lower_case_numbers = settings->printops.lower_case_numbers;
po.rounding = settings->printops.rounding;
po.base_display = BASE_DISPLAY_NONE;
po.abbreviate_names = settings->printops.abbreviate_names;
po.digit_grouping = settings->printops.digit_grouping;
po.multiplication_sign = settings->printops.multiplication_sign;
po.division_sign = settings->printops.division_sign;
po.short_multiplication = settings->printops.short_multiplication;
po.excessive_parenthesis = settings->printops.excessive_parenthesis;
po.can_display_unicode_string_function = &can_display_unicode_string_function;
po.can_display_unicode_string_arg = (void*) valueEdit;
po.spell_out_logical_operators = settings->printops.spell_out_logical_operators;
po.binary_bits = bits;
po.show_ending_zeroes = false;
po.min_exp = 0;
if(base == 10 || v) {
MathStructure value;
CALCULATOR->calculate(&value, CALCULATOR->unlocalizeExpression(str, eo.parse_options), 1500, eo);
if(v) {
valueEdit->setText(QString::fromStdString(v->number().print(po)));
base = 10;
value.set(*v);
} else {
std::string str = valueEdit->text().toStdString();
remove_blank_ends(str);
if(str.empty()) return;
if(last_is_operator(str, true)) return;
EvaluationOptions eo;
eo.parse_options = settings->evalops.parse_options;
eo.parse_options.read_precision = DONT_READ_PRECISION;
if(eo.parse_options.parsing_mode == PARSING_MODE_RPN || eo.parse_options.parsing_mode == PARSING_MODE_CHAIN) eo.parse_options.parsing_mode = PARSING_MODE_ADAPTIVE;
if(!settings->simplified_percentage) eo.parse_options.parsing_mode = (ParsingMode) (eo.parse_options.parsing_mode | PARSE_PERCENT_AS_ORDINARY_CONSTANT);
eo.parse_options.base = 10;
CALCULATOR->calculate(&value, CALCULATOR->unlocalizeExpression(str, eo.parse_options), 1500, eo);
}
if(value.isNumber()) {
sbin = to_float(value.number(), bits, expbits, sgnpos);
decnum = value.number();
Expand Down Expand Up @@ -174,26 +200,6 @@ void FPConversionDialog::updateFields(int base) {
decEdit->clear();
errorEdit->clear();
} else {
PrintOptions po;
po.number_fraction_format = FRACTION_DECIMAL;
po.interval_display = INTERVAL_DISPLAY_SIGNIFICANT_DIGITS;
po.use_unicode_signs = settings->printops.use_unicode_signs;
po.exp_display = settings->printops.exp_display;
po.lower_case_numbers = settings->printops.lower_case_numbers;
po.rounding = settings->printops.rounding;
po.base_display = BASE_DISPLAY_NONE;
po.abbreviate_names = settings->printops.abbreviate_names;
po.digit_grouping = settings->printops.digit_grouping;
po.multiplication_sign = settings->printops.multiplication_sign;
po.division_sign = settings->printops.division_sign;
po.short_multiplication = settings->printops.short_multiplication;
po.excessive_parenthesis = settings->printops.excessive_parenthesis;
po.can_display_unicode_string_function = &can_display_unicode_string_function;
po.can_display_unicode_string_arg = (void*) valueEdit;
po.spell_out_logical_operators = settings->printops.spell_out_logical_operators;
po.binary_bits = bits;
po.show_ending_zeroes = false;
po.min_exp = 0;
int prec_bak = CALCULATOR->getPrecision();
CALCULATOR->setPrecision(100);
ParseOptions pa;
Expand Down Expand Up @@ -316,6 +322,13 @@ void FPConversionDialog::setValue(const QString &str) {
valueEdit->setText(str);
valueEdit->blockSignals(false);
updateFields(10);
valueEdit->selectAll();
valueEdit->setFocus();
}
void FPConversionDialog::setValue(const MathStructure &m) {
updateFields(0, &m);
valueEdit->selectAll();
valueEdit->setFocus();
}
void FPConversionDialog::setBin(const QString &str) {
binEdit->blockSignals(true);
Expand All @@ -329,12 +342,15 @@ void FPConversionDialog::setBin(const QString &str) {
binEdit->setTextCursor(cursor);
binEdit->blockSignals(false);
updateFields(2);
binEdit->setFocus();
}
void FPConversionDialog::setHex(const QString &str) {
hexEdit->blockSignals(true);
hexEdit->setText(str);
hexEdit->blockSignals(false);
updateFields(16);
hexEdit->selectAll();
hexEdit->setFocus();
}
void FPConversionDialog::hexChanged() {
updateFields(16);
Expand Down
3 changes: 2 additions & 1 deletion src/fpconversiondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ class FPConversionDialog : public QDialog {
protected slots:

void formatChanged();
void updateFields(int base);
void updateFields(int base, const MathStructure *value = NULL);
void hexChanged();
void binChanged();
void valueChanged();

public slots:

void setValue(const QString &str);
void setValue(const MathStructure &m);
void setBin(const QString &str);
void setHex(const QString &str);

Expand Down
Loading

0 comments on commit 55eff02

Please sign in to comment.