Skip to content

Commit 6065971

Browse files
committed
added some ui
1 parent a841684 commit 6065971

11 files changed

+187
-35
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ Makefile*
3636

3737
# QtCtreator CMake
3838
CMakeLists.txt.user*
39+
40+
/debug

AddPostView.qml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import QtQuick 2.0
2+
import QtQuick.Controls 1.4
3+
import QtQuick.Layouts 1.3
4+
5+
Rectangle {
6+
id: rootRectangle
7+
anchors.fill: parent
8+
9+
CustomToolbar {
10+
id: mainToolBar
11+
Layout.preferredWidth: parent.width
12+
13+
ToolButton{
14+
id: goBackButton
15+
anchors.left: toolBarTitle.right
16+
width: parent.height
17+
height: width
18+
19+
Image {
20+
anchors.verticalCenter: parent.verticalCenter
21+
anchors.horizontalCenter: parent.horizontalCenter
22+
source: "icons/back_black.png"
23+
width: parent.width * 0.7
24+
height: width
25+
}
26+
27+
onClicked: {
28+
mainStack.pop();
29+
}
30+
}
31+
}
32+
33+
Rectangle {
34+
id: contentWrapper
35+
width: parent.width > 1200 ? 1080: parent.width * 0.9
36+
anchors.top: mainToolBar.bottom
37+
anchors.bottom: parent.bottom
38+
anchors.horizontalCenter: parent.horizontalCenter
39+
anchors.leftMargin: 10
40+
anchors.rightMargin: 10
41+
clip: true
42+
43+
Flickable {
44+
anchors.fill: parent
45+
contentWidth: parent.width
46+
contentHeight: colForm.height
47+
interactive: true
48+
boundsBehavior: Flickable.StopAtBounds
49+
50+
Column {
51+
id: formWrapper
52+
width: parent.width
53+
spacing: 10
54+
55+
Column {
56+
id: titleGroup
57+
anchors.horizontalCenter: parent.horizontalCenter
58+
59+
Text{
60+
id: titleLabel
61+
anchors.horizontalCenter: parent.horizontalCenter
62+
text: "Title"
63+
}
64+
65+
TextField {
66+
id: titleField
67+
placeholderText: "Post title..."
68+
}
69+
}
70+
71+
Separator {}
72+
73+
Column {
74+
id: contentGroup
75+
anchors.horizontalCenter: parent.horizontalCenter
76+
77+
Text{
78+
id: contentLabel
79+
anchors.horizontalCenter: parent.horizontalCenter
80+
text: "Content"
81+
}
82+
83+
TextArea {
84+
id: contentField
85+
}
86+
}
87+
}
88+
}
89+
}
90+
}

CustomToolbar.qml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import QtQuick 2.0
2+
import QtQuick.Controls 1.4
3+
import QtQuick.Controls.Styles 1.4
4+
5+
ToolBar {
6+
width: parent.width
7+
height: 40
8+
9+
Text {
10+
id: toolBarTitle
11+
text: "iGym2"
12+
anchors.left: parent.left
13+
anchors.verticalCenter: parent.verticalCenter
14+
font.pointSize: 20
15+
}
16+
}

MainForm.ui.qml

-29
This file was deleted.

Separator.qml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import QtQuick 2.0
2+
3+
Rectangle{
4+
anchors.horizontalCenter: parent.horizontalCenter
5+
width: parent.width
6+
height: 1
7+
opacity: 0.15
8+
color : "black"
9+
}

Workouts.qml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import QtQuick 2.0
2+
import QtQuick.Controls 1.4
3+
import QtQuick.Layouts 1.3
4+
5+
ColumnLayout {
6+
anchors.fill: parent
7+
spacing: 0
8+
9+
Component {
10+
id: comp_addPostView
11+
AddPostView {}
12+
}
13+
14+
CustomToolbar {
15+
Layout.preferredWidth: parent.width
16+
17+
ToolButton{
18+
id: addPostButton
19+
anchors.left: toolBarTitle.right
20+
width: parent.height
21+
height: width
22+
23+
Image {
24+
anchors.verticalCenter: parent.verticalCenter
25+
anchors.horizontalCenter: parent.horizontalCenter
26+
source: "icons/add_black.png"
27+
width: parent.width * 0.7
28+
height: width
29+
}
30+
31+
onClicked: {
32+
mainStack.push(comp_addPostView);
33+
}
34+
}
35+
}
36+
37+
Rectangle {
38+
Layout.preferredWidth: parent.width
39+
Layout.preferredHeight: parent.height * 0.5
40+
color: "red"
41+
}
42+
43+
Rectangle {
44+
Layout.preferredWidth: parent.width
45+
Layout.preferredHeight: parent.height * 0.5
46+
color: "blue"
47+
}
48+
}

icons/add_black.png

168 Bytes
Loading

icons/back_black.png

146 Bytes
Loading

main.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#include <QGuiApplication>
22
#include <QQmlApplicationEngine>
3+
#include <QQmlContext>
4+
5+
#include "mediator.h"
36

47
int main(int argc, char *argv[])
58
{
69
QGuiApplication app(argc, argv);
10+
Mediator mediator;
711

812
QQmlApplicationEngine engine;
13+
engine.rootContext()->setContextProperty("mediator", &mediator);
914
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
1015

1116
return app.exec();

main.qml

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import QtQuick 2.6
22
import QtQuick.Window 2.2
3+
import QtQuick.Controls 1.4
34

45
Window {
6+
id: mainWindow
57
visible: true
68
width: 640
79
height: 480
8-
title: qsTr("Hello World")
10+
title: qsTr("iGym")
911

10-
MainForm {
12+
Component {
13+
id: mainComponent
14+
Workouts {}
15+
}
16+
17+
StackView {
18+
id: mainStack
19+
initialItem: mainComponent
1120
anchors.fill: parent
12-
mouseArea.onClicked: {
13-
console.log(qsTr('Clicked on background. Text: "' + textEdit.text + '"'))
14-
}
1521
}
1622
}

qml.qrc

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<RCC>
22
<qresource prefix="/">
33
<file>main.qml</file>
4-
<file>MainForm.ui.qml</file>
4+
<file>AddPostView.qml</file>
5+
<file>CustomToolbar.qml</file>
6+
<file>Separator.qml</file>
7+
<file>Workouts.qml</file>
8+
<file>icons/add_black.png</file>
9+
<file>icons/back_black.png</file>
510
</qresource>
611
</RCC>

0 commit comments

Comments
 (0)