Obsoleted; use sfa.util.rspecHelper directly
[sface.git] / sface / screens / configscreen.py
index 077ee1b..97e697c 100644 (file)
@@ -5,33 +5,54 @@ from PyQt4.QtGui import *
 from sface.config import config
 from sface.screens.sfascreen import SfaScreen
 
+static_labels = {
+    'registry': "usual port for registry: 12345",
+    'slicemgr': ["usual port for slice manager: 12347","usual port for aggregate: 12346"],
+}        
+
 class ConfigWidget(QWidget):
     def __init__(self, parent):
         QWidget.__init__(self, parent)
 
-        layout = QVBoxLayout()
+        glayout = QGridLayout()
+        row = 0
         for (field,msg) in config.field_labels():
-            # label
-            layout.addWidget(QLabel(msg,self))
             # edit : text or checkbox
             default=config.field_default(field)
+            if static_labels.has_key(field):
+                labels=static_labels[field]
+                if not isinstance(labels,list): labels = [ labels, ]
+                for label in labels:
+                    glayout.addWidget(QLabel(label),row,1)
+                    row+=1
             if isinstance(default,bool):
                 edit=QCheckBox(msg)
                 if config.is_true(config.get(field)):
                     edit.setCheckState(Qt.Checked)
             else:
-                edit=QLineEdit(config.get(field), self)
+                edit=QLineEdit(config.get(field) or "", self)
                 edit.setAttribute(Qt.WA_MacShowFocusRect, 0)
             setattr(self,field,edit)
-            layout.addWidget (edit)
 
+            glayout.addWidget(QLabel(msg+":",self), row, 0)
+            glayout.addWidget(edit, row, 1)
+
+            row += 1
+
+        hlayout = QHBoxLayout()
+        hlayout.addStretch()
         for (action,label) in [('apply','Apply'),
                                ('save','Apply && Save')]:
             button=QPushButton(label, self)
             button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
-            layout.addWidget(button, 0, Qt.AlignRight)
-            layout.addStretch()
+            hlayout.addWidget(button, 0, Qt.AlignRight)
+            hlayout.addSpacing(10)
             self.connect(button, SIGNAL('clicked()'), getattr(self,action))
+
+        layout = QVBoxLayout()
+        layout.addLayout(glayout)
+        layout.addLayout(hlayout)
+        layout.addStretch()
         self.setLayout(layout)
 
 
@@ -49,6 +70,9 @@ class ConfigWidget(QWidget):
         self.parent().setStatus("<font color='green'>Settings loaded for current session</font>", timeout=5000)
         config.display("after apply")
 
+        self.parent().signalAll('configurationChanged')
+
+
     def save(self):
         self.apply()
         config.save_config()
@@ -60,3 +84,4 @@ class ConfigScreen(SfaScreen):
         
         widget = ConfigWidget(self)
         self.init(widget, "Configure", "Configure the OneLab Federation GUI")
+