fix for empty sfi_config
[sface.git] / sface / screens / configscreen.py
index 077ee1b..80105a4 100644 (file)
@@ -9,10 +9,9 @@ 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 isinstance(default,bool):
@@ -20,18 +19,29 @@ class ConfigWidget(QWidget):
                 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 +59,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 +73,4 @@ class ConfigScreen(SfaScreen):
         
         widget = ConfigWidget(self)
         self.init(widget, "Configure", "Configure the OneLab Federation GUI")
+