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
2020-07-21 21:03:22 +00:00
import "../../../../shared"
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 "../../../../shared/status"
2021-10-01 15:58:36 +00:00
//TODO remove import dependency
import "../../Chat/views"
2020-07-21 21:03:22 +00:00
2021-10-06 09:16:39 +00:00
import StatusQ . Core 0.1
import "../popups"
2020-11-24 12:14:49 +00:00
ScrollView {
height: parent . height
width: parent . width
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
id: root
2020-11-24 12:14:49 +00:00
contentHeight: appearanceContainer . height
clip: true
2021-10-01 15:58:36 +00:00
property var store
property var globalStore
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-04-16 10:37:53 +00:00
globalSettings . 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 )
}
2020-11-24 12:14:49 +00:00
Item {
id: appearanceContainer
2021-04-08 15:44:58 +00:00
width: profileContainer . profileContentWidth
2021-03-18 09:33:39 +00:00
anchors.horizontalCenter: parent . horizontalCenter
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
}
Rectangle {
id: preview
anchors.top: sectionHeadlinePreview . bottom
anchors.topMargin: Style . current . smallPadding
anchors.left: parent . left
anchors.leftMargin: - Style . current . padding
anchors.right: parent . right
anchors.rightMargin: - Style . current . padding
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-10-01 15:58:36 +00:00
rootStore: root . rootStore
messageStore: root . globalStore . messageStore
///////////TODO Remove
2020-11-25 10:46:18 +00:00
userName: "@vitalik"
identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAb0lEQVR4Ae3UQQqAIBRF0Wj9ba9Bq6l5JBQqfn/ngDMH3YS3AAB/tO3H+XRG3b9bR/+gVoREI2RapVXpfd5+X5oXERKNkHS+rk3tOpWkeREh0QiZVu91ql2zNC8iJBoh0yqtSqt1slpCghICANDPBc0ESPh0bHkHAAAAAElFTkSuQmCC"
2021-02-18 16:36:05 +00:00
//% "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-" )
2020-11-25 10:46:18 +00:00
contentType: Constants . messageType
2020-11-30 17:03:52 +00:00
placeholderMessage: true
2021-10-01 15:58:36 +00:00
Component.onCompleted: {
messageStore . userName = "@vitalik" ;
messageStore . identicon = "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."
messageStore . 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-" ) ;
messageStore . contentType = Constants . messageType ;
//messageStore.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" )
2020-11-25 10:46:18 +00:00
}
StatusSlider {
id: fontSizeSlider
anchors.top: labelFontSize . bottom
anchors.topMargin: Style . current . padding
width: parent . width
minimumValue: 0
maximumValue: 5
stepSize: 1
value: appSettings . fontSize
onValueChanged: {
appSettings . fontSize = value
root . updateFontSize ( value )
}
}
RowLayout {
id: fontSizeSliderLegend
anchors.top: fontSizeSlider . bottom
anchors.topMargin: Style . current . padding
anchors.left: parent . left
anchors.right: parent . right
spacing: Style . current . smallPadding
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-11-25 10:46:18 +00:00
font.pixelSize: 15
2021-02-18 16:36:05 +00:00
//% "XS"
text: qsTrId ( "xs" )
2020-11-25 10:46:18 +00:00
Layout.preferredWidth: fontSizeSlider . width / 6
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-11-25 10:46:18 +00:00
font.pixelSize: 15
2021-02-18 16:36:05 +00:00
//% "S"
text: qsTrId ( "s" )
2020-11-25 10:46:18 +00:00
Layout.preferredWidth: fontSizeSlider . width / 6
Layout.leftMargin: 2
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-11-25 10:46:18 +00:00
font.pixelSize: 15
2021-02-18 16:36:05 +00:00
//% "M"
text: qsTrId ( "m" )
2020-11-25 10:46:18 +00:00
Layout.preferredWidth: fontSizeSlider . width / 6
Layout.leftMargin: 2
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-11-25 10:46:18 +00:00
font.pixelSize: 15
2021-02-18 16:36:05 +00:00
//% "L"
text: qsTrId ( "l" )
2020-11-25 10:46:18 +00:00
Layout.preferredWidth: fontSizeSlider . width / 6
Layout.leftMargin: 2
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-11-25 10:46:18 +00:00
font.pixelSize: 15
2021-02-18 16:36:05 +00:00
//% "XL"
text: qsTrId ( "xl" )
2020-11-25 10:46:18 +00:00
Layout.preferredWidth: fontSizeSlider . width / 6
Layout.leftMargin: 0
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2020-11-25 10:46:18 +00:00
font.pixelSize: 15
2021-02-18 16:36:05 +00:00
//% "XXL"
text: qsTrId ( "xxl" )
2020-11-25 10:46:18 +00:00
Layout.alignment: Qt . AlignRight
Layout.leftMargin: - Style . current . smallPadding
}
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2021-09-02 06:10:39 +00:00
id: labelZoom
anchors.top: fontSizeSliderLegend . bottom
anchors.topMargin: Style . current . xlPadding
anchors.left: parent . left
font.pixelSize: 15
text: qsTr ( "Change Zoom (requires restart)" )
}
StatusSlider {
id: zoomSlider
2021-09-02 09:57:32 +00:00
readonly property int initialValue: {
2021-10-06 09:16:39 +00:00
let scaleFactorStr = root . store . 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
minimumValue: 50
maximumValue: 200
stepSize: 50
2021-09-02 09:57:32 +00:00
value: initialValue
onValueChanged: {
if ( value !== initialValue ) {
2021-10-06 09:16:39 +00:00
root . store . 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
}
}
RowLayout {
id: zoomSliderLegend
anchors.top: zoomSlider . bottom
anchors.topMargin: Style . current . padding
anchors.left: parent . left
anchors.right: parent . right
spacing: 0
2021-10-06 09:16:39 +00:00
StatusBaseText {
2021-09-02 06:10:39 +00:00
font.pixelSize: 15
text: "50%"
}
Item {
Layout.fillWidth: true
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2021-09-02 06:10:39 +00:00
font.pixelSize: 15
Layout.leftMargin: width / 2
text: "100%"
}
Item {
Layout.fillWidth: true
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2021-09-02 06:10:39 +00:00
font.pixelSize: 15
Layout.leftMargin: width / 2
text: "150%"
}
Item {
Layout.fillWidth: true
}
2021-10-06 09:16:39 +00:00
StatusBaseText {
2021-09-02 06:10:39 +00:00
font.pixelSize: 15
text: "200%"
}
}
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-09-02 06:10:39 +00:00
anchors.top: zoomSliderLegend . 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.leftMargin: - Style . current . padding
anchors.right: parent . right
anchors.rightMargin: - Style . current . padding
StatusImageRadioButton {
padding: Style . current . smallPadding
width: 208
height: 184
2021-09-28 15:04:06 +00:00
image.source: Style . svg ( "appearance-normal-light" )
2020-11-24 12:14:49 +00:00
image.height: 128
2021-02-18 16:36:05 +00:00
//% "Light"
control.text: qsTrId ( "light" )
2021-04-16 10:37:53 +00:00
control.checked: globalSettings . theme === Universal . Light
2021-01-19 19:51:02 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2021-04-16 10:37:53 +00:00
root . updateTheme ( Universal . Light )
2020-11-24 12:14:49 +00:00
}
}
}
StatusImageRadioButton {
padding: Style . current . smallPadding
width: 208
height: 184
2021-09-28 15:04:06 +00:00
image.source: Style . svg ( "appearance-normal-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-04-16 10:37:53 +00:00
control.checked: globalSettings . theme === Universal . Dark
2021-01-19 19:51:02 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2021-04-16 10:37:53 +00:00
root . updateTheme ( Universal . Dark )
2020-11-24 12:14:49 +00:00
}
}
}
StatusImageRadioButton {
padding: Style . current . smallPadding
width: 208
height: 184
2021-09-28 15:04:06 +00:00
image.source: Style . svg ( "appearance-normal-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-04-16 10:37:53 +00:00
control.checked: globalSettings . theme === Universal . System
2021-01-19 19:51:02 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2021-04-16 10:37:53 +00:00
root . updateTheme ( Universal . System )
2020-11-24 12:14:49 +00:00
}
}
}
2020-07-21 21:03:22 +00:00
}
}
}