Procházet zdrojové kódy

Attempt to generalize Basic out to View and Basic

Change-Id: I23cb3cdcab6818be3c9db184ce1d9e62bc73d3a9
Donald Carr před 9 roky
rodič
revize
a187f68e4f
5 změnil soubory, kde provedl 39 přidání a 47 odebrání
  1. 2 45
      qml/basic/Basic.qml
  2. 32 0
      qml/common/View.qml
  3. 3 2
      qml/main.qml
  4. 1 0
      qml/qml.qrc
  5. 1 0
      qml/qmldir

+ 2 - 45
qml/basic/Basic.qml

@@ -1,25 +1,11 @@
 import QtQuick 2.5
-import Box2D 2.0
 import Qt.labs.settings 1.0
 
 import ".."
 
-Item {
+View {
     id: root
 
-    signal togglePause
-    signal next
-
-    property var pictureDelegate: Component {
-        ArtImage {}
-    }
-
-    property var effectDelegate: Component {
-        VisualEffect {}
-    }
-
-    anchors.fill: parent
-
     Settings {
         id: basicSettings
         category: "Basic"
@@ -28,15 +14,6 @@ Item {
         property int easingType: Easing.Linear
     }
 
-    QtObject {
-        id: d
-        property var columnArray: []
-
-        function reset() {
-            columnArray = []
-        }
-    }
-
     Component {
         id: columnComponent
 
@@ -58,7 +35,7 @@ Item {
                 property bool initialized: false
 
                 Component.onCompleted: {
-                    d.columnArray.push(this)
+                    columnArray.push(this)
                 }
 
                 onFullChanged: {
@@ -132,29 +109,9 @@ Item {
                     }
                 }
             }
-
-            Connections {
-                target: root
-                onTogglePause: deathTimer.running = !deathTimer.running
-                onNext: deathTimer.triggered()
-            }
         }
     }
 
-    Timer {
-        id: globalDeathTimer
-        running: generalSettings.commonFeed && globalUtil.primed
-        repeat: true
-        interval: globalUtil.adjustedInterval
-        onTriggered: d.columnArray[globalUtil.columnSelection()].shift()
-    }
-
-    Repeater {
-        model: globalUtil.columnCount
-        delegate: columnComponent
-        onModelChanged: d.reset()
-    }
-
     Keys.onUpPressed: generalSettings.interval++
     Keys.onDownPressed: generalSettings.interval = Math.max(0, generalSettings.interval - 1)
 }

+ 32 - 0
qml/common/View.qml

@@ -0,0 +1,32 @@
+import QtQuick 2.5
+
+Item {
+    id: root
+
+    property var columnArray: []
+    property var pictureDelegate: Component {
+        ArtImage {}
+    }
+    property var effectDelegate: Component {
+        VisualEffect {}
+    }
+
+    function reset() {
+        columnArray = []
+    }
+
+    anchors.fill: parent
+
+    Timer {
+        id: globalDeathTimer
+        running: generalSettings.commonFeed && globalUtil.primed
+        repeat: true
+        interval: globalUtil.adjustedInterval
+        onTriggered: columnArray[globalUtil.columnSelection()].shift()
+    }
+
+    Repeater {
+        model: globalUtil.columnCount
+        delegate: columnComponent
+    }
+}

+ 3 - 2
qml/main.qml

@@ -21,7 +21,7 @@ Window {
 
         property bool commonFeedRoundRobin: generalSettings.commonFeedRoundRobin
         property int columnCount: generalSettings.columnCount
-        property int adjustedInterval: 1000*(generalSettings.interval > 60 ? 60*(generalSettings.interval-60) : generalSettings.interval)*(Math.random()+1)
+        property int adjustedInterval: 1000*(generalSettings.interval > 60 ? 60*(generalSettings.interval-60) : Math.max(generalSettings.interval, 1))
 
         function registerColumnPrimed() {
             d.primedColumns++
@@ -29,6 +29,7 @@ Window {
 
         function reset() {
             itemCount = currentColumn = d.primedColumns = 0
+            loader.item.reset()
         }
 
         function columnSelection() {
@@ -60,7 +61,7 @@ Window {
             globalUtil.reset()
         }
 
-        onColumnCountChanged: d.reset()
+        onColumnCountChanged: globalUtil.reset()
     }
 
     Rectangle {

+ 1 - 0
qml/qml.qrc

@@ -14,5 +14,6 @@
         <file>effects/GaussianBlur.qml</file>
         <file>effects/Effects.qml</file>
         <file>common/ArtImage.qml</file>
+        <file>common/View.qml</file>
     </qresource>
 </RCC>

+ 1 - 0
qml/qmldir

@@ -1,3 +1,4 @@
 singleton Effects 1.0 effects/Effects.qml
 ArtImage 1.0 common/ArtImage.qml
 VisualEffect 1.0 common/VisualEffect.qml
+View 1.0 common/View.qml