From 6e20a5d6b930ea4ea121345e909aa0803638c6c0 Mon Sep 17 00:00:00 2001 From: Heiko Tietze Date: Fri, 2 Aug 2024 12:14:59 +0200 Subject: [PATCH] Resolves tdf#161725 - Toggle module-specific file types in MRU Change-Id: I254659718f26800d8dab94e51e8cf66857b0992e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171399 Tested-by: Jenkins Reviewed-by: Heiko Tietze --- framework/inc/strings.hrc | 2 ++ .../source/uielement/recentfilesmenucontroller.cxx | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/framework/inc/strings.hrc b/framework/inc/strings.hrc index 086fe14a4e82..7a4ccf6730ac 100644 --- a/framework/inc/strings.hrc +++ b/framework/inc/strings.hrc @@ -35,6 +35,8 @@ #define STR_NODOCUMENT NC_("STR_NODOCUMENT", "No Documents") #define STR_CLEAR_RECENT_FILES NC_("STR_CLEAR_RECENT_FILES", "Clear List") #define STR_CLEAR_RECENT_FILES_HELP NC_("STR_CLEAR_RECENT_FILES_HELP", "Clears the list with the most recently opened files. This action can not be undone.") +#define STR_TOGGLE_CURRENT_MODULE NC_("STR_TOGGLE_CURRENT_MODULE", "Current Module Only") +#define STR_TOGGLE_CURRENT_MODULE_HELP NC_("STR_TOGGLE_CURRENT_MODULE_HELP", "Shows only documents from the current module") #define STR_REMOTE_TITLE NC_("STR_REMOTE_TITLE", " (Remote)") #define STR_EMDASH_SEPARATOR NC_("STR_EMDASH_SEPARATOR", " — ") #define STR_SAFEMODE_TITLE NC_("STR_SAFEMODE_TITLE", " (Safe Mode)") diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index cae2900576f0..b8bbdd29169e 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -51,6 +51,7 @@ using namespace com::sun::star::util; namespace { constexpr OUString CMD_CLEAR_LIST = u".uno:ClearRecentFileList"_ustr; +constexpr OUString CMD_TOGGLE_CURRENTMODULE = u".uno:ToggleCurrentModule"_ustr; constexpr OUString CMD_OPEN_AS_TEMPLATE = u".uno:OpenTemplate"_ustr; constexpr OUString CMD_OPEN_REMOTE = u".uno:OpenRemote"_ustr; @@ -295,6 +296,12 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > rPopupMenu->setCommand(sal_uInt16(nCount + 1), CMD_CLEAR_LIST); rPopupMenu->setHelpText(sal_uInt16(nCount + 1), FwkResId(STR_CLEAR_RECENT_FILES_HELP)); + // Toggle current module only + rPopupMenu->insertItem(sal_uInt16(nCount + 2), FwkResId(STR_TOGGLE_CURRENT_MODULE), 0, -1); + rPopupMenu->checkItem(sal_uInt16(nCount + 2), bShowCurrentModuleOnly); + rPopupMenu->setCommand(sal_uInt16(nCount + 2), CMD_TOGGLE_CURRENTMODULE); + rPopupMenu->setHelpText(sal_uInt16(nCount + 2), FwkResId(STR_TOGGLE_CURRENT_MODULE_HELP)); + // Open remote menu entry if ( m_bShowToolbarEntries ) { @@ -388,6 +395,13 @@ void SAL_CALL RecentFilesMenuController::itemSelected( const css::awt::MenuEvent u"vnd.org.libreoffice.recentdocs:ClearRecentFileList"_ustr, css::uno::Sequence< css::beans::PropertyValue >() ); } + if ( aCommand == CMD_TOGGLE_CURRENTMODULE ) + { + bool bIsExclusive = officecfg::Office::Common::History::ShowCurrentModuleOnly::get(); + std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::History::ShowCurrentModuleOnly::set(!bIsExclusive, batch); + batch->commit(); + } else if ( aCommand == CMD_OPEN_REMOTE ) { Sequence< PropertyValue > aArgsList( 0 );