Changeset View
Changeset View
Standalone View
Standalone View
src/dolphincontextmenu.cpp
Show First 20 Lines • Show All 186 Lines • ▼ Show 20 Line(s) | |||||
187 | 187 | | |||
188 | void DolphinContextMenu::openItemContextMenu() | 188 | void DolphinContextMenu::openItemContextMenu() | ||
189 | { | 189 | { | ||
190 | Q_ASSERT(!m_fileInfo.isNull()); | 190 | Q_ASSERT(!m_fileInfo.isNull()); | ||
191 | 191 | | |||
192 | QAction* openParentAction = nullptr; | 192 | QAction* openParentAction = nullptr; | ||
193 | QAction* openParentInNewWindowAction = nullptr; | 193 | QAction* openParentInNewWindowAction = nullptr; | ||
194 | QAction* openParentInNewTabAction = nullptr; | 194 | QAction* openParentInNewTabAction = nullptr; | ||
195 | QAction* addToPlacesAction = nullptr; | | |||
196 | const KFileItemListProperties& selectedItemsProps = selectedItemsProperties(); | 195 | const KFileItemListProperties& selectedItemsProps = selectedItemsProperties(); | ||
197 | 196 | | |||
198 | KFileItemActions fileItemActions; | 197 | KFileItemActions fileItemActions; | ||
199 | fileItemActions.setParentWidget(m_mainWindow); | 198 | fileItemActions.setParentWidget(m_mainWindow); | ||
200 | fileItemActions.setItemListProperties(selectedItemsProps); | 199 | fileItemActions.setItemListProperties(selectedItemsProps); | ||
201 | 200 | | |||
202 | if (m_selectedItems.count() == 1) { | 201 | if (m_selectedItems.count() == 1) { | ||
203 | if (m_fileInfo.isDir()) { | 202 | if (m_fileInfo.isDir()) { | ||
204 | // insert 'Open in new window' and 'Open in new tab' entries | 203 | // insert 'Open in new window' and 'Open in new tab' entries | ||
205 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); | 204 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); | ||
206 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab"))); | 205 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab"))); | ||
207 | 206 | | |||
208 | // Insert 'Open With' entries | 207 | // Insert 'Open With' entries | ||
209 | addOpenWithActions(fileItemActions); | 208 | addOpenWithActions(fileItemActions); | ||
210 | 209 | | |||
211 | // insert 'Add to Places' entry | 210 | // insert 'Add to Places' entry | ||
212 | if (!placeExists(m_fileInfo.url())) { | 211 | if (!placeExists(m_fileInfo.url())) { | ||
213 | addToPlacesAction = addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")), | 212 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); | ||
214 | i18nc("@action:inmenu Add selected folder to places", | | |||
215 | "Add to Places")); | | |||
216 | } | 213 | } | ||
217 | 214 | | |||
218 | addSeparator(); | 215 | addSeparator(); | ||
219 | 216 | | |||
220 | // set up 'Create New' menu | 217 | // set up 'Create New' menu | ||
221 | DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow); | 218 | DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow); | ||
222 | const DolphinView* view = m_mainWindow->activeViewContainer()->view(); | 219 | const DolphinView* view = m_mainWindow->activeViewContainer()->view(); | ||
223 | newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); | 220 | newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown()); | ||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | |||||
309 | 306 | | |||
310 | // insert 'Properties...' entry | 307 | // insert 'Properties...' entry | ||
311 | addSeparator(); | 308 | addSeparator(); | ||
312 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | 309 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | ||
313 | addAction(propertiesAction); | 310 | addAction(propertiesAction); | ||
314 | 311 | | |||
315 | QAction* activatedAction = exec(m_pos); | 312 | QAction* activatedAction = exec(m_pos); | ||
316 | if (activatedAction) { | 313 | if (activatedAction) { | ||
317 | if (activatedAction == addToPlacesAction) { | 314 | if (activatedAction == openParentAction) { | ||
318 | const QUrl selectedUrl(m_fileInfo.url()); | | |||
319 | if (selectedUrl.isValid()) { | | |||
320 | PlacesItemModel model; | | |||
321 | const QString text = selectedUrl.fileName(); | | |||
322 | model.createPlacesItem(text, selectedUrl, KIO::iconNameForUrl(selectedUrl)); | | |||
323 | } | | |||
324 | } else if (activatedAction == openParentAction) { | | |||
325 | m_command = OpenParentFolder; | 315 | m_command = OpenParentFolder; | ||
326 | } else if (activatedAction == openParentInNewWindowAction) { | 316 | } else if (activatedAction == openParentInNewWindowAction) { | ||
327 | m_command = OpenParentFolderInNewWindow; | 317 | m_command = OpenParentFolderInNewWindow; | ||
328 | } else if (activatedAction == openParentInNewTabAction) { | 318 | } else if (activatedAction == openParentInNewTabAction) { | ||
329 | m_command = OpenParentFolderInNewTab; | 319 | m_command = OpenParentFolderInNewTab; | ||
330 | } | 320 | } | ||
331 | } | 321 | } | ||
332 | } | 322 | } | ||
Show All 27 Lines | 325 | { | |||
360 | } | 350 | } | ||
361 | 351 | | |||
362 | // Insert 'New Window' and 'New Tab' entries. Don't use "open_in_new_window" and | 352 | // Insert 'New Window' and 'New Tab' entries. Don't use "open_in_new_window" and | ||
363 | // "open_in_new_tab" here, as the current selection should get ignored. | 353 | // "open_in_new_tab" here, as the current selection should get ignored. | ||
364 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("file_new"))); | 354 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("file_new"))); | ||
365 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("new_tab"))); | 355 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("new_tab"))); | ||
366 | 356 | | |||
367 | // Insert 'Add to Places' entry if exactly one item is selected | 357 | // Insert 'Add to Places' entry if exactly one item is selected | ||
368 | QAction* addToPlacesAction = nullptr; | | |||
369 | if (!placeExists(m_mainWindow->activeViewContainer()->url())) { | 358 | if (!placeExists(m_mainWindow->activeViewContainer()->url())) { | ||
370 | addToPlacesAction = addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")), | 359 | addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); | ||
371 | i18nc("@action:inmenu Add current folder to places", "Add to Places")); | | |||
372 | } | 360 | } | ||
373 | 361 | | |||
374 | addSeparator(); | 362 | addSeparator(); | ||
375 | 363 | | |||
376 | QAction* pasteAction = createPasteAction(); | 364 | QAction* pasteAction = createPasteAction(); | ||
377 | addAction(pasteAction); | 365 | addAction(pasteAction); | ||
378 | addSeparator(); | 366 | addSeparator(); | ||
379 | 367 | | |||
Show All 9 Lines | |||||
389 | 377 | | |||
390 | addVersionControlPluginActions(); | 378 | addVersionControlPluginActions(); | ||
391 | 379 | | |||
392 | addCustomActions(); | 380 | addCustomActions(); | ||
393 | 381 | | |||
394 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | 382 | QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); | ||
395 | addAction(propertiesAction); | 383 | addAction(propertiesAction); | ||
396 | 384 | | |||
397 | addShowMenuBarAction(); | 385 | addShowMenuBarAction(); | ||
398 | | ||||
399 | QAction* action = exec(m_pos); | | |||
400 | if (addToPlacesAction && (action == addToPlacesAction)) { | | |||
401 | const DolphinViewContainer* container = m_mainWindow->activeViewContainer(); | | |||
402 | const QUrl url = container->url(); | | |||
403 | if (url.isValid()) { | | |||
404 | PlacesItemModel model; | | |||
405 | QString icon; | | |||
406 | if (container->isSearchModeEnabled()) { | | |||
407 | icon = QStringLiteral("folder-saved-search-symbolic"); | | |||
408 | } else { | | |||
409 | icon = KIO::iconNameForUrl(url); | | |||
410 | } | | |||
411 | model.createPlacesItem(container->placesText(), url, icon); | | |||
412 | } | | |||
413 | } | | |||
414 | } | 386 | } | ||
elvisangelaccio: The `action` variable is no longer used, please remove it. | |||||
415 | 387 | | |||
416 | void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties& properties) | 388 | void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties& properties) | ||
417 | { | 389 | { | ||
418 | const KActionCollection* collection = m_mainWindow->actionCollection(); | 390 | const KActionCollection* collection = m_mainWindow->actionCollection(); | ||
419 | 391 | | |||
420 | // Insert 'Cut', 'Copy' and 'Paste' | 392 | // Insert 'Cut', 'Copy' and 'Paste' | ||
421 | addAction(collection->action(KStandardAction::name(KStandardAction::Cut))); | 393 | addAction(collection->action(KStandardAction::name(KStandardAction::Cut))); | ||
422 | addAction(collection->action(KStandardAction::name(KStandardAction::Copy))); | 394 | addAction(collection->action(KStandardAction::name(KStandardAction::Copy))); | ||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |
The action variable is no longer used, please remove it.