Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Education
LabPlot
Commits
4c541beb
Commit
4c541beb
authored
Jul 08, 2020
by
Stefan Gerlach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[settings] Add decimal separator selection
parent
9da04c54
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
17 deletions
+72
-17
src/kdefrontend/SettingsGeneralPage.cpp
src/kdefrontend/SettingsGeneralPage.cpp
+49
-0
src/kdefrontend/SettingsGeneralPage.h
src/kdefrontend/SettingsGeneralPage.h
+5
-0
src/kdefrontend/ui/settingsgeneralpage.ui
src/kdefrontend/ui/settingsgeneralpage.ui
+18
-17
No files found.
src/kdefrontend/SettingsGeneralPage.cpp
View file @
4c541beb
...
...
@@ -4,6 +4,7 @@
Description : general settings page
--------------------------------------------------------------------
Copyright : (C) 2008-2020 Alexander Semke (alexander.semke@web.de)
Copyright : (C) 2020 Stefan Gerlach (stefan.gerlach@uni.kn)
***************************************************************************/
...
...
@@ -27,6 +28,7 @@
***************************************************************************/
#include "SettingsGeneralPage.h"
#include "backend/lib/macros.h"
#include <KI18n/KLocalizedString>
#include <KConfigGroup>
...
...
@@ -46,6 +48,7 @@ SettingsGeneralPage::SettingsGeneralPage(QWidget* parent) : SettingsPage(parent)
connect
(
ui
.
cbMdiVisibility
,
QOverload
<
int
>::
of
(
&
QComboBox
::
currentIndexChanged
),
this
,
&
SettingsGeneralPage
::
changed
);
connect
(
ui
.
cbTabPosition
,
QOverload
<
int
>::
of
(
&
QComboBox
::
currentIndexChanged
),
this
,
&
SettingsGeneralPage
::
changed
);
connect
(
ui
.
cbUnits
,
QOverload
<
int
>::
of
(
&
QComboBox
::
currentIndexChanged
),
this
,
&
SettingsGeneralPage
::
changed
);
connect
(
ui
.
cbDecimalSeparator
,
QOverload
<
int
>::
of
(
&
QComboBox
::
currentIndexChanged
),
this
,
&
SettingsGeneralPage
::
changed
);
connect
(
ui
.
chkAutoSave
,
&
QCheckBox
::
stateChanged
,
this
,
&
SettingsGeneralPage
::
autoSaveChanged
);
connect
(
ui
.
chkMemoryInfo
,
&
QCheckBox
::
stateChanged
,
this
,
&
SettingsGeneralPage
::
changed
);
...
...
@@ -54,6 +57,42 @@ SettingsGeneralPage::SettingsGeneralPage(QWidget* parent) : SettingsPage(parent)
autoSaveChanged
(
ui
.
chkAutoSave
->
checkState
());
}
SettingsGeneralPage
::
DecimalSeparator
SettingsGeneralPage
::
decimalSeparator
(
QLocale
locale
)
{
QChar
decimalPoint
{
locale
.
decimalPoint
()};
if
(
decimalPoint
==
QChar
(
'.'
))
return
DecimalSeparator
::
Dot
;
else
if
(
decimalPoint
==
QChar
(
','
))
return
DecimalSeparator
::
Comma
;
return
DecimalSeparator
::
Arabic
;
}
QLocale
::
Language
SettingsGeneralPage
::
decimalSeparatorLocale
()
const
{
int
currentIndex
=
ui
.
cbDecimalSeparator
->
currentIndex
();
if
(
currentIndex
==
static_cast
<
int
>
(
decimalSeparator
()))
return
QLocale
().
language
();
QChar
groupSeparator
{
QLocale
().
groupSeparator
()};
QChar
decimalPoint
{
QLocale
().
decimalPoint
()};
if
(
currentIndex
==
static_cast
<
int
>
(
DecimalSeparator
::
Dot
))
{
if
(
groupSeparator
==
QLocale
(
QLocale
::
Language
::
Zarma
).
groupSeparator
())
// \u00a0
return
QLocale
::
Language
::
Zarma
;
// . \u00a0
else
if
(
groupSeparator
==
QLocale
(
QLocale
::
Language
::
SwissGerman
).
groupSeparator
())
// \u2019
return
QLocale
::
Language
::
SwissGerman
;
// . \u2019
else
return
QLocale
::
Language
::
C
;
// . ,
}
else
if
(
currentIndex
==
static_cast
<
int
>
(
DecimalSeparator
::
Comma
))
{
if
(
groupSeparator
==
QLocale
(
QLocale
::
Language
::
French
).
groupSeparator
())
// \u00a0
return
QLocale
::
Language
::
French
;
// , \u00a0
else
if
(
groupSeparator
==
QLocale
(
QLocale
::
Language
::
Walser
).
groupSeparator
())
// \u2019
return
QLocale
::
Language
::
Walser
;
// , \u2019
else
return
QLocale
::
Language
::
German
;
// , .
}
else
{
return
QLocale
::
Language
::
Arabic
;
// \u066b \u066c
}
}
void
SettingsGeneralPage
::
applySettings
()
{
KConfigGroup
group
=
KSharedConfig
::
openConfig
()
->
group
(
QLatin1String
(
"Settings_General"
));
group
.
writeEntry
(
QLatin1String
(
"LoadOnStart"
),
ui
.
cbLoadOnStart
->
currentIndex
());
...
...
@@ -62,18 +101,21 @@ void SettingsGeneralPage::applySettings() {
group
.
writeEntry
(
QLatin1String
(
"TabPosition"
),
ui
.
cbTabPosition
->
currentIndex
());
group
.
writeEntry
(
QLatin1String
(
"MdiWindowVisibility"
),
ui
.
cbMdiVisibility
->
currentIndex
());
group
.
writeEntry
(
QLatin1String
(
"Units"
),
ui
.
cbUnits
->
currentIndex
());
group
.
writeEntry
(
QLatin1String
(
"DecimalSeparatorLocale"
),
static_cast
<
int
>
(
decimalSeparatorLocale
()));
group
.
writeEntry
(
QLatin1String
(
"AutoSave"
),
ui
.
chkAutoSave
->
isChecked
());
group
.
writeEntry
(
QLatin1String
(
"AutoSaveInterval"
),
ui
.
sbAutoSaveInterval
->
value
());
group
.
writeEntry
(
QLatin1String
(
"ShowMemoryInfo"
),
ui
.
chkMemoryInfo
->
isChecked
());
}
void
SettingsGeneralPage
::
restoreDefaults
()
{
DEBUG
(
"SettingsGeneralPage::restoreDefaults()"
)
ui
.
cbLoadOnStart
->
setCurrentIndex
(
0
);
ui
.
cbTitleBar
->
setCurrentIndex
(
0
);
ui
.
cbInterface
->
setCurrentIndex
(
0
);
ui
.
cbTabPosition
->
setCurrentIndex
(
0
);
ui
.
cbMdiVisibility
->
setCurrentIndex
(
0
);
ui
.
cbUnits
->
setCurrentIndex
(
0
);
ui
.
cbDecimalSeparator
->
setCurrentIndex
(
static_cast
<
int
>
(
decimalSeparator
()));
ui
.
chkAutoSave
->
setChecked
(
false
);
ui
.
sbAutoSaveInterval
->
setValue
(
0
);
ui
.
sbAutoSaveInterval
->
setValue
(
5
);
...
...
@@ -81,6 +123,7 @@ void SettingsGeneralPage::restoreDefaults() {
}
void
SettingsGeneralPage
::
loadSettings
()
{
DEBUG
(
"SettingsGeneralPage::loadSettings()"
)
const
KConfigGroup
group
=
KSharedConfig
::
openConfig
()
->
group
(
QLatin1String
(
"Settings_General"
));
ui
.
cbLoadOnStart
->
setCurrentIndex
(
group
.
readEntry
(
QLatin1String
(
"LoadOnStart"
),
0
));
ui
.
cbTitleBar
->
setCurrentIndex
(
group
.
readEntry
(
QLatin1String
(
"TitleBar"
),
0
));
...
...
@@ -88,6 +131,8 @@ void SettingsGeneralPage::loadSettings() {
ui
.
cbTabPosition
->
setCurrentIndex
(
group
.
readEntry
(
QLatin1String
(
"TabPosition"
),
0
));
ui
.
cbMdiVisibility
->
setCurrentIndex
(
group
.
readEntry
(
QLatin1String
(
"MdiWindowVisibility"
),
0
));
ui
.
cbUnits
->
setCurrentIndex
(
group
.
readEntry
(
QLatin1String
(
"Units"
),
0
));
QLocale
::
Language
decimalSeparatorLocale
{
static_cast
<
QLocale
::
Language
>
(
group
.
readEntry
(
QLatin1String
(
"DecimalSeparatorLocale"
),
static_cast
<
int
>
(
QLocale
().
language
())
))
};
ui
.
cbDecimalSeparator
->
setCurrentIndex
(
static_cast
<
int
>
(
decimalSeparator
(
QLocale
(
decimalSeparatorLocale
)))
);
ui
.
chkAutoSave
->
setChecked
(
group
.
readEntry
<
bool
>
(
QLatin1String
(
"AutoSave"
),
false
));
ui
.
sbAutoSaveInterval
->
setValue
(
group
.
readEntry
(
QLatin1String
(
"AutoSaveInterval"
),
0
));
ui
.
chkMemoryInfo
->
setChecked
(
group
.
readEntry
<
bool
>
(
QLatin1String
(
"ShowMemoryInfo"
),
true
));
...
...
@@ -123,6 +168,10 @@ void SettingsGeneralPage::retranslateUi() {
ui
.
cbUnits
->
addItem
(
i18n
(
"Metric"
));
ui
.
cbUnits
->
addItem
(
i18n
(
"Imperial"
));
ui
.
cbDecimalSeparator
->
addItem
(
i18n
(
"Dot (.)"
));
ui
.
cbDecimalSeparator
->
addItem
(
i18n
(
"Comma (,)"
));
ui
.
cbDecimalSeparator
->
addItem
(
i18n
(
"Arabic"
));
}
void
SettingsGeneralPage
::
changed
()
{
...
...
src/kdefrontend/SettingsGeneralPage.h
View file @
4c541beb
...
...
@@ -37,8 +37,13 @@ class SettingsGeneralPage : public SettingsPage {
Q_OBJECT
public:
enum
class
DecimalSeparator
{
Dot
,
Comma
,
Arabic
};
explicit
SettingsGeneralPage
(
QWidget
*
);
static
DecimalSeparator
decimalSeparator
(
QLocale
locale
=
QLocale
());
QLocale
::
Language
decimalSeparatorLocale
()
const
;
void
applySettings
()
override
;
void
restoreDefaults
()
override
;
...
...
src/kdefrontend/ui/settingsgeneralpage.ui
View file @
4c541beb
...
...
@@ -80,14 +80,14 @@
<item
row=
"5"
column=
"0"
>
<widget
class=
"QLabel"
name=
"lUnits"
>
<property
name=
"text"
>
<string>
Units
</string>
<string>
Units
:
</string>
</property>
</widget>
</item>
<item
row=
"5"
column=
"3"
>
<widget
class=
"QComboBox"
name=
"cbUnits"
/>
</item>
<item
row=
"
6
"
column=
"1"
>
<item
row=
"
7
"
column=
"1"
>
<spacer
name=
"verticalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -103,14 +103,14 @@
</property>
</spacer>
</item>
<item
row=
"
7
"
column=
"0"
>
<item
row=
"
8
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"lAutoSave"
>
<property
name=
"text"
>
<string>
Auto-Save:
</string>
</property>
</widget>
</item>
<item
row=
"
7
"
column=
"3"
>
<item
row=
"
8
"
column=
"3"
>
<widget
class=
"QFrame"
name=
"frame"
>
<property
name=
"frameShape"
>
<enum>
QFrame::NoFrame
</enum>
...
...
@@ -119,16 +119,7 @@
<enum>
QFrame::Raised
</enum>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<property
name=
"leftMargin"
>
<number>
0
</number>
</property>
<property
name=
"topMargin"
>
<number>
0
</number>
</property>
<property
name=
"rightMargin"
>
<number>
0
</number>
</property>
<property
name=
"bottomMargin"
>
<property
name=
"margin"
>
<number>
0
</number>
</property>
<item>
...
...
@@ -187,21 +178,21 @@
</layout>
</widget>
</item>
<item
row=
"
8
"
column=
"0"
>
<item
row=
"
9
"
column=
"0"
>
<widget
class=
"QLabel"
name=
"lMemoryInfo"
>
<property
name=
"text"
>
<string>
Show memory info:
</string>
</property>
</widget>
</item>
<item
row=
"
8
"
column=
"3"
>
<item
row=
"
9
"
column=
"3"
>
<widget
class=
"QCheckBox"
name=
"chkMemoryInfo"
>
<property
name=
"text"
>
<string>
Enabled
</string>
</property>
</widget>
</item>
<item
row=
"
9
"
column=
"1"
>
<item
row=
"
10
"
column=
"1"
>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -214,6 +205,16 @@
</property>
</spacer>
</item>
<item
row=
"6"
column=
"0"
>
<widget
class=
"QLabel"
name=
"lDecimalSeparator"
>
<property
name=
"text"
>
<string>
Decimal separator:
</string>
</property>
</widget>
</item>
<item
row=
"6"
column=
"3"
>
<widget
class=
"QComboBox"
name=
"cbDecimalSeparator"
/>
</item>
</layout>
</widget>
<customwidgets>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment