jsdialog: force update if tab is selected again
This will allow to add additional tabs in the view (not existing in the JSON) and switching tabs still will work properly. Change-Id: Ia6901da3157b391502d5170f599410bfd6ea2c61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98253 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98900 Tested-by: Jenkins
This commit is contained in:
parent
710edb329f
commit
915df5936a
2 changed files with 26 additions and 5 deletions
|
@ -29,11 +29,13 @@ class JSDialogNotifyIdle : public Idle
|
|||
{
|
||||
VclPtr<vcl::Window> m_aWindow;
|
||||
std::string m_LastNotificationMessage;
|
||||
bool m_bForce;
|
||||
|
||||
public:
|
||||
JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow);
|
||||
|
||||
void Invoke() override;
|
||||
void ForceUpdate();
|
||||
};
|
||||
|
||||
class JSDialogSender
|
||||
|
@ -46,7 +48,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void notifyDialogState();
|
||||
void notifyDialogState(bool bForce = false);
|
||||
};
|
||||
|
||||
class JSInstanceBuilder : public SalInstanceBuilder
|
||||
|
|
|
@ -26,10 +26,13 @@ JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow)
|
|||
: Idle("JSDialog notify")
|
||||
, m_aWindow(aWindow)
|
||||
, m_LastNotificationMessage()
|
||||
, m_bForce(false)
|
||||
{
|
||||
SetPriority(TaskPriority::POST_PAINT);
|
||||
}
|
||||
|
||||
void JSDialogNotifyIdle::ForceUpdate() { m_bForce = true; }
|
||||
|
||||
void JSDialogNotifyIdle::Invoke()
|
||||
{
|
||||
try
|
||||
|
@ -43,8 +46,9 @@ void JSDialogNotifyIdle::Invoke()
|
|||
tools::JsonWriter aJsonWriter;
|
||||
m_aWindow->DumpAsPropertyTree(aJsonWriter);
|
||||
aJsonWriter.put("id", m_aWindow->GetLOKWindowId());
|
||||
if (!aJsonWriter.isDataEquals(m_LastNotificationMessage))
|
||||
if (m_bForce || !aJsonWriter.isDataEquals(m_LastNotificationMessage))
|
||||
{
|
||||
m_bForce = false;
|
||||
m_LastNotificationMessage = aJsonWriter.extractAsStdString();
|
||||
pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG,
|
||||
m_LastNotificationMessage.c_str());
|
||||
|
@ -57,7 +61,12 @@ void JSDialogNotifyIdle::Invoke()
|
|||
}
|
||||
}
|
||||
|
||||
void JSDialogSender::notifyDialogState() { mpIdleNotify->Start(); }
|
||||
void JSDialogSender::notifyDialogState(bool bForce)
|
||||
{
|
||||
if (bForce)
|
||||
mpIdleNotify->ForceUpdate();
|
||||
mpIdleNotify->Start();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -485,14 +494,24 @@ JSNotebook::JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pContro
|
|||
|
||||
void JSNotebook::set_current_page(int nPage)
|
||||
{
|
||||
bool bForce = false;
|
||||
int nCurrent = get_current_page();
|
||||
if (nCurrent == nPage)
|
||||
bForce = true;
|
||||
|
||||
SalInstanceNotebook::set_current_page(nPage);
|
||||
notifyDialogState();
|
||||
notifyDialogState(bForce);
|
||||
}
|
||||
|
||||
void JSNotebook::set_current_page(const OString& rIdent)
|
||||
{
|
||||
bool bForce = false;
|
||||
OString sCurrent = get_current_page_ident();
|
||||
if (sCurrent == rIdent)
|
||||
bForce = true;
|
||||
|
||||
SalInstanceNotebook::set_current_page(rIdent);
|
||||
notifyDialogState();
|
||||
notifyDialogState(bForce);
|
||||
}
|
||||
|
||||
void JSNotebook::remove_page(const OString& rIdent)
|
||||
|
|
Loading…
Reference in a new issue