SF.net SVN: fclient:[907] trunk/fclient/fclient
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-08-16 06:49:37
|
Revision: 907
http://fclient.svn.sourceforge.net/fclient/?rev=907&view=rev
Author: jUrner
Date: 2008-08-16 06:49:45 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
another package redesign. finally found a way to separate components while leaving
relative imports intact for testing
Modified Paths:
--------------
trunk/fclient/fclient/fclient.py
Added Paths:
-----------
trunk/fclient/fclient/impl/MainWindow/
trunk/fclient/fclient/impl/MainWindow/Actions.py
trunk/fclient/fclient/impl/MainWindow/MainWindow.py
trunk/fclient/fclient/impl/MainWindow/MainWindow.ui
trunk/fclient/fclient/impl/MainWindow/MenuBar.py
trunk/fclient/fclient/impl/MainWindow/Settings.py
trunk/fclient/fclient/impl/MainWindow/StatusBar.py
trunk/fclient/fclient/impl/MainWindow/TitleBar.py
trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py
trunk/fclient/fclient/impl/MainWindow/__init__.py
trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py
Removed Paths:
-------------
trunk/fclient/fclient/impl/MainWindow.py
trunk/fclient/fclient/impl/tpls/MainWindowTpl.ui
trunk/fclient/fclient/impl/tpls/Ui_MainWindowTpl.py
Modified: trunk/fclient/fclient/fclient.py
===================================================================
--- trunk/fclient/fclient/fclient.py 2008-08-12 08:44:19 UTC (rev 906)
+++ trunk/fclient/fclient/fclient.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -70,7 +70,7 @@
else: # everything went well. start gui
app = QtGui.QApplication(sys.argv)
- mainWindow = MainWindow()
+ mainWindow = MainWindow.MainWindow()
singleApp.userData = mainWindow
viewWidget = ViewWidget(mainWindow)
Added: trunk/fclient/fclient/impl/MainWindow/Actions.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/Actions.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/Actions.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,45 @@
+
+# some fixes for relative imports
+# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
+# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a
+# ...package containing relative imports
+from __future__ import absolute_import
+if __name__ == '__main__':
+ import os
+ __path__ = [os.path.dirname(__file__)]
+ from ._fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+from .. import config
+
+from PyQt4 import QtCore, QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+class Actions(config.ActionsBase):
+
+ def __init__(self, parent):
+ config.ActionsBase.__init__(self, parent)
+
+ self.action(
+ name='ActionPreferences',
+ text=self.trUtf8('&Preferences...'),
+ trigger=parent.onActPreferencesTriggered,
+ )
+ self.action(
+ name='ActionExit',
+ text=self.trUtf8('E&xit'),
+ trigger=parent.onActExitTriggered,
+ )
+ self.action(
+ name='ActionAbout',
+ text=self.trUtf8('A&bout...'),
+ trigger=parent.onActAboutTriggered,
+ )
+ self.action(
+ name='ActionHelp',
+ text=self.trUtf8('&Help...'),
+ trigger=parent.onActHelpTriggered,
+ )
+
\ No newline at end of file
Added: trunk/fclient/fclient/impl/MainWindow/MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MainWindow.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/MainWindow.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,103 @@
+
+# some fixes for relative imports
+# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
+# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a
+# ...package containing relative imports
+from __future__ import absolute_import
+if __name__ == '__main__':
+ import os
+ __path__ = [os.path.dirname(__file__)]
+ from ._fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+from PyQt4 import QtCore, QtGui
+
+from .. import config
+from .. import Prefs
+from ..lib.qt4ex import dlgabout
+
+from . import Actions
+from . import MenuBar
+from . import Settings
+from . import StatusBar
+from . import TitleBar
+from . import Ui_MainWindow
+#**********************************************************************************
+#
+#**********************************************************************************
+class MainWindow(QtGui.QMainWindow, Ui_MainWindow.Ui_MainWindow):
+
+ def __init__(self, parent=None):
+ QtGui.QMainWindow.__init__(self, parent)
+ self._isCreated = False
+
+ self.setupUi(self)
+ config.ObjectRegistry.register(self)
+
+ self.fcSettings = Settings.Settings().restore()
+ self.fcActions = Actions.Actions(self)
+ self.setMenuBar(MenuBar.MenuBar(self))
+ self.setStatusBar(StatusBar.StatusBar(self))
+ self.fcTitleBar = TitleBar.TitleBar(self)
+
+ self.setWindowIcon(config.fcResources.getIcon('fclient', 32, iconTheme='application', ext='.svg'))
+ self.restoreGeometry(self.fcSettings.value('Geometry'))
+
+ ##################################
+ ## methods
+ ##################################
+ def titleBar(self):
+ return self.fcTitleBar
+
+ ##################################
+ ## events
+ ##################################
+ def closeEvent(self, event):
+ self.fcSettings.setValues(Geometry=self.saveGeometry())
+
+ def showEvent(self, event):
+ if self._isCreated:
+ return
+ self._isCreated = True
+
+ ###################################
+ ## event onrs
+ ###################################
+ def onActPreferencesTriggered(self):
+ dlg = Prefs.PrefsDlg(self)
+ if dlg.exec_() == dlg.Accepted:
+ pass
+
+ def onActExitTriggered(self):
+ self.close()
+
+ def onActHelpTriggered(self):
+ pass
+
+ def onActAboutTriggered(self):
+ dlg = dlgabout.DlgAbout(
+ self,
+ ##state=self.guiSettings['DlgAboutState'],
+ caption=config.FcAppName + ' - ' + self.trUtf8('About'),
+ appName=config.FcAppName,
+ description=self.trUtf8('a freenet client written in Fc and Qt4'),
+ version=config.FcVersion,
+ author=config.FcAuthor,
+ licence=config.FcLicence,
+ copyright=config.FcCopyright,
+ homepage=config.FcHomepage
+ )
+ dlg.exec_()
+ #self.guiSettings['DlgAboutState'] = dlg.saveState()
+
+#**********************************************************************************
+#
+#**********************************************************************************
+if __name__ == '__main__':
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ w = MainWindow(None)
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
Added: trunk/fclient/fclient/impl/MainWindow/MainWindow.ui
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MainWindow.ui (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/MainWindow.ui 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,70 @@
+<ui version="4.0" >
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>774</width>
+ <height>591</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>774</width>
+ <height>568</height>
+ </rect>
+ </property>
+ <zorder>frame</zorder>
+ </widget>
+ <widget class="QStatusBar" name="statusbar" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>568</y>
+ <width>774</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ <action name="action_Preferences" >
+ <property name="text" >
+ <string>_Preferences</string>
+ </property>
+ </action>
+ <action name="actPreferences" >
+ <property name="text" >
+ <string>&Preferences..</string>
+ </property>
+ </action>
+ <action name="actExit" >
+ <property name="text" >
+ <string>E&xit</string>
+ </property>
+ </action>
+ <action name="actHelp" >
+ <property name="text" >
+ <string>&Help..</string>
+ </property>
+ <property name="toolTip" >
+ <string>Help</string>
+ </property>
+ </action>
+ <action name="actAbout" >
+ <property name="text" >
+ <string>A&bout..</string>
+ </property>
+ <property name="iconText" >
+ <string>About</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/fclient/fclient/impl/MainWindow/MenuBar.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/MenuBar.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/MenuBar.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,26 @@
+
+from PyQt4 import QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+class MenuBar(QtGui.QMenuBar):
+
+ def __init__(self, parent):
+ QtGui.QMenuBar.__init__(self, parent)
+ self.setObjectName('MenuBar')
+ #config.ObjectRegistry.register(self)
+
+ self.menuApplication = QtGui.QMenu(self.trUtf8('&Application'), self)
+ self.addMenu(self.menuApplication)
+ self.menuApplication.addAction(parent.fcActions['ActionPreferences'])
+ self.menuApplication.addAction(parent.fcActions['ActionExit'])
+
+ self.menuHelp = QtGui.QMenu(self.trUtf8('&Help'), self)
+ self.addMenu(self.menuHelp)
+ self.menuHelp.addAction(parent.fcActions['ActionAbout'])
+ self.menuHelp.addAction(parent.fcActions['ActionHelp'])
+
+
+ def addViewMenu(self, menu):
+ self.insertMenu(self.menuHelp.children()[0], menu)
+ return menu
\ No newline at end of file
Added: trunk/fclient/fclient/impl/MainWindow/Settings.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/Settings.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/Settings.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,26 @@
+# some fixes for relative imports
+# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
+# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a
+# ...package containing relative imports
+from __future__ import absolute_import
+if __name__ == '__main__':
+ import os
+ __path__ = [os.path.dirname(__file__)]
+ from ._fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+from .. import config
+
+from PyQt4 import QtCore, QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+class Settings(config.SettingsBase):
+
+ _key_ = config.IdMainWindow
+ _settings_ = (
+ ('Geometry', 'ByteArray', QtCore.QByteArray()),
+ ('ConnectionLabelFlashRate', 'UInt', 800),
+ )
+
Added: trunk/fclient/fclient/impl/MainWindow/StatusBar.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/StatusBar.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/StatusBar.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,90 @@
+
+# some fixes for relative imports
+# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
+# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a
+# ...package containing relative imports
+from __future__ import absolute_import
+if __name__ == '__main__':
+ import os
+ __path__ = [os.path.dirname(__file__)]
+ from ._fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+from .. import config
+
+from PyQt4 import QtCore, QtGui
+#**********************************************************************************
+#
+#**********************************************************************************
+class StatusBar(QtGui.QStatusBar):
+
+
+ class DisconnectTimer(QtCore.QTimer):
+
+ def __init__(self,statusBar):
+ QtCore.QTimer.__init__(self, statusBar)
+ self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
+
+ def start(self, n):
+ QtCore.QTimer.start(self, n)
+
+ def onNext(self):
+ statusBar = self.parent()
+ if statusBar.connectionLabels['LabelConnectionConnected'].isVisible():
+ self.stop()
+ else:
+ statusBar.connectionLabels['LabelConnectionDisonnectedOn'].setVisible(
+ not statusBar.connectionLabels['LabelConnectionDisonnectedOn'].isVisible()
+ )
+ statusBar.connectionLabels['LabelConnectionDisonnectedOff'].setVisible(
+ not statusBar.connectionLabels['LabelConnectionDisonnectedOff'].isVisible()
+ )
+
+ def __init__(self, mainWindow):
+ QtGui.QStatusBar.__init__(self, mainWindow)
+ self.setObjectName('StatusBar')
+ #config.ObjectRegistry.register(self)
+ mainWindow.setStatusBar(self)
+
+ self._disconnectTimer = self.DisconnectTimer(self)
+
+ # setup connection labels
+ self.fcpEvents = (
+ (config.fcpClient.events.ClientConnected, self.onFcpClientConnected),
+ (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconnected),
+ )
+ config.fcpClient.events += self.fcpEvents
+ self.connectionLabels = {
+ 'LabelConnectionConnected': QtGui.QLabel(self),
+ 'LabelConnectionDisonnectedOn': QtGui.QLabel(self),
+ 'LabelConnectionDisonnectedOff': QtGui.QLabel(self),
+ }
+ for objectName, label in self.connectionLabels.items():
+ label.setObjectName(objectName)
+ label.setVisible(False)
+ self.addWidget(label, 0)
+ if config.fcpClient.isConnected():
+ self.connectionLabels['LabelConnectionConnected'].show()
+ else :
+ self.connectionLabels['LabelConnectionDisonnectedOn'].show()
+
+ self.retranslateUi(self)
+
+
+ def retranslateUi(self, this):
+ self.connectionLabels['LabelConnectionConnected'].setText(self.trUtf8('CONNECTED'))
+ self.connectionLabels['LabelConnectionDisonnectedOn'].setText(self.trUtf8('DISCONNECTED'))
+ self.connectionLabels['LabelConnectionDisonnectedOff'].setText(self.trUtf8('DISCONNECTED'))
+
+ def onFcpClientConnected(self, event, msg):
+ self._disconnectTimer.stop()
+ for label in self.connectionLabels.values():
+ label.hide()
+ self.connectionLabels['LabelConnectionConnected'].show()
+
+ def onFcpClientDisconnected(self, event, msg):
+ for label in self.connectionLabels.values():
+ label.hide()
+ self.connectionLabels['LabelConnectionDisonnectedOn'].show()
+ self._disconnectTimer.start(self.parent().fcSettings.value('ConnectionLabelFlashRate'))
Added: trunk/fclient/fclient/impl/MainWindow/TitleBar.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/TitleBar.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/TitleBar.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,32 @@
+
+# some fixes for relative imports
+# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
+# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a
+# ...package containing relative imports
+from __future__ import absolute_import
+if __name__ == '__main__':
+ import os
+ __path__ = [os.path.dirname(__file__)]
+ from ._fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+from .. import config
+
+
+from PyQt4 import QtCore
+#**********************************************************************************
+#
+#**********************************************************************************
+class TitleBar(QtCore.QObject):
+
+ def __init__(self, parent):
+ QtCore.QObject.__init__(self, parent)
+ self.setInfo('')
+
+ def setInfo(self, text):
+ if text:
+ title = config.FcAppName + ' - [%s]' % text
+ else:
+ title = config.FcAppName
+ self.parent().setWindowTitle(title)
Added: trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/Ui_MainWindow.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/MainWindow/MainWindow.ui'
+#
+# Created: Thu Aug 14 13:55:41 2008
+# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_MainWindow(object):
+ def setupUi(self, MainWindow):
+ MainWindow.setObjectName("MainWindow")
+ MainWindow.resize(774, 591)
+ self.centralwidget = QtGui.QWidget(MainWindow)
+ self.centralwidget.setGeometry(QtCore.QRect(0, 0, 774, 568))
+ self.centralwidget.setObjectName("centralwidget")
+ MainWindow.setCentralWidget(self.centralwidget)
+ self.statusbar = QtGui.QStatusBar(MainWindow)
+ self.statusbar.setGeometry(QtCore.QRect(0, 568, 774, 23))
+ self.statusbar.setObjectName("statusbar")
+ MainWindow.setStatusBar(self.statusbar)
+ self.action_Preferences = QtGui.QAction(MainWindow)
+ self.action_Preferences.setObjectName("action_Preferences")
+ self.actPreferences = QtGui.QAction(MainWindow)
+ self.actPreferences.setObjectName("actPreferences")
+ self.actExit = QtGui.QAction(MainWindow)
+ self.actExit.setObjectName("actExit")
+ self.actHelp = QtGui.QAction(MainWindow)
+ self.actHelp.setObjectName("actHelp")
+ self.actAbout = QtGui.QAction(MainWindow)
+ self.actAbout.setObjectName("actAbout")
+
+ self.retranslateUi(MainWindow)
+ QtCore.QMetaObject.connectSlotsByName(MainWindow)
+
+ def retranslateUi(self, MainWindow):
+ MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
+ self.action_Preferences.setText(QtGui.QApplication.translate("MainWindow", "_Preferences", None, QtGui.QApplication.UnicodeUTF8))
+ self.actPreferences.setText(QtGui.QApplication.translate("MainWindow", "&Preferences..", None, QtGui.QApplication.UnicodeUTF8))
+ self.actExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8))
+ self.actHelp.setText(QtGui.QApplication.translate("MainWindow", "&Help..", None, QtGui.QApplication.UnicodeUTF8))
+ self.actHelp.setToolTip(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8))
+ self.actAbout.setText(QtGui.QApplication.translate("MainWindow", "A&bout..", None, QtGui.QApplication.UnicodeUTF8))
+ self.actAbout.setIconText(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ MainWindow = QtGui.QMainWindow()
+ ui = Ui_MainWindow()
+ ui.setupUi(MainWindow)
+ MainWindow.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/MainWindow/__init__.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/__init__.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/__init__.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1 @@
+
Added: trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/_fix_mexec.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -0,0 +1,99 @@
+'''in python 2.5 relative impports are srsly broken ..fix this to make relative imports work
+when executing a module as main (-m), including relative imports up to the root package
+
+see: [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html]
+
+@note: root package is the highest available package in the package hirarchy.
+don't look at __name__ too closely. it gets adjusted for a module to just "do the right
+thing" in __name__ == '__main__' comparisons
+@note: this patch does not work if relative imports are done in __init__.py. no idea why
+and to be honest, I don't wanna* know..
+@note: this is more or less a hack. so it may have unwanted side effects for example
+when importing parent packages. use at your own risk. could improve this module
+by adding a __main__.py to stop at this level or by fixing the __init__.py bug, but
+I don't think its worth it. see what python2.6 or 3k brings..
+
+usage::
+
+ # place this at the top a module, before doing any relative imports
+ from fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+ from ...foo import bar
+
+
+
+##<-- copy and paste code, assuming _fix_mexec resides in the current dir..
+
+# some fixes for relative imports
+# see --> [http://bugs.python.org/issue1510172] absolute/rellative import not working (works only current dir and below)
+# see --> [http://mail.python.org/pipermail/python-ideas/2007-February/000232.html] PEP for executing a module in a
+# ...package containing relative imports
+from __future__ import absolute_import
+if __name__ == '__main__':
+ import os
+ __path__ = [os.path.dirname(__file__)]
+ from ._fix_mexec import fix_mexec
+ fix_mexec(__name__, __file__)
+ del fix_mexec
+
+
+##--> copy and paste code
+'''
+
+import imp, os, sys
+#********************************************************************************
+#
+#********************************************************************************
+class MainName(str):
+ def __eq__(self, other):
+ if other == '__main__': return True
+ return str.__eq__(self, other)
+ def __ne__(self, other):
+ if other == '__main__': return False
+ return str.__ne__(self, other)
+
+
+def fix_mexec(_name_, _file_):
+ """bugfix for relative imports not working
+ @param _name_: __name__ of the module
+ @param _file_: __file__ of the module
+
+ @note: not complete: relies on __init__.py, .pyo (...) is ignored currently
+ """
+ if _name_ == '__main__':
+ out = []
+ # find allparent packages
+ p = os.path.dirname(os.path.abspath(_file_))
+ prev = p
+ while True:
+ pkg = os.path.join(p, '__init__.py')
+ if os.path.isfile(pkg):
+ out.append([pkg, os.path.basename(p)])
+ else:
+ break
+ prev = p
+ p = os.path.dirname(p)
+ if p == prev:
+ break
+ out.reverse()
+
+ # adjust sub package names an import parent modules
+ name = None
+ for n, (fpath, name) in enumerate(out):
+ if n > 0:
+ name = out[n][1] = out[n -1][1] + '.' + out[n][1]
+ m = imp.load_source(name, fpath)
+ m.__path__ = [os.path.dirname(fpath)]
+
+ # adjust name of the __main__ module
+ if name is not None:
+ m = sys.modules.pop('__main__')
+ # 'foo.bar..__main__' does not work for some reason. 'foo.bar' seems to work as expected
+ ##m.__name__ = _Name_(name + '.' + '__main__')
+ m.__name__ = MainName(name)
+ sys.modules[m.__name__] = m
+
+
+
Deleted: trunk/fclient/fclient/impl/MainWindow.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow.py 2008-08-12 08:44:19 UTC (rev 906)
+++ trunk/fclient/fclient/impl/MainWindow.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -1,246 +0,0 @@
-from __future__ import absolute_import
-if __name__ == '__main__': # see --> http://bugs.Fc.org/issue1510172 . works only current dir and below
- import os; __path__ = [os.path.dirname(__file__)]
-
-import logging
-import sys
-logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
-
-from PyQt4 import QtCore, QtGui
-
-from . import config
-from . import Prefs
-from .lib.qt4ex import dlgabout
-
-from .tpls.Ui_MainWindowTpl import Ui_MainWindow
-#**********************************************************************************
-#
-#**********************************************************************************
-class Settings(config.SettingsBase):
-
- _key_ = config.IdMainWindow
- _settings_ = (
- ('Geometry', 'ByteArray', QtCore.QByteArray()),
- ('ConnectionLabelFlashRate', 'UInt', 800),
- )
-
-
-class Actions(config.ActionsBase):
-
- def __init__(self, parent):
- config.ActionsBase.__init__(self, parent)
-
- self.action(
- name='ActionPreferences',
- text=self.trUtf8('&Preferences...'),
- trigger=parent.onActPreferencesTriggered,
- )
- self.action(
- name='ActionExit',
- text=self.trUtf8('E&xit'),
- trigger=parent.onActExitTriggered,
- )
- self.action(
- name='ActionAbout',
- text=self.trUtf8('A&bout...'),
- trigger=parent.onActAboutTriggered,
- )
- self.action(
- name='ActionHelp',
- text=self.trUtf8('&Help...'),
- trigger=parent.onActHelpTriggered,
- )
-
-#**********************************************************************************
-#
-#**********************************************************************************
-class MenuBar(QtGui.QMenuBar):
-
- def __init__(self, parent):
- QtGui.QMenuBar.__init__(self, parent)
- self.setObjectName('MenuBar')
- #config.ObjectRegistry.register(self)
-
- self.menuApplication = QtGui.QMenu(self.trUtf8('&Application'), self)
- self.addMenu(self.menuApplication)
- self.menuApplication.addAction(parent.fcActions['ActionPreferences'])
- self.menuApplication.addAction(parent.fcActions['ActionExit'])
-
- self.menuHelp = QtGui.QMenu(self.trUtf8('&Help'), self)
- self.addMenu(self.menuHelp)
- self.menuHelp.addAction(parent.fcActions['ActionAbout'])
- self.menuHelp.addAction(parent.fcActions['ActionHelp'])
-
-
- def addViewMenu(self, menu):
- self.insertMenu(self.menuHelp.children()[0], menu)
- return menu
-
-
-class StatusBar(QtGui.QStatusBar):
-
-
- class DisconnectTimer(QtCore.QTimer):
-
- def __init__(self,statusBar):
- QtCore.QTimer.__init__(self, statusBar)
- self.connect(self, QtCore.SIGNAL('timeout()'), self.onNext)
-
- def start(self, n):
- QtCore.QTimer.start(self, n)
-
- def onNext(self):
- statusBar = self.parent()
- if statusBar.connectionLabels['LabelConnectionConnected'].isVisible():
- self.stop()
- else:
- statusBar.connectionLabels['LabelConnectionDisonnectedOn'].setVisible(
- not statusBar.connectionLabels['LabelConnectionDisonnectedOn'].isVisible()
- )
- statusBar.connectionLabels['LabelConnectionDisonnectedOff'].setVisible(
- not statusBar.connectionLabels['LabelConnectionDisonnectedOff'].isVisible()
- )
-
- def __init__(self, mainWindow):
- QtGui.QStatusBar.__init__(self, mainWindow)
- self.setObjectName('StatusBar')
- #config.ObjectRegistry.register(self)
- mainWindow.setStatusBar(self)
-
- self._disconnectTimer = self.DisconnectTimer(self)
-
- # setup connection labels
- self.fcpEvents = (
- (config.fcpClient.events.ClientConnected, self.onFcpClientConnected),
- (config.fcpClient.events.ClientDisconnected, self.onFcpClientDisconnected),
- )
- config.fcpClient.events += self.fcpEvents
- self.connectionLabels = {
- 'LabelConnectionConnected': QtGui.QLabel(self),
- 'LabelConnectionDisonnectedOn': QtGui.QLabel(self),
- 'LabelConnectionDisonnectedOff': QtGui.QLabel(self),
- }
- for objectName, label in self.connectionLabels.items():
- label.setObjectName(objectName)
- label.setVisible(False)
- self.addWidget(label, 0)
- if config.fcpClient.isConnected():
- self.connectionLabels['LabelConnectionConnected'].show()
- else :
- self.connectionLabels['LabelConnectionDisonnectedOn'].show()
-
- self.retranslateUi(self)
-
-
- def retranslateUi(self, this):
- self.connectionLabels['LabelConnectionConnected'].setText(self.trUtf8('CONNECTED'))
- self.connectionLabels['LabelConnectionDisonnectedOn'].setText(self.trUtf8('DISCONNECTED'))
- self.connectionLabels['LabelConnectionDisonnectedOff'].setText(self.trUtf8('DISCONNECTED'))
-
- def onFcpClientConnected(self, event, msg):
- self._disconnectTimer.stop()
- for label in self.connectionLabels.values():
- label.hide()
- self.connectionLabels['LabelConnectionConnected'].show()
-
- def onFcpClientDisconnected(self, event, msg):
- for label in self.connectionLabels.values():
- label.hide()
- self.connectionLabels['LabelConnectionDisonnectedOn'].show()
- self._disconnectTimer.start(self.parent().fcSettings.value('ConnectionLabelFlashRate'))
-
-
-
-class TitleBar(QtCore.QObject):
-
- def __init__(self, parent):
- QtCore.QObject.__init__(self, parent)
- self.setInfo('')
-
- def setInfo(self, text):
- if text:
- title = config.FcAppName + ' - [%s]' % text
- else:
- title = config.FcAppName
- self.parent().setWindowTitle(title)
-
-#**********************************************************************************
-#
-#**********************************************************************************
-class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
-
- def __init__(self, parent=None):
- QtGui.QMainWindow.__init__(self, parent)
- self._isCreated = False
-
- self.setupUi(self)
- config.ObjectRegistry.register(self)
-
- self.fcSettings = Settings().restore()
- self.fcActions = Actions(self)
- self.setMenuBar(MenuBar(self))
- self.setStatusBar(StatusBar(self))
- self.fcTitleBar = TitleBar(self)
-
- self.setWindowIcon(config.fcResources.getIcon('fclient', 32, iconTheme='application', ext='.svg'))
- self.restoreGeometry(self.fcSettings.value('Geometry'))
-
- ##################################
- ## methods
- ##################################
- def titleBar(self):
- return self.fcTitleBar
-
-
- ##################################
- ## events
- ##################################
- def closeEvent(self, event):
- self.fcSettings.setValues(Geometry=self.saveGeometry())
-
- def showEvent(self, event):
- if self._isCreated:
- return
- self._isCreated = True
-
- ###################################
- ## event onrs
- ###################################
- def onActPreferencesTriggered(self):
- dlg = Prefs.PrefsDlg(self)
- if dlg.exec_() == dlg.Accepted:
- pass
-
- def onActExitTriggered(self):
- self.close()
-
- def onActHelpTriggered(self):
- pass
-
- def onActAboutTriggered(self):
- dlg = dlgabout.DlgAbout(
- self,
- ##state=self.guiSettings['DlgAboutState'],
- caption=config.FcAppName + ' - ' + self.trUtf8('About'),
- appName=config.FcAppName,
- description=self.trUtf8('a freenet client written in Fc and Qt4'),
- version=config.FcVersion,
- author=config.FcAuthor,
- licence=config.FcLicence,
- copyright=config.FcCopyright,
- homepage=config.FcHomepage
- )
- dlg.exec_()
- #self.guiSettings['DlgAboutState'] = dlg.saveState()
-
-#**********************************************************************************
-#
-#**********************************************************************************
-if __name__ == '__main__':
- import sys
-
- app = QtGui.QApplication(sys.argv)
- w = MainWindow(None)
- w.show()
- res = app.exec_()
- sys.exit(res)
\ No newline at end of file
Deleted: trunk/fclient/fclient/impl/tpls/MainWindowTpl.ui
===================================================================
--- trunk/fclient/fclient/impl/tpls/MainWindowTpl.ui 2008-08-12 08:44:19 UTC (rev 906)
+++ trunk/fclient/fclient/impl/tpls/MainWindowTpl.ui 2008-08-16 06:49:45 UTC (rev 907)
@@ -1,70 +0,0 @@
-<ui version="4.0" >
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>774</width>
- <height>591</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>MainWindow</string>
- </property>
- <widget class="QWidget" name="centralwidget" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>774</width>
- <height>568</height>
- </rect>
- </property>
- <zorder>frame</zorder>
- </widget>
- <widget class="QStatusBar" name="statusbar" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>568</y>
- <width>774</width>
- <height>23</height>
- </rect>
- </property>
- </widget>
- <action name="action_Preferences" >
- <property name="text" >
- <string>_Preferences</string>
- </property>
- </action>
- <action name="actPreferences" >
- <property name="text" >
- <string>&Preferences..</string>
- </property>
- </action>
- <action name="actExit" >
- <property name="text" >
- <string>E&xit</string>
- </property>
- </action>
- <action name="actHelp" >
- <property name="text" >
- <string>&Help..</string>
- </property>
- <property name="toolTip" >
- <string>Help</string>
- </property>
- </action>
- <action name="actAbout" >
- <property name="text" >
- <string>A&bout..</string>
- </property>
- <property name="iconText" >
- <string>About</string>
- </property>
- </action>
- </widget>
- <resources/>
- <connections/>
-</ui>
Deleted: trunk/fclient/fclient/impl/tpls/Ui_MainWindowTpl.py
===================================================================
--- trunk/fclient/fclient/impl/tpls/Ui_MainWindowTpl.py 2008-08-12 08:44:19 UTC (rev 906)
+++ trunk/fclient/fclient/impl/tpls/Ui_MainWindowTpl.py 2008-08-16 06:49:45 UTC (rev 907)
@@ -1,57 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/tpls/MainWindowTpl.ui'
-#
-# Created: Sat Aug 2 01:50:59 2008
-# by: PyQt4 UI code generator 4.4.3-snapshot-20080705
-#
-# WARNING! All changes made in this file will be lost!
-
-from PyQt4 import QtCore, QtGui
-
-class Ui_MainWindow(object):
- def setupUi(self, MainWindow):
- MainWindow.setObjectName("MainWindow")
- MainWindow.resize(774, 591)
- self.centralwidget = QtGui.QWidget(MainWindow)
- self.centralwidget.setGeometry(QtCore.QRect(0, 0, 774, 568))
- self.centralwidget.setObjectName("centralwidget")
- MainWindow.setCentralWidget(self.centralwidget)
- self.statusbar = QtGui.QStatusBar(MainWindow)
- self.statusbar.setGeometry(QtCore.QRect(0, 568, 774, 23))
- self.statusbar.setObjectName("statusbar")
- MainWindow.setStatusBar(self.statusbar)
- self.action_Preferences = QtGui.QAction(MainWindow)
- self.action_Preferences.setObjectName("action_Preferences")
- self.actPreferences = QtGui.QAction(MainWindow)
- self.actPreferences.setObjectName("actPreferences")
- self.actExit = QtGui.QAction(MainWindow)
- self.actExit.setObjectName("actExit")
- self.actHelp = QtGui.QAction(MainWindow)
- self.actHelp.setObjectName("actHelp")
- self.actAbout = QtGui.QAction(MainWindow)
- self.actAbout.setObjectName("actAbout")
-
- self.retranslateUi(MainWindow)
- QtCore.QMetaObject.connectSlotsByName(MainWindow)
-
- def retranslateUi(self, MainWindow):
- MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
- self.action_Preferences.setText(QtGui.QApplication.translate("MainWindow", "_Preferences", None, QtGui.QApplication.UnicodeUTF8))
- self.actPreferences.setText(QtGui.QApplication.translate("MainWindow", "&Preferences..", None, QtGui.QApplication.UnicodeUTF8))
- self.actExit.setText(QtGui.QApplication.translate("MainWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8))
- self.actHelp.setText(QtGui.QApplication.translate("MainWindow", "&Help..", None, QtGui.QApplication.UnicodeUTF8))
- self.actHelp.setToolTip(QtGui.QApplication.translate("MainWindow", "Help", None, QtGui.QApplication.UnicodeUTF8))
- self.actAbout.setText(QtGui.QApplication.translate("MainWindow", "A&bout..", None, QtGui.QApplication.UnicodeUTF8))
- self.actAbout.setIconText(QtGui.QApplication.translate("MainWindow", "About", None, QtGui.QApplication.UnicodeUTF8))
-
-
-if __name__ == "__main__":
- import sys
- app = QtGui.QApplication(sys.argv)
- MainWindow = QtGui.QMainWindow()
- ui = Ui_MainWindow()
- ui.setupUi(MainWindow)
- MainWindow.show()
- sys.exit(app.exec_())
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|