Thread: SF.net SVN: fclient: [565] trunk/fclient/src/fclient/config.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-07-08 16:49:04
|
Revision: 565 http://fclient.svn.sourceforge.net/fclient/?rev=565&view=rev Author: jUrner Date: 2008-07-08 09:47:26 -0700 (Tue, 08 Jul 2008) Log Message: ----------- experimental ..add a global object registry Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-08 15:58:43 UTC (rev 564) +++ trunk/fclient/src/fclient/config.py 2008-07-08 16:47:26 UTC (rev 565) @@ -5,6 +5,7 @@ import atexit import os +import weakref from PyQt4 import QtCore from .lib import fcp2 @@ -16,7 +17,37 @@ FclientAppName = 'fclient' SettingsDir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings') + #********************************************************************************** +# looks like QObject.findChild() does not always work. docs mention troubles +# with MSVC 6 where you should use qFindChild(). can not test this. so keep +# a dict for lookups... +#********************************************************************************** +IdViewWidget = 'ViewWidget' +IdViewLoggerWidget = 'ViewLoggerWidget' +IdViewConnectionWidget = 'ViewConnectionWidget' + + +class ObjectRegistry(weakref.WeakValueDictionary): + """global object registry + + use the registry to register and retrieve ui objects previously registerd by their object ids (Id*). + ObjectRegistry is actually a WeakValueDictionary. so use as a dict + """ + + def register(self, obj): + """regisdters an object in the registry + @param obj: (QObject) object to register + @note: QObject.objectName() is taken as id. ids have to be unique throughout the runtime of the gui + """ + ido = str(obj.objectName()) + if ido in self: + raise ValueError('ui object already registered: %s' % ido) + self[ido] = obj + + +ObjectRegistry = ObjectRegistry() +#********************************************************************************** # #********************************************************************************** class ConfigSettings(settingsbase.SettingsBase): @@ -67,8 +98,12 @@ #********************************************************************************** class Config(object): + _UiObjRegistry = weakref.WeakValueDictionary() + + def __init__(self, parent): - + + self.fcpClient = fcp2.Client() # global fcp client self.settings = Settings() # global settings class self.configSettings = ConfigSettings() # settings of the config @@ -79,15 +114,12 @@ atexit.register(self.close) - def close(self): self.settings.dumpSettings(None, self.configSettings) - +#********************************************************************************** +# +#********************************************************************************** + - -s = Config(None) - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-08 16:53:28
|
Revision: 567 http://fclient.svn.sourceforge.net/fclient/?rev=567&view=rev Author: jUrner Date: 2008-07-08 09:52:34 -0700 (Tue, 08 Jul 2008) Log Message: ----------- clean up Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-08 16:49:12 UTC (rev 566) +++ trunk/fclient/src/fclient/config.py 2008-07-08 16:52:34 UTC (rev 567) @@ -1,4 +1,5 @@ -"""""" +"""global application config +""" 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__)] @@ -17,7 +18,6 @@ FclientAppName = 'fclient' SettingsDir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings') - #********************************************************************************** # looks like QObject.findChild() does not always work. docs mention troubles # with MSVC 6 where you should use qFindChild(). can not test this. so keep @@ -98,17 +98,13 @@ #********************************************************************************** class Config(object): - _UiObjRegistry = weakref.WeakValueDictionary() - - def __init__(self, parent): - - + self.fcpClient = fcp2.Client() # global fcp client self.settings = Settings() # global settings class self.configSettings = ConfigSettings() # settings of the config + - self.settings.readSettings(None, self.configSettings) self.settings.setStoreLocal(directory=self.configSettings['StoreSettingsLocally']) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 16:32:32
|
Revision: 571 http://fclient.svn.sourceforge.net/fclient/?rev=571&view=rev Author: jUrner Date: 2008-07-11 09:32:39 -0700 (Fri, 11 Jul 2008) Log Message: ----------- too many changes to list Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-09 08:39:05 UTC (rev 570) +++ trunk/fclient/src/fclient/config.py 2008-07-11 16:32:39 UTC (rev 571) @@ -10,7 +10,7 @@ from PyQt4 import QtCore from .lib import fcp2 -from .lib.qt4ex import settingsbase +from .lib.qt4ex import settings #********************************************************************************** # #********************************************************************************** @@ -50,69 +50,42 @@ #********************************************************************************** # #********************************************************************************** -class ConfigSettings(settingsbase.SettingsBase): +class SettingsBase(settings.SettingsBase): + """application wide base class for settings""" - KEY_SETTINGS = 'ConfigSettings' - SETTINGS = [ - ('StoreSettingsLocally', ['UPyString', SettingsDir]), # if not None, settings are stored locally in the app folder - ] - - - -class Settings(settingsbase.Settings): - """customized settings class to allow to store settings locally""" + _config_settings_ = None - def __init__(self): - settingsbase.Settings.__init__(self, FclientOrgName, FclientAppName) - self.format = QtCore.QSettings.IniFormat - self.scope = QtCore.QSettings.UserScope - self.directory = None - - self.setStoreLocal(SettingsDir) - - - def setStoreLocal(self, directory=None): - """should the settings be stored locally? - - @param directory: (str) if None, the default location of the os is used to store settings, if a directory - setings are stored there - """ - if directory is None: - self.format = QtCore.QSettings.NativeFormat - self.scope = QtCore.QSettings.UserScope + #TODO: we have to notify all instances on changes. yuk + def settingsObject(self): + settingsDir = self._config_settings_.value('SettingsDir') + if settingsDir: + format = QtCore.QSettings.IniFormat + scope = QtCore.QSettings.UserScope + QtCore.QSettings.setPath(format, scope, settingsDir) else: - self.format = QtCore.QSettings.IniFormat - self.scope = QtCore.QSettings.UserScope - QtCore.QSettings.setPath(self.format, self.scope, directory) - self.directory = directory - - - def getObject(self, parent): - o = QtCore.QSettings(self.format, self.scope, self.orgName, self.appName, parent) - o.setFallbacksEnabled(False) - #print o.fileName() - return o + format = QtCore.QSettings.NativeFormat + scope = QtCore.QSettings.SystemScope + if self._config_settings_.value('SettingsAllUsers'): + scope = QtCore.QSettings.UserScope + settings = QtCore.QSettings(format, scope, FclientOrgName, FclientAppName, self.parent()) + settings.setFallbacksEnabled(False) + return settings + +class Settings(SettingsBase): + _key_ = 'ConfigSettings' + _settings_ = ( + ('SettingsDir', 'String', QtCore.QString(SettingsDir)), # if not None, settings are stored locally in the app folder + ('SettingsAllUsers', 'Bool', False), # store settings for all users? + ) + +SettingsBase._config_settings_ = Settings() #********************************************************************************** # #********************************************************************************** -class Config(object): - - def __init__(self, parent): - - self.fcpClient = fcp2.Client() # global fcp client - self.settings = Settings() # global settings class - self.configSettings = ConfigSettings() # settings of the config - - - self.settings.readSettings(None, self.configSettings) - self.settings.setStoreLocal(directory=self.configSettings['StoreSettingsLocally']) - - atexit.register(self.close) - - def close(self): - self.settings.dumpSettings(None, self.configSettings) - +fcpClient = fcp2.Client() # global fcp client +settings = Settings(None) # global settings class + #********************************************************************************** # #********************************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-11 19:36:30
|
Revision: 580 http://fclient.svn.sourceforge.net/fclient/?rev=580&view=rev Author: jUrner Date: 2008-07-11 12:36:40 -0700 (Fri, 11 Jul 2008) Log Message: ----------- hello node. can't hear you Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-11 16:37:09 UTC (rev 579) +++ trunk/fclient/src/fclient/config.py 2008-07-11 19:36:40 UTC (rev 580) @@ -83,7 +83,7 @@ #********************************************************************************** # #********************************************************************************** -fcpClient = fcp2.Client() # global fcp client +fcpClient = fcp2.Client(debugVerbosity=fcp2.ConstDebugVerbosity.Debug) # global fcp client settings = Settings(None) # global settings class #********************************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-12 11:06:48
|
Revision: 583 http://fclient.svn.sourceforge.net/fclient/?rev=583&view=rev Author: jUrner Date: 2008-07-12 04:06:56 -0700 (Sat, 12 Jul 2008) Log Message: ----------- added scope consts for settings Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-11 19:42:24 UTC (rev 582) +++ trunk/fclient/src/fclient/config.py 2008-07-12 11:06:56 UTC (rev 583) @@ -50,11 +50,17 @@ #********************************************************************************** # #********************************************************************************** +SettingScopeExpert = 0x1 +SettingScopePrivate = 0x2 +SettingScopeUser = 0x4 +SettingSkopeMask = SettingScopeExpert | SettingScopePrivate | SettingScopeUser + class SettingsBase(settings.SettingsBase): """application wide base class for settings""" _config_settings_ = None + #TODO: we have to notify all instances on changes. yuk def settingsObject(self): settingsDir = self._config_settings_.value('SettingsDir') @@ -75,8 +81,8 @@ class Settings(SettingsBase): _key_ = 'ConfigSettings' _settings_ = ( - ('SettingsDir', 'String', QtCore.QString(SettingsDir)), # if not None, settings are stored locally in the app folder - ('SettingsAllUsers', 'Bool', False), # store settings for all users? + ('SettingsDir', 'String', QtCore.QString(SettingsDir), SettingScopeUser), # if not None, settings are stored locally in the app folder + ('SettingsAllUsers', 'Bool', False, SettingScopeUser), # store settings for all users? ) SettingsBase._config_settings_ = Settings() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-12 19:58:10
|
Revision: 598 http://fclient.svn.sourceforge.net/fclient/?rev=598&view=rev Author: jUrner Date: 2008-07-12 12:58:19 -0700 (Sat, 12 Jul 2008) Log Message: ----------- new ids Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-12 19:57:57 UTC (rev 597) +++ trunk/fclient/src/fclient/config.py 2008-07-12 19:58:19 UTC (rev 598) @@ -23,6 +23,9 @@ # with MSVC 6 where you should use qFindChild(). can not test this. so keep # a dict for lookups... #********************************************************************************** +IdMainWindow = 'MainWindow' +IdMainWindowMenuBar = 'MainWindowMenuBar' +IdMainWindowStatusBar = 'MainWindowStatusBar' IdViewWidget = 'ViewWidget' IdViewLoggerWidget = 'ViewLoggerWidget' IdViewConnectionWidget = 'ViewConnectionWidget' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-13 14:07:23
|
Revision: 606 http://fclient.svn.sourceforge.net/fclient/?rev=606&view=rev Author: jUrner Date: 2008-07-13 07:07:33 -0700 (Sun, 13 Jul 2008) Log Message: ----------- add basic browser view impl Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-13 14:07:23 UTC (rev 605) +++ trunk/fclient/src/fclient/config.py 2008-07-13 14:07:33 UTC (rev 606) @@ -10,12 +10,17 @@ from PyQt4 import QtCore from .lib import fcp2 -from .lib.qt4ex import settings +from .lib.qt4ex.lib import settings #********************************************************************************** # #********************************************************************************** FclientOrgName = 'fclient' FclientAppName = 'fclient' +FclientVersion = '0.1.0' +FclientAuthor = 'Juergen Urner' +FclientLicence = 'MIT' +FclientCopyright = '(c) 2008 Juergen Urner' +FclientHomepage = 'http://fclient.sourceforge.net/' SettingsDir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings') #********************************************************************************** @@ -24,11 +29,12 @@ # a dict for lookups... #********************************************************************************** IdMainWindow = 'MainWindow' -IdMainWindowMenuBar = 'MainWindowMenuBar' +IdMainWindowMenuBarWrap = 'MainWindowMenuBarWrap' IdMainWindowStatusBar = 'MainWindowStatusBar' IdViewWidget = 'ViewWidget' +IdViewBrowserWidget = 'ViewBrowserWidget' +IdViewConnectionWidget = 'ViewConnectionWidget' IdViewLoggerWidget = 'ViewLoggerWidget' -IdViewConnectionWidget = 'ViewConnectionWidget' class ObjectRegistry(weakref.WeakValueDictionary): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jU...@us...> - 2008-07-15 23:51:43
|
Revision: 637 http://fclient.svn.sourceforge.net/fclient/?rev=637&view=rev Author: jUrner Date: 2008-07-15 16:51:52 -0700 (Tue, 15 Jul 2008) Log Message: ----------- no need to set verbosity anymore Modified Paths: -------------- trunk/fclient/src/fclient/config.py Modified: trunk/fclient/src/fclient/config.py =================================================================== --- trunk/fclient/src/fclient/config.py 2008-07-15 23:51:04 UTC (rev 636) +++ trunk/fclient/src/fclient/config.py 2008-07-15 23:51:52 UTC (rev 637) @@ -98,7 +98,7 @@ #********************************************************************************** # #********************************************************************************** -fcpClient = fcp2.Client(debugVerbosity=fcp2.ConstDebugVerbosity.Debug) # global fcp client +fcpClient = fcp2.Client() # global fcp client settings = Settings(None) # global settings class #********************************************************************************** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |