aboutsummaryrefslogtreecommitdiff
path: root/mesongui.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-10-18 20:55:10 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-10-18 20:55:10 +0300
commitae06ca2afc58901d9d72f13f662701cf12281b51 (patch)
tree25421861a84584438b39a3972b62d7398ac5d99b /mesongui.py
parent4a899f2d9becbd204e6f63dbf4fb7be921a1ce71 (diff)
downloadmeson-ae06ca2afc58901d9d72f13f662701cf12281b51.zip
meson-ae06ca2afc58901d9d72f13f662701cf12281b51.tar.gz
meson-ae06ca2afc58901d9d72f13f662701cf12281b51.tar.bz2
User options now do a full round trip.
Diffstat (limited to 'mesongui.py')
-rwxr-xr-xmesongui.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/mesongui.py b/mesongui.py
index 8c29178..2f9cac7 100755
--- a/mesongui.py
+++ b/mesongui.py
@@ -234,8 +234,7 @@ class CoreModel(QAbstractItemModel):
return QModelIndex()
class OptionForm:
- def __init__(self, build, coredata, form):
- self.build = build
+ def __init__(self, coredata, form):
self.coredata = coredata
self.form = form
form.addRow(PyQt5.QtWidgets.QLabel("Meson options"))
@@ -262,25 +261,48 @@ class OptionForm:
self.set_user_options()
def set_user_options(self):
- options = self.build.user_options
+ options = self.coredata.user_options
keys = list(options.keys())
keys.sort()
+ self.opt_keys = keys
+ self.opt_widgets = []
for key in keys:
opt = options[key]
if isinstance(opt, optinterpreter.UserStringOption):
w = PyQt5.QtWidgets.QLineEdit(opt.value)
+ w.textChanged.connect(self.user_option_changed)
elif isinstance(opt, optinterpreter.UserBooleanOption):
w = QCheckBox('')
w.setChecked(opt.value)
+ w.stateChanged.connect(self.user_option_changed)
elif isinstance(opt, optinterpreter.UserComboOption):
w = QComboBox()
for i in opt.choices:
w.addItem(i)
w.setCurrentText(opt.value)
+ w.currentTextChanged.connect(self.user_option_changed)
else:
raise RuntimeError("Unknown option type")
+ self.opt_widgets.append(w)
self.form.addRow(opt.description, w)
+ def user_option_changed(self, dummy=None):
+ for i in range(len(self.opt_keys)):
+ key = self.opt_keys[i]
+ w = self.opt_widgets[i]
+ if isinstance(w, PyQt5.QtWidgets.QLineEdit):
+ newval = w.text()
+ elif isinstance(w, QComboBox):
+ newval = w.currentText()
+ elif isinstance(w, QCheckBox):
+ if w.checkState() == 0:
+ newval = False
+ else:
+ newval = True
+ else:
+ raise RuntimeError('Unknown widget type')
+ self.coredata.user_options[key].value = newval
+
def build_type_changed(self, newtype):
self.coredata.buildtype = newtype
@@ -362,7 +384,7 @@ class MesonGui():
self.build_dir = self.build.environment.build_dir
self.src_dir = self.build.environment.source_dir
self.build_models()
- self.options = OptionForm(self.build, self.coredata, self.ui.option_form)
+ self.options = OptionForm(self.coredata, self.ui.option_form)
self.ui.show()
def build_models(self):