SF.net SVN: fclient:[815] trunk/fclient/src/fclient/impl/ViewBrowser.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-29 11:42:50
|
Revision: 815
http://fclient.svn.sourceforge.net/fclient/?rev=815&view=rev
Author: jUrner
Date: 2008-07-29 11:42:59 +0000 (Tue, 29 Jul 2008)
Log Message:
-----------
combed over find box
Modified Paths:
--------------
trunk/fclient/src/fclient/impl/ViewBrowser.py
Modified: trunk/fclient/src/fclient/impl/ViewBrowser.py
===================================================================
--- trunk/fclient/src/fclient/impl/ViewBrowser.py 2008-07-29 11:41:57 UTC (rev 814)
+++ trunk/fclient/src/fclient/impl/ViewBrowser.py 2008-07-29 11:42:59 UTC (rev 815)
@@ -25,6 +25,9 @@
# x. user staring gui for first time. maybe we should not connext untill the user connects explicitely
# x. looks like on error loading page reload does not work
# x. when loading a page, until fproxy reacts reload is enabled instead of stop. hitting reloading will trigger an error
+# x. icons on find bar push button text tio the side. no idea
+# x. on find action, give feedback when no matching text was found on page
+# some shortcuts for actions are still missing
#******************************************************************************************
"""
@@ -193,7 +196,7 @@
def setVisible(self, flag):
if self.menuBar is not None:
for menu in self.menus:
- menu.children()[0].setVisible(flag)
+ menu.children()[0].setEnabled(flag)
if self.statusBar is not None:
self.progress.setVisible(flag)
self.labelStatus.setVisible(flag)
@@ -266,11 +269,13 @@
iconSize = parent.fcSettings.value('IconSize')
iconTheme = parent.fcSettings.value('IconTheme')
+ #TODO: shortcut
self.action(
name='ActionCloseCurrentTab',
text=self.trUtf8('Close ¤t tab'),
trigger=parent.onCloseCurrentTab,
)
+ #TODO: shortcut
self.action( # context menu only
name='ActionCloseBrowserUnderMouse',
text=self.trUtf8('&Close tab'),
@@ -281,11 +286,13 @@
text=self.trUtf8('Close &all tabs'),
trigger=parent.onCloseAllTabs,
)
+ #TODO: shortcut
self.action(
name='ActionOpenNewTab',
text=self.trUtf8('Open &new tab'),
trigger=parent.onOpenNewTab,
)
+ #TODO: shortcut
self.action(
name='ActionGoToFProxy',
text=self.trUtf8('Go to f&Proxy homepage'),
@@ -294,8 +301,10 @@
self.action(
name='ActionGoToHomePage',
text=self.trUtf8('Go to &homepage'),
+ shortcut=QtGui.QKeySequence(self.trUtf8('Alt+Home')),
trigger=parent.onGoToHomePage,
)
+ #TODO: shortcut
self.action(
name='ActionObjectProperties',
text=self.trUtf8('Properties..'),
@@ -304,11 +313,13 @@
self.action(
name='ActionZoomIn',
text=self.trUtf8('Zoom in'),
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.ZoomIn),
trigger=parent.onZoomIn,
)
self.action(
name='ActionZoomOut',
text=self.trUtf8('Zoom out'),
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.ZoomOut),
trigger=parent.onZoomOut,
)
@@ -318,6 +329,7 @@
text=self.trUtf8('Back'),
trigger=None,
isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Back),
icon=config.fcResources.getIcon('back', iconSize, iconTheme=iconTheme),
userData=(None, None),
)
@@ -326,6 +338,7 @@
text=self.trUtf8('Forward'),
trigger=None,
isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Forward),
icon=config.fcResources.getIcon('forward', iconSize, iconTheme=iconTheme),
userData=(None, None),
)
@@ -334,6 +347,7 @@
text=self.trUtf8('Reload'),
trigger=None,
isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Refresh),
icon=config.fcResources.getIcon('reload_page', iconSize, iconTheme=iconTheme),
userData=(None, None),
)
@@ -342,10 +356,10 @@
text=self.trUtf8('Stop'),
trigger=None,
isEnabled=False,
+ shortcut=QtGui.QKeySequence(self.trUtf8('Esc')),
icon=config.fcResources.getIcon('stop', iconSize, iconTheme=iconTheme),
userData=(None, None),
)
-
self.action(
name='ActionBackIsClose',
text=self.trUtf8('Back is close'),
@@ -353,15 +367,30 @@
trigger=None,
)
- # search actions
+ # find actions
self.action(
- parent=parent,
- name='ActionSearch',
- text=self.trUtf8('Search'),
- shortcut=QtGui.QKeySequence(self.trUtf8('Ctrl+F')),
- trigger=parent.onSearch,
+ name='ActionFind',
+ text=self.trUtf8('Find'),
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Find),
+ trigger=parent.onFind,
)
+ self.action(
+ name='ActionFindNext',
+ text=self.trUtf8('Find next'),
+ isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindNext),
+ trigger=parent.onFindNext,
+ )
+ self.action(
+ name='ActionFindPrevious',
+ text=self.trUtf8('Find previous'),
+ isEnabled=False,
+ shortcut=QtGui.QKeySequence(QtGui.QKeySequence.FindPrevious),
+ trigger=parent.onFindPrevious,
+ )
+
+
def intertwineBrowserActions(self, browser=None):
"""intertwines Browser actions with BrowserWidget actions
@note: call everytime the current browser changes
@@ -428,11 +457,11 @@
IdBtReload = 'btReload'
IdBtStop = 'btStop'
- IdFrameSearch = 'frameSearch'
- IdEdSearch = 'edSearch'
- IdBtSearchUpwards = 'btSearchUpwards'
- IdBtSearchDownwards = 'btSearchDownwards'
- IdCkSearchCaseSensitive = 'ckSearchCaseSensitive'
+ IdFrameFind = 'frameFind'
+ IdEdFind = 'edFind'
+ IdBtFindPrevious = 'btFindPrevious'
+ IdBtFindNext= 'btFindNext'
+ IdCkFindCaseSensitive = 'ckFindCaseSensitive'
ForcedMinBrowserTabText = 5 # forced minimum number of chars on browser tabBar
@@ -450,6 +479,10 @@
self.fcViewObject = BrowserWidgetViewObject(self)
self.fcGlobalFeedback = BrowserWidgetGlobalFeedback(self, idGlobalFeedback)
+ # setup
+ iconSize = self.fcSettings.value('IconSize')
+ iconTheme = self.fcSettings.value('IconTheme')
+
# setup tab bar
tabWidget = self.controlById(self.IdTabBrowsers)
tabWidget.clear()
@@ -468,14 +501,17 @@
self.controlById(self.IdBtStop).setDefaultAction(self.fcActions['ActionStop'])
# setupp search bar
- bt = self.controlById(self.IdBtSearchUpwards)
- self.connect(bt, QtCore.SIGNAL('clicked()'), self.onSearchUpwards)
- bt = self.controlById(self.IdBtSearchDownwards)
- self.connect(bt, QtCore.SIGNAL('clicked()'), self.onSearchDownwards)
- ed = self.controlById(self.IdEdSearch)
- self.connect(ed, QtCore.SIGNAL('returnPressed()'), self.onSearchDownwards)
- frameSearch = self.controlById(self.IdFrameSearch)
- frameSearch.setVisible(False)
+ bt = self.controlById(self.IdBtFindPrevious)
+ self.connect(bt, QtCore.SIGNAL('clicked()'), self.fcActions['ActionFindPrevious'].trigger)
+ bt.setIcon(config.fcResources.getIcon('arrow_up',iconSize, iconTheme=iconTheme))
+ bt = self.controlById(self.IdBtFindNext)
+ bt.setIcon(config.fcResources.getIcon('arrow_down', iconSize, iconTheme=iconTheme))
+ self.connect(bt, QtCore.SIGNAL('clicked()'), self.fcActions['ActionFindNext'].trigger)
+ ed = self.controlById(self.IdEdFind)
+ self.connect(ed, QtCore.SIGNAL('returnPressed()'), self.fcActions['ActionFindNext'].trigger)
+ self.connect(ed, QtCore.SIGNAL('textChanged(const QString &)'), self.onEdFindTextChanged)
+ frameFind = self.controlById(self.IdFrameFind)
+ frameFind.setVisible(False)
#########################################
## private methods
@@ -661,6 +697,10 @@
#TODO: rework. we need more then one menu
def populateMenu(self, menu):
+ menu.addAction(self.fcActions['ActionBack'])
+ menu.addAction(self.fcActions['ActionForward'])
+ menu.addAction(self.fcActions['ActionReload'])
+ menu.addAction(self.fcActions['ActionStop'])
menu.addAction(self.fcActions['ActionGoToFProxy'])
menu.addAction(self.fcActions['ActionGoToHomePage'])
menu.addAction(self.fcActions['ActionCloseCurrentTab'])
@@ -668,7 +708,9 @@
menu.addAction(self.fcActions['ActionOpenNewTab'])
menu.addAction(self.fcActions['ActionZoomIn'])
menu.addAction(self.fcActions['ActionZoomOut'])
- menu.addAction(self.fcActions['ActionSearch'])
+ menu.addAction(self.fcActions['ActionFind'])
+ menu.addAction(self.fcActions['ActionFindNext'])
+ menu.addAction(self.fcActions['ActionFindPrevious'])
return menu
#########################################
@@ -869,6 +911,11 @@
tabWidget.removeTab(i)
self.fcActions.intertwineBrowserActions(self.currentBrowser())
+ def onEdFindTextChanged(self, text):
+ self.fcActions['ActionFindNext'].setEnabled(bool(text))
+ self.fcActions['ActionFindPrevious'].setEnabled(bool(text))
+
+
#TODO: open in new tab option?
def onGoToFProxy(self, action):
url = QtCore.QUrl()
@@ -907,27 +954,37 @@
if browser is not None and act is browser.pageAction(browser.page().Back):
self._adjustBackIsClose()
- def onSearch(self, action):
- frameSearch = self.controlById(self.IdFrameSearch)
- frameSearch.setVisible(not frameSearch.isVisible())
+ def onFind(self, action):
+ frameFind = self.controlById(self.IdFrameFind)
+ ed = self.controlById(self.IdEdFind)
+ #ed.setText('fooBar')
- def onSearchDownwards(self):
+ frameFind.setVisible(not frameFind.isVisible())
+ #self.fcActions['ActionFindNext'].setEnabled()
+ #self.fcActions['ActionFindPrevious'].setEnabled()
+ if frameFind.isVisible():
+ ed.setFocus(QtCore.Qt.OtherFocusReason)
+ ed.selectAll()
+
+ #TODO: give feedback when no matching text was found
+ def onFindNext(self):
browser = self.currentBrowser()
if browser is not None:
page = browser.page()
- ed = self.controlById(self.IdEdSearch)
- ck = self.controlById(self.IdCkSearchCaseSensitive)
+ ed = self.controlById(self.IdEdFind)
+ ck = self.controlById(self.IdCkFindCaseSensitive)
flags = page.FindWrapsAroundDocument
if ck.checkState() == QtCore.Qt.Checked:
flags |= page.FindCaseSensitively
- browser.findText(ed.text(), flags)
+ if not browser.findText(ed.text(), flags):
+ pass
- def onSearchUpwards(self):
+ def onFindPrevious(self):
browser = self.currentBrowser()
if browser is not None:
page = browser.page()
- ed = self.controlById(self.IdEdSearch)
- ck = self.controlById(self.IdCkSearchCaseSensitive)
+ ed = self.controlById(self.IdEdFind)
+ ck = self.controlById(self.IdCkFindCaseSensitive)
flags = page.FindWrapsAroundDocument | page.FindBackward
if ck.checkState() == QtCore.Qt.Checked:
flags |= page.FindCaseSensitively
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|