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
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 )
2022-10-03 13:39:30 +00:00
Theme . updateFontSize ( fontSize )
2020-11-25 10:46:18 +00:00
}
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
2022-07-26 11:53:18 +00:00
height: childrenRect . height
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
Rectangle {
id: preview
2022-07-26 11:53:18 +00:00
anchors.top: parent . top
2020-11-25 10:46:18 +00:00
anchors.left: parent . left
anchors.right: parent . right
2022-07-05 10:12:27 +00:00
height: placeholderMessage . implicitHeight +
placeholderMessage . anchors . leftMargin +
placeholderMessage . anchors . rightMargin
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 {
2022-07-05 10:12:27 +00:00
id: placeholderMessage
2020-11-25 10:46:18 +00:00
anchors.top: parent . top
anchors.left: parent . left
2022-07-05 10:12:27 +00:00
anchors.right: parent . right
2022-07-26 11:53:18 +00:00
anchors.margins: Style . current . smallPadding
2021-12-17 22:06:40 +00:00
isMessage: true
shouldRepeatHeader: true
2022-07-05 10:12:27 +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"
2022-07-05 10:12:27 +00:00
messageText: qsTr ( "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." )
2021-12-17 22:06:40 +00:00
messageContentType: Constants . messageContentType . messageType
placeholderMessage: true
2020-11-25 10:46:18 +00:00
}
}
StatusSectionHeadline {
id: sectionHeadlineFontSize
2022-07-26 11:53:18 +00:00
text: qsTr ( "Text size" )
2020-11-25 10:46:18 +00:00
anchors.top: preview . bottom
2022-07-26 11:53:18 +00:00
anchors.topMargin: Style . current . bigPadding * 2
2020-11-25 10:46:18 +00:00
anchors.left: parent . left
anchors.right: parent . right
}
2022-05-20 10:51:44 +00:00
StatusQ . StatusLabeledSlider {
2020-11-25 10:46:18 +00:00
id: fontSizeSlider
2022-07-26 11:53:18 +00:00
anchors.top: sectionHeadlineFontSize . bottom
2020-11-25 10:46:18 +00:00
anchors.topMargin: Style . current . padding
width: parent . width
2022-10-03 13:39:30 +00:00
textRole: "name"
valueRole: "value"
model: ListModel {
ListElement { name: qsTr ( "XS" ) ; value: Theme . FontSizeXS }
ListElement { name: qsTr ( "S" ) ; value: Theme . FontSizeS }
ListElement { name: qsTr ( "M" ) ; value: Theme . FontSizeM }
ListElement { name: qsTr ( "L" ) ; value: Theme . FontSizeL }
ListElement { name: qsTr ( "XL" ) ; value: Theme . FontSizeXL }
ListElement { name: qsTr ( "XXL" ) ; value: Theme . FontSizeXXL }
}
2021-10-20 09:50:50 +00:00
value: localAccountSensitiveSettings . fontSize
2022-10-03 13:39:30 +00:00
onCurrentValueChanged: {
const fontSize = currentValue
if ( localAccountSensitiveSettings . fontSize !== fontSize ) {
localAccountSensitiveSettings . fontSize = fontSize
appearanceView . updateFontSize ( fontSize )
2022-05-16 15:02:03 +00:00
}
2020-11-25 10:46:18 +00:00
}
}
2022-07-26 11:53:18 +00:00
StatusSectionHeadline {
2021-09-02 06:10:39 +00:00
id: labelZoom
2021-11-02 19:54:02 +00:00
anchors.top: fontSizeSlider . bottom
2022-07-26 11:53:18 +00:00
anchors.topMargin: Style . current . bigPadding * 2
2021-09-02 06:10:39 +00:00
anchors.left: parent . left
2022-07-26 11:53:18 +00:00
anchors.right: parent . right
text: qsTr ( "Zoom (requires restart)" )
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
}
}
2022-07-26 11:53:18 +00:00
Rectangle {
id: modeSeparator
anchors.top: zoomSlider . bottom
anchors.topMargin: Style . current . padding * 3
anchors.left: parent . left
anchors.right: parent . right
height: 1
color: Style . current . separator
}
2020-11-24 12:14:49 +00:00
StatusSectionHeadline {
id: sectionHeadlineAppearance
2022-07-26 11:53:18 +00:00
text: qsTr ( "Mode" )
anchors.top: modeSeparator . 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
2022-07-26 11:53:18 +00:00
spacing: Style . current . halfPadding
2020-11-24 12:14:49 +00:00
StatusImageRadioButton {
2022-07-26 11:53:18 +00:00
Layout.preferredWidth: parent . width / 3 - parent . spacing
Layout.preferredHeight: implicitHeight
2022-05-09 16:07:49 +00:00
image.source: Style . png ( "appearance-light" )
2022-04-04 11:26:30 +00:00
control.text: qsTr ( "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 {
2022-07-26 11:53:18 +00:00
Layout.preferredWidth: parent . width / 3 - parent . spacing
2022-05-09 16:07:49 +00:00
image.source: Style . png ( "appearance-dark" )
2022-04-04 11:26:30 +00:00
control.text: qsTr ( "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 {
2022-07-26 11:53:18 +00:00
Layout.preferredWidth: parent . width / 3 - parent . spacing
2022-05-09 16:07:49 +00:00
image.source: Style . png ( "appearance-system" )
2022-04-04 11:26:30 +00:00
control.text: qsTr ( "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
}
}
}