1
0

7 Коммитууд 05d1b74ed9 ... 96fedd1594

Эзэн SHA1 Мессеж Огноо
  Donald Carr 96fedd1594 White background; 16 columns population works well 5 жил өмнө
  Donald Carr a1eb52e0c7 Reduce amplitude 5 жил өмнө
  Donald Carr 0570e6c2ed Cease to load full sized images 5 жил өмнө
  Donald Carr 52f27bd712 Fork the FullSizedArtImage 5 жил өмнө
  Donald Carr de45f68a33 Add Qt wobble effect to effect list 5 жил өмнө
  Donald Carr c28c1e7011 Always allow for develoment qml to override backed in qml 5 жил өмнө
  Donald Carr c4b9fc0a58 code.chaos-reins.com is the browseable gogs instance 5 жил өмнө

+ 1 - 1
qml/3rdparty/effects/Effects.qml

@@ -3,7 +3,7 @@ pragma Singleton
 import QtQuick 2.5
 
 Item {
-    property var names: ["Emboss", "Billboard", "GaussianBlur"]
+    property var names: ["Emboss", "Billboard", "GaussianBlur", "Wobble"]
     property var components: []
     property string randomEffectText: "Random"
 

+ 9 - 0
qml/3rdparty/effects/Wobble.qml

@@ -0,0 +1,9 @@
+import QtQuick 2.8
+
+Effect {
+    property real amplitude: 0.04 * 0.01
+    property real frequency: 20
+    property real time: 0
+    NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
+    fragmentShader: Qt.resolvedUrl("shaders/wobble.fsh")
+}

+ 21 - 0
qml/3rdparty/effects/shaders/wobble.fsh

@@ -0,0 +1,21 @@
+#ifdef GL_ES
+    precision mediump float;
+#else
+#   define lowp
+#   define mediump
+#   define highp
+#endif // GL_ES
+
+uniform lowp float qt_Opacity;
+uniform highp float amplitude;
+uniform highp float frequency;
+uniform highp float time;
+uniform sampler2D source;
+
+varying highp vec2 qt_TexCoord0;
+
+void main()
+{
+    highp vec2 p = sin(time + frequency * qt_TexCoord0);
+    gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;
+}

+ 5 - 18
qml/common/ArtImage.qml

@@ -14,28 +14,15 @@ Rectangle {
     color: globalSettings.randomBackdropColor ? Qt.rgba(Math.random(255), Math.random(255), Math.random(255), 1.0) : "black"
 
     height: width*nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height/nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width
-    width: parent ? parent.width : 0
+    width: globalVars.imageWidthOverride
 
     Image {
         id: image
         cache: false
         opacity: globalSettings.fadeInImages ? 0 : 1.0
 
-        x: globalSettings.artFrameWidth
-        y: globalSettings.artFrameWidth
-
-        height: (globalVars.imageWidthOverride > 0
-                 ? Math.ceil(globalVars.imageWidthOverride*nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height/nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width)
-                 : nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height
-                 ) - 2*globalSettings.artFrameWidth
-
-        width: (globalVars.imageWidthOverride > 0
-                ? globalVars.imageWidthOverride
-                : nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width
-                ) - 2*globalSettings.artFrameWidth
-
-        transformOrigin: Item.TopLeft
-        scale: (root.width - 2*globalSettings.artFrameWidth)/image.width
+        height: root.height
+        width: root.width
 
         asynchronous: true
         fillMode: Image.PreserveAspectFit
@@ -43,8 +30,8 @@ Rectangle {
         source: nativeUtils.imageCollection.data(modelIndex)
 
         mirror: globalSettings.randomlyMirrorArt && (Math.random() < globalSettings.randomlyMirrorArtFreq)
-        smooth: globalSettings.smoothArt
-        mipmap: !globalSettings.smoothArt
+        smooth: true
+        mipmap: false
 
         sourceSize.height: height
         sourceSize.width: width

+ 77 - 0
qml/common/FullSizedArtImage.qml

@@ -0,0 +1,77 @@
+import QtQuick 2.5
+import PictureModel 1.0
+
+import ".."
+
+Rectangle {
+    id: root
+    property var effect
+    property int modelIndex
+
+    property alias asynchronous: image.asynchronous
+    property alias source: image.source
+
+    color: globalSettings.randomBackdropColor ? Qt.rgba(Math.random(255), Math.random(255), Math.random(255), 1.0) : "black"
+
+    height: width*nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height/nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width
+    width: parent ? parent.width : 0
+
+    Image {
+        id: image
+        cache: false
+        opacity: globalSettings.fadeInImages ? 0 : 1.0
+
+        x: globalSettings.artFrameWidth
+        y: globalSettings.artFrameWidth
+
+        height: (globalVars.imageWidthOverride > 0
+                 ? Math.ceil(globalVars.imageWidthOverride*nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height/nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width)
+                 : nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).height
+                 ) - 2*globalSettings.artFrameWidth
+
+        width: (globalVars.imageWidthOverride > 0
+                ? globalVars.imageWidthOverride
+                : nativeUtils.imageCollection.data(modelIndex, PictureModel.SizeRole).width
+                ) - 2*globalSettings.artFrameWidth
+
+        transformOrigin: Item.TopLeft
+        scale: (root.width - 2*globalSettings.artFrameWidth)/image.width
+
+        asynchronous: true
+        fillMode: Image.PreserveAspectFit
+
+        source: nativeUtils.imageCollection.data(modelIndex)
+
+        mirror: globalSettings.randomlyMirrorArt && (Math.random() < globalSettings.randomlyMirrorArtFreq)
+        smooth: globalSettings.smoothArt
+        mipmap: !globalSettings.smoothArt
+
+        sourceSize.height: height
+        sourceSize.width: width
+
+        Behavior on opacity {
+            enabled: image.asynchronous
+            SequentialAnimation {
+                ScriptAction { script: root.effect !== undefined ? root.effect.scheduleUpdate() : undefined }
+                NumberAnimation { duration: 1000 }
+            }
+        }
+
+        onStatusChanged: {
+            if (status === Image.Ready) {
+                opacity = globalSettings.artOpacity
+            }
+        }
+    }
+
+    Component.onCompleted: {
+        modelIndex = nativeUtils.imageCollection.requestIndex()
+        if (globalSettings.effect !== "" && Effects.validate(globalSettings.effect)) {
+            var component = Qt.createComponent("VisualEffect.qml");
+            component.status !== Component.Ready && console.log('Component failed with:' + component.errorString())
+            root.effect = component.createObject(root, { target: image, effect: globalSettings.effect })
+        }
+    }
+
+    Component.onDestruction: nativeUtils.imageCollection.retireIndex(modelIndex)
+}

+ 5 - 0
qml/views/trivial/Trivial.qml

@@ -59,6 +59,11 @@ Item {
         }
     }
 
+    Rectangle {
+        color: "white"
+        anchors.fill: parent
+    }
+
     Timer {
         id: settleTimer
         interval: 5000

+ 17 - 7
src/main.cpp

@@ -108,7 +108,7 @@ public:
 
 private:
     QString localPath;
-    QString webPath;
+    QString remotePath;
     QQuickView *view = nullptr;
     static QQmlEngine* sharedQmlEngine;
     bool prioritizeRemoteCopy;
@@ -128,8 +128,14 @@ ArtView::ArtView(QScreen *screen)
     // https://g.chaos-reins.com/sirspudd/artriculate/raw/master/qml/main.qml
 
     // A word to the wise; establish the latency on github raw content before pursuing loading it from there
-    webPath = settings.value("remoteQMLUrl", "https://g.chaos-reins.com/sirspudd/artriculate/raw/master/qml").toString();
-    settings.setValue("remoteQMLUrl", webPath);
+    remotePath = settings.value("remoteQMLUrl", "https://code.chaos-reins.com/sirspudd/artriculate/raw/master/qml").toString();
+    settings.setValue("remoteQMLUrl", remotePath);
+
+    QString qmlDevPath = settings.value("qmlDevPath", "/opt/dev/src/artriculate/qml").toString();
+    settings.setValue("qmlDevPath", qmlDevPath);
+
+    bool qmlDevPathOverride = settings.value("qmlDevPathOverride", false).toBool();
+    settings.setValue("qmlDevPathOverride", qmlDevPathOverride);
 
 #ifdef COMPILED_RESOURCES
     localPath = "qrc:/qml";
@@ -137,9 +143,13 @@ ArtView::ArtView(QScreen *screen)
     if (QCoreApplication::applicationDirPath().startsWith("/usr")) {
         localPath = "/usr/share/" % qApp->applicationName() % "/qml";
     } else {
-        localPath = QString("%1%2").arg(ORIGINAL_SOURCE_PATH).arg("/../qml");
+        localPath = QString("%1%2").arg(QCoreApplication::applicationDirPath()).arg("/qml");
     }
 #endif
+    if (QFileInfo::exists(qmlDevPath) && qmlDevPathOverride) {
+        qDebug() << "Explicitly overriding local qml path with:" << qmlDevPath;
+        localPath = qmlDevPath;
+    }
 
     if (sharedQmlEngine) {
         view = new QQuickView(sharedQmlEngine, nullptr);
@@ -148,7 +158,6 @@ ArtView::ArtView(QScreen *screen)
 
         sharedQmlEngine = view->engine();
         // Seems academic given QML files still need to explicitly import ".." the topmost qmldir
-        sharedQmlEngine->addImportPath(webPath);
         sharedQmlEngine->rootContext()->setContextProperty("nativeUtils", new NativeUtils(sharedQmlEngine));
         QObject::connect(sharedQmlEngine, &QQmlEngine::quit, qApp, &QCoreApplication::quit);
     }
@@ -167,7 +176,8 @@ ArtView::ArtView(QScreen *screen)
     }
     view->setResizeMode(QQuickView::SizeRootObjectToView);
     if (prioritizeRemoteCopy) {
-        view->setSource(QUrl(webPath + "/main.qml"));
+        view->engine()->addImportPath(remotePath);
+        view->setSource(QUrl(remotePath + "/main.qml"));
     } else {
         view->setSource(QUrl(localPath + "/main.qml"));
     }
@@ -180,7 +190,7 @@ ArtView::ArtView(QScreen *screen)
         if (status == QQuickView::Error) {
             if (prioritizeRemoteCopy) {
                 prioritizeRemoteCopy = false;
-                qDebug() << "Failed to load qml from:" << webPath;
+                qDebug() << "Failed to load qml from:" << remotePath;
                 qDebug() << "Attemping local copy!:" << localPath;
                 sharedQmlEngine->addImportPath(localPath);
                 QMetaObject::invokeMethod(view, "setSource", Qt::QueuedConnection, QGenericReturnArgument(), Q_ARG(QUrl, QUrl(localPath + "/main.qml")));