diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-07-24 20:58:16 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-07-24 20:58:16 +0200 |
| commit | d7de7fe9427df19497b336dd4a5eca61055bd437 (patch) | |
| tree | a2031bed2f51cebe3d1033bd4c48824426d7c88e /src/gui_qt.cc | |
| parent | 7fbc163ed0d3e6d7f803486518bdd36e4c3bbbf6 (diff) | |
Add description to GuiForm fields
And improve GTK implementation of GuiForm to use GtkGrid instead
of GtkBox
Diffstat (limited to 'src/gui_qt.cc')
| -rw-r--r-- | src/gui_qt.cc | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/gui_qt.cc b/src/gui_qt.cc index cc2ad0d..596ddda 100644 --- a/src/gui_qt.cc +++ b/src/gui_qt.cc @@ -839,13 +839,15 @@ public: } void add_string(std::string const& id, std::string const& label, - std::string const& value) override { - values_.emplace_back(new StringValue(id, label, value)); + std::string const& value, + std::string const& description) override { + values_.emplace_back(new StringValue(id, label, description, value)); } void add_number(std::string const& id, std::string const& label, - uint64_t value) override { - values_.emplace_back(new NumberValue(id, label, value)); + uint64_t value, + std::string const& description) override { + values_.emplace_back(new NumberValue(id, label, description, value)); } std::string get_string(std::string const& id) const override { @@ -904,10 +906,13 @@ protected: Type const type_; std::string const id_; std::string const label_; + std::string const description_; QLineEdit* edit_; - Value(Type type, std::string const& id, std::string const& label) - : type_(type), id_(id), label_(label), edit_(nullptr) { + Value(Type type, std::string const& id, std::string const& label, + std::string const& description) + : type_(type), id_(id), label_(label), description_(description), + edit_(nullptr) { } }; @@ -915,8 +920,9 @@ protected: std::string value_; StringValue(std::string const& id, std::string const& label, + std::string const& description, std::string const& value) - : Value(STRING, id, label), value_(value) { + : Value(STRING, id, label, description), value_(value) { } }; @@ -924,8 +930,9 @@ protected: uint64_t value_; NumberValue(std::string const& id, std::string const& label, + std::string const& description, uint64_t value) - : Value(NUMBER, id, label), value_(value) { + : Value(NUMBER, id, label, description), value_(value) { } }; @@ -972,6 +979,13 @@ protected: layout->addWidget(label, row, 0); layout->addWidget(edit, row, 1); ++row; + if (!value->description_.empty()) { + auto desc = new QLabel( + QString::fromStdString("<i>" + value->description_ + "</i>")); + desc->setAlignment(Qt::AlignTrailing); + desc->setWordWrap(true); + layout->addWidget(desc, row++, 0, 1, 2); + } } error_ = new QLabel(); layout->addWidget(error_, row++, 0, 1, 2); |
