|
@@ -7,9 +7,8 @@ from PySide6.QtWidgets import QMainWindow, QMessageBox
|
|
from sqlalchemy.exc import OperationalError
|
|
from sqlalchemy.exc import OperationalError
|
|
|
|
|
|
from logger import logger
|
|
from logger import logger
|
|
-from module import create_filename
|
|
|
|
-from module.cam import IPCam, USBCam, load_image
|
|
|
|
-from module.lang.ru import *
|
|
|
|
|
|
+from module import create_filename, translate
|
|
|
|
+from module.cam import IPCam, USBCam
|
|
from module.MyMessageBox import show_dialog
|
|
from module.MyMessageBox import show_dialog
|
|
from module.Printer import Print
|
|
from module.Printer import Print
|
|
from module.QRCode import make as make_qr
|
|
from module.QRCode import make as make_qr
|
|
@@ -18,10 +17,11 @@ from module.WorkWithDB import *
|
|
from module.wkhtmltopdf import get_path_wkhtmltopdf
|
|
from module.wkhtmltopdf import get_path_wkhtmltopdf
|
|
from module.ImageTool import rotate_image
|
|
from module.ImageTool import rotate_image
|
|
from widgets import PStackedWidget, create_widget_stacked
|
|
from widgets import PStackedWidget, create_widget_stacked
|
|
|
|
+from module.cam.USBCam import get_first_cam
|
|
|
|
|
|
from .DialogAbout import DialogAbout
|
|
from .DialogAbout import DialogAbout
|
|
from .DialogHistory import DialogHistory
|
|
from .DialogHistory import DialogHistory
|
|
-from .DialogSettingCam import SettingCam
|
|
|
|
|
|
+from .DialogSettingCam import DialogSettingCam
|
|
from .ListPersonal import ListPersonal
|
|
from .ListPersonal import ListPersonal
|
|
from .ListPlace import ListPlace
|
|
from .ListPlace import ListPlace
|
|
from .ui_py.ui_MainWindow import Ui_MainWindow
|
|
from .ui_py.ui_MainWindow import Ui_MainWindow
|
|
@@ -30,13 +30,19 @@ vecrot_cam_from_db = [str, str, str]
|
|
|
|
|
|
|
|
|
|
class MainWindow(QMainWindow, Ui_MainWindow):
|
|
class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
|
+ __wwc: IPCam | USBCam = None
|
|
|
|
+ data_propusk: dict = None
|
|
|
|
+ stacked_face: PStackedWidget = None
|
|
|
|
+ __file_name_document: str = None
|
|
|
|
+ __file_name_face: str = None
|
|
|
|
+ __mode: str = 'video'
|
|
|
|
+ __cam_face: str = get_first_cam()
|
|
|
|
+ __cam_document: str = get_first_cam()
|
|
|
|
+
|
|
def __init__(self, parent=None) -> None:
|
|
def __init__(self, parent=None) -> None:
|
|
|
|
|
|
super(MainWindow, self).__init__(parent)
|
|
super(MainWindow, self).__init__(parent)
|
|
self.setupUi(self)
|
|
self.setupUi(self)
|
|
- self.__wwc = None
|
|
|
|
- self.data_propusk = None
|
|
|
|
- self.stacked_face = None
|
|
|
|
|
|
|
|
self.date_from.setDateTime(QDateTime().currentDateTime())
|
|
self.date_from.setDateTime(QDateTime().currentDateTime())
|
|
self.date_to.setDateTime(QDateTime().currentDateTime())
|
|
self.date_to.setDateTime(QDateTime().currentDateTime())
|
|
@@ -97,7 +103,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
|
|
|
def __show_setting_cam_window(self) -> None:
|
|
def __show_setting_cam_window(self) -> None:
|
|
self.__stop_cam()
|
|
self.__stop_cam()
|
|
- SettingCam(self).exec_()
|
|
|
|
|
|
+ DialogSettingCam(self).exec_()
|
|
self.__check_setting_cam()
|
|
self.__check_setting_cam()
|
|
self.__create_widget_face_cam()
|
|
self.__create_widget_face_cam()
|
|
|
|
|
|
@@ -112,30 +118,30 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
|
|
|
def __checked_rotate_document(self) -> bool:
|
|
def __checked_rotate_document(self) -> bool:
|
|
return self.rotate_image_document.isChecked()
|
|
return self.rotate_image_document.isChecked()
|
|
-
|
|
|
|
|
|
+
|
|
def __check_setting_cam(self) -> None:
|
|
def __check_setting_cam(self) -> None:
|
|
try:
|
|
try:
|
|
self.__mode, self.__cam_face, self.__cam_document = self.__get_selected_cam()
|
|
self.__mode, self.__cam_face, self.__cam_document = self.__get_selected_cam()
|
|
except ValueError:
|
|
except ValueError:
|
|
- logger.warning(warring_cams.get("title"))
|
|
|
|
|
|
+ logger.warning(translate('Cameras not configured'))
|
|
if show_dialog(
|
|
if show_dialog(
|
|
QMessageBox.Warning,
|
|
QMessageBox.Warning,
|
|
- warring_cams.get("title"),
|
|
|
|
- warring_cams.get("body")
|
|
|
|
|
|
+ translate('Cameras not configured'),
|
|
|
|
+ translate('Set up the camera \nSettings -> Camera settings')
|
|
):
|
|
):
|
|
self.__show_setting_cam_window()
|
|
self.__show_setting_cam_window()
|
|
self.__check_setting_cam()
|
|
self.__check_setting_cam()
|
|
else:
|
|
else:
|
|
self.close()
|
|
self.close()
|
|
except TypeError:
|
|
except TypeError:
|
|
- logger.warning(warring_cams.get("title"))
|
|
|
|
|
|
+ logger.warning(translate('Cameras not configured'))
|
|
|
|
|
|
def __check_wkhtmltopdf(self) -> None:
|
|
def __check_wkhtmltopdf(self) -> None:
|
|
if get_path_wkhtmltopdf() is None:
|
|
if get_path_wkhtmltopdf() is None:
|
|
- logger.critical('Не установлена программа wkhtmltopdf')
|
|
|
|
- show_dialog(QMessageBox.Icon.Critical,
|
|
|
|
- "Не найден wkhtmltopdf",
|
|
|
|
- "Не установлена программа wkhtmltopdf")
|
|
|
|
|
|
+ logger.critical(translate('wkhtmltopdf not installed'))
|
|
|
|
+ show_dialog(QMessageBox.Icon.Critical,
|
|
|
|
+ translate("Not found wkhtmltopdf"),
|
|
|
|
+ translate("wkhtmltopdf not installed"))
|
|
sys.exit(0)
|
|
sys.exit(0)
|
|
|
|
|
|
def __update_list_combobox(self) -> None:
|
|
def __update_list_combobox(self) -> None:
|
|
@@ -182,11 +188,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
try:
|
|
try:
|
|
return cam[0].mode, cam[0].selected_cam, cam[1].selected_cam
|
|
return cam[0].mode, cam[0].selected_cam, cam[1].selected_cam
|
|
except:
|
|
except:
|
|
- logger.error('Нет записи о камерах')
|
|
|
|
|
|
+ logger.error(translate('Missing camera records'))
|
|
if show_dialog(
|
|
if show_dialog(
|
|
QMessageBox.Icon.Critical,
|
|
QMessageBox.Icon.Critical,
|
|
- 'Камера',
|
|
|
|
- 'Отсутствуют записи о камерах'
|
|
|
|
|
|
+ translate('Camera'),
|
|
|
|
+ translate('Missing camera records')
|
|
):
|
|
):
|
|
self.__show_setting_cam_window()
|
|
self.__show_setting_cam_window()
|
|
self.__check_setting_cam()
|
|
self.__check_setting_cam()
|
|
@@ -202,12 +208,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
if self.__wwc is None:
|
|
if self.__wwc is None:
|
|
widget.to_video()
|
|
widget.to_video()
|
|
self.__create_wwc(widget, cam)
|
|
self.__create_wwc(widget, cam)
|
|
- self.btn_start_cam.setText(stop_cam)
|
|
|
|
|
|
+ self.btn_start_cam.setText(translate('Launch сamera'))
|
|
|
|
|
|
else:
|
|
else:
|
|
self.__stop_cam()
|
|
self.__stop_cam()
|
|
widget.to_image()
|
|
widget.to_image()
|
|
- self.btn_start_cam.setText(start_cam)
|
|
|
|
|
|
+ self.btn_start_cam.setText(translate('Stop camera'))
|
|
|
|
|
|
def __create_wwc(self, widget: PStackedWidget, cam: str) -> None:
|
|
def __create_wwc(self, widget: PStackedWidget, cam: str) -> None:
|
|
if self.__mode in 'snapshot':
|
|
if self.__mode in 'snapshot':
|
|
@@ -215,9 +221,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
self.__wwc.qLabel = widget.video
|
|
self.__wwc.qLabel = widget.video
|
|
self.__wwc.lnk_connect = cam
|
|
self.__wwc.lnk_connect = cam
|
|
self.__wwc.start()
|
|
self.__wwc.start()
|
|
- else:
|
|
|
|
|
|
+ elif self.__mode in ('video', 'document'):
|
|
self.__wwc = USBCam(widget.video, cam)
|
|
self.__wwc = USBCam(widget.video, cam)
|
|
self.__wwc.start_cam()
|
|
self.__wwc.start_cam()
|
|
|
|
+ else:
|
|
|
|
+ logger.error(F"{translate('No corrected')}: {self.__mode}")
|
|
|
|
|
|
def __take_image(self) -> None:
|
|
def __take_image(self) -> None:
|
|
if self.tabWidget.currentIndex() == 1:
|
|
if self.tabWidget.currentIndex() == 1:
|
|
@@ -229,7 +237,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
self.stacked_face.image)
|
|
self.stacked_face.image)
|
|
self.stacked_face.to_image()
|
|
self.stacked_face.to_image()
|
|
|
|
|
|
- self.btn_start_cam.setText(start_cam)
|
|
|
|
|
|
+ self.btn_start_cam.setText(translate('Launch сamera'))
|
|
|
|
|
|
# self.__stop_cam()
|
|
# self.__stop_cam()
|
|
|
|
|
|
@@ -288,11 +296,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
list_propusk.insert().values(**self.data_propusk)
|
|
list_propusk.insert().values(**self.data_propusk)
|
|
)
|
|
)
|
|
|
|
|
|
- show_dialog(QMessageBox.Icon.Information, '', 'Сохранено')
|
|
|
|
|
|
+ show_dialog(QMessageBox.Icon.Information, '', translate('Save success'))
|
|
except OperationalError as er:
|
|
except OperationalError as er:
|
|
logger.error(er)
|
|
logger.error(er)
|
|
- show_dialog(QMessageBox.Icon.Critical, 'Ошибка',
|
|
|
|
- 'Произошла ошибка при сохранении! \n Обратитесь к администратору')
|
|
|
|
|
|
+ show_dialog(QMessageBox.Icon.Critical, translate('Error'),
|
|
|
|
+ 'An error occurred while saving! \n Please contact your administrator')
|
|
|
|
|
|
def __set_default_data(self) -> None:
|
|
def __set_default_data(self) -> None:
|
|
self.number_propusk.clear()
|
|
self.number_propusk.clear()
|
|
@@ -302,10 +310,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
if self.__wwc is not None:
|
|
if self.__wwc is not None:
|
|
self.__stop_cam()
|
|
self.__stop_cam()
|
|
|
|
|
|
- self.stacked_document.to_image()
|
|
|
|
- self.stacked_face.to_image()
|
|
|
|
- load_image(self.stacked_document, os.environ.get('NO_MEDIA_IMAGE'))
|
|
|
|
- load_image(self.stacked_face, os.environ.get('NO_MEDIA_IMAGE'))
|
|
|
|
|
|
+ self.stacked_document.set_default_image()
|
|
|
|
+ self.stacked_face.set_default_image()
|
|
|
|
|
|
self.receiving_man.clear()
|
|
self.receiving_man.clear()
|
|
self.purpose_visite.clear()
|
|
self.purpose_visite.clear()
|
|
@@ -315,10 +321,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
self.__wwc.stop_cam()
|
|
self.__wwc.stop_cam()
|
|
self.__wwc = None
|
|
self.__wwc = None
|
|
|
|
|
|
- self.btn_start_cam.setText(start_cam)
|
|
|
|
|
|
+ self.btn_start_cam.setText(translate('Launch сamera'))
|
|
|
|
|
|
def __create_widget_face_cam(self) -> None:
|
|
def __create_widget_face_cam(self) -> None:
|
|
- self.gridLayout.removeWidget(self.stacked_face)
|
|
|
|
|
|
+ if self.stacked_face is not None:
|
|
|
|
+ self.gridLayout.removeWidget(self.stacked_face)
|
|
|
|
|
|
self.stacked_face = create_widget_stacked(
|
|
self.stacked_face = create_widget_stacked(
|
|
name_object=u'stacked_face',
|
|
name_object=u'stacked_face',
|
|
@@ -332,6 +339,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|
|
|
|
|
def __change_text_btn(self) -> None:
|
|
def __change_text_btn(self) -> None:
|
|
if self.stacked_face.currentIndex() == 0:
|
|
if self.stacked_face.currentIndex() == 0:
|
|
- self.btn_start_cam.setText(stop_cam)
|
|
|
|
|
|
+ self.btn_start_cam.setText(translate('Stop camera'))
|
|
else:
|
|
else:
|
|
- self.btn_start_cam.setText(start_cam)
|
|
|
|
|
|
+ self.btn_start_cam.setText(translate('Launch сamera'))
|