|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to select the action to be performed on the bookmark. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog |
|
12 |
|
13 from .Ui_BookmarkActionSelectionDialog import Ui_BookmarkActionSelectionDialog |
|
14 |
|
15 import Helpviewer.HelpWindow |
|
16 |
|
17 import UI.PixmapCache |
|
18 |
|
19 |
|
20 class BookmarkActionSelectionDialog(QDialog, Ui_BookmarkActionSelectionDialog): |
|
21 """ |
|
22 Class implementing a dialog to select the action to be performed on the bookmark. |
|
23 """ |
|
24 Undefined = -1 |
|
25 AddBookmark = 0 |
|
26 EditBookmark = 1 |
|
27 AddSpeeddial = 2 |
|
28 RemoveSpeeddial = 3 |
|
29 |
|
30 def __init__(self, url, parent=None): |
|
31 """ |
|
32 Constructor |
|
33 |
|
34 @param url URL to be worked on (QUrl) |
|
35 @param parent reference to the parent widget (QWidget) |
|
36 """ |
|
37 super().__init__(parent) |
|
38 self.setupUi(self) |
|
39 |
|
40 self.__action = self.Undefined |
|
41 |
|
42 self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32.png")) |
|
43 |
|
44 if Helpviewer.HelpWindow.HelpWindow.bookmarksManager()\ |
|
45 .bookmarkForUrl(url) is None: |
|
46 self.__bmAction = self.AddBookmark |
|
47 self.bookmarkPushButton.setText(self.trUtf8("Add Bookmark")) |
|
48 else: |
|
49 self.__bmAction = self.EditBookmark |
|
50 self.bookmarkPushButton.setText(self.trUtf8("Edit Bookmark")) |
|
51 |
|
52 if Helpviewer.HelpWindow.HelpWindow.speedDial().pageForUrl(url).url: |
|
53 self.__sdAction = self.RemoveSpeeddial |
|
54 self.speeddialPushButton.setText(self.trUtf8("Remove from Speed Dial")) |
|
55 else: |
|
56 self.__sdAction = self.AddSpeeddial |
|
57 self.speeddialPushButton.setText(self.trUtf8("Add to Speed Dial")) |
|
58 |
|
59 @pyqtSlot() |
|
60 def on_bookmarkPushButton_clicked(self): |
|
61 """ |
|
62 Private slot handling selection of a bookmark action. |
|
63 """ |
|
64 self.__action = self.__bmAction |
|
65 self.accept() |
|
66 |
|
67 @pyqtSlot() |
|
68 def on_speeddialPushButton_clicked(self): |
|
69 """ |
|
70 Private slot handling selection of a speed dial action. |
|
71 """ |
|
72 self.__action = self.__sdAction |
|
73 self.accept() |
|
74 |
|
75 def getAction(self): |
|
76 """ |
|
77 Public method to get the selected action. |
|
78 """ |
|
79 return self.__action |