19 ) |
19 ) |
20 try: |
20 try: |
21 from PyQt6.QtWebEngineCore import QWebEngineProfile, QWebEngineSettings |
21 from PyQt6.QtWebEngineCore import QWebEngineProfile, QWebEngineSettings |
22 WEBENGINE_AVAILABLE = True |
22 WEBENGINE_AVAILABLE = True |
23 except ImportError: |
23 except ImportError: |
24 WEBENGINE_AVAILABLE = True |
24 WEBENGINE_AVAILABLE = False |
25 |
25 |
26 from EricWidgets import EricFileDialog, EricMessageBox |
26 from EricWidgets import EricFileDialog, EricMessageBox |
27 |
27 |
28 import UI.PixmapCache |
28 import UI.PixmapCache |
29 import Utilities |
29 import Utilities |
146 self.__buttonLine2 = QFrame(self) |
146 self.__buttonLine2 = QFrame(self) |
147 self.__buttonLine2.setFrameShape(QFrame.Shape.VLine) |
147 self.__buttonLine2.setFrameShape(QFrame.Shape.VLine) |
148 self.__buttonLine2.setFrameShadow(QFrame.Shadow.Sunken) |
148 self.__buttonLine2.setFrameShadow(QFrame.Shadow.Sunken) |
149 self.__navButtonsLayout.addWidget(self.__buttonLine2) |
149 self.__navButtonsLayout.addWidget(self.__buttonLine2) |
150 |
150 |
151 # TODO: add plus button to open a new page (about:blank) |
151 self.__addPageButton = QToolButton(self) |
152 # TODO: add minus button to close the current page |
152 self.__addPageButton.setIcon(UI.PixmapCache.getIcon("plus")) |
|
153 self.__addPageButton.setToolTip( |
|
154 self.tr("Add a new empty page")) |
|
155 self.__addPageButton.clicked.connect(self.__addNewPage) |
|
156 self.__navButtonsLayout.addWidget(self.__addPageButton) |
|
157 |
|
158 self.__closePageButton = QToolButton(self) |
|
159 self.__closePageButton.setIcon(UI.PixmapCache.getIcon("minus")) |
|
160 self.__closePageButton.setToolTip( |
|
161 self.tr("Close the current page")) |
|
162 self.__closePageButton.clicked.connect(self.closeCurrentPage) |
|
163 self.__navButtonsLayout.addWidget(self.__closePageButton) |
|
164 |
|
165 self.__buttonLine3 = QFrame(self) |
|
166 self.__buttonLine3.setFrameShape(QFrame.Shape.VLine) |
|
167 self.__buttonLine3.setFrameShadow(QFrame.Shadow.Sunken) |
|
168 self.__navButtonsLayout.addWidget(self.__buttonLine3) |
|
169 |
|
170 # TODO: add find button to show the find widget |
153 |
171 |
154 self.__navButtonsLayout.addStretch() |
172 self.__navButtonsLayout.addStretch() |
155 |
173 |
156 self.__layout.addLayout(self.__navButtonsLayout) |
174 self.__layout.addLayout(self.__navButtonsLayout) |
157 |
175 |
394 self.tr("HTML Files (*.htm *.html);;All Files (*)") |
412 self.tr("HTML Files (*.htm *.html);;All Files (*)") |
395 ) |
413 ) |
396 if htmlFile: |
414 if htmlFile: |
397 self.currentViewer().setLink(QUrl.fromLocalFile(htmlFile)) |
415 self.currentViewer().setLink(QUrl.fromLocalFile(htmlFile)) |
398 |
416 |
|
417 @pyqtSlot() |
|
418 def __addNewPage(self): |
|
419 """ |
|
420 Private slot to add a new empty page. |
|
421 """ |
|
422 self.addPage() |
|
423 |
399 def addPage(self, url=None, background=False): |
424 def addPage(self, url=None, background=False): |
400 """ |
425 """ |
401 Public method to add a new help page with the given URL. |
426 Public method to add a new help page with the given URL. |
402 |
427 |
403 @param url requested URL (defaults to QUrl("about:blank")) |
428 @param url requested URL (defaults to QUrl("about:blank")) |
410 """ |
435 """ |
411 if url is None: |
436 if url is None: |
412 url = QUrl("about:blank") |
437 url = QUrl("about:blank") |
413 |
438 |
414 viewer = self.__newViewer() |
439 viewer = self.__newViewer() |
415 viewer.setUrl(url) |
440 viewer.setLink(url) |
416 |
441 |
417 cv = self.currentViewer() |
442 cv = self.currentViewer() |
418 if background and bool(cv): |
443 if background and bool(cv): |
419 index = self.__helpStack.indexOf(cv) + 1 |
444 index = self.__helpStack.indexOf(cv) + 1 |
420 self.__helpStack.insertWidget(index, viewer) |
445 self.__helpStack.insertWidget(index, viewer) |