summaryrefslogtreecommitdiff
path: root/cui/source/dialogs
diff options
context:
space:
mode:
authorYusuf Keten <ketenyusuf@gmail.com>2020-07-11 08:23:20 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2020-07-19 11:45:50 +0200
commit27cf6e73d05ac803d5fc12c53aea20ed53007234 (patch)
treee1300782845d21b74736c6602ac9595ecb546947 /cui/source/dialogs
parent7843b91477b8c6e39f02046625c8fa0940e52203 (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/source/dialogs')
-rw-r--r--cui/source/dialogs/AdditionsDialog.cxx60
1 files changed, 60 insertions, 0 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: */