Viewer: PSI logo links to psi.ch, inverted in dark theme, sized to the menu bar
Build Packages / Create release (push) Successful in 16s
Build Packages / build:viewer:macos-arm64:nocuda (push) Successful in 3m26s
Build Packages / build:rugnux:macos-arm64:nocuda (push) Successful in 2m43s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 9m0s
Build Packages / build:rugnux:linux-x86_64:cuda (push) Successful in 9m47s
Build Packages / build:viewer:linux-x86_64:nocuda (push) Successful in 11m0s
Build Packages / build:viewer:linux-x86_64:cuda (push) Successful in 13m6s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 15m53s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 16m29s
Build Packages / build:viewer:windows-x86_64:nocuda (push) Successful in 18m39s
Build Packages / build:viewer:windows-x86_64:cuda (push) Successful in 24m19s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m26s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 19m44s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 20m39s
Build Packages / Generate python client (push) Successful in 44s
Build Packages / Build documentation (push) Successful in 1m21s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 21m12s
Build Packages / build:rugnux:windows-x86_64:cuda (push) Successful in 14m6s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 18m54s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 21m53s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 19m34s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m26s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 18m53s
Build Packages / Unit tests (push) Successful in 1h46m13s

The logo is black only, so the dark-theme negative is the same image with
its colours inverted, redrawn on every theme change. It is now a flat tool
button opening https://www.psi.ch. Button padding is removed and the logo
is scaled to the menu bar's natural height, so it no longer makes the bar
taller than its entries.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-09-29 14:09:04 +02:00
1 parent 4e1d44bca9
commit dd596ce281
1 file changed
+27 -6
+27 -6
View File
@@ -26,6 +26,9 @@
#include <QLabel>
#include <QPainter>
#include <QPushButton>
#include <QToolButton>
#include <QDesktopServices>
#include <QUrl>
#include <utility>
@@ -37,6 +40,7 @@
#include "widgets/JFJochViewerSettingsDock.h"
#include "widgets/JFJochViewerFileBrowser.h"
#include "JFJochViewerStatusBar.h"
#include "ViewerTheme.h"
#include "../common/CUDAWrapper.h"
#include "../rugnux/RugnuxDefaults.h"
#include "windows/JFJochViewerImageListWindow.h"
@@ -71,14 +75,31 @@ JFJochViewerWindow::JFJochViewerWindow(QWidget *parent, bool dbus, const QString
menuBar = new JFJochViewerMenu(this);
setMenuBar(menuBar);
// PSI logo in the menu-bar corner. There are four interchangeable dot designs; pick one at
// random each launch, for fun.
// PSI logo in the menu-bar corner, linking to the PSI website. There are four interchangeable dot
// designs; pick one at random each launch, for fun. The logo is black only, so the negative for the
// dark theme is the same image with its colours inverted.
{
const int n = QRandomGenerator::global()->bounded(1, 5); // 1..4
QPixmap logoPixmap(QStringLiteral(":/psi_%1.png").arg(n, 2, 10, QLatin1Char('0')));
auto *logo = new QLabel(this);
logo->setPixmap(logoPixmap.scaledToHeight(22, Qt::SmoothTransformation));
logo->setContentsMargins(6, 0, 8, 0);
// As tall as the menu entries make the bar, so the logo does not stretch it.
const QImage logoImage = QImage(QStringLiteral(":/psi_%1.png").arg(n, 2, 10, QLatin1Char('0')))
.convertToFormat(QImage::Format_ARGB32)
.scaledToHeight(menuBar->sizeHint().height(), Qt::SmoothTransformation);
auto *logo = new QToolButton(this);
logo->setAutoRaise(true);
// No button padding or frame, which would make the bar taller all the same.
logo->setStyleSheet("QToolButton { padding: 0px 8px 0px 6px; border: none; }");
logo->setCursor(Qt::PointingHandCursor);
logo->setToolTip("Paul Scherrer Institute - www.psi.ch");
logo->setIconSize(logoImage.size());
auto setLogoIcon = [logo, logoImage] {
QImage image = logoImage;
if (DarkTheme())
image.invertPixels(QImage::InvertRgb);
logo->setIcon(QPixmap::fromImage(image));
};
setLogoIcon();
connect(ThemeNotifier::Instance(), &ThemeNotifier::changed, logo, setLogoIcon);
connect(logo, &QToolButton::clicked, [] { QDesktopServices::openUrl(QUrl("https://www.psi.ch")); });
menuBar->setCornerWidget(logo, Qt::TopRightCorner);
}