add keyboard, fix display of negative numbers

This commit is contained in:
Jeff Wang 2019-04-04 02:46:10 -04:00
parent 8550049335
commit 4734fe5a0e
3 changed files with 15 additions and 2 deletions

View File

@ -19,6 +19,7 @@ int main(int argc, char** argv)
//fixed-width font for LCD
QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
fixedFont.setStyleHint(QFont::TypeWriter);
fixedFont.setPointSize(24);
engine.rootContext()->setContextProperty("_fixedFont", fixedFont);
//handle quit

View File

@ -59,7 +59,7 @@ ApplicationWindow
color: "gray"
border { width: 1; color: "black" }
Text {
text: index
text: {getText(parent.parent.objectName, index)}
anchors.centerIn: parent
}
MouseArea {
@ -71,4 +71,16 @@ ApplicationWindow
}
}
}
function getText(row, col) {
var keys = [
["Shift", "x<->y", "+/-", "C"],
["7", "8", "9", "/"],
["4", "5", "6", "*"],
["1", "2", "3", "-"],
["0", ".", "Enter", "+"]
]
return keys[row][col]
}
}

View File

@ -76,7 +76,7 @@ static int is_valid_character(char letter){
return 1;
} else if(letter == CGRAM_EXP || letter == CGRAM_EXP_NEG){
return 1;
} else if(letter == '.' || letter == ' '){
} else if(letter == '.' || letter == ' ' || letter == '-'){
return 1;
}