123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- import QtQuick 1.1
- import com.nokia.meego 1.0
- import "IMQuery.js" as JsIMQuery
- Page {
- id: mainPage
- tools: commonTools
- Rectangle {
- id: rectMain
- color: "#0080e6"
- gradient: Gradient {
- GradientStop {
- position: 0.00;
- color: "#048ef7";
- }
- GradientStop {
- position: 0.26;
- color: "#dbdbdb";
- }
- GradientStop {
- position: 0.62;
- color: "#ffffff";
- }
- GradientStop {
- position: 1.00;
- color: "#c0c0c0";
- }
- }
- anchors.left: parent.left
- anchors.leftMargin: 0
- anchors.top: parent.top
- width: mainPage.width
- height: mainPage.height
- SipAttributes {
- id:customSipAttributes
- actionKeyEnabled: true
- actionKeyHighlighted: true
- actionKeyLabel: qsTr("Submit")
- }
- Row {
- id: rowQuery
- anchors.horizontalCenter: parent.horizontalCenter
- Image {
- id: appLogo
- width: 64; height: 64
- source: "qrc:/appLogoWithoutBG"
- MouseArea {
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.top: parent.top
- onClicked: Qt.openUrlExternally("http://dadablog.net/HarmattanApps")
- }
- }
- Label {
- id: lblInstruction
- width: 220
- y: 15
- text: qsTr("Specify a Chinese character: ")
- font.pointSize: 20
- }
- TextField {
- id: txtCharacter
- width: 90
- opacity: 0.7
- maximumLength: 1
- platformSipAttributes: customSipAttributes
- Keys.onReturnPressed: {
- txtQueryResults.queryCharacter(txtCharacter.text)
- txtCharacter.text = ""
- txtCharacter.closeSoftwareInputPanel()
- }
- platformStyle: TextFieldStyle { paddingRight: clearButton.width }
- Image {
- id: clearButton
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- source: "image://theme/icon-m-input-clear"
- MouseArea {
- anchors.fill: parent
- onClicked: {
- inputContext.reset();
- txtCharacter.text = "";
- }
- }
- }
- }
- Button{
- id: btnQuery
- width: 100
- text: qsTr("Submit")
- opacity: 0.5
- onClicked: submitQuery()
- function submitQuery() {
- txtQueryResults.queryCharacter(txtCharacter.text)
- txtCharacter.text = ""
- }
- }
- }
- Flickable {
- id: flick
- anchors.left: parent.left
- anchors.leftMargin: 0
- anchors.top: rowQuery.bottom
- contentHeight: rectMain.height * 2.7
- width: rectMain.width
- height: rectMain.height
- clip: true
- flickableDirection: Flickable.VerticalFlick
- boundsBehavior: Flickable.DragOverBounds
- function ensureVisible(r)
- {
- if (contentY >= r.y)
- contentY = r.y;
- else if (contentY+height <= r.y+r.height)
- contentY = r.y+r.height-height;
- }
- QueryDialog {
- id: nonChineseErrorDialog
- titleText: qsTr("Error")
- acceptButtonText: qsTr("OK")
- message: qsTr("Please specify a Chinese character.")
- }
- TextEdit {
- id: txtQueryResults
- text: ""
- textFormat: TextEdit.RichText
- font.pointSize: 18
- width: rectMain.width
- height: rectMain.height - rowQuery.height
- readOnly: true
- focus: true
- wrapMode: "WrapAtWordBoundaryOrAnywhere"
- onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
- function queryCharacter( character ) {
- if (character != "")
- {
- var db = openDatabaseSync("IM","1.0","IMQuery",7235584);
- var r = "<font size=\"+5\" color=\"#000080\">" + character + "</font> "
- // Do nothing if character is not Chinese character.
- if (character.charCodeAt(0)>=31 && character.charCodeAt(0)<=127) {
- text = ""
- nonChineseErrorDialog.open()
- } else {
- var bRowsReturned
- db.readTransaction(
- function(tx) {
- // Look up character for Radicals.
- var rs = tx.executeSql('SELECT * FROM Radical WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr(" belongs to the ") + rs.rows.item(i).Radical + qsTr(" radical (") + rs.rows.item(i).RemainingStrokes + qsTr(" strokes)") + "<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- if (bRowsReturned==true) {
- r += "<hr />"
- bRowsReturned = false
- }
- db.readTransaction(
- function(tx) {
- // Look up character for Stroke Order strokes.
- var rs = tx.executeSql('SELECT * FROM StrokeOrder WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Total strokes: ") + (rs.rows.item(i).Strokes.length).toString() + "<br />"
- r += qsTr("Stroke 5: ") + JsIMQuery.convertToStrokes(rs.rows.item(i).Strokes.substr(0,5)) + " (" + rs.rows.item(i).Strokes.substr(0,5) + ")<br />"
- r += qsTr("Stroke orders: ") + JsIMQuery.convertToStrokes(rs.rows.item(i).Strokes) + " (" + rs.rows.item(i).Strokes + ")<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- if (bRowsReturned==true) {
- r += "<hr />"
- bRowsReturned = false
- }
- db.readTransaction(
- function(tx) {
- // Look up character for PinYin inputs.
- var rs = tx.executeSql('SELECT * FROM PinYin WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Pin Yin: ") + rs.rows.item(i).Keys + "<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- db.readTransaction(
- function(tx) {
- // Look up character for ZhuYin inputs.
- var rs = tx.executeSql('SELECT * FROM ZhuYin WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Zhu Yin: ") + JsIMQuery.convertToZhuYin(rs.rows.item(i).Keys) + " (" + rs.rows.item(i).Keys.toUpperCase() + ")<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- if (bRowsReturned==true) {
- r += "<hr />"
- bRowsReturned = false
- }
- db.readTransaction(
- function(tx) {
- // Look up character for ChangJie3 & Quick3 radicals.
- var rs = tx.executeSql('SELECT * FROM CangJie3 WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("CangJie 3rd Edition: ") + JsIMQuery.convertToCangJie(rs.rows.item(i).Keys) + " (" + rs.rows.item(i).Keys.toUpperCase() + ")<br />"
- r += qsTr("Quick CangJie 3rd Edition: ") + JsIMQuery.convertToCangJie( rs.rows.item(i).Keys.substr(0,1) + rs.rows.item(i).Keys.substr( rs.rows.item(i).Keys.length - 1,1) ) + " (" + rs.rows.item(i).Keys.substr(0,1).toUpperCase() + rs.rows.item(i).Keys.substr( rs.rows.item(i).Keys.length - 1,1).toUpperCase() + ")<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- db.readTransaction(
- function(tx) {
- // Look up character for ChangJie5 & Quick5 radicals.
- var rs = tx.executeSql('SELECT * FROM CangJie5 WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("CangJie 5th Edition: ") + JsIMQuery.convertToCangJie(rs.rows.item(i).Keys) + " (" + rs.rows.item(i).Keys.toUpperCase() + ")<br />"
- r += qsTr("Quick CangJie 5th Edition: ") + JsIMQuery.convertToCangJie( rs.rows.item(i).Keys.substr(0,1) + rs.rows.item(i).Keys.substr( rs.rows.item(i).Keys.length - 1,1) ) + " (" + rs.rows.item(i).Keys.substr(0,1).toUpperCase() + rs.rows.item(i).Keys.substr( rs.rows.item(i).Keys.length - 1,1).toUpperCase() + ")<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- if (bRowsReturned==true) {
- r += "<hr />"
- bRowsReturned = false
- }
- db.readTransaction(
- function(tx) {
- // Look up character for Jyut Ping inputs.
- var rs = tx.executeSql('SELECT * FROM JyutPing WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Jyut Ping: ") + rs.rows.item(i).Keys + "<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- db.readTransaction(
- function(tx) {
- // Look up character for Cantonese inputs.
- var rs = tx.executeSql('SELECT * FROM Canton WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Cantonese: ") + rs.rows.item(i).Keys + "<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- if (bRowsReturned==true) {
- r += "<hr />"
- bRowsReturned = false
- }
- db.readTransaction(
- function(tx) {
- // Look up character for DaiYi 3rd Edition radicals.
- var rs = tx.executeSql('SELECT * FROM DaYi3 WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Da Yi 3rd Edition: ") + JsIMQuery.convertToDaiYi3(rs.rows.item(i).Keys) + " (" + rs.rows.item(i).Keys.toUpperCase() + ")<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- db.readTransaction(
- function(tx) {
- // Look up character for WuBi radicals.
- var rs = tx.executeSql('SELECT * FROM WuBi WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Wu Bi: ") + JsIMQuery.convertToWuBi(rs.rows.item(i).Keys) + " (" + rs.rows.item(i).Keys.toUpperCase() + ")<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- if (bRowsReturned==true) {
- r += "<hr />"
- bRowsReturned = false
- }
- db.readTransaction(
- function(tx) {
- // Look up character for Array30 inputs.
- var rs = tx.executeSql('SELECT * FROM Array30 WHERE Character=\'' + character + '\'');
- if (rs.rows.length!=0) {
- for(var i = 0; i < rs.rows.length; i++) {
- r += qsTr("Array 30 keys: ") + JsIMQuery.convertToArray30(rs.rows.item(i).Keys) + " (" + rs.rows.item(i).Keys + ")<br />"
- bRowsReturned = true
- }
- }
- text = r
- }
- )
- r += "\n\n"
- text = r
- }
- }
- }
- }
- }
- }
- }
|