866 )) |
866 )) |
867 if not self.__initShortcutsOnly: |
867 if not self.__initShortcutsOnly: |
868 self.copyAct.triggered.connect(self.__copy) |
868 self.copyAct.triggered.connect(self.__copy) |
869 self.__actions.append(self.copyAct) |
869 self.__actions.append(self.copyAct) |
870 |
870 |
871 # TODO: add more editing actions: Cut, Paste, Undo, Redo, Select All |
871 self.cutAct = E5Action( |
|
872 self.tr('Cut'), |
|
873 UI.PixmapCache.getIcon("editCut.png"), |
|
874 self.tr('Cu&t'), |
|
875 QKeySequence(self.tr("Ctrl+X", "Edit|Cut")), |
|
876 0, self, 'webbrowser_edit_cut') |
|
877 self.cutAct.setStatusTip(self.tr('Cut the selected text')) |
|
878 self.cutAct.setWhatsThis(self.tr( |
|
879 """<b>Cut</b>""" |
|
880 """<p>Cut the selected text to the clipboard.</p>""" |
|
881 )) |
|
882 if not self.__initShortcutsOnly: |
|
883 self.cutAct.triggered.connect(self.__cut) |
|
884 self.__actions.append(self.cutAct) |
|
885 |
|
886 self.pasteAct = E5Action( |
|
887 self.tr('Paste'), |
|
888 UI.PixmapCache.getIcon("editPaste.png"), |
|
889 self.tr('&Paste'), |
|
890 QKeySequence(self.tr("Ctrl+V", "Edit|Paste")), |
|
891 0, self, 'webbrowser_edit_paste') |
|
892 self.pasteAct.setStatusTip(self.tr('Paste text from the clipboard')) |
|
893 self.pasteAct.setWhatsThis(self.tr( |
|
894 """<b>Paste</b>""" |
|
895 """<p>Paste some text from the clipboard.</p>""" |
|
896 )) |
|
897 if not self.__initShortcutsOnly: |
|
898 self.pasteAct.triggered.connect(self.__paste) |
|
899 self.__actions.append(self.pasteAct) |
|
900 |
|
901 self.undoAct = E5Action( |
|
902 self.tr('Undo'), |
|
903 UI.PixmapCache.getIcon("editUndo.png"), |
|
904 self.tr('&Undo'), |
|
905 QKeySequence(self.tr("Ctrl+Z", "Edit|Undo")), |
|
906 0, self, 'webbrowser_edit_undo') |
|
907 self.undoAct.setStatusTip(self.tr('Undo the last edit action')) |
|
908 self.undoAct.setWhatsThis(self.tr( |
|
909 """<b>Undo</b>""" |
|
910 """<p>Undo the last edit action.</p>""" |
|
911 )) |
|
912 if not self.__initShortcutsOnly: |
|
913 self.undoAct.triggered.connect(self.__undo) |
|
914 self.__actions.append(self.undoAct) |
|
915 |
|
916 self.redoAct = E5Action( |
|
917 self.tr('Redo'), |
|
918 UI.PixmapCache.getIcon("editRedo.png"), |
|
919 self.tr('&Redo'), |
|
920 QKeySequence(self.tr("Ctrl+Shift+Z", "Edit|Redo")), |
|
921 0, self, 'webbrowser_edit_redo') |
|
922 self.redoAct.setStatusTip(self.tr('Redo the last edit action')) |
|
923 self.redoAct.setWhatsThis(self.tr( |
|
924 """<b>Redo</b>""" |
|
925 """<p>Redo the last edit action.</p>""" |
|
926 )) |
|
927 if not self.__initShortcutsOnly: |
|
928 self.redoAct.triggered.connect(self.__redo) |
|
929 self.__actions.append(self.redoAct) |
|
930 |
|
931 self.selectAllAct = E5Action( |
|
932 self.tr('Select All'), |
|
933 UI.PixmapCache.getIcon("editSelectAll.png"), |
|
934 self.tr('&Select All'), |
|
935 QKeySequence(self.tr("Ctrl+A", "Edit|Select All")), |
|
936 0, self, 'webbrowser_edit_select_all') |
|
937 self.selectAllAct.setStatusTip(self.tr('Select all text')) |
|
938 self.selectAllAct.setWhatsThis(self.tr( |
|
939 """<b>Select All</b>""" |
|
940 """<p>Select all text of the current browser.</p>""" |
|
941 )) |
|
942 if not self.__initShortcutsOnly: |
|
943 self.selectAllAct.triggered.connect(self.__selectAll) |
|
944 self.__actions.append(self.selectAllAct) |
|
945 |
|
946 # TODO: add more editing actions: Select All |
872 |
947 |
873 self.findAct = E5Action( |
948 self.findAct = E5Action( |
874 self.tr('Find...'), |
949 self.tr('Find...'), |
875 UI.PixmapCache.getIcon("find.png"), |
950 UI.PixmapCache.getIcon("find.png"), |
876 self.tr('&Find...'), |
951 self.tr('&Find...'), |
1703 ## menu.addSeparator() |
1778 ## menu.addSeparator() |
1704 menu.addAction(self.exitAct) |
1779 menu.addAction(self.exitAct) |
1705 |
1780 |
1706 menu = mb.addMenu(self.tr('&Edit')) |
1781 menu = mb.addMenu(self.tr('&Edit')) |
1707 menu.setTearOffEnabled(True) |
1782 menu.setTearOffEnabled(True) |
|
1783 menu.addAction(self.undoAct) |
|
1784 menu.addAction(self.redoAct) |
|
1785 menu.addSeparator() |
1708 menu.addAction(self.copyAct) |
1786 menu.addAction(self.copyAct) |
|
1787 menu.addAction(self.cutAct) |
|
1788 menu.addAction(self.pasteAct) |
|
1789 menu.addSeparator() |
|
1790 menu.addAction(self.selectAllAct) |
1709 menu.addSeparator() |
1791 menu.addSeparator() |
1710 menu.addAction(self.findAct) |
1792 menu.addAction(self.findAct) |
1711 menu.addAction(self.findNextAct) |
1793 menu.addAction(self.findNextAct) |
1712 menu.addAction(self.findPrevAct) |
1794 menu.addAction(self.findPrevAct) |
1713 |
1795 |
1867 ## savePageScreenButton.setPopupMode(QToolButton.MenuButtonPopup) |
1949 ## savePageScreenButton.setPopupMode(QToolButton.MenuButtonPopup) |
1868 |
1950 |
1869 edittb = self.addToolBar(self.tr("Edit")) |
1951 edittb = self.addToolBar(self.tr("Edit")) |
1870 edittb.setObjectName("EditToolBar") |
1952 edittb.setObjectName("EditToolBar") |
1871 edittb.setIconSize(UI.Config.ToolBarIconSize) |
1953 edittb.setIconSize(UI.Config.ToolBarIconSize) |
|
1954 edittb.addAction(self.undoAct) |
|
1955 edittb.addAction(self.redoAct) |
|
1956 edittb.addSeparator() |
1872 edittb.addAction(self.copyAct) |
1957 edittb.addAction(self.copyAct) |
|
1958 edittb.addAction(self.cutAct) |
|
1959 edittb.addAction(self.pasteAct) |
|
1960 edittb.addSeparator() |
|
1961 edittb.addAction(self.selectAllAct) |
1873 |
1962 |
1874 viewtb = self.addToolBar(self.tr("View")) |
1963 viewtb = self.addToolBar(self.tr("View")) |
1875 viewtb.setObjectName("ViewToolBar") |
1964 viewtb.setObjectName("ViewToolBar") |
1876 viewtb.setIconSize(UI.Config.ToolBarIconSize) |
1965 viewtb.setIconSize(UI.Config.ToolBarIconSize) |
1877 viewtb.addAction(self.zoomInAct) |
1966 viewtb.addAction(self.zoomInAct) |
2505 def __copy(self): |
2594 def __copy(self): |
2506 """ |
2595 """ |
2507 Private slot called to handle the copy action. |
2596 Private slot called to handle the copy action. |
2508 """ |
2597 """ |
2509 self.currentBrowser().copy() |
2598 self.currentBrowser().copy() |
|
2599 |
|
2600 def __cut(self): |
|
2601 """ |
|
2602 Private slot called to handle the cut action. |
|
2603 """ |
|
2604 self.currentBrowser().cut() |
|
2605 |
|
2606 def __paste(self): |
|
2607 """ |
|
2608 Private slot called to handle the paste action. |
|
2609 """ |
|
2610 self.currentBrowser().paste() |
|
2611 |
|
2612 def __undo(self): |
|
2613 """ |
|
2614 Private slot to handle the undo action. |
|
2615 """ |
|
2616 self.currentBrowser().undo() |
|
2617 |
|
2618 def __redo(self): |
|
2619 """ |
|
2620 Private slot to handle the redo action. |
|
2621 """ |
|
2622 self.currentBrowser().redo() |
|
2623 |
|
2624 def __selectAll(self): |
|
2625 """ |
|
2626 Private slot to handle the select all action. |
|
2627 """ |
|
2628 self.currentBrowser().selectAll() |
2510 ## |
2629 ## |
2511 ## def __privateBrowsing(self): |
2630 ## def __privateBrowsing(self): |
2512 ## """ |
2631 ## """ |
2513 ## Private slot to switch private browsing. |
2632 ## Private slot to switch private browsing. |
2514 ## """ |
2633 ## """ |
3072 backItems = history.backItems(historyCount) |
3191 backItems = history.backItems(historyCount) |
3073 for index in range(len(backItems) - 1, -1, -1): |
3192 for index in range(len(backItems) - 1, -1, -1): |
3074 item = backItems[index] |
3193 item = backItems[index] |
3075 act = QAction(self) |
3194 act = QAction(self) |
3076 act.setData(-1 * (index + 1)) |
3195 act.setData(-1 * (index + 1)) |
3077 ## icon = HelpWindow.__getWebIcon(item.url()) |
3196 icon = HelpWindow.icon(item.url()) |
3078 ## act.setIcon(icon) |
3197 act.setIcon(icon) |
3079 act.setText(item.title()) |
3198 act.setText(item.title()) |
3080 self.backMenu.addAction(act) |
3199 self.backMenu.addAction(act) |
3081 |
3200 |
3082 def __showForwardMenu(self): |
3201 def __showForwardMenu(self): |
3083 """ |
3202 """ |
3089 forwardItems = history.forwardItems(historyCount) |
3208 forwardItems = history.forwardItems(historyCount) |
3090 for index in range(len(forwardItems)): |
3209 for index in range(len(forwardItems)): |
3091 item = forwardItems[index] |
3210 item = forwardItems[index] |
3092 act = QAction(self) |
3211 act = QAction(self) |
3093 act.setData(index + 1) |
3212 act.setData(index + 1) |
3094 ## icon = HelpWindow.__getWebIcon(item.url()) |
3213 icon = HelpWindow.icon(item.url()) |
3095 ## act.setIcon(icon) |
3214 act.setIcon(icon) |
3096 act.setText(item.title()) |
3215 act.setText(item.title()) |
3097 self.forwardMenu.addAction(act) |
3216 self.forwardMenu.addAction(act) |
3098 |
3217 |
3099 def __navigationMenuActionTriggered(self, act): |
3218 def __navigationMenuActionTriggered(self, act): |
3100 """ |
3219 """ |
3289 Class method to get the icon for an URL. |
3408 Class method to get the icon for an URL. |
3290 |
3409 |
3291 @param url URL to get icon for (QUrl) |
3410 @param url URL to get icon for (QUrl) |
3292 @return icon for the URL (QIcon) |
3411 @return icon for the URL (QIcon) |
3293 """ |
3412 """ |
3294 # TODO: implement an icon fetcher |
3413 return WebIconProvider.instance().iconForUrl(url) |
3295 ## icon = HelpWindow.__getWebIcon(url) |
|
3296 ## if icon.isNull(): |
|
3297 ## hostUrl = QUrl() |
|
3298 ## hostUrl.setScheme(url.scheme()) |
|
3299 ## hostUrl.setHost(url.host()) |
|
3300 ## icon = HelpWindow.__getWebIcon(hostUrl) |
|
3301 ## |
|
3302 ## if icon.isNull(): |
|
3303 ## pixmap = QWebSettings.webGraphic( |
|
3304 ## QWebSettings.DefaultFrameIconGraphic) |
|
3305 ## if pixmap.isNull(): |
|
3306 ## pixmap = UI.PixmapCache.getPixmap("defaultIcon.png") |
|
3307 ## QWebSettings.setWebGraphic( |
|
3308 ## QWebSettings.DefaultFrameIconGraphic, pixmap) |
|
3309 ## return QIcon(pixmap) |
|
3310 ## |
|
3311 icon = UI.PixmapCache.getIcon("defaultIcon.png") |
|
3312 return icon |
|
3313 |
3414 |
3314 ## @staticmethod |
|
3315 ## def __getWebIcon(url): |
|
3316 ## """ |
|
3317 ## Private static method to fetch the icon for a URL. |
|
3318 ## |
|
3319 ## @param url URL to get icon for (QUrl) |
|
3320 ## @return icon for the URL (QIcon) |
|
3321 ## """ |
|
3322 ## scheme = url.scheme() |
|
3323 ## if scheme in ["eric", "about"]: |
|
3324 ## return UI.PixmapCache.getIcon("ericWeb.png") |
|
3325 ## elif scheme == "qthelp" and QTHELP_AVAILABLE: |
|
3326 ## return UI.PixmapCache.getIcon("qthelp.png") |
|
3327 ## elif scheme == "file": |
|
3328 ## return UI.PixmapCache.getIcon("fileMisc.png") |
|
3329 ## elif scheme == "abp": |
|
3330 ## return UI.PixmapCache.getIcon("adBlockPlus.png") |
|
3331 ## |
|
3332 ## icon = QWebSettings.iconForUrl(url) |
|
3333 ## if icon.isNull(): |
|
3334 ## # try again |
|
3335 ## QThread.usleep(10) |
|
3336 ## icon = QWebSettings.iconForUrl(url) |
|
3337 ## if not icon.isNull(): |
|
3338 ## icon = QIcon(icon.pixmap(22, 22)) |
|
3339 ## return icon |
|
3340 ## |
|
3341 ## @classmethod |
3415 ## @classmethod |
3342 ## def bookmarksManager(cls): |
3416 ## def bookmarksManager(cls): |
3343 ## """ |
3417 ## """ |
3344 ## Class method to get a reference to the bookmarks manager. |
3418 ## Class method to get a reference to the bookmarks manager. |
3345 ## |
3419 ## |