SF.net SVN: fclient:[956] trunk/fclient/fclient/impl/MainWindow
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-08-22 12:59:43
|
Revision: 956
http://fclient.svn.sourceforge.net/fclient/?rev=956&view=rev
Author: jUrner
Date: 2008-08-22 12:59:51 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
ups, forgot to check in prefs of mainWindow
Added Paths:
-----------
trunk/fclient/fclient/impl/MainWindow/prefs/
trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py
trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui
trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py
trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui
trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py
trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py
trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py
trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py
Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.py 2008-08-22 12:59:51 UTC (rev 956)
@@ -0,0 +1,145 @@
+# 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 ...lib.qt4ex import dlgpreferences
+from ...lib.qt4ex.lib import settings
+
+from .Ui_PrefsGlobal import Ui_PrefsGlobalWidget
+#**********************************************************************************
+#
+#**********************************************************************************
+class PrefsGlobalWidget(QtGui.QWidget, Ui_PrefsGlobalWidget):
+
+ IdEdSettingsDir = 'edSettingsDir'
+ IdBtSelectSettingsDir = 'btSelectSettingsDir'
+
+ IdCkSettingsAllUsers = 'ckSettingsAllUsers'
+
+ IdEdDownloadDir = 'edDownloadDir'
+ IdBtSelectDownloadDir = 'btSelectDownloadDir'
+
+
+ def __init__(self, parent=None, page=None):
+ QtGui.QWidget.__init__(self, parent)
+
+ self.setupUi(self)
+
+ self.fcSettingsControler = settings.SettingsControler(config.fcSettings, parent=self)
+ if page is not None:
+ page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty)
+
+ self.fcSettingsControler.addLineEdit(
+ self.controlById(self.IdEdSettingsDir),
+ 'SettingsDir',
+ )
+ self.fcSettingsControler.addCheckBox(
+ self.controlById(self.IdCkSettingsAllUsers),
+ 'SettingsAllUsers',
+ )
+ self.fcSettingsControler.addLineEdit(
+ self.controlById(self.IdEdDownloadDir),
+ 'DownloadDir',
+ )
+
+ bt = self.controlById(self.IdBtSelectSettingsDir)
+ self.connect(bt, QtCore.SIGNAL('clicked()'), self.onBtSelectSettingsDirClicked)
+ bt = self.controlById(self.IdBtSelectDownloadDir)
+ self.connect(bt, QtCore.SIGNAL('clicked()'), self.onBtSelectDownloadDirClicked)
+
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+ def doApply(self):
+ if self.fcSettingsControler is not None:
+ return self.fcSettingsControler.apply()
+ return False
+
+ def doRestoreDefaults(self):
+ if self.fcSettingsControler is not None:
+ return self.fcSettingsControler.restoreDefaults()
+ return False
+
+ #####################
+ ## event handlers
+ #####################
+ def onBtSelectSettingsDirClicked(self):
+ ed = self.controlById(self.IdEdSettingsDir)
+ directory = QtGui.QFileDialog.getExistingDirectory(
+ self,
+ config.FcAppName + self.trUtf8(' - Select settings directory..'),
+ ed.text(),
+ )
+ if directory:
+ ed.setText(directory)
+
+ def onBtSelectDownloadDirClicked(self):
+ ed = self.controlById(self.IdEdDownloadDir)
+ directory = QtGui.QFileDialog.getExistingDirectory(
+ self,
+ config.FcAppName + self.trUtf8(' - Select download directory..'),
+ ed.text(),
+ )
+ if directory:
+ ed.setText(directory)
+
+#***********************************************************************
+#
+#***********************************************************************
+class PrefsPageGlobal(dlgpreferences.Page):
+
+ UUID = '{ba654bd8-4c63-11dd-b8b1-a11c9b5c3981}'
+
+ def __init__(self):
+ dlgpreferences.Page.__init__(self, self.UUID)
+ self._widget = None
+
+ def displayName(self):
+ return self.trUtf8('Global')
+
+ def canApply(self): return True
+ def canHelp(self): return False
+ def canRestoreDefaults(self): return True
+
+ def doApply(self):
+ self._widget.doApply()
+ return True
+
+ def doRestoreDefaults(self):
+ self._widget.doRestoreDefaults()
+ return True
+
+ def setVisible(self, parent, flag):
+ createdNew = False
+ if flag and self._widget is None:
+ createdNew = True
+ self._widget = PrefsGlobalWidget(parent=parent, page=self)
+ self._widget.setVisible(flag)
+ return (createdNew, self._widget)
+
+#***********************************************************************
+#
+#***********************************************************************
+if __name__ == '__main__':
+ from PyQt4 import QtGui
+ import sys
+
+ app = QtGui.QApplication(sys.argv)
+ w = PrefsGlobalWidget(None)
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui 2008-08-22 12:59:51 UTC (rev 956)
@@ -0,0 +1,114 @@
+<ui version="4.0" >
+ <class>PrefsGlobalWidget</class>
+ <widget class="QWidget" name="PrefsGlobalWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>465</width>
+ <height>316</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="fieldHeader" >
+ <property name="text" >
+ <string>Settings directory:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Directory to store settings to.Leave empty to store settings in a location your os feels best with</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QLineEdit" name="edSettingsDir" />
+ </item>
+ <item>
+ <widget class="QPushButton" name="btSelectSettingsDir" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>If no path for settings is specified, store settings only for the the current user or for all users?</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QCheckBox" name="ckSettingsAllUsers" >
+ <property name="text" >
+ <string>Store settings for all users</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <widget class="QLabel" name="fieldHeader_2" >
+ <property name="text" >
+ <string>Default download directory:</string>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QLineEdit" name="edDownloadDir" />
+ </item>
+ <item>
+ <widget class="QPushButton" name="btSelectDownloadDir" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="7" column="0" >
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>38</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.py 2008-08-22 12:59:51 UTC (rev 956)
@@ -0,0 +1,110 @@
+# 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 ...lib.qt4ex import dlgpreferences
+from ...lib.qt4ex.lib import settings
+
+from .Ui_PrefsSingleApp import Ui_PrefsSingleApp
+#**********************************************************************************
+#
+#**********************************************************************************
+class PrefsSingleApp(QtGui.QWidget, Ui_PrefsSingleApp):
+
+ IdEdHost = 'edHost'
+ IdSpinPort = 'spinPort'
+
+ def __init__(self, parent=None, page=None):
+ QtGui.QWidget.__init__(self, parent)
+
+ self.setupUi(self)
+
+ self.fcSettingsControler = settings.SettingsControler(config.fcSettings, parent=self)
+ if page is not None:
+ page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty)
+
+ self.fcSettingsControler.addLineEdit(
+ self.controlById(self.IdEdHost),
+ 'SingleAppHost',
+ )
+
+ spinPort = self.controlById(self.IdSpinPort)
+ spinPort.setRange(0, 0xFFFF) #TODO: no idea if port range (0, 0xFFFF) this is reasonable
+ self.fcSettingsControler.addSpinBox(
+ spinPort,
+ 'SingleAppPort',
+ )
+
+
+ def controlById(self, idControl):
+ return getattr(self, idControl)
+
+ def doApply(self):
+ if self.fcSettingsControler is not None:
+ return self.fcSettingsControler.apply()
+ return False
+
+ def doRestoreDefaults(self):
+ if self.fcSettingsControler is not None:
+ return self.fcSettingsControler.restoreDefaults()
+ return False
+
+#***********************************************************************
+#
+#***********************************************************************
+class PrefsPageSingleApp(dlgpreferences.Page):
+
+ UUID = '{9b76279c-46da-4fbe-9c02-a62fc843d6fc}'
+
+ def __init__(self):
+ dlgpreferences.Page.__init__(self, self.UUID)
+ self._widget = None
+
+ def displayName(self):
+ return self.trUtf8('Single application')
+
+ def canApply(self): return True
+ def canHelp(self): return False
+ def canRestoreDefaults(self): return True
+
+ def doApply(self):
+ self._widget.doApply()
+ return True
+
+ def doRestoreDefaults(self):
+ self._widget.doRestoreDefaults()
+ return True
+
+ def setVisible(self, parent, flag):
+ createdNew = False
+ if flag and self._widget is None:
+ createdNew = True
+ self._widget = PrefsSingleApp(parent=parent, page=self)
+ self._widget.setVisible(flag)
+ return (createdNew, self._widget)
+
+#***********************************************************************
+#
+#***********************************************************************
+if __name__ == '__main__':
+ from PyQt4 import QtGui
+ import sys
+
+ app = QtGui.QApplication(sys.argv)
+ w = PrefsSingleApp(None)
+ w.show()
+ res = app.exec_()
+ sys.exit(res)
+
Added: trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui 2008-08-22 12:59:51 UTC (rev 956)
@@ -0,0 +1,101 @@
+<ui version="4.0" >
+ <class>PrefsSingleApp</class>
+ <widget class="QWidget" name="PrefsSingleApp" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>533</width>
+ <height>399</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="fieldHeader_3" >
+ <property name="text" >
+ <string>Single application:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>The gui uses a socket connection to enshure only one instance is running at a time. Use the boxes below to adjust host and port of the connection to your needs.</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags" >
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QLabel" name="fieldName" >
+ <property name="text" >
+ <string>Host: </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="fieldName_2" >
+ <property name="text" >
+ <string>Port: </string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QLineEdit" name="edHost" />
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinPort" />
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="1" >
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>251</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="3" column="0" >
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>218</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Added: trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsGlobal.py 2008-08-22 12:59:51 UTC (rev 956)
@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/MainWindow/prefs/PrefsGlobal.ui'
+#
+# Created: Sun Aug 17 14:17:01 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_PrefsGlobalWidget(object):
+ def setupUi(self, PrefsGlobalWidget):
+ PrefsGlobalWidget.setObjectName("PrefsGlobalWidget")
+ PrefsGlobalWidget.resize(465, 316)
+ self.gridLayout = QtGui.QGridLayout(PrefsGlobalWidget)
+ self.gridLayout.setObjectName("gridLayout")
+ self.fieldHeader = QtGui.QLabel(PrefsGlobalWidget)
+ self.fieldHeader.setObjectName("fieldHeader")
+ self.gridLayout.addWidget(self.fieldHeader, 0, 0, 1, 1)
+ self.label = QtGui.QLabel(PrefsGlobalWidget)
+ self.label.setWordWrap(True)
+ self.label.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByKeyboard)
+ self.label.setObjectName("label")
+ self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
+ self.hboxlayout = QtGui.QHBoxLayout()
+ self.hboxlayout.setObjectName("hboxlayout")
+ self.edSettingsDir = QtGui.QLineEdit(PrefsGlobalWidget)
+ self.edSettingsDir.setObjectName("edSettingsDir")
+ self.hboxlayout.addWidget(self.edSettingsDir)
+ self.btSelectSettingsDir = QtGui.QPushButton(PrefsGlobalWidget)
+ self.btSelectSettingsDir.setObjectName("btSelectSettingsDir")
+ self.hboxlayout.addWidget(self.btSelectSettingsDir)
+ self.gridLayout.addLayout(self.hboxlayout, 2, 0, 1, 1)
+ self.label_2 = QtGui.QLabel(PrefsGlobalWidget)
+ self.label_2.setWordWrap(True)
+ self.label_2.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
+ self.label_2.setObjectName("label_2")
+ self.gridLayout.addWidget(self.label_2, 3, 0, 1, 1)
+ self.ckSettingsAllUsers = QtGui.QCheckBox(PrefsGlobalWidget)
+ self.ckSettingsAllUsers.setObjectName("ckSettingsAllUsers")
+ self.gridLayout.addWidget(self.ckSettingsAllUsers, 4, 0, 1, 1)
+ self.fieldHeader_2 = QtGui.QLabel(PrefsGlobalWidget)
+ self.fieldHeader_2.setWordWrap(True)
+ self.fieldHeader_2.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
+ self.fieldHeader_2.setObjectName("fieldHeader_2")
+ self.gridLayout.addWidget(self.fieldHeader_2, 5, 0, 1, 1)
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.edDownloadDir = QtGui.QLineEdit(PrefsGlobalWidget)
+ self.edDownloadDir.setObjectName("edDownloadDir")
+ self.horizontalLayout.addWidget(self.edDownloadDir)
+ self.btSelectDownloadDir = QtGui.QPushButton(PrefsGlobalWidget)
+ self.btSelectDownloadDir.setObjectName("btSelectDownloadDir")
+ self.horizontalLayout.addWidget(self.btSelectDownloadDir)
+ self.gridLayout.addLayout(self.horizontalLayout, 6, 0, 1, 1)
+ spacerItem = QtGui.QSpacerItem(20, 38, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.gridLayout.addItem(spacerItem, 7, 0, 1, 1)
+
+ self.retranslateUi(PrefsGlobalWidget)
+ QtCore.QMetaObject.connectSlotsByName(PrefsGlobalWidget)
+
+ def retranslateUi(self, PrefsGlobalWidget):
+ PrefsGlobalWidget.setWindowTitle(QtGui.QApplication.translate("PrefsGlobalWidget", "Form", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldHeader.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Settings directory:", None, QtGui.QApplication.UnicodeUTF8))
+ self.label.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Directory to store settings to.Leave empty to store settings in a location your os feels best with", None, QtGui.QApplication.UnicodeUTF8))
+ self.btSelectSettingsDir.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "...", None, QtGui.QApplication.UnicodeUTF8))
+ self.label_2.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "If no path for settings is specified, store settings only for the the current user or for all users?", None, QtGui.QApplication.UnicodeUTF8))
+ self.ckSettingsAllUsers.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Store settings for all users", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldHeader_2.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "Default download directory:", None, QtGui.QApplication.UnicodeUTF8))
+ self.btSelectDownloadDir.setText(QtGui.QApplication.translate("PrefsGlobalWidget", "...", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ PrefsGlobalWidget = QtGui.QWidget()
+ ui = Ui_PrefsGlobalWidget()
+ ui.setupUi(PrefsGlobalWidget)
+ PrefsGlobalWidget.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/Ui_PrefsSingleApp.py 2008-08-22 12:59:51 UTC (rev 956)
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file '/home/me/src/fclient/trunk/fclient/fclient/impl/MainWindow/prefs/PrefsSingleApp.ui'
+#
+# Created: Sun Aug 17 14:17:03 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_PrefsSingleApp(object):
+ def setupUi(self, PrefsSingleApp):
+ PrefsSingleApp.setObjectName("PrefsSingleApp")
+ PrefsSingleApp.resize(533, 399)
+ self.gridLayout = QtGui.QGridLayout(PrefsSingleApp)
+ self.gridLayout.setObjectName("gridLayout")
+ self.fieldHeader_3 = QtGui.QLabel(PrefsSingleApp)
+ self.fieldHeader_3.setObjectName("fieldHeader_3")
+ self.gridLayout.addWidget(self.fieldHeader_3, 0, 0, 1, 1)
+ self.label = QtGui.QLabel(PrefsSingleApp)
+ self.label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
+ self.label.setWordWrap(True)
+ self.label.setTextInteractionFlags(QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse)
+ self.label.setObjectName("label")
+ self.gridLayout.addWidget(self.label, 1, 0, 1, 2)
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setObjectName("horizontalLayout")
+ self.verticalLayout = QtGui.QVBoxLayout()
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.fieldName = QtGui.QLabel(PrefsSingleApp)
+ self.fieldName.setObjectName("fieldName")
+ self.verticalLayout.addWidget(self.fieldName)
+ self.fieldName_2 = QtGui.QLabel(PrefsSingleApp)
+ self.fieldName_2.setObjectName("fieldName_2")
+ self.verticalLayout.addWidget(self.fieldName_2)
+ self.horizontalLayout.addLayout(self.verticalLayout)
+ self.verticalLayout_2 = QtGui.QVBoxLayout()
+ self.verticalLayout_2.setObjectName("verticalLayout_2")
+ self.edHost = QtGui.QLineEdit(PrefsSingleApp)
+ self.edHost.setObjectName("edHost")
+ self.verticalLayout_2.addWidget(self.edHost)
+ self.spinPort = QtGui.QSpinBox(PrefsSingleApp)
+ self.spinPort.setObjectName("spinPort")
+ self.verticalLayout_2.addWidget(self.spinPort)
+ self.horizontalLayout.addLayout(self.verticalLayout_2)
+ self.gridLayout.addLayout(self.horizontalLayout, 2, 0, 1, 1)
+ spacerItem = QtGui.QSpacerItem(251, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+ self.gridLayout.addItem(spacerItem, 2, 1, 1, 1)
+ spacerItem1 = QtGui.QSpacerItem(20, 218, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+ self.gridLayout.addItem(spacerItem1, 3, 0, 1, 1)
+
+ self.retranslateUi(PrefsSingleApp)
+ QtCore.QMetaObject.connectSlotsByName(PrefsSingleApp)
+
+ def retranslateUi(self, PrefsSingleApp):
+ PrefsSingleApp.setWindowTitle(QtGui.QApplication.translate("PrefsSingleApp", "Form", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldHeader_3.setText(QtGui.QApplication.translate("PrefsSingleApp", "Single application:", None, QtGui.QApplication.UnicodeUTF8))
+ self.label.setText(QtGui.QApplication.translate("PrefsSingleApp", "The gui uses a socket connection to enshure only one instance is running at a time. Use the boxes below to adjust host and port of the connection to your needs.", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldName.setText(QtGui.QApplication.translate("PrefsSingleApp", "Host: ", None, QtGui.QApplication.UnicodeUTF8))
+ self.fieldName_2.setText(QtGui.QApplication.translate("PrefsSingleApp", "Port: ", None, QtGui.QApplication.UnicodeUTF8))
+
+
+if __name__ == "__main__":
+ import sys
+ app = QtGui.QApplication(sys.argv)
+ PrefsSingleApp = QtGui.QWidget()
+ ui = Ui_PrefsSingleApp()
+ ui.setupUi(PrefsSingleApp)
+ PrefsSingleApp.show()
+ sys.exit(app.exec_())
+
Added: trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/__init__.py 2008-08-22 12:59:51 UTC (rev 956)
@@ -0,0 +1 @@
+
Added: trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py
===================================================================
--- trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py (rev 0)
+++ trunk/fclient/fclient/impl/MainWindow/prefs/_fix_mexec.py 2008-08-22 12:59:51 UTC (rev 956)
@@ -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
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|