Colour Layer Panel Text by Source

Version 1.0.1 · QGIS 4.2+ only · offline reference guide

What it does

Colours the layer name text shown in the Layers panel according to each layer's data source. Layer names, symbology, data sources and project structure are never changed. Categorised legend entries beneath a layer are left in the normal QGIS text colour — only the layer row itself is coloured.

What it colours

SourceHow it's matched
PostgreSQL layersYour own rules (Configure dialog): database name or service= name, checked in order, first match wins.
GeoPackage layersOne fixed, editable colour.
Memory / temporary layersOne fixed, editable colour.
Everything elseNormal QGIS text colour (unchanged).

No database or service names ship built in — add your own via Plugins → Colour Layer Panel Text by Source → Configure source colours…

The toggle button

A compact, icon-only, checkable button lives on the Layers panel's own toolbar only — it is not duplicated in the Plugins menu, which holds just the Configure entry. Its icon changes between a muted grey bar stack (off) and a coloured bar stack (on), so the state is visible without a text label. Tooltip: "Toggle layer-name colours by data source".

Setting up rules

  1. Open Plugins → Colour Layer Panel Text by Source → Configure source colours…
  2. Click Add rule to insert a row.
  3. The Value column is a dropdown, pre-filled with database/service names found in currently loaded PostgreSQL layers for the selected Match on type — pick one, or type your own if it isn't loaded.
  4. Pick a colour for the row, and repeat for further rules.
  5. Set GeoPackage and Memory/temporary colours in the row below the table, if wanted.
If a PostgreSQL layer uses a stored connection or pg_service.conf entry (service=...) instead of an explicit dbname=..., its name only appears in the Value dropdown when Match on is set to "Service name" — switch the row to that match type to find it.

Recovering from a broken plugin state

If QGIS's Layers panel becomes unusable after installing a plugin update:

  1. Close QGIS.
  2. Delete the plugin folder from %APPDATA%\QGIS\QGIS4\profiles\default\python\plugins\colour_layer_panel_text_by_source.
  3. Restart QGIS.

Compatibility & testing

QGIS 4.2 – 4.99 Python 3.12 Qt 6 / PyQt6. QGIS 3 is not supported.

Live-tested in QGIS 4.2.0 (Windows) against PostgreSQL layers spanning two databases connected via authcfg. service= connections, GeoPackage/memory colouring, group nodes, and other platforms/QGIS versions have not yet been tested — please report issues at the issue tracker with the rule(s) you added and the layer's provider/URI (Properties → Source tab).

Author & licence

Ian Hay · github.com/ianhay/colour_layer_panel_text_by_source

Licensed under the GNU General Public License v3 or later (see LICENSE in the plugin's root folder).