From 2527fc3af02756f1646fa62548c415e1052f6211 Mon Sep 17 00:00:00 2001 From: lilf03 Date: Mon, 9 Sep 2024 15:43:25 +0800 Subject: [PATCH] Support paste text to search input --- library/clip | 2 +- resources/i18n/en-US/hints.json | 1 + resources/i18n/zh-Hans/hints.json | 1 + resources/i18n/zh-Hant/hints.json | 1 + wiliwili/source/activity/search_activity_tv.cpp | 14 ++++++++++++++ wiliwili/source/utils/config_helper.cpp | 4 +--- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/library/clip b/library/clip index 94693e241..1d5d20cef 160000 --- a/library/clip +++ b/library/clip @@ -1 +1 @@ -Subproject commit 94693e2414a2c69a8ca16f065240c80a94cc6221 +Subproject commit 1d5d20cefbe388b3cde285a4ec61114238d3fa70 diff --git a/resources/i18n/en-US/hints.json b/resources/i18n/en-US/hints.json index 34c599101..b5ac02e55 100644 --- a/resources/i18n/en-US/hints.json +++ b/resources/i18n/en-US/hints.json @@ -5,6 +5,7 @@ "exit": "Exit", "on": "On", "off": "Off", + "paste": "Paste", "delete": "Delete", "save": "Save", "submit": "Submit", diff --git a/resources/i18n/zh-Hans/hints.json b/resources/i18n/zh-Hans/hints.json index f021d6b1f..84765657f 100644 --- a/resources/i18n/zh-Hans/hints.json +++ b/resources/i18n/zh-Hans/hints.json @@ -5,6 +5,7 @@ "exit": "退出", "on": "开", "off": "关", + "paste": "粘贴", "delete": "删除", "save": "保存", "submit": "提交", diff --git a/resources/i18n/zh-Hant/hints.json b/resources/i18n/zh-Hant/hints.json index 1584c76a2..837ab1044 100644 --- a/resources/i18n/zh-Hant/hints.json +++ b/resources/i18n/zh-Hant/hints.json @@ -5,6 +5,7 @@ "exit": "退出", "on": "開", "off": "關", + "paste": "粘貼", "delete": "刪除", "save": "儲存", "submit": "提交", diff --git a/wiliwili/source/activity/search_activity_tv.cpp b/wiliwili/source/activity/search_activity_tv.cpp index b7e2132ba..02551e6e6 100644 --- a/wiliwili/source/activity/search_activity_tv.cpp +++ b/wiliwili/source/activity/search_activity_tv.cpp @@ -21,6 +21,10 @@ #include "bilibili/result/search_result.h" #include "analytics.h" +#if defined(__APPLE__) || defined(__linux__) || defined(_WIN32) +#include +#endif + using namespace brls::literals; typedef brls::Event KeyboardEvent; @@ -164,6 +168,16 @@ void TVSearchActivity::onContentAvailable() { return true; }); inputLabel->getParent()->addGestureRecognizer(new brls::TapGestureRecognizer(this->inputLabel->getParent())); +#if defined(__APPLE__) || defined(__linux__) || defined(_WIN32) + inputLabel->getParent()->registerAction("hints/paste"_i18n, brls::BUTTON_B, [this](brls::View* view) { + std::string text; + if (clip::get_text(text)) { + this->setCurrentSearch(text); + this->updateInputLabel(); + } + return true; + }); +#endif KeyboardData keyboard; for (int i = 'A'; i <= 'Z'; i++) { diff --git a/wiliwili/source/utils/config_helper.cpp b/wiliwili/source/utils/config_helper.cpp index dfae23125..3ff8bef79 100644 --- a/wiliwili/source/utils/config_helper.cpp +++ b/wiliwili/source/utils/config_helper.cpp @@ -7,9 +7,6 @@ #elif defined(__APPLE__) || defined(__linux__) || defined(_WIN32) #include #include -#if defined(_WIN32) -#include -#endif #endif #include @@ -48,6 +45,7 @@ extern in_addr_t secondary_dns; #ifdef _WIN32 #include +#include #endif #ifndef PATH_MAX