Localize numeric keyboard's dot key according to locale and user preferences.
--HG-- branch : develop
This commit is contained in:
parent
be6c676145
commit
89ce8afe77
|
@ -110,6 +110,9 @@ TMainWindow::TMainWindow(QWidget *parent)
|
||||||
ui->lineEditEmail->setClearButtonEnabled(true);
|
ui->lineEditEmail->setClearButtonEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ui->lineEditFind->installEventFilter(this);
|
||||||
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget));
|
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget));
|
||||||
ui->tabWidget->setVisible(false);
|
ui->tabWidget->setVisible(false);
|
||||||
|
|
||||||
|
@ -556,6 +559,60 @@ void TMainWindow::showEvent(QShowEvent *event)
|
||||||
isInitialized = true;//first show windows are held
|
isInitialized = true;//first show windows are held
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool TMainWindow::eventFilter(QObject *object, QEvent *event)
|
||||||
|
{
|
||||||
|
if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object))
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
if ((keyEvent->key() == Qt::Key_Enter) || (keyEvent->key() == Qt::Key_Return))
|
||||||
|
{
|
||||||
|
// Ignore Enter key
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
||||||
|
{
|
||||||
|
if (qApp->Settings()->GetOsSeparator())
|
||||||
|
{
|
||||||
|
plainTextEdit->insertPlainText(QLocale::system().decimalPoint());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plainTextEdit->insertPlainText(QLocale::c().decimalPoint());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (QLineEdit *textEdit = qobject_cast<QLineEdit *>(object))
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
||||||
|
{
|
||||||
|
if (qApp->Settings()->GetOsSeparator())
|
||||||
|
{
|
||||||
|
textEdit->insert(QLocale::system().decimalPoint());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textEdit->insert(QLocale::c().decimalPoint());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// pass the event on to the parent class
|
||||||
|
return QMainWindow::eventFilter(object, event);
|
||||||
|
}
|
||||||
|
return false;// pass the event to the widget
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::FileSave()
|
void TMainWindow::FileSave()
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,6 +68,7 @@ protected:
|
||||||
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||||
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
|
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void FileNew();
|
void FileNew();
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabMeasurements">
|
<widget class="QWidget" name="tabMeasurements">
|
||||||
<attribute name="icon">
|
<attribute name="icon">
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "vformulapropertyeditor.h"
|
#include "vformulapropertyeditor.h"
|
||||||
#include "../vpropertyexplorer/vproperties.h"
|
#include "../vpropertyexplorer/vproperties.h"
|
||||||
#include "../vpatterndb/vformula.h"
|
#include "../vpatterndb/vformula.h"
|
||||||
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
|
||||||
enum class ChildType : char {Invalid = 0, Value = 1, Formula = 2};
|
enum class ChildType : char {Invalid = 0, Value = 1, Formula = 2};
|
||||||
|
|
||||||
|
@ -48,12 +49,14 @@ VFormulaProperty::VFormulaProperty(const QString &name)
|
||||||
addChild(tmpValue);
|
addChild(tmpValue);
|
||||||
tmpValue->setUpdateBehaviour(true, false);
|
tmpValue->setUpdateBehaviour(true, false);
|
||||||
tmpValue->setReadOnly(true);
|
tmpValue->setReadOnly(true);
|
||||||
|
tmpValue->setOsSeparator(qApp->Settings()->GetOsSeparator());
|
||||||
tmpValue->setTypeForParent(static_cast<int>(ChildType::Value));
|
tmpValue->setTypeForParent(static_cast<int>(ChildType::Value));
|
||||||
|
|
||||||
VStringProperty* tmpFormula = new VStringProperty(tr("Formula"));
|
VStringProperty* tmpFormula = new VStringProperty(tr("Formula"));
|
||||||
addChild(tmpFormula);
|
addChild(tmpFormula);
|
||||||
tmpFormula->setClearButtonEnable(true);
|
tmpFormula->setClearButtonEnable(true);
|
||||||
tmpFormula->setUpdateBehaviour(true, false);
|
tmpFormula->setUpdateBehaviour(true, false);
|
||||||
|
tmpFormula->setOsSeparator(qApp->Settings()->GetOsSeparator());
|
||||||
tmpFormula->setTypeForParent(static_cast<int>(ChildType::Formula));
|
tmpFormula->setTypeForParent(static_cast<int>(ChildType::Formula));
|
||||||
|
|
||||||
setValue(0);
|
setValue(0);
|
||||||
|
|
|
@ -68,9 +68,12 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
ui->lineEditFind->setClearButtonEnabled(true);
|
ui->lineEditFind->setClearButtonEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ui->lineEditFind->installEventFilter(this);
|
||||||
|
|
||||||
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidgetIncrement));
|
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidgetIncrement));
|
||||||
|
|
||||||
formulaBaseHeight = ui->plainTextEditFormula->height();
|
formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C));
|
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C));
|
||||||
|
|
||||||
|
@ -729,6 +732,36 @@ void DialogIncrements::changeEvent(QEvent *event)
|
||||||
QWidget::changeEvent(event);
|
QWidget::changeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogIncrements::eventFilter(QObject *object, QEvent *event)
|
||||||
|
{
|
||||||
|
if (QLineEdit *textEdit = qobject_cast<QLineEdit *>(object))
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
||||||
|
{
|
||||||
|
if (qApp->Settings()->GetOsSeparator())
|
||||||
|
{
|
||||||
|
textEdit->insert(QLocale::system().decimalPoint());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textEdit->insert(QLocale::c().decimalPoint());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// pass the event on to the parent class
|
||||||
|
return DialogTool::eventFilter(object, event);
|
||||||
|
}
|
||||||
|
return false;// pass the event to the widget
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogIncrements::ShowIncrementDetails()
|
void DialogIncrements::ShowIncrementDetails()
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,7 @@ signals:
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
|
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
|
||||||
virtual void changeEvent ( QEvent * event) Q_DECL_OVERRIDE;
|
virtual void changeEvent ( QEvent * event) Q_DECL_OVERRIDE;
|
||||||
|
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
||||||
private slots:
|
private slots:
|
||||||
void ShowIncrementDetails();
|
void ShowIncrementDetails();
|
||||||
void AddIncrement();
|
void AddIncrement();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "vstringproperty.h"
|
#include "vstringproperty.h"
|
||||||
|
|
||||||
|
#include <QKeyEvent>
|
||||||
#include <QLatin1String>
|
#include <QLatin1String>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
@ -38,7 +39,7 @@ using namespace VPE;
|
||||||
|
|
||||||
|
|
||||||
VPE::VStringProperty::VStringProperty(const QString &name, const QMap<QString, QVariant> &settings)
|
VPE::VStringProperty::VStringProperty(const QString &name, const QMap<QString, QVariant> &settings)
|
||||||
: VProperty(name, QVariant::String), readOnly(false), typeForParent(0), clearButton(false)
|
: VProperty(name, QVariant::String), readOnly(false), typeForParent(0), clearButton(false), m_osSeparator(false)
|
||||||
{
|
{
|
||||||
VProperty::setSettings(settings);
|
VProperty::setSettings(settings);
|
||||||
d_ptr->VariantValue.setValue(QString());
|
d_ptr->VariantValue.setValue(QString());
|
||||||
|
@ -46,7 +47,7 @@ VPE::VStringProperty::VStringProperty(const QString &name, const QMap<QString, Q
|
||||||
}
|
}
|
||||||
|
|
||||||
VPE::VStringProperty::VStringProperty(const QString &name)
|
VPE::VStringProperty::VStringProperty(const QString &name)
|
||||||
: VProperty(name), readOnly(false), typeForParent(0), clearButton(false)
|
: VProperty(name), readOnly(false), typeForParent(0), clearButton(false), m_osSeparator(false)
|
||||||
{
|
{
|
||||||
d_ptr->VariantValue.setValue(QString());
|
d_ptr->VariantValue.setValue(QString());
|
||||||
d_ptr->VariantValue.convert(QVariant::String);
|
d_ptr->VariantValue.convert(QVariant::String);
|
||||||
|
@ -61,6 +62,7 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
|
||||||
QLineEdit* tmpEditor = new QLineEdit(parent);
|
QLineEdit* tmpEditor = new QLineEdit(parent);
|
||||||
tmpEditor->setLocale(parent->locale());
|
tmpEditor->setLocale(parent->locale());
|
||||||
tmpEditor->setReadOnly(readOnly);
|
tmpEditor->setReadOnly(readOnly);
|
||||||
|
tmpEditor->installEventFilter(this);
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||||
tmpEditor->setClearButtonEnabled(clearButton);
|
tmpEditor->setClearButtonEnabled(clearButton);
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,6 +89,11 @@ void VPE::VStringProperty::setReadOnly(bool readOnly)
|
||||||
this->readOnly = readOnly;
|
this->readOnly = readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VStringProperty::setOsSeparator(bool separator)
|
||||||
|
{
|
||||||
|
m_osSeparator = separator;
|
||||||
|
}
|
||||||
|
|
||||||
void VStringProperty::setClearButtonEnable(bool value)
|
void VStringProperty::setClearButtonEnable(bool value)
|
||||||
{
|
{
|
||||||
this->clearButton = value;
|
this->clearButton = value;
|
||||||
|
@ -150,3 +157,32 @@ void VStringProperty::setTypeForParent(int value)
|
||||||
{
|
{
|
||||||
typeForParent = value;
|
typeForParent = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VStringProperty::eventFilter(QObject *object, QEvent *event)
|
||||||
|
{
|
||||||
|
if (QLineEdit *textEdit = qobject_cast<QLineEdit *>(object))
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
||||||
|
{
|
||||||
|
if (m_osSeparator)
|
||||||
|
{
|
||||||
|
textEdit->insert(QLocale::system().decimalPoint());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textEdit->insert(QLocale::c().decimalPoint());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// pass the event on to the parent class
|
||||||
|
return VProperty::eventFilter(object, event);
|
||||||
|
}
|
||||||
|
return false;// pass the event to the widget
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
virtual QVariant getEditorData(const QWidget* editor) const Q_DECL_OVERRIDE;
|
virtual QVariant getEditorData(const QWidget* editor) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void setReadOnly(bool readOnly);
|
void setReadOnly(bool readOnly);
|
||||||
|
void setOsSeparator(bool separator);
|
||||||
void setClearButtonEnable(bool value);
|
void setClearButtonEnable(bool value);
|
||||||
|
|
||||||
//! Sets the settings.
|
//! Sets the settings.
|
||||||
|
@ -94,6 +95,9 @@ protected:
|
||||||
bool readOnly;
|
bool readOnly;
|
||||||
int typeForParent;
|
int typeForParent;
|
||||||
bool clearButton;
|
bool clearButton;
|
||||||
|
bool m_osSeparator;
|
||||||
|
|
||||||
|
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VStringProperty)
|
Q_DISABLE_COPY(VStringProperty)
|
||||||
|
|
|
@ -346,8 +346,7 @@ void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
||||||
{
|
{
|
||||||
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object);
|
if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object))
|
||||||
if (plainTextEdit != nullptr)
|
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::KeyPress)
|
if (event->type() == QEvent::KeyPress)
|
||||||
{
|
{
|
||||||
|
@ -357,6 +356,18 @@ bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
||||||
// Ignore Enter key
|
// Ignore Enter key
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if ((keyEvent->key() == Qt::Key_Period) && (keyEvent->modifiers() & Qt::KeypadModifier))
|
||||||
|
{
|
||||||
|
if (qApp->Settings()->GetOsSeparator())
|
||||||
|
{
|
||||||
|
plainTextEdit->insertPlainText(QLocale::system().decimalPoint());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plainTextEdit->insertPlainText(QLocale::c().decimalPoint());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -364,7 +375,7 @@ bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
||||||
// pass the event on to the parent class
|
// pass the event on to the parent class
|
||||||
return QDialog::eventFilter(object, event);
|
return QDialog::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
return false;
|
return false;// pass the event to the widget
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user