Skip to content

Commit 9e6100f

Browse files
aula-1: First version
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
0 parents  commit 9e6100f

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Aulas KDE-Brasil
2+
3+
Repositório para aulas apresentadas no [canal do youtube KDE-Brasil](https://www.youtube.com/playlist?list=PL6oOWzm2QNuwGM1gUZkVm79jfvW9QaOpd).
4+
5+
---
6+
7+
#### [Aula 1 - Iniciando um projeto QML/C++ com CMake](https://youtu.be/ibyXGgSBes0?list=PL6oOWzm2QNuwGM1gUZkVm79jfvW9QaOpd)

aula-1/CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
project(aula-1)
2+
3+
cmake_minimum_required(VERSION 2.8)
4+
5+
# Find the QtWidgets library
6+
find_package(Qt5 REQUIRED
7+
Core
8+
Qml
9+
Quick
10+
QuickControls2
11+
Widgets
12+
)
13+
14+
add_subdirectory(src)

aula-1/qml/main.qml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import QtQuick 2.12
2+
import QtQuick.Controls 2.12
3+
import QtQuick.Controls.Material 2.12
4+
import QtQuick.Layouts 1.12
5+
import QtMultimedia 5.8
6+
7+
ApplicationWindow {
8+
id: window
9+
title: "aula-1"
10+
visible: true
11+
height: 400
12+
width: 600
13+
14+
Material.theme: Material.Dark
15+
Material.accent: Material.Purple
16+
17+
Video {
18+
id: video
19+
anchors.fill: parent
20+
volume: 0
21+
playbackRate: 10
22+
source: "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"
23+
}
24+
25+
Timer {
26+
running: true
27+
repeat: true
28+
onTriggered: print(video.position*100/video.duration, "%")
29+
}
30+
31+
RowLayout {
32+
anchors.bottom: parent.bottom
33+
anchors.horizontalCenter: parent.horizontalCenter
34+
Button {
35+
text: video.playbackState == MediaPlayer.PlayingState ? "Stop" : "Play"
36+
opacity: 0.5
37+
onClicked: {
38+
if(video.playbackState == MediaPlayer.PlayingState) {
39+
video.stop()
40+
} else {
41+
video.play()
42+
}
43+
}
44+
}
45+
ProgressBar {
46+
value: video.position/video.duration
47+
}
48+
}
49+
}

aula-1/resources.qrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<RCC>
2+
<qresource>
3+
<file alias="main.qml">qml/main.qml</file>
4+
</qresource>
5+
</RCC>

aula-1/src/CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Populate a CMake variable with the sources
2+
set(SRCS
3+
main.cpp
4+
)
5+
6+
qt5_add_resources(RESOURCES ../resources.qrc)
7+
8+
# Tell CMake to create the aula-1 executable
9+
add_executable(aula-1 ${SRCS} ${RESOURCES})
10+
# Use the Widgets module from Qt 5
11+
target_link_libraries(aula-1
12+
Qt5::Core
13+
Qt5::Qml
14+
Qt5::QuickControls2
15+
Qt5::Quick
16+
Qt5::Widgets
17+
)

aula-1/src/main.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <QApplication>
2+
#include <QQmlApplicationEngine>
3+
#include <QQuickStyle>
4+
5+
int main(int argc, char *argv[]) {
6+
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
7+
QQuickStyle::setStyle("Material");
8+
9+
QGuiApplication app(argc, argv);
10+
QQmlApplicationEngine appEngine("qrc:/main.qml");
11+
12+
return app.exec();
13+
}

0 commit comments

Comments
 (0)