/*!
\brief This function is called when the spinbox recieves key press event.
*/
-void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e)
-{
- if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
- QWidget::keyPressEvent(e);
- } else {
- ModuleBase_DoubleSpinBox::keyPressEvent(e);
- }
-}
+//void ModuleBase_ParamSpinBox::keyPressEvent(QKeyEvent* e)
+//{
+// if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
+// QWidget::keyPressEvent(e);
+// } else {
+// ModuleBase_DoubleSpinBox::keyPressEvent(e);
+// }
+//}
/*!
\brief This function is called when the spinbox recieves show event.
bool isAcceptVariables() const;
bool hasVariable() const;
-signals:
- void textChanged(const QString&);
+//signals:
+ //void textChanged(const QString&);
protected:
bool hasVariable(const QString& theText) const;
bool findVariable(const QString&, double&) const;
protected:
- virtual void keyPressEvent(QKeyEvent*);
+ //virtual void keyPressEvent(QKeyEvent*);
virtual void showEvent(QShowEvent*);
protected slots:
#include <QWidgetAction>
#include <QRegExp>
#include <QRegExpValidator>
+#include <QDesktopWidget>
+#include <QDialog>
+#include <QLayout>
ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
const Config_WidgetAPI* theData,
void editedValue(double& outValue, QString& outText)
{
- QMenu* aPopup = new QMenu();
+ QDialog aDlg(QApplication::desktop(), Qt::Popup/* | Qt::FramelessWindowHint*/);
+ QHBoxLayout* aLay = new QHBoxLayout(&aDlg);
+ aLay->setContentsMargins(2, 2, 2, 2);
- QLineEdit* aEditor = new QLineEdit(QString::number(outValue), aPopup);
- QWidgetAction* aLineEditAction = new QWidgetAction(aPopup);
- aLineEditAction->setDefaultWidget(aEditor);
- aPopup->addAction(aLineEditAction);
+ ModuleBase_ParamSpinBox* aEditor = new ModuleBase_ParamSpinBox(&aDlg);
+ aEditor->setMinimum(0);
+ aEditor->setMaximum(DBL_MAX);
+ aEditor->setValue(outValue);
+ aLay->addWidget(aEditor);
aEditor->setFocus();
aEditor->selectAll();
- QString anExpression("([0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)|([_a-zA-Z][a-zA-Z0-9_]*)");
- aEditor->setValidator(new QRegExpValidator(QRegExp(anExpression), aEditor));
- QObject::connect(aEditor, SIGNAL(returnPressed()), aLineEditAction, SIGNAL(triggered()));
- QObject::connect(aLineEditAction, SIGNAL(triggered()), aPopup, SLOT(hide()));
+ QObject::connect(aEditor, SIGNAL(editingFinished()), &aDlg, SLOT(accept()));
- QAction* aResult = aPopup->exec(QCursor::pos());
+ aDlg.move(QCursor::pos());
+ aDlg.exec();
outText = aEditor->text();
bool isDouble;
double aValue = outText.toDouble(&isDouble);
outValue = aValue;
outText = ""; // return empty string, if it's can be converted to a double
}
- aPopup->deleteLater();
}
bool ModuleBase_WidgetEditor::focusTo()