6 """ |
6 """ |
7 Module implementing a dialog to select the action to be performed on the |
7 Module implementing a dialog to select the action to be performed on the |
8 bookmark. |
8 bookmark. |
9 """ |
9 """ |
10 |
10 |
|
11 import enum |
|
12 |
11 from PyQt6.QtCore import pyqtSlot |
13 from PyQt6.QtCore import pyqtSlot |
12 from PyQt6.QtWidgets import QDialog |
14 from PyQt6.QtWidgets import QDialog |
13 |
15 |
14 from eric7.EricGui import EricPixmapCache |
16 from eric7.EricGui import EricPixmapCache |
15 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
17 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
16 |
18 |
17 from .Ui_BookmarkActionSelectionDialog import Ui_BookmarkActionSelectionDialog |
19 from .Ui_BookmarkActionSelectionDialog import Ui_BookmarkActionSelectionDialog |
18 |
20 |
19 |
21 |
|
22 class BookmarkAction(enum.Enum): |
|
23 """ |
|
24 Class defining the available bookmark actions. |
|
25 """ |
|
26 |
|
27 Undefined = -1 |
|
28 AddBookmark = 0 |
|
29 EditBookmark = 1 |
|
30 AddSpeeddial = 2 |
|
31 RemoveSpeeddial = 3 |
|
32 |
|
33 |
20 class BookmarkActionSelectionDialog(QDialog, Ui_BookmarkActionSelectionDialog): |
34 class BookmarkActionSelectionDialog(QDialog, Ui_BookmarkActionSelectionDialog): |
21 """ |
35 """ |
22 Class implementing a dialog to select the action to be performed on |
36 Class implementing a dialog to select the action to be performed on |
23 the bookmark. |
37 the bookmark. |
24 """ |
38 """ |
25 |
|
26 # TODO: change this to an enum |
|
27 Undefined = -1 |
|
28 AddBookmark = 0 |
|
29 EditBookmark = 1 |
|
30 AddSpeeddial = 2 |
|
31 RemoveSpeeddial = 3 |
|
32 |
39 |
33 def __init__(self, url, parent=None): |
40 def __init__(self, url, parent=None): |
34 """ |
41 """ |
35 Constructor |
42 Constructor |
36 |
43 |
40 @type QWidget |
47 @type QWidget |
41 """ |
48 """ |
42 super().__init__(parent) |
49 super().__init__(parent) |
43 self.setupUi(self) |
50 self.setupUi(self) |
44 |
51 |
45 self.__action = self.Undefined |
52 self.__action = BookmarkAction.Undefined |
46 |
53 |
47 self.icon.setPixmap(EricPixmapCache.getPixmap("bookmark32")) |
54 self.icon.setPixmap(EricPixmapCache.getPixmap("bookmark32")) |
48 |
55 |
49 if WebBrowserWindow.bookmarksManager().bookmarkForUrl(url) is None: |
56 if WebBrowserWindow.bookmarksManager().bookmarkForUrl(url) is None: |
50 self.__bmAction = self.AddBookmark |
57 self.__bmAction = BookmarkAction.AddBookmark |
51 self.bookmarkPushButton.setText(self.tr("Add Bookmark")) |
58 self.bookmarkPushButton.setText(self.tr("Add Bookmark")) |
52 else: |
59 else: |
53 self.__bmAction = self.EditBookmark |
60 self.__bmAction = BookmarkAction.EditBookmark |
54 self.bookmarkPushButton.setText(self.tr("Edit Bookmark")) |
61 self.bookmarkPushButton.setText(self.tr("Edit Bookmark")) |
55 |
62 |
56 if WebBrowserWindow.speedDial().pageForUrl(url).url: |
63 if WebBrowserWindow.speedDial().pageForUrl(url).url: |
57 self.__sdAction = self.RemoveSpeeddial |
64 self.__sdAction = BookmarkAction.RemoveSpeeddial |
58 self.speeddialPushButton.setText(self.tr("Remove from Speed Dial")) |
65 self.speeddialPushButton.setText(self.tr("Remove from Speed Dial")) |
59 else: |
66 else: |
60 self.__sdAction = self.AddSpeeddial |
67 self.__sdAction = BookmarkAction.AddSpeeddial |
61 self.speeddialPushButton.setText(self.tr("Add to Speed Dial")) |
68 self.speeddialPushButton.setText(self.tr("Add to Speed Dial")) |
62 |
69 |
63 msh = self.minimumSizeHint() |
70 msh = self.minimumSizeHint() |
64 self.resize(max(self.width(), msh.width()), msh.height()) |
71 self.resize(max(self.width(), msh.width()), msh.height()) |
65 |
72 |