eric6/WebBrowser/SpeedDial/SpeedDial.py

Tue, 02 Mar 2021 17:17:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 02 Mar 2021 17:17:09 +0100
changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.

4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
4adc526bc4b3 Continued porting the web browser.
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) 2012 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the speed dial.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
12 from PyQt5.QtCore import (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 pyqtSignal, pyqtSlot, QObject, QCryptographicHash, QByteArray, QUrl,
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 qWarning
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
15 )
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from E5Gui import E5MessageBox
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
19 from ..Tools.WebBrowserTools import pixmapFileToDataUrl
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 from Utilities.AutoSaver import AutoSaver
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Utilities
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class SpeedDial(QObject):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing the speed dial.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @signal pagesChanged() emitted after the list of pages changed
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @signal thumbnailLoaded(url, src) emitted after a thumbnail was loaded
5726
e1dbd217214a Fixed a few source docu issues (forgotten signals and exceptions).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5624
diff changeset
31 @signal pageTitleLoaded(url, title) emitted after a title was loaded
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @signal speedDialSaved() emitted after the speed dial data was saved
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 pagesChanged = pyqtSignal()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 thumbnailLoaded = pyqtSignal(str, str)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 pageTitleLoaded = pyqtSignal(str, str)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 speedDialSaved = pyqtSignal()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 def __init__(self, parent=None):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Constructor
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @param parent reference to the parent object (QObject)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 super(SpeedDial, self).__init__(parent)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__regenerateScript = True
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__webPages = []
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__initialScript = ""
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.__thumbnailsDirectory = ""
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__thumbnailers = []
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.__initialize()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__saveTimer = AutoSaver(self, self.save)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.pagesChanged.connect(self.__saveTimer.changeOccurred)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 def addPage(self, url, title):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 Public method to add a page for the given data.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @param url URL of the page (QUrl)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param title title of the page (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 if url.isEmpty():
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 return
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 from .Page import Page
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 page = Page(
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__escapeUrl(url.toString()),
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.__escapeTitle(title))
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__webPages.append(page)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__regenerateScript = True
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.pagesChanged.emit()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 def removePage(self, url):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 Public method to remove a page.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 @param url URL of the page (QUrl)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 page = self.pageForUrl(url)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 if not page.isValid():
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 return
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.removeImageForUrl(page.url)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__webPages.remove(page)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__regenerateScript = True
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.pagesChanged.emit()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def __imageFileName(self, url):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 Private method to generate the image file name for a URL.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @param url URL to generate the file name from (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @return name of the image file (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 return os.path.join(
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 self.__thumbnailsDirectory,
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 str(QCryptographicHash.hash(QByteArray(url.encode("utf-8")),
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
106 QCryptographicHash.Algorithm.Md5).toHex(), encoding="utf-8"
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
107 ) + ".png")
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 def initialScript(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 Public method to get the 'initial' JavaScript script.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 @return initial JavaScript script (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 if self.__regenerateScript:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.__regenerateScript = False
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.__initialScript = ""
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 for page in self.__webPages:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if page.broken:
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
121 imgSource = pixmapFileToDataUrl("brokenPage.png", True)
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 else:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 imgSource = self.__imageFileName(page.url)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if not os.path.exists(imgSource):
4923
939b6181ab26 Fixed an issue in the speed dial.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4913
diff changeset
125 self.loadThumbnail(page.url, False)
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
126 imgSource = pixmapFileToDataUrl("loading.gif", True)
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 if not page.url:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 imgSource = ""
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 else:
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
131 imgSource = pixmapFileToDataUrl(imgSource, True)
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
133 self.__initialScript += (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
134 "addBox('{0}', '{1}', '{2}');\n").format(
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 page.url, Utilities.html_uencode(page.title),
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 imgSource)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 return self.__initialScript
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 def getFileName(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 Public method to get the file name of the user agents file.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 @return name of the user agents file (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 return os.path.join(
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 Utilities.getConfigDir(), "web_browser", "speedDial.xml")
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 def __initialize(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 Private method to initialize the speed dial.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.__thumbnailsDirectory = os.path.join(
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 Utilities.getConfigDir(), "web_browser", "thumbnails")
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 # Create directory if it does not exist yet
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 if not os.path.exists(self.__thumbnailsDirectory):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 os.makedirs(self.__thumbnailsDirectory)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 self.__load()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 def reload(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 Public method to reload the speed dial data.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 self.__load()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 def __load(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 Private method to load the speed dial configuration.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 allPages, pagesPerRow, speedDialSize = [], 0, 0
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 speedDialFile = self.getFileName()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 if os.path.exists(speedDialFile):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 from .SpeedDialReader import SpeedDialReader
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 reader = SpeedDialReader()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 allPages, pagesPerRow, speedDialSize = reader.read(speedDialFile)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.__pagesPerRow = pagesPerRow if pagesPerRow else 4
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 self.__speedDialSize = speedDialSize if speedDialSize else 231
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 if allPages:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.__webPages = allPages
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 self.pagesChanged.emit()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 else:
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
186 allPages = (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
187 'url:"https://eric-ide.python-projects.org/"|'
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
188 'title:"Eric Web Site";'
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
189 'url:"https://www.riverbankcomputing.com/"|'
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
190 'title:"PyQt Web Site";'
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
191 'url:"http://www.qt.io/"|title:"Qt Web Site";'
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
192 'url:"http://blog.qt.io/"|title:"Qt Blog";'
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
193 'url:"https://www.python.org"|'
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
194 'title:"Python Language Website";'
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 'url:"http://www.google.com"|title:"Google";'
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
196 )
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.changed(allPages)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 def save(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 Public method to save the speed dial configuration.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 from .SpeedDialWriter import SpeedDialWriter
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 speedDialFile = self.getFileName()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 writer = SpeedDialWriter()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 if not writer.write(speedDialFile, self.__webPages,
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 self.__pagesPerRow, self.__speedDialSize):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 E5MessageBox.critical(
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 None,
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 self.tr("Saving Speed Dial data"),
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.tr(
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 """<p>Speed Dial data could not be saved to"""
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """ <b>{0}</b></p>""").format(speedDialFile))
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 else:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.speedDialSaved.emit()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
4954
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
217 def resetDials(self):
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
218 """
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
219 Public method to reset the speed dials to the default values.
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
220 """
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
221 ok = E5MessageBox.yesNo(
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
222 None,
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
223 self.tr("Reset Speed Dials"),
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
224 self.tr("""Are you sure you want to reset the speed dials to"""
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
225 """ the default pages?"""))
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
226 if ok:
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
227 speedDialFile = self.getFileName()
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
228 if os.path.exists(speedDialFile):
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
229 os.remove(speedDialFile)
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
230 self.__regenerateScript = True
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
231
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
232 self.__load()
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
233
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 def close(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 Public method to close the user agents manager.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 self.__saveTimer.saveIfNeccessary()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 def pageForUrl(self, url):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 Public method to get the page for the given URL.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 @param url URL to be searched for (QUrl)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 @return page for the URL (Page)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 urlString = url.toString()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 if urlString.endswith("/"):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 urlString = urlString[:-1]
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 for page in self.__webPages:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 if page.url == urlString:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 return page
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 from .Page import Page
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 return Page()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 def urlForShortcut(self, key):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 Public method to get the URL for the given shortcut key.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 @param key shortcut key (integer)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 @return URL for the key (QUrl)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 if key < 0 or len(self.__webPages) <= key:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 return QUrl()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 return QUrl.fromEncoded(self.__webPages[key].url.encode("utf-8"))
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 @pyqtSlot(str)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 def changed(self, allPages):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 Public slot to react on changed pages.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 @param allPages string giving all pages (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 if not allPages:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 return
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 entries = allPages.split('";')
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 self.__webPages = []
4954
36e92a908f3f Improved the web browser Speeddial (both variants).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4923
diff changeset
282 self.__regenerateScript = True
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 from .Page import Page
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 for entry in entries:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 if not entry:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 continue
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 tmp = entry.split('"|')
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 if len(tmp) == 2:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 broken = False
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 elif len(tmp) == 3:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 broken = "brokenPage" in tmp[2][5:]
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 else:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 continue
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 url = tmp[0][5:]
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 if url.endswith("/"):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 url = url[:-1]
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 title = tmp[1][7:]
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 page = Page(url, title, broken)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 self.__webPages.append(page)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 self.pagesChanged.emit()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @pyqtSlot(str, bool)
4868
985d275502c8 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4865
diff changeset
307 def loadThumbnail(self, url, loadTitle):
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 Public slot to load a thumbnail of the given URL.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 @param url URL of the thumbnail (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 @param loadTitle flag indicating to get the title for the thumbnail
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 from the site (boolean)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 if not url:
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 return
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 from .PageThumbnailer import PageThumbnailer
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 thumbnailer = PageThumbnailer(self)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 thumbnailer.setUrl(QUrl.fromEncoded(url.encode("utf-8")))
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 thumbnailer.setLoadTitle(loadTitle)
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
322 thumbnailer.thumbnailCreated.connect(
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
323 lambda imag: self.__thumbnailCreated(imag, thumbnailer))
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self.__thumbnailers.append(thumbnailer)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 thumbnailer.start()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 @pyqtSlot(str)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 def removeImageForUrl(self, url):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 Public slot to remove the image for a URL.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 @param url URL to remove the image for (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 fileName = self.__imageFileName(url)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 if os.path.exists(fileName):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 os.remove(fileName)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 @pyqtSlot(str, result=str)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 def urlFromUserInput(self, url):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 Public slot to get the URL from user input.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 @param url URL entered by the user (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 @return sanitized URL (string)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 return QUrl.fromUserInput(url).toString()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 @pyqtSlot(int)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 def setPagesInRow(self, count):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 Public slot to set the number of pages per row.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 @param count number of pages per row (integer)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 self.__pagesPerRow = count
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 self.__saveTimer.changeOccurred()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 def pagesInRow(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 Public method to get the number of dials per row.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 @return number of dials per row (integer)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 return self.__pagesPerRow
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 @pyqtSlot(int)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 def setSdSize(self, size):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 Public slot to set the size of the speed dial.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 @param size size of the speed dial (integer)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self.__speedDialSize = size
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 self.__saveTimer.changeOccurred()
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 def sdSize(self):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 Public method to get the speed dial size.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 @return speed dial size (integer)
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 return self.__speedDialSize
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
385 def __thumbnailCreated(self, image, thumbnailer):
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 Private slot to handle the creation of a thumbnail image.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
389 @param image thumbnail image
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
390 @type QPixmap
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
391 @param thumbnailer reference to the page thumbnailer
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
392 @type PageThumbnailer
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 """
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
394 if thumbnailer in self.__thumbnailers:
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
395 loadTitle = thumbnailer.loadTitle()
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
396 title = thumbnailer.title()
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
397 url = thumbnailer.url().toString()
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
398 fileName = self.__imageFileName(url)
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
399
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
400 if image.isNull():
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
401 fileName = "brokenPage.png"
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
402 title = self.tr("Unable to load")
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
403 page = self.pageForUrl(thumbnailer.url())
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
404 page.broken = True
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
405 else:
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
406 if not image.save(fileName, "PNG"):
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
407 qWarning(
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
408 "SpeedDial.__thumbnailCreated: Cannot save thumbnail"
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
409 " to {0}".format(fileName))
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
410
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
411 self.__regenerateScript = True
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
412 thumbnailer.deleteLater()
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
413 self.__thumbnailers.remove(thumbnailer)
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
414
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
415 if loadTitle:
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
416 self.pageTitleLoaded.emit(url, title)
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
417
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
418 self.thumbnailLoaded.emit(
7717
f32d7965a17e Changed the code to not rely on the Qt Resource system anymore (no .qrc files and no use of pyrcc5 anymore).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
419 url, pixmapFileToDataUrl(fileName, True))
4865
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 def __escapeTitle(self, title):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 Private method to escape a title string.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 @param title title string to be escaped
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 @type str
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 @return escaped title string
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 @rtype str
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 title = title.replace('"', "&quot;").replace("'", "&apos;")
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 return title
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 def __escapeUrl(self, url):
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 Private method to escape an URL string.
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 @param url URL to be escaped
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 @type str
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 @return escaped URL string
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 @rtype str
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 """
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 url = url.replace('"', "").replace("'", "")
4adc526bc4b3 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 return url

eric ide

mercurial