ClickableLabel

ClickableLabel is a QLabel subclass whose rendered text acts as a link to a folder. When it carries a non-empty folder path, hovering the text shows a hand cursor and underlines it, and a left click opens that folder in the system file manager (via QDesktopServices::openUrl). It backs the data-path label in the main window status bar, the matching data-path label in the standalone viewer, and the experiment-number labels in the FTMW and LIF view widgets, which link to the experiment’s storage directory.

The hit and hover target is only the bounding rectangle of the rendered text — computed from the non-underlined font and honoring the label’s alignment — not the full widget width. A centered label stretched across a tab therefore does not swallow clicks aimed elsewhere. An empty path makes the widget an ordinary, non-interactive label, so a single label can be switched between the active and inert states at runtime (for example a numbered experiment versus a Peak-Up acquisition that has no stored data).

API Reference

class ClickableLabel : public QLabel

A QLabel that acts as a link to a folder.

With a non-empty folder path the rendered text behaves as a link: the pointer becomes a hand and the text underlines on hover, and a left click on the text opens the folder in the system file manager. The interactive region is only the rendered text (honoring the label’s alignment), not the full widget width, so a stretched centered label does not swallow unrelated clicks. An empty path makes it an ordinary, non-interactive label, so one label can be switched between the two states at runtime.

Public Functions

explicit ClickableLabel(QWidget *parent = nullptr)
void setFolderPath(const QString &path)

Set the folder opened on click.

An empty path disables interactivity and clears the tooltip.

Protected Functions

void enterEvent(QEnterEvent *e) override
void leaveEvent(QEvent *e) override
void mouseMoveEvent(QMouseEvent *e) override
void mouseReleaseEvent(QMouseEvent *e) override

Private Functions

QRect textRect() const

Bounding rect of the rendered text within the widget, honoring the label’s alignment. The hit/hover target, computed from a non-underlined font so it does not shift on hover.

void updateHover(const QPoint &pos)
void setUnderline(bool on)

Private Members

QString d_folderPath
bool d_hot = {false}