Add experimental dark mode.

This commit is contained in:
Black Hat 2018-03-21 19:13:47 +08:00
parent cbd5974d55
commit 531abcb48c
7 changed files with 67 additions and 63 deletions

View File

@ -153,18 +153,6 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const
return room->displayName(); return room->displayName();
case Qt::DecorationRole: case Qt::DecorationRole:
{ {
// auto avatar = room->avatar(16, 16);
// if (!avatar.isNull())
// return avatar;
// switch( room->joinState() )
// {
// case JoinState::Join:
// return QIcon(":/irc-channel-joined.svg");
// case JoinState::Invite:
// return QIcon(":/irc-channel-invited.svg");
// case JoinState::Leave:
// return QIcon(":/irc-channel-parted.svg");
// }
if(room->avatarUrl().toString() != "") { if(room->avatarUrl().toString() != "") {
qInfo() << "Room avatar:" << room->avatarUrl(); qInfo() << "Room avatar:" << room->avatarUrl();
return room->avatarUrl(); return room->avatarUrl();

View File

@ -1,8 +1,10 @@
import QtQuick 2.10 import QtQuick 2.10
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.3
Page { Page {
TabBar { property alias theme: themeSwitch.checked
header: TabBar {
id: settingBar id: settingBar
width: parent.width width: parent.width
z: 10 z: 10
@ -36,7 +38,13 @@ Page {
} }
Page { Page {
Column {
width: parent.width
Switch {
id: themeSwitch
text: qsTr("Dark Theme")
}
}
} }
Page { Page {

View File

@ -1,43 +1,6 @@
import QtQuick 2.10 import QtQuick 2.3
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.3
Item { ItemDelegate {
property Item page
property alias contentItem: itemDelegate.contentItem
signal clicked
id: buttonDelegate
Layout.fillWidth: true
Layout.preferredHeight: width
Rectangle {
width: stackView.currentItem === page ? parent.width : 0
height: parent.height
anchors.bottom: itemDelegate.bottom
color: Qt.lighter(Material.accent)
Behavior on width {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
}
ItemDelegate {
id: itemDelegate id: itemDelegate
anchors.fill: parent
onClicked: {
if(page != null && stackView.currentItem != page) {
if(stackView.depth === 1) {
stackView.replace(page)
} else {
stackView.clear()
stackView.push(page)
}
}
buttonDelegate.clicked()
}
}
} }

View File

@ -0,0 +1,43 @@
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.3
Item {
property Item page
property alias contentItem: buttonDelegate.contentItem
signal clicked
id: sideNavButton
Layout.fillWidth: true
Layout.preferredHeight: width
Rectangle {
width: stackView.currentItem === page ? parent.width : 0
height: parent.height
anchors.bottom: buttonDelegate.bottom
color: Qt.lighter(Material.accent)
Behavior on width {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
}
}
ButtonDelegate {
id: buttonDelegate
anchors.fill: parent
onClicked: {
if(page != null && stackView.currentItem !== page) {
if(stackView.depth === 1) {
stackView.replace(page)
} else {
stackView.clear()
stackView.push(page)
}
}
sideNavButton.clicked()
}
}
}

View File

@ -70,7 +70,7 @@ Item {
contentItem: Text { contentItem: Text {
text: "\ue226" text: "\ue226"
color: "#424242" // color: "#424242"
font.pointSize: 16 font.pointSize: 16
font.family: materialFont.name font.family: materialFont.name
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
@ -97,7 +97,7 @@ Item {
contentItem: Text { contentItem: Text {
text: "\ue24e" text: "\ue24e"
color: parent.pressed ? Material.accent : "#424242" // color: parent.pressed ? Material.accent : "#424242"
font.pointSize: 16 font.pointSize: 16
font.family: materialFont.name font.family: materialFont.name
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
@ -115,7 +115,7 @@ Item {
contentItem: Text { contentItem: Text {
text: "\ue163" text: "\ue163"
color: "#424242" // color: "#424242"
font.pointSize: 16 font.pointSize: 16
font.family: materialFont.name font.family: materialFont.name
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter

View File

@ -16,6 +16,7 @@ ApplicationWindow {
width: 960 width: 960
height: 640 height: 640
title: qsTr("Matrique") title: qsTr("Matrique")
Material.theme: settingPage.theme ? Material.Dark : Material.Light
Controller { Controller {
id: matrixController id: matrixController
@ -45,7 +46,7 @@ ApplicationWindow {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
ButtonDelegate { SideNavButton {
contentItem: ImageStatus { contentItem: ImageStatus {
width: parent.width width: parent.width
height: parent.width height: parent.width
@ -66,7 +67,7 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
} }
ButtonDelegate { SideNavButton {
contentItem: Text { contentItem: Text {
text: "\ue853" text: "\ue853"
font.pointSize: 16 font.pointSize: 16
@ -82,7 +83,7 @@ ApplicationWindow {
} }
} }
ButtonDelegate { SideNavButton {
contentItem: Text { contentItem: Text {
text: "\ue5d2" text: "\ue5d2"
font.pointSize: 16 font.pointSize: 16
@ -98,7 +99,7 @@ ApplicationWindow {
} }
} }
ButtonDelegate { SideNavButton {
contentItem: Text { contentItem: Text {
text: "\ue8b8" text: "\ue8b8"
font.pointSize: 16 font.pointSize: 16
@ -109,11 +110,11 @@ ApplicationWindow {
} }
page: Setting { page: Setting {
id: settingPage
} }
} }
ButtonDelegate { SideNavButton {
contentItem: Text { contentItem: Text {
text: "\ue879" text: "\ue879"
font.pointSize: 16 font.pointSize: 16

View File

@ -16,5 +16,6 @@
<file>qml/form/ListForm.qml</file> <file>qml/form/ListForm.qml</file>
<file>qml/Contact.qml</file> <file>qml/Contact.qml</file>
<file>qml/component/ChatRoom.qml</file> <file>qml/component/ChatRoom.qml</file>
<file>qml/component/SideNavButton.qml</file>
</qresource> </qresource>
</RCC> </RCC>