mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
PDFViewer: Use ArgsParser
This commit is contained in:
parent
468ceb1b48
commit
6bed20f456
1 changed files with 9 additions and 4 deletions
|
@ -6,18 +6,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PDFViewerWidget.h"
|
#include "PDFViewerWidget.h"
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/System.h>
|
#include <LibCore/System.h>
|
||||||
#include <LibFileSystemAccessClient/Client.h>
|
#include <LibFileSystemAccessClient/Client.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/Icon.h>
|
#include <LibGUI/Icon.h>
|
||||||
#include <LibGUI/Menubar.h>
|
#include <LibGUI/Menubar.h>
|
||||||
#include <LibGUI/MessageBox.h>
|
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
#include <LibMain/Main.h>
|
#include <LibMain/Main.h>
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
auto app = GUI::Application::construct(arguments);
|
const char* file_path = nullptr;
|
||||||
|
Core::ArgsParser args_parser;
|
||||||
|
args_parser.add_positional_argument(file_path, "PDF file to open", "path", Core::ArgsParser::Required::No);
|
||||||
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
auto app = TRY(GUI::Application::try_create(arguments));
|
||||||
auto app_icon = GUI::Icon::default_icon("app-pdf-viewer");
|
auto app_icon = GUI::Icon::default_icon("app-pdf-viewer");
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
|
@ -37,8 +42,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
window->show();
|
window->show();
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
||||||
if (arguments.argc >= 2) {
|
if (file_path) {
|
||||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, arguments.argv[1]);
|
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, file_path);
|
||||||
if (response.is_error())
|
if (response.is_error())
|
||||||
return 1;
|
return 1;
|
||||||
pdf_viewer_widget->open_file(*response.value());
|
pdf_viewer_widget->open_file(*response.value());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue