Mon, 25 Mar 2013 03:11:06 +0100
Script changes: Future import added, super calls modified and unicode behavior for str.
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  
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

10  from __future__ import unicode_literals # __IGNORE_WARNING__ 
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  
6fd889391d2c
Added a Speed 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

23  @signal thumbnailCreated(QPixmap) emitted after the thumbnail has been created 
6fd889391d2c
Added a Speed 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

24  """ 
6fd889391d2c
Added a Speed 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  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

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

27  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

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

29  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

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

31  @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

32  """ 
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

33  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

34  
6fd889391d2c
Added a Speed 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  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

36  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

37  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

38  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

39  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

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

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

42  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

43  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

44  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

45  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

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

47  self.__page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) 
6fd889391d2c
Added a Speed 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

48  self.__page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) 
6fd889391d2c
Added a Speed 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

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

50  # 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

51  # 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

52  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

53  
6fd889391d2c
Added a Speed 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  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

55  """ 
6fd889391d2c
Added a Speed 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  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

57  
6fd889391d2c
Added a Speed 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  @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

59  """ 
6fd889391d2c
Added a Speed 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  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

61  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

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  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

64  """ 
6fd889391d2c
Added a Speed 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  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

66  
6fd889391d2c
Added a Speed 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  @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

68  """ 
6fd889391d2c
Added a Speed 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  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

70  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

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  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

73  """ 
6fd889391d2c
Added a Speed 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  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

75  
6fd889391d2c
Added a Speed 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  @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

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

78  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

79  
6fd889391d2c
Added a Speed 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  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

81  """ 
6fd889391d2c
Added a Speed 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  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

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

84  @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

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

86  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

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

88  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

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

90  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

91  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

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  @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

94  """ 
6fd889391d2c
Added a Speed 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  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

96  
6fd889391d2c
Added a Speed 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  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

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

99  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

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

101  @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

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

103  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

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

105  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

106  """ 
6fd889391d2c
Added a Speed 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  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

108  """ 
6fd889391d2c
Added a Speed 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  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

110  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

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  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

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

114  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

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

116  @param status flag indicating a successful load of the web 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@dieoffenbachs.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@dieoffenbachs.de>
parents:
diff
changeset

118  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

119  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

120  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

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  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

123  
6fd889391d2c
Added a Speed 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  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

125  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

126  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

127  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

128  
6fd889391d2c
Added a Speed 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  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

130  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

131  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

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  self.thumbnailCreated.emit(QPixmap.fromImage(scaledImage)) 