00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 from xml.etree.ElementTree import parse, SubElement
00034
00035 import sys, os
00036
00037 if os.name == 'nt':
00038 sys.path.append('.')
00039
00040 from distutils.sysconfig import get_python_lib
00041 terp_path = "/".join([get_python_lib(), 'Koo'])
00042 sys.path.append(terp_path)
00043
00044 from Koo.Common.Settings import Settings
00045 from Koo.Common import CommandLine
00046 from Koo.Common import Localization
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 Settings.loadFromFile()
00061 Settings.loadFromRegistry()
00062 Localization.initializeTranslations(Settings.value('client.language'))
00063
00064 arguments = CommandLine.parseArguments(sys.argv)
00065
00066 Localization.initializeTranslations(Settings.value('client.language'))
00067
00068
00069 imports={}
00070
00071 from PyQt4.QtCore import *
00072 from PyQt4.QtGui import *
00073 from Koo.Common import Notifier, Common
00074 from Koo.Common import DBus
00075
00076
00077 Notifier.errorHandler = Common.error
00078 Notifier.warningHandler = Common.warning
00079 Notifier.concurrencyErrorHandler = Common.concurrencyError
00080 Notifier.lostConnectionErrorHandler = Common.lostConnectionError
00081
00082
00083
00084
00085
00086 if Common.isKdeAvailable:
00087 from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs
00088 from PyKDE4.kdeui import KApplication
00089
00090 appName = "Koo"
00091 catalog = ""
00092 programName = ki18n ("Koo")
00093 version = "1.0"
00094 description = ki18n ("KDE OpenObject Client")
00095 license = KAboutData.License_GPL
00096 copyright = ki18n ("(c) 2009 Albert Cervera i Areny")
00097 text = ki18n ("none")
00098 homePage = "www.nan-tic.com"
00099 bugEmail = "albert@nan-tic.com"
00100
00101 aboutData = KAboutData (appName, catalog, programName, version, description,
00102 license, copyright, text, homePage, bugEmail)
00103
00104 KCmdLineArgs.init (arguments, aboutData)
00105
00106 app = KApplication ()
00107 else:
00108 app = QApplication( arguments )
00109
00110 app.setApplicationName( 'Koo' )
00111 app.setOrganizationDomain( 'www.nan-tic.com' )
00112 app.setOrganizationName( 'NaN' )
00113
00114 try:
00115 f = open( Settings.value('koo.stylesheet'), 'r' )
00116 try:
00117 app.setStyleSheet( f.read() )
00118 finally:
00119 f.close()
00120 except:
00121 pass
00122
00123 DBus.init()
00124
00125 Localization.initializeQtTranslations(Settings.value('client.language'))
00126
00127
00128 from Koo.Dialogs.KooMainWindow import *
00129 from Koo.Dialogs.WindowService import *
00130 import Koo.Actions
00131
00132 win = KooMainWindow()
00133
00134 from Koo.Common import Api
00135
00136 class KooApi(Api.KooApi):
00137 def execute(self, actionId, data={}, type=None, context={}):
00138 Koo.Actions.execute( actionId, data, type, context )
00139
00140 def executeReport(self, name, data={}, context={}):
00141 return Koo.Actions.executeReport( name, data, context )
00142
00143 def executeAction(self, action, data={}, context={}):
00144 Koo.Actions.executeAction( action, data, context )
00145
00146 def executeKeyword(self, keyword, data={}, context={}):
00147 return Koo.Actions.executeKeyword( keyword, data, context )
00148
00149 def createWindow(self, view_ids, model, res_id=False, domain=None,
00150 view_type='form', window=None, context=None, mode=None, name=False, autoReload=False,
00151 target='current'):
00152 WindowService.createWindow( view_ids, model, res_id, domain,
00153 view_type, window, context, mode, name, autoReload, target )
00154
00155 def createWebWindow(self, url, title):
00156 WindowService.createWebWindow(url, title)
00157
00158 def windowCreated(self, window, target):
00159 win.addWindow( window, target )
00160
00161 Api.instance = KooApi()
00162
00163 win.show()
00164
00165 if Settings.value('koo.pos_mode'):
00166 import Koo.Pos
00167 app.installEventFilter( Koo.Pos.PosEventFilter(win) )
00168
00169 if Settings.value('koo.enter_as_tab'):
00170 from Koo.Common import EnterEventFilter
00171 app.installEventFilter( EnterEventFilter.EnterEventFilter(win) )
00172
00173 from Koo.Common import ArrowsEventFilter
00174 app.installEventFilter( ArrowsEventFilter.ArrowsEventFilter(win) )
00175
00176 from Koo.Common import WhatsThisEventFilter
00177 app.installEventFilter( WhatsThisEventFilter.WhatsThisEventFilter(win) )
00178
00179 if Settings.value('tip.autostart'):
00180 from Koo.Dialogs.TipOfTheDayDialog import *
00181 dialog = TipOfTheDayDialog()
00182 dialog.exec_()
00183
00184 win.showLoginDialog()
00185
00186 if Settings.value('client.debug'):
00187 def excepthook(type, value, backtrace):
00188 import traceback
00189 Notifier.notifyError( type, value, ''.join( traceback.format_tb( backtrace ) ) )
00190
00191 sys.excepthook = excepthook
00192
00193 app.exec_()