소스 검색

created a repo

Julia 4 년 전
커밋
a86f263b72
4개의 변경된 파일178개의 추가작업 그리고 0개의 파일을 삭제
  1. 30 0
      graber.pro
  2. 20 0
      main.cpp
  3. 123 0
      main.qml
  4. 5 0
      qml.qrc

+ 30 - 0
graber.pro

@@ -0,0 +1,30 @@
+QT += quick
+
+CONFIG += c++11
+
+# The following define makes your compiler emit warnings if you use
+# any Qt feature that has been marked deprecated (the exact warnings
+# depend on your compiler). Refer to the documentation for the
+# deprecated API to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+        main.cpp
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# Additional import path used to resolve QML modules just for Qt Quick Designer
+QML_DESIGNER_IMPORT_PATH =
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target

+ 20 - 0
main.cpp

@@ -0,0 +1,20 @@
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+    QGuiApplication app(argc, argv);
+
+    QQmlApplicationEngine engine;
+    const QUrl url(QStringLiteral("qrc:/main.qml"));
+    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
+                     &app, [url](QObject *obj, const QUrl &objUrl) {
+        if (!obj && url == objUrl)
+            QCoreApplication::exit(-1);
+    }, Qt::QueuedConnection);
+    engine.load(url);
+
+    return app.exec();
+}

+ 123 - 0
main.qml

@@ -0,0 +1,123 @@
+import QtQuick 2.11
+import QtQuick.Window 2.11
+import QtGraphicalEffects 1.0
+
+Window {
+    id: window
+    visible: true
+    width: 640
+    height: 480
+    title: qsTr("Hello World")
+
+    QtObject{
+        id: d
+
+        property int screenCount: 0
+    }
+
+    Item{
+        id: source
+        width:  parent.width
+        height: parent.height
+
+        // Simple Animation
+
+        Rectangle{
+            id: rect
+
+            width: 20
+            height: 20
+            x: 10
+            y: 10
+
+            color: "black"
+            radius: width
+        }
+
+        SequentialAnimation{
+            id: moveAnimation
+            running: true
+            loops: Animation.Infinite
+            PropertyAnimation{target: rect; property: "x"; from: 10; to: source.width - rect.width - 10; duration: 1500; easing.type: Easing.OutCirc}
+            PropertyAnimation{target: rect; property: "y"; from: 10; to: source.height - rect.height - 10; duration: 1000/*; easing.type: Easing.OutCirc*/}
+            PropertyAnimation{target: rect; property: "x"; from: source.width - rect.width - 10; to: 10; duration: 1000/*; easing.type: Easing.OutCirc*/}
+            PropertyAnimation{target: rect; property: "y"; from: source.height - rect.height - 10; to: 0; duration: 1000/*; easing.type: Easing.OutCirc*/}
+        }
+
+
+//        Rectangle{
+//            id: rect
+//            width: parent.width
+//            height: parent.height
+//            color: "#49cc19"
+
+//            Rectangle{
+//                id: btn
+//                anchors.centerIn: parent
+//                width: parent.width / 2
+//                height: parent.height / 2
+//                radius: width / 3
+//                Text {
+//                    id: btnText
+//                    text: qsTr("Yo!")
+//                    font.pointSize: 40
+//                    color: "black"
+//                    anchors.centerIn: parent
+//                }
+
+//                MouseArea{
+//                    id: mouseArea
+//                    anchors.fill: parent
+//                    onPressed: {
+//                        btn.scale = 0.9
+//                        btnShadow.scale = 0.9
+//                        btnText.text = "Clicked"
+//                    }
+
+//                    onReleased: {
+//                        btn.scale = 1
+//                        btnShadow.scale = 1
+//                        btnText.text = "Yo!"
+//                    }
+//                }
+//            }
+
+//            DropShadow{
+//                id: btnShadow
+//                anchors.fill: btn
+//                horizontalOffset: 3
+//                verticalOffset: 13
+//                radius: 8.0
+//                samples: 17
+//                color: "#80000000"
+//                source: btn
+//            }
+//        }
+
+    }
+
+    ShaderEffectSource{
+        id: sourceShader
+        visible: false // Do not render it (will only be rendered when called grapToImage()
+        sourceItem: source
+        width: source.width
+        height: source.height
+        live: false // Will only be updated, when explicitly called for
+        function save() {
+            scheduleUpdate() // explicitly update. grabToImage() will force rendering afterwards.
+            sourceShader.grabToImage(function(result) {
+                            result.saveToFile("C://Documents/%1.png".arg(d.screenCount++));
+                        })
+        }
+    }
+
+    Timer{
+        id: timeToScreenShoot
+        interval: 25
+        repeat: true
+        running: true
+        onTriggered: {
+            sourceShader.save()
+        }
+    }
+}

+ 5 - 0
qml.qrc

@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>main.qml</file>
+    </qresource>
+</RCC>