eric6/WebBrowser/UrlBar/BookmarkActionSelectionDialog.py

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

eric ide

mercurial