diff options
author | Yusuf Keten <ketenyusuf@gmail.com> | 2020-07-11 08:23:20 +0300 |
---|---|---|
committer | Muhammet Kara <muhammet.kara@collabora.com> | 2020-07-19 11:45:50 +0200 |
commit | 27cf6e73d05ac803d5fc12c53aea20ed53007234 (patch) | |
tree | e1300782845d21b74736c6602ac9595ecb546947 /cui | |
parent | 7843b91477b8c6e39f02046625c8fa0940e52203 (diff) |
tdf#133026: Tight integration of extensions - Add the search functions
The search function added. However, I added a case for checking (UI change occurs when "2" is written) because the API is not ready at the moment.
The finalURL variable will be activated when the API is ready.
Change-Id: I23c83e28d6ad8dea6c52813b4c98d219299fa9f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98554
Tested-by: Jenkins
Reviewed-by: Muhammet Kara <muhammet.kara@collabora.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/AdditionsDialog.cxx | 60 | ||||
-rw-r--r-- | cui/source/inc/AdditionsDialog.hxx | 8 |
2 files changed, 67 insertions, 1 deletions
diff --git a/cui/source/dialogs/AdditionsDialog.cxx b/cui/source/dialogs/AdditionsDialog.cxx index ba49e07b9365..73b0247b8b0a 100644 --- a/cui/source/dialogs/AdditionsDialog.cxx +++ b/cui/source/dialogs/AdditionsDialog.cxx @@ -416,12 +416,20 @@ void SearchAndParseThread::execute() AdditionsDialog::AdditionsDialog(weld::Window* pParent) : GenericDialogController(pParent, "cui/ui/additionsdialog.ui", "AdditionsDialog") + , m_aSearchDataTimer("SearchDataTimer") , m_xEntrySearch(m_xBuilder->weld_entry("entrySearch")) , m_xMenuButtonSettings(m_xBuilder->weld_menu_button("buttonGear")) , m_xContentWindow(m_xBuilder->weld_scrolled_window("contentWindow")) , m_xContentGrid(m_xBuilder->weld_container("contentGrid")) , m_xLabelProgress(m_xBuilder->weld_label("labelProgress")) { + m_aSearchDataTimer.SetInvokeHandler(LINK(this, AdditionsDialog, ImplUpdateDataHdl)); + m_aSearchDataTimer.SetDebugName("AdditionsDialog SearchDataTimer"); + m_aSearchDataTimer.SetTimeout(EDIT_UPDATEDATA_TIMEOUT); + + m_xEntrySearch->connect_changed(LINK(this, AdditionsDialog, SearchUpdateHdl)); + m_xEntrySearch->connect_focus_out(LINK(this, AdditionsDialog, FocusOut_Impl)); + // TODO - Temporary URL OString rURL = "https://yusufketen.com/extensionTest.json"; @@ -456,4 +464,56 @@ void AdditionsDialog::SetProgress(const OUString& rProgress) } } +void AdditionsDialog::ClearList() +{ + // for VCL to be able to destroy bitmaps + SolarMutexGuard aGuard; + + for (auto& item : this->m_aAdditionsItems) + { + item.m_xContainer->hide(); + } + this->m_aAdditionsItems.clear(); +} + +IMPL_LINK_NOARG(AdditionsDialog, ImplUpdateDataHdl, Timer*, void) +{ + this->ClearList(); + OUString aSearchTerm(m_xEntrySearch->get_text()); + /* OPTIONAL + if (aSearchTerm.isEmpty()) + return; + */ + if (m_pSearchThread.is()) + m_pSearchThread->StopExecution(); + + OString rURL = "https://yusufketen.com/extensionTest.json"; // + q=aSearchTerm + OUString finalURL = OStringToOUString(rURL + "?q=", RTL_TEXTENCODING_UTF8) + aSearchTerm; + + // Search Test + if (aSearchTerm == "2") + { + rURL = "https://yusufketen.com/extensionTest2.json"; + } + + this->SetProgress(finalURL); + m_pSearchThread + = new SearchAndParseThread(this, OStringToOUString(rURL, RTL_TEXTENCODING_UTF8), false); + m_pSearchThread->launch(); +} + +IMPL_LINK_NOARG(AdditionsDialog, SearchUpdateHdl, weld::Entry&, void) +{ + m_aSearchDataTimer.Start(); +} + +IMPL_LINK_NOARG(AdditionsDialog, FocusOut_Impl, weld::Widget&, void) +{ + if (m_aSearchDataTimer.IsActive()) + { + m_aSearchDataTimer.Stop(); + m_aSearchDataTimer.Invoke(); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/AdditionsDialog.hxx b/cui/source/inc/AdditionsDialog.hxx index 8b3211bb3d1a..7983c1a0438a 100644 --- a/cui/source/inc/AdditionsDialog.hxx +++ b/cui/source/inc/AdditionsDialog.hxx @@ -13,6 +13,7 @@ #include <vcl/svapp.hxx> #include <salhelper/thread.hxx> #include <rtl/ref.hxx> +#include <vcl/timer.hxx> #include <vcl/weld.hxx> struct AdditionsItem @@ -57,7 +58,11 @@ class SearchAndParseThread; class AdditionsDialog : public weld::GenericDialogController { private: - // void fillGrid(); + Timer m_aSearchDataTimer; + + DECL_LINK(SearchUpdateHdl, weld::Entry&, void); + DECL_LINK(ImplUpdateDataHdl, Timer*, void); + DECL_LINK(FocusOut_Impl, weld::Widget&, void); public: std::unique_ptr<weld::Entry> m_xEntrySearch; @@ -74,6 +79,7 @@ public: ~AdditionsDialog() override; void SetProgress(const OUString& rProgress); + void ClearList(); }; class SearchAndParseThread : public salhelper::Thread |