mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +00:00
QuickShow: Use Core::ArgsParser to handle parameters
This commit is contained in:
parent
e0bf57d81f
commit
f88ceb872a
1 changed files with 9 additions and 8 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "QSWidget.h"
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
#include <LibGUI/AboutDialog.h>
|
||||
#include <LibGUI/Action.h>
|
||||
|
@ -53,12 +54,10 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (argc != 2) {
|
||||
printf("usage: qs <image-file>\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
const char* path = nullptr;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "The image file to be displayed.", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_double_buffering_enabled(true);
|
||||
|
@ -66,8 +65,6 @@ int main(int argc, char** argv)
|
|||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-image.png"));
|
||||
|
||||
auto& widget = window->set_main_widget<QSWidget>();
|
||||
if (argc > 1)
|
||||
widget.load_from_file(argv[1]);
|
||||
|
||||
auto update_window_title = [&](int scale) {
|
||||
if (widget.bitmap())
|
||||
|
@ -203,6 +200,10 @@ int main(int argc, char** argv)
|
|||
|
||||
app.set_menubar(move(menubar));
|
||||
|
||||
if (path != nullptr) {
|
||||
widget.load_from_file(path);
|
||||
}
|
||||
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue