diff --git a/Makefile b/Makefile index 8938244..f62880b 100644 --- a/Makefile +++ b/Makefile @@ -16,15 +16,11 @@ help: @echo "KDE Plasma 6 Widget Developer Tools" @echo "" @echo "Usage:" - @echo " make test Run widget in plasmoidviewer (default)" - @echo " make test-local Run widget directly from local package path" - @echo " make test-panel Run in horizontal panel mode" - @echo " make test-desktop Run as a floating desktop widget" - @echo " make test-hidpi Run with 2x DPI scaling" + @echo " make dev Run widget in plasmoidviewer from local package (MODE=panel|desktop|hidpi)" @echo " make watch Start Development Mode with Hot Reload" @echo " make cpp-build Build the C++ QML bridge module" @echo " make cpp-clean Remove C++ bridge build artifacts" - @echo " make install Install/upgrade widget (converts dev symlink)" + @echo " make install Install/upgrade widget in local Plasma package store" @echo " make uninstall Remove widget from local system" @echo " make package Build .plasmoid file for distribution" @echo " make clean Remove build artifacts" @@ -57,30 +53,24 @@ cpp-clean: rm -rf $(CPP_BUILD_DIR) $(CPP_MODULE_DIR) # Testing Targets -# Run plasmoidviewer using the installed widget ID from metadata. -.PHONY: test -test: cpp-build - plasmoidviewer -a $(WIDGET_ID) - -# Run plasmoidviewer directly from the local package directory. -.PHONY: test-local -test-local: cpp-build - plasmoidviewer -a $(PACKAGE_DIR) - -# Run widget in panel simulation (top edge, horizontal form factor). -.PHONY: test-panel -test-panel: cpp-build - plasmoidviewer -a $(WIDGET_ID) -l topedge -f horizontal - -# Run widget in desktop simulation (floating, planar form factor). -.PHONY: test-desktop -test-desktop: cpp-build - plasmoidviewer -a $(WIDGET_ID) -l floating -f planar - -# Run widget with HiDPI scaling enabled (2x scale factor). -.PHONY: test-hidpi -test-hidpi: cpp-build - QT_SCALE_FACTOR=2 plasmoidviewer -a $(WIDGET_ID) +# Run plasmoidviewer from the local package directory. +# Optional MODE values: panel, desktop, hidpi (omit MODE for default). +.PHONY: dev +dev: cpp-build + @mode="$(MODE)"; \ + case "$$mode" in \ + ""|default) \ + plasmoidviewer -a $(PACKAGE_DIR) ;; \ + panel) \ + plasmoidviewer -a $(PACKAGE_DIR) -l topedge -f horizontal ;; \ + desktop) \ + plasmoidviewer -a $(PACKAGE_DIR) -l floating -f planar ;; \ + hidpi) \ + QT_SCALE_FACTOR=2 plasmoidviewer -a $(PACKAGE_DIR) ;; \ + *) \ + echo "Invalid MODE='$$mode'. Allowed: panel, desktop, hidpi (or omit MODE)."; \ + exit 1 ;; \ + esac # Development Tools # Start file watcher for iterative development and reload workflow. @@ -154,15 +144,10 @@ lint-prettier: lint: lint-qml-format lint-qml lint-cpp lint-prettier # Installation -# Install/upgrade widget in local Plasma package store and replace any dev symlink. +# Install/upgrade widget in local Plasma package store. .PHONY: install install: cpp-build - @install_path="$(HOME)/.local/share/plasma/plasmoids/$(WIDGET_ID)"; \ - if [ -L "$$install_path" ]; then \ - echo "Replacing development symlink with installed package: $$install_path"; \ - rm -f "$$install_path"; \ - fi; \ - if kpackagetool6 --type Plasma/Applet --show $(WIDGET_ID) >/dev/null 2>&1; then \ + @if kpackagetool6 --type Plasma/Applet --show $(WIDGET_ID) >/dev/null 2>&1; then \ echo "Upgrading existing package: $(WIDGET_ID)"; \ kpackagetool6 --type Plasma/Applet --upgrade $(PACKAGE_DIR); \ else \ @@ -170,25 +155,20 @@ install: cpp-build kpackagetool6 --type Plasma/Applet --install $(PACKAGE_DIR); \ fi -# Symlink local package into Plasma directory for live development updates. -.PHONY: dev-install -dev-install: cpp-build - @echo "Creating symlink for development..." - mkdir -p $(HOME)/.local/share/plasma/plasmoids/ - ln -sfn $(abspath $(PACKAGE_DIR)) $(HOME)/.local/share/plasma/plasmoids/$(WIDGET_ID) - @echo "Linked $(WIDGET_ID) -> $(PACKAGE_DIR)" - @echo "You can now use 'make test' or the Reload button in plasmoidviewer!" - # Upgrade an already installed widget package with local changes. .PHONY: upgrade upgrade: cpp-build kpackagetool6 --type Plasma/Applet --upgrade $(PACKAGE_DIR) -# Remove both dev symlink and installed widget package from local system. +# Remove installed widget package from local system. .PHONY: uninstall uninstall: - rm -f $(HOME)/.local/share/plasma/plasmoids/$(WIDGET_ID) - kpackagetool6 --type Plasma/Applet --remove $(WIDGET_ID) + @if kpackagetool6 --type Plasma/Applet --show $(WIDGET_ID) >/dev/null 2>&1; then \ + echo "Removing package registration: $(WIDGET_ID)"; \ + kpackagetool6 --type Plasma/Applet --remove $(WIDGET_ID); \ + else \ + echo "Package not registered: $(WIDGET_ID)"; \ + fi # Packaging # Create distributable .plasmoid archive from current package contents. diff --git a/README.md b/README.md index 067fc5e..cc625f1 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,16 @@ sudo pacman -S plasma-sdk inotify-tools kirigami2 qt6-base qt6-declarative 2. Run `make hooks-install` once to enable Git hooks from `.githooks/`. 3. If you use VS Code, run `make cpp-build` once to build the C++ bridge and generate IDE metadata for autocomplete. Then install the official QML extension and reload the VS Code window. 4. Start hot reload while editing with `make watch`. -5. Install a symlinked development version with `make dev-install`. -6. For a normal local install (non-symlinked), use `make install`. -7. Check style/lint status with `make lint`. -8. Format everything with `make format`. -9. Test in different modes with `make test`, `make test-panel`, `make test-desktop`, or `make test-hidpi`. -10. Package for distribution with `make package` (creates `build/.plasmoid`, default: `build/org.kde.plasma.starter.plasmoid`). This is just a zip file with a different extension, so you can inspect it with any archive manager. +5. For a local install into Plasma's package store, use `make install`. +6. Check style/lint status with `make lint`. +7. Format everything with `make format`. +8. Test with `make dev` (default mode) or `make dev MODE=panel|desktop|hidpi`. +9. Package for distribution with `make package` (creates `build/.plasmoid`, default: `build/org.kde.plasma.starter.plasmoid`). This is just a zip file with a different extension, so you can inspect it with any archive manager. ## Editor Setup Notes - **QML IntelliSense (VS Code):** Workspace settings pin `qmlls` to `/usr/lib/qt6/bin/qmlls` and pass `-I/usr/lib/qt6/qml`, `-b${workspaceFolder}/build/cpp`, and `-d/usr/share/doc/qt6`. - **Important:** Run `make cpp-build` at least once so the `build/cpp` metadata used by `qmlls` exists. -- **Install modes:** `make dev-install` creates a symlink for development, while `make install` converts that symlink into a normal installed package. - **Generated C++ QML module:** `package/contents/ui/cppbridge/` is created by the C++ build, so editors may warn about `import "cppbridge"` before first build. - **Known qmllint false-positive:** `plasmoid.configuration.*` is runtime-injected by Plasma; `main.qml` has a targeted `qmllint` suppression for that property lookup. - **C++ editor config:** `clangd` uses `build/cpp/compile_commands.json` (set in `.vscode/settings.json`), with project defaults in `.clangd` and `.clang-format`.