MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / QueryContextMenu

Method QueryContextMenu

src/TortoiseShell/ContextMenu.cpp:830–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

828}
829
830STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT uFlags)
831{
832 CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Shell :: QueryContextMenu itemStates=%ld\n", itemStates);
833 PreserveChdir preserveChdir;
834
835 //first check if our drop handler is called
836 //and then (if true) provide the context menu for the
837 //drop handler
838 if (m_State == FileStateDropHandler)
839 {
840 return QueryDropContext(uFlags, idCmdFirst, hMenu, indexMenu);
841 }
842
843 if ((uFlags & CMF_DEFAULTONLY)!=0)
844 return S_OK; //we don't change the default action
845
846 if (files_.empty() && folder_.empty())
847 return S_OK;
848
849 if (((uFlags & 0x000f)!=CMF_NORMAL)&&(!(uFlags & CMF_EXPLORE))&&(!(uFlags & CMF_VERBSONLY)))
850 return S_OK;
851
852 if (IsIllegalFolder(folder_))
853 return S_OK;
854
855 if (folder_.empty())
856 {
857 // folder is empty, but maybe files are selected
858 if (files_.empty())
859 return S_OK; // nothing selected - we don't have a menu to show
860 // check whether a selected entry is an UID - those are namespace extensions
861 // which we can't handle
862 if (std::any_of(files_.cbegin(), files_.cend(), [](auto& file) { return file.starts_with(L"::{"); }))
863 return S_OK;
864 }
865 else
866 {
867 if (folder_.starts_with(L"::{"))
868 return S_OK;
869 }
870
871 if (((uFlags & CMF_EXTENDEDVERBS) == 0) && g_ShellCache.HideMenusForUnversionedItems())
872 {
873 if ((itemStates & (ITEMIS_INGIT | ITEMIS_INVERSIONEDFOLDER | ITEMIS_FOLDERINGIT | ITEMIS_BAREREPO | ITEMIS_INACCESSIBLE)) == 0)
874 return S_OK;
875 }
876
877 //check if our menu is requested for a git admin directory
878 if (GitAdminDir::IsAdminDirPath(folder_.c_str()))
879 return S_OK;
880
881 if (uFlags & CMF_EXTENDEDVERBS)
882 itemStates |= ITEMIS_EXTENDED;
883
884 regDiffLater.read();
885 if (!std::wstring(regDiffLater).empty())
886 itemStates |= ITEMIS_HASDIFFLATER;
887

Callers 1

OnWndMsgMethod · 0.80

Calls 15

any_ofFunction · 0.85
LoadLangDllFunction · 0.85
GetTGitMenuInfoFunction · 0.85
to_underlyingFunction · 0.85
cbeginMethod · 0.80
cendMethod · 0.80
readMethod · 0.80
GetMenuLayout11Method · 0.80
GetMenuLayoutMethod · 0.80
GetMenuExtMethod · 0.80

Tested by

no test coverage detected