90 """ |
90 """ |
91 Class implementing an external javascript object to search via the startpage. |
91 Class implementing an external javascript object to search via the startpage. |
92 """ |
92 """ |
93 # these must be in line with the strings used by the javascript part of the start page |
93 # these must be in line with the strings used by the javascript part of the start page |
94 translations = [ |
94 translations = [ |
95 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Welcome to Eric Web Browser!"), |
95 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Welcome to eric5 Web Browser!"), |
96 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Eric Web Browser"), |
96 QT_TRANSLATE_NOOP("JavaScriptEricObject", "eric5 Web Browser"), |
97 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Search!"), |
97 QT_TRANSLATE_NOOP("JavaScriptEricObject", "Search!"), |
98 QT_TRANSLATE_NOOP("JavaScriptEricObject", "About Eric"), |
98 QT_TRANSLATE_NOOP("JavaScriptEricObject", "About eric5"), |
99 ] |
99 ] |
100 |
100 |
101 def __init__(self, mw, parent=None): |
101 def __init__(self, mw, parent=None): |
102 """ |
102 """ |
103 Constructor |
103 Constructor |
577 # it is a local path on win os |
577 # it is a local path on win os |
578 name = QUrl.fromLocalFile(name.toString()) |
578 name = QUrl.fromLocalFile(name.toString()) |
579 |
579 |
580 if not QFileInfo(name.toLocalFile()).exists(): |
580 if not QFileInfo(name.toLocalFile()).exists(): |
581 E5MessageBox.critical(self, |
581 E5MessageBox.critical(self, |
582 self.trUtf8("Web Browser"), |
582 self.trUtf8("eric5 Web Browser"), |
583 self.trUtf8("""<p>The file <b>{0}</b> does not exist.</p>""")\ |
583 self.trUtf8("""<p>The file <b>{0}</b> does not exist.</p>""")\ |
584 .format(name.toLocalFile())) |
584 .format(name.toLocalFile())) |
585 return |
585 return |
586 |
586 |
587 if name.toLocalFile().endswith(".pdf") or \ |
587 if name.toLocalFile().endswith(".pdf") or \ |
589 name.toLocalFile().endswith(".chm") or \ |
589 name.toLocalFile().endswith(".chm") or \ |
590 name.toLocalFile().endswith(".CHM"): |
590 name.toLocalFile().endswith(".CHM"): |
591 started = QDesktopServices.openUrl(name) |
591 started = QDesktopServices.openUrl(name) |
592 if not started: |
592 if not started: |
593 E5MessageBox.critical(self, |
593 E5MessageBox.critical(self, |
594 self.trUtf8("Web Browser"), |
594 self.trUtf8("eric5 Web Browser"), |
595 self.trUtf8("""<p>Could not start a viewer""" |
595 self.trUtf8("""<p>Could not start a viewer""" |
596 """ for file <b>{0}</b>.</p>""").format(name.path())) |
596 """ for file <b>{0}</b>.</p>""").format(name.path())) |
597 return |
597 return |
598 elif name.scheme() in ["mailto"]: |
598 elif name.scheme() in ["mailto"]: |
599 started = QDesktopServices.openUrl(name) |
599 started = QDesktopServices.openUrl(name) |
600 if not started: |
600 if not started: |
601 E5MessageBox.critical(self, |
601 E5MessageBox.critical(self, |
602 self.trUtf8("Web Browser"), |
602 self.trUtf8("eric5 Web Browser"), |
603 self.trUtf8("""<p>Could not start an application""" |
603 self.trUtf8("""<p>Could not start an application""" |
604 """ for URL <b>{0}</b>.</p>""").format(name.toString())) |
604 """ for URL <b>{0}</b>.</p>""").format(name.toString())) |
605 return |
605 return |
606 elif name.scheme() == "javascript": |
606 elif name.scheme() == "javascript": |
607 scriptSource = QUrl.fromPercentEncoding(name.toString( |
607 scriptSource = QUrl.fromPercentEncoding(name.toString( |
614 name.toString().endswith(".chm") or \ |
614 name.toString().endswith(".chm") or \ |
615 name.toString().endswith(".CHM"): |
615 name.toString().endswith(".CHM"): |
616 started = QDesktopServices.openUrl(name) |
616 started = QDesktopServices.openUrl(name) |
617 if not started: |
617 if not started: |
618 E5MessageBox.critical(self, |
618 E5MessageBox.critical(self, |
619 self.trUtf8("Web Browser"), |
619 self.trUtf8("eric5 Web Browser"), |
620 self.trUtf8("""<p>Could not start a viewer""" |
620 self.trUtf8("""<p>Could not start a viewer""" |
621 """ for file <b>{0}</b>.</p>""").format(name.path())) |
621 """ for file <b>{0}</b>.</p>""").format(name.path())) |
622 return |
622 return |
623 |
623 |
624 self.load(name) |
624 self.load(name) |