From be8568ce0091a4573198e4f818a012621f8ae9e9 Mon Sep 17 00:00:00 2001 From: thisismy-github <48284263+thisismy-github@users.noreply.github.com> Date: Thu, 12 Aug 2021 17:59:00 -0400 Subject: [PATCH] Added option to hide "see more results" in search Hides the item in both start menu styles and adjusts search height to ensure the empty space is used. Partially fixes #660, but currently does not honor group policy settings. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 39 +++++++++++--------- Src/StartMenu/StartMenuDLL/MenuContainer.h | 1 + Src/StartMenu/StartMenuDLL/SettingsUI.cpp | 1 + Src/StartMenu/StartMenuDLL/StartMenuDLL.rc | 2 + Src/StartMenu/StartMenuDLL/resource.h | 2 + 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index 78915f4..b20452a 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -335,6 +335,7 @@ bool CMenuContainer::s_bDragMovable; bool CMenuContainer::s_bRightDrag; bool CMenuContainer::s_bLockWorkArea; bool CMenuContainer::s_bPendingSearchEnter; +bool CMenuContainer::s_bMoreResults; std::vector CMenuContainer::s_Menus; volatile HWND CMenuContainer::s_FirstMenu, CMenuContainer::s_SearchMenu; CSearchManager::SearchResults CMenuContainer::s_SearchResults; @@ -2745,9 +2746,9 @@ bool CMenuContainer::InitSearchItems( void ) { sepHeight=s_Skin.ItemSettings[s_Skin.More_bitmap_Size.cx?MenuSkin::LIST_SEPARATOR_SPLIT:MenuSkin::LIST_SEPARATOR].itemHeight; itemHeight=s_Skin.ItemSettings[MenuSkin::LIST_ITEM].itemHeight; - // total height minus the search box and the "more results"/"search internet" + // total height minus the search box and the "more results"/"search internet", if present maxHeight=m_Items[m_SearchIndex].itemRect.top-s_Skin.Main_search_padding.top-s_Skin.Search_padding.top; - maxHeight-=itemHeight*(m_SearchItemCount-1); + maxHeight-=itemHeight*(m_SearchItemCount-(s_bMoreResults?1:2)); if (!s_SearchResults.bSearching && !HasMoreResults()) maxHeight+=itemHeight; } @@ -2941,25 +2942,28 @@ bool CMenuContainer::InitSearchItems( void ) if (s_bWin7Style) { UpdateAccelerators(m_OriginalCount,(int)m_Items.size()); - MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; - if (s_SearchResults.bSearching) + if (s_bMoreResults) { - item.id=MENU_SEARCH_EMPTY; - item.name=FindTranslation(L"Menu.Searching",L"Searching..."); - item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,8",CItemManager::ICON_SIZE_TYPE_SMALL); - } - else - { - item.id=MENU_MORE_RESULTS; - item.name=FindTranslation(L"Menu.MoreResults",L"See more results"); - item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,177",CItemManager::ICON_SIZE_TYPE_SMALL); + MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; + if (s_SearchResults.bSearching) + { + item.id=MENU_SEARCH_EMPTY; + item.name=FindTranslation(L"Menu.Searching",L"Searching..."); + item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,8",CItemManager::ICON_SIZE_TYPE_SMALL); + } + else + { + item.id=MENU_MORE_RESULTS; + item.name=FindTranslation(L"Menu.MoreResults",L"See more results"); + item.pItemInfo=g_ItemManager.GetCustomIcon(L"imageres.dll,177",CItemManager::ICON_SIZE_TYPE_SMALL); + } } } else { m_ScrollCount=(int)m_Items.size(); - bool bInternet=GetSettingBool(L"SearchInternet"); - if (s_SearchResults.bSearching) + bool bInternet=GetSettingBool(L"SearchInternet"); + if (s_bMoreResults && s_SearchResults.bSearching) { MenuItem item(MENU_SEARCH_EMPTY); item.name=FindTranslation(L"Menu.Searching",L"Searching..."); @@ -2974,7 +2978,7 @@ bool CMenuContainer::InitSearchItems( void ) item.name=FindTranslation(L"Menu.NoMatch",L"No items match your search."); m_Items.push_back(item); } - if (HasMoreResults()) + if (s_bMoreResults && HasMoreResults()) { { MenuItem item(MENU_SEPARATOR); @@ -5062,7 +5066,7 @@ void CMenuContainer::UpdateSearchResults( bool bForceShowAll ) g_SearchManager.BeginSearch(s_SearchResults.currentString); s_SearchResults.bSearching=true; s_bPendingSearchEnter=false; - if (s_bWin7Style) + if (s_bWin7Style && s_bMoreResults) { MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; item.id=MENU_SEARCH_EMPTY; @@ -7694,6 +7698,7 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr s_bDisableHover=false; s_bDragClosed=false; s_bPendingSearchEnter=false; + s_bMoreResults=GetSettingBool(L"MoreResults"); InitTouchHelper(); bool bRemote=GetSystemMetrics(SM_REMOTESESSION)!=0; diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.h b/Src/StartMenu/StartMenuDLL/MenuContainer.h index ad34beb..84e3693 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.h +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.h @@ -896,6 +896,7 @@ private: static bool s_bRightDrag; // dragging with the right mouse button static bool s_bLockWorkArea; // changes to the work area are ignored static bool s_bPendingSearchEnter; // Enter was pressed before the search results were ready + static bool s_bMoreResults; // shows the "Show More Results" item at the bottom of searches static RECT s_MenuLimits; // area of the main monitor accessible to all menus static RECT s_MainMenuLimits; // area of the main monitor accessible by the main menu static DWORD s_TaskbarState; // the state of the taskbar (ABS_AUTOHIDE and ABS_ALWAYSONTOP) diff --git a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp index de0b515..a037dfe 100644 --- a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp +++ b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp @@ -4359,6 +4359,7 @@ CSetting g_Settings[]={ {L"SearchContents",CSetting::TYPE_BOOL,IDS_SEARCH_CONTENTS,IDS_SEARCH_CONTENTS_TIP,1,0,L"#SearchFiles",L"SearchFiles"}, {L"SearchCategories",CSetting::TYPE_BOOL,IDS_SEARCH_CATEGORIES,IDS_SEARCH_CATEGORIES_TIP,1,0,L"#SearchFiles",L"SearchFiles"}, {L"SearchInternet",CSetting::TYPE_BOOL,IDS_SEARCH_INTERNET,IDS_SEARCH_INTERNET_TIP,1,0,L"SearchBox"}, + {L"MoreResults",CSetting::TYPE_BOOL,IDS_MORE_RESULTS,IDS_MORE_RESULTS_TIP,1,0,L"SearchBox"}, {L"Look",CSetting::TYPE_GROUP,IDS_LOOK_SETTINGS}, {L"SmallIconSize",CSetting::TYPE_INT,IDS_SMALL_SIZE_SM,IDS_SMALL_SIZE_SM_TIP,-1,CSetting::FLAG_COLD}, // 16 for DPI<=96, 20 for DPI<=120, 24 otherwise diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc index daf0a68..c857c0e 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc @@ -1305,6 +1305,8 @@ BEGIN IDS_SEARCH_HINT_TIP "When this is checked, the hint text in the search box will be replaced" IDS_NEW_SEARCH_HINT "Custom search hint text" IDS_NEW_SEARCH_HINT_TIP "The text to replace the search hint with. Empty text is a valid option" + IDS_MORE_RESULTS "Enable ""See more results"" option" + IDS_MORE_RESULTS_TIP "When this is checked, the search results will include an option to do a more advanced search" END #endif // English (U.S.) resources diff --git a/Src/StartMenu/StartMenuDLL/resource.h b/Src/StartMenu/StartMenuDLL/resource.h index 1adc21d..daeabf2 100644 --- a/Src/StartMenu/StartMenuDLL/resource.h +++ b/Src/StartMenu/StartMenuDLL/resource.h @@ -768,6 +768,8 @@ #define IDS_SEARCH_HINT_TIP 3671 #define IDS_NEW_SEARCH_HINT 3672 #define IDS_NEW_SEARCH_HINT_TIP 3673 +#define IDS_MORE_RESULTS 3674 +#define IDS_MORE_RESULTS_TIP 3675 #define IDS_STRING7001 7001 #define IDS_STRING7002 7002 #define IDS_STRING7003 7003