From 101ef19d1e9bec80e5475885bf74552e49eb6080 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 18 Oct 2022 11:54:39 +0200 Subject: [PATCH] ImageViewer: Show current default settings in tooltip List the current default settings in the tooltip for the "Set as Default" button. Fixes: QTCREATORBUG-28322 Change-Id: Ic3a21218a60821e328d6db2375a0e5a08616d686 Reviewed-by: Leena Miettinen Reviewed-by: Reviewed-by: Alessandro Portale --- src/plugins/imageviewer/imageviewer.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp index be6f620bf31..441d33dc6ba 100644 --- a/src/plugins/imageviewer/imageviewer.cpp +++ b/src/plugins/imageviewer/imageviewer.cpp @@ -158,8 +158,19 @@ void ImageViewer::ctor() updateIconByTheme(d->actionOutline, QLatin1String("emblem-photos")); auto setAsDefault = new QAction(Tr::tr("Set as Default"), d->toolbar); - setAsDefault->setToolTip(Tr::tr("Use the current settings for background, outline, and fitting " - "to screen as the default for new image viewers.")); + const auto updateSetAsDefaultToolTip = [this, setAsDefault] { + const ImageView::Settings settings = d->imageView->settings(); + const QString on = Tr::tr("on"); + const QString off = Tr::tr("off"); + setAsDefault->setToolTip( + "

" + + Tr::tr("Use the current settings for background, outline, and fitting " + "to screen as the default for new image viewers. Current default:") + + "

  • " + Tr::tr("Background: %1").arg(settings.showBackground ? on : off) + + "
  • " + Tr::tr("Outline: %1").arg(settings.showOutline ? on : off) + "
  • " + + Tr::tr("Fit to Screen: %1").arg(settings.fitToScreen ? on : off) + "
"); + }; + updateSetAsDefaultToolTip(); d->labelImageSize = new QLabel; d->labelInfo = new QLabel; @@ -226,8 +237,9 @@ void ImageViewer::ctor() this, &ImageViewer::updatePauseAction); connect(d->imageView, &ImageView::scaleFactorChanged, this, &ImageViewer::scaleFactorUpdate); - connect(setAsDefault, &QAction::triggered, d->imageView, [this] { + connect(setAsDefault, &QAction::triggered, d->imageView, [this, updateSetAsDefaultToolTip] { d->imageView->writeSettings(ICore::settings()); + updateSetAsDefaultToolTip(); }); }