diff options
author | Heiko Tietze <tietze.heiko@gmail.com> | 2020-10-23 13:30:17 +0200 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2020-10-24 10:12:08 +0200 |
commit | 92ab0afa1c36bfbc99de25a53a108b6f28e0e627 (patch) | |
tree | ed4433c6202cadb40f0fe4fb4099794cd7cab76a /cui/source/dialogs | |
parent | 3c09c306a15e8c40deedb08d6bcf38b9ee190db4 (diff) |
Show animated GIFs in TotD
marchingants.gif added as an example
Change-Id: I555aebc4a4e191b8afb4be06dfc1e5f3e6d1a911
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104718
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'cui/source/dialogs')
-rw-r--r-- | cui/source/dialogs/tipofthedaydlg.cxx | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/cui/source/dialogs/tipofthedaydlg.cxx b/cui/source/dialogs/tipofthedaydlg.cxx index beed468ba5b6..b88369890529 100644 --- a/cui/source/dialogs/tipofthedaydlg.cxx +++ b/cui/source/dialogs/tipofthedaydlg.cxx @@ -25,8 +25,6 @@ #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> @@ -46,11 +44,11 @@ TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent) : GenericDialogController(pParent, "cui/ui/tipofthedaydialog.ui", "TipOfTheDayDialog") - , m_pImage(m_xBuilder->weld_image("imImage")) , m_pText(m_xBuilder->weld_label("lbText")) , m_pShowTip(m_xBuilder->weld_check_button("cbShowTip")) , m_pNext(m_xBuilder->weld_button("btnNext")) , m_pLink(m_xBuilder->weld_link_button("btnLink")) + , m_pPreview(new weld::CustomWeld(*m_xBuilder, "imPreview", m_aPreview)) { m_pShowTip->set_active(officecfg::Office::Common::Misc::ShowTipOfTheDay::get()); m_pNext->connect_clicked(LINK(this, TipOfTheDayDialog, OnNextClick)); @@ -62,6 +60,8 @@ TipOfTheDayDialog::TipOfTheDayDialog(weld::Window* pParent) if (m_nDay > officecfg::Office::Common::Misc::LastTipOfTheDayShown::get()) m_nCurrentTip++; + m_aPreview.init(&m_aGraphic, LINK(this, TipOfTheDayDialog, ImplModifyHdl)); + UpdateTip(); } @@ -172,20 +172,16 @@ void TipOfTheDayDialog::UpdateTip() // image OUString aURL("$BRAND_BASE_DIR/$BRAND_SHARE_SUBDIR/tipoftheday/"); rtl::Bootstrap::expandMacros(aURL); - OUString aImage = sImage; + OUString aImageName = sImage; // use default image if none is available with the number - if (aImage.isEmpty() || !file_exists(aURL + aImage)) - aImage = "tipoftheday.png"; - // draw image - Graphic aGraphic; - if (GraphicFilter::LoadGraphic(aURL + aImage, OUString(), aGraphic) == ERRCODE_NONE) - { - ScopedVclPtr<VirtualDevice> m_pVirDev = m_pImage->create_virtual_device(); - m_pVirDev->SetOutputSizePixel(aGraphic.GetSizePixel()); - m_pVirDev->DrawBitmapEx(Point(0, 0), aGraphic.GetBitmapEx()); - m_pImage->set_image(m_pVirDev.get()); - m_pVirDev.disposeAndClear(); - } + if (aImageName.isEmpty() || !file_exists(aURL + aImageName)) + aImageName = "tipoftheday.png"; + GraphicFilter::LoadGraphic(aURL + aImageName, OUString(), m_aGraphic); +} + +IMPL_LINK_NOARG(TipOfTheDayDialog, ImplModifyHdl, LinkParamNone*, void) +{ + m_aPreview.SetPreview(m_aGraphic); } IMPL_LINK(TipOfTheDayDialog, OnLinkClick, weld::LinkButton&, rButton, bool) |