Complete pass over both toolbars (review items g–k), closing the toolbar topic. New ToolbarIcons: crisp QPainter vector glyphs (Qt SVG is not a build dep), with white "on" variants for toggles and a shared flat button style (coral hover, navy checked). Navigation toolbar, laid out source-first: - Open (3.5" diskette) · HTTP sync · Movie (reel-on-top camera, distinct from the next/play triangle) ║ the scrub slider, which expands to fill the bar (coral track, navy handle) so it is the obvious way to move across the data ║ precise navigation: first/prev/[number]/next/last, Jump, Sum. - Open and HTTP-sync reach the file / connect dialogs (JFJochViewerMenu openSelected and openHttpSelected, now public). - HTTP-sync has three states via a status dot (grey disconnected / green live / amber frozen); clicking with no live source attached opens the connect dialog. Removed the separate "Reanalyze" toggle. Display toolbar: - Styled foreground slider (matching), Auto/HDR as styled text toggles. Hero buttons: - "Reanalyze image" is now a toggle (worker ReanalyzeImages: run now + keep re-analysing on image/settings/processing changes; coral = active). Processing dock: - Drop the "New job…" toolbar action (the hero button drives it) and parent the job dialog to the main window instead of the dock. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
174 lines
5.6 KiB
C++
174 lines
5.6 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "ToolbarIcons.h"
|
|
|
|
#include <QPainter>
|
|
#include <QPainterPath>
|
|
#include <QPolygonF>
|
|
#include <functional>
|
|
|
|
namespace {
|
|
constexpr int S = 32;
|
|
const QColor INK("#2B2B2B");
|
|
const QColor DISABLED("#9AA6B3");
|
|
|
|
using DrawFn = std::function<void(QPainter &, const QColor &)>;
|
|
|
|
QPixmap render(const DrawFn &fn, const QColor &color) {
|
|
QPixmap pm(S, S);
|
|
pm.fill(Qt::transparent);
|
|
QPainter p(&pm);
|
|
p.setRenderHint(QPainter::Antialiasing);
|
|
fn(p, color);
|
|
return pm;
|
|
}
|
|
|
|
// Toggle-capable icon: ink when off, white when on (checked, navy background), grey when disabled.
|
|
QIcon toggleIcon(const DrawFn &fn) {
|
|
QIcon ic;
|
|
ic.addPixmap(render(fn, INK), QIcon::Normal, QIcon::Off);
|
|
ic.addPixmap(render(fn, Qt::white), QIcon::Normal, QIcon::On);
|
|
ic.addPixmap(render(fn, Qt::white), QIcon::Active, QIcon::On);
|
|
ic.addPixmap(render(fn, DISABLED), QIcon::Disabled, QIcon::Off);
|
|
return ic;
|
|
}
|
|
|
|
void fillTriangle(QPainter &p, const QColor &c, QPointF a, QPointF b, QPointF tip) {
|
|
p.setPen(Qt::NoPen);
|
|
p.setBrush(c);
|
|
p.drawPolygon(QPolygonF({a, b, tip}));
|
|
}
|
|
|
|
void bar(QPainter &p, const QColor &c, double x) {
|
|
p.setPen(Qt::NoPen);
|
|
p.setBrush(c);
|
|
p.drawRoundedRect(QRectF(x, 9, 3.2, 14), 1.2, 1.2);
|
|
}
|
|
|
|
// A pair of curved arrows forming a refresh/sync ring.
|
|
void syncArrows(QPainter &p, const QColor &c) {
|
|
QPen pen(c, 2.4, Qt::SolidLine, Qt::RoundCap);
|
|
p.setPen(pen);
|
|
p.setBrush(Qt::NoBrush);
|
|
const QRectF r(9, 9, 14, 14);
|
|
p.drawArc(r, 40 * 16, 230 * 16);
|
|
p.drawArc(r, (40 + 180) * 16, 230 * 16);
|
|
// arrowheads at the two open ends
|
|
p.setPen(Qt::NoPen);
|
|
p.setBrush(c);
|
|
p.drawPolygon(QPolygonF({QPointF(22, 7.5), QPointF(22, 13.5), QPointF(17.5, 11)}));
|
|
p.drawPolygon(QPolygonF({QPointF(10, 24.5), QPointF(10, 18.5), QPointF(14.5, 21)}));
|
|
}
|
|
}
|
|
|
|
namespace ToolbarIcons {
|
|
|
|
QIcon first() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
bar(p, c, 9);
|
|
fillTriangle(p, c, {24, 9}, {24, 23}, {14, 16});
|
|
});
|
|
}
|
|
|
|
QIcon prev() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
fillTriangle(p, c, {22, 8}, {22, 24}, {11, 16});
|
|
});
|
|
}
|
|
|
|
QIcon next() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
fillTriangle(p, c, {10, 8}, {10, 24}, {21, 16});
|
|
});
|
|
}
|
|
|
|
QIcon last() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
fillTriangle(p, c, {8, 9}, {8, 23}, {18, 16});
|
|
bar(p, c, 19.8);
|
|
});
|
|
}
|
|
|
|
QIcon movie() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
// Two reels on top of a camera body with a lens barrel — an old-fashioned movie camera.
|
|
p.setBrush(Qt::NoBrush);
|
|
p.setPen(QPen(c, 1.8));
|
|
p.drawEllipse(QPointF(10, 11.5), 3.0, 3.0);
|
|
p.drawEllipse(QPointF(16.5, 11.5), 3.0, 3.0);
|
|
p.setPen(Qt::NoPen);
|
|
p.setBrush(c);
|
|
p.drawRoundedRect(QRectF(5, 15, 16, 10), 2, 2);
|
|
p.drawRoundedRect(QRectF(21, 17, 5, 6), 1, 1); // lens barrel
|
|
});
|
|
}
|
|
|
|
QIcon openFile() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
// 3.5" diskette ("save" floppy): square jacket with a cut top-right corner, the metal
|
|
// shutter across the top, and a label panel below.
|
|
p.setPen(QPen(c, 1.8));
|
|
p.setBrush(Qt::NoBrush);
|
|
QPolygonF body({{6, 6}, {20, 6}, {26, 12}, {26, 26}, {6, 26}});
|
|
p.drawPolygon(body); // jacket
|
|
p.setPen(Qt::NoPen);
|
|
p.setBrush(c);
|
|
p.drawRect(QRectF(10, 6, 8, 5.5)); // metal shutter (top)
|
|
p.setBrush(Qt::NoBrush);
|
|
p.setPen(QPen(c, 1.6));
|
|
p.drawRect(QRectF(9.5, 15.5, 13, 8.5)); // label panel
|
|
});
|
|
}
|
|
|
|
QIcon reanalyzeImage() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
p.setPen(QPen(c, 2.0));
|
|
p.setBrush(Qt::NoBrush);
|
|
p.drawRoundedRect(QRectF(8, 8, 16, 16), 2.5, 2.5);
|
|
p.setBrush(c);
|
|
p.drawEllipse(QPointF(16, 16), 2.2, 2.2);
|
|
});
|
|
}
|
|
|
|
QIcon reanalyzeDataset() {
|
|
return toggleIcon([](QPainter &p, const QColor &c) {
|
|
p.setPen(QPen(c, 2.0));
|
|
p.setBrush(Qt::NoBrush);
|
|
for (int i = 2; i >= 0; --i)
|
|
p.drawRoundedRect(QRectF(5 + i * 4.0, 5 + i * 4.0, 14, 14), 2.0, 2.0);
|
|
p.setBrush(c);
|
|
p.drawEllipse(QPointF(12, 12), 2.0, 2.0);
|
|
});
|
|
}
|
|
|
|
QIcon httpSync(HttpState state) {
|
|
QColor dot;
|
|
switch (state) {
|
|
case HttpState::Disconnected: dot = QColor("#9AA6B3"); break; // grey
|
|
case HttpState::Live: dot = QColor("#5CB85C"); break; // green
|
|
case HttpState::Frozen: dot = QColor("#E9A23B"); break; // amber
|
|
}
|
|
auto draw = [dot](QPainter &p, const QColor &c) {
|
|
syncArrows(p, c);
|
|
p.setPen(QPen(Qt::white, 1.2));
|
|
p.setBrush(dot);
|
|
p.drawEllipse(QPointF(24, 24), 4.2, 4.2); // status dot
|
|
};
|
|
QIcon ic;
|
|
ic.addPixmap(render(draw, INK), QIcon::Normal, QIcon::Off);
|
|
ic.addPixmap(render(draw, DISABLED), QIcon::Disabled, QIcon::Off);
|
|
return ic;
|
|
}
|
|
|
|
QString buttonStyle() {
|
|
return QStringLiteral(
|
|
"QToolButton { border:none; border-radius:4px; padding:4px 6px; color:#2B2B2B;"
|
|
" background:transparent; }"
|
|
" QToolButton:hover { background:rgba(250,114,104,0.20); }"
|
|
" QToolButton:checked { background:#1F3A5F; color:white; }"
|
|
" QToolButton:disabled { color:#9AA6B3; }");
|
|
}
|
|
|
|
} // namespace ToolbarIcons
|