eric7/HelpViewer/HelpViewerWidget.py

branch
eric7
changeset 9172
4bac907a4c74
parent 8902
ba9b8c6e4928
equal deleted inserted replaced
9169:2d27173dff5f 9172:4bac907a4c74
22 WEBENGINE_AVAILABLE = True 22 WEBENGINE_AVAILABLE = True
23 except ImportError: 23 except ImportError:
24 WEBENGINE_AVAILABLE = False 24 WEBENGINE_AVAILABLE = False
25 25
26 from EricWidgets import EricFileDialog, EricMessageBox 26 from EricWidgets import EricFileDialog, EricMessageBox
27 from EricWidgets.EricApplication import ericApp
27 from EricWidgets.EricTextEditSearchWidget import ( 28 from EricWidgets.EricTextEditSearchWidget import (
28 EricTextEditSearchWidget, EricTextEditType 29 EricTextEditSearchWidget, EricTextEditType
29 ) 30 )
30 31
31 import UI.PixmapCache 32 import UI.PixmapCache
44 """ 45 """
45 Class implementing an embedded viewer for QtHelp and local HTML files. 46 Class implementing an embedded viewer for QtHelp and local HTML files.
46 """ 47 """
47 MaxHistoryItems = 20 # max. number of history items to be shown 48 MaxHistoryItems = 20 # max. number of history items to be shown
48 49
50 EmpytDocument_Light = (
51 '''<!DOCTYPE html>\n'''
52 '''<html lang="EN">\n'''
53 '''<head>\n'''
54 '''<style type="text/css">\n'''
55 '''html {background-color: #ffffff;}\n'''
56 '''body {background-color: #ffffff;\n'''
57 ''' color: #000000;\n'''
58 ''' margin: 10px 10px 10px 10px;\n'''
59 '''}\n'''
60 '''</style'''
61 '''</head>\n'''
62 '''<body>\n'''
63 '''</body>\n'''
64 '''</html>'''
65 )
66 EmpytDocument_Dark = (
67 '''<!DOCTYPE html>\n'''
68 '''<html lang="EN">\n'''
69 '''<head>\n'''
70 '''<style type="text/css">\n'''
71 '''html {background-color: #262626;}\n'''
72 '''body {background-color: #262626;\n'''
73 ''' color: #ffffff;\n'''
74 ''' margin: 10px 10px 10px 10px;\n'''
75 '''}\n'''
76 '''</style'''
77 '''</head>\n'''
78 '''<body>\n'''
79 '''</body>\n'''
80 '''</html>'''
81 )
82
49 def __init__(self, parent=None): 83 def __init__(self, parent=None):
50 """ 84 """
51 Constructor 85 Constructor
52 86
53 @param parent reference to the parent widget (defaults to None) 87 @param parent reference to the parent widget (defaults to None)
427 """ 461 """
428 urlStr = self.__helpSelector.currentData() 462 urlStr = self.__helpSelector.currentData()
429 if urlStr: 463 if urlStr:
430 url = QUrl(urlStr) 464 url = QUrl(urlStr)
431 self.openUrl(url) 465 self.openUrl(url)
466 else:
467 self.openUrl(QUrl("about:blank"))
432 468
433 def activate(self, searchWord=None, url=None): 469 def activate(self, searchWord=None, url=None):
434 """ 470 """
435 Public method to activate the widget and search for a given word. 471 Public method to activate the widget and search for a given word.
436 472
479 @pyqtSlot() 515 @pyqtSlot()
480 def __addNewPage(self): 516 def __addNewPage(self):
481 """ 517 """
482 Private slot to add a new empty page. 518 Private slot to add a new empty page.
483 """ 519 """
484 self.addPage() 520 urlStr = self.__helpSelector.currentData()
521 url = QUrl(urlStr) if bool(urlStr) else None
522 self.addPage(url=url)
485 523
486 def addPage(self, url=None, background=False): 524 def addPage(self, url=None, background=False):
487 """ 525 """
488 Public method to add a new help page with the given URL. 526 Public method to add a new help page with the given URL.
489 527
1282 1320
1283 @return count of open pages 1321 @return count of open pages
1284 @rtype int 1322 @rtype int
1285 """ 1323 """
1286 return self.__helpStack.count() 1324 return self.__helpStack.count()
1325
1326 @classmethod
1327 def emptyDocument(cls):
1328 """
1329 Class method to get the HTML code for an empty page.
1330
1331 @return HTML code for an empty page.
1332 @rtype str
1333 """
1334 if ericApp().usesDarkPalette():
1335 return cls.EmpytDocument_Dark
1336 else:
1337 return cls.EmpytDocument_Light

eric ide

mercurial