Changeset View
Changeset View
Standalone View
Standalone View
krusader/BookMan/krbookmark.cpp
Show All 15 Lines | |||||
16 | * along with this package; if not, write to the Free Software * | 16 | * along with this package; if not, write to the Free Software * | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | ||
18 | *****************************************************************************/ | 18 | *****************************************************************************/ | ||
19 | 19 | | |||
20 | #include "krbookmark.h" | 20 | #include "krbookmark.h" | ||
21 | #include "../krglobal.h" | 21 | #include "../krglobal.h" | ||
22 | #include "../Archive/krarchandler.h" | 22 | #include "../Archive/krarchandler.h" | ||
23 | #include "../FileSystem/krtrashhandler.h" | 23 | #include "../FileSystem/krtrashhandler.h" | ||
24 | #include "../Panel/listpanelactions.h" | ||||
24 | 25 | | |||
25 | #include <KI18n/KLocalizedString> | 26 | #include <KI18n/KLocalizedString> | ||
26 | #include <KIconThemes/KIconLoader> | 27 | #include <KIconThemes/KIconLoader> | ||
27 | #include <KXmlGui/KActionCollection> | 28 | #include <KXmlGui/KActionCollection> | ||
28 | 29 | | |||
29 | #define BM_NAME(X) (QString("Bookmark:")+X) | 30 | #define BM_NAME(X) (QString("Bookmark:")+X) | ||
30 | 31 | | |||
31 | static const char* NAME_TRASH = I18N_NOOP("Trash bin"); | 32 | static const char* NAME_TRASH = I18N_NOOP("Trash bin"); | ||
Show All 34 Lines | 66 | { | |||
66 | if (_autoDelete) { | 67 | if (_autoDelete) { | ||
67 | QListIterator<KrBookmark *> it(_children); | 68 | QListIterator<KrBookmark *> it(_children); | ||
68 | while (it.hasNext()) | 69 | while (it.hasNext()) | ||
69 | delete it.next(); | 70 | delete it.next(); | ||
70 | _children.clear(); | 71 | _children.clear(); | ||
71 | } | 72 | } | ||
72 | } | 73 | } | ||
73 | 74 | | |||
74 | KrBookmark* KrBookmark::getExistingBookmark(QString actionName, KActionCollection *collection) | 75 | KrBookmark * KrBookmark::getExistingBookmark(QString actionName, KActionCollection *collection) | ||
75 | { | 76 | { | ||
76 | return static_cast<KrBookmark*>(collection->action(BM_NAME(actionName))); | 77 | return static_cast<KrBookmark*>(collection->action(BM_NAME(actionName))); | ||
77 | } | 78 | } | ||
78 | 79 | | |||
79 | KrBookmark* KrBookmark::trash(KActionCollection *collection) | 80 | KrBookmark * KrBookmark::trash(KActionCollection *collection) | ||
80 | { | 81 | { | ||
81 | KrBookmark *bm = getExistingBookmark(i18n(NAME_TRASH), collection); | 82 | KrBookmark *bm = getExistingBookmark(i18n(NAME_TRASH), collection); | ||
82 | if (!bm) | 83 | if (!bm) | ||
83 | bm = new KrBookmark(i18n(NAME_TRASH), QUrl("trash:/"), collection); | 84 | bm = new KrBookmark(i18n(NAME_TRASH), QUrl("trash:/"), collection); | ||
84 | 85 | | |||
85 | bm->setIcon(krLoader->loadIcon(KrTrashHandler::trashIcon(), KIconLoader::Small)); | 86 | bm->setIcon(krLoader->loadIcon(KrTrashHandler::trashIcon(), KIconLoader::Small)); | ||
86 | return bm; | 87 | return bm; | ||
87 | } | 88 | } | ||
88 | 89 | | |||
89 | KrBookmark* KrBookmark::virt(KActionCollection *collection) | 90 | KrBookmark * KrBookmark::virt(KActionCollection *collection) | ||
90 | { | 91 | { | ||
91 | KrBookmark *bm = getExistingBookmark(i18n(NAME_VIRTUAL), collection); | 92 | KrBookmark *bm = getExistingBookmark(i18n(NAME_VIRTUAL), collection); | ||
92 | if (!bm) { | 93 | if (!bm) { | ||
93 | bm = new KrBookmark(i18n(NAME_VIRTUAL), QUrl("virt:/"), collection); | 94 | bm = new KrBookmark(i18n(NAME_VIRTUAL), QUrl("virt:/"), collection); | ||
94 | bm->setIcon(krLoader->loadIcon("document-open-remote", KIconLoader::Small)); | 95 | bm->setIcon(krLoader->loadIcon("document-open-remote", KIconLoader::Small)); | ||
95 | } | 96 | } | ||
96 | return bm; | 97 | return bm; | ||
97 | } | 98 | } | ||
98 | 99 | | |||
99 | KrBookmark* KrBookmark::lan(KActionCollection *collection) | 100 | KrBookmark * KrBookmark::lan(KActionCollection *collection) | ||
100 | { | 101 | { | ||
101 | KrBookmark *bm = getExistingBookmark(i18n(NAME_LAN), collection); | 102 | KrBookmark *bm = getExistingBookmark(i18n(NAME_LAN), collection); | ||
102 | if (!bm) { | 103 | if (!bm) { | ||
103 | bm = new KrBookmark(i18n(NAME_LAN), QUrl("remote:/"), collection); | 104 | bm = new KrBookmark(i18n(NAME_LAN), QUrl("remote:/"), collection); | ||
104 | bm->setIcon(krLoader->loadIcon("network-workgroup", KIconLoader::Small)); | 105 | bm->setIcon(krLoader->loadIcon("network-workgroup", KIconLoader::Small)); | ||
105 | } | 106 | } | ||
106 | return bm; | 107 | return bm; | ||
107 | } | 108 | } | ||
108 | 109 | | |||
110 | QAction * KrBookmark::jumpBackAction(KActionCollection *collection, bool isSetter, ListPanelActions *sourceActions) | ||||
111 | { | ||||
112 | auto actionName = isSetter ? QString("setJumpBack") : QString("jumpBack"); | ||||
113 | auto action = collection->action(actionName); | ||||
114 | if (action) { | ||||
115 | return action; | ||||
116 | } | ||||
117 | | ||||
118 | if (!sourceActions) { | ||||
119 | return nullptr; | ||||
120 | } | ||||
121 | | ||||
122 | // copy essential part of source action (shortcut is not copied as it will introduce ambiguity) | ||||
123 | auto sourceAction = isSetter ? sourceActions->actSetJumpBack : sourceActions->actJumpBack; | ||||
124 | action = new QAction(sourceAction->icon(), sourceAction->text(), sourceAction); | ||||
125 | connect(action, &QAction::triggered, sourceAction, &QAction::trigger); | ||||
126 | // ensure there are no accelerator keys coming from another menu | ||||
127 | action->setText(KLocalizedString::removeAcceleratorMarker(action->text())); | ||||
rade: I suspect this is where you are overwriting the 'Ctrl+j' part of the name. | |||||
Earlier on the line 122 I put a comment: shortcut is not copied as it will introduce ambiguity. removeAcceleratorMarker only removes accelerator key marked with &. nmel: Earlier on the line 122 I put a comment: shortcut is not copied as it will introduce ambiguity. | |||||
128 | | ||||
129 | collection->addAction(actionName, action); | ||||
130 | return action; | ||||
131 | } | ||||
132 | | ||||
109 | KrBookmark* KrBookmark::separator() | 133 | KrBookmark * KrBookmark::separator() | ||
110 | { | 134 | { | ||
111 | KrBookmark *bm = new KrBookmark(""); | 135 | KrBookmark *bm = new KrBookmark(""); | ||
112 | bm->_separator = true; | 136 | bm->_separator = true; | ||
113 | bm->_folder = false; | 137 | bm->_folder = false; | ||
114 | return bm; | 138 | return bm; | ||
115 | } | 139 | } | ||
116 | 140 | | |||
117 | 141 | | |||
118 | void KrBookmark::activatedProxy() | 142 | void KrBookmark::activatedProxy() | ||
119 | { | 143 | { | ||
120 | emit activated(url()); | 144 | emit activated(url()); | ||
121 | } | 145 | } | ||
122 | 146 | |
I suspect this is where you are overwriting the 'Ctrl+j' part of the name.