Helpviewer/SpeedDial/SpeedDial.py

Sun, 10 Feb 2013 11:57:37 +0100

author
"Detlev Offenbach <detlev@die-offenbachs.de>"
date
Sun, 10 Feb 2013 11:57:37 +0100
changeset 2395
47bfeebe95f9
parent 2318
3a3ee7cc2ad6
child 2403
e3d7a861547c
permissions
-rw-r--r--

Fixed an error in the list of default speed dial pages.

1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2295
diff changeset
3 # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the speed dial.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import pyqtSignal, pyqtSlot, QObject, QCryptographicHash, QByteArray, \
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 QUrl, qWarning
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from PyQt4.QtWebKit import QWebPage
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
16 from E5Gui import E5MessageBox
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
18 from .Page import Page
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
19 from .PageThumbnailer import PageThumbnailer
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
20 from .SpeedDialReader import SpeedDialReader
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
21 from .SpeedDialWriter import SpeedDialWriter
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
22
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
23 from Utilities.AutoSaver import AutoSaver
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
24 import Utilities
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 class SpeedDial(QObject):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Class implementing the speed dial.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @signal pagesChanged() emitted after the list of pages changed
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
32 @signal speedDialSaved() emitted after the speed dial data was saved
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 pagesChanged = pyqtSignal()
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
35 speedDialSaved = pyqtSignal()
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 def __init__(self, parent=None):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 Constructor
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 @param parent reference to the parent object (QObject)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 super().__init__(parent)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__regenerateScript = True
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__webPages = []
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__webFrames = []
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.__initialScript = ""
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.__thumbnailsDirectory = ""
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.__thumbnailers = []
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.__initialize()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.pagesChanged.connect(self.__pagesChanged)
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
58
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
59 self.__saveTimer = AutoSaver(self, self.save)
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
60 self.pagesChanged.connect(self.__saveTimer.changeOccurred)
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def addWebFrame(self, frame):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 Public method to add a web frame.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param frame reference to the frame to be added (QWebFrame)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 if frame not in self.__webFrames:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__webFrames.append(frame)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 def addPage(self, url, title):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 Public method to add a page for the given data.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 @param url URL of the page (QUrl)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 @param title title of the page (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 if url.isEmpty():
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 return
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 page = Page(url.toString(), title)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__webPages.append(page)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.pagesChanged.emit()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 def removePage(self, url):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 Public method to remove a page.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 @param url URL of the page (QUrl)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 page = self.pageForUrl(url)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 if not page.url:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 return
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 self.removeImageForUrl(page.url)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.__webPages.remove(page)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.pagesChanged.emit()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 def __imageFileName(self, url):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 Private method to generate the image file name for a URL.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 @param url URL to generate the file name from (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 @return name of the image file (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 """
1965
96f5a76e1845 Fixed some PEP-8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1703
diff changeset
108 return os.path.join(self.__thumbnailsDirectory,
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 str(QCryptographicHash.hash(QByteArray(url.encode("utf-8")),
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 QCryptographicHash.Md5).toHex(), encoding="utf-8") + ".png")
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 def initialScript(self):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 Public method to get the 'initial' JavaScript script.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @return initial JavaScript script (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 if self.__regenerateScript:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 self.__regenerateScript = False
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.__initialScript = ""
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 for page in self.__webPages:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 if page.broken:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 imgSource = "qrc:icons/brokenPage.png"
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 else:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 imgSource = self.__imageFileName(page.url)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 if not os.path.exists(imgSource):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.loadThumbnail(page.url)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 imgSource = "qrc:icons/loading.gif"
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 if not page.url:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 imgSource = ""
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 else:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 imgSource = QUrl.fromLocalFile(imgSource).toString()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.__initialScript += "addBox('{0}', '{1}', '{2}');\n".format(
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 page.url, page.title, imgSource)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 return self.__initialScript
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
141 def getFileName(self):
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
142 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
143 Public method to get the file name of the user agents file.
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
144
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
145 @return name of the user agents file (string)
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
146 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
147 return os.path.join(Utilities.getConfigDir(), "browser", "speedDial.xml")
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
148
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 def __initialize(self):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 Private method to initialize the speed dial.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
153 self.__thumbnailsDirectory = os.path.join(
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
154 Utilities.getConfigDir(), "browser", "thumbnails")
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
155 # Create directory if it does not exist yet
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
156 if not os.path.exists(self.__thumbnailsDirectory):
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
157 os.makedirs(self.__thumbnailsDirectory)
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
159 self.__load()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
160
1700
40c911b8c0dd Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1699
diff changeset
161 def reload(self):
40c911b8c0dd Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1699
diff changeset
162 """
40c911b8c0dd Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1699
diff changeset
163 Public method to reload the speed dial data.
40c911b8c0dd Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1699
diff changeset
164 """
40c911b8c0dd Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1699
diff changeset
165 self.__load()
40c911b8c0dd Made the speed dial settings synchronizable via the sync manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1699
diff changeset
166
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
167 def __load(self):
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
168 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
169 Private method to load the speed dial configuration.
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
170 """
1703
796e59fd5b7a Fixed an issue reading Speed Dial data, if the speed dial XML file isn't there yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1700
diff changeset
171 allPages, pagesPerRow, speedDialSize = [], 0, 0
796e59fd5b7a Fixed an issue reading Speed Dial data, if the speed dial XML file isn't there yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1700
diff changeset
172
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
173 speedDialFile = self.getFileName()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
174 if os.path.exists(speedDialFile):
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
175 reader = SpeedDialReader()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
176 allPages, pagesPerRow, speedDialSize = reader.read(speedDialFile)
1703
796e59fd5b7a Fixed an issue reading Speed Dial data, if the speed dial XML file isn't there yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1700
diff changeset
177
796e59fd5b7a Fixed an issue reading Speed Dial data, if the speed dial XML file isn't there yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1700
diff changeset
178 self.__pagesPerRow = pagesPerRow if pagesPerRow else 4
796e59fd5b7a Fixed an issue reading Speed Dial data, if the speed dial XML file isn't there yet.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1700
diff changeset
179 self.__speedDialSize = speedDialSize if speedDialSize else 231
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
180
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
181 if allPages:
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
182 self.__webPages = allPages
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
183 self.pagesChanged.emit()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
184 else:
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 allPages = \
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 'url:"http://eric-ide.python-projects.org/"|title:"Eric Web Site";'\
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 'url:"http://www.riverbankcomputing.com/"|title:"PyQt4 Web Site";'\
2395
47bfeebe95f9 Fixed an error in the list of default speed dial pages.
"Detlev Offenbach <detlev@die-offenbachs.de>"
parents: 2318
diff changeset
188 'url:"http://qt.digia.com/"|title:"Qt Web Site";'\
2295
f51d70c46079 Changed the Qt related URLs of the speed dial defaults to reflect the movement to Digia.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1965
diff changeset
189 'url:"http://blog.qt.digia.com/"|title:"Qt Blog";'\
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 'url:"http://www.python.org"|title:"Python Language Website";'\
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 'url:"http://www.google.com"|title:"Google";'
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
192 self.changed(allPages)
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
193
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
194 def save(self):
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
195 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
196 Public method to save the speed dial configuration.
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
197 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
198 speedDialFile = self.getFileName()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
199 writer = SpeedDialWriter()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
200 if not writer.write(speedDialFile,
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
201 self.__webPages, self.__pagesPerRow, self.__speedDialSize):
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
202 E5MessageBox.critical(None,
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
203 self.trUtf8("Saving Speed Dial data"),
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
204 self.trUtf8("""<p>Speed Dial data could not be saved to <b>{0}</b></p>"""
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
205 ).format(speedDialFile))
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
206 else:
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
207 self.speedDialSaved.emit()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
208
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
209 def close(self):
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
210 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
211 Public method to close the user agents manager.
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
212 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
213 self.__saveTimer.saveIfNeccessary()
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 def pageForUrl(self, url):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 Public method to get the page for the given URL.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 @param url URL to be searched for (QUrl)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 @return page for the URL (Page)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 urlString = url.toString()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 for page in self.__webPages:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 if page.url == urlString:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 return page
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 return Page()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 def urlForShortcut(self, key):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 Public method to get the URL for the given shortcut key.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 @param key shortcut key (integer)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 @return URL for the key (QUrl)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 if key < 0 or len(self.__webPages) <= key:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 return QUrl()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 return QUrl.fromEncoded(self.__webPages[key].url.encode("utf-8"))
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 @pyqtSlot(str)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 def changed(self, allPages):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 Public slot to react on changed pages.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 @param allPages string giving all pages (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 if not allPages:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 return
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 entries = allPages.split('";')
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.__webPages = []
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 for entry in entries:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 if not entry:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 continue
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 tmp = entry.split('"|')
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 if len(tmp) == 2:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 broken = False
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 elif len(tmp) == 3:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 broken = "brokenPage" in tmp[2][5:]
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 else:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 continue
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 page = Page(tmp[0][5:], tmp[1][7:], broken)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 self.__webPages.append(page)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 self.pagesChanged.emit()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 @pyqtSlot(str)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 @pyqtSlot(str, bool)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 def loadThumbnail(self, url, loadTitle=False):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 Public slot to load a thumbnail of the given URL.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 @param url URL of the thumbnail (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 @param loadTitle flag indicating to get the title for the thumbnail
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 from the site (boolean)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 if not url:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 return
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 thumbnailer = PageThumbnailer(self)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 thumbnailer.setUrl(QUrl.fromEncoded(url.encode("utf-8")))
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 thumbnailer.setLoadTitle(loadTitle)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 thumbnailer.thumbnailCreated.connect(self.__thumbnailCreated)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 self.__thumbnailers.append(thumbnailer)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 thumbnailer.start()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 @pyqtSlot(str)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 def removeImageForUrl(self, url):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 Public slot to remove the image for a URL.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 @param url URL to remove the image for (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 fileName = self.__imageFileName(url)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 if os.path.exists(fileName):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 os.remove(fileName)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 @pyqtSlot(str, result=str)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 def urlFromUserInput(self, url):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 Public slot to get the URL from user input.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 @param url URL entered by the user (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 @return sanitized URL (string)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 return QUrl.fromUserInput(url).toString()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 @pyqtSlot(int)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 def setPagesInRow(self, count):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 Public slot to set the number of pages per row.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 @param count number of pages per row (integer)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
320 self.__pagesPerRow = count
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
321 self.__saveTimer.changeOccurred()
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 def pagesInRow(self):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 Public method to get the number of dials per row.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 @return number of dials per row (integer)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
329 return self.__pagesPerRow
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 @pyqtSlot(int)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 def setSdSize(self, size):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 Public slot to set the size of the speed dial.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 @param size size of the speed dial (integer)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
338 self.__speedDialSize = size
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
339 self.__saveTimer.changeOccurred()
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 def sdSize(self):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 Public method to get the speed dial size.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 @return speed dial size (integer)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
347 return self.__speedDialSize
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 def __thumbnailCreated(self, image):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 Private slot to handle the creation of a thumbnail image.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 @param image thumbnail image (QPixmap)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 thumbnailer = self.sender()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 if not isinstance(thumbnailer, PageThumbnailer) or \
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 thumbnailer not in self.__thumbnailers:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 return
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 loadTitle = thumbnailer.loadTitle()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 title = thumbnailer.title()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 url = thumbnailer.url().toString()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 fileName = self.__imageFileName(url)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 if image.isNull():
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 fileName = "qrc:icons/brokenPage.png"
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 title = self.trUtf8("Unable to load")
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 loadTitle = True
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 page = self.pageForUrl(thumbnailer.url())
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 page.broken = True
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 else:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 if not image.save(fileName):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 qWarning("SpeedDial.__thumbnailCreated: Cannot save thumbnail to {0}"
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 .format(fileName))
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 fileName = QUrl.fromLocalFile(fileName).toString()
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 self.__regenerateScript = True
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 for frame in self.__cleanFrames():
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 frame.evaluateJavaScript("setImageToUrl('{0}', '{1}');".format(
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 url, fileName))
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 if loadTitle:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 frame.evaluateJavaScript("setTitleToUrl('{0}', '{1}');".format(
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 url, title))
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386
2318
3a3ee7cc2ad6 Changed some signal handlings (disconnect).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
387 ## thumbnailer.thumbnailCreated.disconnect(self.__thumbnailCreated)
3a3ee7cc2ad6 Changed some signal handlings (disconnect).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
388 thumbnailer.deleteLater()
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 self.__thumbnailers.remove(thumbnailer)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 def __cleanFrames(self):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 Private method to clean all frames.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 @return list of speed dial frames (list of QWebFrame)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 frames = []
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 for frame in self.__webFrames[:]:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 if frame.url().toString() == "eric:speeddial":
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 frames.append(frame)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 else:
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 self.__webFrames.remove(frame)
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 return frames
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 def __pagesChanged(self):
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 """
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 Private slot to react on a change of the pages configuration.
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
411 # update all speed dial pages
1670
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 self.__regenerateScript = True
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 for frame in self.__cleanFrames():
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 frame.page().triggerAction(QWebPage.Reload)

eric ide

mercurial