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);
|
||||
#endif
|
||||
|
||||
ui->lineEditFind->installEventFilter(this);
|
||||
ui->plainTextEditFormula->installEventFilter(this);
|
||||
|
||||
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidget));
|
||||
ui->tabWidget->setVisible(false);
|
||||
|
||||
|
@ -556,6 +559,60 @@ void TMainWindow::showEvent(QShowEvent *event)
|
|||
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()
|
||||
{
|
||||
|
|
|
@ -68,6 +68,7 @@ protected:
|
|||
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
||||
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
void FileNew();
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<string/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabMeasurements">
|
||||
<attribute name="icon">
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "vformulapropertyeditor.h"
|
||||
#include "../vpropertyexplorer/vproperties.h"
|
||||
#include "../vpatterndb/vformula.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
|
||||
enum class ChildType : char {Invalid = 0, Value = 1, Formula = 2};
|
||||
|
||||
|
@ -48,12 +49,14 @@ VFormulaProperty::VFormulaProperty(const QString &name)
|
|||
addChild(tmpValue);
|
||||
tmpValue->setUpdateBehaviour(true, false);
|
||||
tmpValue->setReadOnly(true);
|
||||
tmpValue->setOsSeparator(qApp->Settings()->GetOsSeparator());
|
||||
tmpValue->setTypeForParent(static_cast<int>(ChildType::Value));
|
||||
|
||||
VStringProperty* tmpFormula = new VStringProperty(tr("Formula"));
|
||||
addChild(tmpFormula);
|
||||
tmpFormula->setClearButtonEnable(true);
|
||||
tmpFormula->setUpdateBehaviour(true, false);
|
||||
tmpFormula->setOsSeparator(qApp->Settings()->GetOsSeparator());
|
||||
tmpFormula->setTypeForParent(static_cast<int>(ChildType::Formula));
|
||||
|
||||
setValue(0);
|
||||
|
|
|
@ -68,9 +68,12 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
|||
ui->lineEditFind->setClearButtonEnabled(true);
|
||||
#endif
|
||||
|
||||
ui->lineEditFind->installEventFilter(this);
|
||||
|
||||
search = QSharedPointer<VTableSearch>(new VTableSearch(ui->tableWidgetIncrement));
|
||||
|
||||
formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||
ui->plainTextEditFormula->installEventFilter(this);
|
||||
|
||||
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C));
|
||||
|
||||
|
@ -726,7 +729,37 @@ void DialogIncrements::changeEvent(QEvent *event)
|
|||
FullUpdateFromFile();
|
||||
}
|
||||
// remember to call base class implementation
|
||||
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
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -59,8 +59,9 @@ signals:
|
|||
void FullUpdateTree(const Document &parse);
|
||||
|
||||
protected:
|
||||
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void changeEvent ( QEvent * event) Q_DECL_OVERRIDE;
|
||||
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void changeEvent ( QEvent * event) Q_DECL_OVERRIDE;
|
||||
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
void ShowIncrementDetails();
|
||||
void AddIncrement();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "vstringproperty.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QLatin1String>
|
||||
#include <QLineEdit>
|
||||
#include <QLocale>
|
||||
|
@ -38,7 +39,7 @@ using namespace VPE;
|
|||
|
||||
|
||||
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);
|
||||
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)
|
||||
: 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.convert(QVariant::String);
|
||||
|
@ -61,6 +62,7 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
|
|||
QLineEdit* tmpEditor = new QLineEdit(parent);
|
||||
tmpEditor->setLocale(parent->locale());
|
||||
tmpEditor->setReadOnly(readOnly);
|
||||
tmpEditor->installEventFilter(this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
|
||||
tmpEditor->setClearButtonEnabled(clearButton);
|
||||
#endif
|
||||
|
@ -87,6 +89,11 @@ void VPE::VStringProperty::setReadOnly(bool readOnly)
|
|||
this->readOnly = readOnly;
|
||||
}
|
||||
|
||||
void VStringProperty::setOsSeparator(bool separator)
|
||||
{
|
||||
m_osSeparator = separator;
|
||||
}
|
||||
|
||||
void VStringProperty::setClearButtonEnable(bool value)
|
||||
{
|
||||
this->clearButton = value;
|
||||
|
@ -150,3 +157,32 @@ void VStringProperty::setTypeForParent(int 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;
|
||||
|
||||
void setReadOnly(bool readOnly);
|
||||
void setOsSeparator(bool separator);
|
||||
void setClearButtonEnable(bool value);
|
||||
|
||||
//! Sets the settings.
|
||||
|
@ -94,6 +95,9 @@ protected:
|
|||
bool readOnly;
|
||||
int typeForParent;
|
||||
bool clearButton;
|
||||
bool m_osSeparator;
|
||||
|
||||
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VStringProperty)
|
||||
|
|
|
@ -346,8 +346,7 @@ void DialogTool::MoveCursorToEnd(QPlainTextEdit *plainTextEdit)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object);
|
||||
if (plainTextEdit != nullptr)
|
||||
if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(object))
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
|
@ -357,6 +356,18 @@ bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
|||
// 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
|
||||
|
@ -364,7 +375,7 @@ bool DialogTool::eventFilter(QObject *object, QEvent *event)
|
|||
// pass the event on to the parent class
|
||||
return QDialog::eventFilter(object, event);
|
||||
}
|
||||
return false;
|
||||
return false;// pass the event to the widget
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user