SF.net SVN: fclient:[799] trunk/fclient/src/fclient/impl/ PrefsConnectionWidget.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-28 12:19:40
|
Revision: 799
http://fclient.svn.sourceforge.net/fclient/?rev=799&view=rev
Author: jUrner
Date: 2008-07-28 12:19:49 +0000 (Mon, 28 Jul 2008)
Log Message:
-----------
reworkes prefs page to use new settings controller
Modified Paths:
--------------
trunk/fclient/src/fclient/impl/PrefsConnectionWidget.py
Modified: trunk/fclient/src/fclient/impl/PrefsConnectionWidget.py
===================================================================
--- trunk/fclient/src/fclient/impl/PrefsConnectionWidget.py 2008-07-28 12:19:10 UTC (rev 798)
+++ trunk/fclient/src/fclient/impl/PrefsConnectionWidget.py 2008-07-28 12:19:49 UTC (rev 799)
@@ -1,4 +1,12 @@
-
+"""
+"""
+#*******************************************************************************
+#TODO:
+#
+# x. should we reconnect when the user changes the fcp connection name?
+#
+#
+#******************************************************************************
from __future__ import absolute_import
if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below
@@ -9,6 +17,7 @@
from . import config
from .lib.qt4ex import dlgpreferences
+from .lib.qt4ex.lib import settings
from .tpls.Ui_PrefsConnectionExpertSettingsTpl import Ui_PrefsConnectionExpertSettings
#**********************************************************************************
@@ -21,39 +30,52 @@
IdSpinConnectionTimerTimeout = 'spinConnectionTimerTimeout'
IdSpinFcpPollTimerTimeout = 'spinFcpPollTimerTimeout'
- def __init__(self, parent=None):
+
+ def __init__(self, parent=None, page=None):
QtGui.QWidget.__init__(self, parent)
self.setupUi(self)
self.setWindowTitle(config.FclientAppName + self.trUtf8(' - Connection expert settings'))
-
- edName = self.controlById(self.IdEdFcpConnectionName)
- edName.setText(config.settings.value('FcpConnectionName'))
- self.connect(edName, QtCore.SIGNAL('textChanged(const QString &)'), self.onEdFcpConnectionNameChanged)
-
+ self.fcSettingsControler = None
+
+ #
connectionWidget = config.ObjectRegistry.get(config.IdViewConnectionWidget, None)
- spins = (
- (self.IdSpinFcpConnectionTimerMaxDuration, 'FcpConnectionTimerMaxDuration'),
- (self.IdSpinConnectionTimerTimeout, 'FcpConnectionTimerTimeout'),
- (self.IdSpinFcpPollTimerTimeout, 'FcpPollTimerTimeout'),
- )
- for idControl, settingName in spins:
- spin = self.controlById(idControl)
- if connectionWidget is None:
- spin.setEnabled(False)
- else:
- spin.setValue(connectionWidget.fcSettings.value(settingName))
-
-
-
-
+ if connectionWidget is None:
+ self.setEnabled(False)
+ else:
+ self.fcSettingsControler = settings.SettingsControler(connectionWidget.fcSettings, parent=self)
+ if page is not None:
+ page.connect(self.fcSettingsControler, QtCore.SIGNAL('isDirty(bool)'), page.setDirty)
+ self.fcSettingsControler.addLineEdit(
+ self.controlById(self.IdEdFcpConnectionName),
+ 'FcpConnectionName',
+ )
+ self.fcSettingsControler.addSpinBox(
+ self.controlById(self.IdSpinFcpConnectionTimerMaxDuration),
+ 'FcpConnectionTimerMaxDuration',
+ )
+ self.fcSettingsControler.addSpinBox(
+ self.controlById(self.IdSpinConnectionTimerTimeout),
+ 'FcpConnectionTimerTimeout',
+ )
+ self.fcSettingsControler.addSpinBox(
+ self.controlById(self.IdSpinFcpPollTimerTimeout),
+ 'FcpPollTimerTimeout',
+ )
+
def controlById(self, idControl):
return getattr(self, idControl)
-
- def onEdFcpConnectionNameChanged(self, text):
- config.settings.setValues(FcpConnectionName=text)
+ 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
+
#***********************************************************************
#
#***********************************************************************
@@ -64,19 +86,29 @@
def __init__(self):
dlgpreferences.Page.__init__(self, self.UUID)
self._widget = None
- self.setDirty(True)
-
+
def displayName(self):
return self.trUtf8('Connection')
def canApply(self): return True
- def canHelp(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 = PrefsConnectionExpertSettingsWidget(parent)
+ self._widget = PrefsConnectionExpertSettingsWidget(parent, page=self)
+ self.connect(self._widget, QtCore.SIGNAL('setDirty(bool)'), self.setDirty)
self._widget.setVisible(flag)
return (createdNew, self._widget)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|