92 lines
3.5 KiB
Python
92 lines
3.5 KiB
Python
"""Application settings 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,
|
|
QGroupBox,
|
|
QLineEdit,
|
|
QVBoxLayout,
|
|
)
|
|
|
|
from ..config import Settings
|
|
|
|
|
|
class SettingsDialog(QDialog):
|
|
"""Edit persistent application preferences."""
|
|
|
|
def __init__(self, settings: Settings, parent=None):
|
|
super().__init__(parent)
|
|
self.setWindowTitle("Preferences")
|
|
self.setMinimumWidth(440)
|
|
self._settings = settings
|
|
|
|
ui = QGroupBox("Interface")
|
|
uf = QFormLayout(ui)
|
|
self.show_hidden = QCheckBox("Show hidden files in filesystem pane")
|
|
self.show_hidden.setChecked(settings.show_hidden)
|
|
uf.addRow(self.show_hidden)
|
|
self.confirm_delete = QCheckBox("Confirm before deleting entries")
|
|
self.confirm_delete.setChecked(settings.confirm_delete)
|
|
uf.addRow(self.confirm_delete)
|
|
|
|
defaults = QGroupBox("New Image Defaults")
|
|
df = QFormLayout(defaults)
|
|
self.d_label = QLineEdit(settings.default_volume_label)
|
|
df.addRow("Volume label:", self.d_label)
|
|
self.d_level = QComboBox()
|
|
self.d_level.addItems(["1", "2", "3"])
|
|
self.d_level.setCurrentText(str(settings.default_interchange_level))
|
|
df.addRow("ISO9660 level:", self.d_level)
|
|
self.d_joliet = QCheckBox("Joliet")
|
|
self.d_joliet.setChecked(bool(settings.default_joliet))
|
|
df.addRow(self.d_joliet)
|
|
self.d_rr = QCheckBox("Rock Ridge")
|
|
self.d_rr.setChecked(bool(settings.default_rock_ridge))
|
|
df.addRow(self.d_rr)
|
|
self.d_udf = QCheckBox("UDF (new)")
|
|
self.d_udf.setChecked(bool(settings.default_udf))
|
|
df.addRow(self.d_udf)
|
|
|
|
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
|
buttons.accepted.connect(self.accept)
|
|
buttons.rejected.connect(self.reject)
|
|
|
|
layout = QVBoxLayout(self)
|
|
layout.addWidget(ui)
|
|
layout.addWidget(defaults)
|
|
layout.addStretch(1)
|
|
layout.addWidget(buttons)
|
|
|
|
def apply_to(self, settings: Settings) -> Settings:
|
|
settings.show_hidden = self.show_hidden.isChecked()
|
|
settings.confirm_delete = self.confirm_delete.isChecked()
|
|
settings.default_volume_label = self.d_label.text() or "CDROM"
|
|
settings.default_interchange_level = int(self.d_level.currentText())
|
|
settings.default_joliet = 3 if self.d_joliet.isChecked() else 0
|
|
settings.default_rock_ridge = "1.09" if self.d_rr.isChecked() else ""
|
|
settings.default_udf = "2.60" if self.d_udf.isChecked() else ""
|
|
return settings
|