85 |
85 |
86 if act is not None: |
86 if act is not None: |
87 v = act.data() |
87 v = act.data() |
88 |
88 |
89 if act.menu() is None: |
89 if act.menu() is None: |
90 menuAction = menu.addAction( |
90 act2 = menu.addAction(self.tr("Open")) |
91 self.tr("&Open"), self.__openBookmark) |
91 act2.setData(v) |
92 menuAction.setData(v) |
92 act2.triggered.connect( |
93 menuAction = menu.addAction( |
93 lambda: self.__openBookmark(act2)) |
94 self.tr("Open in New &Tab\tCtrl+LMB"), |
94 act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB")) |
95 self.__openBookmarkInNewTab) |
95 act2.setData(v) |
96 menuAction.setData(v) |
96 act2.triggered.connect( |
|
97 lambda: self.__openBookmarkInNewTab(act2)) |
97 menu.addSeparator() |
98 menu.addSeparator() |
98 |
99 |
99 menuAction = menu.addAction( |
100 act2 = menu.addAction(self.tr("Remove")) |
100 self.tr("&Remove"), self.__removeBookmark) |
101 act2.setData(v) |
101 menuAction.setData(v) |
102 act2.triggered.connect(lambda: self.__removeBookmark(act2)) |
102 menu.addSeparator() |
103 menu.addSeparator() |
103 |
104 |
104 menuAction = menu.addAction( |
105 act2 = menu.addAction(self.tr("Properties...")) |
105 self.tr("&Properties..."), self.__edit) |
106 act2.setData(v) |
106 menuAction.setData(v) |
107 act2.triggered.connect(lambda: self.__edit(act2)) |
107 menu.addSeparator() |
108 menu.addSeparator() |
108 |
109 |
109 menu.addAction(self.tr("Add &Bookmark..."), self.__newBookmark) |
110 menu.addAction(self.tr("Add &Bookmark..."), self.__newBookmark) |
110 menu.addAction(self.tr("Add &Folder..."), self.__newFolder) |
111 menu.addAction(self.tr("Add &Folder..."), self.__newFolder) |
111 |
112 |
131 else: |
132 else: |
132 self.openUrl.emit( |
133 self.openUrl.emit( |
133 idx.data(BookmarksModel.UrlRole), |
134 idx.data(BookmarksModel.UrlRole), |
134 idx.data(Qt.DisplayRole)) |
135 idx.data(Qt.DisplayRole)) |
135 |
136 |
136 def __openToolBarBookmark(self): |
137 def __openBookmark(self, act): |
137 """ |
138 """ |
138 Private slot to open a bookmark in the current browser tab. |
139 Private slot to open a bookmark in the current browser tab. |
139 """ |
140 |
140 idx = self.index(self.sender()) |
141 @param act reference to the triggering action |
141 |
142 @type QAction |
142 if self._keyboardModifiers & Qt.ControlModifier: |
143 """ |
143 self.newUrl.emit( |
144 idx = self.index(act) |
144 idx.data(BookmarksModel.UrlRole), |
|
145 idx.data(Qt.DisplayRole)) |
|
146 else: |
|
147 self.openUrl.emit( |
|
148 idx.data(BookmarksModel.UrlRole), |
|
149 idx.data(Qt.DisplayRole)) |
|
150 self.resetFlags() |
|
151 |
|
152 def __openBookmark(self): |
|
153 """ |
|
154 Private slot to open a bookmark in the current browser tab. |
|
155 """ |
|
156 idx = self.index(self.sender()) |
|
157 |
145 |
158 self.openUrl.emit( |
146 self.openUrl.emit( |
159 idx.data(BookmarksModel.UrlRole), |
147 idx.data(BookmarksModel.UrlRole), |
160 idx.data(Qt.DisplayRole)) |
148 idx.data(Qt.DisplayRole)) |
161 |
149 |
162 def __openBookmarkInNewTab(self): |
150 def __openBookmarkInNewTab(self, act): |
163 """ |
151 """ |
164 Private slot to open a bookmark in a new browser tab. |
152 Private slot to open a bookmark in a new browser tab. |
165 """ |
153 |
166 idx = self.index(self.sender()) |
154 @param act reference to the triggering action |
|
155 @type QAction |
|
156 """ |
|
157 idx = self.index(act) |
167 |
158 |
168 self.newUrl.emit( |
159 self.newUrl.emit( |
169 idx.data(BookmarksModel.UrlRole), |
160 idx.data(BookmarksModel.UrlRole), |
170 idx.data(Qt.DisplayRole)) |
161 idx.data(Qt.DisplayRole)) |
171 |
162 |
172 def __removeBookmark(self): |
163 def __removeBookmark(self, act): |
173 """ |
164 """ |
174 Private slot to remove a bookmark. |
165 Private slot to remove a bookmark. |
175 """ |
166 |
176 idx = self.index(self.sender()) |
167 @param act reference to the triggering action |
|
168 @type QAction |
|
169 """ |
|
170 idx = self.index(act) |
177 |
171 |
178 self.__bookmarksModel.removeRow(idx.row(), self.rootIndex()) |
172 self.__bookmarksModel.removeRow(idx.row(), self.rootIndex()) |
179 |
173 |
180 def __newBookmark(self): |
174 def __newBookmark(self): |
181 """ |
175 """ |
206 menu = BookmarksMenu(self) |
200 menu = BookmarksMenu(self) |
207 menu.openUrl.connect(self.openUrl) |
201 menu.openUrl.connect(self.openUrl) |
208 menu.newUrl.connect(self.newUrl) |
202 menu.newUrl.connect(self.newUrl) |
209 return menu |
203 return menu |
210 |
204 |
211 def __edit(self): |
205 def __edit(self, act): |
212 """ |
206 """ |
213 Private slot to edit a bookmarks properties. |
207 Private slot to edit a bookmarks properties. |
|
208 |
|
209 @param act reference to the triggering action |
|
210 @type QAction |
214 """ |
211 """ |
215 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
212 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
216 idx = self.index(self.sender()) |
213 idx = self.index(act) |
217 node = self.__bookmarksModel.node(idx) |
214 node = self.__bookmarksModel.node(idx) |
218 dlg = BookmarkPropertiesDialog(node) |
215 dlg = BookmarkPropertiesDialog(node) |
219 dlg.exec_() |
216 dlg.exec_() |