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

Resolves: tdf#124743 - Tip of the Day randomization

srand() added, image file name part of the hrc definition now

Change-Id: Ib697f64406ab6b11468eb837c71d57398a0533b5
Reviewed-on: https://gerrit.libreoffice.org/70767
Tested-by: Jenkins
Reviewed-by: 's avatarHeiko Tietze <tietze.heiko@gmail.com>
üst 0871804b
This diff is collapsed.
......@@ -40,6 +40,7 @@ TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent)
m_pNext->connect_clicked(LINK(this, TipOfTheDayDialog, OnNextClick));
nNumberOfTips = SAL_N_ELEMENTS(TIPOFTHEDAY_STRINGARRAY);
srand(time(nullptr));
nCurrentTip = rand() % nNumberOfTips;
UpdateTip();
}
......@@ -65,7 +66,7 @@ void TipOfTheDayDialog::UpdateTip()
{
//get string
OUString aText;
aText = CuiResId(TIPOFTHEDAY_STRINGARRAY[nCurrentTip]);
aText = CuiResId(TIPOFTHEDAY_STRINGARRAY[nCurrentTip].first);
//move hyperlink into linkbutton
sal_Int32 nPos = aText.indexOf("http");
if (nPos > 0)
......@@ -85,9 +86,9 @@ void TipOfTheDayDialog::UpdateTip()
// import the image
OUString aURL("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/tipoftheday/");
rtl::Bootstrap::expandMacros(aURL);
OUString aName = "tipoftheday_" + OUString::number(nCurrentTip) + ".png";
OUString aName = TIPOFTHEDAY_STRINGARRAY[nCurrentTip].second;
// use default image if none is available with the number
if (!file_exists(aURL + aName))
if (aName.isEmpty() || !file_exists(aURL + aName))
aName = "tipoftheday.png";
// draw image
Graphic aGraphic;
......
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