* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
+#include <cassert>
#include <QCheckBox>
-#include "bool.h"
+#include "bool.hpp"
namespace pv {
namespace prop {
-Bool::Bool(QString name, Getter getter, Setter setter) :
- Property(name, getter, setter),
- check_box_(NULL)
-{
-}
-
-Bool::~Bool()
+Bool::Bool(QString name, QString desc, Getter getter, Setter setter) :
+ Property(name, desc, getter, setter),
+ check_box_(nullptr)
{
}
return check_box_;
if (!getter_)
- return NULL;
+ return nullptr;
Glib::VariantBase variant = getter_();
if (!variant.gobj())
- return NULL;
-
- bool value = Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(
- variant).get();
+ return nullptr;
check_box_ = new QCheckBox(name(), parent);
- check_box_->setCheckState(value ? Qt::Checked : Qt::Unchecked);
+ check_box_->setToolTip(desc());
+
+ update_widget();
if (auto_commit)
connect(check_box_, SIGNAL(stateChanged(int)),
return true;
}
+void Bool::update_widget()
+{
+ if (!check_box_)
+ return;
+
+ Glib::VariantBase variant = getter_();
+ assert(variant.gobj());
+
+ bool value = Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(
+ variant).get();
+
+ check_box_->setCheckState(value ? Qt::Checked : Qt::Unchecked);
+}
+
void Bool::commit()
{
assert(setter_);
commit();
}
-} // prop
-} // pv
+} // namespace prop
+} // namespace pv