Skip to content

Commit

Permalink
firewall-applet: Fix Ok button sensitivity in dialogs
Browse files Browse the repository at this point in the history
The Ok buttons in dialogs only should be sensitive, if there have ben changes
in the dialog. The use of setEnabled does not have a good result, but
setDisabled is working as expected.

Also call combo_changed in the end of set_zone.

Dropped unused combo arg in combo_changed.

Call set_zone late in create_ui.
  • Loading branch information
t-woerner committed Jun 29, 2015
1 parent 3a1f22c commit 7c03a34
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/firewall-applet
Expand Up @@ -105,7 +105,6 @@ class ZoneInterfaceEditor(QtGui.QDialog):

self.combo = QtGui.QComboBox()
self.fill_zone_combo()
self.set_zone(zone)
vbox.addWidget(self.combo)

buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok
Expand All @@ -114,17 +113,19 @@ class ZoneInterfaceEditor(QtGui.QDialog):
buttonBox.accepted.connect(self.ok)
buttonBox.rejected.connect(self.hide)
vbox.addWidget(buttonBox)
self.ok_button.setEnabled(False)
self.ok_button.setDisabled(True)

self.combo.activated.connect(self.combo_changed)
self.setLayout(vbox)
self.set_zone(zone)

def combo_changed(self, combo):
self.ok_button.setEnabled(self.get_zone() != self.zone)
def combo_changed(self):
self.ok_button.setDisabled(self.get_zone() == self.zone)

def set_zone(self, zone):
self.zone = zone
self.combo.setCurrentIndex(self.combo.findText(self.zone))
self.combo_changed()

def get_zone(self):
text = str(self.combo.currentText())
Expand Down

0 comments on commit 7c03a34

Please sign in to comment.