19 class BookmarkActionSelectionDialog(QDialog, Ui_BookmarkActionSelectionDialog): |
19 class BookmarkActionSelectionDialog(QDialog, Ui_BookmarkActionSelectionDialog): |
20 """ |
20 """ |
21 Class implementing a dialog to select the action to be performed on |
21 Class implementing a dialog to select the action to be performed on |
22 the bookmark. |
22 the bookmark. |
23 """ |
23 """ |
|
24 |
24 Undefined = -1 |
25 Undefined = -1 |
25 AddBookmark = 0 |
26 AddBookmark = 0 |
26 EditBookmark = 1 |
27 EditBookmark = 1 |
27 AddSpeeddial = 2 |
28 AddSpeeddial = 2 |
28 RemoveSpeeddial = 3 |
29 RemoveSpeeddial = 3 |
29 |
30 |
30 def __init__(self, url, parent=None): |
31 def __init__(self, url, parent=None): |
31 """ |
32 """ |
32 Constructor |
33 Constructor |
33 |
34 |
34 @param url URL to be worked on (QUrl) |
35 @param url URL to be worked on (QUrl) |
35 @param parent reference to the parent widget (QWidget) |
36 @param parent reference to the parent widget (QWidget) |
36 """ |
37 """ |
37 super().__init__(parent) |
38 super().__init__(parent) |
38 self.setupUi(self) |
39 self.setupUi(self) |
39 |
40 |
40 self.__action = self.Undefined |
41 self.__action = self.Undefined |
41 |
42 |
42 self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32")) |
43 self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32")) |
43 |
44 |
44 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
45 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
45 |
46 |
46 if WebBrowserWindow.bookmarksManager().bookmarkForUrl(url) is None: |
47 if WebBrowserWindow.bookmarksManager().bookmarkForUrl(url) is None: |
47 self.__bmAction = self.AddBookmark |
48 self.__bmAction = self.AddBookmark |
48 self.bookmarkPushButton.setText(self.tr("Add Bookmark")) |
49 self.bookmarkPushButton.setText(self.tr("Add Bookmark")) |
49 else: |
50 else: |
50 self.__bmAction = self.EditBookmark |
51 self.__bmAction = self.EditBookmark |
51 self.bookmarkPushButton.setText(self.tr("Edit Bookmark")) |
52 self.bookmarkPushButton.setText(self.tr("Edit Bookmark")) |
52 |
53 |
53 if WebBrowserWindow.speedDial().pageForUrl(url).url: |
54 if WebBrowserWindow.speedDial().pageForUrl(url).url: |
54 self.__sdAction = self.RemoveSpeeddial |
55 self.__sdAction = self.RemoveSpeeddial |
55 self.speeddialPushButton.setText( |
56 self.speeddialPushButton.setText(self.tr("Remove from Speed Dial")) |
56 self.tr("Remove from Speed Dial")) |
|
57 else: |
57 else: |
58 self.__sdAction = self.AddSpeeddial |
58 self.__sdAction = self.AddSpeeddial |
59 self.speeddialPushButton.setText(self.tr("Add to Speed Dial")) |
59 self.speeddialPushButton.setText(self.tr("Add to Speed Dial")) |
60 |
60 |
61 msh = self.minimumSizeHint() |
61 msh = self.minimumSizeHint() |
62 self.resize(max(self.width(), msh.width()), msh.height()) |
62 self.resize(max(self.width(), msh.width()), msh.height()) |
63 |
63 |
64 @pyqtSlot() |
64 @pyqtSlot() |
65 def on_bookmarkPushButton_clicked(self): |
65 def on_bookmarkPushButton_clicked(self): |
66 """ |
66 """ |
67 Private slot handling selection of a bookmark action. |
67 Private slot handling selection of a bookmark action. |
68 """ |
68 """ |
69 self.__action = self.__bmAction |
69 self.__action = self.__bmAction |
70 self.accept() |
70 self.accept() |
71 |
71 |
72 @pyqtSlot() |
72 @pyqtSlot() |
73 def on_speeddialPushButton_clicked(self): |
73 def on_speeddialPushButton_clicked(self): |
74 """ |
74 """ |
75 Private slot handling selection of a speed dial action. |
75 Private slot handling selection of a speed dial action. |
76 """ |
76 """ |
77 self.__action = self.__sdAction |
77 self.__action = self.__sdAction |
78 self.accept() |
78 self.accept() |
79 |
79 |
80 def getAction(self): |
80 def getAction(self): |
81 """ |
81 """ |
82 Public method to get the selected action. |
82 Public method to get the selected action. |
83 |
83 |
84 @return reference to the associated action |
84 @return reference to the associated action |
85 """ |
85 """ |
86 return self.__action |
86 return self.__action |