137 act.menu() is None and \ |
140 act.menu() is None and \ |
138 self.index(act).isValid(): |
141 self.index(act).isValid(): |
139 menu = QMenu() |
142 menu = QMenu() |
140 v = act.data() |
143 v = act.data() |
141 |
144 |
142 menuAction = menu.addAction( |
145 act2 = menu.addAction(self.tr("Open")) |
143 self.tr("&Open"), self.__openBookmark) |
146 act2.setData(v) |
144 menuAction.setData(v) |
147 act2.triggered.connect( |
145 menuAction = menu.addAction( |
148 lambda: self.__openBookmark(act2)) |
146 self.tr("Open in New &Tab\tCtrl+LMB"), |
149 act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB")) |
147 self.__openBookmarkInNewTab) |
150 act2.setData(v) |
148 menuAction.setData(v) |
151 act2.triggered.connect( |
|
152 lambda: self.__openBookmarkInNewTab(act2)) |
149 menu.addSeparator() |
153 menu.addSeparator() |
150 |
154 |
151 menuAction = menu.addAction( |
155 act2 = menu.addAction(self.tr("Remove")) |
152 self.tr("&Remove"), self.__removeBookmark) |
156 act2.setData(v) |
153 menuAction.setData(v) |
157 act2.triggered.connect(lambda: self.__removeBookmark(act2)) |
154 menu.addSeparator() |
158 menu.addSeparator() |
155 |
159 |
156 menuAction = menu.addAction( |
160 act2 = menu.addAction(self.tr("Properties...")) |
157 self.tr("&Properties..."), self.__edit) |
161 act2.setData(v) |
158 menuAction.setData(v) |
162 act2.triggered.connect(lambda: self.__edit(act2)) |
159 |
163 |
160 execAct = menu.exec_(QCursor.pos()) |
164 execAct = menu.exec_(QCursor.pos()) |
161 if execAct is not None: |
165 if execAct is not None: |
162 self.close() |
166 self.close() |
163 parent = self.parent() |
167 parent = self.parent() |
164 while parent is not None and isinstance(parent, QMenu): |
168 while parent is not None and isinstance(parent, QMenu): |
165 parent.close() |
169 parent.close() |
166 parent = parent.parent() |
170 parent = parent.parent() |
167 |
171 |
168 def __openBookmark(self): |
172 def __openBookmark(self, act): |
169 """ |
173 """ |
170 Private slot to open a bookmark in the current browser tab. |
174 Private slot to open a bookmark in the current browser tab. |
171 """ |
175 |
172 idx = self.index(self.sender()) |
176 @param act reference to the triggering action |
|
177 @type QAction |
|
178 """ |
|
179 idx = self.index(act) |
173 |
180 |
174 self.openUrl.emit( |
181 self.openUrl.emit( |
175 idx.data(BookmarksModel.UrlRole), |
182 idx.data(BookmarksModel.UrlRole), |
176 idx.data(Qt.DisplayRole)) |
183 idx.data(Qt.DisplayRole)) |
177 |
184 |
178 def __openBookmarkInNewTab(self): |
185 def __openBookmarkInNewTab(self, act): |
179 """ |
186 """ |
180 Private slot to open a bookmark in a new browser tab. |
187 Private slot to open a bookmark in a new browser tab. |
181 """ |
188 |
182 idx = self.index(self.sender()) |
189 @param act reference to the triggering action |
|
190 @type QAction |
|
191 """ |
|
192 idx = self.index(act) |
183 |
193 |
184 self.newUrl.emit( |
194 self.newUrl.emit( |
185 idx.data(BookmarksModel.UrlRole), |
195 idx.data(BookmarksModel.UrlRole), |
186 idx.data(Qt.DisplayRole)) |
196 idx.data(Qt.DisplayRole)) |
187 |
197 |
188 def __removeBookmark(self): |
198 def __removeBookmark(self, act): |
189 """ |
199 """ |
190 Private slot to remove a bookmark. |
200 Private slot to remove a bookmark. |
191 """ |
201 |
192 idx = self.index(self.sender()) |
202 @param act reference to the triggering action |
|
203 @type QAction |
|
204 """ |
|
205 idx = self.index(act) |
193 self.removeEntry(idx) |
206 self.removeEntry(idx) |
194 |
207 |
195 def __edit(self): |
208 def __edit(self, act): |
196 """ |
209 """ |
197 Private slot to edit a bookmarks properties. |
210 Private slot to edit a bookmarks properties. |
|
211 |
|
212 @param act reference to the triggering action |
|
213 @type QAction |
198 """ |
214 """ |
199 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
215 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
200 |
216 |
201 idx = self.index(self.sender()) |
217 idx = self.index(act) |
202 node = self.model().node(idx) |
218 node = self.model().node(idx) |
203 dlg = BookmarkPropertiesDialog(node) |
219 dlg = BookmarkPropertiesDialog(node) |
204 dlg.exec_() |
220 dlg.exec_() |
205 |
221 |
206 ############################################################################## |
222 ############################################################################## |
277 return |
293 return |
278 |
294 |
279 self.addSeparator() |
295 self.addSeparator() |
280 act = self.addAction(self.tr("Default Home Page")) |
296 act = self.addAction(self.tr("Default Home Page")) |
281 act.setData("eric:home") |
297 act.setData("eric:home") |
282 act.triggered.connect(self.__defaultBookmarkTriggered) |
298 act.triggered.connect( |
|
299 lambda: self.__defaultBookmarkTriggered(act)) |
283 act = self.addAction(self.tr("Speed Dial")) |
300 act = self.addAction(self.tr("Speed Dial")) |
284 act.setData("eric:speeddial") |
301 act.setData("eric:speeddial") |
285 act.triggered.connect(self.__defaultBookmarkTriggered) |
302 act.triggered.connect( |
|
303 lambda: self.__defaultBookmarkTriggered(act)) |
286 self.addSeparator() |
304 self.addSeparator() |
287 act = self.addAction(self.tr("Open all in Tabs")) |
305 act = self.addAction(self.tr("Open all in Tabs")) |
288 act.triggered.connect(self.openAll) |
306 act.triggered.connect(lambda: self.openAll(act)) |
289 |
307 |
290 def setInitialActions(self, actions): |
308 def setInitialActions(self, actions): |
291 """ |
309 """ |
292 Public method to set the list of actions that should appear first in |
310 Public method to set the list of actions that should appear first in |
293 the menu. |
311 the menu. |