Prechádzať zdrojové kódy

Move from resource system to live files

Donald Carr 8 rokov pred
rodič
commit
0716a83f02
46 zmenil súbory, kde vykonal 117 pridanie a 153 odobranie
  1. 1 1
      art
  2. 3 31
      artriculate.pro
  3. 0 13
      deployment.pri
  4. 0 0
      qml/3rdparty/backdrops/cells/cells.qml
  5. 0 0
      qml/3rdparty/backdrops/cells/noise.png
  6. 0 0
      qml/3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml
  7. 0 0
      qml/3rdparty/backdrops/qml-presentation-visuals/Swirl.qml
  8. 0 0
      qml/3rdparty/backdrops/qml-presentation-visuals/particle.png
  9. 0 0
      qml/3rdparty/effects/Billboard.qml
  10. 2 2
      qml/3rdparty/effects/Effect.qml
  11. 0 0
      qml/3rdparty/effects/Effects.qml
  12. 0 0
      qml/3rdparty/effects/Emboss.qml
  13. 0 0
      qml/3rdparty/effects/GaussianBlur.qml
  14. 0 0
      qml/3rdparty/effects/shaders/billboard.fsh
  15. 0 0
      qml/3rdparty/effects/shaders/emboss.fsh
  16. 0 0
      qml/3rdparty/effects/shaders/gaussianblur_h.fsh
  17. 0 0
      qml/3rdparty/effects/shaders/gaussianblur_v.fsh
  18. 1 1
      qml/main.qml
  19. 45 0
      qml/qml.pro
  20. 0 34
      qml/qml.qrc
  21. 3 3
      qml/qmldir
  22. 0 0
      qml/unlicensed/Unlicensed.qml
  23. 0 0
      qml/unlicensed/unlicensed.png
  24. 2 1
      qml/views/basic/Basic.qml
  25. 2 1
      qml/views/cascade/Cascade.qml
  26. 0 0
      qml/views/cascade/CascadeDelegate.qml
  27. 3 2
      qml/views/conveyor/Conveyor.qml
  28. 0 0
      qml/views/conveyor/Monty_python_foot.png
  29. 2 1
      qml/views/procession/Procession.qml
  30. 0 0
      qml/views/procession/ProcessionImage.qml
  31. 2 1
      qml/views/reel/Reel.qml
  32. 2 1
      qml/views/simplelistview/SimpleListView.qml
  33. 2 1
      qml/views/well/Well.qml
  34. 0 0
      qml/views/well/WellDelegate.qml
  35. 0 17
      resources/resources.qrc
  36. 4 1
      src/filereader.h
  37. 0 16
      src/helperfunctions.cpp
  38. 0 22
      src/helperfunctions.h
  39. 9 4
      src/main.cpp
  40. 0 0
      src/resources/artriculate.desktop
  41. 0 0
      src/resources/artriculate.png
  42. 0 0
      src/resources/artriculate@.service
  43. 0 0
      src/resources/license-header
  44. 0 0
      src/resources/qt_logo_green_rgb.png
  45. 5 0
      src/resources/resources.qrc
  46. 29 0
      src/src.pro

+ 1 - 1
art

@@ -16,4 +16,4 @@ fi
 env="$env __GL_SYNC_TO_VBLANK=1 QML_FORCE_THREADED_RENDERER=1"
 
 export $env
-${script_dir}/artriculate $args
+${script_dir}/src/artriculate $args

+ 3 - 31
artriculate.pro

@@ -1,33 +1,5 @@
-TEMPLATE = app
+TEMPLATE = subdirs
 
-QT += qml quick dbus sql
-CONFIG += c++11
+CONFIG += ordered
 
-DEFINES *= QT_USE_QSTRINGBUILDER
-
-SOURCES += src/main.cpp \
-    src/picturemodel.cpp \
-    src/helperfunctions.cpp
-
-RESOURCES += qml/qml.qrc resources/resources.qrc
-
-# Additional import path used to resolve QML modules in Qt Creator's code model
-QML_IMPORT_PATH =
-
-target.path = /usr/bin
-
-desktop.path = /usr/share/applications
-desktop.files += resources/artriculate.desktop
-
-icon.path = /usr/share/icons/hicolor/128x128/apps
-icon.files += resources/artriculate.png
-
-INSTALLS += target desktop icon
-
-# Default rules for deployment.
-include(deployment.pri)
-
-HEADERS += \
-    src/picturemodel.h \
-    src/helperfunctions.h \
-    src/filereader.h
+SUBDIRS += src qml

+ 0 - 13
deployment.pri

@@ -1,13 +0,0 @@
-unix:!android {
-    isEmpty(target.path) {
-        qnx {
-            target.path = /tmp/$${TARGET}/bin
-        } else {
-            target.path = /opt/$${TARGET}/bin
-        }
-        export(target.path)
-    }
-    INSTALLS += target
-}
-
-export(INSTALLS)

+ 0 - 0
resources/3rdparty/backdrops/cells/cells.qml → qml/3rdparty/backdrops/cells/cells.qml


+ 0 - 0
resources/3rdparty/backdrops/cells/noise.png → qml/3rdparty/backdrops/cells/noise.png


+ 0 - 0
resources/3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml → qml/3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml


+ 0 - 0
resources/3rdparty/backdrops/qml-presentation-visuals/Swirl.qml → qml/3rdparty/backdrops/qml-presentation-visuals/Swirl.qml


+ 0 - 0
resources/3rdparty/backdrops/qml-presentation-visuals/particle.png → qml/3rdparty/backdrops/qml-presentation-visuals/particle.png


+ 0 - 0
qml/effects/Billboard.qml → qml/3rdparty/effects/Billboard.qml


+ 2 - 2
qml/effects/Effect.qml → qml/3rdparty/effects/Effect.qml

@@ -77,7 +77,7 @@ ShaderEffect {
     // rather than being inline in the QML file
 
     onFragmentShaderFilenameChanged:
-        fragmentShader = d.fragmentShaderCommon + fileReader.readFile(":shaders/" + fragmentShaderFilename)
+        fragmentShader = d.fragmentShaderCommon + fileReader.readFile("shaders/" + fragmentShaderFilename)
     onVertexShaderFilenameChanged:
-        vertexShader = fileReader.readFile(":shaders/" + vertexShaderFilename)
+        vertexShader = fileReader.readFile("shaders/" + vertexShaderFilename)
 }

+ 0 - 0
qml/effects/Effects.qml → qml/3rdparty/effects/Effects.qml


+ 0 - 0
qml/effects/Emboss.qml → qml/3rdparty/effects/Emboss.qml


+ 0 - 0
qml/effects/GaussianBlur.qml → qml/3rdparty/effects/GaussianBlur.qml


+ 0 - 0
resources/shaders/billboard.fsh → qml/3rdparty/effects/shaders/billboard.fsh


+ 0 - 0
resources/shaders/emboss.fsh → qml/3rdparty/effects/shaders/emboss.fsh


+ 0 - 0
resources/shaders/gaussianblur_h.fsh → qml/3rdparty/effects/shaders/gaussianblur_h.fsh


+ 0 - 0
resources/shaders/gaussianblur_v.fsh → qml/3rdparty/effects/shaders/gaussianblur_v.fsh


+ 1 - 1
qml/main.qml

@@ -86,7 +86,7 @@ Window {
         }
 
         function deriveViewPath(view) {
-            return view.toLowerCase() + "/" + view + ".qml"
+            return "views/" + view.toLowerCase() + "/" + view + ".qml"
         }
 
         onCurrentViewFilenameChanged: {

+ 45 - 0
qml/qml.pro

@@ -0,0 +1,45 @@
+TEMPLATE = subdirs
+
+DISTFILES += \
+        main.qml \
+        qmldir \
+        widgets/Widget.qml \
+        widgets/FPS.qml \
+        widgets/Clock.qml \
+        widgets/ItemCount.qml \
+        widgets/Resolution.qml \
+        widgets/WidgetTray.qml \
+        common/VisualEffect.qml \
+        common/ArtImage.qml \
+        common/View.qml \
+        physics/BoxBody.qml \
+        physics/ImageBoxBody.qml \
+        physics/ArtBoxBody.qml \
+        physics/RectangleBoxBody.qml \
+        views/well/WellDelegate.qml \
+        views/well/Well.qml \
+        views/cascade/Cascade.qml \
+        views/cascade/CascadeDelegate.qml \
+        views/conveyor/Conveyor.qml \
+        views/conveyor/Monty_python_foot.png \
+        views/basic/Basic.qml \
+        views/reel/Reel.qml \
+        views/procession/Procession.qml \
+        views/procession/ProcessionImage.qml \
+        views/simplelistview/SimpleListView.qml \
+        unlicensed/Unlicensed.qml \
+        unlicensed/unlicensed.png \
+        3rdparty/effects/Effects.qml \
+        3rdparty/effects/Effect.qml \
+        3rdparty/effects/Billboard.qml \
+        3rdparty/effects/Emboss.qml \
+        3rdparty/effects/GaussianBlur.qml \
+        3rdparty/backdrops/qml-presentation-visuals/Swirl.qml \
+        3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml \
+        3rdparty/backdrops/qml-presentation-visuals/particle.png \
+        3rdparty/backdrops/cells/cells.qml \
+        3rdparty/backdrops/cells/noise.png \
+        3rdparty/effects/shaders/billboard.fsh \
+        3rdparty/effects/shaders/emboss.fsh \
+        3rdparty/effects/shaders/gaussianblur_h.fsh \
+        3rdparty/effects/shaders/gaussianblur_v.fsh

+ 0 - 34
qml/qml.qrc

@@ -1,34 +0,0 @@
-<RCC>
-    <qresource prefix="/">
-        <file>main.qml</file>
-        <file>qmldir</file>
-        <file>widgets/Widget.qml</file>
-        <file>widgets/FPS.qml</file>
-        <file>widgets/Clock.qml</file>
-        <file>widgets/ItemCount.qml</file>
-        <file>widgets/Resolution.qml</file>
-        <file>widgets/WidgetTray.qml</file>
-        <file>common/VisualEffect.qml</file>
-        <file>physics/BoxBody.qml</file>
-        <file>physics/ImageBoxBody.qml</file>
-        <file>physics/ArtBoxBody.qml</file>
-        <file>physics/RectangleBoxBody.qml</file>
-        <file>well/WellDelegate.qml</file>
-        <file>well/Well.qml</file>
-        <file>cascade/Cascade.qml</file>
-        <file>cascade/CascadeDelegate.qml</file>
-        <file>conveyor/Conveyor.qml</file>
-        <file>basic/Basic.qml</file>
-        <file>reel/Reel.qml</file>
-        <file>procession/Procession.qml</file>
-        <file>procession/ProcessionImage.qml</file>
-        <file>effects/Effect.qml</file>
-        <file>effects/Billboard.qml</file>
-        <file>effects/Emboss.qml</file>
-        <file>effects/GaussianBlur.qml</file>
-        <file>effects/Effects.qml</file>
-        <file>common/ArtImage.qml</file>
-        <file>common/View.qml</file>
-        <file>simplelistview/SimpleListView.qml</file>
-    </qresource>
-</RCC>

+ 3 - 3
qml/qmldir

@@ -1,4 +1,4 @@
-singleton Effects 1.0 effects/Effects.qml
+singleton Effects 1.0 3rdparty/effects/Effects.qml
 ArtImage 1.0 common/ArtImage.qml
 VisualEffect 1.0 common/VisualEffect.qml
 View 1.0 common/View.qml
@@ -11,6 +11,6 @@ Clock 1.0 widgets/Clock.qml
 Resolution 1.0 widgets/Resolution.qml
 ItemCount 1.0 widgets/ItemCount.qml
 WidgetTray 1.0 widgets/WidgetTray.qml
-BackgroundCells 1.0 3rdparty/backdrops/cells/cells.qml
-BackgroundSwirls 1.0 3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml
+Cells 1.0 3rdparty/backdrops/cells/cells.qml
+Swirls 1.0 3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml
 Unlicensed 1.0 unlicensed/Unlicensed.qml

+ 0 - 0
resources/unlicensed/Unlicensed.qml → qml/unlicensed/Unlicensed.qml


+ 0 - 0
resources/unlicensed/unlicensed.png → qml/unlicensed/unlicensed.png


+ 2 - 1
qml/basic/Basic.qml → qml/views/basic/Basic.qml

@@ -1,7 +1,8 @@
 import QtQuick 2.5
 import Qt.labs.settings 1.0
 
-import ".."
+// Forgive me
+import "../.."
 
 View {
     id: root

+ 2 - 1
qml/cascade/Cascade.qml → qml/views/cascade/Cascade.qml

@@ -2,7 +2,8 @@ import QtQuick 2.5
 import Box2D 2.0
 import Qt.labs.settings 1.0
 
-import ".."
+// Forgive me
+import "../.."
 
 Item {
     id: root

+ 0 - 0
qml/cascade/CascadeDelegate.qml → qml/views/cascade/CascadeDelegate.qml


+ 3 - 2
qml/conveyor/Conveyor.qml → qml/views/conveyor/Conveyor.qml

@@ -3,7 +3,8 @@ import Box2D 2.0
 import Qt.labs.settings 1.0
 import PictureModel 1.0
 
-import ".."
+// Forgive me
+import "../.."
 
 Item {
     id: root
@@ -38,7 +39,7 @@ Item {
         anchors.verticalCenter: viewport.verticalCenter
         fixedRotation: true
         z: 10
-        source: "qrc:/Monty_python_foot.png"
+        source: "Monty_python_foot.png"
         height: viewport.height
         width: viewport.height/foot.implicitHeight*foot.implicitWidth
         sourceSize.height: height

+ 0 - 0
resources/Monty_python_foot.png → qml/views/conveyor/Monty_python_foot.png


+ 2 - 1
qml/procession/Procession.qml → qml/views/procession/Procession.qml

@@ -1,7 +1,8 @@
 import QtQuick 2.5
 import Qt.labs.settings 1.0
 
-import ".."
+// Forgive me
+import "../.."
 
 View {
     id: root

+ 0 - 0
qml/procession/ProcessionImage.qml → qml/views/procession/ProcessionImage.qml


+ 2 - 1
qml/reel/Reel.qml → qml/views/reel/Reel.qml

@@ -1,7 +1,8 @@
 import QtQuick 2.5
 import Qt.labs.settings 1.0
 
-import ".."
+// Forgive me
+import "../.."
 
 View {
     id: root

+ 2 - 1
qml/simplelistview/SimpleListView.qml → qml/views/simplelistview/SimpleListView.qml

@@ -1,6 +1,7 @@
 import QtQuick 2.5
 
-import ".."
+// Forgive me
+import "../.."
 
 ListView {
     delegate: ArtImage {

+ 2 - 1
qml/well/Well.qml → qml/views/well/Well.qml

@@ -2,7 +2,8 @@ import QtQuick 2.5
 import Box2D 2.0
 import Qt.labs.settings 1.0
 
-import ".."
+// Forgive me
+import "../.."
 
 View {
     id: root

+ 0 - 0
qml/well/WellDelegate.qml → qml/views/well/WellDelegate.qml


+ 0 - 17
resources/resources.qrc

@@ -1,17 +0,0 @@
-<RCC>
-    <qresource prefix="/">
-        <file>unlicensed/unlicensed.png</file>
-        <file>unlicensed/Unlicensed.qml</file>
-        <file>qt_logo_green_rgb.png</file>
-        <file>Monty_python_foot.png</file>
-        <file>shaders/billboard.fsh</file>
-        <file>shaders/emboss.fsh</file>
-        <file>shaders/gaussianblur_h.fsh</file>
-        <file>shaders/gaussianblur_v.fsh</file>
-        <file>3rdparty/backdrops/qml-presentation-visuals/Swirl.qml</file>
-        <file>3rdparty/backdrops/qml-presentation-visuals/BackgroundSwirls.qml</file>
-        <file>3rdparty/backdrops/qml-presentation-visuals/particle.png</file>
-        <file>3rdparty/backdrops/cells/cells.qml</file>
-        <file>3rdparty/backdrops/cells/noise.png</file>
-    </qresource>
-</RCC>

+ 4 - 1
src/filereader.h

@@ -5,6 +5,8 @@
 #include <QFile>
 #include <QTextStream>
 
+#include <QCoreApplication>
+
 class FileReader : public QObject {
     Q_OBJECT
 public:
@@ -12,7 +14,8 @@ public:
     Q_INVOKABLE static QString readFile(const QString &fileName)
     {
         QString content;
-        QFile file(fileName);
+        QString qmlPath = QCoreApplication::applicationDirPath() + "/../qml/3rdparty/effects/";
+        QFile file(qmlPath + fileName);
         if (file.open(QIODevice::ReadOnly)) {
             QTextStream stream(&file);
             content = stream.readAll();

+ 0 - 16
src/helperfunctions.cpp

@@ -1,16 +0,0 @@
-#include "helperfunctions.h"
-
-HelperFunctions::HelperFunctions(QObject *parent) : QObject(parent)
-{
-    const int kAccelerationFactor = 1;
-    velocityArray = new qreal[kVelocityTableEntries];
-    for(int i = 0; i < kVelocityTableEntries; i++) {
-        velocityArray[i] = kAccelerationFactor*i/60;
-    }
-}
-
-qreal HelperFunctions::velocityForTick(int tick)
-{
-    int tock = qBound(0, tick, kVelocityTableEntries - 1);
-    return velocityArray[tock];
-}

+ 0 - 22
src/helperfunctions.h

@@ -1,22 +0,0 @@
-#ifndef HELPERFUNCTIONS_H
-#define HELPERFUNCTIONS_H
-
-#include <QObject>
-#include <qglobal.h>
-
-class HelperFunctions : public QObject
-{
-    Q_OBJECT
-public:
-    explicit HelperFunctions(QObject *parent = nullptr);
-    Q_SCRIPTABLE qreal velocityForTick(int tick);
-
-signals:
-
-public slots:
-private:
-    const int kVelocityTableEntries = 600;
-    qreal* velocityArray;
-};
-
-#endif // HELPERFUNCTIONS_H

+ 9 - 4
src/main.cpp

@@ -18,7 +18,6 @@
 
 #include "picturemodel.h"
 #include "filereader.h"
-#include "helperfunctions.h"
 
 #include <QGuiApplication>
 #include <QQmlApplicationEngine>
@@ -87,10 +86,16 @@ int main(int argc, char *argv[])
     QQmlApplicationEngine engine;
     qmlRegisterType<PictureModel>("PictureModel", 1, 0, "PictureModel");
 
-    engine.addImportPath("qrc:/");
+    QString qmlPath;
+    if (QDir(app.applicationDirPath()).dirName() == "src") {
+        qmlPath = QCoreApplication::applicationDirPath() % "/../qml";
+    } else {
+        qmlPath = "/usr/share/" % app.applicationName() % "/qml";
+    }
+
+    engine.addImportPath(qmlPath);
     engine.rootContext()->setContextProperty("fileReader", new FileReader(&app));
-    engine.rootContext()->setContextProperty("nativeHelper", new HelperFunctions(&app));
-    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+    engine.load(QUrl(qmlPath + "/main.qml"));
 
     return app.exec();
 }

+ 0 - 0
resources/artriculate.desktop → src/resources/artriculate.desktop


+ 0 - 0
resources/artriculate.png → src/resources/artriculate.png


+ 0 - 0
resources/artriculate@.service → src/resources/artriculate@.service


+ 0 - 0
resources/license-header → src/resources/license-header


+ 0 - 0
resources/qt_logo_green_rgb.png → src/resources/qt_logo_green_rgb.png


+ 5 - 0
src/resources/resources.qrc

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

+ 29 - 0
src/src.pro

@@ -0,0 +1,29 @@
+TEMPLATE = app
+
+QT += qml quick dbus sql
+CONFIG += c++11
+
+DEFINES *= QT_USE_QSTRINGBUILDER
+
+HEADERS += \
+    picturemodel.h \
+    filereader.h
+
+SOURCES += main.cpp \
+    picturemodel.cpp
+
+RESOURCES += resources/resources.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+TARGET = artriculate
+target.path = /usr/bin
+
+desktop.path = /usr/share/applications
+desktop.files += resources/artriculate.desktop
+
+icon.path = /usr/share/icons/hicolor/128x128/apps
+icon.files += resources/artriculate.png
+
+INSTALLS += target desktop icon