2024-02-22 15:16:47 +00:00
import QtQuick 2.15
import QtQuick . Controls 2.15
import QtQuick . Layouts 1.15
import QtQuick . Window 2.15
import QtQuick . Controls . Universal 2.15
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
2024-10-15 19:26:12 +00:00
Theme . 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 ) {
2024-10-15 19:26:12 +00:00
Theme . changeFontSize ( 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
2023-01-24 17:31:20 +00:00
anchors.left: ! ! parent ? parent.left : undefined
2024-10-15 19:26:12 +00:00
anchors.leftMargin: Theme . padding
width: appearanceView . contentWidth - 2 * Theme . padding
2022-07-26 11:53:18 +00:00
height: childrenRect . height
2020-07-21 21:03:22 +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
2024-10-15 19:26:12 +00:00
radius: Theme . radius
border.color: Theme . palette . border
color: Theme . palette . transparent
2020-11-25 10:46:18 +00:00
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
2024-10-15 19:26:12 +00:00
anchors.margins: Theme . smallPadding
2021-12-17 22:06:40 +00:00
isMessage: true
shouldRepeatHeader: true
2022-07-05 10:12:27 +00:00
messageTimestamp: Date . now ( )
2022-11-08 11:37:25 +00:00
senderDisplayName: "vitalik.eth"
2021-12-17 22:06:40 +00:00
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
2024-10-15 19:26:12 +00:00
anchors.topMargin: Theme . 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
2024-10-15 19:26:12 +00:00
anchors.topMargin: Theme . padding
2020-11-25 10:46:18 +00:00
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
Rectangle {
id: modeSeparator
2024-05-13 17:56:26 +00:00
anchors.top: fontSizeSlider . bottom
2024-10-15 19:26:12 +00:00
anchors.topMargin: Theme . padding * 3
2022-07-26 11:53:18 +00:00
anchors.left: parent . left
anchors.right: parent . right
height: 1
2024-10-15 19:26:12 +00:00
color: Theme . palette . separator
2022-07-26 11:53:18 +00:00
}
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
2024-10-15 19:26:12 +00:00
anchors.topMargin: Theme . padding * 3
2020-11-24 12:14:49 +00:00
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
2024-10-15 19:26:12 +00:00
anchors.topMargin: Theme . padding
2020-11-24 12:14:49 +00:00
anchors.left: parent . left
anchors.right: parent . right
2024-10-15 19:26:12 +00:00
spacing: Theme . 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
2024-10-15 19:26:12 +00:00
image.source: Theme . 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
2024-10-15 19:26:12 +00:00
image.source: Theme . 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
2024-10-15 19:26:12 +00:00
image.source: Theme . 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
}
}
}