Instead of replacing:
result = result.replace(".", separator);
you could use toLocaleString without checking
result = result.toPrecision(CALC.PRECISION).replace(/\.0+$/,"").toLocaleString(Qt.locale(), "f", 0);
Instead of replacing separators, function buttonClicked(buttonName) {
if (buttonName === separator) { buttonName = '.';
} keyboardButtons[buttonName].clicked();
}
function buttonReleased(buttonName) {
if (buttonName === separator) { buttonName = '.';
} keyboardButtons[buttonName].released();
}
try to use contruction:
Keys.onPressed: {
...
Keys.onReleased: {
...
else if (event.text === separator) { buttonClicked(".")
Instead of
if (separator !== '.' && last.value.toString() === '.') { last.value = separator;
} screenFormula[screenFormula.length - 1]._number += last.value.toString();
One more comment:
Instead of replacing: toPrecision( CALC.PRECISION) .replace( /\.0+$/ ,"").toLocaleSt ring(Qt. locale( ), "f", 0);
result = result.replace(".", separator);
you could use toLocaleString without checking
result = result.
Instead of replacing separators,
function buttonClicked( buttonName) {
buttonNam e = '.';
keyboardButto ns[buttonName] .clicked( );
if (buttonName === separator) {
}
}
if (buttonName === separator) {
}
}
try to use contruction:
Keys.onPressed: {
...
Keys.onReleased: {
...
else if (event.text === separator) {
buttonClicked( ".")
Instead of toString( ) === '.') {
last. value = separator;
screenFormula [screenFormula. length - 1]._number += last.value. toString( );
if (separator !== '.' && last.value.
}
use:
screenForm ula[screenFormu la.length - 1]._number += last.value. toLocaleString( Qt.locale( ), "f", 0);
Thanks !