mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 10:12:38 +02:00
GUI: disable option if archive dir is not writable
Disable the option to move original documents to 'unsafe' subdirectory when said directory is not writable.
This commit is contained in:
parent
c36f73ac8d
commit
49b7736cb4
1 changed files with 18 additions and 1 deletions
|
@ -11,7 +11,7 @@ from typing import List, Optional
|
||||||
from colorama import Fore, Style
|
from colorama import Fore, Style
|
||||||
from PySide2 import QtCore, QtGui, QtWidgets
|
from PySide2 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
from .. import container
|
from .. import container, errors
|
||||||
from ..container import convert
|
from ..container import convert
|
||||||
from ..document import SAFE_EXTENSION, Document
|
from ..document import SAFE_EXTENSION, Document
|
||||||
from ..util import get_resource_path, get_subprocess_startupinfo
|
from ..util import get_resource_path, get_subprocess_startupinfo
|
||||||
|
@ -479,6 +479,20 @@ class SettingsWidget(QtWidgets.QWidget):
|
||||||
or self.open_checkbox.checkState() == QtCore.Qt.Checked
|
or self.open_checkbox.checkState() == QtCore.Qt.Checked
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def check_writeable_archive_dir(self, docs: List[Document]) -> None:
|
||||||
|
# assumed all documents are in the same directory
|
||||||
|
first_doc = docs[0]
|
||||||
|
try:
|
||||||
|
first_doc.validate_default_archive_dir()
|
||||||
|
except errors.UnwriteableArchiveDirException:
|
||||||
|
self.radio_move_untrusted.setDisabled(True)
|
||||||
|
self.radio_move_untrusted.setChecked(False)
|
||||||
|
self.radio_move_untrusted.setToolTip(
|
||||||
|
'Option disabled because Dangerzone couldn\'t create "untrusted"\n'
|
||||||
|
+ "subdirectory in the same directory as the original files."
|
||||||
|
)
|
||||||
|
self.radio_save_to.setChecked(True)
|
||||||
|
|
||||||
def update_ui(self) -> None:
|
def update_ui(self) -> None:
|
||||||
conversion_readiness_conditions = [
|
conversion_readiness_conditions = [
|
||||||
self.check_safe_extension_is_valid(),
|
self.check_safe_extension_is_valid(),
|
||||||
|
@ -504,6 +518,9 @@ class SettingsWidget(QtWidgets.QWidget):
|
||||||
|
|
||||||
self.update_ui()
|
self.update_ui()
|
||||||
|
|
||||||
|
# validations
|
||||||
|
self.check_writeable_archive_dir(selected_docs)
|
||||||
|
|
||||||
def select_output_directory(self) -> None:
|
def select_output_directory(self) -> None:
|
||||||
dialog = QtWidgets.QFileDialog()
|
dialog = QtWidgets.QFileDialog()
|
||||||
dialog.setLabelText(QtWidgets.QFileDialog.Accept, "Select output directory")
|
dialog.setLabelText(QtWidgets.QFileDialog.Accept, "Select output directory")
|
||||||
|
|
Loading…
Reference in a new issue