MCPcopy Create free account
hub / github.com/KDE/kdiff3 / QueryContextMenu

Method QueryContextMenu

diff_ext_for_kdiff3/diff_ext.cpp:160–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160STDMETHODIMP
161DIFF_EXT::QueryContextMenu(HMENU menu, UINT position, UINT first_cmd, UINT /*last_cmd not used*/, UINT flags)
162{
163 LOG();
164
165 SERVER::instance()->recent_files(); // updates recent files list (reads from registry)
166
167 m_id_Diff = UINT(-1);
168 m_id_DiffWith = UINT(-1);
169 m_id_DiffLater = UINT(-1);
170 m_id_MergeWith = UINT(-1);
171 m_id_Merge3 = UINT(-1);
172 m_id_Diff3 = UINT(-1);
173 m_id_DiffWith_Base = UINT(-1);
174 m_id_ClearList = UINT(-1);
175 m_id_About = UINT(-1);
176
177 HRESULT ret = MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);
178
179 if(!(flags & CMF_DEFAULTONLY))
180 {
181 /* Menu structure:
182 KDiff3 -> (1 File selected): Save 'selection' for later comparison (push onto history stack)
183 Compare 'selection' with first file on history stack.
184 Compare 'selection' with -> choice from history stack
185 Merge 'selection' with first file on history stack.
186 Merge 'selection' with last two files on history stack.
187 (2 Files selected): Compare 's1' with 's2'
188 Merge 's1' with 's2'
189 (3 Files selected): Compare 's1', 's2' and 's3'
190 */
191 HMENU subMenu = CreateMenu();
192
193 UINT id = first_cmd;
194 m_id_FirstCmd = first_cmd;
195
196 insertMenuItemHelper(menu, id++, position++, TEXT("")); // begin separator
197
198 tstring menuString;
199 UINT pos2 = 0;
200 if(m_nrOfSelectedFiles == 1)
201 {
202 size_t nrOfRecentFiles = m_recentFiles.size();
203 tstring menuStringCompare;
204 tstring menuStringMerge;
205 tstring firstFileName;
206 if(nrOfRecentFiles >= 1)
207 {
208 firstFileName = TEXT("'") + cut_to_length(m_recentFiles.front()) + TEXT("'");
209 }
210
211 menuStringCompare = fromQString(i18nc("Contexualmenu option", "Compare with %1", toQString(firstFileName)));
212 menuStringMerge = fromQString(i18nc("Contexualmenu option", "Merge with %1", toQString(firstFileName)));
213
214 m_id_DiffWith = insertMenuItemHelper(subMenu, id++, pos2++, menuStringCompare, nrOfRecentFiles >= 1 ? MFS_ENABLED : MFS_DISABLED);
215 m_id_MergeWith = insertMenuItemHelper(subMenu, id++, pos2++, menuStringMerge, nrOfRecentFiles >= 1 ? MFS_ENABLED : MFS_DISABLED);
216
217 m_id_Merge3 = insertMenuItemHelper(subMenu, id++, pos2++, fromQString(i18nc("Contexualmenu option", "3-way merge with base")),

Callers

nothing calls this directly

Calls 3

insertMenuItemHelperFunction · 0.85
endMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected