Continued porting the web browser. QtWebEngine

Sat, 13 Feb 2016 14:17:39 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 13 Feb 2016 14:17:39 +0100
branch
QtWebEngine
changeset 4735
84e78ee0f361
parent 4734
ce0b1f024da9
child 4741
f9e1adc69076

Continued porting the web browser.

- added bookmarking from the URL bar stuff

WebBrowser/ClosedTabsManager.py file | annotate | diff | comparison | revisions
WebBrowser/History/HistoryManager.py file | annotate | diff | comparison | revisions
WebBrowser/History/HistoryMenu.py file | annotate | diff | comparison | revisions
WebBrowser/UrlBar/BookmarkActionSelectionDialog.py file | annotate | diff | comparison | revisions
WebBrowser/UrlBar/BookmarkActionSelectionDialog.ui file | annotate | diff | comparison | revisions
WebBrowser/UrlBar/BookmarkInfoDialog.py file | annotate | diff | comparison | revisions
WebBrowser/UrlBar/BookmarkInfoDialog.ui file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserTabWidget.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserView.py file | annotate | diff | comparison | revisions
WebBrowser/WebBrowserWindow.py file | annotate | diff | comparison | revisions
eric6.e4p file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/ClosedTabsManager.py	Sat Feb 13 14:17:39 2016 +0100
@@ -0,0 +1,116 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2012 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a class to manage closed tabs.
+"""
+
+from __future__ import unicode_literals
+
+from PyQt5.QtCore import pyqtSignal, QUrl, QObject
+
+
+class ClosedTab(object):
+    """
+    Class implementing a structure to store data about a closed tab.
+    """
+    def __init__(self, url=QUrl(), title="", position=-1):
+        """
+        Constructor
+        
+        @param url URL of the closed tab (QUrl)
+        @param title title of the closed tab (string)
+        @param position index of the closed tab (integer)
+        """
+        self.url = url
+        self.title = title
+        self.position = position
+    
+    def __eq__(self, other):
+        """
+        Special method implementing the equality operator.
+        
+        @param other reference to the object to compare against (ClosedTab)
+        @return flag indicating equality of the tabs (boolean)
+        """
+        return self.url == other.url and \
+            self.title == other.title and \
+            self.position == other.position
+
+
+class ClosedTabsManager(QObject):
+    """
+    Class implementing a manager for closed tabs.
+    
+    @signal closedTabAvailable(boolean) emitted to signal a change of
+        availability of closed tabs
+    """
+    closedTabAvailable = pyqtSignal(bool)
+    
+    def __init__(self, parent=None):
+        """
+        Constructor
+        
+        @param parent reference to the parent object (QObject)
+        """
+        super(ClosedTabsManager, self).__init__()
+        
+        self.__closedTabs = []
+    
+    def recordBrowser(self, browser, position):
+        """
+        Public method to record the data of a browser about to be closed.
+        
+        @param browser reference to the browser to be closed (HelpBrowser)
+        @param position index of the tab to be closed (integer)
+        """
+        import WebBrowser.WebBrowserWindow
+        if WebBrowser.WebBrowserWindow.WebBrowserWindow\
+                .mainWindow().getWindow().isPrivate():
+            return
+        
+        if browser.url().isEmpty():
+            return
+        
+        tab = ClosedTab(browser.url(), browser.title(), position)
+        self.__closedTabs.insert(0, tab)
+        self.closedTabAvailable.emit(True)
+    
+    def getClosedTabAt(self, index):
+        """
+        Public method to get the indexed closed tab.
+        
+        @param index index of the tab to return (integer)
+        @return requested tab (ClosedTab)
+        """
+        if len(self.__closedTabs) > 0 and len(self.__closedTabs) > index:
+            tab = self.__closedTabs.pop(index)
+        else:
+            tab = ClosedTab()
+        self.closedTabAvailable.emit(len(self.__closedTabs) > 0)
+        return tab
+    
+    def isClosedTabAvailable(self):
+        """
+        Public method to check for closed tabs.
+        
+        @return flag indicating the availability of closed tab data (boolean)
+        """
+        return len(self.__closedTabs) > 0
+    
+    def clearList(self):
+        """
+        Public method to clear the list of closed tabs.
+        """
+        self.__closedTabs = []
+        self.closedTabAvailable.emit(False)
+    
+    def allClosedTabs(self):
+        """
+        Public method to get a list of all closed tabs.
+        
+        @return list of closed tabs (list of ClosedTab)
+        """
+        return self.__closedTabs
--- a/WebBrowser/History/HistoryManager.py	Sat Feb 13 13:36:01 2016 +0100
+++ b/WebBrowser/History/HistoryManager.py	Sat Feb 13 14:17:39 2016 +0100
@@ -179,32 +179,6 @@
             self.__saveTimer.changeOccurred()
         self.historyReset.emit()
     
-##    def _addHistoryEntry(self, itm):
-##        """
-##        Protected method to add a history item.
-##        
-##        @param itm reference to the history item to add (HistoryEntry)
-##        """
-##        import WebBrowser.WebBrowserWindow
-##        if WebBrowser.WebBrowserWindow.WebBrowserWindow\
-##                .mainWindow().getWindow().isPrivate():
-##            return
-##        
-##        self.__history.insert(0, itm)
-##        self.entryAdded.emit(itm)
-##        if len(self.__history) == 1:
-##            self.__checkForExpired()
-##    
-##    def _removeHistoryEntry(self, itm):
-##        """
-##        Protected method to remove a history item.
-##        
-##        @param itm reference to the history item to remove (HistoryEntry)
-##        """
-##        self.__lastSavedUrl = ""
-##        self.__history.remove(itm)
-##        self.entryRemoved.emit(itm)
-    
     def addHistoryEntry(self, view):
         """
         Public method to add a history entry.
--- a/WebBrowser/History/HistoryMenu.py	Sat Feb 13 13:36:01 2016 +0100
+++ b/WebBrowser/History/HistoryMenu.py	Sat Feb 13 14:17:39 2016 +0100
@@ -277,12 +277,11 @@
         self.__initialActions = []
         self.__mostVisitedMenu = None
         
-        # TODO: Closed Tabs Manager
-##        self.__closedTabsMenu = QMenu(self.tr("Closed Tabs"))
-##        self.__closedTabsMenu.aboutToShow.connect(
-##            self.__aboutToShowClosedTabsMenu)
-##        self.__tabWidget.closedTabsManager().closedTabAvailable.connect(
-##            self.__closedTabAvailable)
+        self.__closedTabsMenu = QMenu(self.tr("Closed Tabs"))
+        self.__closedTabsMenu.aboutToShow.connect(
+            self.__aboutToShowClosedTabsMenu)
+        self.__tabWidget.closedTabsManager().closedTabAvailable.connect(
+            self.__closedTabAvailable)
         
         self.setMaxRows(7)
         
@@ -340,10 +339,9 @@
             self.__mostVisitedMenu.openUrl.connect(self.openUrl)
             self.__mostVisitedMenu.newUrl.connect(self.newUrl)
         self.addMenu(self.__mostVisitedMenu)
-        # TODO: Closed Tabs Manager
-##        act = self.addMenu(self.__closedTabsMenu)
-##        act.setIcon(UI.PixmapCache.getIcon("trash.png"))
-##        act.setEnabled(self.__tabWidget.canRestoreClosedTab())
+        act = self.addMenu(self.__closedTabsMenu)
+        act.setIcon(UI.PixmapCache.getIcon("trash.png"))
+        act.setEnabled(self.__tabWidget.canRestoreClosedTab())
         self.addSeparator()
         
         act = self.addAction(UI.PixmapCache.getIcon("history.png"),
@@ -383,42 +381,40 @@
                 self.tr("Clear History"),
                 self.tr("""Do you want to clear the history?""")):
             self.__historyManager.clear()
-            # TODO: Closed Tabs Manager
-##            self.__tabWidget.clearClosedTabsList()
+            self.__tabWidget.clearClosedTabsList()
     
-    # TODO: Closed Tabs Manager
-##    def __aboutToShowClosedTabsMenu(self):
-##        """
-##        Private slot to populate the closed tabs menu.
-##        """
-##        fm = self.__closedTabsMenu.fontMetrics()
-##        maxWidth = fm.width('m') * 40
-##        
-##        import WebBrowser.WebBrowserWindow
-##        self.__closedTabsMenu.clear()
-##        index = 0
-##        for tab in self.__tabWidget.closedTabsManager().allClosedTabs():
-##            title = fm.elidedText(tab.title, Qt.ElideRight, maxWidth)
-##            self.__closedTabsMenu.addAction(
-##                WebBrowser.WebBrowserWindow.WebBrowserWindow.icon(tab.url),
-##                title,
-##                self.__tabWidget.restoreClosedTab).setData(index)
-##            index += 1
-##        self.__closedTabsMenu.addSeparator()
-##        self.__closedTabsMenu.addAction(
-##            self.tr("Restore All Closed Tabs"),
-##            self.__tabWidget.restoreAllClosedTabs)
-##        self.__closedTabsMenu.addAction(
-##            self.tr("Clear List"),
-##            self.__tabWidget.clearClosedTabsList)
-##    
-##    def __closedTabAvailable(self, avail):
-##        """
-##        Private slot to handle changes of the availability of closed tabs.
-##        
-##        @param avail flag indicating the availability of closed tabs (boolean)
-##        """
-##        self.__closedTabsMenu.setEnabled(avail)
+    def __aboutToShowClosedTabsMenu(self):
+        """
+        Private slot to populate the closed tabs menu.
+        """
+        fm = self.__closedTabsMenu.fontMetrics()
+        maxWidth = fm.width('m') * 40
+        
+        import WebBrowser.WebBrowserWindow
+        self.__closedTabsMenu.clear()
+        index = 0
+        for tab in self.__tabWidget.closedTabsManager().allClosedTabs():
+            title = fm.elidedText(tab.title, Qt.ElideRight, maxWidth)
+            self.__closedTabsMenu.addAction(
+                WebBrowser.WebBrowserWindow.WebBrowserWindow.icon(tab.url),
+                title,
+                self.__tabWidget.restoreClosedTab).setData(index)
+            index += 1
+        self.__closedTabsMenu.addSeparator()
+        self.__closedTabsMenu.addAction(
+            self.tr("Restore All Closed Tabs"),
+            self.__tabWidget.restoreAllClosedTabs)
+        self.__closedTabsMenu.addAction(
+            self.tr("Clear List"),
+            self.__tabWidget.clearClosedTabsList)
+    
+    def __closedTabAvailable(self, avail):
+        """
+        Private slot to handle changes of the availability of closed tabs.
+        
+        @param avail flag indicating the availability of closed tabs (boolean)
+        """
+        self.__closedTabsMenu.setEnabled(avail)
 
 
 class HistoryMostVisitedMenu(E5ModelMenu):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/UrlBar/BookmarkActionSelectionDialog.py	Sat Feb 13 14:17:39 2016 +0100
@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2012 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to select the action to be performed on the
+bookmark.
+"""
+
+from __future__ import unicode_literals
+
+from PyQt5.QtCore import pyqtSlot
+from PyQt5.QtWidgets import QDialog
+
+from .Ui_BookmarkActionSelectionDialog import Ui_BookmarkActionSelectionDialog
+
+import UI.PixmapCache
+
+
+class BookmarkActionSelectionDialog(QDialog, Ui_BookmarkActionSelectionDialog):
+    """
+    Class implementing a dialog to select the action to be performed on
+    the bookmark.
+    """
+    Undefined = -1
+    AddBookmark = 0
+    EditBookmark = 1
+    AddSpeeddial = 2
+    RemoveSpeeddial = 3
+    
+    def __init__(self, url, parent=None):
+        """
+        Constructor
+        
+        @param url URL to be worked on (QUrl)
+        @param parent reference to the parent widget (QWidget)
+        """
+        super(BookmarkActionSelectionDialog, self).__init__(parent)
+        self.setupUi(self)
+        
+        self.__action = self.Undefined
+        
+        self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32.png"))
+        
+        import WebBrowser.WebBrowserWindow
+        
+        if WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()\
+           .bookmarkForUrl(url) is None:
+            self.__bmAction = self.AddBookmark
+            self.bookmarkPushButton.setText(self.tr("Add Bookmark"))
+        else:
+            self.__bmAction = self.EditBookmark
+            self.bookmarkPushButton.setText(self.tr("Edit Bookmark"))
+        
+        # TODO: SpeedDial
+        self.speeddialPushButton.setText("Future Speed Dial Entry")
+##        if WebBrowser.WebBrowserWindow.WebBrowserWindow.speedDial().pageForUrl(url).url:
+##            self.__sdAction = self.RemoveSpeeddial
+##            self.speeddialPushButton.setText(
+##                self.tr("Remove from Speed Dial"))
+##        else:
+##            self.__sdAction = self.AddSpeeddial
+##            self.speeddialPushButton.setText(self.tr("Add to Speed Dial"))
+        
+        msh = self.minimumSizeHint()
+        self.resize(max(self.width(), msh.width()), msh.height())
+    
+    @pyqtSlot()
+    def on_bookmarkPushButton_clicked(self):
+        """
+        Private slot handling selection of a bookmark action.
+        """
+        self.__action = self.__bmAction
+        self.accept()
+    
+    @pyqtSlot()
+    def on_speeddialPushButton_clicked(self):
+        """
+        Private slot handling selection of a speed dial action.
+        """
+        self.__action = self.__sdAction
+        self.accept()
+    
+    def getAction(self):
+        """
+        Public method to get the selected action.
+        
+        @return reference to the associated action
+        """
+        return self.__action
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/UrlBar/BookmarkActionSelectionDialog.ui	Sat Feb 13 14:17:39 2016 +0100
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BookmarkActionSelectionDialog</class>
+ <widget class="QDialog" name="BookmarkActionSelectionDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>291</width>
+    <height>153</height>
+   </rect>
+  </property>
+  <property name="sizeGripEnabled">
+   <bool>true</bool>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="icon">
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>&lt;b&gt;Add/Edit Bookmark&lt;/b&gt;</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QPushButton" name="bookmarkPushButton"/>
+   </item>
+   <item>
+    <widget class="QPushButton" name="speeddialPushButton"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/UrlBar/BookmarkInfoDialog.py	Sat Feb 13 14:17:39 2016 +0100
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2010 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to show some bookmark info.
+"""
+
+from __future__ import unicode_literals
+
+from PyQt5.QtCore import pyqtSlot
+from PyQt5.QtGui import QFont
+from PyQt5.QtWidgets import QDialog
+
+from .Ui_BookmarkInfoDialog import Ui_BookmarkInfoDialog
+
+import UI.PixmapCache
+
+
+class BookmarkInfoDialog(QDialog, Ui_BookmarkInfoDialog):
+    """
+    Class implementing a dialog to show some bookmark info.
+    """
+    def __init__(self, bookmark, parent=None):
+        """
+        Constructor
+        
+        @param bookmark reference to the bookmark to be shown (Bookmark)
+        @param parent reference to the parent widget (QWidget)
+        """
+        super(BookmarkInfoDialog, self).__init__(parent)
+        self.setupUi(self)
+        
+        self.__bookmark = bookmark
+        
+        self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32.png"))
+        
+        font = QFont()
+        font.setPointSize(font.pointSize() + 2)
+        self.title.setFont(font)
+        
+        if bookmark is None:
+            self.titleEdit.setEnabled(False)
+        else:
+            self.titleEdit.setText(bookmark.title)
+            self.titleEdit.setFocus()
+        
+        msh = self.minimumSizeHint()
+        self.resize(max(self.width(), msh.width()), msh.height())
+    
+    @pyqtSlot()
+    def on_removeButton_clicked(self):
+        """
+        Private slot to remove the current bookmark.
+        """
+        import Helpviewer.HelpWindow
+        Helpviewer.HelpWindow.HelpWindow.bookmarksManager()\
+            .removeBookmark(self.__bookmark)
+        self.close()
+    
+    def accept(self):
+        """
+        Public slot handling the acceptance of the dialog.
+        """
+        if self.__bookmark is not None and \
+           self.titleEdit.text() != self.__bookmark.title:
+            import WebBrowser.WebBrowserWindow
+            WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()\
+                .setTitle(self.__bookmark, self.titleEdit.text())
+        self.close()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebBrowser/UrlBar/BookmarkInfoDialog.ui	Sat Feb 13 14:17:39 2016 +0100
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BookmarkInfoDialog</class>
+ <widget class="QDialog" name="BookmarkInfoDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>350</width>
+    <height>135</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Edit Bookmark</string>
+  </property>
+  <property name="sizeGripEnabled">
+   <bool>true</bool>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="1">
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <property name="spacing">
+      <number>10</number>
+     </property>
+     <item>
+      <widget class="QLabel" name="icon">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout">
+       <item>
+        <widget class="QLabel" name="title">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Edit this Bookmark</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignCenter</set>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="removeButton">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="toolTip">
+          <string>Press to remove this bookmark</string>
+         </property>
+         <property name="text">
+          <string>Remove this Bookmark</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Title:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QLineEdit" name="titleEdit"/>
+   </item>
+   <item row="2" column="0" colspan="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>removeButton</tabstop>
+  <tabstop>titleEdit</tabstop>
+  <tabstop>buttonBox</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>BookmarkInfoDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>227</x>
+     <y>114</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>134</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>BookmarkInfoDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>295</x>
+     <y>120</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>134</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
--- a/WebBrowser/WebBrowserTabWidget.py	Sat Feb 13 13:36:01 2016 +0100
+++ b/WebBrowser/WebBrowserTabWidget.py	Sat Feb 13 14:17:39 2016 +0100
@@ -69,11 +69,10 @@
         self.setDocumentMode(True)
         self.setElideMode(Qt.ElideNone)
         
-        # TODO: Closed Tabs Manager
-##        from .ClosedTabsManager import ClosedTabsManager
-##        self.__closedTabsManager = ClosedTabsManager(self)
-##        self.__closedTabsManager.closedTabAvailable.connect(
-##            self.__closedTabAvailable)
+        from .ClosedTabsManager import ClosedTabsManager
+        self.__closedTabsManager = ClosedTabsManager(self)
+        self.__closedTabsManager.closedTabAvailable.connect(
+            self.__closedTabAvailable)
         
         from .UrlBar.StackedUrlBar import StackedUrlBar
         self.__stackedUrlBar = StackedUrlBar(self)
@@ -103,20 +102,19 @@
         self.__navigationButton.setEnabled(False)
         self.__rightCornerWidgetLayout.addWidget(self.__navigationButton)
         
-        # TODO: Closed Tabs Manager
-##        self.__closedTabsMenu = QMenu(self)
-##        self.__closedTabsMenu.aboutToShow.connect(
-##            self.__aboutToShowClosedTabsMenu)
-##        
-##        self.__closedTabsButton = QToolButton(self)
-##        self.__closedTabsButton.setIcon(UI.PixmapCache.getIcon("trash.png"))
-##        self.__closedTabsButton.setToolTip(
-##            self.tr("Show a navigation menu for closed tabs"))
-##        self.__closedTabsButton.setPopupMode(QToolButton.InstantPopup)
-##        self.__closedTabsButton.setMenu(self.__closedTabsMenu)
-##        self.__closedTabsButton.setEnabled(False)
-##        self.__rightCornerWidgetLayout.addWidget(self.__closedTabsButton)
-##        
+        self.__closedTabsMenu = QMenu(self)
+        self.__closedTabsMenu.aboutToShow.connect(
+            self.__aboutToShowClosedTabsMenu)
+        
+        self.__closedTabsButton = QToolButton(self)
+        self.__closedTabsButton.setIcon(UI.PixmapCache.getIcon("trash.png"))
+        self.__closedTabsButton.setToolTip(
+            self.tr("Show a navigation menu for closed tabs"))
+        self.__closedTabsButton.setPopupMode(QToolButton.InstantPopup)
+        self.__closedTabsButton.setMenu(self.__closedTabsMenu)
+        self.__closedTabsButton.setEnabled(False)
+        self.__rightCornerWidgetLayout.addWidget(self.__closedTabsButton)
+        
         self.__closeButton = QToolButton(self)
         self.__closeButton.setIcon(UI.PixmapCache.getIcon("close.png"))
         self.__closeButton.setToolTip(
@@ -186,10 +184,10 @@
         self.__tabContextMenu.addAction(
             UI.PixmapCache.getIcon("reload.png"),
             self.tr('Reload All'), self.reloadAllBrowsers)
-##        self.__tabContextMenu.addSeparator()
-##        self.__tabContextMenu.addAction(
-##            UI.PixmapCache.getIcon("addBookmark.png"),
-##            self.tr('Bookmark All Tabs'), self.__mainWindow.bookmarkAll)
+        self.__tabContextMenu.addSeparator()
+        self.__tabContextMenu.addAction(
+            UI.PixmapCache.getIcon("addBookmark.png"),
+            self.tr('Bookmark All Tabs'), self.__mainWindow.bookmarkAll)
         
         self.__tabBackContextMenu = QMenu(self)
         self.__tabBackContextMenu.addAction(
@@ -197,15 +195,15 @@
         self.__tabBackContextMenu.addAction(
             UI.PixmapCache.getIcon("reload.png"),
             self.tr('Reload All'), self.reloadAllBrowsers)
-##        self.__tabBackContextMenu.addAction(
-##            UI.PixmapCache.getIcon("addBookmark.png"),
-##            self.tr('Bookmark All Tabs'), self.__mainWindow.bookmarkAll)
-##        self.__tabBackContextMenu.addSeparator()
-##        self.__restoreClosedTabAct = self.__tabBackContextMenu.addAction(
-##            UI.PixmapCache.getIcon("trash.png"),
-##            self.tr('Restore Closed Tab'), self.restoreClosedTab)
-##        self.__restoreClosedTabAct.setEnabled(False)
-##        self.__restoreClosedTabAct.setData(0)
+        self.__tabBackContextMenu.addAction(
+            UI.PixmapCache.getIcon("addBookmark.png"),
+            self.tr('Bookmark All Tabs'), self.__mainWindow.bookmarkAll)
+        self.__tabBackContextMenu.addSeparator()
+        self.__restoreClosedTabAct = self.__tabBackContextMenu.addAction(
+            UI.PixmapCache.getIcon("trash.png"),
+            self.tr('Restore Closed Tab'), self.restoreClosedTab)
+        self.__restoreClosedTabAct.setEnabled(False)
+        self.__restoreClosedTabAct.setData(0)
     
     def __showContextMenu(self, coord, index):
         """
@@ -484,8 +482,9 @@
         urlbar.deleteLater()
         del urlbar
         
-##        self.__closedTabsManager.recordBrowser(browser, index)
-##        
+        self.__closedTabsManager.recordBrowser(browser, index)
+        
+        # TODO: WebInspector
 ##        browser.closeWebInspector()
         browser.home()
         self.removeTab(index)
@@ -955,78 +954,77 @@
             elif browser.url() != "":
                 browser.setFocus()
     
-    # TODO: Closed Tabs Manager
-##    def restoreClosedTab(self):
-##        """
-##        Public slot to restore the most recently closed tab.
-##        """
-##        if not self.canRestoreClosedTab():
-##            return
-##        
-##        act = self.sender()
-##        tab = self.__closedTabsManager.getClosedTabAt(act.data())
-##        
-##        self.newBrowser(tab.url.toString(), position=tab.position)
-##    
-##    def canRestoreClosedTab(self):
-##        """
-##        Public method to check, if closed tabs can be restored.
-##        
-##        @return flag indicating that closed tabs can be restored (boolean)
-##        """
-##        return self.__closedTabsManager.isClosedTabAvailable()
-##    
-##    def restoreAllClosedTabs(self):
-##        """
-##        Public slot to restore all closed tabs.
-##        """
-##        if not self.canRestoreClosedTab():
-##            return
-##        
-##        for tab in self.__closedTabsManager.allClosedTabs():
-##            self.newBrowser(tab.url.toString(), position=tab.position)
-##        self.__closedTabsManager.clearList()
-##    
-##    def clearClosedTabsList(self):
-##        """
-##        Public slot to clear the list of closed tabs.
-##        """
-##        self.__closedTabsManager.clearList()
-##    
-##    def __aboutToShowClosedTabsMenu(self):
-##        """
-##        Private slot to populate the closed tabs menu.
-##        """
-##        fm = self.__closedTabsMenu.fontMetrics()
-##        maxWidth = fm.width('m') * 40
-##        
-##        self.__closedTabsMenu.clear()
-##        index = 0
-##        for tab in self.__closedTabsManager.allClosedTabs():
-##            title = fm.elidedText(tab.title, Qt.ElideRight, maxWidth)
-##            self.__closedTabsMenu.addAction(
-##                self.__mainWindow.icon(tab.url), title,
-##                self.restoreClosedTab).setData(index)
-##            index += 1
-##        self.__closedTabsMenu.addSeparator()
-##        self.__closedTabsMenu.addAction(
-##            self.tr("Restore All Closed Tabs"), self.restoreAllClosedTabs)
-##        self.__closedTabsMenu.addAction(
-##            self.tr("Clear List"), self.clearClosedTabsList)
-##    
-##    def closedTabsManager(self):
-##        """
-##        Public slot to get a reference to the closed tabs manager.
-##        
-##        @return reference to the closed tabs manager (ClosedTabsManager)
-##        """
-##        return self.__closedTabsManager
-##    
-##    def __closedTabAvailable(self, avail):
-##        """
-##        Private slot to handle changes of the availability of closed tabs.
-##        
-##        @param avail flag indicating the availability of closed tabs (boolean)
-##        """
-##        self.__closedTabsButton.setEnabled(avail)
-##        self.__restoreClosedTabAct.setEnabled(avail)
+    def restoreClosedTab(self):
+        """
+        Public slot to restore the most recently closed tab.
+        """
+        if not self.canRestoreClosedTab():
+            return
+        
+        act = self.sender()
+        tab = self.__closedTabsManager.getClosedTabAt(act.data())
+        
+        self.newBrowser(tab.url.toString(), position=tab.position)
+    
+    def canRestoreClosedTab(self):
+        """
+        Public method to check, if closed tabs can be restored.
+        
+        @return flag indicating that closed tabs can be restored (boolean)
+        """
+        return self.__closedTabsManager.isClosedTabAvailable()
+    
+    def restoreAllClosedTabs(self):
+        """
+        Public slot to restore all closed tabs.
+        """
+        if not self.canRestoreClosedTab():
+            return
+        
+        for tab in self.__closedTabsManager.allClosedTabs():
+            self.newBrowser(tab.url.toString(), position=tab.position)
+        self.__closedTabsManager.clearList()
+    
+    def clearClosedTabsList(self):
+        """
+        Public slot to clear the list of closed tabs.
+        """
+        self.__closedTabsManager.clearList()
+    
+    def __aboutToShowClosedTabsMenu(self):
+        """
+        Private slot to populate the closed tabs menu.
+        """
+        fm = self.__closedTabsMenu.fontMetrics()
+        maxWidth = fm.width('m') * 40
+        
+        self.__closedTabsMenu.clear()
+        index = 0
+        for tab in self.__closedTabsManager.allClosedTabs():
+            title = fm.elidedText(tab.title, Qt.ElideRight, maxWidth)
+            self.__closedTabsMenu.addAction(
+                self.__mainWindow.icon(tab.url), title,
+                self.restoreClosedTab).setData(index)
+            index += 1
+        self.__closedTabsMenu.addSeparator()
+        self.__closedTabsMenu.addAction(
+            self.tr("Restore All Closed Tabs"), self.restoreAllClosedTabs)
+        self.__closedTabsMenu.addAction(
+            self.tr("Clear List"), self.clearClosedTabsList)
+    
+    def closedTabsManager(self):
+        """
+        Public slot to get a reference to the closed tabs manager.
+        
+        @return reference to the closed tabs manager (ClosedTabsManager)
+        """
+        return self.__closedTabsManager
+    
+    def __closedTabAvailable(self, avail):
+        """
+        Private slot to handle changes of the availability of closed tabs.
+        
+        @param avail flag indicating the availability of closed tabs (boolean)
+        """
+        self.__closedTabsButton.setEnabled(avail)
+        self.__restoreClosedTabAct.setEnabled(avail)
--- a/WebBrowser/WebBrowserView.py	Sat Feb 13 13:36:01 2016 +0100
+++ b/WebBrowser/WebBrowserView.py	Sat Feb 13 14:17:39 2016 +0100
@@ -1109,14 +1109,41 @@
         """
         Public slot to bookmark the current page.
         """
+        from .Tools import Scripts
+        script = Scripts.getAllMetaAttributes()
+        self.page().runJavaScript(
+            script, self.__addBookmarkCallback)
+    
+    def __addBookmarkCallback(self, res):
+        """
+        Private callback method of __addBookmark().
+        
+        @param url URL for the bookmark
+        @type str
+        @param title title for the bookmark
+        @type str
+        @param res result of the JavaScript
+        @type list
+        """
+        description = ""
+        for meta in res:
+            if meta["name"] == "description":
+                description = meta["content"]
+        
         from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
         dlg = AddBookmarkDialog()
         dlg.setUrl(bytes(self.url().toEncoded()).decode())
         dlg.setTitle(self.title())
-        meta = self.page().mainFrame().metaData()
-        if "description" in meta:
-            dlg.setDescription(meta["description"][0])
+        dlg.setDescription(description)
         dlg.exec_()
+##        from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog
+##        dlg = AddBookmarkDialog()
+##        dlg.setUrl(bytes(self.url().toEncoded()).decode())
+##        dlg.setTitle(self.title())
+##        meta = self.page().mainFrame().metaData()
+##        if "description" in meta:
+##            dlg.setDescription(meta["description"][0])
+##        dlg.exec_()
     
     def dragEnterEvent(self, evt):
         """
--- a/WebBrowser/WebBrowserWindow.py	Sat Feb 13 13:36:01 2016 +0100
+++ b/WebBrowser/WebBrowserWindow.py	Sat Feb 13 14:17:39 2016 +0100
@@ -944,8 +944,6 @@
             self.selectAllAct.triggered.connect(self.__selectAll)
         self.__actions.append(self.selectAllAct)
         
-        # TODO: add more editing actions: Select All
-        
         self.findAct = E5Action(
             self.tr('Find...'),
             UI.PixmapCache.getIcon("find.png"),
@@ -2322,6 +2320,7 @@
         Private slot called to add the displayed file to the bookmarks.
         """
         view = self.currentBrowser()
+        view.addBookmark()
         urlStr = bytes(view.url().toEncoded()).decode()
         title = view.title()
         
--- a/eric6.e4p	Sat Feb 13 13:36:01 2016 +0100
+++ b/eric6.e4p	Sat Feb 13 14:17:39 2016 +0100
@@ -1288,6 +1288,7 @@
     <Source>WebBrowser/Bookmarks/XbelReader.py</Source>
     <Source>WebBrowser/Bookmarks/XbelWriter.py</Source>
     <Source>WebBrowser/Bookmarks/__init__.py</Source>
+    <Source>WebBrowser/ClosedTabsManager.py</Source>
     <Source>WebBrowser/History/HistoryCompleter.py</Source>
     <Source>WebBrowser/History/HistoryDialog.py</Source>
     <Source>WebBrowser/History/HistoryFilterModel.py</Source>
@@ -1309,6 +1310,8 @@
     <Source>WebBrowser/Tools/WebIconLoader.py</Source>
     <Source>WebBrowser/Tools/WebIconProvider.py</Source>
     <Source>WebBrowser/Tools/__init__.py</Source>
+    <Source>WebBrowser/UrlBar/BookmarkActionSelectionDialog.py</Source>
+    <Source>WebBrowser/UrlBar/BookmarkInfoDialog.py</Source>
     <Source>WebBrowser/UrlBar/FavIconLabel.py</Source>
     <Source>WebBrowser/UrlBar/StackedUrlBar.py</Source>
     <Source>WebBrowser/UrlBar/UrlBar.py</Source>
@@ -1727,6 +1730,8 @@
     <Form>WebBrowser/Bookmarks/BookmarksImportDialog.ui</Form>
     <Form>WebBrowser/History/HistoryDialog.ui</Form>
     <Form>WebBrowser/SearchWidget.ui</Form>
+    <Form>WebBrowser/UrlBar/BookmarkActionSelectionDialog.ui</Form>
+    <Form>WebBrowser/UrlBar/BookmarkInfoDialog.ui</Form>
     <Form>WebBrowser/ZoomManager/ZoomValuesDialog.ui</Form>
   </Forms>
   <Translations>

eric ide

mercurial