Skip to content

Commit

Permalink
添加词组数量设置以及修复联想功能
Browse files Browse the repository at this point in the history
  • Loading branch information
0312birdzhang committed Mar 13, 2018
1 parent 4a8a039 commit 77b6818
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 12 deletions.
4 changes: 3 additions & 1 deletion harbour-souniaoime.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions libgooglepinyin/src/pinyindecoderservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ QList<QString> PinyinDecoderService::predictionList(const QString &history, int
QList<QString> 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;
}
Expand Down
16 changes: 14 additions & 2 deletions miaomiaomiao/maliit/plugins/com/jolla/SouniaoHandler.qml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
Expand Down
54 changes: 49 additions & 5 deletions miaomiaomiao/qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions rpm/harbour-souniaoime.changes
Original file line number Diff line number Diff line change
@@ -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 <author's email> version-release
# - Summary of changes

* Sun Apr 13 2014 Jack Tar <jack.tar@example.com> 0.0.1-1
- Scrubbed the deck
- Hoisted the sails

25 changes: 25 additions & 0 deletions rpm/harbour-souniaoime.changes.run
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions rpm/harbour-souniaoime.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77b6818

Please sign in to comment.