forked from qt-creator/qt-creator
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:
@@ -158,8 +158,19 @@ void ImageViewer::ctor()
|
|||||||
updateIconByTheme(d->actionOutline, QLatin1String("emblem-photos"));
|
updateIconByTheme(d->actionOutline, QLatin1String("emblem-photos"));
|
||||||
|
|
||||||
auto setAsDefault = new QAction(Tr::tr("Set as Default"), d->toolbar);
|
auto setAsDefault = new QAction(Tr::tr("Set as Default"), d->toolbar);
|
||||||
setAsDefault->setToolTip(Tr::tr("Use the current settings for background, outline, and fitting "
|
const auto updateSetAsDefaultToolTip = [this, setAsDefault] {
|
||||||
"to screen as the default for new image viewers."));
|
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->labelImageSize = new QLabel;
|
||||||
d->labelInfo = new QLabel;
|
d->labelInfo = new QLabel;
|
||||||
@@ -226,8 +237,9 @@ void ImageViewer::ctor()
|
|||||||
this, &ImageViewer::updatePauseAction);
|
this, &ImageViewer::updatePauseAction);
|
||||||
connect(d->imageView, &ImageView::scaleFactorChanged,
|
connect(d->imageView, &ImageView::scaleFactorChanged,
|
||||||
this, &ImageViewer::scaleFactorUpdate);
|
this, &ImageViewer::scaleFactorUpdate);
|
||||||
connect(setAsDefault, &QAction::triggered, d->imageView, [this] {
|
connect(setAsDefault, &QAction::triggered, d->imageView, [this, updateSetAsDefaultToolTip] {
|
||||||
d->imageView->writeSettings(ICore::settings());
|
d->imageView->writeSettings(ICore::settings());
|
||||||
|
updateSetAsDefaultToolTip();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user