Skip to content

Commit c8f3f04

Browse files
committed
Basic project for creating component in QMl
1 parent 18ecf03 commit c8f3f04

29 files changed

+489
-0
lines changed

AppStyle.qml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pragma Singleton
2+
import QtQuick 2.15
3+
4+
QtObject {
5+
readonly property color background: "#232429"
6+
readonly property color hoverColor: "#2a2d36"
7+
readonly property color textBackground: "#2b2f3b"
8+
readonly property color popupBackground: "#333742"
9+
readonly property color appStyle: "#1d5ffe"
10+
readonly property color labelColor: "#85889b"
11+
readonly property color textColor: "#ffffff"
12+
readonly property color borderColor: "#464a53"
13+
readonly property color placeholderColor: "#757985"
14+
}

Component.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
QT += quick
2+
3+
# You can make your code fail to compile if it uses deprecated APIs.
4+
# In order to do so, uncomment the following line.
5+
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
6+
7+
SOURCES += \
8+
main.cpp
9+
10+
RESOURCES += qml.qrc
11+
12+
# Additional import path used to resolve QML modules in Qt Creator's code model
13+
QML_IMPORT_PATH =
14+
15+
# Additional import path used to resolve QML modules just for Qt Quick Designer
16+
QML_DESIGNER_IMPORT_PATH =
17+
18+
# Default rules for deployment.
19+
qnx: target.path = /tmp/$${TARGET}/bin
20+
else: unix:!android: target.path = /opt/$${TARGET}/bin
21+
!isEmpty(target.path): INSTALLS += target

Component.pro.user

+263
Large diffs are not rendered by default.

FontStyle.qml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
pragma Singleton
2+
import QtQuick 2.9
3+
import QtQuick.Controls 2.5
4+
5+
6+
QtObject {
7+
readonly property int h1 : 32
8+
readonly property int h2 : 24
9+
readonly property double h3 : 18.72
10+
readonly property int h4 : 16
11+
readonly property double h5 : 13.28
12+
readonly property double h6 : 10.72
13+
14+
readonly property int content : 14
15+
16+
readonly property var getAwesomeBrand: fontAwesomeBrand
17+
readonly property var getAwesomeRegular: fontAwesomeRegular
18+
readonly property var getAwesomeLight: fontAwesomeLight
19+
readonly property var getAwesomeSolid: fontAwesomeSolid
20+
readonly property var getContentFont: contentFontMedium
21+
readonly property var getContentFontBold: contentFontBold
22+
readonly property var getContentFontMedium: contentFontMedium
23+
readonly property var getContentFontLight: contentFontLight
24+
25+
readonly property var fontAwesomeBrand: FontLoader {
26+
source: "qrc:/fonts/Font Awesome 5 Brands-Regular-400.otf"
27+
}
28+
29+
readonly property var fontAwesomeRegular: FontLoader {
30+
source: "qrc:/fonts/Font Awesome 5 Pro-Regular-400.otf"
31+
}
32+
33+
readonly property var fontAwesomeLight: FontLoader {
34+
source: "qrc:/fonts/Font Awesome 5 Pro-Light-300.otf"
35+
}
36+
37+
readonly property var fontAwesomeSolid: FontLoader {
38+
source: "qrc:/fonts/Font Awesome 5 Pro-Solid-900.otf"
39+
}
40+
41+
readonly property var contentFontLight: FontLoader {
42+
source: "qrc:/fonts/Nunito-Light.ttf"
43+
}
44+
45+
readonly property var contentFontBold: FontLoader {
46+
source: "qrc:/fonts/Nunito-Bold.ttf"
47+
}
48+
49+
readonly property var contentFontMedium: FontLoader {
50+
source: "qrc:/fonts/Nunito-Medium.ttf"
51+
}
52+
}

Images/add.svg

+5
Loading

Images/airdrop.svg

+7
Loading

Images/airplane.svg

+5
Loading

Images/archive-add.svg

+5
Loading

Images/arrow-down.svg

+5
Loading

Images/arrow-up.svg

+5
Loading

Images/arrow.svg

+5
Loading

Images/eye-off.svg

+8
Loading

Images/eye-on.svg

+11
Loading

Images/moon.svg

+5
Loading

Images/sun.svg

+5
Loading

Images/tick.svg

+7
Loading
465 KB
Binary file not shown.
94.8 KB
Binary file not shown.
578 KB
Binary file not shown.
1.37 MB
Binary file not shown.
1.24 MB
Binary file not shown.
1.04 MB
Binary file not shown.

fonts/Nunito-Bold.ttf

129 KB
Binary file not shown.

fonts/Nunito-Light.ttf

129 KB
Binary file not shown.

fonts/Nunito-Medium.ttf

129 KB
Binary file not shown.

fonts/Nunito-Regular.ttf

129 KB
Binary file not shown.

main.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <QGuiApplication>
2+
#include <QQmlApplicationEngine>
3+
4+
5+
int main(int argc, char *argv[])
6+
{
7+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
8+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
9+
#endif
10+
QGuiApplication app(argc, argv);
11+
12+
QQmlApplicationEngine engine;
13+
14+
qmlRegisterSingletonType(QStringLiteral("qrc:/AppStyle.qml"),"AppStyle",1,0,"AppStyle");
15+
qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/FontSystem.qml")),"AppStyle",1,0,"FontStyle");
16+
17+
const QUrl url(QStringLiteral("qrc:/main.qml"));
18+
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
19+
&app, [url](QObject *obj, const QUrl &objUrl) {
20+
if (!obj && url == objUrl)
21+
QCoreApplication::exit(-1);
22+
}, Qt::QueuedConnection);
23+
engine.load(url);
24+
25+
return app.exec();
26+
}

main.qml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import QtQuick 2.15
2+
import QtQuick.Window 2.15
3+
import AppStyle 1.0
4+
import QtQuick.Controls 2.5
5+
import "./"
6+
Window {
7+
width: 640
8+
height: 480
9+
visible: true
10+
title: qsTr("Hello World")
11+
color: AppStyle.background
12+
}

qml.qrc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<RCC>
2+
<qresource prefix="/">
3+
<file>main.qml</file>
4+
<file>fonts/Font Awesome 5 Brands-Regular-400.otf</file>
5+
<file>fonts/Font Awesome 5 Free-Regular-400.otf</file>
6+
<file>fonts/Font Awesome 5 Free-Solid-900.otf</file>
7+
<file>fonts/Font Awesome 5 Pro-Light-300.otf</file>
8+
<file>fonts/Font Awesome 5 Pro-Regular-400.otf</file>
9+
<file>fonts/Font Awesome 5 Pro-Solid-900.otf</file>
10+
<file>fonts/Nunito-Bold.ttf</file>
11+
<file>fonts/Nunito-Light.ttf</file>
12+
<file>fonts/Nunito-Medium.ttf</file>
13+
<file>fonts/Nunito-Regular.ttf</file>
14+
<file>Images/add.svg</file>
15+
<file>Images/airdrop.svg</file>
16+
<file>Images/airplane.svg</file>
17+
<file>Images/archive-add.svg</file>
18+
<file>Images/arrow-down.svg</file>
19+
<file>Images/arrow-up.svg</file>
20+
<file>Images/arrow.svg</file>
21+
<file>Images/eye-off.svg</file>
22+
<file>Images/eye-on.svg</file>
23+
<file>Images/moon.svg</file>
24+
<file>Images/sun.svg</file>
25+
<file>Images/tick.svg</file>
26+
<file>AppStyle.qml</file>
27+
</qresource>
28+
</RCC>

0 commit comments

Comments
 (0)