Commit 51b6b612 authored by Alexander Semke's avatar Alexander Semke

Automatically update locale dependent widgets in Worksheet and Plot

properties widgets on settings changes. Needs to be done similarly for
all other properties widgets.
parent 65d9e0e0
......@@ -2257,7 +2257,22 @@ void MainWin::handleSettingsChanges() {
}
}
//update the locale
auto* widget = stackedWidget->currentWidget();
BaseDock* dock = dynamic_cast<BaseDock*>(widget);
qDebug() << "dock " << dock;
if (dock)
dock->updateLocale();
else {
auto* labelWidget = dynamic_cast<LabelWidget*>(widget);
if (labelWidget)
labelWidget->updateUnits();
}
//update the units
//TODO: implement similar to the update of the locale above:
//update for the current dock widget only,
//for others the settings will be updated once the user selects them
if (stackedWidget) {
for (int i = 0; i < stackedWidget->count(); ++i) {
auto* widget = stackedWidget->widget(i);
......
......@@ -60,6 +60,7 @@ public:
enum class Units {Metric, Imperial};
virtual void updateLocale() {};
virtual void updateUnits() {};
protected:
......
......@@ -285,17 +285,7 @@ void CartesianPlotDock::setPlots(QList<CartesianPlot*> list) {
labelWidget->setLabels(labels);
SET_NUMBER_LOCALE
ui.sbLeft->setLocale(numberLocale);
ui.sbTop->setLocale(numberLocale);
ui.sbWidth->setLocale(numberLocale);
ui.sbHeight->setLocale(numberLocale);
ui.sbBorderWidth->setLocale(numberLocale);
ui.sbBorderCornerRadius->setLocale(numberLocale);
ui.sbPaddingHorizontal->setLocale(numberLocale);
ui.sbPaddingVertical->setLocale(numberLocale);
ui.sbPaddingRight->setLocale(numberLocale);
ui.sbPaddingBottom->setLocale(numberLocale);
updateLocale();
//if there is more then one plot in the list, disable the name and comment fields in the tab "general"
if (list.size() == 1) {
......@@ -388,6 +378,20 @@ void CartesianPlotDock::activateTitleTab() {
ui.tabWidget->setCurrentWidget(ui.tabTitle);
}
void CartesianPlotDock::updateLocale() {
SET_NUMBER_LOCALE
ui.sbLeft->setLocale(numberLocale);
ui.sbTop->setLocale(numberLocale);
ui.sbWidth->setLocale(numberLocale);
ui.sbHeight->setLocale(numberLocale);
ui.sbBorderWidth->setLocale(numberLocale);
ui.sbBorderCornerRadius->setLocale(numberLocale);
ui.sbPaddingHorizontal->setLocale(numberLocale);
ui.sbPaddingVertical->setLocale(numberLocale);
ui.sbPaddingRight->setLocale(numberLocale);
ui.sbPaddingBottom->setLocale(numberLocale);
}
void CartesianPlotDock::updateUnits() {
const KConfigGroup group = KSharedConfig::openConfig()->group(QLatin1String("Settings_General"));
BaseDock::Units units = (BaseDock::Units)group.readEntry("Units", static_cast<int>(Units::Metric));
......@@ -437,6 +441,7 @@ void CartesianPlotDock::updateUnits() {
labelWidget->updateUnits();
}
//************************************************************
//**** SLOTs for changes triggered in CartesianPlotDock ******
//************************************************************
......
......@@ -49,6 +49,7 @@ public:
explicit CartesianPlotDock(QWidget*);
void setPlots(QList<CartesianPlot*>);
void activateTitleTab();
void updateLocale() override;
void updateUnits() override;
private:
......
......@@ -158,15 +158,7 @@ void WorksheetDock::setWorksheets(QList<Worksheet*> list) {
m_worksheet = list.first();
m_aspect = list.first();
SET_NUMBER_LOCALE
ui.sbWidth->setLocale(numberLocale);
ui.sbHeight->setLocale(numberLocale);
ui.sbLayoutTopMargin->setLocale(numberLocale);
ui.sbLayoutBottomMargin->setLocale(numberLocale);
ui.sbLayoutLeftMargin->setLocale(numberLocale);
ui.sbLayoutRightMargin->setLocale(numberLocale);
ui.sbLayoutHorizontalSpacing->setLocale(numberLocale);
ui.sbLayoutVerticalSpacing->setLocale(numberLocale);
updateLocale();
//if there are more then one worksheet in the list, disable the name and comment field in the tab "general"
if (list.size() == 1) {
......@@ -223,6 +215,18 @@ void WorksheetDock::setWorksheets(QList<Worksheet*> list) {
m_initializing = false;
}
void WorksheetDock::updateLocale() {
SET_NUMBER_LOCALE
ui.sbWidth->setLocale(numberLocale);
ui.sbHeight->setLocale(numberLocale);
ui.sbLayoutTopMargin->setLocale(numberLocale);
ui.sbLayoutBottomMargin->setLocale(numberLocale);
ui.sbLayoutLeftMargin->setLocale(numberLocale);
ui.sbLayoutRightMargin->setLocale(numberLocale);
ui.sbLayoutHorizontalSpacing->setLocale(numberLocale);
ui.sbLayoutVerticalSpacing->setLocale(numberLocale);
}
void WorksheetDock::updateUnits() {
const KConfigGroup group = KSharedConfig::openConfig()->group(QLatin1String("Settings_General"));
BaseDock::Units units = (BaseDock::Units)group.readEntry("Units", static_cast<int>(Units::Metric));
......
......@@ -45,6 +45,7 @@ class WorksheetDock : public BaseDock {
public:
explicit WorksheetDock(QWidget*);
void setWorksheets(QList<Worksheet*>);
void updateLocale() override;
void updateUnits() override;
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment