eric6/WebBrowser/UrlBar/BookmarkInfoDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2010 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show some bookmark info.
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
10 from PyQt5.QtCore import pyqtSlot
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
11 from PyQt5.QtGui import QFont
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
12 from PyQt5.QtWidgets import QDialog
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Ui_BookmarkInfoDialog import Ui_BookmarkInfoDialog
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import UI.PixmapCache
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
18
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class BookmarkInfoDialog(QDialog, Ui_BookmarkInfoDialog):
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing a dialog to show some bookmark info.
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
23 def __init__(self, bookmark, parent=None):
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Constructor
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param bookmark reference to the bookmark to be shown (Bookmark)
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param parent reference to the parent widget (QWidget)
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2403
diff changeset
30 super(BookmarkInfoDialog, self).__init__(parent)
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.setupUi(self)
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.__bookmark = bookmark
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
35 self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32"))
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 font = QFont()
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 font.setPointSize(font.pointSize() + 2)
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.title.setFont(font)
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 if bookmark is None:
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.titleEdit.setEnabled(False)
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 else:
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.titleEdit.setText(bookmark.title)
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.titleEdit.setFocus()
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
46
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
47 msh = self.minimumSizeHint()
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
48 self.resize(max(self.width(), msh.width()), msh.height())
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @pyqtSlot()
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def on_removeButton_clicked(self):
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Private slot to remove the current bookmark.
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
4749
750577d35452 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4735
diff changeset
55 import WebBrowser.WebBrowserWindow
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
56 (WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
57 .removeBookmark(self.__bookmark))
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.close()
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 def accept(self):
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 Public slot handling the acceptance of the dialog.
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
64 if (
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
65 self.__bookmark is not None and
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
66 self.titleEdit.text() != self.__bookmark.title
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
67 ):
4735
84e78ee0f361 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
68 import WebBrowser.WebBrowserWindow
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
69 (WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
70 .setTitle(self.__bookmark, self.titleEdit.text()))
661
f9d49e0c2522 Added code to show some bookmark data from the URL bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.close()

eric ide

mercurial