diff options
author | Eike Ziller <[email protected]> | 2022-09-14 16:31:30 +0200 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2022-09-15 11:28:41 +0000 |
commit | e57b797342e24bf2edf3f67411863bc1f8bc284d (patch) | |
tree | 7c1508d06b1ac16932b309422d524ed5a4f5f239 /src/plugins/imageviewer/imageviewer.cpp | |
parent | e7ddd8a5b7f7d0d540de5811b5ea9eaabbdc2c0b (diff) |
ImageViewer: Add button for saving current view settings as default
Fixes: QTCREATORBUG-27816
Change-Id: I85806634ea9f10761d281ab8c8cf892dd1b65145
Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/plugins/imageviewer/imageviewer.cpp')
-rw-r--r-- | src/plugins/imageviewer/imageviewer.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp index a3ecd5de5f7..a448f2fe478 100644 --- a/src/plugins/imageviewer/imageviewer.cpp +++ b/src/plugins/imageviewer/imageviewer.cpp @@ -92,6 +92,8 @@ ImageViewer::ImageViewer(const QSharedPointer<ImageViewerFile> &document) void ImageViewer::ctor() { d->imageView = new ImageView(d->file.data()); + d->imageView->readSettings(ICore::settings()); + const ImageView::Settings settings = d->imageView->settings(); setContext(Core::Context(Constants::IMAGEVIEWER_ID)); setWidget(d->imageView); @@ -112,12 +114,13 @@ void ImageViewer::ctor() d->toolButtonPlayPause = new CommandButton; d->toolButtonBackground->setCheckable(true); - d->toolButtonBackground->setChecked(false); + d->toolButtonBackground->setChecked(settings.showBackground); d->toolButtonOutline->setCheckable(true); - d->toolButtonOutline->setChecked(true); + d->toolButtonOutline->setChecked(settings.showOutline); d->toolButtonFitToScreen->setCheckable(true); + d->toolButtonFitToScreen->setChecked(settings.fitToScreen); d->toolButtonZoomIn->setAutoRepeat(true); @@ -153,6 +156,12 @@ void ImageViewer::ctor() // (photograph has outline - piece of paper) updateButtonIconByTheme(d->toolButtonOutline, QLatin1String("emblem-photos")); + auto setAsDefaultButton = new QToolButton; + auto setAsDefault = new QAction(Tr::tr("Set as Default"), setAsDefaultButton); + setAsDefault->setToolTip(Tr::tr("Use the current settings for background, outline, and fitting " + "to screen as the default for new image viewers.")); + setAsDefaultButton->setDefaultAction(setAsDefault); + d->toolButtonExportImage->setCommandId(Constants::ACTION_EXPORT_IMAGE); d->toolButtonMultiExportImages->setCommandId(Constants::ACTION_EXPORT_MULTI_IMAGES); d->toolButtonCopyDataUrl->setCommandId(Constants::ACTION_COPY_DATA_URL); @@ -173,9 +182,12 @@ void ImageViewer::ctor() horizontalLayout->addWidget(d->toolButtonExportImage); horizontalLayout->addWidget(d->toolButtonMultiExportImages); horizontalLayout->addWidget(d->toolButtonCopyDataUrl); + horizontalLayout->addWidget(new StyledSeparator); horizontalLayout->addWidget(d->toolButtonBackground); horizontalLayout->addWidget(d->toolButtonOutline); horizontalLayout->addWidget(d->toolButtonFitToScreen); + horizontalLayout->addWidget(setAsDefaultButton); + horizontalLayout->addWidget(new StyledSeparator); horizontalLayout->addWidget(d->toolButtonOriginalSize); horizontalLayout->addWidget(d->toolButtonZoomIn); horizontalLayout->addWidget(d->toolButtonZoomOut); @@ -231,6 +243,9 @@ void ImageViewer::ctor() this, &ImageViewer::updatePauseAction); connect(d->imageView, &ImageView::scaleFactorChanged, this, &ImageViewer::scaleFactorUpdate); + connect(setAsDefault, &QAction::triggered, d->imageView, [this] { + d->imageView->writeSettings(ICore::settings()); + }); } ImageViewer::~ImageViewer() |