Rebased ref, commits from common ancestor: commit 3797cfec7f04f46110d26ca13dbfc7e50ddedc25 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Tue Mar 31 15:42:28 2020 +0200 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Apr 1 11:46:16 2020 +0200
jsdialog: use Idle timer to send updates Change-Id: Ib4f18bab1279c622b576dca53169b40c4a2526bc diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index d01d878828c2..4a9b4e1d6fbc 100644 --- a/include/vcl/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -14,12 +14,24 @@ typedef std::map<OString, weld::Widget*> WidgetMap; +class JSDialogNotifyIdle : public Idle +{ + VclPtr<vcl::Window> m_aWindow; + std::string m_LastNotificationMessage; + +public: + JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow); + + void Invoke() override; +}; + class VCL_DLLPUBLIC JSDialogSender { - VclPtr<vcl::Window> m_aOwnedToplevel; + std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify; + public: JSDialogSender(VclPtr<vcl::Window> aOwnedToplevel) - : m_aOwnedToplevel(aOwnedToplevel) + : mpIdleNotify(new JSDialogNotifyIdle(aOwnedToplevel)) {} void notifyDialogState(); diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 7db752b77045..bfc58fa09076 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -7,23 +7,47 @@ using namespace weld; -void JSDialogSender::notifyDialogState() +JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow) +: Idle("JSDialog notify") +, m_aWindow(aWindow) +, m_LastNotificationMessage() { - if (!m_aOwnedToplevel) - return; + SetPriority(TaskPriority::POST_PAINT); +} - const vcl::ILibreOfficeKitNotifier* pNotifier = m_aOwnedToplevel->GetLOKNotifier(); - if (pNotifier) +void JSDialogNotifyIdle::Invoke() +{ + try { - std::stringstream aStream; - boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree(); - aTree.put("id", m_aOwnedToplevel->GetLOKWindowId()); - boost::property_tree::write_json(aStream, aTree); - const std::string message = aStream.str(); - pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + if (!m_aWindow) + return; + + const vcl::ILibreOfficeKitNotifier* pNotifier = m_aWindow->GetLOKNotifier(); + if (pNotifier) + { + std::stringstream aStream; + boost::property_tree::ptree aTree = m_aWindow->DumpAsPropertyTree(); + aTree.put("id", m_aWindow->GetLOKWindowId()); + boost::property_tree::write_json(aStream, aTree); + const std::string message = aStream.str(); + if (message != m_LastNotificationMessage) + { + m_LastNotificationMessage = message; + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str()); + } + } + } + catch (boost::property_tree::json_parser::json_parser_error& rError) + { + SAL_WARN("vcl.jsdialog", rError.message()); } } +void JSDialogSender::notifyDialogState() +{ + mpIdleNotify->Start(); +} + JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) : SalInstanceBuilder( dynamic_cast<SalInstanceWidget*>(pParent) ? commit 77760691b4cfaa4a869ceb3f021b1fcfadf3ea1c Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Thu Mar 26 11:49:24 2020 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Wed Apr 1 11:43:23 2020 +0200 jsdialog: mobile version of spell dialog Change-Id: I611b09a8ffb6eb1972ba8702a7a76c9e6ab25fb4 diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 68ef370f65e7..416f2118b522 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -60,6 +60,8 @@ #include <svtools/langtab.hxx> #include <cppuhelper/exc_hlp.hxx> #include <sal/log.hxx> +#include <comphelper/lok.hxx> +#include <sfx2/lokhelper.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -192,9 +194,23 @@ SpellDialog::SpellDialog(SpellDialogChildWindow* pChildWindow, , m_xOptionsPB(m_xBuilder->weld_button("options")) , m_xUndoPB(m_xBuilder->weld_button("undo")) , m_xClosePB(m_xBuilder->weld_button("close")) + , m_xHelpPB(m_xBuilder->weld_button("help")) , m_xToolbar(m_xBuilder->weld_toolbar("toolbar")) , m_xSentenceEDWeld(new weld::CustomWeld(*m_xBuilder, "sentence", *m_xSentenceED)) + , m_xMobileError(m_xBuilder->weld_label("mobile-spell-error")) { + m_xSentenceED->SetMobileErrorLabel(m_xMobileError); + + if (comphelper::LibreOfficeKit::isActive() + && comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView())) + { + m_xClosePB->hide(); + m_xHelpPB->hide(); + m_xOptionsPB->hide(); + m_xSentenceEDWeld->hide(); + m_xMobileError->set_visible(true); + } + m_xSentenceED->SetSpellDialog(this); m_xSentenceED->Init(m_xToolbar.get()); @@ -1667,6 +1683,8 @@ bool SentenceEditWindow_Impl::MarkNextError( bool bIgnoreCurrentError, const css if (pEECharAttrib) { ExtractErrorDescription(*pEECharAttrib, aSpellErrorDescription); + if (m_xMobileError) + m_xMobileError->set_label(aSpellErrorDescription.sErrorText); bGrammarError = aSpellErrorDescription.bIsGrammarError; m_nErrorStart = pEECharAttrib->nStart; diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index 30d8627084cb..92d4a9ed6391 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -65,6 +65,7 @@ class SentenceEditWindow_Impl : public weld::CustomWidgetController private: std::unique_ptr<EditEngine> m_xEditEngine; std::unique_ptr<EditView> m_xEdView; + std::shared_ptr<weld::Label> m_xMobileError; std::set<sal_Int32> m_aIgnoreErrorsAt; SpellDialog* m_pSpellDialog; @@ -155,6 +156,8 @@ public: void MoveErrorEnd(long nOffset); void ResetIgnoreErrorsAt() { m_aIgnoreErrorsAt.clear(); } + + void SetMobileErrorLabel(std::shared_ptr<weld::Label> xMobileError) { m_xMobileError = xMobileError; } }; // class SvxSpellDialog --------------------------------------------- @@ -206,8 +209,10 @@ private: std::unique_ptr<weld::Button> m_xOptionsPB; std::unique_ptr<weld::Button> m_xUndoPB; std::unique_ptr<weld::Button> m_xClosePB; + std::unique_ptr<weld::Button> m_xHelpPB; std::unique_ptr<weld::Toolbar> m_xToolbar; std::unique_ptr<weld::CustomWeld> m_xSentenceEDWeld; + std::shared_ptr<weld::Label> m_xMobileError; DECL_LINK(ChangeHdl, weld::Button&, void); DECL_LINK(DoubleClickChangeHdl, weld::TreeView&, void); diff --git a/cui/uiconfig/ui/spellingdialog.ui b/cui/uiconfig/ui/spellingdialog.ui index ccc6a30e7a46..f80e6ec80d82 100644 --- a/cui/uiconfig/ui/spellingdialog.ui +++ b/cui/uiconfig/ui/spellingdialog.ui @@ -81,6 +81,7 @@ <property name="receives_default">True</property> <property name="use_underline">True</property> <property name="use_stock">True</property> + <property name="sensitive">False</property> </object> <packing> <property name="expand">False</property> @@ -425,6 +426,16 @@ <property name="top_attach">2</property> </packing> </child> + <child> + <object class="GtkLabel" id="mobile-spell-error"> + <property name="visible">False</property> + <property name="can_focus">False</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">2</property> + </packing> + </child> <child> <object class="GtkScrolledWindow"> <property name="visible">True</property> diff --git a/solenv/sanitizers/ui/cui.suppr b/solenv/sanitizers/ui/cui.suppr index 59f22233ff39..549954c47a90 100644 --- a/solenv/sanitizers/ui/cui.suppr +++ b/solenv/sanitizers/ui/cui.suppr @@ -460,6 +460,7 @@ cui/uiconfig/ui/spellingdialog.ui://GtkLabel[@id='explain'] orphan-label cui/uiconfig/ui/spellingdialog.ui://GtkLabel[@id='resumeft'] orphan-label cui/uiconfig/ui/spellingdialog.ui://GtkLabel[@id='nosuggestionsft'] orphan-label cui/uiconfig/ui/spellingdialog.ui://GtkLabel[@id='alttitleft'] orphan-label +cui/uiconfig/ui/spellingdialog.ui://GtkLabel[@id='mobile-spell-error'] orphan-label cui/uiconfig/ui/storedwebconnectiondialog.ui://GtkLabel[@id='label1'] orphan-label cui/uiconfig/ui/storedwebconnectiondialog.ui://GtkLabel[@id='website'] orphan-label cui/uiconfig/ui/storedwebconnectiondialog.ui://GtkLabel[@id='username'] orphan-label diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index efd46f9adec0..d9786bc4d70b 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -154,6 +154,7 @@ weld::Builder* Application::CreateBuilder(weld::Widget* pParent, const OUString rUIFile == "modules/scalc/ui/validationcriteriapage.ui" || rUIFile == "modules/scalc/ui/validationhelptabpage-mobile.ui" || rUIFile == "modules/scalc/ui/erroralerttabpage-mobile.ui" || + rUIFile == "cui/ui/spellingdialog.ui" || rUIFile == "modules/swriter/ui/watermarkdialog.ui") bUseJSBuilder = true; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits