# bianbu-accounts

A minimal Qt6 plugin for bianbu-control-center plus a standalone app that reuses the same code for faster UI development.

## Project layout

```text
bianbu-accounts.pro           # top-level: builds both plugin and app (subdirs)
src/
  bianbu-accounts-app.pro     # standalone app (.exe)
  main.cpp                      # runs the same UI without bianbu-control-center
  plugin/
    bianbu-accounts-plugin.pro# plugin (.so)
    common.pri                  # shared config and sources used by both targets
    bianbu-accounts-plugin.h  # shared implementation (QObject + BBCCPluginInterface)
    bianbu-accounts-plugin.cpp
```

Both targets include `src/plugin/common.pri`, which centralizes common Qt modules, include paths, and the shared source files.

## Prerequisites

- Qt6 build tools: `qt6-base-dev` `qt6-tools-dev`
- Bianbu Control Center headers: `libbianbu-dev`

On Debian/Ubuntu:

```bash
sudo apt update
sudo apt install qt6-base-dev qt6-tools-dev libbianbu-dev
```

Note: The qmake projects will fail early with a clear error if control-center headers are missing (expected path: `/usr/include/bbcc/interface/interface.h`).

## Build everything (recommended)

```bash
qmake bianbu-accounts.pro
make -j"$(nproc)"
```

Optional install (installs both the plugin .so and the app binary):

```bash
sudo make install
```

## Build individually

Plugin (.so):

```bash
qmake src/plugin/bianbu-accounts-plugin.pro
make -j"$(nproc)"
sudo make install    # optional: installs to $[QT_INSTALL_LIBS]/bianbu-control-center by default
```

Standalone app:

```bash
qmake src/bianbu-accounts-app.pro
make -j"$(nproc)"
./bianbu-accounts   # TARGET name from the app .pro
```

## Use inside bianbu-control-center

Launch bianbu-control-center as usual; it will discover plugins from its default directory:

```bash
bianbu-control-center
```

The plugin should appear under the relevant category (changeable in code).

## Customize

- Category: change `pluginTypes()` to one of the `FunType` values in `<control-center/interface/interface.h>` (adjust include path when header migration is complete)
- Display name: change `pluginI18nName()`
- Stable id: change `name()` (ASCII)
- Homepage visibility: adjust `isShowOnHomePage()`
- Icon: return a different themed icon in `icon()`
- Search integration (optional): override `translator()` to provide custom translator

## Notes

- The plugin target defines `BBCC_ACCOUNTS_BUILD_PLUGIN`, enabling `Q_PLUGIN_METADATA` only for the .so build.
- The plugin installs to `$[QT_INSTALL_LIBS]/bianbu-control-center` (qmake INSTALLS). You can override the install directory with `BCC_PLUGIN_DIR`, e.g.:

  ```bash
  cd build/src/plugin
  sudo make install BCC_PLUGIN_DIR=/custom/path/bianbu-control-center
  ```
- The app can optionally install to `/usr/bin`.
- To remove the plugin, delete the installed `.so` from bianbu-control-center's plugin directory and restart bianbu-control-center.

## Open-source friendly build rules

- Out-of-source builds supported (recommended): all artifacts land under `build/` via qmake's OUT_PWD routing (`.obj`, `.moc`, `.ui`, `.rcc`, `DESTDIR`).
- Dependency detection prefers `pkg-config` when available.
- Install paths are configurable:
  - `BCC_PLUGIN_DIR` overrides the plugin destination (default: `$[QT_INSTALL_LIBS]/bianbu-control-center`).
  - `INSTALL_ROOT` is honored by qmake for staged installs, e.g. `sudo make install INSTALL_ROOT=/tmp/pkgroot`.
