diff options
author | Bayram Çiçek <mail@bayramcicek.com.tr> | 2021-03-03 21:57:11 +0300 |
---|---|---|
committer | Adolfo Jayme Barrientos <fitojb@ubuntu.com> | 2021-04-06 15:52:58 +0200 |
commit | 6fcabbd6199869753fd6a266f23901962a77f556 (patch) | |
tree | d19f63c12b8441fa5ac8322972f7e506a7420728 /framework | |
parent | no need to check mxSalBmp here (diff) | |
download | core-6fcabbd6199869753fd6a266f23901962a77f556.tar.gz core-6fcabbd6199869753fd6a266f23901962a77f556.zip |
tdf#129153: Show MIME type icon in main menu File>Recent documents list
- MIME type icons added for all items of the recent
documents list.
- It respects the user choice about "show
icons in menus" configuration. (e.g. under gtk3)
Change-Id: Icd94880fcda06ab2e2d9615a03be5d3373799314
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111934
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/uielement/recentfilesmenucontroller.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index a5792d29b224..ee22dd306a5e 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -28,6 +28,9 @@ #include <unotools/historyoptions.hxx> #include <vcl/menu.hxx> #include <vcl/svapp.hxx> +#include <vcl/image.hxx> +#include <vcl/settings.hxx> +#include <svtools/imagemgr.hxx> using namespace css; using namespace com::sun::star::uno; @@ -131,6 +134,7 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > int nPickListMenuItems = std::min<sal_Int32>( aHistoryList.getLength(), MAX_MENU_ITEMS ); m_aRecentFilesItems.clear(); + if (( nPickListMenuItems > 0 ) && !m_bDisabled ) { for ( int i = 0; i < nPickListMenuItems; i++ ) @@ -181,6 +185,9 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > INetURLObject aURL( m_aRecentFilesItems[i] ); OUString aTipHelpText( aURL.getFSysPath( FSysStyle::Detect ) ); + StyleSettings aIconSettings; + bool aIsIconsAllowed = aIconSettings.GetUseImagesInMenus(); + if ( aURL.GetProtocol() == INetProtocol::File ) { // Do handle file URL differently: don't show the protocol, just the file name @@ -195,6 +202,12 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > aMenuShortCut.append( aMenuTitle ); pVCLPopupMenu->InsertItem( sal_uInt16( i+1 ), aMenuShortCut.makeStringAndClear() ); + + if ( aIsIconsAllowed ) { + Image aThumbnail = SvFileInformationManager::GetImage(aURL); + pVCLPopupMenu->SetItemImage(sal_uInt16 ( i+1 ), aThumbnail); + } + pVCLPopupMenu->SetTipHelpText( sal_uInt16( i+1 ), aTipHelpText ); pVCLPopupMenu->SetItemCommand( sal_uInt16( i+1 ), aURLString ); } @@ -225,7 +238,10 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > } else { - // No recent documents => insert "no document" string + // Add InsertSeparator(), otherwise it will display + // the first item icon of recent files instead of displaying no icon. + pVCLPopupMenu->InsertSeparator(); + // No recent documents => insert "no documents" string pVCLPopupMenu->InsertItem( 1, FwkResId(STR_NODOCUMENT) ); // Do not disable it, otherwise the Toolbar controller and MenuButton // will display SV_RESID_STRING_NOSELECTIONPOSSIBLE instead of STR_NODOCUMENT |