forked from skift-org/skift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (32 loc) · 1.16 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <libsettings/Settings.h>
#include <libsystem/process/Process.h>
#include <libwidget/Application.h>
#include <libwidget/Button.h>
#include <libwidget/Image.h>
#include <libwidget/Panel.h>
#include <libwidget/TitleBar.h>
int main(int argc, char **argv)
{
if (argc == 1)
return -1;
if (Application::initialize(argc, argv) != SUCCESS)
return -1;
Window *window = new Window(WINDOW_RESIZABLE);
window->icon(Icon::get("image"));
window->title("Image Viewer");
window->size(Vec2i(700, 500));
window->root()->layout(VFLOW(0));
new TitleBar(window->root());
auto toolbar = new Panel(window->root());
toolbar->layout(HFLOW(0));
toolbar->insets(4);
auto bitmap = Bitmap::load_from_or_placeholder(argv[1]);
auto set_has_wallaper = new Button(toolbar, Button::TEXT, Icon::get("wallpaper"), "Set As Wallpaper");
set_has_wallaper->on(Event::ACTION, [&](auto) {
settings::write(settings::Path::parse("appearance:wallpaper.image"), process_resolve(argv[1]));
});
auto image = new Image(window->root(), bitmap);
image->flags(Widget::FILL);
window->show();
return Application::run();
}