20 |
20 |
21 class BookmarksMenu(E5ModelMenu): |
21 class BookmarksMenu(E5ModelMenu): |
22 """ |
22 """ |
23 Class implementing the bookmarks menu base class. |
23 Class implementing the bookmarks menu base class. |
24 |
24 |
25 @signal openUrl(QUrl, str) emitted to open a URL in the current tab |
25 @signal openUrl(QUrl, str) emitted to open a URL with the given title in the |
26 @signal newUrl(QUrl, str) emitted to open a URL in a new tab |
26 current tab |
|
27 @signal newUrl(QUrl, str) emitted to open a URL with the given title in a |
|
28 new tab |
27 """ |
29 """ |
28 openUrl = pyqtSignal(QUrl, str) |
30 openUrl = pyqtSignal(QUrl, str) |
29 newUrl = pyqtSignal(QUrl, str) |
31 newUrl = pyqtSignal(QUrl, str) |
30 |
32 |
31 def __init__(self, parent=None): |
33 def __init__(self, parent=None): |
185 |
187 |
186 |
188 |
187 class BookmarksMenuBarMenu(BookmarksMenu): |
189 class BookmarksMenuBarMenu(BookmarksMenu): |
188 """ |
190 """ |
189 Class implementing a dynamically populated menu for bookmarks. |
191 Class implementing a dynamically populated menu for bookmarks. |
190 """ |
192 |
|
193 @signal openUrl(QUrl, str) emitted to open a URL with the given title in the |
|
194 current tab |
|
195 """ |
|
196 openUrl = pyqtSignal(QUrl, str) |
|
197 |
191 def __init__(self, parent=None): |
198 def __init__(self, parent=None): |
192 """ |
199 """ |
193 Constructor |
200 Constructor |
194 |
201 |
195 @param parent reference to the parent widget (QWidget) |
202 @param parent reference to the parent widget (QWidget) |
220 self.__bookmarksManager.bookmarksModel()\ |
227 self.__bookmarksManager.bookmarksModel()\ |
221 .nodeIndex(self.__bookmarksManager.toolbar()), |
228 .nodeIndex(self.__bookmarksManager.toolbar()), |
222 1, self) |
229 1, self) |
223 return True |
230 return True |
224 |
231 |
|
232 def postPopulated(self): |
|
233 """ |
|
234 Public method to add any actions after the tree. |
|
235 """ |
|
236 if self.isEmpty(): |
|
237 return |
|
238 |
|
239 parent = self.rootIndex() |
|
240 |
|
241 hasBookmarks = False |
|
242 |
|
243 for i in range(parent.model().rowCount(parent)): |
|
244 child = parent.model().index(i, 0, parent) |
|
245 |
|
246 if child.data(BookmarksModel.TypeRole) == BookmarkNode.Bookmark: |
|
247 hasBookmarks = True |
|
248 break |
|
249 |
|
250 if not hasBookmarks: |
|
251 return |
|
252 |
|
253 self.addSeparator() |
|
254 act = self.addAction(self.trUtf8("Default Home Page")) |
|
255 act.setData("eric:home") |
|
256 act.triggered[()].connect(self.__defaultBookmarkTriggered) |
|
257 act = self.addAction(self.trUtf8("Speed Dial")) |
|
258 act.setData("eric:speeddial") |
|
259 act.triggered[()].connect(self.__defaultBookmarkTriggered) |
|
260 self.addSeparator() |
|
261 act = self.addAction(self.trUtf8("Open all in Tabs")) |
|
262 act.triggered[()].connect(self.openAll) |
|
263 |
225 def setInitialActions(self, actions): |
264 def setInitialActions(self, actions): |
226 """ |
265 """ |
227 Public method to set the list of actions that should appear first in the menu. |
266 Public method to set the list of actions that should appear first in the menu. |
228 |
267 |
229 @param actions list of initial actions (list of QAction) |
268 @param actions list of initial actions (list of QAction) |
230 """ |
269 """ |
231 self.__initialActions = actions[:] |
270 self.__initialActions = actions[:] |
232 for act in self.__initialActions: |
271 for act in self.__initialActions: |
233 self.addAction(act) |
272 self.addAction(act) |
|
273 |
|
274 def __defaultBookmarkTriggered(self): |
|
275 """ |
|
276 Private slot handling the default bookmark menu entries. |
|
277 """ |
|
278 act = self.sender() |
|
279 urlStr = act.data() |
|
280 if urlStr.startswith("eric:"): |
|
281 self.openUrl.emit(QUrl(urlStr), "") |