+ add InputField to widget plugin
This commit is contained in:
parent
037eb8eee3
commit
d85f442089
|
@ -418,6 +418,106 @@ ActionSelector::~ActionSelector()
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
InputField::InputField (QWidget * parent)
|
||||||
|
: QLineEdit(parent),
|
||||||
|
Value(0),
|
||||||
|
Maximum(INT_MAX),
|
||||||
|
Minimum(-INT_MAX),
|
||||||
|
StepSize(1.0),
|
||||||
|
HistorySize(5)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
InputField::~InputField()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the preference path to \a path. */
|
||||||
|
void InputField::setParamGrpPath( const QByteArray& path )
|
||||||
|
{
|
||||||
|
m_sPrefGrp = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the widget's preferences path. */
|
||||||
|
QByteArray InputField::paramGrpPath() const
|
||||||
|
{
|
||||||
|
return m_sPrefGrp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// sets the field with a quantity
|
||||||
|
void InputField::setValue(double quant)
|
||||||
|
{
|
||||||
|
Value = quant;
|
||||||
|
setText(QString("%1 %2").arg(Value).arg(UnitStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// sets the field with a quantity
|
||||||
|
double InputField::getQuantity() const
|
||||||
|
{
|
||||||
|
return Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get the value of the singleStep property
|
||||||
|
double InputField::singleStep(void)const
|
||||||
|
{
|
||||||
|
return StepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set the value of the singleStep property
|
||||||
|
void InputField::setSingleStep(double s)
|
||||||
|
{
|
||||||
|
StepSize = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get the value of the maximum property
|
||||||
|
double InputField::maximum(void)const
|
||||||
|
{
|
||||||
|
return Maximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set the value of the maximum property
|
||||||
|
void InputField::setMaximum(double m)
|
||||||
|
{
|
||||||
|
Maximum = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get the value of the minimum property
|
||||||
|
double InputField::minimum(void)const
|
||||||
|
{
|
||||||
|
return Minimum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set the value of the minimum property
|
||||||
|
void InputField::setMinimum(double m)
|
||||||
|
{
|
||||||
|
Minimum = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputField::setUnitText(QString str)
|
||||||
|
{
|
||||||
|
UnitStr = str;
|
||||||
|
setText(QString("%1 %2").arg(Value).arg(UnitStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString InputField::getUnitText(void)
|
||||||
|
{
|
||||||
|
return UnitStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the value of the minimum property
|
||||||
|
int InputField::historySize(void)const
|
||||||
|
{
|
||||||
|
return HistorySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the value of the minimum property
|
||||||
|
void InputField::setHistorySize(int i)
|
||||||
|
{
|
||||||
|
HistorySize = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
CommandIconView::CommandIconView ( QWidget * parent )
|
CommandIconView::CommandIconView ( QWidget * parent )
|
||||||
: QListWidget(parent)
|
: QListWidget(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,12 @@
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
|
namespace Base {
|
||||||
|
class Quantity{};
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Base::Quantity)
|
||||||
|
|
||||||
namespace Gui
|
namespace Gui
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -203,6 +209,54 @@ private:
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class InputField : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QByteArray prefPath READ paramGrpPath WRITE setParamGrpPath )
|
||||||
|
Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep )
|
||||||
|
Q_PROPERTY(double maximum READ maximum WRITE setMaximum )
|
||||||
|
Q_PROPERTY(double minimum READ minimum WRITE setMinimum )
|
||||||
|
Q_PROPERTY(int historySize READ historySize WRITE setHistorySize )
|
||||||
|
Q_PROPERTY(QString unit READ getUnitText WRITE setUnitText )
|
||||||
|
Q_PROPERTY(double quantity READ getQuantity WRITE setValue )
|
||||||
|
|
||||||
|
public:
|
||||||
|
InputField (QWidget * parent = 0);
|
||||||
|
virtual ~InputField();
|
||||||
|
|
||||||
|
void setValue(double);
|
||||||
|
double getQuantity(void) const;
|
||||||
|
double singleStep(void) const;
|
||||||
|
void setSingleStep(double);
|
||||||
|
double maximum(void) const;
|
||||||
|
void setMaximum(double);
|
||||||
|
double minimum(void) const;
|
||||||
|
void setMinimum(double);
|
||||||
|
int historySize(void) const;
|
||||||
|
void setHistorySize(int);
|
||||||
|
void setUnitText(QString);
|
||||||
|
QString getUnitText(void);
|
||||||
|
QByteArray paramGrpPath () const;
|
||||||
|
void setParamGrpPath(const QByteArray& name);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void valueChanged(const Base::Quantity&);
|
||||||
|
void valueChanged(double);
|
||||||
|
void parseError(const QString& errorText);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QByteArray m_sPrefGrp;
|
||||||
|
QString UnitStr;
|
||||||
|
double Value;
|
||||||
|
double Maximum;
|
||||||
|
double Minimum;
|
||||||
|
double StepSize;
|
||||||
|
int HistorySize;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
class CommandIconView : public QListWidget
|
class CommandIconView : public QListWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
@ -453,6 +453,86 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* XPM */
|
||||||
|
static const char *inputfield_pixmap[]={
|
||||||
|
"22 22 6 1",
|
||||||
|
"a c #000000",
|
||||||
|
"# c #000080",
|
||||||
|
"b c #008080",
|
||||||
|
"c c #808080",
|
||||||
|
"d c #c0c0c0",
|
||||||
|
". c #ffffff",
|
||||||
|
"......................",
|
||||||
|
"......................",
|
||||||
|
"......................",
|
||||||
|
"...#aaaaaaaaaaaaaa#...",
|
||||||
|
".baccccccccccccccccab.",
|
||||||
|
".acccddddddddddddddca.",
|
||||||
|
"#ccd................d#",
|
||||||
|
"acc.................da",
|
||||||
|
"acd.......d....ca.ac.a",
|
||||||
|
"acd......db......a...a",
|
||||||
|
"acd.dbbb.dbbbd...a...a",
|
||||||
|
"acd.ccdbddb.db...a...a",
|
||||||
|
"acd.dbbbddb..b...a...a",
|
||||||
|
"acd.bd.bddb..b...a...a",
|
||||||
|
"acd.bbbbddbbbc...a...a",
|
||||||
|
"acd..d.....dd..ca.acda",
|
||||||
|
"#cd.................d#",
|
||||||
|
".ac................da.",
|
||||||
|
".badd............dda#.",
|
||||||
|
"...#aaaaaaaaaaaaaa#...",
|
||||||
|
"......................",
|
||||||
|
"......................"};
|
||||||
|
|
||||||
|
class InputFieldPlugin : public QDesignerCustomWidgetInterface
|
||||||
|
{
|
||||||
|
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||||
|
public:
|
||||||
|
InputFieldPlugin()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
QWidget *createWidget(QWidget *parent)
|
||||||
|
{
|
||||||
|
return new Gui::InputField(parent);
|
||||||
|
}
|
||||||
|
QString group() const
|
||||||
|
{
|
||||||
|
return QLatin1String("Input Widgets");
|
||||||
|
}
|
||||||
|
QIcon icon() const
|
||||||
|
{
|
||||||
|
return QIcon( QPixmap( inputfield_pixmap ) );
|
||||||
|
}
|
||||||
|
QString includeFile() const
|
||||||
|
{
|
||||||
|
return QLatin1String("Gui/InputField.h");
|
||||||
|
}
|
||||||
|
QString toolTip() const
|
||||||
|
{
|
||||||
|
return QLatin1String("Input Field");
|
||||||
|
}
|
||||||
|
QString whatsThis() const
|
||||||
|
{
|
||||||
|
return QLatin1String("A widget to work qith quantities.");
|
||||||
|
}
|
||||||
|
bool isContainer() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QString domXml() const
|
||||||
|
{
|
||||||
|
return "<ui language=\"c++\">\n"
|
||||||
|
" <widget class=\"Gui::InputField\" name=\"inputField\">\n"
|
||||||
|
" </widget>\n"
|
||||||
|
"</ui>";
|
||||||
|
}
|
||||||
|
QString name() const
|
||||||
|
{
|
||||||
|
return QLatin1String("Gui::InputField");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* XPM */
|
/* XPM */
|
||||||
static const char *iconview_pixmap[]={
|
static const char *iconview_pixmap[]={
|
||||||
"22 22 10 1",
|
"22 22 10 1",
|
||||||
|
@ -1252,6 +1332,7 @@ QList<QDesignerCustomWidgetInterface *> CustomWidgetPlugin::customWidgets () con
|
||||||
cw.append(new FileChooserPlugin);
|
cw.append(new FileChooserPlugin);
|
||||||
cw.append(new AccelLineEditPlugin);
|
cw.append(new AccelLineEditPlugin);
|
||||||
cw.append(new ActionSelectorPlugin);
|
cw.append(new ActionSelectorPlugin);
|
||||||
|
cw.append(new InputFieldPlugin);
|
||||||
cw.append(new CommandIconViewPlugin);
|
cw.append(new CommandIconViewPlugin);
|
||||||
cw.append(new UIntSpinBoxPlugin);
|
cw.append(new UIntSpinBoxPlugin);
|
||||||
cw.append(new ColorButtonPlugin);
|
cw.append(new ColorButtonPlugin);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user