Helpviewer/SpeedDial/SpeedDial.py

Sun, 29 Jul 2012 18:05:03 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 29 Jul 2012 18:05:03 +0200
changeset 1965
96f5a76e1845
parent 1703
796e59fd5b7a
child 2295
f51d70c46079
permissions
-rw-r--r--

Fixed some PEP-8 related issues.

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
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de>
6fd889391d2c Added a Speed Dial to the web browser including 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";'\
6fd889391d2c Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 'url:"http://qt.nokia.com/"|title:"Qt 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
189 '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
190 '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
191 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
192
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
193 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
194 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
195 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
196 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
197 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
198 writer = SpeedDialWriter()
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
199 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
200 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
201 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
202 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
203 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
204 ).format(speedDialFile))
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
205 else:
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
206 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
207
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
208 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
209 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
210 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
211 """
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
212 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
213
6fd889391d2c Added a Speed Dial to the web browser including 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 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
215 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
217
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
219 @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
220 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
222 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
223 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
224 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
225
6fd889391d2c Added a Speed Dial to the web browser including 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 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
227
6fd889391d2c Added a Speed Dial to the web browser including 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 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
229 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
231
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
233 @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
234 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
236 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
237
6fd889391d2c Added a Speed Dial to the web browser including 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 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
239
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
241 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
242 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
244
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
246 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
248 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
249
6fd889391d2c Added a Speed Dial to the web browser including 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 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
251 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
252
6fd889391d2c Added a Speed Dial to the web browser including 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 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
254 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
255 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
256
6fd889391d2c Added a Speed Dial to the web browser including 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 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
258 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
259 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
260 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
261 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
262 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
263 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
264
6fd889391d2c Added a Speed Dial to the web browser including 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 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
266 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
267
6fd889391d2c Added a Speed Dial to the web browser including 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 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
269
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
271 @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
272 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
273 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
275
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
277 @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
278 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
279 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
281 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
282
6fd889391d2c Added a Speed Dial to the web browser including 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 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
284 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
285 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
286 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
287 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
288
6fd889391d2c Added a Speed Dial to the web browser including 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 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
290
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
292 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
293 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
295
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
297 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
299 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
300 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
301
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
303 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
304 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
306
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
308 @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
309 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
311
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
313 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
314 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
316
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
318 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
319 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
320 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
321
6fd889391d2c Added a Speed Dial to the web browser including 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 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
323 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
325
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
327 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
328 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
329
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
331 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
332 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
334
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
336 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
337 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
338 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
339
6fd889391d2c Added a Speed Dial to the web browser including 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 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
341 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
343
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
345 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
346 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
347
6fd889391d2c Added a Speed Dial to the web browser including 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 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
349 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
351
6fd889391d2c Added a Speed Dial to the web browser including 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 @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
353 """
6fd889391d2c Added a Speed Dial to the web browser including 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 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
355 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
356 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
357 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
358
6fd889391d2c Added a Speed Dial to the web browser including 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 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
360 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
361 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
362 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
363
6fd889391d2c Added a Speed Dial to the web browser including 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 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
365 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
366 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
367 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
368 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
369 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
370 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
371 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
372 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
373 .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
374
6fd889391d2c Added a Speed Dial to the web browser including 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 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
376
6fd889391d2c Added a Speed Dial to the web browser including 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 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
378
6fd889391d2c Added a Speed Dial to the web browser including 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 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
380 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
381 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
382 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
383 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
384 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
385
6fd889391d2c Added a Speed Dial to the web browser including 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 thumbnailer.thumbnailCreated.disconnect(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
387 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
388
6fd889391d2c Added a Speed Dial to the web browser including 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 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
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 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
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 @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
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 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
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 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
398 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
399 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
400 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
401 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
402
6fd889391d2c Added a Speed Dial to the web browser including 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 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
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 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
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 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
408 """
1699
10706f6ad9d2 Changed the speedial to store the data into an XML file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1670
diff changeset
409 # 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
410 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
411 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
412 frame.page().triggerAction(QWebPage.Reload)

eric ide

mercurial