aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-10-18 20:15:49 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-10-18 20:15:49 +0300
commit4a899f2d9becbd204e6f63dbf4fb7be921a1ce71 (patch)
tree26aa4981b9fb906c9daa0da9b1b43d9c2e1c9431
parent75edffd34d4eec9c1580b2c33dac3e8f7573d77f (diff)
downloadmeson-4a899f2d9becbd204e6f63dbf4fb7be921a1ce71.zip
meson-4a899f2d9becbd204e6f63dbf4fb7be921a1ce71.tar.gz
meson-4a899f2d9becbd204e6f63dbf4fb7be921a1ce71.tar.bz2
Turn user options into for widgets.
-rwxr-xr-xmesongui.py32
-rw-r--r--optinterpreter.py6
-rw-r--r--test cases/common/47 options/meson_options.txt2
3 files changed, 34 insertions, 6 deletions
diff --git a/mesongui.py b/mesongui.py
index 3a8a8cf..8c29178 100755
--- a/mesongui.py
+++ b/mesongui.py
@@ -15,7 +15,7 @@
# limitations under the License.
import sys, os, pickle, time, shutil
-import build, coredata, environment
+import build, coredata, environment, optinterpreter
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication, QMainWindow, QHeaderView
from PyQt5.QtWidgets import QComboBox, QCheckBox
@@ -234,9 +234,11 @@ class CoreModel(QAbstractItemModel):
return QModelIndex()
class OptionForm:
- def __init__(self, cdata, form):
- self.coredata = cdata
+ def __init__(self, build, coredata, form):
+ self.build = build
+ self.coredata = coredata
self.form = form
+ form.addRow(PyQt5.QtWidgets.QLabel("Meson options"))
combo = QComboBox()
combo.addItem('plain')
combo.addItem('debug')
@@ -256,6 +258,28 @@ class OptionForm:
pch.setChecked(self.coredata.use_pch)
pch.stateChanged.connect(self.pch_changed)
self.form.addRow('Enable pch', pch)
+ form.addRow(PyQt5.QtWidgets.QLabel("Project options"))
+ self.set_user_options()
+
+ def set_user_options(self):
+ options = self.build.user_options
+ keys = list(options.keys())
+ keys.sort()
+ for key in keys:
+ opt = options[key]
+ if isinstance(opt, optinterpreter.UserStringOption):
+ w = PyQt5.QtWidgets.QLineEdit(opt.value)
+ elif isinstance(opt, optinterpreter.UserBooleanOption):
+ w = QCheckBox('')
+ w.setChecked(opt.value)
+ elif isinstance(opt, optinterpreter.UserComboOption):
+ w = QComboBox()
+ for i in opt.choices:
+ w.addItem(i)
+ w.setCurrentText(opt.value)
+ else:
+ raise RuntimeError("Unknown option type")
+ self.form.addRow(opt.description, w)
def build_type_changed(self, newtype):
self.coredata.buildtype = newtype
@@ -338,7 +362,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.coredata, self.ui.option_form)
+ self.options = OptionForm(self.build, self.coredata, self.ui.option_form)
self.ui.show()
def build_models(self):
diff --git a/optinterpreter.py b/optinterpreter.py
index 9d23536..0b87e04 100644
--- a/optinterpreter.py
+++ b/optinterpreter.py
@@ -23,6 +23,7 @@ class OptionException(coredata.MesonException):
class UserOption:
def __init__(self, kwargs):
super().__init__()
+ self.description = kwargs.get('description', '')
class UserStringOption(UserOption):
def __init__(self, kwargs):
@@ -127,4 +128,7 @@ class OptionInterpreter:
opt_name = posargs[0]
if not isinstance(opt_name, str):
raise OptionException('Positional argument must be a string.')
- self.options[opt_name] = option_types[opt_type](kwargs)
+ opt = option_types[opt_type](kwargs)
+ if opt.description == '':
+ opt.description = opt_name
+ self.options[opt_name] = opt
diff --git a/test cases/common/47 options/meson_options.txt b/test cases/common/47 options/meson_options.txt
index fcd3db4..653dd75 100644
--- a/test cases/common/47 options/meson_options.txt
+++ b/test cases/common/47 options/meson_options.txt
@@ -1,3 +1,3 @@
-option('testoption', type : 'string', value : 'optval')
+option('testoption', type : 'string', value : 'optval', description : 'An option to do something')
option('other_one', type : 'boolean', value : false)
option('combo_opt', type : 'combo', choices : ['one', 'two', 'combo'], value : 'combo')