From 77b68185756d220ce3dfaff23d5005061cda33bf Mon Sep 17 00:00:00 2001 From: BirdZhang <0312birdzhang@gmail.com> Date: Tue, 13 Mar 2018 14:51:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=8D=E7=BB=84=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E8=AE=BE=E7=BD=AE=E4=BB=A5=E5=8F=8A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=81=94=E6=83=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- harbour-souniaoime.pro | 4 +- libgooglepinyin/src/pinyindecoderservice.cpp | 5 +- .../plugins/com/jolla/SouniaoHandler.qml | 16 +++++- miaomiaomiao/qml/pages/FirstPage.qml | 54 +++++++++++++++++-- rpm/harbour-souniaoime.changes | 18 +++++++ rpm/harbour-souniaoime.changes.run | 25 +++++++++ rpm/harbour-souniaoime.spec | 4 +- 7 files changed, 114 insertions(+), 12 deletions(-) create mode 100644 rpm/harbour-souniaoime.changes create mode 100644 rpm/harbour-souniaoime.changes.run diff --git a/harbour-souniaoime.pro b/harbour-souniaoime.pro index 689b8d7..8c957b5 100644 --- a/harbour-souniaoime.pro +++ b/harbour-souniaoime.pro @@ -5,4 +5,6 @@ SUBDIRS += \ miaomiaomiao -OTHER_FILES += rpm/harbour-souniaoime.spec +OTHER_FILES += rpm/harbour-souniaoime.spec \ + rpm/harbour-souniaoime.changes \ + rpm/harbour-souniaoime.changes.run diff --git a/libgooglepinyin/src/pinyindecoderservice.cpp b/libgooglepinyin/src/pinyindecoderservice.cpp index 6176238..8a8e3c0 100644 --- a/libgooglepinyin/src/pinyindecoderservice.cpp +++ b/libgooglepinyin/src/pinyindecoderservice.cpp @@ -227,8 +227,9 @@ QList PinyinDecoderService::predictionList(const QString &history, int QList predictList; char16 (*predictItems)[kMaxPredictSize + 1] = 0; int predictNum = int(im_get_predicts(history.utf16(), predictItems)); - predictList.reserve(predictNum); - for (int i = 0; i <= fetchSize; i++) + fetchSize = predictNum > fetchSize ? fetchSize : predictNum; + predictList.reserve(fetchSize); + for (int i = 0; i < fetchSize; i++) predictList.append(QString((QChar *)predictItems[i])); return predictList; } diff --git a/miaomiaomiao/maliit/plugins/com/jolla/SouniaoHandler.qml b/miaomiaomiao/maliit/plugins/com/jolla/SouniaoHandler.qml index ea04554..50d4caa 100644 --- a/miaomiaomiao/maliit/plugins/com/jolla/SouniaoHandler.qml +++ b/miaomiaomiao/maliit/plugins/com/jolla/SouniaoHandler.qml @@ -1,5 +1,6 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 +import Nemo.Configuration 1.0 import com.meego.maliitquick 1.0 import com.jolla.keyboard 1.0 import xyz.birdzhang.ime 1.0 @@ -19,6 +20,13 @@ InputHandler { property bool pinyinMode: MInputMethodQuick.contentType !== Maliit.UrlContentType && MInputMethodQuick.contentType !== Maliit.EmailContentType property int cursorIndex: MInputMethodQuick.cursorPosition + ConfigurationGroup{ + id: config + path: "/app/xyz.birdzhang.ime" + property int pageSize: 20 + property int fetchSize: 15 + } + onPinyinModeChanged: { handler.composingEnabled = handler.pinyinMode keyboard.layout.pinyinMode = handler.pinyinMode @@ -60,13 +68,14 @@ InputHandler { property var olderSql property bool hasMore:false property bool fetchMany:false - property int pageSize: 20 //TODO configroup - property int fetchSize: 15 //TODO configroup + property int pageSize: config.pageSize; + property int fetchSize: config.fetchSize; property int pred:0 signal candidatesUpdated Component.onCompleted:{ + console.log("pageSize:"+config.pageSize) gpy.init(); gpy.setUserDictionary(true); } @@ -764,6 +773,9 @@ InputHandler { for (var i = 0; i < tmppredictionsList.length; i++) { gpy.candidates.append({text: tmppredictionsList[i], type: "full", segment: 0, candidate: i}) } + if(tmppredictionsList.length > 0){ + gpy.candidates.append({text: " ", type: "full", segment: 0, candidate: tmppredictionsList.length}); + } gpy.hasMore = false; gpy.candidatesUpdated(); } diff --git a/miaomiaomiao/qml/pages/FirstPage.qml b/miaomiaomiao/qml/pages/FirstPage.qml index 0b91b33..a429e72 100644 --- a/miaomiaomiao/qml/pages/FirstPage.qml +++ b/miaomiaomiao/qml/pages/FirstPage.qml @@ -1,8 +1,14 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 +import Nemo.Configuration 1.0 Page{ - + ConfigurationGroup{ + id: config + path: "/app/xyz.birdzhang.ime" + property int pageSize: 20 + property int fetchSize: 15 + } SilicaFlickable{ anchors.fill: parent contentHeight: column.height @@ -49,10 +55,48 @@ Page{ horizontalAlignment: Text.AlignRight } -// TextField{ -// width: parent.width -// focus: true -// } + Item { + width: parent.width + height: Theme.paddingSmall + } + + SectionHeader{ + text: "自定义" + } + + SectionHeader{ + text: "联想词数量" + font.pixelSize: Theme.fontSizeExtraSmall + } + Slider { + minimumValue: 5 + maximumValue: 20 + stepSize: 1 + value: config.fetchSize + width: parent.width + valueText: value + onValueChanged: { + config.fetchSize = value; + } + } + + SectionHeader{ + text: "候选词数量" + font.pixelSize: Theme.fontSizeExtraSmall + } + + Slider { + minimumValue: 10 + maximumValue: 25 + stepSize: 1 + value: config.pageSize + width: parent.width + valueText: value + onValueChanged: { + config.pageSize = value; + } + } + Image{ source: "./notexist.jpg" width: parent.width - Theme.paddingLarge diff --git a/rpm/harbour-souniaoime.changes b/rpm/harbour-souniaoime.changes new file mode 100644 index 0000000..d7f1b06 --- /dev/null +++ b/rpm/harbour-souniaoime.changes @@ -0,0 +1,18 @@ +# Rename this file as harbour-qvod.changes to include changelog +# entries in your RPM file. +# +# Add new changelog entries following the format below. +# Add newest entries to the top of the list. +# Separate entries from eachother with a blank line. +# +# Alternatively, if your changelog is automatically generated (e.g. with +# the git-change-log command provided with Sailfish OS SDK), create a +# harbour-qvod.changes.run script to let mb2 run the required commands for you. + +# * date Author's Name version-release +# - Summary of changes + +* Sun Apr 13 2014 Jack Tar 0.0.1-1 +- Scrubbed the deck +- Hoisted the sails + diff --git a/rpm/harbour-souniaoime.changes.run b/rpm/harbour-souniaoime.changes.run new file mode 100644 index 0000000..3b7ade9 --- /dev/null +++ b/rpm/harbour-souniaoime.changes.run @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Rename this file as harbour-souniaoime.changes.run to let mb2 automatically +# generate changelog from well formatted Git commit messages and tag +# annotations. + +git-change-log + +# Here are some basic examples how to change from the default behavior. Run +# git-change-log --help inside the Sailfish OS SDK chroot or build engine to +# learn all the options git-change-log accepts. + +# Use a subset of tags +#git-change-log --tags refs/tags/my-prefix/* + +# Group entries by minor revision, suppress headlines for patch-level revisions +#git-change-log --dense '/[0-9]\+\.[0-9\+$' + +# Trim very old changes +#git-change-log --since 2014-04-01 +#echo '[ Some changelog entries trimmed for brevity ]' + +# Use the subjects (first lines) of tag annotations when no entry would be +# included for a revision otherwise +#git-change-log --auto-add-annotations diff --git a/rpm/harbour-souniaoime.spec b/rpm/harbour-souniaoime.spec index 021255f..10d0cf8 100644 --- a/rpm/harbour-souniaoime.spec +++ b/rpm/harbour-souniaoime.spec @@ -5,8 +5,8 @@ Name: harbour-souniaoime %{!?qtc_make:%define qtc_make make} %{?qtc_builddir:%define _builddir %qtc_builddir} -Version: 0.2 -Release: 2 +Version: 0.3.0 +Release: 1 Summary: PinyinIme for Sailfish OS License: LGPLv2 Group: Qt/Qt