SF.net SVN: fclient:[665] trunk/fclient/src/fclient/Ui_View.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-18 02:57:12
|
Revision: 665
http://fclient.svn.sourceforge.net/fclient/?rev=665&view=rev
Author: jUrner
Date: 2008-07-18 02:57:21 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
View itsself is a view ++ action to show / hide top tabs
Modified Paths:
--------------
trunk/fclient/src/fclient/Ui_View.py
Modified: trunk/fclient/src/fclient/Ui_View.py
===================================================================
--- trunk/fclient/src/fclient/Ui_View.py 2008-07-18 02:53:20 UTC (rev 664)
+++ trunk/fclient/src/fclient/Ui_View.py 2008-07-18 02:57:21 UTC (rev 665)
@@ -21,14 +21,61 @@
#**********************************************************************************
#
#**********************************************************************************
+class Actions(config.ActionsBase):
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ self.action(
+ name='ActionShowTopTabBar',
+ text=self.trUtf8('Show top &tabs'),
+ trigger=parent.onActionShowTabsTop,
+ isCheckable=True,
+ isChecked=True,
+ )
+
+
+class GlobalFeedback(config.GlobalFeedbackBase):
+ """wrapper for global statusbar widgets, menus"""
+
+ def __init__(self, parent, idFeedbackParent):
+ config.GlobalFeedbackBase.__init__(self, parent, idFeedbackParent)
+
+ print self.menuBar
+ # menus
+ self.menus = []
+ if self.menuBar is not None:
+ menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
+ parent.populateMenu(menu)
+ self.menus.append(menu)
+ self.menuBar.addViewMenu(menu)
+
+ def setVisible(self, flag):
+ for menu in self.menus:
+ menu.children()[0].setVisible(flag)
+
+
+
class Settings(config.SettingsBase):
_key_ = config.IdViewWidget
_settings_ = (
('LastViewTop', 'String', '', config.SettingScopePrivate),
('LastViewBottom', 'String', '', config.SettingScopePrivate),
('SplitterPos', 'ByteArray', QtCore.QByteArray(), config.SettingScopePrivate),
+ ('ShowTopTabBar', 'Bool', True, config.SettingScopePrivate),
+
)
+
+class ViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('View')
+ self.icon=QtGui.QIcon()
+
#***********************************************************************
#
#***********************************************************************
@@ -39,7 +86,7 @@
IdTabBottom = 'tabBottom'
- def __init__(self, parent):
+ def __init__(self, parent, idFeedbackParent=config.IdMainWindow):
QtGui.QWidget.__init__(self, parent)
self._isCreated = False
@@ -48,18 +95,27 @@
self.setupUi(self)
config.ObjectRegistry.register(self)
- self.fclientSettings = Settings().restore()
+ self.fcActions = Actions(self)
+ self.fcSettings = Settings().restore()
+ self.fcViewObject = ViewObject(self)
+ self.fcGlobalFeedback = GlobalFeedback(self, idFeedbackParent)
# setup tab widgets
- tabTop = self.controlById(self.IdTabTop)
- tabTop.removeTab(0)
- tabBottom = self.controlById(self.IdTabBottom)
- tabBottom.removeTab(0)
+ tabWidgetTop = self.controlById(self.IdTabTop)
+ tabWidgetTop.removeTab(0)
+ tabWidgetBottom = self.controlById(self.IdTabBottom)
+ tabWidgetBottom.removeTab(0)
# setup splitter
splitter = self.controlById(self.IdSplitter)
- splitter.restoreState(self.fclientSettings.value('SplitterPos'))
- self.connect(splitter, QtCore.SIGNAL('splitterMoved(int, int)'), self.handleSplitterMoved)
+ splitter.restoreState(self.fcSettings.value('SplitterPos'))
+ self.connect(splitter, QtCore.SIGNAL('splitterMoved(int, int)'), self.onSplitterMoved)
+
+ # setup actions
+ showTopTabBar = self.fcSettings.value('ShowTopTabBar')
+ self.fcActions['ActionShowTopTabBar'].setChecked(showTopTabBar)
+ tabWidgetTop.tabBar().setVisible(showTopTabBar)
+
def controlById(self, idControl):
@@ -67,18 +123,18 @@
def _addViews(self, toTop, *views):
- tab = self.controlById(self.IdTabTop) if toTop else self.controlById(self.IdTabBottom)
+ tabWidget = self.controlById(self.IdTabTop) if toTop else self.controlById(self.IdTabBottom)
for view in views:
name = view.fcViewObject.name
if not name:
raise ValueError('view must have a name')
if name in self.views:
raise ValueError('view with that name is already present: %s' % name)
- view.setParent(tab)
- i = tab.addTab(view, view.fcViewObject.icon, view.fcViewObject.displayName)
- self.views[name] = (tab, view)
+ view.setParent(tabWidget)
+ i = tabWidget.addTab(view, view.fcViewObject.icon, view.fcViewObject.displayName)
+ self.views[name] = (tabWidget, view)
- tab.tabBar().setVisible(tab.count() > 1)
+ #tab.tabBar().setVisible(tab.count() > 1)
def addBottomViews(self, *views):
@@ -89,13 +145,12 @@
return self._addViews(True, *views)
- def viewFromName(self, name):
- result = self.views.get(name, None)
- if result is not None:
- return result[1]
- return None
-
+ def populateMenu(self, menu):
+ menu.addAction(self.fcActions['ActionShowTopTabBar'])
+ return menu
+
+
def setCurrentView(self, name):
result = self.views.get(name, None)
if result is not None:
@@ -103,6 +158,24 @@
tab.setCurrentWidget(view)
return True
return False
+
+
+ def viewFromName(self, name):
+ result = self.views.get(name, None)
+ if result is not None:
+ return result[1]
+ return None
+
+ #########################################################
+ ##
+ #########################################################
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+
#########################################################
##
@@ -118,36 +191,42 @@
self._isCreated = True
# restore current views
- tabTop = self.controlById(self.IdTabTop)
- lastName = self.fclientSettings.value('LastViewTop')
+ tabWidgetTop = self.controlById(self.IdTabTop)
+ lastName = self.fcSettings.value('LastViewTop')
self.setCurrentView(lastName)
- tabBottom = self.controlById(self.IdTabBottom)
- lastName = self.fclientSettings.value('LastViewBottom')
+ tabWidgetBottom = self.controlById(self.IdTabBottom)
+ lastName = self.fcSettings.value('LastViewBottom')
self.setCurrentView(lastName)
# finally connect... not to overwrite settings
- self.connect(tabTop, QtCore.SIGNAL('currentChanged(int)'), self.handleTabTopCurrentChanged)
- self.connect(tabBottom, QtCore.SIGNAL('currentChanged(int)'), self.handleTabBottomCurrentChanged)
+ self.connect(tabWidgetTop, QtCore.SIGNAL('currentChanged(int)'), self.onTabTopCurrentChanged)
+ self.connect(tabWidgetBottom, QtCore.SIGNAL('currentChanged(int)'), self.onTabBottomCurrentChanged)
#########################################################
##
#########################################################
- def handleSplitterMoved(self, pos, index):
+ def onActionShowTabsTop(self, action):
+ tabWidgetTop = self.controlById(self.IdTabTop)
+ tabWidgetTop.tabBar().setVisible(action.isChecked())
+ self.fcSettings.setValues(ShowTopTabBar=action.isChecked())
+
+
+ def onSplitterMoved(self, pos, index):
splitter = self.controlById(self.IdSplitter)
- self.fclientSettings.setValues(SplitterPos=splitter.saveState())
+ self.fcSettings.setValues(SplitterPos=splitter.saveState())
- def handleTabTopCurrentChanged(self, index):
- tab = self.controlById(self.IdTabTop)
- view = tab.currentWidget()
- self.fclientSettings.setValues(LastViewTop=view.fcViewObject.name)
+ def onTabTopCurrentChanged(self, index):
+ tabWidget = self.controlById(self.IdTabTop)
+ view = tabWidget.currentWidget()
+ self.fcSettings.setValues(LastViewTop=view.fcViewObject.name)
- def handleTabBottomCurrentChanged(self, index):
+ def onTabBottomCurrentChanged(self, index):
tab = self.controlById(self.IdTabBottom)
view = tab.currentWidget()
- self.fclientSettings.setValues(LastViewBottom=view.fcViewObject.name)
+ self.fcSettings.setValues(LastViewBottom=view.fcViewObject.name)
#**********************************************************************************
#
@@ -155,7 +234,7 @@
#NOTE: to self. no need to register views to config.ObjectRegistry. they are just
# opaque objects private to ViewWidget
class View(object):
- """base class for views handled by L{ViewWidget}"""
+ """base class for views ond by L{ViewWidget}"""
def __init__(self):
raise NotImplemetedError()
@@ -181,19 +260,7 @@
@return: (str) id
"""
raise NotImplemetedError()
-
-class ViewObject(QtCore.QObject):
- """base class for view objects"""
-
- def __init__(self, parent):
- QtCore.QObject.__init__(self, parent)
-
- self.name = '' #unique name of the view
- self.displayName = '' # name as shown t the user
- self.icon = None # QIcon associated to the view
-
-
#**********************************************************************************
#
#**********************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|