Commit graph

119 commits

Author SHA1 Message Date
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
deeplow
2bed3c10e4
Move safe PDF naming logic to document.py
Let the Document class suggest the default filename for the safe PDF,
based on the provided input filename, appended with the extension
`-safe.pdf`.

Previously, this logic was copy-pasted throughout the code, which made
it difficult to maintain.
2022-10-27 13:44:12 +01:00
deeplow
e487b7f0a9
Instantiate documents with a filename
Avoid setting document's filename via document.filename and instead
do it via object instantiation where possible.

Incidentally this has to change some window logic. When
select_document() is called it no longer checks if there is already an
open window with no document selected yet. The user can open as many
windows with unselected documents as they want.
2022-10-27 13:44:03 +01:00
deeplow
0493aca036
Rename common.Common class to document.Document
Rename the `common` module and `common.Common` class to `document` and
`document.Document` respectively. Also, rename the variables that hold
instances of this class.

This change reflects the fact that the class is responsible for tracking
the state of the document. When we add bulk document conversion,
allowing us to keep track of a document's state will be key. This name
change is a step towards that.
2022-10-27 13:44:01 +01:00
deeplow
82ac22e837
remove hardcoded 'docker' logging reference
Closes #122 as this was the last remaining hardcoded docker
reference where the code also applied to podman.
2022-09-15 12:17:22 +01:00
deeplow
57e455bbf1
remove "container" from container.py method names
Container-related methods recently moved to container.py no longer
need to have 'container' in their name as they are within the
container scope already.

Additonally it made it awkward to call from another module:

    from .. import container
    container.get_container_runtime()
2022-09-15 12:09:38 +01:00
deeplow
6202c0dba9
deduplicate container-tech-checking logic
The logic for detecting if we were are running on docker or podman
and identifying its respective binary were scattered across the
codebase. This centralizes it all in container.py
2022-09-15 12:09:37 +01:00
deeplow
a822870853
move global_common container logic to container.py
Container-specific methods in global_common class were basically
static methods. So it made sense to move these to container.py
2022-09-15 12:09:34 +01:00
deeplow
272281a29e
move to util: get_subprocess_startupinfo 2022-09-15 10:40:36 +01:00
deeplow
ce57fc0449
move get_resource_path to util.py
static methods that are used application-wide should belong to
the utilities python file.

inspired by @gmarmstrong's PR #166 on refactoring global_common
methods to be static and have a dzutil.py
2022-09-15 09:24:11 +01:00
deeplow
f44e6521b6
better handle QFileDialog.getOpenFileName filename 2022-08-22 12:28:39 +01:00
deeplow
e0b3c5b599
resolve naming conflict: QWidget.update()
QWidget.update() is already a built-in Qt method [1]. This method
was unintentionally being overriden. Renamed it to update_progress
to fix it.

[1]: https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QWidget.html#PySide2.QtWidgets.PySide2.QtWidgets.QWidget.update
2022-08-22 11:13:37 +01:00
deeplow
46a62c1669
fix type hints with commonn input/output filename
Input_filename and output_filename could be None or Str. This lead
to typing issues where the static analysis type hint tool could not
check that the type colisions would not happen in runtime.

So the logic was replaced by throwing a runtime exception if either
of these valiables is ever used without first having been set.
2022-08-22 11:12:16 +01:00
deeplow
665e4d54f7
add type hints (1st pass: non problematic cases) 2022-08-22 10:33:28 +01:00
deeplow
d579a47a84
add type hints (1st pass: non problematic cases) 2022-08-22 10:33:23 +01:00
deeplow
4d8e4c53e3
sort imports with isort linter 2022-08-22 10:15:26 +01:00
deeplow
67d91be81a
replace prints with logging
fixes #144: printing non-ascii characters in a macOS application
opened directly from finder would sometimes lead to an error
message in /var/log/system.log similar to this:

  Failed to execute script 'dangerzone' due to unhandled exception:
  'ascii' codec can't encode character '\u201c' in position 1:
  ordinal not in range(128)
2022-08-18 12:07:23 +01:00
Micah Lee
d90097e7af
In GUI only use OCR if the OCR box is checked 2021-12-13 11:32:41 -08:00
Micah Lee
369ffe6cea
Allow opening external links in the WaitingWidget label 2021-11-30 14:59:05 -08:00
Micah Lee
8d40555bf5
Prevent background windows from popping up for subprocess calls in Windows 2021-11-29 14:55:31 -08:00
Micah Lee
e6d90a5729
Show more details on failure 2021-11-24 12:35:43 -08:00
Micah Lee
7c4f35e0f8
Delete old function in global_common, and remove useless stuff from container.convert 2021-11-23 16:20:51 -08:00
Micah Lee
a7e0c3994d
Finish Docker Desktop flow 2021-11-22 15:02:29 -08:00
Micah Lee
a54e19fe11
Get WaitingWidget to properly check for and install the image 2021-11-22 14:37:53 -08:00
Micah Lee
42ce884419
Work on changing the WaitingWidget to check for Docker 2021-11-22 14:06:31 -08:00
Micah Lee
d1c33bfcf5
Begin ripping out VM logic, go back to Docker Desktop for Mac 2021-11-22 13:36:21 -08:00
Micah Lee
b82ffa2cac
Make it so windows remember if waiting has finished 2021-08-06 13:10:56 -07:00
Micah Lee
ea47a2e92c
Fix error message user interface 2021-08-06 12:58:02 -07:00
Micah Lee
7c756c194e
Add progress bar 2021-08-05 15:36:09 -07:00
Micah Lee
2c9787ff99
Rename TasksWidget to ConvertWidget 2021-08-05 15:08:51 -07:00
Micah Lee
450320de6f
Make GUI use the new container too 2021-08-04 16:41:47 -07:00
Micah Lee
4a2c92e911
Move just the single task into its own ConvertThread object 2021-08-04 15:20:38 -07:00
Micah Lee
0b1a5b2c2a
Show waiting widget when installing the containre in Linux too 2021-08-04 15:13:48 -07:00
Micah Lee
588206a9e8
Start implementing built-in container in Linux, without a VM 2021-08-04 14:42:46 -07:00
Micah Lee
5cf97b9c73
Properly close window 2021-07-27 11:23:03 -07:00
Micah Lee
acaa7a9cd1
Work with dark theme 2021-07-27 11:14:41 -07:00
Micah Lee
7fcd10e404
Move main window content into widget, and either show content or the waiting widget, but never both 2021-07-27 11:06:20 -07:00
Micah Lee
488dca4a71
Totally refactor how tasks work and how dangerzone-container works so that there is a single --convert task 2021-07-02 13:32:23 -07:00
Micah Lee
fe63689320
Remove restart from systray and replace it with new window 2021-07-02 10:17:46 -07:00
Micah Lee
2904d44aad
Start making it possible to execute podman inside the VM 2021-07-01 16:45:25 -07:00
Micah Lee
c7bd8a317a
Move the MainWindow widgets into the same file, and move the vm object into global_common 2021-07-01 16:06:36 -07:00
Micah Lee
e81e6ccc6c
Remove everything related to updating the container image 2021-07-01 15:56:12 -07:00
Micah Lee
1f1bb2b353
Successfully wait for VM to start, and then move on in the UI 2021-07-01 15:52:19 -07:00
Micah Lee
d9d352a680
Fix removing PDF viewer search in Mac, and make the waiting widget look better 2021-06-30 12:31:33 -07:00
Micah Lee
6ff68f88ea
Refactor dangerzone to move GUI code into its own module 2021-06-09 15:24:03 -07:00
Renamed from dangerzone/main_window.py (Browse further)