def _click_open_spatial_export_folder(self): output_folder = QFileDialog.getExistingDirectory( self, f"Select folder for spatial outputs", GuiSettings.settings().value("spatial_outputs"), QFileDialog.ShowDirsOnly) if os.path.exists(output_folder): GuiSettings.settings().setValue("spatial_outputs", output_folder) self.output_folder_input.setText(output_folder)
def _click_open_output(self): filters = ("GeoTIFF (*.tif *.tiff)") filename, _ = QFileDialog.getSaveFileName( self, f"Select output file", GuiSettings.settings().value(output_folder_settings), filters) if filename is None: return last_open_folder = os.path.dirname(filename) if os.path.exists(last_open_folder): GuiSettings.settings().setValue(output_folder_settings, last_open_folder) self._set_output_filename(filename)
def _click_open(self): filters = ("GeoTIFF (*.tif *.tiff);;" "Bathymetry Attributed Grid BAG (*.bag);;" "All files (*.*)") selections, _ = QFileDialog.getOpenFileNames( self, f"Open {self.band_name} file", GuiSettings.settings().value(input_folder_settings), filters) if len(selections) == 0: return last_open_folder = os.path.dirname(selections[0]) if os.path.exists(last_open_folder): GuiSettings.settings().setValue(input_folder_settings, last_open_folder) self._set_filename(selections[0])
def initialize(self): self.qax_widget.initialize() self.settings = GuiSettings.settings() self.resize( QtCore.QSize( int(self.settings.value("qax_app_width", defaultValue=920)), int(self.settings.value("qax_app_height", defaultValue=840)), ))
def _click_add(self): """ Add files selected by user. Opens file selection dialog """ import_folder_name = "{}_import_folder".format( self.file_group.clean_name()) filters = [] if len(self.file_group.file_types) > 0: all_ext = [ "*.{}".format(ft.extension) for ft in self.file_group.file_types ] all_formats = "Supported formats ({})".format(" ".join(all_ext)) filters.append(all_formats) for ft in self.file_group.file_types: filters.append("{} (*.{})".format(ft.name, ft.extension)) filters.append("All files (*.*)") # ask the file path to the user # noinspection PyCallByClass selections, _ = QtWidgets.QFileDialog.getOpenFileNames( self, "Add {} file".format(self.file_group.name.lower()), GuiSettings.settings().value(import_folder_name), ";; ".join(filters)) if len(selections) == 0: logger.debug('adding raw: aborted') return last_open_folder = os.path.dirname(selections[0]) if os.path.exists(last_open_folder): GuiSettings.settings().setValue(import_folder_name, last_open_folder) new_selected_files = [ os.path.abspath(selection).replace("\\", "/") for selection in selections ] self.selected_files.extend(new_selected_files) self._update_file_list() self.files_added.emit(self.file_group)
def _add_check_outputs(self): co_groupbox = QGroupBox("Check outputs") co_groupbox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) co_layout = QVBoxLayout() co_layout.setSpacing(16) co_groupbox.setLayout(co_layout) self.qajson_spatial_checkbox = QCheckBox( "Include summary spatial output in QAJSON. " "Supports QAX visualisation.") self.qajson_spatial_checkbox.setCheckState( QtCore.Qt.CheckState.Checked) co_layout.addWidget(self.qajson_spatial_checkbox) export_layout = QVBoxLayout() export_layout.setSpacing(4) self.export_spatial_checkbox = QCheckBox( "Export detailed spatial outputs to file. " "Supports visualisation in other geospatial applications.") self.export_spatial_checkbox.stateChanged.connect( self._on_export_spatial_changed) export_layout.addWidget(self.export_spatial_checkbox) output_folder_layout = QHBoxLayout() output_folder_layout.setSpacing(4) output_folder_layout.addSpacerItem(QtWidgets.QSpacerItem(37, 20)) self.output_folder_label = QLabel( "Detailed spatial output folder location:") output_folder_layout.addWidget(self.output_folder_label) self.output_folder_input = QLineEdit() self.output_folder_input.setText( GuiSettings.settings().value("spatial_outputs")) self.output_folder_input.setMinimumWidth(300) self.output_folder_input.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) output_folder_layout.addWidget(self.output_folder_input) self.open_output_folder_button = QPushButton() output_folder_layout.addWidget(self.open_output_folder_button) self.open_output_folder_button.setIcon(qta.icon('fa.folder-open')) self.open_output_folder_button.setToolTip( f"Select file containing data") self.open_output_folder_button.clicked.connect( self._click_open_spatial_export_folder) export_layout.addLayout(output_folder_layout) co_layout.addLayout(export_layout) self._on_export_spatial_changed() self.vbox.addWidget(co_groupbox)