Sat, 14 Dec 2013 23:44:25 +0100
# __IGNORE_WARNING__ added/ removed.
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@dieoffenbachs.de>
parents:
diff
changeset

1  # * coding: utf8 * 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

2  
2302
f29e9405c851
Updated copyright for 2013.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
1670
diff
changeset

3  # Copyright (c) 2012  2013 Detlev Offenbach <detlev@dieoffenbachs.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@dieoffenbachs.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@dieoffenbachs.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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

7  Module implementing an object to create a thumbnail image of a 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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

9  
3145
a9de05d4a22f
# __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3057
diff
changeset

10  from __future__ import unicode_literals 
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2403
diff
changeset

11  
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@dieoffenbachs.de>
parents:
diff
changeset

12  from PyQt4.QtCore import pyqtSignal, QObject, QSize, Qt, 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@dieoffenbachs.de>
parents:
diff
changeset

13  from PyQt4.QtGui import QPixmap, QImage, QPainter 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

15  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

16  from ..Network.NetworkAccessManagerProxy import NetworkAccessManagerProxy 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

17  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

18  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

19  class PageThumbnailer(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@dieoffenbachs.de>
parents:
diff
changeset

20  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

21  Class implementing a thumbnail creator for web sites. 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

22  
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

23  @signal thumbnailCreated(QPixmap) emitted after the thumbnail has been 
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

24  created 
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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

26  thumbnailCreated = pyqtSignal(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@dieoffenbachs.de>
parents:
diff
changeset

27  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

28  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@dieoffenbachs.de>
parents:
diff
changeset

29  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

30  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@dieoffenbachs.de>
parents:
diff
changeset

31  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

32  @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@dieoffenbachs.de>
parents:
diff
changeset

33  """ 
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2403
diff
changeset

34  super(PageThumbnailer, self).__init__(parent) 
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@dieoffenbachs.de>
parents:
diff
changeset

35  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

36  self.__page = QWebPage(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@dieoffenbachs.de>
parents:
diff
changeset

37  self.__size = QSize(231, 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@dieoffenbachs.de>
parents:
diff
changeset

38  self.__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@dieoffenbachs.de>
parents:
diff
changeset

39  self.__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@dieoffenbachs.de>
parents:
diff
changeset

40  self.__url = 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@dieoffenbachs.de>
parents:
diff
changeset

41  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

42  self.__proxy = NetworkAccessManagerProxy(self) 
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2302
diff
changeset

43  import Helpviewer.HelpWindow 
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@dieoffenbachs.de>
parents:
diff
changeset

44  self.__proxy.setPrimaryNetworkAccessManager( 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

45  Helpviewer.HelpWindow.HelpWindow.networkAccessManager()) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

46  self.__page.setNetworkAccessManager(self.__proxy) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

47  
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

48  self.__page.mainFrame().setScrollBarPolicy( 
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

49  Qt.Horizontal, Qt.ScrollBarAlwaysOff) 
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

50  self.__page.mainFrame().setScrollBarPolicy( 
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

51  Qt.Vertical, Qt.ScrollBarAlwaysOff) 
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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

53  # Full HD 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

54  # Every page should fit in this resolution 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

55  self.__page.setViewportSize(QSize(1920, 1080)) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

57  def setSize(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@dieoffenbachs.de>
parents:
diff
changeset

58  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

59  Public method to set the size of the 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@dieoffenbachs.de>
parents:
diff
changeset

60  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

61  @param size size of the image (QSize) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

62  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

63  if size.isValid(): 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

64  self.__size = QSize(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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

66  def setUrl(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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

68  Public method to set the URL of the site to be thumbnailed. 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

69  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

70  @param url URL of the web site (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@dieoffenbachs.de>
parents:
diff
changeset

71  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

72  if url.isValid(): 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

73  self.__url = QUrl(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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

75  def url(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@dieoffenbachs.de>
parents:
diff
changeset

76  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

77  Public method to get the URL of 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@dieoffenbachs.de>
parents:
diff
changeset

78  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

79  @return URL of the thumbnail (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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

81  return QUrl(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@dieoffenbachs.de>
parents:
diff
changeset

82  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

83  def loadTitle(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@dieoffenbachs.de>
parents:
diff
changeset

84  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

85  Public method to check, if the title is loaded from the 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@dieoffenbachs.de>
parents:
diff
changeset

86  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

87  @return flag indicating, that the title is loaded (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@dieoffenbachs.de>
parents:
diff
changeset

88  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

89  return self.__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@dieoffenbachs.de>
parents:
diff
changeset

90  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

91  def setLoadTitle(self, 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@dieoffenbachs.de>
parents:
diff
changeset

92  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

93  Public method to set a flag indicating to load the title from 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

94  the 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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

96  @param load flag indicating to load the title (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@dieoffenbachs.de>
parents:
diff
changeset

97  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

98  self.__loadTitle = 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@dieoffenbachs.de>
parents:
diff
changeset

99  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

100  def title(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@dieoffenbachs.de>
parents:
diff
changeset

101  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

102  Public method to get the title of 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@dieoffenbachs.de>
parents:
diff
changeset

103  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

104  @return title 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@dieoffenbachs.de>
parents:
diff
changeset

105  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

106  return self.__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@dieoffenbachs.de>
parents:
diff
changeset

107  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

108  def start(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@dieoffenbachs.de>
parents:
diff
changeset

109  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

110  Public method to start the thumbnailing action. 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

112  self.__page.loadFinished.connect(self.__createThumbnail) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

113  self.__page.mainFrame().load(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@dieoffenbachs.de>
parents:
diff
changeset

114  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

115  def __createThumbnail(self, status): 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

116  """ 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

117  Private slot creating the thumbnail of the 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@dieoffenbachs.de>
parents:
diff
changeset

118  
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

119  @param status flag indicating a successful load of the web site 
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
2403
diff
changeset

120  (boolean) 
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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

122  if not status: 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

123  self.thumbnailCreated.emit(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@dieoffenbachs.de>
parents:
diff
changeset

124  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@dieoffenbachs.de>
parents:
diff
changeset

125  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

126  self.__title = self.__page.mainFrame().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@dieoffenbachs.de>
parents:
diff
changeset

127  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

128  image = QImage(self.__page.viewportSize(), QImage.Format_ARGB32) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

129  painter = QPainter(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@dieoffenbachs.de>
parents:
diff
changeset

130  self.__page.mainFrame().render(painter) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

131  painter.end() 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

132  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

133  scaledImage = image.scaled(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@dieoffenbachs.de>
parents:
diff
changeset

134  Qt.KeepAspectRatioByExpanding, 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

135  Qt.SmoothTransformation) 
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

136  
6fd889391d2c
Added a Speed Dial to the web browser including the capability to select the first ten pages by pressing Meta+1 to Meta+0.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

137  self.thumbnailCreated.emit(QPixmap.fromImage(scaledImage)) 