SF.net SVN: fclient:[950] trunk/fclient/fclient/impl/ViewBrowser
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-08-22 08:04:31
|
Revision: 950
http://fclient.svn.sourceforge.net/fclient/?rev=950&view=rev
Author: jUrner
Date: 2008-08-22 08:04:41 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
impl browser bookmarks. pages cann be bookmarked now ++ bookmark editor
Modified Paths:
--------------
trunk/fclient/fclient/impl/ViewBrowser/Actions.py
trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py
Modified: trunk/fclient/fclient/impl/ViewBrowser/Actions.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-08-22 08:02:47 UTC (rev 949)
+++ trunk/fclient/fclient/impl/ViewBrowser/Actions.py 2008-08-22 08:04:41 UTC (rev 950)
@@ -186,7 +186,20 @@
isEnabled=True,
trigger=parent.onCloseCurrentSideBar,
)
-
+
+ # bookmarks
+ self.action(
+ name='ActionEditBookmarks',
+ text=self.trUtf8('Edit bookmarks..'),
+ isEnabled=True,
+ trigger=parent.onEditBookmarks,
+ )
+ self.action(
+ name='ActionBookmarkPage',
+ text=self.trUtf8('Bookmark page..'),
+ isEnabled=True,
+ trigger=parent.onBookmarkPage,
+ )
def intertwineBrowserActions(self, browser=None):
"""intertwines Browser actions with BrowserWidget actions
@@ -218,3 +231,16 @@
myPageAction.setUserData((newPageAction, onActionChanged))
myPageAction.connect(newPageAction, QtCore.SIGNAL('changed()'), onActionChanged)
newPageAction.connect(myPageAction, QtCore.SIGNAL('triggered()'), newPageAction.trigger)
+
+#***********************************************************************************
+#
+#***********************************************************************************
+class BookmarkAction(QtGui.QAction):
+
+ def __init__(self, parent, text, target):
+ QtGui.QAction.__init__(self, text, parent)
+ self.target = target
+
+
+
+
Modified: trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py
===================================================================
--- trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-22 08:02:47 UTC (rev 949)
+++ trunk/fclient/fclient/impl/ViewBrowser/ViewBrowser.py 2008-08-22 08:04:41 UTC (rev 950)
@@ -41,7 +41,7 @@
# x. close icon for ActionCloseSideBar
# x. peformance of QWebView sucks when it comes to rendering images
# x. on some pages images are not be loaded (no network error?!) while ff loads them without any problems
-#
+# x. icons for bookmarks
#*******************************************************************************************
#TODO: code
#
@@ -77,6 +77,8 @@
from . import Settings
from .dlgs import DlgPropsBrowserObject
+from .dlgs import DlgBookmarks
+from .dlgs import DlgBookmarkPage
from .Ui_BrowserWidget import Ui_ViewBrowserWidget
#*****************************************************************************************
@@ -109,6 +111,8 @@
QtGui.QWidget.__init__(self, parent)
self.menuSideBars = QtGui.QMenu(self.trUtf8('Side bars')) #TODO: retranslate
+ self.menuBookmarks = QtGui.QMenu(self.trUtf8('Bookmarks')) #TODO: retranslate
+ self.connect(self.menuBookmarks, QtCore.SIGNAL('aboutToShow()'), self.onMenuBookmarksAboutToShow)
self.setupUi(self)
self.isCreated = False
@@ -274,6 +278,12 @@
if isinstance(widget, Browser.Browser):
return widget
+ def currentUrl(self):
+ browser = self.currentBrowser()
+ if browser is not None:
+ lastBrowserState = browser.userData()
+ return lastBrowserState.url
+
def load(self, url, force=False, browser=None):
"""loads an url in the current browser. if there is no current browser, a new browser is created
@param force: (bool) if True, a new browser is opend if there is no browser available
@@ -379,7 +389,10 @@
menu.addAction(self.fcActions['ActionFind'])
menu.addAction(self.fcActions['ActionFindNext'])
menu.addAction(self.fcActions['ActionFindPrevious'])
+ menu.addAction(self.fcActions['ActionEditBookmarks'])
+ menu.addAction(self.fcActions['ActionBookmarkPage'])
+ menu.addMenu(self.menuBookmarks)
menu.addMenu(self.menuSideBars)
return menu
@@ -417,6 +430,20 @@
#########################################
## event handlers
#########################################
+ def onBookmarkPage(self, action):
+ dlg = DlgBookmarkPage.DlgBookmarkPage(self)
+ dlg.show()
+ if dlg.result() == dlg.Accepted:
+ pass
+
+ def onBookmarkTriggered(self):
+ action = self.sender()
+ if self.fcSettings.value('OpenBookmarksInNewTab'):
+ browser = self.newBrowser(self.trUtf8('Loading'))
+ self.load(action.target, browser=browser)
+ else:
+ self.load(action.target, force=True)
+
#TODO: actions need some comb over
def onBrowserCustomContextMenuRequested(self, pt):
browser = self.sender()
@@ -604,6 +631,12 @@
self.fcActions['ActionFindNext'].setEnabled(bool(text))
self.fcActions['ActionFindPrevious'].setEnabled(bool(text))
+ def onEditBookmarks(self, action):
+ dlg = DlgBookmarks.DlgBookmarks(self)
+ dlg.show()
+ if dlg.result() == dlg.Accepted:
+ pass
+
def onFind(self, action):
frameFind = self.controlById(self.IdFrameFind)
ed = self.controlById(self.IdEdFind)
@@ -651,6 +684,27 @@
qUrl = QtCore.QUrl(home)
self.load(qUrl, force=True)
+ #TODO: how to know if we have bookmarks?
+ def onMenuBookmarksAboutToShow(self):
+ self.menuBookmarks.clear()
+ stack = [self.menuBookmarks, ]
+ try:
+ for event, params in DlgBookmarks.DlgBookmarks.walkBookmarks(DlgBookmarks.BookmarksFile):
+ if event == 'beginfolder':
+ menu = QtGui.QMenu(params['name'], stack[-1])
+ stack[-1].addMenu(menu)
+ stack.append(menu)
+ elif event == 'endfolder':
+ stack.pop()
+ elif event == 'bookmark':
+ action = Actions.BookmarkAction(stack[-1], params['name'], params['target'])
+ stack[-1].addAction(action)
+ self.connect(action, QtCore.SIGNAL('triggered()'), self.onBookmarkTriggered)
+ except SyntaxError:
+ pass
+ except IOError:
+ pass
+
def onNavBarReturnPressed(self):
text = self.controlById(self.IdEdAddressBar).text()
if text.isEmpty():
@@ -683,6 +737,7 @@
if browser is not None and act is browser.pageAction(browser.page().Back):
self._adjustBackIsClose()
+ #TODO: not yet implemented
def onSavePage(self, action):
# we have to cheat a bit here and reload the page to make shure the page has
# all QNetWorkReplies present
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|