82 |
82 |
83 if act is not None: |
83 if act is not None: |
84 v = act.data() |
84 v = act.data() |
85 |
85 |
86 if act.menu() is None: |
86 if act.menu() is None: |
87 menu.addAction( |
87 act2 = menu.addAction(self.tr("Open")) |
88 self.tr("Open"), |
88 act2.setData(v) |
89 self.__openBookmark).setData(v) |
89 act2.triggered.connect( |
90 menu.addAction( |
90 lambda: self.__openBookmark(act2)) |
91 self.tr("Open in New Tab\tCtrl+LMB"), |
91 act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB")) |
92 self.__openBookmarkInNewTab).setData(v) |
92 act2.setData(v) |
93 menu.addAction( |
93 act2.triggered.connect( |
94 self.tr("Open in New Window"), |
94 lambda: self.__openBookmarkInNewTab(act2)) |
95 self.__openBookmarkInNewWindow).setData(v) |
95 act2 = menu.addAction(self.tr("Open in New Window")) |
96 menu.addAction( |
96 act2.setData(v) |
97 self.tr("Open in New Private Window"), |
97 act2.triggered.connect( |
98 self.__openBookmarkInPrivateWindow).setData(v) |
98 lambda: self.__openBookmarkInNewWindow(act2)) |
|
99 act2 = menu.addAction(self.tr("Open in New Private Window")) |
|
100 act2.setData(v) |
|
101 act2.triggered.connect( |
|
102 lambda: self.__openBookmarkInPrivateWindow(act2)) |
99 menu.addSeparator() |
103 menu.addSeparator() |
100 |
104 |
101 menu.addAction( |
105 act2 = menu.addAction(self.tr("Remove")) |
102 self.tr("Remove"), |
106 act2.setData(v) |
103 self.__removeBookmark).setData(v) |
107 act2.triggered.connect(lambda: self.__removeBookmark(act2)) |
104 menu.addSeparator() |
108 menu.addSeparator() |
105 |
109 |
106 menu.addAction( |
110 act2 = menu.addAction(self.tr("Properties...")) |
107 self.tr("Properties..."), |
111 act2.setData(v) |
108 self.__edit).setData(v) |
112 act2.triggered.connect(lambda: self.__edit(act2)) |
109 menu.addSeparator() |
113 menu.addSeparator() |
110 |
114 |
111 menu.addAction(self.tr("Add Bookmark..."), self.__newBookmark) |
115 menu.addAction(self.tr("Add Bookmark..."), self.__newBookmark) |
112 menu.addAction(self.tr("Add Folder..."), self.__newFolder) |
116 menu.addAction(self.tr("Add Folder..."), self.__newFolder) |
113 |
117 |
151 self.openUrl.emit( |
155 self.openUrl.emit( |
152 idx.data(BookmarksModel.UrlRole), |
156 idx.data(BookmarksModel.UrlRole), |
153 idx.data(Qt.DisplayRole)) |
157 idx.data(Qt.DisplayRole)) |
154 self.__updateVisitCount(idx) |
158 self.__updateVisitCount(idx) |
155 |
159 |
156 def __openBookmark(self): |
160 def __openBookmark(self, act): |
157 """ |
161 """ |
158 Private slot to open a bookmark in the current browser tab. |
162 Private slot to open a bookmark in the current browser tab. |
159 """ |
163 |
160 idx = self.index(self.sender()) |
164 @param act reference to the triggering action |
|
165 @type QAction |
|
166 """ |
|
167 idx = self.index(act) |
161 |
168 |
162 self.openUrl.emit( |
169 self.openUrl.emit( |
163 idx.data(BookmarksModel.UrlRole), |
170 idx.data(BookmarksModel.UrlRole), |
164 idx.data(Qt.DisplayRole)) |
171 idx.data(Qt.DisplayRole)) |
165 self.__updateVisitCount(idx) |
172 self.__updateVisitCount(idx) |
166 |
173 |
167 def __openBookmarkInNewTab(self): |
174 def __openBookmarkInNewTab(self, act): |
168 """ |
175 """ |
169 Private slot to open a bookmark in a new browser tab. |
176 Private slot to open a bookmark in a new browser tab. |
170 """ |
177 |
171 idx = self.index(self.sender()) |
178 @param act reference to the triggering action |
|
179 @type QAction |
|
180 """ |
|
181 idx = self.index(act) |
172 |
182 |
173 self.newTab.emit( |
183 self.newTab.emit( |
174 idx.data(BookmarksModel.UrlRole), |
184 idx.data(BookmarksModel.UrlRole), |
175 idx.data(Qt.DisplayRole)) |
185 idx.data(Qt.DisplayRole)) |
176 self.__updateVisitCount(idx) |
186 self.__updateVisitCount(idx) |
177 |
187 |
178 def __openBookmarkInNewWindow(self): |
188 def __openBookmarkInNewWindow(self, act): |
179 """ |
189 """ |
180 Private slot to open a bookmark in a new window. |
190 Private slot to open a bookmark in a new window. |
181 """ |
191 |
182 idx = self.index(self.sender()) |
192 @param act reference to the triggering action |
|
193 @type QAction |
|
194 """ |
|
195 idx = self.index(act) |
183 |
196 |
184 self.newWindow.emit( |
197 self.newWindow.emit( |
185 idx.data(BookmarksModel.UrlRole), |
198 idx.data(BookmarksModel.UrlRole), |
186 idx.data(Qt.DisplayRole)) |
199 idx.data(Qt.DisplayRole)) |
187 self.__updateVisitCount(idx) |
200 self.__updateVisitCount(idx) |
188 |
201 |
189 def __openBookmarkInPrivateWindow(self): |
202 def __openBookmarkInPrivateWindow(self, act): |
190 """ |
203 """ |
191 Private slot to open a bookmark in a new private window. |
204 Private slot to open a bookmark in a new private window. |
192 """ |
205 |
193 idx = self.index(self.sender()) |
206 @param act reference to the triggering action |
|
207 @type QAction |
|
208 """ |
|
209 idx = self.index(act) |
194 url = idx.data(BookmarksModel.UrlRole) |
210 url = idx.data(BookmarksModel.UrlRole) |
195 |
211 |
196 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
212 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
197 WebBrowserWindow.mainWindow().newPrivateWindow(url) |
213 WebBrowserWindow.mainWindow().newPrivateWindow(url) |
198 self.__updateVisitCount(idx) |
214 self.__updateVisitCount(idx) |
199 |
215 |
200 def __removeBookmark(self): |
216 def __removeBookmark(self, act): |
201 """ |
217 """ |
202 Private slot to remove a bookmark. |
218 Private slot to remove a bookmark. |
203 """ |
219 |
204 idx = self.index(self.sender()) |
220 @param act reference to the triggering action |
|
221 @type QAction |
|
222 """ |
|
223 idx = self.index(act) |
205 |
224 |
206 self.__bookmarksModel.removeRow(idx.row(), self.rootIndex()) |
225 self.__bookmarksModel.removeRow(idx.row(), self.rootIndex()) |
207 |
226 |
208 def __newBookmark(self): |
227 def __newBookmark(self): |
209 """ |
228 """ |
235 menu.openUrl.connect(self.openUrl) |
254 menu.openUrl.connect(self.openUrl) |
236 menu.newTab.connect(self.newTab) |
255 menu.newTab.connect(self.newTab) |
237 menu.newWindow.connect(self.newWindow) |
256 menu.newWindow.connect(self.newWindow) |
238 return menu |
257 return menu |
239 |
258 |
240 def __edit(self): |
259 def __edit(self, act): |
241 """ |
260 """ |
242 Private slot to edit a bookmarks properties. |
261 Private slot to edit a bookmarks properties. |
|
262 |
|
263 @param act reference to the triggering action |
|
264 @type QAction |
243 """ |
265 """ |
244 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
266 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
245 idx = self.index(self.sender()) |
267 idx = self.index(act) |
246 node = self.__bookmarksModel.node(idx) |
268 node = self.__bookmarksModel.node(idx) |
247 dlg = BookmarkPropertiesDialog(node) |
269 dlg = BookmarkPropertiesDialog(node) |
248 dlg.exec_() |
270 dlg.exec_() |