SF.net SVN: fclient:[726] trunk/fclient/src/fclient/config.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-25 07:10:12
|
Revision: 726
http://fclient.svn.sourceforge.net/fclient/?rev=726&view=rev
Author: jUrner
Date: 2008-07-25 07:10:20 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
many changes
Modified Paths:
--------------
trunk/fclient/src/fclient/config.py
Modified: trunk/fclient/src/fclient/config.py
===================================================================
--- trunk/fclient/src/fclient/config.py 2008-07-25 07:09:37 UTC (rev 725)
+++ trunk/fclient/src/fclient/config.py 2008-07-25 07:10:20 UTC (rev 726)
@@ -4,9 +4,8 @@
if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
import os; __path__ = [os.path.dirname(__file__)]
-import atexit
import os
-import weakref
+import weakref
from PyQt4 import QtCore
from .lib import fcp2
@@ -22,11 +21,14 @@
FclientCopyright = '(c) 2008 Juergen Urner'
FclientHomepage = 'http://fclient.sourceforge.net/'
-FclientDir = os.path.dirname(os.path.abspath(__file__))
-FclientDocDir = os.path.join(FclientDir, 'doc')
-FclientDownloadsDir = os.path.join(FclientDir, 'downloads')
-FclientResDir = os.path.join(FclientDir, 'res')
-FclientSettingsDir = os.path.join(FclientDir, 'settings')
+_ = os.path.dirname(os.path.abspath(__file__))
+FclientDir = QtCore.QString(_)
+FclientDocDir = QtCore.QString(os.path.join(_, 'doc'))
+FclientDownloadDir = QtCore.QString(os.path.join(_, 'downloads'))
+FclientResDir = QtCore.QString(os.path.join(_, 'res'))
+FclientSettingsDir = QtCore.QString(os.path.join(_, 'settings'))
+del _
+
#**********************************************************************************
# 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
@@ -100,16 +102,23 @@
('SettingsDir', 'String', QtCore.QString(FclientSettingsDir), SettingScopeUser), # if not None, settings are stored locally in the app folder
('SettingsAllUsers', 'Bool', False, SettingScopeUser), # store settings for all users?
('IconTheme', 'String', 'crystal', SettingScopeUser),
- ('DownloadsDir', 'String', FclientDownloadsDir, SettingScopeUser),
+ ('DownloadDir', 'String', FclientDownloadDir, SettingScopeUser),
+
+ ('FcpAutoConnect', 'Bool', True, SettingScopeUser),
+ ('FcpConnectionName', 'String', '', SettingScopeUser), #TODO: not implemented
+ ('FcpConnectionHost', 'String', fcp2.Client.DefaultFcpHost, SettingScopeUser),
+ ('FcpConnectionPort', 'UInt', fcp2.Client.DefaultFcpPort, SettingScopeUser),
+ ('FproxyConnectionHost', 'String','127.0.0.1', SettingScopeUser),
+ ('FproxyConnectionPort', 'UInt', 8888, SettingScopeUser),
)
SettingsBase._config_settings_ = Settings()
#**********************************************************************************
#
#**********************************************************************************
-fcpClient = fcp2.Client() # global fcp client
-settings = Settings(None) # global settings class
-resources = resources.Resources([FclientResDir, ], )
+fcpClient = fcp2.Client() # global fcp client
+settings = Settings(None).restore() # global settings class
+resources = resources.Resources([FclientResDir, ], ) # access to global resources
#**********************************************************************************
#
@@ -149,4 +158,42 @@
self.name = '' #unique name of the view
self.displayName = '' # name as shown t the user
self.icon = None # QIcon associated to the view
-
\ No newline at end of file
+
+
+#********************************************************************************
+#
+#********************************************************************************
+#TODO: maybe find a better place
+def qStringToFcpKey(qString):
+ """converts a qString to a fcp key
+ @return: fcp key or None if the key could not be converted
+ """
+ string = unicode(qString)
+ try:
+ key = fcp2.Key(string)
+ except fcp2.ErrorKey:
+ pass
+ else:
+ return key
+ return None
+
+
+def guessFileNameFromKey(fcpKey, default=None):
+ """guesses the filename from a key
+ @param fcpKey: fcp key to guess the filename for
+ @paran default: what to return when no filename could be guessed?
+ @return: (QString) filename or or default if no filename was found
+ """
+ key = fcpKey.toString().rstrip('/')
+ filename = ''
+ if fcpKey.KeyType == fcp2.ConstKeyType.KSK:
+ if fcpKey.docName is not None:
+ filename = os.path.basename(fcpKey.docName)
+ else:
+ filename = os.path.basename(key)
+ if filename == key:
+ filename = ''
+ if filename:
+ return QtCore.QString(filename)
+ return default
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|