SF.net SVN: fclient:[772] trunk/fclient/src/fclient
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-27 11:37:49
|
Revision: 772
http://fclient.svn.sourceforge.net/fclient/?rev=772&view=rev
Author: jUrner
Date: 2008-07-27 11:37:58 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
naming
Modified Paths:
--------------
trunk/fclient/src/fclient/fclient.py
trunk/fclient/src/fclient/impl/ViewConnection.py
trunk/fclient/src/fclient/impl/ViewDownloads.py
Added Paths:
-----------
trunk/fclient/src/fclient/impl/ViewLogger.py
Removed Paths:
-------------
trunk/fclient/src/fclient/impl/Ui_ViewLogger.py
Modified: trunk/fclient/src/fclient/fclient.py
===================================================================
--- trunk/fclient/src/fclient/fclient.py 2008-07-27 11:36:07 UTC (rev 771)
+++ trunk/fclient/src/fclient/fclient.py 2008-07-27 11:37:58 UTC (rev 772)
@@ -11,7 +11,7 @@
from .impl.ViewBrowser import ViewBrowserWidget
from .impl.ViewConnection import ViewConnectionWidget
from .impl.ViewDownloads import ViewDownloadsWidget
-from .impl.Ui_ViewLogger import ViewLoggerWidget
+from .impl.ViewLogger import ViewLoggerWidget
#*************************************************************
#
#*************************************************************
Deleted: trunk/fclient/src/fclient/impl/Ui_ViewLogger.py
===================================================================
--- trunk/fclient/src/fclient/impl/Ui_ViewLogger.py 2008-07-27 11:36:07 UTC (rev 771)
+++ trunk/fclient/src/fclient/impl/Ui_ViewLogger.py 2008-07-27 11:37:58 UTC (rev 772)
@@ -1,276 +0,0 @@
-
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-import sys
-import logging
-
-from PyQt4 import QtCore, QtGui
-
-from . import config
-from .lib import fcp2
-
-from .tpls.Ui_ViewLoggerWidgetTpl import Ui_ViewLoggerWidget
-#**********************************************************************************
-#
-#**********************************************************************************
-class Actions(config.ActionsBase):
-
- PrefixVerbosity = 'ActionVerbosity'
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- # for ease of use verbosities are mapped to verbosity actions like this: PrefixVerbosity + Verbosity
- self.action(
- name='ActionLoggerClear',
- text=self.trUtf8('C&lear'),
- trigger=parent.onActionLoggerClear,
- )
-
- groupVerbosity = self.group(
- name='GroupVerbosity',
- trigger=parent.onGroupVerbosityTriggered,
- isExclusive=True,
- )
- self.action(
- name='ActionVerbosityInfo',
- text=self.trUtf8('Info'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Info,
- )
- self.action(
- name='ActionVerbosityMessage',
- text=self.trUtf8('Message'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Message,
- )
- self.action(
- name='ActionVerbosityDebug',
- text=self.trUtf8('Debug'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Debug,
- )
- self.action(
- name='ActionVerbosityChatty',
- text=self.trUtf8('Chatty'),
- group=groupVerbosity,
- trigger=None,
- isCheckable=True,
- userData=fcp2.ConstDebugVerbosity.Chatty,
- )
-
-
-class GlobalFeedback(config.GlobalFeedbackBase):
- """wrapper for global statusbar widgets, menus"""
-
- def __init__(self, parent, idGlobalFeedback):
- config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
-
- # menus
- self.menus = []
- if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
- menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
- parent.populateMenu(menu)
- self.menus.append(menu)
- self.menuBar.addViewMenu(menu)
-
- # status bar widgets
- self.label1 = None
- #if self.statusBar is not None:
- # self.label1 = QtGui.QLabel('foo here', self.statusBar)
-
- def setVisible(self, flag):
- for menu in self.menus:
- menu.children()[0].setVisible(flag)
- if self.label1 is not None:
- self.label1.setVisible(flag)
-
-
-class Settings(config.SettingsBase):
-
- PrefixVerbosityColorFg = 'ColorFgVerbosity'
-
- _key_ = config.IdViewLoggerWidget
- _settings_ = (
- ('MaxLines', 'UInt', 1000, config.SettingScopeUser),
- ('Verbosity', 'PyString', 'Info', config.SettingScopePrivate),
-
- #TODO: Chatty does not seem to work. check in fcp2.client
- ('ColorFgVerbosityCRITICAL', 'QColor', QtGui.QColor('red'), config.SettingScopeUser),
- ('ColorFgVerbosityERROR', 'QColor', QtGui.QColor('red'), config.SettingScopeUser),
- ('ColorFgVerbosityWARNING', 'QColor', QtGui.QColor('red'), config.SettingScopeUser),
- ('ColorFgVerbosityINFO', 'QColor', QtGui.QColor('black'), config.SettingScopeUser),
- ('ColorFgVerbosityMESSAGE', 'QColor', QtGui.QColor('blue'), config.SettingScopeUser),
- ('ColorFgVerbosityDEBUG', 'QColor', QtGui.QColor('slategray'), config.SettingScopeUser),
- ('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray'), config.SettingScopeUser),
- )
-
-
-class LoggerViewObject(config.ViewObject):
-
- def __init__(self, parent):
- config.ViewObject. __init__(self, parent)
-
- self.name=parent.objectName()
- self.displayName=self.trUtf8('Logger')
- self.icon=QtGui.QIcon()
-
-
-#***********************************************************************
-#
-#***********************************************************************
-class MyLoggingHandler(logging.Handler):
-
- def __init__(self, cb, *args, **kwargs):
- logging.Handler.__init__(self, *args, **kwargs)
- self.cb = cb
-
- def emit(self, record):
- self.cb(record)
-
-#***********************************************************************
-#
-#***********************************************************************
-class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget):
-
- IdEdLogger = 'edLogger'
-
-
- def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
- QtGui.QWidget.__init__(self, parent)
- self._isCreated = False
- self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff
-
- self.setupUi(self)
- config.ObjectRegistry.register(self)
-
- self.fcActions = Actions(self)
- self.fcSettings = Settings(self).restore()
- self.fcViewObject = LoggerViewObject(self)
- self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
-
-
- # setup editbox
- #NOTE: do not move to showEvent(). we want to be up and alive as soon as possible to catch logs
- ed = self.controlById(self.IdEdLogger)
- ed.document().setMaximumBlockCount(self.fcSettings.value('MaxLines'))
- ed.contextMenuEvent = self.loggerContextMenuEvent
- self.connect(ed, QtCore.SIGNAL('textChanged()'), self.onLoggerTextChanged)
-
- # setup logger
- self.loggingHandler = MyLoggingHandler(self.addRecord)
- logging.getLogger('').addHandler(self.loggingHandler)
-
- # setup actions
- verbosity = self.fcSettings.value('Verbosity').title()
- action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
- if action is None:
- verbosity = self.fcSettings.restoreDefaults('Verbosity')['Verbosity']
- action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
- if action is None:
- raise ValueError('default verbosity action "%s" not found. WTF?' % self.actions.PrefixVerbosity + verbosity)
- action.trigger()
-
- #########################################
- ## methods
- #########################################
- def addRecord(self, record):
- """adds a logging record"""
-
- ed = self.controlById(self.IdEdLogger)
- fmt = ed.currentCharFormat()
- colorFg = self.fcSettings.value(self.fcSettings.PrefixVerbosityColorFg + record.levelname)
- fmt.setForeground(QtGui.QBrush(colorFg))
- ed.setCurrentCharFormat(fmt)
-
- text = '%s:%s:%s' % (record.levelname, record.name, record.getMessage())
- ed.appendPlainText(text)
-
-
- def controlById(self, idControl):
- return getattr(self, idControl)
-
-
- def populateMenu(self, menu):
- menu.addAction(self.fcActions['ActionLoggerClear'])
- subMenu = menu.addMenu(self.trUtf8('Verbosity'))
- subMenu.addActions(self.fcActions['GroupVerbosity'].actions())
- return menu
-
- #########################################
- ##view methods
- #########################################
- def viewClose(self):
- pass
-
- def viewDisplayName(self):
- return self.trUtf8('Logger')
-
- def viewIcon(self):
- return QtGui.QIcon()
-
- def viewName(self):
- return self.objectName()
-
- #########################################
- ## overwritten events
- #########################################
- def loggerContextMenuEvent(self, event):
- """customize context menu of the logger QTextEdit"""
- ed = self.controlById(self.IdEdLogger)
- menu = ed.createStandardContextMenu()
- self.populateMenu(menu)
- menu.exec_(event.globalPos())
-
-
- def hideEvent(self, event):
- self.fcGlobalFeedback.setVisible(False)
-
-
- def showEvent(self, event):
- self.fcGlobalFeedback.setVisible(True)
- if self._isCreated:
- return
- self._isCreated = True
-
- #########################################
- ## event onrs
- #########################################
- def onActionLoggerClear(self, action):
- self.controlById(self.IdEdLogger).clear()
-
-
- def onGroupVerbosityTriggered(self, action):
- nameVerbosity = action.objectName()[len(self.fcActions.PrefixVerbosity):]
- self.fcSettings.setValues(Verbosity=nameVerbosity)
- logging.getLogger().setLevel(action.userData())
-
-
- def onLoggerTextChanged(self):
- ed = self.controlById(self.IdEdLogger)
- self.fcActions['ActionLoggerClear'].setEnabled(not ed.document().isEmpty())
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
- from . import Ui_ViewLogger
-
- app = QtGui.QApplication(sys.argv)
- w = ViewLoggerWidget(None)
-
- w.show()
- res = app.exec_()
- sys.exit(res)
-
-
-
Modified: trunk/fclient/src/fclient/impl/ViewConnection.py
===================================================================
--- trunk/fclient/src/fclient/impl/ViewConnection.py 2008-07-27 11:36:07 UTC (rev 771)
+++ trunk/fclient/src/fclient/impl/ViewConnection.py 2008-07-27 11:37:58 UTC (rev 772)
@@ -295,7 +295,7 @@
#**********************************************************************************
if __name__ == '__main__':
import sys
- from . import View, Ui_ViewLogger
+ from . import View, ViewLogger
app = QtGui.QApplication(sys.argv)
w = Ui_View.ViewWidget(None)
Modified: trunk/fclient/src/fclient/impl/ViewDownloads.py
===================================================================
--- trunk/fclient/src/fclient/impl/ViewDownloads.py 2008-07-27 11:36:07 UTC (rev 771)
+++ trunk/fclient/src/fclient/impl/ViewDownloads.py 2008-07-27 11:37:58 UTC (rev 772)
@@ -255,7 +255,7 @@
import sys
from . import View
from . import ViewConnection
- from . import Ui_ViewLogger
+ from . import ViewLogger
from . import MainWindow
app = QtGui.QApplication(sys.argv)
@@ -269,7 +269,7 @@
Ui_ViewConnection.ViewConnectionWidget(None),
ViewDownloadsWidget(None),
)
- viewWidget.addBottomViews(Ui_ViewLogger.ViewLoggerWidget(None))
+ viewWidget.addBottomViews(ViewLogger.ViewLoggerWidget(None))
mainWindow.show()
res = app.exec_()
Added: trunk/fclient/src/fclient/impl/ViewLogger.py
===================================================================
--- trunk/fclient/src/fclient/impl/ViewLogger.py (rev 0)
+++ trunk/fclient/src/fclient/impl/ViewLogger.py 2008-07-27 11:37:58 UTC (rev 772)
@@ -0,0 +1,276 @@
+
+from __future__ import absolute_import
+if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
+ import os; __path__ = [os.path.dirname(__file__)]
+
+import sys
+import logging
+
+from PyQt4 import QtCore, QtGui
+
+from . import config
+from .lib import fcp2
+
+from .tpls.Ui_ViewLoggerWidgetTpl import Ui_ViewLoggerWidget
+#**********************************************************************************
+#
+#**********************************************************************************
+class Actions(config.ActionsBase):
+
+ PrefixVerbosity = 'ActionVerbosity'
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ # for ease of use verbosities are mapped to verbosity actions like this: PrefixVerbosity + Verbosity
+ self.action(
+ name='ActionLoggerClear',
+ text=self.trUtf8('C&lear'),
+ trigger=parent.onActionLoggerClear,
+ )
+
+ groupVerbosity = self.group(
+ name='GroupVerbosity',
+ trigger=parent.onGroupVerbosityTriggered,
+ isExclusive=True,
+ )
+ self.action(
+ name='ActionVerbosityInfo',
+ text=self.trUtf8('Info'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Info,
+ )
+ self.action(
+ name='ActionVerbosityMessage',
+ text=self.trUtf8('Message'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Message,
+ )
+ self.action(
+ name='ActionVerbosityDebug',
+ text=self.trUtf8('Debug'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Debug,
+ )
+ self.action(
+ name='ActionVerbosityChatty',
+ text=self.trUtf8('Chatty'),
+ group=groupVerbosity,
+ trigger=None,
+ isCheckable=True,
+ userData=fcp2.ConstDebugVerbosity.Chatty,
+ )
+
+
+class GlobalFeedback(config.GlobalFeedbackBase):
+ """wrapper for global statusbar widgets, menus"""
+
+ def __init__(self, parent, idGlobalFeedback):
+ config.GlobalFeedbackBase.__init__(self, parent, idGlobalFeedback)
+
+ # menus
+ self.menus = []
+ if self.menuBar is not None and hasattr(parent, 'fcViewObject'):
+ menu = QtGui.QMenu(parent.fcViewObject.displayName, self.menuBar)
+ parent.populateMenu(menu)
+ self.menus.append(menu)
+ self.menuBar.addViewMenu(menu)
+
+ # status bar widgets
+ self.label1 = None
+ #if self.statusBar is not None:
+ # self.label1 = QtGui.QLabel('foo here', self.statusBar)
+
+ def setVisible(self, flag):
+ for menu in self.menus:
+ menu.children()[0].setVisible(flag)
+ if self.label1 is not None:
+ self.label1.setVisible(flag)
+
+
+class Settings(config.SettingsBase):
+
+ PrefixVerbosityColorFg = 'ColorFgVerbosity'
+
+ _key_ = config.IdViewLoggerWidget
+ _settings_ = (
+ ('MaxLines', 'UInt', 1000, config.SettingScopeUser),
+ ('Verbosity', 'PyString', 'Info', config.SettingScopePrivate),
+
+ #TODO: Chatty does not seem to work. check in fcp2.client
+ ('ColorFgVerbosityCRITICAL', 'QColor', QtGui.QColor('red'), config.SettingScopeUser),
+ ('ColorFgVerbosityERROR', 'QColor', QtGui.QColor('red'), config.SettingScopeUser),
+ ('ColorFgVerbosityWARNING', 'QColor', QtGui.QColor('red'), config.SettingScopeUser),
+ ('ColorFgVerbosityINFO', 'QColor', QtGui.QColor('black'), config.SettingScopeUser),
+ ('ColorFgVerbosityMESSAGE', 'QColor', QtGui.QColor('blue'), config.SettingScopeUser),
+ ('ColorFgVerbosityDEBUG', 'QColor', QtGui.QColor('slategray'), config.SettingScopeUser),
+ ('ColorFgVerbosityCHATTY', 'QColor', QtGui.QColor('lightslategray'), config.SettingScopeUser),
+ )
+
+
+class LoggerViewObject(config.ViewObject):
+
+ def __init__(self, parent):
+ config.ViewObject. __init__(self, parent)
+
+ self.name=parent.objectName()
+ self.displayName=self.trUtf8('Logger')
+ self.icon=QtGui.QIcon()
+
+
+#***********************************************************************
+#
+#***********************************************************************
+class MyLoggingHandler(logging.Handler):
+
+ def __init__(self, cb, *args, **kwargs):
+ logging.Handler.__init__(self, *args, **kwargs)
+ self.cb = cb
+
+ def emit(self, record):
+ self.cb(record)
+
+#***********************************************************************
+#
+#***********************************************************************
+class ViewLoggerWidget(QtGui.QWidget, Ui_ViewLoggerWidget):
+
+ IdEdLogger = 'edLogger'
+
+
+ def __init__(self, parent, idGlobalFeedback=config.IdMainWindow):
+ QtGui.QWidget.__init__(self, parent)
+ self._isCreated = False
+ self._mainWindowMenus = {} #TODO: wrap along with toolbars to a handy class MainWindowStuff
+
+ self.setupUi(self)
+ config.ObjectRegistry.register(self)
+
+ self.fcActions = Actions(self)
+ self.fcSettings = Settings(self).restore()
+ self.fcViewObject = LoggerViewObject(self)
+ self.fcGlobalFeedback = GlobalFeedback(self, idGlobalFeedback)
+
+
+ # setup editbox
+ #NOTE: do not move to showEvent(). we want to be up and alive as soon as possible to catch logs
+ ed = self.controlById(self.IdEdLogger)
+ ed.document().setMaximumBlockCount(self.fcSettings.value('MaxLines'))
+ ed.contextMenuEvent = self.loggerContextMenuEvent
+ self.connect(ed, QtCore.SIGNAL('textChanged()'), self.onLoggerTextChanged)
+
+ # setup logger
+ self.loggingHandler = MyLoggingHandler(self.addRecord)
+ logging.getLogger('').addHandler(self.loggingHandler)
+
+ # setup actions
+ verbosity = self.fcSettings.value('Verbosity').title()
+ action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
+ if action is None:
+ verbosity = self.fcSettings.restoreDefaults('Verbosity')['Verbosity']
+ action = self.fcActions.get(self.fcActions.PrefixVerbosity + verbosity, None)
+ if action is None:
+ raise ValueError('default verbosity action "%s" not found. WTF?' % self.actions.PrefixVerbosity + verbosity)
+ action.trigger()
+
+ #########################################
+ ## methods
+ #########################################
+ def addRecord(self, record):
+ """adds a logging record"""
+
+ ed = self.controlById(self.IdEdLogger)
+ fmt = ed.currentCharFormat()
+ colorFg = self.fcSettings.value(self.fcSettings.PrefixVerbosityColorFg + record.levelname)
+ fmt.setForeground(QtGui.QBrush(colorFg))
+ ed.setCurrentCharFormat(fmt)
+
+ text = '%s:%s:%s' % (record.levelname, record.name, record.getMessage())
+ ed.appendPlainText(text)
+
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+
+ def populateMenu(self, menu):
+ menu.addAction(self.fcActions['ActionLoggerClear'])
+ subMenu = menu.addMenu(self.trUtf8('Verbosity'))
+ subMenu.addActions(self.fcActions['GroupVerbosity'].actions())
+ return menu
+
+ #########################################
+ ##view methods
+ #########################################
+ def viewClose(self):
+ pass
+
+ def viewDisplayName(self):
+ return self.trUtf8('Logger')
+
+ def viewIcon(self):
+ return QtGui.QIcon()
+
+ def viewName(self):
+ return self.objectName()
+
+ #########################################
+ ## overwritten events
+ #########################################
+ def loggerContextMenuEvent(self, event):
+ """customize context menu of the logger QTextEdit"""
+ ed = self.controlById(self.IdEdLogger)
+ menu = ed.createStandardContextMenu()
+ self.populateMenu(menu)
+ menu.exec_(event.globalPos())
+
+
+ def hideEvent(self, event):
+ self.fcGlobalFeedback.setVisible(False)
+
+
+ def showEvent(self, event):
+ self.fcGlobalFeedback.setVisible(True)
+ if self._isCreated:
+ return
+ self._isCreated = True
+
+ #########################################
+ ## event onrs
+ #########################################
+ def onActionLoggerClear(self, action):
+ self.controlById(self.IdEdLogger).clear()
+
+
+ def onGroupVerbosityTriggered(self, action):
+ nameVerbosity = action.objectName()[len(self.fcActions.PrefixVerbosity):]
+ self.fcSettings.setValues(Verbosity=nameVerbosity)
+ logging.getLogger().setLevel(action.userData())
+
+
+ def onLoggerTextChanged(self):
+ ed = self.controlById(self.IdEdLogger)
+ self.fcActions['ActionLoggerClear'].setEnabled(not ed.document().isEmpty())
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+ from . import Ui_ViewLogger
+
+ app = QtGui.QApplication(sys.argv)
+ w = ViewLoggerWidget(None)
+
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|