Skip to content

Commit 81840c3

Browse files
committed
add nextSchemaOption
1 parent 68fc613 commit 81840c3

16 files changed

+106
-14
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

+14-1
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,22 @@ void RimeEngine::updateSchemaMenu() {
849849
instance_->userInterfaceManager().registerAction(&schemaAction);
850850
schemaMenu_.insertAction(&separatorAction_, &schemaAction);
851851
updateActionsForSchema(schemaId);
852-
schemas_.insert(schemaId);
852+
schemas_.push_back(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("fcitx-rime-next-schema", &schemaAction);
867+
schemaMenu_.insertAction(&separatorAction_, &schemaAction);
855868
}
856869
}
857870

src/rimeengine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class RimeEngine final : public InputMethodEngineV2 {
184184

185185
FCITX_ADDON_DEPENDENCY_LOADER(notifications, instance_->addonManager());
186186

187-
std::unordered_set<std::string> schemas_;
187+
std::vector<std::string> schemas_;
188188
std::list<SimpleAction> schemActions_;
189189
std::unordered_map<std::string,
190190
std::list<std::unique_ptr<RimeOptionAction>>>

src/rimestate.cpp

+31-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,36 @@ 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.empty()) {
139+
auto it = std::find(schemas.begin(), schemas.end(), currentSchemaId);
140+
if (it != schemas.end() && std::next(it) != schemas.end()) {
141+
targetSchemaId = *std::next(it);
142+
}
143+
}
144+
if (targetSchemaId.empty()) {
145+
return;
146+
}
147+
engine_->blockNotificationFor(30000);
148+
api->set_option(session(), RIME_ASCII_MODE, false);
149+
api->select_schema(session(), targetSchemaId.data());
150+
return;
151+
}
152+
123153
void RimeState::keyEvent(KeyEvent &event) {
124154
auto api = engine_->api();
125155
if (api->is_maintenance_mode()) {
@@ -388,7 +418,7 @@ void RimeState::restore() {
388418
if (savedCurrentSchema_.empty()) {
389419
return;
390420
}
391-
if (!engine_->schemas().count(savedCurrentSchema_)) {
421+
if (!std::count(engine_->schemas().begin(), engine_->schemas().end(), savedCurrentSchema_)) {
392422
return;
393423
}
394424

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)