diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..4ad6550 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,30 @@ +name: Build Detektor binarie + +on: + push: + branches: [ dev ] + +jobs: + build_macos: + runs-on: macos + # alpine doesn't have prebuilt wheels + container: python:3.13-slim + + steps: + - name: Checkout + run: | + apt update -y + apt install -y --no-install-recommends git + git clone ${{ gitea.server_url }}/${{ gitea.repository }} . + git checkout ${{ gitea.ref_name }} + + - name: Install deps + run: | + python -m venv venv + . venv/bin/activate + python -m pip install --upgrade pip setuptools wheel + pip install -r requirements.txt + pip list + + - name: Build binary + run: python -m PyInstaller build-config/macos_build.spec diff --git a/README.md b/README.md new file mode 100644 index 0000000..ab5eb12 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Detektor +bla bla bla diff --git a/requirements.txt b/requirements.txt index f62079f..48c39ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -PyQt6==6.8.0 +PyQt6==6.8.* pyinstaller==6.11.1 wheel==0.45.1 pyqtgraph==0.13.7 @@ -7,4 +7,4 @@ dbfread==2.0.7 openpyxl==3.1.5 xlsxwriter==3.2.2 PyOpenGL==3.1.9 -PyOpenGL_accelerate==3.1.9 +#PyOpenGL_accelerate==3.1.9 diff --git a/src/channel_calibration_dialog.py b/src/channel_calibration_dialog.py index 50da021..c45fd85 100644 --- a/src/channel_calibration_dialog.py +++ b/src/channel_calibration_dialog.py @@ -71,8 +71,9 @@ class ChannelCalibrationDialog(QDialog): channel_layout.addWidget(RoundedColorRectangleWidget(ch.color)) + from PyQt6.QtCore import QLocale float_validator = CustomDoubleValidator() - # float_validator.setLocale("C") + float_validator.setLocale(QLocale(QLocale.Language.C)) # Přičíst input add_layout = QVBoxLayout() @@ -138,8 +139,15 @@ class ChannelCalibrationDialog(QDialog): # get the current channel object of the current (duplicated dataset) channel = DetektorContainer().get().get_channel_by_uuid(channel_id) - offset = float(self.add_input.text()) - multiple = float(self.multiply_input.text()) + try: + # validate inputs + offset = float(self.add_input.text().replace(',', '.')) + multiple = float(self.multiply_input.text().replace(',', '.')) + except ValueError: + WrongDataDialog() + return + + logging.debug(f'Calibrating channel {channel.name} +{offset} x{multiple}') if self._only_region: @@ -178,12 +186,37 @@ class MissingChannelDialog(QDialog): self.setWindowTitle("Vyberte kanál") self.setModal(True) # Set the dialog as modal (blocks main window) - self.resize(300, 150) + self.resize(400, 75) # Main layout main_layout = QVBoxLayout() self.setLayout(main_layout) - main_layout.addWidget(QLabel("Vyberte kanál, na kterém chcete provést kalibraci")) + label = QLabel("Vyberte kanál, na kterém chcete provést kalibraci") + label.setAlignment(Qt.AlignmentFlag.AlignCenter) + main_layout.addWidget(label) + + cancel_button = QPushButton("OK") + cancel_button.clicked.connect(self.close) + main_layout.addWidget(cancel_button) + + # Show the dialog + self.exec() + + +class WrongDataDialog(QDialog): + def __init__(self): + super().__init__() + + self.setWindowTitle("Špatná data") + self.setModal(True) # Set the dialog as modal (blocks main window) + self.resize(400, 75) + + # Main layout + main_layout = QVBoxLayout() + self.setLayout(main_layout) + label = QLabel("Zadaná data nejsou platná čísla.") + label.setAlignment(Qt.AlignmentFlag.AlignCenter) + main_layout.addWidget(label) cancel_button = QPushButton("OK") cancel_button.clicked.connect(self.close) @@ -193,6 +226,18 @@ class MissingChannelDialog(QDialog): self.exec() class CustomDoubleValidator(QDoubleValidator): + def validate(self, input_str, pos): - input_str = input_str.replace(',', '.') # Replace ',' with '.' - return super().validate(input_str, pos) \ No newline at end of file + # Accept both comma and dot as decimal separator for validation + if ',' in input_str: + # Allow comma as intermediate state so user can type it + test_str = input_str.replace(',', '.') + state, _, _ = super().validate(test_str, pos) + if state == QDoubleValidator.State.Acceptable: + return (QDoubleValidator.State.Intermediate, input_str, pos) + return (QDoubleValidator.State.Intermediate, input_str, pos) + return super().validate(input_str, pos) + + def fixup(self, input_str): + # Actually replace comma with dot in the QLineEdit + return input_str.replace(',', '.') \ No newline at end of file