Selaa lähdekoodia

FontEditor: Add help documentation

Brendan Coles 4 vuotta sitten
vanhempi
commit
35fe1b39a2

+ 1 - 1
Applications/FontEditor/CMakeLists.txt

@@ -8,4 +8,4 @@ set(SOURCES
 )
 
 serenity_app(FontEditor ICON app-font-editor)
-target_link_libraries(FontEditor LibGUI LibGfx)
+target_link_libraries(FontEditor LibGUI LibDesktop LibGfx)

+ 19 - 1
Applications/FontEditor/main.cpp

@@ -25,7 +25,9 @@
  */
 
 #include "FontEditor.h"
+#include <AK/URL.h>
 #include <LibCore/ArgsParser.h>
+#include <LibDesktop/Launcher.h>
 #include <LibGUI/AboutDialog.h>
 #include <LibGUI/Action.h>
 #include <LibGUI/Application.h>
@@ -43,13 +45,26 @@
 
 int main(int argc, char** argv)
 {
-    if (pledge("stdio shared_buffer thread rpath accept unix cpath wpath fattr", nullptr) < 0) {
+    if (pledge("stdio shared_buffer thread rpath accept unix cpath wpath fattr unix", nullptr) < 0) {
         perror("pledge");
         return 1;
     }
 
     auto app = GUI::Application::construct(argc, argv);
 
+    if (pledge("stdio shared_buffer thread rpath accept cpath wpath unix", nullptr) < 0) {
+        perror("pledge");
+        return 1;
+    }
+
+    if (!Desktop::Launcher::add_allowed_handler_with_only_specific_urls(
+            "/bin/Help",
+            { URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md") })
+        || !Desktop::Launcher::seal_allowlist()) {
+        warnln("Failed to set up allowed launch URLs");
+        return 1;
+    }
+
     if (pledge("stdio shared_buffer thread rpath accept cpath wpath", nullptr) < 0) {
         perror("pledge");
         return 1;
@@ -127,6 +142,9 @@ int main(int argc, char** argv)
     }));
 
     auto& help_menu = menubar->add_menu("Help");
+    help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) {
+        Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md"), "/bin/Help");
+    }));
     help_menu.add_action(GUI::Action::create("About", [&](const GUI::Action&) {
         GUI::AboutDialog::show("Font Editor", app_icon.bitmap_for_size(32), window);
     }));

+ 19 - 0
Base/usr/share/man/man1/FontEditor.md

@@ -0,0 +1,19 @@
+## Name
+
+FontEditor - Serenity font editor
+
+## Synopsis
+
+```**sh
+$ FontEditor [file]
+```
+
+## Description
+
+FontEditor is a font editing application for Serenity.
+
+## Examples
+
+```sh
+$ FontEditor /res/fonts/CsillaRegular10.font
+```