Преглед на файлове

Try to generalize a range of properties

Change-Id: I6188d99e3b09eb2edd507e0fda89542df7d1904b
Donald Carr преди 9 години
родител
ревизия
bce158c776
променени са 2 файла, в които са добавени 37 реда и са изтрити 34 реда
  1. 8 28
      qml/basic/Basic.qml
  2. 29 6
      qml/main.qml

+ 8 - 28
qml/basic/Basic.qml

@@ -26,35 +26,14 @@ Item {
 
         property int animationDuration: 2000
         property int easingType: Easing.Linear
-        property bool commonFeed: true
-        property bool commonFeedRoundRobin: true
     }
 
     QtObject {
         id: d
-        property int columnCount: generalSettings.columnCount
         property var columnArray: []
-        property int primedColumns: 0
-        property int currentColumn: 0
-        property bool commonFeedRoundRobin: basicSettings.commonFeedRoundRobin
 
         function reset() {
             columnArray = []
-            primedColumns = 0
-        }
-
-        function columnSelection() {
-            if (commonFeedRoundRobin) {
-                var ret = currentColumn
-                currentColumn = (currentColumn + 1) % d.columnCount
-                return ret
-            } else {
-                return Math.floor(Math.random()*d.columnCount)
-            }
-        }
-
-        onColumnCountChanged: {
-            reset()
         }
     }
 
@@ -85,7 +64,7 @@ Item {
                 onFullChanged: {
                     if (!initialized) {
                         initialized = true
-                        d.primedColumns++
+                        globalVars.registerColumnPrimed()
                     }
                 }
 
@@ -139,7 +118,7 @@ Item {
 
                 Timer {
                     id: deathTimer
-                    running: !basicSettings.commonFeed && artworkStack.initialized
+                    running: !generalSettings.commonFeed && artworkStack.initialized
                     repeat: true
                     interval: globalVars.adjustedInterval
                     onTriggered: artworkStack.shift()
@@ -164,17 +143,18 @@ Item {
 
     Timer {
         id: globalDeathTimer
-        running: basicSettings.commonFeed && (d.primedColumns === d.columnCount)
+        running: generalSettings.commonFeed && globalVars.primed
         repeat: true
         interval: globalVars.adjustedInterval
-        onTriggered: d.columnArray[d.columnSelection()].shift()
+        onTriggered: d.columnArray[globalVars.columnSelection()].shift()
     }
 
     Repeater {
-        model: d.columnCount
+        model: globalVars.columnCount
         delegate: columnComponent
+        onModelChanged: d.reset()
     }
 
-    Keys.onUpPressed: root.togglePause()
-    Keys.onDownPressed: root.next()
+    Keys.onUpPressed: generalSettings.interval++
+    Keys.onDownPressed: generalSettings.interval = Math.max(0, generalSettings.interval - 1)
 }

+ 29 - 6
qml/main.qml

@@ -8,18 +8,38 @@ Window {
     width: 1024
     height: 768
 
-
     QtObject {
         id: d
-        function reset() {
-            globalVars.itemCount = 0
-        }
+        property int primedColumns: 0
     }
 
     QtObject {
         id: globalVars
-        property int adjustedInterval: 1000*(generalSettings.interval > 60 ? 60*(generalSettings.interval-60) : generalSettings.interval)*(Math.random()+1)
         property int itemCount
+        property int currentColumn: 0
+        property bool primed: d.primedColumns === columnCount
+
+        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)
+
+        function registerColumnPrimed() {
+            d.primedColumns++
+        }
+
+        function reset() {
+            itemCount = currentColumn = d.primedColumns = 0
+        }
+
+        function columnSelection() {
+            if (commonFeedRoundRobin) {
+                var ret = currentColumn
+                currentColumn = (currentColumn + 1) % columnCount
+                return ret
+            } else {
+                return Math.floor(Math.random()*columnCount)
+            }
+        }
     }
 
     Settings {
@@ -32,9 +52,12 @@ Window {
         property bool smoothArt: false
         property bool randomlyMirrorArt: true
 
+        property bool commonFeed: true
+        property bool commonFeedRoundRobin: true
+
         onViewChanged: {
             loader.source = generalSettings.view.toLowerCase() + "/" + generalSettings.view + ".qml"
-            d.reset()
+            globalVars.reset()
         }
 
         onColumnCountChanged: d.reset()