Commit graph

94 commits

Author SHA1 Message Date
Alex Pyrgiotis
79ccd14d5d
Fix PySide2 issue for Ubuntu Focal
Provide a fallback for QRegularExpressionValidator specifically for
Ubuntu Focal, because it's not present in PySide2 5.14. Instead,
fallback to QRegExpValidator if it doesn't exist.

Fixes #339
2023-02-21 20:17:05 +02:00
deeplow
275df80484
GUI: exit with 1 when some conversion failed
Fixes: #318
2023-02-08 17:24:55 +00:00
deeplow
81e9ccf30a
Add PySide6 dependency for Windows and MacOS
We're not yet adding them to Linux, since PySide6 is not yet available
in Linux distros' packages, whereas with Linux and macOS our packaging
process includes the shipped binaries.

Fixes #211
2023-01-30 11:42:18 +00:00
deeplow
ab2f9ead9a
Replace PySide2-stubs with types-PySide2
Replace PySide2-stubs with types-PySide2, both of which are projects
that provide PySide2 typing hints, for the following reasons:

1. types-PySide2 is more complete and allows us to ditch some 'type:
   ignore' comments for Mypy.
2. PySide2-stubs also brings PySide2 as a dependency, which cannot be
   installed in MacOS M1 machines.

Refs #177
2023-01-30 11:42:09 +00:00
deeplow
a339eff648
Add dummy conversion to GUI 2023-01-25 14:53:26 +00:00
deeplow
538df18709
Split isolation providers into their own .py files
Provides more clear code organization having each provider in their own
python file rather than a single one.
2023-01-25 14:19:05 +00:00
deeplow
a4f27afdc6
Abstract container into an IsolationProvider
Encapsulate container logic into an implementation of
AbstractIsolationProvider. This flexibility will allow for other types
of isolation managers, such as a Dummy one.
2023-01-24 11:03:39 +00:00
deeplow
1114a0dfa1
Rename container.py to isolation_provider.py
First step in encapsulating the isolation provider.
2023-01-24 11:03:36 +00:00
deeplow
c406c95cec
GUI: Add version to header bar
Fixes #219
2023-01-16 14:39:27 +00:00
deeplow
766c455929
Windows: persist "Open safe documents after converting" setting
Now that safe PDFs can open on Windows right after conversion
(implemented in commit 5b2fefd), we need to save/load the "Open safe
documents after converting" setting.
2022-12-01 15:02:31 +00:00
deeplow
7e42994f81
Prevent user from adding files from multiple dirs
Allowing this would lead to several UI edge-cases related to where the
files would be saved. Avoiding this is the easiest solution at the
moment.

In the future we should consider other options.
2022-11-30 12:49:20 +00:00
deeplow
06797ab626
Prevent adding duplicate documents
It was possible that users would add duplicate documents via 'open with
Dangerzone'. This would lead to unexpected situations and preventing it
both in the CLI and the GUI solves those issues.
2022-11-30 12:49:18 +00:00
deeplow
65d0b7a0d0
Allow adding more docs via 'open_with' while in settings
Handle the case where a user has already added some documents (either
through 'open with' or via Dangerzone 'select documents' button) and
then they want to add some more via the 'open_with' dialog.

It updates the settings to reflect the newly added documents and blocks
the user from adding them if a conversion is already in progress.
2022-11-30 12:49:17 +00:00
deeplow
cb68ba7d1c
Centralize 'document adding' in ContentWidget
Makes the ContentWidget a choke-point, where we can allow or prevent
adding more documents and where we can ensure that newly selected
documents are added immediately to the DangerzoneGui class.

Logically, the application flow should not change in any way.
2022-11-30 12:49:16 +00:00
deeplow
af5f7c70d3
Quit dangerzone on macOS when window is closed
Closing windows on macOS would not actually close Dangerzone. Now that
it is a single-window program, it makes sense for it to close
immediately.

Fixes #271
2022-11-29 16:01:27 +00:00
deeplow
466d83129e
Increase minimum window width for macOS
The save group box would get partially trimmed when running in macOS
this appears to be due to differences in rendering fonts and widget
sizes.

Refs #270
2022-11-29 15:56:09 +00:00
deeplow
49b7736cb4
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.
2022-11-24 11:16:38 +00:00
deeplow
bbd0d98f50
Implement 'move to subdir' logic & store in settings
Fixes #251 by implementing the logic for archiving a document after
conversion into a default sub-directory.
2022-11-24 11:16:30 +00:00
deeplow
d3e125de55
Remove mypy ignore comments
For some reason, mypy was complaining that these statements were no
longer unreachable, but now it no longer is.
2022-11-24 11:16:28 +00:00
deeplow
8a31b085ee
Adjust window / settings widget proportions to fit
With the added new widgets not all widgets in the settings fit
perfectly.
2022-11-24 11:15:02 +00:00
deeplow
994e70c17a
Switch save widgets order
Move the 'safe_extension' widget to the top of the settings and the save
location widget to the bottom.
2022-11-24 09:32:15 +00:00
deeplow
bc82163bc4
Inform user # of selected docs when in settings
Reminds the users of the number of documents selected when they are in
the settings.
2022-11-24 09:05:24 +00:00
deeplow
5b2fefd150
Open PDFs on Windows (instead of explorer.exe)
Homogenize GUI by having on Windows the option of opening documents after
conversion. This removes the need for windows-specific GTK widgets.
2022-11-21 12:39:29 +00:00
deeplow
8b3739707d
Rename document_selected to documents_selected 2022-11-21 12:39:24 +00:00
deeplow
aba699a238
Pass Documents instead of file list in document_selected
In the various UI widgets we need to know which documents were just
added. Previously, we passed the filenames around via a PySides signal.
2022-11-21 12:39:23 +00:00
deeplow
39621fe51d
Limit n. parallel conversions in GUI
Limit the number of simultaneous document conversions to prevent
consuming too much CPU.
2022-11-21 12:39:20 +00:00
deeplow
45a865aae3
Prompt on exit: abort conversion?
Foot-shooting prevention by prompting the user if they are sure
they want to quit Dangerzone with ongoing conversions in progress.
2022-11-21 12:39:16 +00:00
deeplow
3c1e8a232d
Get OCR settings before conversion starts
In preparation for adding a limit on how many convert threads exist, we
are simplifying its logic. Getting ocr_lang doesn't seem to belong to
the thread.
2022-11-21 12:38:42 +00:00
deeplow
95a0536c61
Change start button text to plural when multiple docs 2022-11-21 12:38:27 +00:00
deeplow
06bd117d52
Align document labels
Aligns document labels following the design specified in issue #117.
It did not specify how it would change with window resize, so it
currently expands the progress bar / error message width and keeps the
document name fixed in size.
2022-11-21 12:38:25 +00:00
deeplow
bbc70df43b
Match styling of document-labels to design reference
- removes bold
- removes font size (default works)
- removes 'suspicious: ' label before the document name
2022-11-21 12:38:24 +00:00
deeplow
6707cbbc4a
Add conversion status icon next to each document
Allows the user to see the staus of each document at a gance.
2022-11-21 12:38:23 +00:00
deeplow
9641a61bb3
Typing: ignore 'unreachable' lint warning
Mypy complains about a line being unreachable. This is probably a false
positive. It must assume the code is not using a framework and thus it
can't when a PySide 'connect()' is being called.
2022-11-21 12:38:21 +00:00
deeplow
ce4efc0c25
Lint mypy: ignore type inconsistency w/ official docs
The official docs state the setProperty() method is (str, Any) but
mypy-pyside says it is (bytes, Any). So we ignore it.

[1]: https://doc.qt.io/qtforpython-5/PySide2/QtCore/QObject.html#PySide2.QtCore.PySide2.QtCore.QObject.setProperty
2022-11-21 12:38:20 +00:00
deeplow
df8e2f1b8b
Remove window management logic
Since everything now happens in a single window, there is no need
to have a way to keep track other windows. They simply won't exist.

But on windows and Linux it will still be possible to start
multiple windows by starting various Dangerzone processes. On MacOS
this doesn't seem to be as easy from the launcher, but it should
not be critical as multiple documents can be converted at the same
time in the one window.
2022-11-21 12:38:19 +00:00
deeplow
c40502fb46
Don't close MainWindow when first conversion ends
First step in removing the multi-window approach, which got replaced
by multi-document single-window.

Fixes #205.
2022-11-21 12:38:14 +00:00
deeplow
f791dc70ab
Hide widgets: select docs -> settings -> conversion
To help debugging and visualizing what was happening, we set all
widgets to be visible at the same time. Now that is no longer needed,
we can hide them.

This keeps the original program flow:
  1. select the documents
  2. set the settings
  3. see the conversion progress

This diverges from the proposed design in issue #117 for simplification
and consistency (with past program flow) purposes.
2022-11-21 12:38:13 +00:00
deeplow
41017745ec
Add greyed out document name right before '-safe.pdf'
The user is supposed to only be able to select the safe PDF extension.
In a multi-file scenario, the extension will be the same for all files.

We follow here the design document [1]. To achieve this, we needed a
QLabel right next to a QLineEdit, to give the user the illusion that
it is the same graphical object.

[1]: https://github.com/firstlookmedia/dangerzone/files/6657536/DangerZone_NA02a.pdf
2022-11-21 12:38:12 +00:00
deeplow
e64954acfa
Validate safe-extension (-safe.pdf) before converting
Avoid conversion issues when saving the output file when it is set
wrongly. Inform the user with a red box saying "must end in .pdf"
and prevent the user from clicking "convert" before that is fixed.

Combines the validation logic with the already-existing 'update_ui()'
2022-11-21 12:38:09 +00:00
deeplow
1790231db0
Set default output dir and allow users changing it
Set the default directory for saving the file as the one from
the first document. This one will show just the directory name.
If the user changes it by choosing another directory, then show the new
directory name and its full path.
2022-11-21 12:37:57 +00:00
deeplow
4a42627f45
GUI settings: enable & adapt to muti-document
- shows settings again
- removes documents arg from settings widget - this is now stored
  under DangerzoneGui instance.
- removes widget 'dangerous_doc_label' - the doc label is already
  shown next to each document.
- 'Save as' button now serves the purpose of selecting where all
  output files should be saved. Before, it was for selecting where
  the file would be saved.
- 'save_lineedit' widget which was read-only and showed the path
  where the file would be saved, it now called 'safe_suffix' and is
  writable. It is where the user can type the safe file extension
  (e.g. '-safe.pdf'). Validation is not yet implemented.
- when 'start_button' is clicked it now changes the output_filename
  of all the documents to set their output directory to the one the
  user has selected (if 'save_checkbox' enabled) and to set their
  new 'safe_suffix'
- change to plural text for selection of multiple documents
2022-11-21 12:37:49 +00:00
deeplow
2e477b8a12
Initial refactor: GUI one-window multi-document support
Allows the user to:
  a) specify filenames via the terminal (for the GUI)
  b) select multiple documents via the GUI

The conversion process can't yet be started since the settings are
broken and disabled (expect mypy complaints).
2022-11-21 12:37:45 +00:00
deeplow
a8001d4f3e
Comment out settings_widget temporarily
The settings widget will be broken when we add multiple document
support in the GUI, at first, at least.
2022-11-21 12:37:43 +00:00
deeplow
bf8ca96a44
Rename 'convert_widget' to 'documents_list' 2022-11-21 12:37:42 +00:00
deeplow
0444fc56ec
Temporarily show all dangerzone widgets (for debugging) 2022-11-21 12:37:41 +00:00
deeplow
6d2fdf0afe
Deduplicate container output parsing (stdout_callback)
The container output logging logic was in both the CLI and the GUI.
This change moves the core parsing logic to container.py.

Since the code was largely the same, now cli does need to specify
a stdout_callback since all the necessary logging already happens.

The GUI now only adds an stdout_callback to detect if there was an
error during the conversion process.
2022-11-14 08:54:02 +00:00
deeplow
981716ccff
Sequential bulk document support in cli
Basic implementation of bulk document support in dangerzone-cli.

Usage: dangerzone-cli [OPTIONS] doc1.pdf doc2.pdf
2022-11-14 08:51:00 +00:00
deeplow
649e427486
Make DangerzoneGui a subclass of DangerzoneCore
Simplify state sharing by having all dangerzone core logic in one
single class instead of two.
2022-10-27 13:44:16 +01:00
deeplow
dca290fb6b
Rename gui.common.GuiCommon class to gui.logic.DangerzoneGui
Rename the `gui.common` module and `gui.common.GuiCommon` class
to `gui.logic` and `gui.logic.DangerzoneGui` respectively. We keep as is
the original names of the variables that hold instances of this class,
since they will change in subsequent commits.

This change is part of the initial refactor to make the DangerzoneGui
class handle the GUI logic of the Dangerzone project.
2022-10-27 13:44:15 +01:00
deeplow
cb8130042e
Rename global_common.GlobalCommon class to logic.Dangerzone
Rename the `global_common` module and `global_common.GlobalCommon` class
to `logic` and `logic.Dangerzone` respectively. Also rename variables
that hold instances of this class.

This change is part of the initial refactor to make the Dangerzone class
handle the core logic of the Dangerzone project.
2022-10-27 13:44:13 +01:00