Kaydet (Commit) b2eae358 authored tarafından heiko tietze's avatar heiko tietze Kaydeden (comit) Heiko Tietze

Resolves tdf#124978 - Tip-of-the-day references

* LibreOffice changed into %PRODUCTNAME
* std::pair made into std::tuple and hyperlinks separated from strings
* tip about donation / getinvolved added
* "Use an array formula to repeat a calculation with different values..." removed
* "%PRODUCTNAME supports 110 languages"->"%PRODUCTNAME supports over 150 languages"
* code added to open offline help
* online hyperlinks converted into offline links, if available
* Ctrl, Shift, Alt uppercased
* › replace by >
* ellipsis removed

Change-Id: Ic35257d0a6d6e77750716254fb9d1f6983a54af1
Reviewed-on: https://gerrit.libreoffice.org/71760
Tested-by: Jenkins
Reviewed-by: 's avatarHeiko Tietze <tietze.heiko@gmail.com>
üst 34d12802
This diff is collapsed.
......@@ -27,6 +27,8 @@
#include <tipoftheday.hrc>
#include <vcl/graphicfilter.hxx>
#include <vcl/virdev.hxx>
#include <sfx2/sfxhelp.hxx>
#include <vcl/svapp.hxx>
TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent)
: GenericDialogController(pParent, "cui/ui/tipofthedaydialog.ui", "TipOfTheDayDialog")
......@@ -64,35 +66,42 @@ static bool file_exists(const OUString& fileName)
void TipOfTheDayDialog::UpdateTip()
{
//get string
OUString aText;
aText = CuiResId(TIPOFTHEDAY_STRINGARRAY[nCurrentTip].first);
//move hyperlink into linkbutton
sal_Int32 nPos = aText.indexOf("http");
if (nPos > 0)
// text
OUString aText = CuiResId(std::get<0>(TIPOFTHEDAY_STRINGARRAY[nCurrentTip]));
m_pText->set_label(aText);
// hyperlink
aLink = std::get<1>(TIPOFTHEDAY_STRINGARRAY[nCurrentTip]);
if (aLink.isEmpty())
{
m_pLink->set_visible(false);
}
else if (aLink.startsWith("http"))
{
m_pLink->set_uri(aLink);
m_pLink->set_label(CuiResId(STR_MORE_LINK));
m_pLink->set_visible(true);
if (aText.getLength() - nPos > 40)
m_pLink->set_label(aText.copy(nPos, 40) + "...");
else
m_pLink->set_label(aText.copy(nPos));
m_pLink->set_uri(aText.copy(nPos));
aText = aText.copy(0, nPos - 1);
m_pLink->connect_clicked(Link<weld::LinkButton&, void>());
}
else
m_pLink->set_visible(false);
m_pText->set_label(aText);
{
m_pLink->set_uri("");
m_pLink->set_label(CuiResId(STR_HELP_LINK));
m_pLink->set_visible(true);
//converts aLink into the proper offline/online hyperlink
m_pLink->connect_clicked(LINK(this, TipOfTheDayDialog, OnLinkClick));
}
// import the image
// image
OUString aURL("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/tipoftheday/");
rtl::Bootstrap::expandMacros(aURL);
OUString aName = TIPOFTHEDAY_STRINGARRAY[nCurrentTip].second;
OUString aImage = std::get<2>(TIPOFTHEDAY_STRINGARRAY[nCurrentTip]);
// use default image if none is available with the number
if (aName.isEmpty() || !file_exists(aURL + aName))
aName = "tipoftheday.png";
if (aImage.isEmpty() || !file_exists(aURL + aImage))
aImage = "tipoftheday.png";
// draw image
Graphic aGraphic;
if (GraphicFilter::LoadGraphic(aURL + aName, OUString(), aGraphic) == ERRCODE_NONE)
if (GraphicFilter::LoadGraphic(aURL + aImage, OUString(), aGraphic) == ERRCODE_NONE)
{
ScopedVclPtr<VirtualDevice> m_pVirDev;
m_pVirDev = m_pImage->create_virtual_device();
......@@ -111,6 +120,11 @@ IMPL_STATIC_LINK(TipOfTheDayDialog, OnShowTipToggled, weld::ToggleButton&, rButt
xChanges->commit();
}
IMPL_LINK_NOARG(TipOfTheDayDialog, OnLinkClick, weld::LinkButton&, void)
{
Application::GetHelp()->Start(aLink, static_cast<weld::Widget*>(nullptr));
}
IMPL_LINK_NOARG(TipOfTheDayDialog, OnNextClick, weld::Button&, void)
{
nCurrentTip = rand() % nNumberOfTips;
......
......@@ -32,9 +32,11 @@ private:
sal_uInt32 nCurrentTip;
sal_uInt32 nNumberOfTips;
OUString aLink;
void UpdateTip();
DECL_STATIC_LINK(TipOfTheDayDialog, OnShowTipToggled, weld::ToggleButton&, void);
DECL_LINK(OnNextClick, weld::Button&, void);
DECL_LINK(OnLinkClick, weld::LinkButton&, void);
public:
TipOfTheDayDialog(weld::Window* pWindow);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment