diff --git a/CMakeLists.txt b/CMakeLists.txt index a732bd0..3bc7baa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,15 @@ project(gitmoji VERSION 1.0.0) find_package(Albert REQUIRED) albert_plugin( + INCLUDE + INTERFACE include + PRIVATE include/albert/plugin QT Concurrent Widgets ) + +# Add the resource file manually +qt6_add_resources(RESOURCES src/gitmojis.qrc) + +# Add resources to the target +target_sources(gitmoji PRIVATE ${RESOURCES}) diff --git a/README.md b/README.md index 6a01ab1..b535c3c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ A fast and efficient C++ implementation of the Gitmoji picker for Albert launche - Configurable copy format via settings - Fast indexing and fuzzy search - Native Albert C++ plugin +- Gitmoji data embedded as Qt resource (no external files needed) ## Installation @@ -26,12 +27,14 @@ Copy the built library to your Albert plugins directory: ```bash # Local installation -cp build/libgitmoji.so ~/.local/lib/albert/ +cp build/gitmoji.so ~/.local/lib/albert/ # Or system-wide -sudo cp build/libgitmoji.so /usr/lib/albert/ +sudo cp build/gitmoji.so /usr/lib/albert/ ``` +Restart Albert to load the plugin. + ## Usage Trigger the plugin with `gm ` followed by your search query. @@ -43,17 +46,20 @@ Examples: ## Configuration -Access the plugin settings in Albert to choose what to copy: -- **Emoji**: Copy the emoji character (e.g., 🎨) -- **Gitmoji code**: Copy the code (e.g., :art:) +Access plugin settings in Albert to choose what to copy: +- **Emoji**: Copy emoji character (e.g., 🎨) +- **Gitmoji code**: Copy code (e.g., :art:) + +Settings are persisted using QSettings. ## Development This plugin uses: - Albert C++ API -- Qt6 framework +- Qt6 framework with embedded resources - CMake build system - IndexQueryHandler for efficient search +- BackgroundExecutor for async indexing ## License diff --git a/src/plugin.cpp b/src/plugin.cpp index ed5ef63..40c8abd 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -15,6 +15,8 @@ using namespace Qt::StringLiterals; using namespace albert; using namespace std; +static bool resourcesInitialized = false; + static const QString CONFIG_KEY = u"copy_format"_s; static const QString VALUE_EMOJI = u"emoji"_s; static const QString VALUE_CODE = u"code"_s; @@ -73,6 +75,12 @@ struct GitmojiItem : Item Plugin::Plugin() { + if (!resourcesInitialized) + { + Q_INIT_RESOURCE(gitmojis); + resourcesInitialized = true; + } + indexer.parallel = [this](const bool &abort) { vector r;