143 lines
5.9 KiB
Python
143 lines
5.9 KiB
Python
"""New ISO image options dialog."""
|
|
|
|
# This file is part of ISO Scalpel.
|
|
# Copyright (C) 2025 Jeremy Anderson <info@dcos.net>
|
|
#
|
|
# 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 <https://www.gnu.org/licenses/>
|
|
# 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 (
|
|
QCheckBox,
|
|
QComboBox,
|
|
QDialog,
|
|
QDialogButtonBox,
|
|
QFormLayout,
|
|
QGridLayout,
|
|
QGroupBox,
|
|
QLabel,
|
|
QLineEdit,
|
|
QVBoxLayout,
|
|
)
|
|
|
|
from ..iso_handler import NewIsoOptions
|
|
|
|
|
|
class NewIsoDialog(QDialog):
|
|
"""Collect the options used to create a fresh image."""
|
|
|
|
def __init__(self, settings, parent=None):
|
|
super().__init__(parent)
|
|
self.setWindowTitle("New ISO Image")
|
|
self.setMinimumWidth(460)
|
|
self._settings = settings
|
|
|
|
# --- volume identity ----------------------------------------------
|
|
vol_group = QGroupBox("Volume Identity")
|
|
vol_form = QFormLayout(vol_group)
|
|
self.volume_label = QLineEdit(settings.default_volume_label)
|
|
self.volume_label.setMaxLength(32)
|
|
vol_form.addRow("Volume label:", self.volume_label)
|
|
|
|
self.publisher = QLineEdit()
|
|
vol_form.addRow("Publisher:", self.publisher)
|
|
self.preparer = QLineEdit()
|
|
vol_form.addRow("Data preparer:", self.preparer)
|
|
self.application = QLineEdit("ISO Scalpel")
|
|
vol_form.addRow("Application:", self.application)
|
|
self.system_id = QLineEdit()
|
|
vol_form.addRow("System ID:", self.system_id)
|
|
self.volume_set_id = QLineEdit(" ")
|
|
vol_form.addRow("Volume set ID:", self.volume_set_id)
|
|
|
|
# --- extensions ----------------------------------------------------
|
|
ext_group = QGroupBox("Extensions")
|
|
ext_grid = QGridLayout(ext_group)
|
|
|
|
ext_grid.addWidget(QLabel("ISO9660 interchange level:"), 0, 0)
|
|
self.interchange = QComboBox()
|
|
self.interchange.addItems(["1 (8.3 names)", "2 (32 chars)", "3 (32 chars, multi-extent)"])
|
|
self.interchange.setCurrentIndex(max(0, settings.default_interchange_level - 1))
|
|
ext_grid.addWidget(self.interchange, 0, 1)
|
|
|
|
self.joliet = QCheckBox("Joliet (Microsoft long names, Unicode)")
|
|
self.joliet.setChecked(bool(settings.default_joliet))
|
|
ext_grid.addWidget(self.joliet, 1, 0, 1, 2)
|
|
|
|
self.joliet_level = QComboBox()
|
|
self.joliet_level.addItems(["Level 1", "Level 2", "Level 3"])
|
|
self.joliet_level.setCurrentIndex((settings.default_joliet or 3) - 1)
|
|
ext_grid.addWidget(QLabel("Joliet level:"), 2, 0)
|
|
ext_grid.addWidget(self.joliet_level, 2, 1)
|
|
|
|
self.rock_ridge = QCheckBox("Rock Ridge (Unix long names + permissions)")
|
|
self.rock_ridge.setChecked(bool(settings.default_rock_ridge))
|
|
ext_grid.addWidget(self.rock_ridge, 3, 0, 1, 2)
|
|
|
|
self.rr_version = QComboBox()
|
|
self.rr_version.addItems(["1.09", "1.12"])
|
|
self.rr_version.setCurrentText(settings.default_rock_ridge or "1.09")
|
|
ext_grid.addWidget(QLabel("Rock Ridge version:"), 4, 0)
|
|
ext_grid.addWidget(self.rr_version, 4, 1)
|
|
|
|
self.udf = QCheckBox("UDF (Universal Disk Format — new in this port)")
|
|
self.udf.setChecked(bool(settings.default_udf))
|
|
ext_grid.addWidget(self.udf, 5, 0, 1, 2)
|
|
|
|
self.udf_version = QComboBox()
|
|
self.udf_version.addItems(["2.50", "2.60"])
|
|
self.udf_version.setCurrentText(settings.default_udf or "2.60")
|
|
ext_grid.addWidget(QLabel("UDF version:"), 6, 0)
|
|
ext_grid.addWidget(self.udf_version, 6, 1)
|
|
|
|
self.xa = QCheckBox("XA (Extended Attributes)")
|
|
ext_grid.addWidget(self.xa, 7, 0, 1, 2)
|
|
|
|
# --- block size ----------------------------------------------------
|
|
ext_grid.addWidget(QLabel("Logical block size:"), 8, 0)
|
|
self.block_size = QComboBox()
|
|
self.block_size.addItems(["2048", "4096", "8192"])
|
|
self.block_size.setCurrentText(str(settings.default_block_size))
|
|
ext_grid.addWidget(self.block_size, 8, 1)
|
|
|
|
# --- buttons -------------------------------------------------------
|
|
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
|
buttons.accepted.connect(self.accept)
|
|
buttons.rejected.connect(self.reject)
|
|
|
|
layout = QVBoxLayout(self)
|
|
layout.addWidget(vol_group)
|
|
layout.addWidget(ext_group)
|
|
layout.addStretch(1)
|
|
layout.addWidget(buttons)
|
|
|
|
# ------------------------------------------------------------------ result
|
|
def options(self) -> NewIsoOptions:
|
|
opts = NewIsoOptions()
|
|
opts.volume_label = self.volume_label.text().strip() or "CDROM"
|
|
opts.interchange_level = self.interchange.currentIndex() + 1
|
|
opts.block_size = int(self.block_size.currentText())
|
|
opts.joliet = (self.joliet_level.currentIndex() + 1) if self.joliet.isChecked() else None
|
|
opts.rock_ridge = self.rr_version.currentText() if self.rock_ridge.isChecked() else None
|
|
opts.udf = self.udf_version.currentText() if self.udf.isChecked() else None
|
|
opts.publisher = self.publisher.text()
|
|
opts.preparer = self.preparer.text()
|
|
opts.application = self.application.text() or "ISO Scalpel"
|
|
opts.system_id = self.system_id.text()
|
|
opts.volume_set_id = self.volume_set_id.text() or " "
|
|
opts.xa = self.xa.isChecked()
|
|
return opts
|