Parcourir la source

tweak webcam window, slider less accurate, resize properly after constructor.

Thomas Buck il y a 3 ans
Parent
révision
5ce498a2ce
1 fichiers modifiés avec 11 ajouts et 15 suppressions
  1. 11
    15
      src/octotray.py

+ 11
- 15
src/octotray.py Voir le fichier

@@ -154,9 +154,9 @@ class AspectRatioPixmapLabel(QLabel):
154 154
 
155 155
 class CamWindow(QWidget):
156 156
     reloadDelayDefault = 1000 # in ms
157
-    statusDelay = 10 * 1000 # in ms
158
-    addSize = 100
157
+    statusDelay = 5 * 1000 # in ms
159 158
     reloadOn = True
159
+    sliderFactor = 100
160 160
 
161 161
     def __init__(self, parent, printer, *args, **kwargs):
162 162
         super(CamWindow, self).__init__(*args, **kwargs)
@@ -186,13 +186,13 @@ class CamWindow(QWidget):
186 186
         box.addLayout(slide, 0)
187 187
 
188 188
         self.slider = QSlider(Qt.Horizontal)
189
-        self.slider.setMinimum(0)
190
-        self.slider.setMaximum(2000)
191
-        self.slider.setTickInterval(100)
192
-        self.slider.setPageStep(100)
193
-        self.slider.setSingleStep(100)
189
+        self.slider.setMinimum(int(0 / self.sliderFactor))
190
+        self.slider.setMaximum(int(2000 / self.sliderFactor))
191
+        self.slider.setTickInterval(int(100 / self.sliderFactor))
192
+        self.slider.setPageStep(int(100 / self.sliderFactor))
193
+        self.slider.setSingleStep(int(100 / self.sliderFactor))
194 194
         self.slider.setTickPosition(QSlider.TicksBelow)
195
-        self.slider.setValue(self.reloadDelayDefault)
195
+        self.slider.setValue(int(self.reloadDelayDefault / self.sliderFactor))
196 196
         self.slider.valueChanged.connect(self.sliderChanged)
197 197
         slide.addWidget(self.slider, 1)
198 198
 
@@ -203,10 +203,6 @@ class CamWindow(QWidget):
203 203
         box.addWidget(self.statusLabel, 0)
204 204
         box.setAlignment(label, Qt.AlignHCenter)
205 205
 
206
-        size = self.size()
207
-        size.setHeight(size.height() + self.addSize)
208
-        self.resize(size)
209
-
210 206
         self.loadImage()
211 207
         self.loadStatus()
212 208
 
@@ -214,7 +210,7 @@ class CamWindow(QWidget):
214 210
         return self.host
215 211
 
216 212
     def sliderChanged(self):
217
-        self.slideLabel.setText(str(self.slider.value()) + "ms")
213
+        self.slideLabel.setText(str(self.slider.value() * self.sliderFactor) + "ms")
218 214
 
219 215
     def closeEvent(self, event):
220 216
         self.reloadOn = False
@@ -223,7 +219,7 @@ class CamWindow(QWidget):
223 219
 
224 220
     def scheduleLoadImage(self):
225 221
         if self.reloadOn:
226
-            QTimer.singleShot(self.slider.value(), self.loadImage)
222
+            QTimer.singleShot(self.slider.value() * self.sliderFactor, self.loadImage)
227 223
 
228 224
     def scheduleLoadStatus(self):
229 225
         if self.reloadOn:
@@ -699,7 +695,7 @@ class OctoTray():
699 695
         y = (screenGeometry.height() - self.settingsWindow.height()) / 2
700 696
         x += screenGeometry.x()
701 697
         y += screenGeometry.y()
702
-        self.settingsWindow.setGeometry(int(x), int(y), int(self.settingsWindow.width()), int(self.settingsWindow.height()))
698
+        self.settingsWindow.setGeometry(int(x), int(y), int(self.settingsWindow.width()), int(self.settingsWindow.height()) + 50)
703 699
 
704 700
     def removeSettingsWindow(self):
705 701
         self.settingsWindow = None

Chargement…
Annuler
Enregistrer