Changeset View
Changeset View
Standalone View
Standalone View
krusader/BookMan/krbookmarkhandler.cpp
Show First 20 Lines • Show All 465 Lines • ▼ Show 20 Line(s) | 462 | if (hasVirtualFS) { | |||
---|---|---|---|---|---|
466 | CONNECT_BM(bm); | 466 | CONNECT_BM(bm); | ||
467 | } | 467 | } | ||
468 | 468 | | |||
469 | if (hasJumpback) { | 469 | if (hasJumpback) { | ||
470 | menu->addSeparator(); | 470 | menu->addSeparator(); | ||
471 | 471 | | |||
472 | ListPanelActions *actions = _mainWindow->listPanelActions(); | 472 | ListPanelActions *actions = _mainWindow->listPanelActions(); | ||
473 | 473 | | |||
474 | auto action = KrBookmark::jumpBackAction(_privateCollection, true, actions); | 474 | auto slotTriggered = [=] { | ||
475 | if (action) { | 475 | if (_mainBookmarkPopup && !_mainBookmarkPopup->isHidden()) { | ||
476 | menu->addAction(action); | 476 | _mainBookmarkPopup->close(); | ||
477 | _specialBookmarks.append(action); | | |||
478 | } | 477 | } | ||
479 | 478 | }; | |||
480 | action = KrBookmark::jumpBackAction(_privateCollection, false, actions); | 479 | auto addJumpBackAction = [=](bool isSetter) { | ||
480 | auto action = KrBookmark::jumpBackAction(_privateCollection, isSetter, actions); | ||||
481 | if (action) { | 481 | if (action) { | ||
482 | menu->addAction(action); | 482 | menu->addAction(action); | ||
483 | _specialBookmarks.append(action); | 483 | _specialBookmarks.append(action); | ||
484 | | ||||
485 | // disconnecting from this as a receiver is important: | ||||
486 | // we don't want to break connections established by KrBookmark::jumpBackAction | ||||
487 | disconnect(action, &QAction::triggered, this, nullptr); | ||||
488 | connect(action, &QAction::triggered, this, slotTriggered); | ||||
martinkostolny: There is a possibility to use a UniqueConnection instead of disconnect & connect. But we would… | |||||
It's a great suggestion. I think I'll do this as a part of CONNECT_BM refactoring later. nmel: It's a great suggestion. I think I'll do this as a part of CONNECT_BM refactoring later. | |||||
484 | } | 489 | } | ||
490 | }; | ||||
491 | | ||||
492 | addJumpBackAction(true); | ||||
493 | addJumpBackAction(false); | ||||
485 | } | 494 | } | ||
486 | } | 495 | } | ||
487 | 496 | | |||
488 | menu->addSeparator(); | 497 | menu->addSeparator(); | ||
489 | menu->addAction(KrActions::actAddBookmark); | 498 | menu->addAction(KrActions::actAddBookmark); | ||
490 | _specialBookmarks.append(KrActions::actAddBookmark); | 499 | _specialBookmarks.append(KrActions::actAddBookmark); | ||
491 | QAction *bmAct = menu->addAction(krLoader->loadIcon("bookmarks", KIconLoader::Small), | 500 | QAction *bmAct = menu->addAction(krLoader->loadIcon("bookmarks", KIconLoader::Small), | ||
492 | i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks())); | 501 | i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks())); | ||
▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines |
There is a possibility to use a UniqueConnection instead of disconnect & connect. But we would need to create a standard method for closing the popup (named e.g. KrBookmarkHandler::slotCloseBookmarkPopup) instead of slotTriggered lambda. Maybe it could also be then re-used in KrBookmarkHandler::slotActivated. Then we could just call here this:
But it's just a suggestion.