From dd596ce28143960007240e276e73adf99bf3e28b Mon Sep 17 00:00:00 2001 From: leonarski_f Date: Tue, 29 Sep 2026 14:09:04 +0200 Subject: [PATCH] Viewer: PSI logo links to psi.ch, inverted in dark theme, sized to the menu bar 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) --- viewer/JFJochViewerWindow.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/viewer/JFJochViewerWindow.cpp b/viewer/JFJochViewerWindow.cpp index 7b2cc883a..b532e842d 100644 --- a/viewer/JFJochViewerWindow.cpp +++ b/viewer/JFJochViewerWindow.cpp @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include @@ -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); }