Changeset View
Changeset View
Standalone View
Standalone View
krusader/BookMan/krbookmarkhandler.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 56 | { | |||
---|---|---|---|---|---|
60 | 60 | | |||
61 | // create _root: father of all bookmarks. it is a dummy bookmark and never shown | 61 | // create _root: father of all bookmarks. it is a dummy bookmark and never shown | ||
62 | _root = new KrBookmark(i18n("Bookmarks")); | 62 | _root = new KrBookmark(i18n("Bookmarks")); | ||
63 | _root->setParent(this); | 63 | _root->setParent(this); | ||
64 | 64 | | |||
65 | // load bookmarks | 65 | // load bookmarks | ||
66 | importFromFile(); | 66 | importFromFile(); | ||
67 | 67 | | |||
68 | // hack | 68 | // create bookmark manager | ||
69 | QString filename = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + BOOKMARKS_FILE; | 69 | QString filename = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + BOOKMARKS_FILE; | ||
70 | manager = KBookmarkManager::managerForFile(filename, QStringLiteral("krusader")); | 70 | manager = KBookmarkManager::managerForFile(filename, QStringLiteral("krusader")); | ||
71 | connect(manager, SIGNAL(changed(QString,QString)), this, SLOT(bookmarksChanged(QString,QString))); | 71 | connect(manager, SIGNAL(changed(QString,QString)), this, SLOT(bookmarksChanged(QString,QString))); | ||
72 | | ||||
73 | // fill a dummy menu to properly init actions (allows toolbar bookmark buttons to work properly) | ||||
74 | auto menu = new QMenu(mainWindow->widget()); | ||||
75 | populate(menu); | ||||
martinkostolny: I'd prefer:
```_quickSearchAction = new QWidgetAction(this);
_quickSearchBar = new QLineEdit… | |||||
Thanks! I was moving around the code and forgot to update the ownership. QLineEdit doesn't need the widget because the next call transfers ownership to the action. https://doc.qt.io/qt-5/qwidgetaction.html#setDefaultWidget nmel: Thanks! I was moving around the code and forgot to update the ownership. QLineEdit doesn't need… | |||||
76 | menu->deleteLater(); | ||||
72 | } | 77 | } | ||
73 | 78 | | |||
74 | KrBookmarkHandler::~KrBookmarkHandler() | 79 | KrBookmarkHandler::~KrBookmarkHandler() | ||
75 | { | 80 | { | ||
76 | delete manager; | 81 | delete manager; | ||
77 | delete _privateCollection; | 82 | delete _privateCollection; | ||
78 | } | 83 | } | ||
79 | 84 | | |||
▲ Show 20 Lines • Show All 337 Lines • ▼ Show 20 Line(s) | 420 | if (hasVirtualFS) { | |||
417 | menu->addAction(bm); | 422 | menu->addAction(bm); | ||
418 | _specialBookmarks.append(bm); | 423 | _specialBookmarks.append(bm); | ||
419 | CONNECT_BM(bm); | 424 | CONNECT_BM(bm); | ||
420 | } | 425 | } | ||
421 | 426 | | |||
422 | if (hasJumpback) { | 427 | if (hasJumpback) { | ||
423 | // add the jump-back button | 428 | // add the jump-back button | ||
424 | ListPanelActions *actions = _mainWindow->listPanelActions(); | 429 | ListPanelActions *actions = _mainWindow->listPanelActions(); | ||
430 | if (actions) { | ||||
425 | menu->addAction(actions->actJumpBack); | 431 | menu->addAction(actions->actJumpBack); | ||
426 | _specialBookmarks.append(actions->actJumpBack); | 432 | _specialBookmarks.append(actions->actJumpBack); | ||
427 | menu->addSeparator(); | 433 | menu->addSeparator(); | ||
428 | menu->addAction(actions->actSetJumpBack); | 434 | menu->addAction(actions->actSetJumpBack); | ||
429 | _specialBookmarks.append(actions->actSetJumpBack); | 435 | _specialBookmarks.append(actions->actSetJumpBack); | ||
430 | } | 436 | } | ||
431 | } | 437 | } | ||
438 | } | ||||
432 | 439 | | |||
433 | if (!hasJumpback) | 440 | if (!hasJumpback) | ||
434 | menu->addSeparator(); | 441 | menu->addSeparator(); | ||
435 | 442 | | |||
436 | menu->addAction(KrActions::actAddBookmark); | 443 | menu->addAction(KrActions::actAddBookmark); | ||
437 | _specialBookmarks.append(KrActions::actAddBookmark); | 444 | _specialBookmarks.append(KrActions::actAddBookmark); | ||
438 | QAction *bmAct = menu->addAction(krLoader->loadIcon("bookmarks", KIconLoader::Small), | 445 | QAction *bmAct = menu->addAction(krLoader->loadIcon("bookmarks", KIconLoader::Small), | ||
439 | i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks())); | 446 | i18n("Manage Bookmarks"), manager, SLOT(slotEditBookmarks())); | ||
▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines |
I'd prefer:
...this way the objects will be automatically destroyed when parent is destroyed. But I may be wrong.