From f6e511e43c8a3d8742c309bd14d6b05fc28d8747 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 11 Feb 2015 12:33:13 +0200 Subject: [PATCH] Set and dynamically refresh locale settings for tool property browser. --HG-- branch : feature --- src/app/mainwindow.cpp | 7 ++++--- src/app/widgets/doubledelegate.cpp | 1 + src/app/widgets/textdelegate.cpp | 1 + src/app/widgets/vformulaproperty.cpp | 2 +- src/app/widgets/vtooloptionspropertybrowser.cpp | 8 ++++++++ src/app/widgets/vtooloptionspropertybrowser.h | 1 + src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/venumproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vfileproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp | 2 ++ src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp | 1 + src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp | 2 +- src/libs/vpropertyexplorer/plugins/vstringproperty.cpp | 1 + 15 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index b06ca4732..9e35e4b2d 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -84,7 +84,6 @@ MainWindow::MainWindow(QWidget *parent) recentFileActs[i] = nullptr; } - WindowsLocale(); CreateActions(); CreateMenus(); ToolBarDraws(); @@ -135,6 +134,7 @@ MainWindow::MainWindow(QWidget *parent) PropertyBrowser(); setCurrentFile(""); + WindowsLocale(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1144,6 +1144,7 @@ void MainWindow::ArrowTool() ui->actionArrowTool->setChecked(true); ui->actionStopTool->setEnabled(false); tool = Tool::Arrow; + emit EnableItemMove(true); QCursor cur(Qt::ArrowCursor); ui->view->setCursor(cur); helpLabel->setText(""); @@ -1403,8 +1404,8 @@ void MainWindow::Open() void MainWindow::Preferences() { ConfigDialog dlg(this); - connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); - connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); + connect(&dlg, &ConfigDialog::UpdateProperties, this, &MainWindow::WindowsLocale); // Must be first + connect(&dlg, &ConfigDialog::UpdateProperties, toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); if (dlg.exec() == QDialog::Accepted) { InitAutoSave(); diff --git a/src/app/widgets/doubledelegate.cpp b/src/app/widgets/doubledelegate.cpp index 981ad3d0d..f375376a6 100644 --- a/src/app/widgets/doubledelegate.cpp +++ b/src/app/widgets/doubledelegate.cpp @@ -53,6 +53,7 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption Q_UNUSED(index); emit NewLastValue(-10001.0);//Here need reset value to default because we begin work with new item QDoubleSpinBox *editor = new QDoubleSpinBox(parent); + editor->setLocale(parent->locale()); editor->setMinimum(-10000.0); editor->setMaximum(10000.0); connect(editor, &QDoubleSpinBox::editingFinished, this, &DoubleSpinBoxDelegate::commitAndCloseEditor); diff --git a/src/app/widgets/textdelegate.cpp b/src/app/widgets/textdelegate.cpp index 296dd1507..a02fadece 100644 --- a/src/app/widgets/textdelegate.cpp +++ b/src/app/widgets/textdelegate.cpp @@ -58,6 +58,7 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem Q_UNUSED(option); Q_UNUSED(index); QLineEdit *editor = new QLineEdit(parent); + editor->setLocale(parent->locale()); //Same regex pattern in xsd file editor->setValidator( new QRegExpValidator(QRegExp(regex)) ); connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor); diff --git a/src/app/widgets/vformulaproperty.cpp b/src/app/widgets/vformulaproperty.cpp index 09fbd2057..4e32e8bf9 100644 --- a/src/app/widgets/vformulaproperty.cpp +++ b/src/app/widgets/vformulaproperty.cpp @@ -94,7 +94,7 @@ QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewI VFormula formula = VProperty::d_ptr->VariantValue.value(); VFormulaPropertyEditor* tmpEditor = new VFormulaPropertyEditor(parent); - + tmpEditor->setLocale(parent->locale()); tmpEditor->SetFormula(formula); VProperty::d_ptr->editor = tmpEditor; return VProperty::d_ptr->editor; diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index d565d45e5..63dff0c6c 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -232,6 +232,14 @@ void VToolOptionsPropertyBrowser::UpdateOptions() } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::RefreshOptions() +{ + QGraphicsItem *item = currentItem; + itemClicked(nullptr);//close options + itemClicked(item);//reopen options +} + //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) { diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h index 50a4d9ed8..4e28e7a5f 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.h +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -51,6 +51,7 @@ public slots: void itemClicked(QGraphicsItem *item); void userChangedData(VPE::VProperty* property); void UpdateOptions(); + void RefreshOptions(); private: Q_DISABLE_COPY(VToolOptionsPropertyBrowser) diff --git a/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp index 38a1791a9..fc27d18f2 100644 --- a/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp @@ -58,6 +58,7 @@ QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewIte Q_UNUSED(delegate); VColorPropertyEditor* tmpWidget = new VColorPropertyEditor(parent); + tmpWidget->setLocale(parent->locale()); tmpWidget->SetColor(d_ptr->VariantValue.value()); return tmpWidget; } diff --git a/src/libs/vpropertyexplorer/plugins/venumproperty.cpp b/src/libs/vpropertyexplorer/plugins/venumproperty.cpp index 30330044d..14d3d5ea7 100644 --- a/src/libs/vpropertyexplorer/plugins/venumproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/venumproperty.cpp @@ -70,6 +70,7 @@ QWidget* VEnumProperty::createEditor(QWidget * parent, const QStyleOptionViewIte Q_UNUSED(delegate); QComboBox* tmpEditor = new QComboBox(parent); tmpEditor->clear(); + tmpEditor->setLocale(parent->locale()); tmpEditor->addItems(EnumerationLiterals); tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt()); connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, diff --git a/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp b/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp index 4434675d0..8e965fabf 100644 --- a/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfileproperty.cpp @@ -87,6 +87,7 @@ QWidget* VFileProperty::createEditor(QWidget * parent, const QStyleOptionViewIte VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*))); } + tmpWidget->setLocale(parent->locale()); tmpWidget->setFilter(static_cast(d_ptr)->FileFilters); // todo: parse this string tmpWidget->setFile(d_ptr->VariantValue.toString()); tmpWidget->setDirectory(static_cast(d_ptr)->Directory); diff --git a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp index f4fce1de4..58c03b877 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp @@ -86,6 +86,7 @@ QWidget *VLineColorProperty::createEditor(QWidget *parent, const QStyleOptionVie ++i; } + tmpEditor->setLocale(parent->locale()); tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt()); connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, &VLineColorProperty::currentIndexChanged); diff --git a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp index a5305dbee..c449096fd 100644 --- a/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vlinetypeproperty.cpp @@ -76,6 +76,7 @@ QWidget *VLineTypeProperty::createEditor(QWidget *parent, const QStyleOptionView Q_UNUSED(delegate); QComboBox* tmpEditor = new QComboBox(parent); tmpEditor->clear(); + tmpEditor->setLocale(parent->locale()); tmpEditor->setIconSize(QSize(80, 14)); tmpEditor->setMinimumWidth(80); tmpEditor->setMaximumWidth(110); diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp index b86def022..65ee10a1a 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp @@ -56,6 +56,7 @@ QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionView Q_UNUSED(delegate); QSpinBox* tmpEditor = new QSpinBox(parent); + tmpEditor->setLocale(parent->locale()); tmpEditor->setMinimum(static_cast(minValue)); tmpEditor->setMaximum(static_cast(maxValue)); tmpEditor->setSingleStep(static_cast(singleStep)); @@ -162,6 +163,7 @@ QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewI Q_UNUSED(options); Q_UNUSED(delegate); QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent); + tmpEditor->setLocale(parent->locale()); tmpEditor->setMinimum(minValue); tmpEditor->setMaximum(maxValue); tmpEditor->setDecimals(Precision); diff --git a/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp b/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp index 513d8d812..d117e764e 100644 --- a/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vobjectproperty.cpp @@ -64,6 +64,7 @@ QWidget* VObjectProperty::createEditor(QWidget * parent, const QStyleOptionViewI Q_UNUSED(delegate); QComboBox* tmpEditor = new QComboBox(parent); tmpEditor->clear(); + tmpEditor->setLocale(parent->locale()); FillList(tmpEditor, objects); tmpEditor->setCurrentIndex(tmpEditor->findData(VProperty::d_ptr->VariantValue.toUInt())); connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, diff --git a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp index f51346d54..6d10a23f2 100644 --- a/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vshortcutproperty.cpp @@ -61,7 +61,7 @@ QWidget* VShortcutProperty::createEditor(QWidget * parent, const QStyleOptionVie { VShortcutEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*))); } - + tmpWidget->setLocale(parent->locale()); return tmpWidget; } diff --git a/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp b/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp index d4bac678c..08341ded4 100644 --- a/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vstringproperty.cpp @@ -50,6 +50,7 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV Q_UNUSED(delegate); QLineEdit* tmpEditor = new QLineEdit(parent); + tmpEditor->setLocale(parent->locale()); tmpEditor->setReadOnly(readOnly); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setText(d_ptr->VariantValue.toString());