main.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2020, Idan Horowitz <idan.horowitz@gmail.com>
  3. * Copyright (c) 2021, the SerenityOS developers
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form must reproduce the above copyright notice,
  13. * this list of conditions and the following disclaimer in the documentation
  14. * and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  20. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include "MouseSettingsWindow.h"
  28. #include <LibGUI/Action.h>
  29. #include <LibGUI/Application.h>
  30. #include <LibGUI/Icon.h>
  31. #include <LibGUI/Menu.h>
  32. #include <LibGUI/Menubar.h>
  33. #include <unistd.h>
  34. int main(int argc, char** argv)
  35. {
  36. if (pledge("stdio cpath rpath recvfd sendfd unix fattr", nullptr) < 0) {
  37. perror("pledge");
  38. return 1;
  39. }
  40. auto app = GUI::Application::construct(argc, argv);
  41. if (pledge("stdio cpath rpath recvfd sendfd", nullptr) < 0) {
  42. perror("pledge");
  43. return 1;
  44. }
  45. auto app_icon = GUI::Icon::default_icon("app-mouse");
  46. auto window = MouseSettingsWindow::construct();
  47. window->set_title("Mouse Settings");
  48. window->resize(300, 220);
  49. window->set_resizable(false);
  50. window->set_minimizable(false);
  51. window->set_icon(app_icon.bitmap_for_size(16));
  52. auto menubar = GUI::Menubar::construct();
  53. auto& app_menu = menubar->add_menu("File");
  54. app_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
  55. app->quit();
  56. }));
  57. auto& help_menu = menubar->add_menu("Help");
  58. help_menu.add_action(GUI::CommonActions::make_about_action("Mouse Settings", app_icon, window));
  59. window->set_menubar(move(menubar));
  60. window->show();
  61. return app->exec();
  62. }