video settings screen converted
This commit is contained in:
parent
238f7e367a
commit
423bda93c6
2 changed files with 126 additions and 67 deletions
|
@ -5,6 +5,7 @@ from ui.widgets import CenteredWidget, DataLabel, LineEdit, RubberBandWindow
|
||||||
import pyaudio
|
import pyaudio
|
||||||
import updater.updater as updater
|
import updater.updater as updater
|
||||||
import utils.ui as util_ui
|
import utils.ui as util_ui
|
||||||
|
import cv2
|
||||||
|
|
||||||
|
|
||||||
class AddContact(CenteredWidget):
|
class AddContact(CenteredWidget):
|
||||||
|
@ -761,70 +762,18 @@ class VideoSettings(CenteredWidget):
|
||||||
def __init__(self, settings):
|
def __init__(self, settings):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._settings = settings
|
self._settings = settings
|
||||||
self.initUI()
|
uic.loadUi(get_views_path('video_settings_screen'), self)
|
||||||
self.retranslateUi()
|
self._devices = self._frame_max_sizes = None
|
||||||
|
self._update_ui()
|
||||||
self.center()
|
self.center()
|
||||||
self.desktopAreaSelection = None
|
self.desktopAreaSelection = None
|
||||||
|
|
||||||
def initUI(self):
|
|
||||||
self.setObjectName("videoSettingsForm")
|
|
||||||
self.resize(400, 120)
|
|
||||||
self.setMinimumSize(QtCore.QSize(400, 120))
|
|
||||||
self.setMaximumSize(QtCore.QSize(400, 120))
|
|
||||||
self.in_label = QtWidgets.QLabel(self)
|
|
||||||
self.in_label.setGeometry(QtCore.QRect(25, 5, 350, 20))
|
|
||||||
font = QtGui.QFont()
|
|
||||||
font.setPointSize(16)
|
|
||||||
font.setBold(True)
|
|
||||||
font.setFamily(self._settings['font'])
|
|
||||||
self.in_label.setFont(font)
|
|
||||||
self.video_size = QtWidgets.QComboBox(self)
|
|
||||||
self.video_size.setGeometry(QtCore.QRect(25, 70, 350, 30))
|
|
||||||
self.input = QtWidgets.QComboBox(self)
|
|
||||||
self.input.setGeometry(QtCore.QRect(25, 30, 350, 30))
|
|
||||||
self.input.currentIndexChanged.connect(self.selectionChanged)
|
|
||||||
self.button = QtWidgets.QPushButton(self)
|
|
||||||
self.button.clicked.connect(self.button_clicked)
|
|
||||||
self.button.setGeometry(QtCore.QRect(25, 70, 350, 30))
|
|
||||||
import cv2
|
|
||||||
self.devices = [-1]
|
|
||||||
screen = QtWidgets.QApplication.primaryScreen()
|
|
||||||
size = screen.size()
|
|
||||||
self.frame_max_sizes = [(size.width(), size.height())]
|
|
||||||
desktop = util_ui.tr("Desktop")
|
|
||||||
self.input.addItem(desktop)
|
|
||||||
for i in range(10):
|
|
||||||
v = cv2.VideoCapture(i)
|
|
||||||
if v.isOpened():
|
|
||||||
v.set(cv2.CAP_PROP_FRAME_WIDTH, 10000)
|
|
||||||
v.set(cv2.CAP_PROP_FRAME_HEIGHT, 10000)
|
|
||||||
|
|
||||||
width = int(v.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
||||||
height = int(v.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
||||||
del v
|
|
||||||
self.devices.append(i)
|
|
||||||
self.frame_max_sizes.append((width, height))
|
|
||||||
self.input.addItem('Device #' + str(i))
|
|
||||||
try:
|
|
||||||
index = self.devices.index(self._settings.video['device'])
|
|
||||||
self.input.setCurrentIndex(index)
|
|
||||||
except:
|
|
||||||
print('Video devices error!')
|
|
||||||
|
|
||||||
def retranslateUi(self):
|
|
||||||
self.setWindowTitle(util_ui.tr("Video settings"))
|
|
||||||
self.in_label.setText(util_ui.tr("Device:"))
|
|
||||||
self.button.setText(util_ui.tr("Select region"))
|
|
||||||
|
|
||||||
def button_clicked(self):
|
|
||||||
self.desktopAreaSelection = DesktopAreaSelectionWindow(self)
|
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
if self.input.currentIndex() == 0:
|
if self.deviceComboBox.currentIndex() == 0:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self._settings.video['device'] = self.devices[self.input.currentIndex()]
|
self._settings.video['device'] = self.devices[self.input.currentIndex()]
|
||||||
text = self.video_size.currentText()
|
text = self.resolutionComboBox.currentText()
|
||||||
self._settings.video['width'] = int(text.split(' ')[0])
|
self._settings.video['width'] = int(text.split(' ')[0])
|
||||||
self._settings.video['height'] = int(text.split(' ')[-1])
|
self._settings.video['height'] = int(text.split(' ')[-1])
|
||||||
self._settings.save()
|
self._settings.save()
|
||||||
|
@ -840,15 +789,48 @@ class VideoSettings(CenteredWidget):
|
||||||
self._settings.video['y'] = y
|
self._settings.video['y'] = y
|
||||||
self._settings.save()
|
self._settings.save()
|
||||||
|
|
||||||
def selectionChanged(self):
|
def _update_ui(self):
|
||||||
if self.input.currentIndex() == 0:
|
self.deviceComboBox.currentIndexChanged.connect(self._device_changed)
|
||||||
self.button.setVisible(True)
|
self.selectRegionPushButton.clicked.connect(self._button_clicked)
|
||||||
self.video_size.setVisible(False)
|
self._devices = [-1]
|
||||||
else:
|
screen = QtWidgets.QApplication.primaryScreen()
|
||||||
self.button.setVisible(False)
|
size = screen.size()
|
||||||
self.video_size.setVisible(True)
|
self._frame_max_sizes = [(size.width(), size.height())]
|
||||||
width, height = self.frame_max_sizes[self.input.currentIndex()]
|
desktop = util_ui.tr("Desktop")
|
||||||
self.video_size.clear()
|
self.deviceComboBox.addItem(desktop)
|
||||||
|
for i in range(10):
|
||||||
|
v = cv2.VideoCapture(i)
|
||||||
|
if v.isOpened():
|
||||||
|
v.set(cv2.CAP_PROP_FRAME_WIDTH, 10000)
|
||||||
|
v.set(cv2.CAP_PROP_FRAME_HEIGHT, 10000)
|
||||||
|
|
||||||
|
width = int(v.get(cv2.CAP_PROP_FRAME_WIDTH))
|
||||||
|
height = int(v.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
||||||
|
del v
|
||||||
|
self._devices.append(i)
|
||||||
|
self._frame_max_sizes.append((width, height))
|
||||||
|
self.deviceComboBox.addItem(util_ui.tr('Device #') + str(i))
|
||||||
|
try:
|
||||||
|
index = self._devices.index(self._settings.video['device'])
|
||||||
|
self.deviceComboBox.setCurrentIndex(index)
|
||||||
|
except:
|
||||||
|
print('Video devices error!')
|
||||||
|
self._retranslate_ui()
|
||||||
|
|
||||||
|
def _retranslate_ui(self):
|
||||||
|
self.setWindowTitle(util_ui.tr("Video settings"))
|
||||||
|
self.deviceLabel.setText(util_ui.tr("Device:"))
|
||||||
|
self.selectRegionPushButton.setText(util_ui.tr("Select region"))
|
||||||
|
|
||||||
|
def _button_clicked(self):
|
||||||
|
self.desktopAreaSelection = DesktopAreaSelectionWindow(self)
|
||||||
|
|
||||||
|
def _device_changed(self):
|
||||||
|
index = self.deviceComboBox.currentIndex()
|
||||||
|
self.selectRegionPushButton.setVisible(index == 0)
|
||||||
|
self.resolutionComboBox.setVisible(index != 0)
|
||||||
|
width, height = self._frame_max_sizes[index]
|
||||||
|
self.resolutionComboBox.clear()
|
||||||
dims = [
|
dims = [
|
||||||
(320, 240),
|
(320, 240),
|
||||||
(640, 360),
|
(640, 360),
|
||||||
|
@ -860,7 +842,7 @@ class VideoSettings(CenteredWidget):
|
||||||
]
|
]
|
||||||
for w, h in dims:
|
for w, h in dims:
|
||||||
if w <= width and h <= height:
|
if w <= width and h <= height:
|
||||||
self.video_size.addItem(str(w) + ' * ' + str(h))
|
self.resolutionComboBox.addItem(str(w) + ' * ' + str(h))
|
||||||
|
|
||||||
|
|
||||||
class PluginsSettings(CenteredWidget):
|
class PluginsSettings(CenteredWidget):
|
||||||
|
|
77
toxygen/ui/views/video_settings_screen.ui
Normal file
77
toxygen/ui/views/video_settings_screen.ui
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Form</class>
|
||||||
|
<widget class="QWidget" name="Form">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>120</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>120</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>400</width>
|
||||||
|
<height>120</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" name="deviceLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>25</x>
|
||||||
|
<y>5</y>
|
||||||
|
<width>350</width>
|
||||||
|
<height>20</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" name="deviceComboBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>25</x>
|
||||||
|
<y>30</y>
|
||||||
|
<width>350</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="selectRegionPushButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>25</x>
|
||||||
|
<y>70</y>
|
||||||
|
<width>350</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" name="resolutionComboBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>25</x>
|
||||||
|
<y>70</y>
|
||||||
|
<width>350</width>
|
||||||
|
<height>30</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Reference in a new issue