OpenStructure
Loading...
Searching...
No Matches
tool_options_widget.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_GUI_TOOL_OPTIONS_WIDGET_HH
20#define OST_GUI_TOOL_OPTIONS_WIDGET_HH
21
22/*
23 Author: Marco Biasini
24 */
25
27
29
30#include <QWidget>
31
32namespace ost { namespace gui {
33
34class DLLEXPORT_OST_GUI EnumOptBinder : public QObject {
35 Q_OBJECT
36public:
38 EnumOptBinder(QObject* parent, ToolOptionEnum* enum_opt):
39 QObject(parent), enum_opt_(enum_opt)
40 { }
41public slots:
42 void IndexChanged(int index)
43 {
44 enum_opt_->SetIndex(index);
45 }
46private:
47 ToolOptionEnum* enum_opt_;
48};
49
50class DLLEXPORT_OST_GUI IntOptBinder : public QObject {
51 Q_OBJECT
52public:
54 IntOptBinder(QObject* parent, ToolOptionInt* int_opt):
55 QObject(parent), int_opt_(int_opt)
56 { }
57public slots:
58 void TextChanged(const QString& text)
59 {
60 int_opt_->SetValue(text.toInt());
61 }
62private:
63 ToolOptionInt* int_opt_;
64};
65
66class DLLEXPORT_OST_GUI FloatOptBinder : public QObject {
67 Q_OBJECT
68public:
70 FloatOptBinder(QObject* parent, ToolOptionFloat* float_opt):
71 QObject(parent), float_opt_(float_opt)
72 { }
73public slots:
74 void TextChanged(const QString& text)
75 {
76 float_opt_->SetValue(text.toFloat());
77 }
78private:
79 ToolOptionFloat* float_opt_;
80};
81
82class DLLEXPORT_OST_GUI ToolOptionsWidget : public QWidget {
83public:
84 ToolOptionsWidget(ToolOptions* options, QWidget* parent=NULL);
85private:
86 void Populate();
87 QWidget* MakeIntWidget(ToolOptionInt* opts);
88 QWidget* MakeEnumWidget(ToolOptionEnum* opts);
89 QWidget* MakeFloatWidget(ToolOptionFloat* opts);
90 QWidget* MakeButtonWidget(ToolOptionButton* opts);
91 ToolOptions* options_;
92};
93
94}}
95
96#endif
EnumOptBinder(QObject *parent, ToolOptionEnum *enum_opt)
FloatOptBinder(QObject *parent, ToolOptionFloat *float_opt)
void TextChanged(const QString &text)
void TextChanged(const QString &text)
IntOptBinder(QObject *parent, ToolOptionInt *int_opt)
ToolOptionsWidget(ToolOptions *options, QWidget *parent=NULL)
#define DLLEXPORT_OST_GUI
Definition base.dox:1