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 <riitta-leena.miettinen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Eike Ziller
2022-10-18 11:54:39 +02:00
parent 1478a36530
commit 101ef19d1e

View File

@@ -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(
"<p>"
+ Tr::tr("Use the current settings for background, outline, and fitting "
"to screen as the default for new image viewers. Current default:")
+ "</p><p><ul><li>" + Tr::tr("Background: %1").arg(settings.showBackground ? on : off)
+ "</li><li>" + Tr::tr("Outline: %1").arg(settings.showOutline ? on : off) + "</li><li>"
+ Tr::tr("Fit to Screen: %1").arg(settings.fitToScreen ? on : off) + "</li></ul>");
};
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();
});
}