Browse Source

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

Thomas Buck 3 years ago
parent
commit
5ce498a2ce
1 changed files with 11 additions and 15 deletions
  1. 11
    15
      src/octotray.py

+ 11
- 15
src/octotray.py View File

154
 
154
 
155
 class CamWindow(QWidget):
155
 class CamWindow(QWidget):
156
     reloadDelayDefault = 1000 # in ms
156
     reloadDelayDefault = 1000 # in ms
157
-    statusDelay = 10 * 1000 # in ms
158
-    addSize = 100
157
+    statusDelay = 5 * 1000 # in ms
159
     reloadOn = True
158
     reloadOn = True
159
+    sliderFactor = 100
160
 
160
 
161
     def __init__(self, parent, printer, *args, **kwargs):
161
     def __init__(self, parent, printer, *args, **kwargs):
162
         super(CamWindow, self).__init__(*args, **kwargs)
162
         super(CamWindow, self).__init__(*args, **kwargs)
186
         box.addLayout(slide, 0)
186
         box.addLayout(slide, 0)
187
 
187
 
188
         self.slider = QSlider(Qt.Horizontal)
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
         self.slider.setTickPosition(QSlider.TicksBelow)
194
         self.slider.setTickPosition(QSlider.TicksBelow)
195
-        self.slider.setValue(self.reloadDelayDefault)
195
+        self.slider.setValue(int(self.reloadDelayDefault / self.sliderFactor))
196
         self.slider.valueChanged.connect(self.sliderChanged)
196
         self.slider.valueChanged.connect(self.sliderChanged)
197
         slide.addWidget(self.slider, 1)
197
         slide.addWidget(self.slider, 1)
198
 
198
 
203
         box.addWidget(self.statusLabel, 0)
203
         box.addWidget(self.statusLabel, 0)
204
         box.setAlignment(label, Qt.AlignHCenter)
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
         self.loadImage()
206
         self.loadImage()
211
         self.loadStatus()
207
         self.loadStatus()
212
 
208
 
214
         return self.host
210
         return self.host
215
 
211
 
216
     def sliderChanged(self):
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
     def closeEvent(self, event):
215
     def closeEvent(self, event):
220
         self.reloadOn = False
216
         self.reloadOn = False
223
 
219
 
224
     def scheduleLoadImage(self):
220
     def scheduleLoadImage(self):
225
         if self.reloadOn:
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
     def scheduleLoadStatus(self):
224
     def scheduleLoadStatus(self):
229
         if self.reloadOn:
225
         if self.reloadOn:
699
         y = (screenGeometry.height() - self.settingsWindow.height()) / 2
695
         y = (screenGeometry.height() - self.settingsWindow.height()) / 2
700
         x += screenGeometry.x()
696
         x += screenGeometry.x()
701
         y += screenGeometry.y()
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
     def removeSettingsWindow(self):
700
     def removeSettingsWindow(self):
705
         self.settingsWindow = None
701
         self.settingsWindow = None

Loading…
Cancel
Save