"""ISO volume properties dialog (view + edit metadata).""" # This file is part of ISO Scalpel. # Copyright (C) 2025 Jeremy Anderson # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see # or write to the Free Software Foundation, Inc., 51 Franklin Street, # Fifth Floor, Boston, MA 02110-1301 USA. from __future__ import annotations from PySide6.QtWidgets import ( QDialog, QDialogButtonBox, QFormLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit, QPushButton, QVBoxLayout, ) from ..iso_handler import IsoHandler from ..iso_record import _human_size class PropertiesDialog(QDialog): """Display and edit volume descriptors of the open image.""" def __init__(self, handler: IsoHandler, parent=None): super().__init__(parent) self.setWindowTitle("ISO Properties") self.setMinimumWidth(520) self._handler = handler props = handler.get_properties() # --- editable identity -------------------------------------------- id_group = QGroupBox("Volume Identity") f = QFormLayout(id_group) self.volume_label = QLineEdit(props.volume_label) self.volume_label.setMaxLength(32) f.addRow("Volume label:", self.volume_label) self.publisher = QLineEdit(props.publisher) f.addRow("Publisher:", self.publisher) self.preparer = QLineEdit(props.preparer) f.addRow("Data preparer:", self.preparer) self.application = QLineEdit(props.application) f.addRow("Application:", self.application) self.system_id = QLineEdit(props.system_id) f.addRow("System ID:", self.system_id) self.volume_set_id = QLineEdit(props.volume_set_id) f.addRow("Volume set ID:", self.volume_set_id) # --- read-only image info ----------------------------------------- info_group = QGroupBox("Image Information") info = QFormLayout(info_group) info.addRow("File:", QLabel(handler.filename or "(unsaved)")) info.addRow("Image size:", QLabel(_human_size(props.total_size))) info.addRow("Block size:", QLabel(f"{props.block_size} bytes")) info.addRow("ISO9660 level:", QLabel(str(props.interchange_level))) info.addRow("Extensions:", QLabel(", ".join(props.extensions) or "(none)")) # --- buttons ------------------------------------------------------- self.apply_label_btn = QPushButton("Apply Label") self.apply_label_btn.setToolTip( "Write the volume label back to the image (does not save to disk)") buttons = QDialogButtonBox(QDialogButtonBox.Close) buttons.rejected.connect(self.reject) buttons.accepted.connect(self.accept) self.apply_label_btn.clicked.connect(self._apply_label) bl = QHBoxLayout() bl.addWidget(self.apply_label_btn) bl.addStretch(1) bl.addWidget(buttons) layout = QVBoxLayout(self) layout.addWidget(id_group) layout.addWidget(info_group) layout.addStretch(1) layout.addLayout(bl) def _apply_label(self) -> None: self._handler.set_volume_label(self.volume_label.text()) self.publisher.setEnabled(False) self.preparer.setEnabled(False) self.application.setEnabled(False)