2020-07-21 21:03:22 +00:00
import QtQuick 2.13
import QtQuick . Controls 2.13
import QtQuick . Layouts 1.13
feat: Support system dark mode theme
Supports system dark mode. Changes the user appearance setting to a 3-way setting of System, Light, Dark.
New accounts will have their appearance setting set to "System", which uses the system setting to determine if dark mode should be applied.
Breaking change: Users who had their settings on Light Theme, will now get the system theme (light or dark). Users who had their theme set to Dark, will now get the Light theme.
At startup, the onboarding screens will have the system-level setting of dark mode applied or not. Once, logged in, the user settings will be applied.
## Note
An appearance setting of "System" is not dynamic to the system-level setting. This means that if a user has "System" set for their appearance (and ie, the user has light mode set), and then user then changes their system setting from light to dark, the app will not respond until it is restarted. This is due to a limitation of Qt not having a reliable way to propagate these changes to QML.
2020-09-29 06:18:00 +00:00
import QtQuick . Controls . Universal 2.12
2021-09-28 15:04:06 +00:00
import utils 1.0
2021-10-27 21:27:49 +00:00
import shared 1.0
2021-10-28 20:23:30 +00:00
import shared . views 1.0
2021-10-27 21:27:49 +00:00
import shared . status 1.0
2021-10-28 20:23:30 +00:00
import shared . views . chat 1.0
2020-07-21 21:03:22 +00:00
2021-10-06 09:16:39 +00:00
import StatusQ . Core 0.1
2021-11-01 09:44:43 +00:00
import StatusQ . Core . Theme 0.1
2021-10-22 12:48:52 +00:00
import StatusQ . Controls 0.1 as StatusQ
2021-10-06 09:16:39 +00:00
import "../popups"
2021-12-30 12:39:47 +00:00
import "../stores"
2021-10-06 09:16:39 +00:00
2022-05-07 11:45:15 +00:00
SettingsContentBase {
2021-12-09 13:28:02 +00:00
id: appearanceView
2021-12-29 10:32:43 +00:00
2021-12-30 12:39:47 +00:00
property AppearanceStore appearanceStore
2021-12-09 13:28:02 +00:00
property var systemPalette
2020-07-21 21:03:22 +00:00
feat: Support system dark mode theme
Supports system dark mode. Changes the user appearance setting to a 3-way setting of System, Light, Dark.
New accounts will have their appearance setting set to "System", which uses the system setting to determine if dark mode should be applied.
Breaking change: Users who had their settings on Light Theme, will now get the system theme (light or dark). Users who had their theme set to Dark, will now get the Light theme.
At startup, the onboarding screens will have the system-level setting of dark mode applied or not. Once, logged in, the user settings will be applied.
## Note
An appearance setting of "System" is not dynamic to the system-level setting. This means that if a user has "System" set for their appearance (and ie, the user has light mode set), and then user then changes their system setting from light to dark, the app will not respond until it is restarted. This is due to a limitation of Qt not having a reliable way to propagate these changes to QML.
2020-09-29 06:18:00 +00:00
enum Theme {
2020-11-24 12:14:49 +00:00
Light ,
Dark ,
System
feat: Support system dark mode theme
Supports system dark mode. Changes the user appearance setting to a 3-way setting of System, Light, Dark.
New accounts will have their appearance setting set to "System", which uses the system setting to determine if dark mode should be applied.
Breaking change: Users who had their settings on Light Theme, will now get the system theme (light or dark). Users who had their theme set to Dark, will now get the Light theme.
At startup, the onboarding screens will have the system-level setting of dark mode applied or not. Once, logged in, the user settings will be applied.
## Note
An appearance setting of "System" is not dynamic to the system-level setting. This means that if a user has "System" set for their appearance (and ie, the user has light mode set), and then user then changes their system setting from light to dark, the app will not respond until it is restarted. This is due to a limitation of Qt not having a reliable way to propagate these changes to QML.
2020-09-29 06:18:00 +00:00
}
function updateTheme ( theme ) {
2021-10-20 10:55:10 +00:00
localAppSettings . theme = theme
2021-08-12 11:52:04 +00:00
Style . changeTheme ( theme , systemPalette . isCurrentSystemThemeDark ( ) )
feat: Support system dark mode theme
Supports system dark mode. Changes the user appearance setting to a 3-way setting of System, Light, Dark.
New accounts will have their appearance setting set to "System", which uses the system setting to determine if dark mode should be applied.
Breaking change: Users who had their settings on Light Theme, will now get the system theme (light or dark). Users who had their theme set to Dark, will now get the Light theme.
At startup, the onboarding screens will have the system-level setting of dark mode applied or not. Once, logged in, the user settings will be applied.
## Note
An appearance setting of "System" is not dynamic to the system-level setting. This means that if a user has "System" set for their appearance (and ie, the user has light mode set), and then user then changes their system setting from light to dark, the app will not respond until it is restarted. This is due to a limitation of Qt not having a reliable way to propagate these changes to QML.
2020-09-29 06:18:00 +00:00
}
2020-11-25 10:46:18 +00:00
function updateFontSize ( fontSize ) {
Style . changeFontSize ( fontSize )
}
2021-12-29 10:32:43 +00:00
Component.onCompleted: {
appearanceView . updateFontSize ( localAccountSensitiveSettings . fontSize )
}
2021-12-09 13:28:02 +00:00
2020-11-24 12:14:49 +00:00
Item {
id: appearanceContainer
2022-05-07 11:45:15 +00:00
anchors.left: parent . left
anchors.leftMargin: Style . current . padding
width: appearanceView . contentWidth - 2 * Style . current . padding
2020-11-24 12:14:49 +00:00
height: this . childrenRect . height + 100
2020-07-21 21:03:22 +00:00
2020-11-24 12:14:49 +00:00
ButtonGroup {
id: chatModeSetting
2020-07-21 21:03:22 +00:00
}
2020-11-24 12:14:49 +00:00
ButtonGroup {
id: appearanceSetting
feat: Support system dark mode theme
Supports system dark mode. Changes the user appearance setting to a 3-way setting of System, Light, Dark.
New accounts will have their appearance setting set to "System", which uses the system setting to determine if dark mode should be applied.
Breaking change: Users who had their settings on Light Theme, will now get the system theme (light or dark). Users who had their theme set to Dark, will now get the Light theme.
At startup, the onboarding screens will have the system-level setting of dark mode applied or not. Once, logged in, the user settings will be applied.
## Note
An appearance setting of "System" is not dynamic to the system-level setting. This means that if a user has "System" set for their appearance (and ie, the user has light mode set), and then user then changes their system setting from light to dark, the app will not respond until it is restarted. This is due to a limitation of Qt not having a reliable way to propagate these changes to QML.
2020-09-29 06:18:00 +00:00
}
2020-11-24 12:14:49 +00:00
2020-11-25 10:46:18 +00:00
StatusSectionHeadline {
id: sectionHeadlinePreview
2021-02-18 16:36:05 +00:00
//% "Preview"
text: qsTrId ( "preview" )
2020-11-25 10:46:18 +00:00
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
2022-05-07 11:45:15 +00:00
anchors.topMargin: 0
2020-11-25 10:46:18 +00:00
}
Rectangle {
id: preview
anchors.top: sectionHeadlinePreview . bottom
anchors.topMargin: Style . current . smallPadding
anchors.left: parent . left
anchors.right: parent . right
2021-02-02 17:04:49 +00:00
height: paceholderMessage . height + Style . current . padding * 4
2020-11-25 10:46:18 +00:00
radius: Style . current . radius
border.color: Style . current . border
color: Style . current . transparent
2021-10-01 15:58:36 +00:00
MessageView {
2021-02-02 17:04:49 +00:00
id: paceholderMessage
2020-11-25 10:46:18 +00:00
anchors.top: parent . top
anchors.topMargin: Style . current . padding * 2
anchors.left: parent . left
anchors.leftMargin: Style . current . smallPadding
2021-12-17 22:06:40 +00:00
isMessage: true
shouldRepeatHeader: true
2021-12-29 10:32:43 +00:00
messageTimestamp: Date . now ( )
2021-12-17 22:06:40 +00:00
senderDisplayName: "@vitalik"
senderIcon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAb0lEQVR4Ae3UQQqAIBRF0Wj9ba9Bq6l5JBQqfn/ngDMH3YS3AAB/tO3H+XRG3b9bR/+gVoREI2RapVXpfd5+X5oXERKNkHS+rk3tOpWkeREh0QiZVu91ql2zNC8iJBoh0yqtSqt1slpCghICANDPBc0ESPh0bHkHAAAAAElFTkSuQmCC"
//% "Blockchains will drop search costs, causing a kind of decomposition that allows you to have markets of entities that are horizontally segregated and vertically segregated."
message: qsTrId ( "blockchains-will-drop-search-costs--causing-a-kind-of-decomposition-that-allows-you-to-have-markets-of-entities-that-are-horizontally-segregated-and-vertically-segregated-" )
messageContentType: Constants . messageContentType . messageType
placeholderMessage: true
2020-11-25 10:46:18 +00:00
}
}
StatusSectionHeadline {
id: sectionHeadlineFontSize
2021-02-18 16:36:05 +00:00
//% "Size"
text: qsTrId ( "size" )
2020-11-25 10:46:18 +00:00
anchors.top: preview . bottom
anchors.topMargin: Style . current . padding
anchors.left: parent . left
anchors.right: parent . right
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-11-25 10:46:18 +00:00
id: labelFontSize
anchors.top: sectionHeadlineFontSize . bottom
anchors.topMargin: Style . current . padding
anchors.left: parent . left
font.pixelSize: 15
2021-02-18 16:36:05 +00:00
//% "Change font size"
text: qsTrId ( "change-font-size" )
2021-11-01 09:44:43 +00:00
color: Theme . palette . directColor1
2020-11-25 10:46:18 +00:00
}
2022-05-20 10:51:44 +00:00
StatusQ . StatusLabeledSlider {
2020-11-25 10:46:18 +00:00
id: fontSizeSlider
anchors.top: labelFontSize . bottom
anchors.topMargin: Style . current . padding
width: parent . width
2022-05-20 10:51:44 +00:00
model: [ qsTr ( "XS" ) , qsTr ( "S" ) , qsTr ( "M" ) , qsTr ( "L" ) , qsTr ( "XL" ) , qsTr ( "XXL" ) ]
2021-10-20 09:50:50 +00:00
value: localAccountSensitiveSettings . fontSize
2020-11-25 10:46:18 +00:00
onValueChanged: {
2022-05-16 15:02:03 +00:00
if ( localAccountSensitiveSettings . fontSize !== value ) {
localAccountSensitiveSettings . fontSize = value
appearanceView . updateFontSize ( value )
}
2020-11-25 10:46:18 +00:00
}
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2021-09-02 06:10:39 +00:00
id: labelZoom
2021-11-02 19:54:02 +00:00
anchors.top: fontSizeSlider . bottom
2021-09-02 06:10:39 +00:00
anchors.topMargin: Style . current . xlPadding
anchors.left: parent . left
font.pixelSize: 15
text: qsTr ( "Change Zoom (requires restart)" )
2021-11-01 09:44:43 +00:00
color: Theme . palette . directColor1
2021-09-02 06:10:39 +00:00
}
2022-05-20 10:51:44 +00:00
StatusQ . StatusLabeledSlider {
2021-09-02 06:10:39 +00:00
id: zoomSlider
2021-09-02 09:57:32 +00:00
readonly property int initialValue: {
2021-12-29 10:32:43 +00:00
let scaleFactorStr = appearanceView . appearanceStore . readTextFile ( uiScaleFilePath )
2021-09-02 09:57:32 +00:00
if ( scaleFactorStr === "" ) {
return 100
}
let scaleFactor = parseFloat ( scaleFactorStr )
if ( isNaN ( scaleFactor ) ) {
return 100
}
return scaleFactor * 100
}
2021-09-02 06:10:39 +00:00
anchors.top: labelZoom . bottom
anchors.topMargin: Style . current . padding
width: parent . width
2021-10-22 12:48:52 +00:00
from: 50
to: 200
2021-09-02 06:10:39 +00:00
stepSize: 50
2022-05-20 10:51:44 +00:00
model: [ qsTr ( "50%" ) , qsTr ( "100%" ) , qsTr ( "150%" ) , qsTr ( "200%" ) ]
2021-09-02 09:57:32 +00:00
value: initialValue
onValueChanged: {
if ( value !== initialValue ) {
2021-12-29 10:32:43 +00:00
appearanceView . appearanceStore . writeTextFile ( uiScaleFilePath , value / 100.0 )
2021-09-02 06:54:02 +00:00
}
}
2021-09-02 09:57:32 +00:00
onPressedChanged: {
if ( ! pressed && value !== initialValue ) {
confirmAppRestartModal . open ( )
}
}
ConfirmAppRestartModal {
id: confirmAppRestartModal
2021-09-02 12:39:50 +00:00
onClosed: {
zoomSlider . value = zoomSlider . initialValue
}
2021-09-02 06:10:39 +00:00
}
}
2020-11-24 12:14:49 +00:00
StatusSectionHeadline {
id: sectionHeadlineAppearance
2021-02-18 16:36:05 +00:00
//% "Appearance"
text: qsTrId ( "appearance" )
2021-03-15 21:11:07 +00:00
// anchors.top: chatModeSection.bottom
2021-11-02 19:54:02 +00:00
anchors.top: zoomSlider . bottom
2020-11-24 12:14:49 +00:00
anchors.topMargin: Style . current . padding * 3
anchors.left: parent . left
anchors.right: parent . right
2020-07-21 21:03:22 +00:00
}
2020-11-24 12:14:49 +00:00
RowLayout {
id: appearanceSection
anchors.top: sectionHeadlineAppearance . bottom
anchors.topMargin: Style . current . padding
anchors.left: parent . left
anchors.right: parent . right
StatusImageRadioButton {
padding: Style . current . smallPadding
width: 208
height: 184
2022-05-09 16:07:49 +00:00
image.source: Style . png ( "appearance-light" )
2020-11-24 12:14:49 +00:00
image.height: 128
2021-02-18 16:36:05 +00:00
//% "Light"
2022-05-09 16:07:49 +00:00
control.text: qsTrId ( "Light" )
2021-10-20 10:55:10 +00:00
control.checked: localAppSettings . theme === Universal . Light
2021-01-19 19:51:02 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2021-12-09 13:28:02 +00:00
appearanceView . updateTheme ( Universal . Light )
2020-11-24 12:14:49 +00:00
}
}
}
StatusImageRadioButton {
padding: Style . current . smallPadding
width: 208
height: 184
2022-05-09 16:07:49 +00:00
image.source: Style . png ( "appearance-dark" )
2020-11-24 12:14:49 +00:00
image.height: 128
2021-02-18 16:36:05 +00:00
//% "Dark"
control.text: qsTrId ( "dark" )
2021-10-20 10:55:10 +00:00
control.checked: localAppSettings . theme === Universal . Dark
2021-01-19 19:51:02 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2021-12-09 13:28:02 +00:00
appearanceView . updateTheme ( Universal . Dark )
2020-11-24 12:14:49 +00:00
}
}
}
StatusImageRadioButton {
padding: Style . current . smallPadding
width: 208
height: 184
2022-05-09 16:07:49 +00:00
image.source: Style . png ( "appearance-system" )
2020-11-24 12:14:49 +00:00
image.height: 128
2021-02-18 16:36:05 +00:00
//% "System"
control.text: qsTrId ( "system" )
2021-10-20 10:55:10 +00:00
control.checked: localAppSettings . theme === Universal . System
2021-01-19 19:51:02 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2021-12-09 13:28:02 +00:00
appearanceView . updateTheme ( Universal . System )
2020-11-24 12:14:49 +00:00
}
}
}
2020-07-21 21:03:22 +00:00
}
}
}