Resolves tdf#137607 and tdf#137500 - Improvements to TotD
Shows tooltip for UNO commands Check if the UNO command is available in the current module Don't show the menu entry on the start center Change-Id: I5c67ec3f8543b5442a6e2c2a478bfeb4ec0e1f3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104558 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
committed by
Heiko Tietze
parent
fe2b4e7dc6
commit
31763e5af0
@@ -32,6 +32,7 @@
|
||||
* uri:
|
||||
* if uri is empty, do not show any link
|
||||
* if uri starts with "http", show the link directly in the browser
|
||||
* if uri starts with ".uno:", run the command if available in the current module
|
||||
* all other strings are converted to a link for the offline help
|
||||
* to find the right uri, look in instdir/help/hid2file.js after building --with-help=html
|
||||
* structure of hid2file.js 'uri' : 'rest of URL' (that starts: https://help.libreoffice.org/latest/en-US/)
|
||||
|
||||
@@ -21,11 +21,19 @@
|
||||
#include <tipofthedaydlg.hxx>
|
||||
#include <tipoftheday.hrc>
|
||||
|
||||
#include <sfx2/viewfrm.hxx>
|
||||
#include <vcl/commandinfoprovider.hxx>
|
||||
#include <vcl/graphicfilter.hxx>
|
||||
#include <vcl/help.hxx>
|
||||
#include <vcl/virdev.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
|
||||
#include <com/sun/star/frame/XDesktop2.hpp>
|
||||
#include <com/sun/star/frame/XDispatch.hpp>
|
||||
#include <com/sun/star/frame/XDispatchProvider.hpp>
|
||||
#include <com/sun/star/util/URL.hpp>
|
||||
#include <com/sun/star/util/URLTransformer.hpp>
|
||||
|
||||
#include <comphelper/dispatchcommand.hxx>
|
||||
#include <comphelper/propertysequence.hxx>
|
||||
#include <dialmgr.hxx>
|
||||
@@ -105,10 +113,42 @@ void TipOfTheDayDialog::UpdateTip()
|
||||
}
|
||||
else if (sLink.startsWith(".uno:"))
|
||||
{
|
||||
m_pLink->set_uri(sLink);
|
||||
m_pLink->set_label(CuiResId(STR_UNO_LINK));
|
||||
m_pLink->set_visible(true);
|
||||
m_pLink->connect_activate_link(LINK(this, TipOfTheDayDialog, OnLinkClick));
|
||||
m_pLink->set_visible(false);
|
||||
//show the link only if the UNO command is available in the current module
|
||||
SfxViewFrame* pViewFrame = SfxViewFrame::Current();
|
||||
if (pViewFrame)
|
||||
{
|
||||
const auto xFrame = pViewFrame->GetFrame().GetFrameInterface();
|
||||
const css::uno::Reference<css::frame::XDispatchProvider> xDispatchProvider(
|
||||
xFrame, css::uno::UNO_QUERY);
|
||||
if (xDispatchProvider.is())
|
||||
{
|
||||
css::util::URL aCommandURL;
|
||||
aCommandURL.Complete = sLink;
|
||||
const css::uno::Reference<css::uno::XComponentContext> xContext
|
||||
= comphelper::getProcessComponentContext();
|
||||
const css::uno::Reference<css::util::XURLTransformer> xParser
|
||||
= css::util::URLTransformer::create(xContext);
|
||||
xParser->parseStrict(aCommandURL);
|
||||
const css::uno::Reference<css::frame::XDispatch> xDisp
|
||||
= xDispatchProvider->queryDispatch(aCommandURL, OUString(), 0);
|
||||
if (xDisp.is())
|
||||
{
|
||||
m_pLink->set_label(CuiResId(STR_UNO_LINK));
|
||||
m_pLink->set_uri(sLink);
|
||||
|
||||
const OUString aModuleName(
|
||||
vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
|
||||
const auto aProperties
|
||||
= vcl::CommandInfoProvider::GetCommandProperties(sLink, aModuleName);
|
||||
m_pLink->set_tooltip_text(
|
||||
vcl::CommandInfoProvider::GetTooltipForCommand(sLink, aProperties, xFrame));
|
||||
|
||||
m_pLink->set_visible(true);
|
||||
m_pLink->connect_activate_link(LINK(this, TipOfTheDayDialog, OnLinkClick));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sLink.startsWith("http"))
|
||||
{
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
<menu:menuitem menu:id=".uno:HelpIndex"/>
|
||||
<menu:menuitem menu:id=".uno:ExtendedHelp"/>
|
||||
<menu:menuitem menu:id=".uno:Documentation"/>
|
||||
<menu:menuitem menu:id=".uno:TipOfTheDay"/>
|
||||
<menu:menuseparator/>
|
||||
<menu:menuitem menu:id=".uno:QuestionAnswers"/>
|
||||
<menu:menuitem menu:id=".uno:SendFeedback"/>
|
||||
|
||||
@@ -6233,6 +6233,9 @@
|
||||
<prop oor:name="Label" oor:type="xs:string">
|
||||
<value xml:lang="en-US">User ~Interface...</value>
|
||||
</prop>
|
||||
<prop oor:name="TooltipLabel" oor:type="xs:string">
|
||||
<value xml:lang="en-US">Shows a dialog to select the user interface</value>
|
||||
</prop>
|
||||
<prop oor:name="Properties" oor:type="xs:int">
|
||||
<value>1</value>
|
||||
</prop>
|
||||
|
||||
Reference in New Issue
Block a user