diff --git a/build.zig b/build.zig index 2e52a70..c79abae 100644 --- a/build.zig +++ b/build.zig @@ -1,57 +1,102 @@ const std = @import("std"); pub fn build(b: *std.Build) void { - // const target = b.standardTargetOptions(.{}); - // const optimize = b.standardOptimizeOption(.{}); - - // Step 1: Generate Qt resources automatically - const rcc_cmd = b.addSystemCommand(&.{ "rcc", "ui/resources.qrc", "-o", "qrc_resources.cpp" }); + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); // Create the executable - const mod = b.createModule(.{ - .target = b.graph.host, + const exe = b.addExecutable(.{ + .name = "waycast", + .target = target, + .optimize = optimize, }); - mod.addCSourceFiles(.{ - .files = &.{ - "main.cpp", - "qrc_resources.cpp", - }, - .flags = &.{ + // Set C++20 standard + exe.linkLibCpp(); + + // Add include directories (equivalent to CMake include_directories) + exe.addIncludePath(b.path("lib")); + exe.addIncludePath(b.path("lib/ui")); + exe.addIncludePath(b.path("lib/plugins")); + exe.addIncludePath(b.path("src")); + + // Add source files (equivalent to CMake GLOB_RECURSE and target_sources) + const src_files = [_][]const u8{ + // Main source + "src/main.cpp", + + // Library UI files + "lib/ui/AppListModel.cpp", + "lib/ui/ListItem.cpp", + + // Plugin files + "src/plugins/DesktopAppPlugin/DesktopAppListItem.cpp", + }; + + exe.addCSourceFiles(.{ + .files = &src_files, + .flags = &[_][]const u8{ "-std=c++20", + "-fmodules-ts", + "-mavx2", "-Wall", "-Wextra", }, }); - const exe = b.addExecutable(.{ - .name = "waycast", - .root_module = mod, - }); - - exe.step.dependOn(&rcc_cmd.step); - - // Link C++ standard library - exe.linkLibCpp(); - // Link Qt6 + // System library dependencies (equivalent to find_package and target_link_libraries) + // Qt6 libraries exe.linkSystemLibrary("Qt6Core"); - exe.linkSystemLibrary("Qt6Quick"); exe.linkSystemLibrary("Qt6Gui"); exe.linkSystemLibrary("Qt6Qml"); + exe.linkSystemLibrary("Qt6Quick"); + exe.linkSystemLibrary("Qt6QuickControls2"); + exe.linkSystemLibrary("Qt6Widgets"); + + // LayerShellQt + exe.linkSystemLibrary("LayerShellQtInterface"); + + // GIO (GLib) - equivalent to pkg_check_modules(GIO REQUIRED gio-2.0) + exe.linkSystemLibrary("gio-2.0"); + exe.linkSystemLibrary("gobject-2.0"); + exe.linkSystemLibrary("glib-2.0"); + + // Add pkg-config paths for system libraries + exe.addLibraryPath(.{ .cwd_relative = "/usr/lib" }); + exe.addLibraryPath(.{ .cwd_relative = "/usr/local/lib" }); + + // QML resource compilation (equivalent to qt_add_qml_module) + // Note: This is simplified - full Qt QML module support would need more complex setup + _ = b.addSystemCommand(&.{ + "rcc", "-binary", "-o", "qml_resources.rcc", "ui/Main.qml" + }); + + // Set RPATH for runtime library discovery (equivalent to INSTALL_RPATH) + if (target.result.os.tag == .linux) { + exe.addRPath(.{ .cwd_relative = "$ORIGIN" }); + } // Install the executable b.installArtifact(exe); - // Create a run step + // Create run command const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); - // Allow passing arguments to the program + // Allow passing arguments if (b.args) |args| { run_cmd.addArgs(args); } - // Create the run step - const run_step = b.step("run", "Run the application"); + // Create run step + const run_step = b.step("run", "Run waycast"); run_step.dependOn(&run_cmd.step); -} + + // Create build step (equivalent to make bld) + const build_step = b.step("bld", "Build waycast"); + build_step.dependOn(&exe.step); + + // Combined build and run step (equivalent to make br) + const build_run_step = b.step("br", "Build and run waycast"); + build_run_step.dependOn(&run_cmd.step); +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 1dbed72..78b4537 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,11 @@ int main(int argc, char *argv[]) QWindow *window = qobject_cast(rootObjects.first()); if (window) { + // Enable transparency support + QSurfaceFormat format = window->format(); + format.setAlphaBufferSize(8); + window->setFormat(format); + LayerShellQt::Window *layerWindow = LayerShellQt::Window::get(window); if (layerWindow) { diff --git a/ui/Main.qml b/ui/Main.qml index 958dbf3..e13aa7c 100644 --- a/ui/Main.qml +++ b/ui/Main.qml @@ -14,6 +14,9 @@ ApplicationWindow { Material.theme: Material.Dark + // Set window opacity for semi-transparency + opacity: 0.95 + Shortcut { sequence: "Escape" onActivated: Qt.quit() @@ -75,7 +78,7 @@ ApplicationWindow { delegate: ItemDelegate { width: listView.width - height: 40 + height: 60 Rectangle { anchors.fill: parent @@ -110,11 +113,29 @@ ApplicationWindow { } } - Text { + Column { anchors.verticalCenter: parent.verticalCenter - text: model.name - color: Material.foreground - font.pixelSize: 14 + spacing: 2 + + Text { + text: model.name + color: Material.foreground + font.pixelSize: 14 + font.weight: Font.Medium + } + + Text { + text: model.description || "" + color: Material.color(Material.Grey, Material.Shade400) + font.pixelSize: 11 + visible: text.length > 0 + opacity: 0.8 + + // Truncate long descriptions + elide: Text.ElideRight + maximumLineCount: 1 + width: Math.min(implicitWidth, listView.width - 60) // Leave space for icon and margins + } } }