summaryrefslogtreecommitdiff
path: root/Userland/Applications/PDFViewer
AgeCommit message (Collapse)Author
2023-05-15Userland: Port `Model::column_name()` to StringKarol Kosek
2023-05-05LibGUI: Make `Application`'s construction fallibleLucas CHOLLET
The pattern to construct `Application` was to use the `try_create` method from the `C_OBJECT` macro. While being safe from an OOM perspective, this method doesn't propagate errors from the constructor. This patch make `Application` use the `C_OBJECT_ABSTRACT` and manually define a `create` method that can bubble up errors from the construction stage. This commit also removes the ability to use `argc` and `argv` to create an `Application`, only `Main`'s `Arguments` can be used. From a user point of view, the patch renames `try_create` => `create`, hence the huge number of modified files.
2023-04-30LibGUI+Userland: Port Labels to Stringthankyouverycool
2023-04-20PDFViewer: Propagate errors from `PDFViewerWidget::initialize_menubar()`Karol Kosek
2023-04-19LibGUI+Userland: Make Menu::*add_submmenu take name using new stringKarol Kosek
2023-04-19LibGUI+Userland: Make Window::*add_menu take name using new stringKarol Kosek
2023-04-18LibGUI+Userland: Improve error and font handling for InputBoxthankyouverycool
Adds fallible factories, ports DeprecatedString, and rebuilds the layout to accomodate system font changes.
2023-04-03PDFViewer: Add list of recently-opened filesSam Atkins
2023-03-22PDFViewer: Create OutlineModel items with the correct pointerJulian Offenhäuser
This fixes a bug where we would construct a ModelIndex with a pointer to NonnullRefPtr<OutlineItem>, instead of a pointer to the underlying OutlineItem, which caused a crash later on when we would try to dereference that pointer.
2023-03-16LibGUI+Userland: Make TabWidget::*add_tab() take title using new stringKarol Kosek
2023-03-06Everywhere: Remove NonnullRefPtr.h includesAndreas Kling
2023-03-06Everywhere: Stop using NonnullRefPtrVectorAndreas Kling
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
2023-03-01LibCore+Everywhere: Remove ArgsParser::add*(char const*&)Ali Mohammad Pur
This is not guaranteed to always work correctly as ArgsParser deals in StringViews and might have a non-properly-null-terminated string as a value. As a bonus, using StringView (and DeprecatedString where necessary) leads to nicer looking code too :^)
2023-02-25Everywhere: Use _{short_,}string to create Strings from literalsLinus Groh
2023-02-18Userland: Specify margins and spacing in the GUI::Layout constructorSam Atkins
2023-02-13LibCore: Move Stream-based file into the `Core` namespaceTim Schumacher
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-02-13Userland: Set Button text using the new String classKarol Kosek
2023-02-13LibGUI+Userland: Add `_deprecated` suffix to AbstractButton::{set_,}textKarol Kosek
2023-02-04LibGUI+Userland: Switch order of parameters for InputBox::showKarol Baraniecki
Because usage of the input_type parameter is now higher than of the placeholder parameter, this makes for a cleaner API.
2023-01-26LibGfx: Remove `try_` prefix from bitmap creation functionsTim Schumacher
Those don't have any non-try counterpart, so we might as well just omit it.
2023-01-13Userland: Remove a bunch of unveil calls on /sys/kernel/processesLiav A
These are not needed anymore since the introduction of the new get_root_session_id syscall.
2023-01-10PDFViewer: Port to Core::Stream::FileKarol Kosek
2023-01-07LibFileSystemAccessClient: Rename try_* functions to try_*_deprecatedKarol Kosek
These functions return the deprecated `Core::File` class, so let's mark it as such to avoid possible confusion between future non try_* functions which will use Core::Stream family classes and to possibly grab someone's attention. :^)
2023-01-06LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)Sam Atkins
Rip that bandaid off! This does the following, in one big, awkward jump: - Replace all uses of `set_main_widget<Foo>()` with the `try` version. - Remove `set_main_widget<Foo>()`. - Rename the `try` version to just be `set_main_widget` because it's now the only one. The majority of places that call `set_main_widget<Foo>()` are inside constructors, so this unfortunately gives us a big batch of new `release_value_but_fixme_should_propagate_errors()` calls.
2023-01-06PDFViewer: Inform users of underlying issue when loading documentRodrigo Tobar
While this is not super useful to end users, it's still better than the simpler, generic "failed to load" error message.
2023-01-02Everywhere: Fix badly-formatted includesBen Wiederhake
In 7c5e30daaa615ad3a2ef55222423a747ac0a1227, the focus was "only" on Userland/Libraries/, whereas this commit cleans up the remaining headers in the repo, and any new badly-formatted include.
2022-12-20PDFViewer: Prompt password for encrypted documentsRodrigo Tobar
This tackles a FIXME, but also makes sense to implement only now that the SecurityHandler logic has been fixed. When a Document is created an automatic attempt is made to provide the empty string as the password; even if this attempt failed the SecurityHandler still reported it had a user password, hence we never arrived to the VERIFY_NOT_REQUIRED line this commit is changing.
2022-12-20PDFViewer: Fix indexing error in ErrorsViewRodrigo Tobar
I confused myself when implementing this, plus I tested using pages that had errors in pages 1 and 2, so the index and the number of the page (internally represented as 0-indexed) was always the same. When opening files with errors on higher pages it became evident that there was an issue with how I was reading the errors per page from the corresponding ModelIndex object.
2022-12-17PDFViewer: Move to page when outline item is selectedRodrigo Tobar
2022-12-17PDFViewer: Inform about selections on Outline viewRodrigo Tobar
Selecting an Outline Item from the Outline view informs via callback the corresponding Destination that has been selected. This will be used to move the application to the corresponding page/section/etc.
2022-12-17PDFViewer: Show page numbers in Outline TreeViewRodrigo Tobar
This is a nice addition to the outline view, which previously simply displayed the titles of each section. Pages are shown in the first column, but the tree is expanded via the second column, where the title is.
2022-12-17PDFViewer: Fix parent_index() implementation in OutlineModelRodrigo Tobar
The previous implementation had some repeated code, and wasn't really working (because the OutlineItem.parent member was never populated). In fact, when navigating with the up/down arrows in the associted TreeView one could experience some funky behavior. Now that we store OutlineItem's parents, we are fixing the implementation for parent_index(), which was comparing the parent siblings against the item's outline item instead of to its parent.
2022-12-17PDFViewer: Propagate errors from OutlineModel constructionRodrigo Tobar
This follows the same idea that Andreas was doing in this latest videos, where construction-time TRY()s were not present but should have been. Like Andreas did, moving the initialisation of such fields to the factory function, which then returns ErrorOr solves the issue.
2022-12-17PDFViewer: Perform standard error handling when opening filesRodrigo Tobar
The previous implementation of open_file had a lambda that was used to inspect the call of ErrorOr-returning calls. This was a non-standard way of doing this though, as the more usual and clearer way is to have an inner function that returns ErrorOr, then handle any incoming errors on the top level function. This commit adds a try_open_file function, where all the logic occurs, and all the failure-producing steps are simplied TRY'ed. The top level open_file function takes that result and does what the lambda previously did: showing a message box with the actual error.
2022-12-16PDFViewer: Avoid errors due to copying of ErrorOrRodrigo Tobar
The handle_error took PDFErrorOr<T> objects by value, meaning that their inner values (the error or value stored in the underlying Variant) were somehow copied over. In the first instance where this lambda is called with T = NonnullRefPtr, resulting in funky behavior (invalid NonnullRefPtr state with a VALIDATE fail): if there is no error then the PDFErrorOr<T> copy is destroyed, which might be causing the underlying NonnullRefPtr to be destroyed, but somehow the original in the caller context gets affected and fails verification. The solution seems simple anyway: just pass the value by reference (lvalue or rvalue) so the original object can be used directly, avoiding destruction.
2022-12-16PDFViewer: Remove unnecessary ternary operationRodrigo Tobar
2022-12-16PDFViewer: Add TreeView to communicate rendering errorsRodrigo Tobar
Now that the rendering process communicates all errors upstream, and PDFViewer has a way to tap into those errors as they occur, we can visualise them more neatly. This commit adds a TreeView that we populate with the errors stemming from the rendering process. The TreeView has two levels: at the top sit pages where errors can be found, and under each page we can see the errors that have been found on that page. The TreeView sits below the main PDF rendering.
2022-12-16LibPDF: Switch to best-effort PDF renderingRodrigo Tobar
The current rendering routine aborts as soon as an error is found during rendering, which potentially severely limits the contents we show on screen. Moreover, whenever an error happens the PDFViewer widget shows an error dialog, and doesn't display the bitmap that has been painted so far. This commit improves the situation in both fronts, implementing rendering now with a best-effort approach. Firstly, execution of operations isn't halted after an operand results in an error, but instead execution of all operations is always attempted, and all collected errors are returned in bulk. Secondly, PDFViewer now always displays the resulting bitmap, regardless of error being produced or not. To communicate errors, an on_render_errors callback has been added so clients can subscribe to these events and handle them as appropriate.
2022-12-10PDFViewer: Let users change image renderingRodrigo Tobar
A new checkbox in the toolbar now allows users toggle image rendering. A corresponding Config option makes this setting non-volatile. To void clashing with the previous "show_clipping_paths" option when caching a Page, we now use the RenderingPreferences.hash() and the pair_int_hash funcitons to compute a unique key into the page cache map for a given RenderingPreferences and zoom level.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-25PDFViewer: Show single/multi page actions on toolbarRodrigo Tobar
These actions were being constructed, and they work, but were not shown in the toolbar. Adding them will allow users to actually use them, as well as pick up any bugs they might have.
2022-11-25PDFViewer: Toggle prev/next page actions when page changesRodrigo Tobar
These actions were not updated accordingly when one scrolled through the document, and thus one could accidentally, for example, move to the next page when standing on the last, which caused a crash. This commit fixes that behavior, toggling the actions' enabled status depending on the new page being displayed.
2022-11-25PDFViewer: Prevent infinity recursionRodrigo Tobar
When removing all contents from the NumericInput box in PDFViewer the callback set the (empty) text again back in the box, triggering another callback in a recursive, non-stopping fashion. Not setting the text back in the box avoids the problem.
2022-11-25PDFViewer: Let users change clipping paths visibilityRodrigo Tobar
Now that the Renderer accepts preferences, PDFViewer can offer ways for changing these preferences. The first step in this direction is to add a checkbox that allows toggling whether clipping paths are visible or not. A Config item has also been added to remember this setting.
2022-11-19PDFViewer: Take the mousewheel delta into account for scrollingJulian Offenhäuser
We now respect the system-wide setting for scroll speed, where we would previously use a fixed step.
2022-11-19PDFViewer: Simplify user-facing error messagesJulian Offenhäuser
We now show a simple, if less helpful, message to the user and print the verbose error message to serial instead.
2022-11-19PDFViewer: Invalidate document when a page fails to loadJulian Offenhäuser
This fixes an issue where we would show an error message on every subsequent paint event, making it impossible to close or use the application further. Some more architectural work is needed if we want to invalidate the sidebar entries as well.
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.