Changeset View
Changeset View
Standalone View
Standalone View
src/dolphincontextmenu.cpp
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Line(s) | 201 | if (m_selectedItems.count() == 1) { | |||
---|---|---|---|---|---|
202 | if (m_fileInfo.isDir()) { | 202 | if (m_fileInfo.isDir()) { | ||
203 | // insert 'Open in new window' and 'Open in new tab' entries | 203 | // insert 'Open in new window' and 'Open in new tab' entries | ||
204 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); | 204 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); | ||
205 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab"))); | 205 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab"))); | ||
206 | 206 | | |||
207 | // Insert 'Open With' entries | 207 | // Insert 'Open With' entries | ||
208 | addOpenWithActions(fileItemActions); | 208 | addOpenWithActions(fileItemActions); | ||
209 | 209 | | |||
210 | // insert 'Add to Places' entry | | |||
211 | if (!placeExists(m_fileInfo.url())) { | | |||
212 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); | | |||
213 | } | | |||
214 | | ||||
215 | addSeparator(); | | |||
216 | | ||||
217 | // set up 'Create New' menu | 210 | // set up 'Create New' menu | ||
218 | DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow); | 211 | DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow); | ||
219 | const DolphinView* view = m_mainWindow->activeViewContainer()->view(); | 212 | const DolphinView* view = m_mainWindow->activeViewContainer()->view(); | ||
220 | newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); | 213 | newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); | ||
221 | newFileMenu->checkUpToDate(); | 214 | newFileMenu->checkUpToDate(); | ||
222 | newFileMenu->setPopupFiles(m_fileInfo.url()); | 215 | newFileMenu->setPopupFiles(m_fileInfo.url()); | ||
223 | newFileMenu->setEnabled(selectedItemsProps.supportsWriting()); | 216 | newFileMenu->setEnabled(selectedItemsProps.supportsWriting()); | ||
224 | connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); | 217 | connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); | ||
225 | connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); | 218 | connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); | ||
226 | 219 | | |||
227 | QMenu* menu = newFileMenu->menu(); | 220 | QMenu* menu = newFileMenu->menu(); | ||
228 | menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); | 221 | menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New")); | ||
229 | menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); | 222 | menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); | ||
230 | addMenu(menu); | 223 | addMenu(menu); | ||
231 | 224 | | |||
232 | addSeparator(); | 225 | addSeparator(); | ||
233 | } else if (m_baseUrl.scheme().contains(QLatin1String("search")) || m_baseUrl.scheme().contains(QLatin1String("timeline"))) { | 226 | } else if (m_baseUrl.scheme().contains(QLatin1String("search")) || m_baseUrl.scheme().contains(QLatin1String("timeline"))) { | ||
234 | addOpenWithActions(fileItemActions); | 227 | addOpenWithActions(fileItemActions); | ||
elvisangelaccio: Leftover? | |||||
235 | 228 | | |||
236 | openParentAction = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), | 229 | openParentAction = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), | ||
237 | i18nc("@action:inmenu", | 230 | i18nc("@action:inmenu", | ||
238 | "Open Path"), | 231 | "Open Path"), | ||
239 | this); | 232 | this); | ||
240 | addAction(openParentAction); | 233 | addAction(openParentAction); | ||
241 | 234 | | |||
242 | openParentInNewWindowAction = new QAction(QIcon::fromTheme(QStringLiteral("window-new")), | 235 | openParentInNewWindowAction = new QAction(QIcon::fromTheme(QStringLiteral("window-new")), | ||
243 | i18nc("@action:inmenu", | 236 | i18nc("@action:inmenu", | ||
244 | "Open Path in New Window"), | 237 | "Open Path in New Window"), | ||
245 | this); | 238 | this); | ||
246 | addAction(openParentInNewWindowAction); | 239 | addAction(openParentInNewWindowAction); | ||
247 | 240 | | |||
248 | openParentInNewTabAction = new QAction(QIcon::fromTheme(QStringLiteral("tab-new")), | 241 | openParentInNewTabAction = new QAction(QIcon::fromTheme(QStringLiteral("tab-new")), | ||
249 | i18nc("@action:inmenu", | 242 | i18nc("@action:inmenu", | ||
250 | "Open Path in New Tab"), | 243 | "Open Path in New Tab"), | ||
251 | this); | 244 | this); | ||
252 | addAction(openParentInNewTabAction); | 245 | addAction(openParentInNewTabAction); | ||
253 | 246 | | |||
254 | addSeparator(); | 247 | addSeparator(); | ||
255 | } else if (!DolphinView::openItemAsFolderUrl(m_fileInfo).isEmpty()) { | | |||
256 | // Insert 'Open With" entries | | |||
257 | addOpenWithActions(fileItemActions); | | |||
258 | | ||||
259 | // insert 'Open in new window' and 'Open in new tab' entries | | |||
260 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); | | |||
261 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab"))); | | |||
262 | | ||||
263 | addSeparator(); | | |||
264 | } else { | 248 | } else { | ||
265 | // Insert 'Open With" entries | 249 | // Insert 'Open With" entries | ||
266 | addOpenWithActions(fileItemActions); | 250 | addOpenWithActions(fileItemActions); | ||
267 | } | 251 | } | ||
268 | if (m_fileInfo.isLink()) { | 252 | if (m_fileInfo.isLink()) { | ||
269 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("show_target"))); | 253 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("show_target"))); | ||
270 | addSeparator(); | 254 | addSeparator(); | ||
271 | } | 255 | } | ||
Show All 12 Lines | 266 | if (selectionHasOnlyDirs) { | |||
284 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tabs"))); | 268 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tabs"))); | ||
285 | } | 269 | } | ||
286 | // Insert 'Open With" entries | 270 | // Insert 'Open With" entries | ||
287 | addOpenWithActions(fileItemActions); | 271 | addOpenWithActions(fileItemActions); | ||
288 | } | 272 | } | ||
289 | 273 | | |||
290 | insertDefaultItemActions(selectedItemsProps); | 274 | insertDefaultItemActions(selectedItemsProps); | ||
291 | 275 | | |||
276 | // insert 'Add to Places' entry if appropriate | ||||
277 | if (m_selectedItems.count() == 1) { | ||||
278 | if (m_fileInfo.isDir()) { | ||||
279 | if (!placeExists(m_fileInfo.url())) { | ||||
280 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); | ||||
281 | } | ||||
282 | } | ||||
283 | } | ||||
284 | | ||||
292 | addSeparator(); | 285 | addSeparator(); | ||
293 | 286 | | |||
294 | fileItemActions.addServiceActionsTo(this); | 287 | fileItemActions.addServiceActionsTo(this); | ||
295 | fileItemActions.addPluginActionsTo(this); | 288 | fileItemActions.addPluginActionsTo(this); | ||
296 | 289 | | |||
297 | addVersionControlPluginActions(); | 290 | addVersionControlPluginActions(); | ||
298 | 291 | | |||
299 | // insert 'Copy To' and 'Move To' sub menus | 292 | // insert 'Copy To' and 'Move To' sub menus | ||
Show All 18 Lines | 306 | if (activatedAction) { | |||
318 | } else if (activatedAction == openParentInNewTabAction) { | 311 | } else if (activatedAction == openParentInNewTabAction) { | ||
319 | m_command = OpenParentFolderInNewTab; | 312 | m_command = OpenParentFolderInNewTab; | ||
320 | } | 313 | } | ||
321 | } | 314 | } | ||
322 | } | 315 | } | ||
323 | 316 | | |||
324 | void DolphinContextMenu::openViewportContextMenu() | 317 | void DolphinContextMenu::openViewportContextMenu() | ||
325 | { | 318 | { | ||
326 | // setup 'Create New' menu | | |||
327 | KNewFileMenu* newFileMenu = m_mainWindow->newFileMenu(); | | |||
328 | const DolphinView* view = m_mainWindow->activeViewContainer()->view(); | 319 | const DolphinView* view = m_mainWindow->activeViewContainer()->view(); | ||
329 | newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); | | |||
330 | newFileMenu->checkUpToDate(); | | |||
331 | newFileMenu->setPopupFiles(m_baseUrl); | | |||
332 | addMenu(newFileMenu->menu()); | | |||
333 | addSeparator(); | | |||
334 | 320 | | |||
335 | // Insert 'Open With' entries | 321 | // Insert 'Open With' entries | ||
336 | KFileItem baseItem = view->rootItem(); | 322 | KFileItem baseItem = view->rootItem(); | ||
337 | if (baseItem.isNull() || baseItem.url() != m_baseUrl) { | 323 | if (baseItem.isNull() || baseItem.url() != m_baseUrl) { | ||
338 | baseItem = baseFileItem(); | 324 | baseItem = baseFileItem(); | ||
339 | } | 325 | } | ||
340 | 326 | | |||
341 | const KFileItemListProperties baseUrlProperties(KFileItemList() << baseItem); | 327 | const KFileItemListProperties baseUrlProperties(KFileItemList() << baseItem); | ||
342 | KFileItemActions fileItemActions; | 328 | KFileItemActions fileItemActions; | ||
343 | fileItemActions.setParentWidget(m_mainWindow); | 329 | fileItemActions.setParentWidget(m_mainWindow); | ||
344 | fileItemActions.setItemListProperties(baseUrlProperties); | 330 | fileItemActions.setItemListProperties(baseUrlProperties); | ||
345 | 331 | | |||
346 | // Don't show "Open With" menu items if the current dir is empty, because there's | 332 | // Don't show "Open With" menu items if the current dir is empty, because there's | ||
347 | // generally no app that can do anything interesting with an empty directory | 333 | // generally no app that can do anything interesting with an empty directory | ||
348 | if (view->itemsCount() != 0) { | 334 | if (view->itemsCount() != 0) { | ||
349 | addOpenWithActions(fileItemActions); | 335 | addOpenWithActions(fileItemActions); | ||
350 | } | 336 | } | ||
351 | 337 | | |||
352 | // Insert 'New Window' and 'New Tab' entries. Don't use "open_in_new_window" and | 338 | // Set up and insert 'Create New' menu | ||
353 | // "open_in_new_tab" here, as the current selection should get ignored. | 339 | KNewFileMenu* newFileMenu = m_mainWindow->newFileMenu(); | ||
354 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("file_new"))); | 340 | newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); | ||
355 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("new_tab"))); | 341 | newFileMenu->checkUpToDate(); | ||
342 | newFileMenu->setPopupFiles(m_baseUrl); | ||||
343 | addMenu(newFileMenu->menu()); | ||||
344 | | ||||
345 | QAction* pasteAction = createPasteAction(); | ||||
346 | addAction(pasteAction); | ||||
356 | 347 | | |||
357 | // Insert 'Add to Places' entry if exactly one item is selected | 348 | // Insert 'Add to Places' entry if it's not already in the places panel | ||
358 | if (!placeExists(m_mainWindow->activeViewContainer()->url())) { | 349 | if (!placeExists(m_mainWindow->activeViewContainer()->url())) { | ||
359 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); | 350 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); | ||
360 | } | 351 | } | ||
361 | | ||||
362 | addSeparator(); | | |||
363 | | ||||
364 | QAction* pasteAction = createPasteAction(); | | |||
365 | addAction(pasteAction); | | |||
366 | addSeparator(); | 352 | addSeparator(); | ||
367 | 353 | | |||
368 | // Insert 'Sort By' and 'View Mode' | 354 | // Insert 'Sort By' and 'View Mode' | ||
369 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("sort"))); | 355 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("sort"))); | ||
370 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("view_mode"))); | 356 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("view_mode"))); | ||
371 | 357 | | |||
372 | addSeparator(); | 358 | addSeparator(); | ||
373 | 359 | | |||
374 | // Insert service actions | 360 | // Insert service actions | ||
375 | fileItemActions.addServiceActionsTo(this); | 361 | fileItemActions.addServiceActionsTo(this); | ||
376 | fileItemActions.addPluginActionsTo(this); | 362 | fileItemActions.addPluginActionsTo(this); | ||
377 | 363 | | |||
378 | addVersionControlPluginActions(); | 364 | addVersionControlPluginActions(); | ||
379 | 365 | | |||
380 | addCustomActions(); | 366 | addCustomActions(); | ||
381 | 367 | | |||
368 | addSeparator(); | ||||
369 | | ||||
382 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | 370 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | ||
383 | addAction(propertiesAction); | 371 | addAction(propertiesAction); | ||
384 | 372 | | |||
385 | addShowMenuBarAction(); | 373 | addShowMenuBarAction(); | ||
386 | 374 | | |||
387 | exec(m_pos); | 375 | exec(m_pos); | ||
388 | } | 376 | } | ||
389 | 377 | | |||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |
Leftover?