Skip to content

Commit 3d290e5

Browse files
committed
Создание рабочего экрана "Person"
1 parent bc58319 commit 3d290e5

File tree

17 files changed

+321
-11
lines changed

17 files changed

+321
-11
lines changed

main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33

44
int main(int argc, char *argv[])
55
{
6+
QCoreApplication::setOrganizationName("AMM");
7+
QCoreApplication::setOrganizationDomain("www.amm.vsu.ru");
8+
QCoreApplication::setApplicationName("DepressionKiller");
9+
610
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
711

812
QGuiApplication app(argc, argv);
913

14+
app.setApplicationName("DepressionKiller");
15+
app.setApplicationVersion("0.1");
16+
1017
QQmlApplicationEngine engine;
1118
const QUrl url(QStringLiteral("qrc:/main.qml"));
1219
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,

main.qml

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,72 @@
11
import QtQuick 2.12
22
import QtQuick.Window 2.12
3+
import "./qml-other/settings"
4+
import "./qml-other/panels"
35

46
Window {
57
visible: true
6-
width: Screen.width
7-
height: Screen.height
8-
title: qsTr("Hello World")
9-
10-
Rectangle {
11-
anchors.centerIn: parent
12-
color: "red"
13-
width: parent.width/2
14-
height: width
8+
width: 1080/2.5
9+
height: 2340/2.5
10+
color: colorTh.base
11+
title: qsTr("Антидепрессия")
12+
13+
ColorTheme {
14+
id: colorTh
15+
}
16+
17+
SaveSet {
18+
id: setApp
19+
}
20+
21+
Item {
22+
id: container
23+
width: parent.width
24+
height: parent.height
25+
26+
PersonPanel {
27+
id: personPanel
28+
width: parent.width
29+
height: parent.height - bar.height
30+
anchors.top: parent.top
31+
}
32+
33+
Rectangle {
34+
id: bar
35+
height: parent.width * 0.12
36+
width: parent.width
37+
anchors.horizontalCenter: parent.horizontalCenter
38+
anchors.bottom: parent.bottom
39+
color: colorTh.base_ext
40+
41+
Image {
42+
id: avatarMenu
43+
source: personPanel.state != "active" ? "qrc:/resources/" + colorTh.icon_dir + "/avatar-off.png"
44+
: "qrc:/resources/" + colorTh.icon_dir + "/avatar.png"
45+
width: parent.height * 0.8
46+
height: width
47+
anchors.verticalCenter: parent.verticalCenter
48+
anchors.left: parent.left
49+
anchors.leftMargin: parent.width/5
50+
fillMode: Image.PreserveAspectFit
51+
52+
MouseArea {
53+
anchors.fill: parent
54+
onClicked: {
55+
personPanel.state = "active"
56+
}
57+
}
58+
}
59+
60+
Image {
61+
id: toDoMenu
62+
source: "qrc:/resources/" + colorTh.icon_dir + "/ToDo-off.png"
63+
width: avatarMenu.width
64+
height: width
65+
anchors.verticalCenter: parent.verticalCenter
66+
anchors.right: parent.right
67+
anchors.rightMargin: parent.width/5
68+
fillMode: Image.PreserveAspectFit
69+
}
70+
}
1571
}
1672
}

qml-other/lol.qml

Whitespace-only changes.

qml-other/panels/PersonPanel.qml

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,180 @@
11
import QtQuick 2.12
2+
import QtQuick.Controls 2.12
23

34
Item {
5+
Image {
6+
id: avatar
7+
source: "qrc:/resources/" + colorTh.icon_dir + "/avatar.png"
8+
width: parent.width * 0.25
9+
anchors.horizontalCenter: parent.horizontalCenter
10+
anchors.top: parent.top
11+
anchors.topMargin: parent.height * 0.06
12+
height: width
13+
fillMode: Image.PreserveAspectFit
14+
}
15+
16+
Text {
17+
id: helloText
18+
text: qsTr("Здравствуйте!")
19+
font.family: "Segoe UI Semibold"
20+
verticalAlignment: Text.AlignVCenter
21+
horizontalAlignment: Text.AlignHCenter
22+
font.pixelSize: parent.width * 0.08
23+
color: colorTh.contr
24+
anchors.top: avatar.bottom
25+
anchors.horizontalCenter: parent.horizontalCenter
26+
}
27+
28+
Text {
29+
id: helloText2
30+
text: qsTr("")
31+
font.family: "Segoe UI Semibold"
32+
verticalAlignment: Text.AlignVCenter
33+
horizontalAlignment: Text.AlignHCenter
34+
font.pixelSize: parent.width * 0.05
35+
color: colorTh.contr
36+
anchors.top: helloText.bottom
37+
anchors.horizontalCenter: parent.horizontalCenter
38+
}
39+
40+
function timeChanged() {
41+
var h = (new Date).getHours()
42+
if (h >= 0 && h < 6)
43+
{
44+
helloText.text = qsTr("Доброй ночи!")
45+
helloText2.text = qsTr("Постарайтесь соблюдать\nрежим сна")
46+
}
47+
else if (h >= 6 && h < 11)
48+
{
49+
helloText.text = qsTr("Доброго утра!")
50+
helloText2.text = qsTr("Начните день\n с позитивных мыслей")
51+
}
52+
else if (h >= 11 && h < 18)
53+
{
54+
helloText.text = qsTr("Доброго Вам дня!")
55+
helloText2.text = qsTr("Будьте продуктивны\n")
56+
}
57+
else
58+
{
59+
helloText.text = qsTr("Добрый вечер!")
60+
helloText2.text = qsTr("Вспомните, что позитивного\nбыло за день")
61+
}
62+
}
63+
64+
Timer {
65+
interval: 3600000; running: true; repeat: true;
66+
onTriggered: timeChanged()
67+
}
68+
69+
ListModel {
70+
id: modelView
71+
ListElement {
72+
number: 1
73+
title: qsTr("Что такое депрессия?")
74+
}
75+
ListElement {
76+
number: 2
77+
title: qsTr("Тест Вашего состояния")
78+
}
79+
ListElement {
80+
number: 3
81+
title: qsTr("Дневник мыслей")
82+
}
83+
ListElement {
84+
number: 4
85+
title: qsTr("Помощь специалиста")
86+
}
87+
ListElement {
88+
number: 5
89+
title: qsTr("Темные цвета")
90+
}
91+
ListElement {
92+
number: 6
93+
title: qsTr("О приложении")
94+
}
95+
}
96+
97+
Component {
98+
id: componentView
99+
100+
Item {
101+
id: itemElemSetting
102+
width: parent.width
103+
height: titleText.font.pixelSize * 2
104+
105+
Text {
106+
id: titleText
107+
text: title
108+
font.family: "Segoe UI Semilight"
109+
font.italic: true
110+
verticalAlignment: Text.AlignBottom
111+
font.pixelSize: parent.width * 0.05
112+
color: colorTh.contrC
113+
anchors.left: parent.left
114+
anchors.leftMargin: parent.width * 0.05
115+
}
116+
117+
MouseArea {
118+
anchors.fill: parent
119+
onClicked: {
120+
if (number != 5)
121+
clicked(number)
122+
}
123+
}
124+
}
125+
}
126+
127+
signal clicked(int num)
128+
129+
ListView {
130+
clip: true
131+
id: viewSettingListView
132+
anchors.top: helloText2.bottom
133+
anchors.horizontalCenter: parent.horizontalCenter
134+
height: parent.width * 0.10 * modelView.count
135+
width: parent.width
136+
model: modelView
137+
delegate: componentView
138+
interactive: false
139+
anchors.topMargin: parent.width * 0.05
140+
}
141+
142+
Switch {
143+
id: switchTheme
144+
width: height * 2.8
145+
height: parent.width * 0.05
146+
anchors.right: parent.right
147+
anchors.bottom: viewSettingListView.bottom
148+
anchors.bottomMargin: parent.width * 0.1 + height * 0.5
149+
anchors.rightMargin: parent.width * 0.05
150+
checked: colorTh.state == "black"
151+
onToggled: {
152+
if (!checked)
153+
colorTh.changeTheme("white")
154+
else
155+
colorTh.changeTheme("black")
156+
}
157+
indicator: Rectangle {
158+
width: switchTheme.width
159+
height: switchTheme.height
160+
anchors.centerIn: switchTheme
161+
radius: height/2
162+
color: switchTheme.checked ? colorTh.contr : colorTh.base_ext
163+
border.color: colorTh.contrC
164+
165+
Rectangle {
166+
x: switchTheme.checked ? parent.width - width : 0
167+
anchors.verticalCenter: parent.verticalCenter
168+
width: height
169+
height: switchTheme.height * 1.5
170+
radius: height/2
171+
color: colorTh.contrC
172+
}
173+
}
174+
}
175+
176+
Component.onCompleted: {
177+
timeChanged()
178+
}
4179

5180
}

qml-other/settings/ColorTheme.qml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import QtQuick 2.0
2+
import Qt.labs.settings 1.1
3+
4+
Item {
5+
id: themeColor
6+
property color base: "black"
7+
property color base_ext: "#404040"
8+
property color contr: "#447C4F"
9+
property color contrC: "white"
10+
property string icon_dir: "blackTh"
11+
12+
state: colorThemesSet.selected
13+
14+
Settings {
15+
id: colorThemesSet
16+
category: "color_theme"
17+
property string selected: "whiteTh"
18+
}
19+
20+
states: [
21+
State {
22+
name: "black"
23+
PropertyChanges {
24+
target: themeColor
25+
base: "black"
26+
base_ext: "#404040"
27+
contr: "#447C4F"
28+
contrC: "white"
29+
icon_dir: "blackTh"
30+
}
31+
},
32+
33+
State {
34+
name: "white"
35+
PropertyChanges {
36+
target: themeColor
37+
base: "white"
38+
base_ext: "#C6C6C6"
39+
contr: "#005D77"
40+
contrC: "black"
41+
icon_dir: "whiteTh"
42+
}
43+
}
44+
]
45+
46+
function changeTheme(_state)
47+
{
48+
colorThemesSet.selected = _state
49+
themeColor.state = _state
50+
}
51+
52+
Component.onCompleted: {
53+
themeColor.state = colorThemesSet.selected
54+
}
55+
56+
}

qml-other/settings/SaveSet.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import QtQuick 2.0
2+
import Qt.labs.settings 1.1
3+
4+
Settings {
5+
category: "app_data"
6+
property bool black_theme: false
7+
}

qml.qrc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
<RCC>
22
<qresource prefix="/">
33
<file>main.qml</file>
4-
<file>qml-other/lol.qml</file>
5-
<file>resources/null.jpg</file>
64
<file>qml-other/begin-menu/BeginMenu.qml</file>
75
<file>qml-other/panels/PersonPanel.qml</file>
86
<file>qml-other/panels/ToDoPanel.qml</file>
7+
<file>qml-other/settings/SaveSet.qml</file>
8+
<file>qml-other/settings/ColorTheme.qml</file>
9+
<file>resources/blackTh/avatar.png</file>
10+
<file>resources/whiteTh/avatar.png</file>
11+
<file>resources/blackTh/avatar-off.png</file>
12+
<file>resources/blackTh/ToDo-off.png</file>
13+
<file>resources/blackTh/ToDo-on.png</file>
14+
<file>resources/whiteTh/avatar-off.png</file>
15+
<file>resources/whiteTh/ToDo-off.png</file>
16+
<file>resources/whiteTh/ToDo-on.png</file>
17+
<file>resources/WhatIsDepress.mp4</file>
918
</qresource>
1019
</RCC>

resources/WhatIsDepress.mp4

8.96 MB
Binary file not shown.

resources/blackTh/ToDo-off.png

17.5 KB
Loading

resources/blackTh/ToDo-on.png

18.2 KB
Loading

0 commit comments

Comments
 (0)