Skip to content

Commit c44bcde

Browse files
committed
add nextSchemaOption
1 parent 68fc613 commit c44bcde

15 files changed

+106
-11
lines changed

po/ca.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ msgstr ""
6060
msgid "Half Shape is enabled."
6161
msgstr ""
6262

63-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
63+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6464
msgid "Latin Mode"
6565
msgstr ""
6666

67+
#: src/rimeengine.cpp:858
68+
msgid "Next Schema"
69+
msgstr ""
70+
6771
#: src/rimeengine.h:77
6872
msgid "Load available plugins automatically"
6973
msgstr ""

po/da.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ msgstr ""
5959
msgid "Half Shape is enabled."
6060
msgstr ""
6161

62-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
62+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6363
msgid "Latin Mode"
6464
msgstr "Latinsk tilstand"
6565

66+
#: src/rimeengine.cpp:858
67+
msgid "Next Schema"
68+
msgstr ""
69+
6670
#: src/rimeengine.h:77
6771
msgid "Load available plugins automatically"
6872
msgstr ""

po/de.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,14 @@ msgstr ""
6161
msgid "Half Shape is enabled."
6262
msgstr ""
6363

64-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
64+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6565
msgid "Latin Mode"
6666
msgstr "Lateinischer Modus"
6767

68+
#: src/rimeengine.cpp:858
69+
msgid "Next Schema"
70+
msgstr ""
71+
6872
#: src/rimeengine.h:77
6973
msgid "Load available plugins automatically"
7074
msgstr ""

po/fcitx5-rime.pot

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ msgstr ""
5555
msgid "Half Shape is enabled."
5656
msgstr ""
5757

58-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
58+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
5959
msgid "Latin Mode"
6060
msgstr ""
6161

62+
#: src/rimeengine.cpp:858
63+
msgid "Next Schema"
64+
msgstr ""
65+
6266
#: src/rimeengine.h:77
6367
msgid "Load available plugins automatically"
6468
msgstr ""

po/he.po

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ msgstr ""
6565
msgid "Latin Mode"
6666
msgstr ""
6767

68+
#: src/rimeengine.cpp:858
69+
msgid "Next Schema"
70+
msgstr ""
71+
6872
#: src/rimeengine.h:78
6973
msgid "Load available plugins automatically"
7074
msgstr ""

po/ja.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ msgstr "全角は有効です。"
6262
msgid "Half Shape is enabled."
6363
msgstr "半角は有効です。"
6464

65-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
65+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6666
msgid "Latin Mode"
6767
msgstr "ラテンモード"
6868

69+
#: src/rimeengine.cpp:858
70+
msgid "Next Schema"
71+
msgstr ""
72+
6973
#: src/rimeengine.h:77
7074
msgid "Load available plugins automatically"
7175
msgstr "利用可能なプラグインを自動的にロードする"

po/ko.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ msgstr "전각이 활성화되었습니다."
6060
msgid "Half Shape is enabled."
6161
msgstr "반각이 활성화되었습니다."
6262

63-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
63+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6464
msgid "Latin Mode"
6565
msgstr "로마자 모드"
6666

67+
#: src/rimeengine.cpp:858
68+
msgid "Next Schema"
69+
msgstr ""
70+
6771
#: src/rimeengine.h:77
6872
msgid "Load available plugins automatically"
6973
msgstr "사용 가능한 플러그인 자동으로 불러오기"

po/ru.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ msgstr "Полноширинная форма включена."
6363
msgid "Half Shape is enabled."
6464
msgstr "Полуширинная форма включена."
6565

66-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
66+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6767
msgid "Latin Mode"
6868
msgstr "Режим Латиницы"
6969

70+
#: src/rimeengine.cpp:858
71+
msgid "Next Schema"
72+
msgstr ""
73+
7074
#: src/rimeengine.h:77
7175
msgid "Load available plugins automatically"
7276
msgstr "Автоматически загружать доступные плагины"

po/tr.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ msgstr ""
6060
msgid "Half Shape is enabled."
6161
msgstr ""
6262

63-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
63+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6464
msgid "Latin Mode"
6565
msgstr "Latin Modu"
6666

67+
#: src/rimeengine.cpp:858
68+
msgid "Next Schema"
69+
msgstr ""
70+
6771
#: src/rimeengine.h:77
6872
msgid "Load available plugins automatically"
6973
msgstr "Kullanılabilir eklentileri otomatikmen yükle"

po/vi.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ msgstr ""
5959
msgid "Half Shape is enabled."
6060
msgstr ""
6161

62-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
62+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6363
msgid "Latin Mode"
6464
msgstr ""
6565

66+
#: src/rimeengine.cpp:858
67+
msgid "Next Schema"
68+
msgstr ""
69+
6670
#: src/rimeengine.h:77
6771
msgid "Load available plugins automatically"
6872
msgstr ""

po/zh_CN.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,14 @@ msgstr "已启用全角字符。 "
6161
msgid "Half Shape is enabled."
6262
msgstr "已启用半角字符。"
6363

64-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
64+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6565
msgid "Latin Mode"
6666
msgstr "英文模式"
6767

68+
#: src/rimeengine.cpp:858
69+
msgid "Next Schema"
70+
msgstr "下一个方案"
71+
6872
#: src/rimeengine.h:77
6973
msgid "Load available plugins automatically"
7074
msgstr "自动加载可用插件"

po/zh_TW.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,14 @@ msgstr "已啟用全形字符。"
6565
msgid "Half Shape is enabled."
6666
msgstr "已啟用半形字符。"
6767

68-
#: src/rimestate.cpp:67 src/rimeengine.cpp:822
68+
#: src/rimestate.cpp:67 src/rimeengine.cpp:828
6969
msgid "Latin Mode"
7070
msgstr "羅馬拼音模式"
7171

72+
#: src/rimeengine.cpp:858
73+
msgid "Next Schema"
74+
msgstr "下一个方案"
75+
7276
#: src/rimeengine.h:77
7377
msgid "Load available plugins automatically"
7478
msgstr "自動載入可用插件"

src/rimeengine.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,19 @@ void RimeEngine::updateSchemaMenu() {
852852
schemas_.insert(schemaId);
853853
}
854854
api_->free_schema_list(&list);
855+
856+
schemActions_.emplace_back();
857+
auto &schemaAction = schemActions_.back();
858+
schemaAction.setShortText(_("Next Schema"));
859+
schemaAction.connect<SimpleAction::Activated>(
860+
[this](InputContext *ic) {
861+
auto state = ic->propertyFor(&factory_);
862+
blockNotificationFor(30000);
863+
state->switchNextSchema();
864+
imAction_->update(ic);
865+
});
866+
instance_->userInterfaceManager().registerAction(&schemaAction);
867+
schemaMenu_.insertAction(&separatorAction_, &schemaAction);
855868
}
856869
}
857870

src/rimestate.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,39 @@ void RimeState::selectSchema(const std::string &schema) {
120120
api->select_schema(session(), schema.data());
121121
}
122122

123+
void RimeState::switchNextSchema() {
124+
std::string currentSchemaId;
125+
std::string targetSchemaId;
126+
const auto& schemas = engine_->schemas();
127+
auto api = engine_->api();
128+
if (api->is_maintenance_mode()) {
129+
return;
130+
}
131+
getStatus([&currentSchemaId](const RimeStatus &status) {
132+
currentSchemaId = status.schema_id ? status.schema_id : "";
133+
});
134+
if (currentSchemaId.empty()) {
135+
return;
136+
}
137+
targetSchemaId = *schemas.begin();
138+
if (schemas.count(currentSchemaId)) {
139+
auto it = schemas.find(currentSchemaId);
140+
if (it != schemas.end()) {
141+
++it;
142+
if (it != schemas.end()) {
143+
targetSchemaId = *it;
144+
}
145+
}
146+
}
147+
if (targetSchemaId.empty()) {
148+
return;
149+
}
150+
engine_->blockNotificationFor(30000);
151+
api->set_option(session(), RIME_ASCII_MODE, false);
152+
api->select_schema(session(), targetSchemaId.data());
153+
return;
154+
}
155+
123156
void RimeState::keyEvent(KeyEvent &event) {
124157
auto api = engine_->api();
125158
if (api->is_maintenance_mode()) {

src/rimestate.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class RimeState : public InputContextProperty {
3939
std::string subModeLabel();
4040
void toggleLatinMode();
4141
void setLatinMode(bool latin);
42+
void switchNextSchema();
4243
void selectSchema(const std::string &schemaId);
4344
RimeSessionId session(bool requestNewSession = true);
4445

0 commit comments

Comments
 (0)