mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +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 "QSWidget.h"
|
||||||
#include <AK/URL.h>
|
#include <AK/URL.h>
|
||||||
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/MimeData.h>
|
#include <LibCore/MimeData.h>
|
||||||
#include <LibGUI/AboutDialog.h>
|
#include <LibGUI/AboutDialog.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
|
@ -53,12 +54,10 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
const char* path = nullptr;
|
||||||
if (argc != 2) {
|
Core::ArgsParser args_parser;
|
||||||
printf("usage: qs <image-file>\n");
|
args_parser.add_positional_argument(path, "The image file to be displayed.", "file", Core::ArgsParser::Required::No);
|
||||||
return 0;
|
args_parser.parse(argc, argv);
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto window = GUI::Window::construct();
|
auto window = GUI::Window::construct();
|
||||||
window->set_double_buffering_enabled(true);
|
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"));
|
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-image.png"));
|
||||||
|
|
||||||
auto& widget = window->set_main_widget<QSWidget>();
|
auto& widget = window->set_main_widget<QSWidget>();
|
||||||
if (argc > 1)
|
|
||||||
widget.load_from_file(argv[1]);
|
|
||||||
|
|
||||||
auto update_window_title = [&](int scale) {
|
auto update_window_title = [&](int scale) {
|
||||||
if (widget.bitmap())
|
if (widget.bitmap())
|
||||||
|
@ -203,6 +200,10 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
app.set_menubar(move(menubar));
|
app.set_menubar(move(menubar));
|
||||||
|
|
||||||
|
if (path != nullptr) {
|
||||||
|
widget.load_from_file(path);
|
||||||
|
}
|
||||||
|
|
||||||
window->show();
|
window->show();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue