2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 Denis Mingulov.
|
|
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2010-06-18 11:02:48 +02:00
|
|
|
|
|
|
|
|
#include "imageviewer.h"
|
2022-07-08 18:09:57 +02:00
|
|
|
|
2010-06-18 11:02:48 +02:00
|
|
|
#include "imageview.h"
|
2022-07-08 18:51:09 +02:00
|
|
|
#include "imageviewerconstants.h"
|
|
|
|
|
#include "imageviewerfile.h"
|
|
|
|
|
#include "imageviewertr.h"
|
2010-06-18 11:02:48 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2010-06-18 11:02:50 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2018-01-31 12:41:04 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2022-07-08 18:09:57 +02:00
|
|
|
#include <coreplugin/actionmanager/commandbutton.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/filepath.h>
|
2010-06-18 11:02:48 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2016-05-23 14:15:06 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2022-07-08 18:09:57 +02:00
|
|
|
#include <utils/styledbar.h>
|
2010-06-18 11:02:48 +02:00
|
|
|
|
2018-02-05 17:10:42 +01:00
|
|
|
#include <QAction>
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2022-07-08 18:51:09 +02:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
2022-07-08 18:09:57 +02:00
|
|
|
#include <QHBoxLayout>
|
2022-07-08 18:51:09 +02:00
|
|
|
#include <QImageReader>
|
2022-07-08 18:09:57 +02:00
|
|
|
#include <QLabel>
|
2022-07-08 18:51:09 +02:00
|
|
|
#include <QMap>
|
2022-07-08 18:09:57 +02:00
|
|
|
#include <QSpacerItem>
|
|
|
|
|
#include <QWidget>
|
2022-07-08 18:51:09 +02:00
|
|
|
#include <QWidget>
|
2022-07-08 18:09:57 +02:00
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace Utils;
|
2010-06-18 11:02:48 +02:00
|
|
|
|
2022-07-08 18:51:09 +02:00
|
|
|
namespace ImageViewer::Internal{
|
2010-06-18 11:02:48 +02:00
|
|
|
|
|
|
|
|
struct ImageViewerPrivate
|
|
|
|
|
{
|
|
|
|
|
QString displayName;
|
2015-05-29 13:23:52 +02:00
|
|
|
QSharedPointer<ImageViewerFile> file;
|
2010-06-18 11:02:48 +02:00
|
|
|
ImageView *imageView;
|
|
|
|
|
QWidget *toolbar;
|
2022-07-08 18:09:57 +02:00
|
|
|
|
|
|
|
|
CommandButton *toolButtonExportImage;
|
|
|
|
|
CommandButton *toolButtonMultiExportImages;
|
|
|
|
|
CommandButton *toolButtonCopyDataUrl;
|
|
|
|
|
CommandButton *toolButtonBackground;
|
|
|
|
|
CommandButton *toolButtonOutline;
|
|
|
|
|
CommandButton *toolButtonFitToScreen;
|
|
|
|
|
CommandButton *toolButtonOriginalSize;
|
|
|
|
|
CommandButton *toolButtonZoomIn;
|
|
|
|
|
CommandButton *toolButtonZoomOut;
|
|
|
|
|
CommandButton *toolButtonPlayPause;
|
|
|
|
|
QLabel *labelImageSize;
|
|
|
|
|
QLabel *labelInfo;
|
2010-06-18 11:02:48 +02:00
|
|
|
};
|
|
|
|
|
|
2015-05-29 13:23:52 +02:00
|
|
|
/*!
|
|
|
|
|
Tries to change the \a button icon to the icon specified by \a name
|
|
|
|
|
from the current theme. Returns \c true if icon is updated, \c false
|
|
|
|
|
otherwise.
|
|
|
|
|
*/
|
|
|
|
|
static bool updateButtonIconByTheme(QAbstractButton *button, const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(!name.isEmpty(), return false);
|
|
|
|
|
|
|
|
|
|
if (QIcon::hasThemeIcon(name)) {
|
|
|
|
|
button->setIcon(QIcon::fromTheme(name));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-24 09:42:16 +02:00
|
|
|
ImageViewer::ImageViewer()
|
|
|
|
|
: d(new ImageViewerPrivate)
|
2010-06-18 11:02:48 +02:00
|
|
|
{
|
2015-05-29 13:23:52 +02:00
|
|
|
d->file.reset(new ImageViewerFile);
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-24 09:42:16 +02:00
|
|
|
ImageViewer::ImageViewer(const QSharedPointer<ImageViewerFile> &document)
|
|
|
|
|
: d(new ImageViewerPrivate)
|
2015-05-29 13:23:52 +02:00
|
|
|
{
|
|
|
|
|
d->file = document;
|
|
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewer::ctor()
|
|
|
|
|
{
|
|
|
|
|
d->imageView = new ImageView(d->file.data());
|
2022-09-14 16:31:30 +02:00
|
|
|
d->imageView->readSettings(ICore::settings());
|
|
|
|
|
const ImageView::Settings settings = d->imageView->settings();
|
2010-06-18 11:02:48 +02:00
|
|
|
|
2011-04-13 13:00:30 +02:00
|
|
|
setContext(Core::Context(Constants::IMAGEVIEWER_ID));
|
2011-09-02 12:16:56 +02:00
|
|
|
setWidget(d->imageView);
|
2015-05-29 13:23:52 +02:00
|
|
|
setDuplicateSupported(true);
|
2011-04-13 13:00:30 +02:00
|
|
|
|
2010-06-18 11:02:48 +02:00
|
|
|
// toolbar
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolbar = new QWidget;
|
|
|
|
|
|
|
|
|
|
d->toolButtonExportImage = new CommandButton;
|
|
|
|
|
d->toolButtonMultiExportImages = new CommandButton;
|
|
|
|
|
d->toolButtonCopyDataUrl = new CommandButton;
|
|
|
|
|
d->toolButtonBackground = new CommandButton;
|
|
|
|
|
d->toolButtonOutline = new CommandButton;
|
|
|
|
|
d->toolButtonFitToScreen = new CommandButton;
|
|
|
|
|
d->toolButtonOriginalSize = new CommandButton;
|
|
|
|
|
d->toolButtonZoomIn = new CommandButton;
|
|
|
|
|
d->toolButtonZoomOut = new CommandButton;
|
|
|
|
|
d->toolButtonPlayPause = new CommandButton;
|
|
|
|
|
|
|
|
|
|
d->toolButtonBackground->setCheckable(true);
|
2022-09-14 16:31:30 +02:00
|
|
|
d->toolButtonBackground->setChecked(settings.showBackground);
|
2022-07-08 18:09:57 +02:00
|
|
|
|
|
|
|
|
d->toolButtonOutline->setCheckable(true);
|
2022-09-14 16:31:30 +02:00
|
|
|
d->toolButtonOutline->setChecked(settings.showOutline);
|
2022-07-08 18:09:57 +02:00
|
|
|
|
2022-09-14 13:55:43 +02:00
|
|
|
d->toolButtonFitToScreen->setCheckable(true);
|
2022-09-14 16:31:30 +02:00
|
|
|
d->toolButtonFitToScreen->setChecked(settings.fitToScreen);
|
2022-07-08 18:09:57 +02:00
|
|
|
|
|
|
|
|
d->toolButtonZoomIn->setAutoRepeat(true);
|
|
|
|
|
|
|
|
|
|
d->toolButtonZoomOut->setAutoRepeat(true);
|
|
|
|
|
|
2022-07-08 18:51:09 +02:00
|
|
|
d->toolButtonExportImage->setToolTipBase(Tr::tr("Export as Image"));
|
|
|
|
|
d->toolButtonMultiExportImages->setToolTipBase(Tr::tr("Export Images of Multiple Sizes"));
|
|
|
|
|
d->toolButtonOutline->setToolTipBase(Tr::tr("Show Outline"));
|
|
|
|
|
d->toolButtonFitToScreen->setToolTipBase(Tr::tr("Fit to Screen"));
|
|
|
|
|
d->toolButtonOriginalSize->setToolTipBase(Tr::tr("Original Size"));
|
|
|
|
|
d->toolButtonZoomIn->setToolTipBase(Tr::tr("Zoom In"));
|
|
|
|
|
d->toolButtonZoomOut->setToolTipBase(Tr::tr("Zoom Out"));
|
2022-07-08 18:09:57 +02:00
|
|
|
|
|
|
|
|
d->toolButtonExportImage->setIcon(Icons::EXPORTFILE_TOOLBAR.icon());
|
|
|
|
|
d->toolButtonMultiExportImages->setIcon(Icons::MULTIEXPORTFILE_TOOLBAR.icon());
|
|
|
|
|
d->toolButtonCopyDataUrl->setIcon(Icons::COPY_TOOLBAR.icon());
|
|
|
|
|
const Icon backgroundIcon({{":/utils/images/desktopdevicesmall.png", Theme::IconsBaseColor}});
|
|
|
|
|
d->toolButtonBackground->setIcon(backgroundIcon.icon());
|
|
|
|
|
d->toolButtonOutline->setIcon(Icons::BOUNDING_RECT.icon());
|
|
|
|
|
d->toolButtonZoomIn->setIcon(
|
|
|
|
|
ActionManager::command(Core::Constants::ZOOM_IN)->action()->icon());
|
|
|
|
|
d->toolButtonZoomOut->setIcon(
|
|
|
|
|
ActionManager::command(Core::Constants::ZOOM_OUT)->action()->icon());
|
|
|
|
|
d->toolButtonOriginalSize->setIcon(
|
|
|
|
|
ActionManager::command(Core::Constants::ZOOM_RESET)->action()->icon());
|
|
|
|
|
d->toolButtonFitToScreen->setIcon(Icons::FITTOVIEW_TOOLBAR.icon());
|
|
|
|
|
|
2010-06-18 11:02:48 +02:00
|
|
|
// icons update - try to use system theme
|
2022-07-08 18:09:57 +02:00
|
|
|
updateButtonIconByTheme(d->toolButtonFitToScreen, QLatin1String("zoom-fit-best"));
|
2010-06-18 11:02:48 +02:00
|
|
|
// a display - something is on the background
|
2022-07-08 18:09:57 +02:00
|
|
|
updateButtonIconByTheme(d->toolButtonBackground, QLatin1String("video-display"));
|
2010-06-18 11:02:48 +02:00
|
|
|
// "emblem to specify the directory where the user stores photographs"
|
|
|
|
|
// (photograph has outline - piece of paper)
|
2022-07-08 18:09:57 +02:00
|
|
|
updateButtonIconByTheme(d->toolButtonOutline, QLatin1String("emblem-photos"));
|
|
|
|
|
|
2022-09-14 16:31:30 +02:00
|
|
|
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);
|
|
|
|
|
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonExportImage->setCommandId(Constants::ACTION_EXPORT_IMAGE);
|
|
|
|
|
d->toolButtonMultiExportImages->setCommandId(Constants::ACTION_EXPORT_MULTI_IMAGES);
|
|
|
|
|
d->toolButtonCopyDataUrl->setCommandId(Constants::ACTION_COPY_DATA_URL);
|
|
|
|
|
d->toolButtonZoomIn->setCommandId(Core::Constants::ZOOM_IN);
|
|
|
|
|
d->toolButtonZoomOut->setCommandId(Core::Constants::ZOOM_OUT);
|
|
|
|
|
d->toolButtonOriginalSize->setCommandId(Core::Constants::ZOOM_RESET);
|
|
|
|
|
d->toolButtonFitToScreen->setCommandId(Constants::ACTION_FIT_TO_SCREEN);
|
|
|
|
|
d->toolButtonBackground->setCommandId(Constants::ACTION_BACKGROUND);
|
|
|
|
|
d->toolButtonOutline->setCommandId(Constants::ACTION_OUTLINE);
|
|
|
|
|
d->toolButtonPlayPause->setCommandId(Constants::ACTION_TOGGLE_ANIMATION);
|
|
|
|
|
|
|
|
|
|
d->labelImageSize = new QLabel;
|
|
|
|
|
d->labelInfo = new QLabel;
|
|
|
|
|
|
|
|
|
|
auto horizontalLayout = new QHBoxLayout(d->toolbar);
|
|
|
|
|
horizontalLayout->setSpacing(0);
|
|
|
|
|
horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonExportImage);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonMultiExportImages);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonCopyDataUrl);
|
2022-09-14 16:31:30 +02:00
|
|
|
horizontalLayout->addWidget(new StyledSeparator);
|
2022-07-08 18:09:57 +02:00
|
|
|
horizontalLayout->addWidget(d->toolButtonBackground);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonOutline);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonFitToScreen);
|
2022-09-14 16:31:30 +02:00
|
|
|
horizontalLayout->addWidget(setAsDefaultButton);
|
|
|
|
|
horizontalLayout->addWidget(new StyledSeparator);
|
2022-07-08 18:09:57 +02:00
|
|
|
horizontalLayout->addWidget(d->toolButtonOriginalSize);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonZoomIn);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonZoomOut);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonPlayPause);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonPlayPause);
|
|
|
|
|
horizontalLayout->addWidget(new StyledSeparator);
|
|
|
|
|
horizontalLayout->addItem(new QSpacerItem(315, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
|
|
|
|
|
horizontalLayout->addWidget(new StyledSeparator);
|
|
|
|
|
horizontalLayout->addWidget(d->labelImageSize);
|
|
|
|
|
horizontalLayout->addWidget(new StyledSeparator);
|
|
|
|
|
horizontalLayout->addWidget(d->labelInfo);
|
2012-06-25 20:39:09 +04:00
|
|
|
|
2010-06-18 11:02:48 +02:00
|
|
|
// connections
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonExportImage, &QAbstractButton::clicked,
|
2016-03-17 16:02:20 +01:00
|
|
|
d->imageView, &ImageView::exportImage);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonMultiExportImages, &QAbstractButton::clicked,
|
2018-01-12 15:32:10 +01:00
|
|
|
d->imageView, &ImageView::exportMultiImages);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonCopyDataUrl, &QAbstractButton::clicked,
|
2022-05-07 03:50:41 +09:00
|
|
|
d->imageView, &ImageView::copyDataUrl);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonZoomIn, &QAbstractButton::clicked,
|
2015-09-21 16:19:04 +02:00
|
|
|
d->imageView, &ImageView::zoomIn);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonZoomOut, &QAbstractButton::clicked,
|
2015-09-21 16:19:04 +02:00
|
|
|
d->imageView, &ImageView::zoomOut);
|
2022-09-14 13:55:43 +02:00
|
|
|
connect(d->toolButtonFitToScreen,
|
|
|
|
|
&QAbstractButton::toggled,
|
|
|
|
|
d->imageView,
|
|
|
|
|
&ImageView::setFitToScreen);
|
|
|
|
|
connect(d->imageView,
|
|
|
|
|
&ImageView::fitToScreenChanged,
|
|
|
|
|
d->toolButtonFitToScreen,
|
|
|
|
|
&QAbstractButton::setChecked);
|
|
|
|
|
connect(d->toolButtonOriginalSize,
|
|
|
|
|
&QAbstractButton::clicked,
|
|
|
|
|
d->imageView,
|
|
|
|
|
&ImageView::resetToOriginalSize);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonBackground, &QAbstractButton::toggled,
|
2015-09-21 16:19:04 +02:00
|
|
|
d->imageView, &ImageView::setViewBackground);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonOutline, &QAbstractButton::toggled,
|
2015-09-21 16:19:04 +02:00
|
|
|
d->imageView, &ImageView::setViewOutline);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonPlayPause, &CommandButton::clicked,
|
2015-01-29 14:32:36 +01:00
|
|
|
this, &ImageViewer::playToggled);
|
2015-05-29 13:23:52 +02:00
|
|
|
connect(d->file.data(), &ImageViewerFile::imageSizeChanged,
|
|
|
|
|
this, &ImageViewer::imageSizeUpdated);
|
2015-06-02 17:14:48 +02:00
|
|
|
connect(d->file.data(), &ImageViewerFile::openFinished,
|
|
|
|
|
d->imageView, &ImageView::createScene);
|
2016-04-14 09:35:39 +02:00
|
|
|
connect(d->file.data(), &ImageViewerFile::openFinished,
|
|
|
|
|
this, &ImageViewer::updateToolButtons);
|
2015-05-29 13:23:52 +02:00
|
|
|
connect(d->file.data(), &ImageViewerFile::aboutToReload,
|
|
|
|
|
d->imageView, &ImageView::reset);
|
|
|
|
|
connect(d->file.data(), &ImageViewerFile::reloadFinished,
|
|
|
|
|
d->imageView, &ImageView::createScene);
|
|
|
|
|
connect(d->file.data(), &ImageViewerFile::isPausedChanged,
|
|
|
|
|
this, &ImageViewer::updatePauseAction);
|
2015-09-21 16:19:04 +02:00
|
|
|
connect(d->imageView, &ImageView::scaleFactorChanged,
|
|
|
|
|
this, &ImageViewer::scaleFactorUpdate);
|
2022-09-14 16:31:30 +02:00
|
|
|
connect(setAsDefault, &QAction::triggered, d->imageView, [this] {
|
|
|
|
|
d->imageView->writeSettings(ICore::settings());
|
|
|
|
|
});
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImageViewer::~ImageViewer()
|
|
|
|
|
{
|
2011-09-02 12:16:56 +02:00
|
|
|
delete d->imageView;
|
|
|
|
|
delete d->toolbar;
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-08 18:09:57 +02:00
|
|
|
IDocument *ImageViewer::document() const
|
2010-06-18 11:02:48 +02:00
|
|
|
{
|
2015-05-29 13:23:52 +02:00
|
|
|
return d->file.data();
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *ImageViewer::toolBar()
|
|
|
|
|
{
|
2011-09-02 12:16:56 +02:00
|
|
|
return d->toolbar;
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-08 18:09:57 +02:00
|
|
|
IEditor *ImageViewer::duplicate()
|
2015-05-29 13:23:52 +02:00
|
|
|
{
|
|
|
|
|
auto other = new ImageViewer(d->file);
|
|
|
|
|
other->d->imageView->createScene();
|
2016-04-14 09:35:39 +02:00
|
|
|
other->updateToolButtons();
|
2022-07-08 18:09:57 +02:00
|
|
|
other->d->labelImageSize->setText(d->labelImageSize->text());
|
2021-01-12 13:13:20 +01:00
|
|
|
|
|
|
|
|
emit editorDuplicated(other);
|
|
|
|
|
|
2015-05-29 13:23:52 +02:00
|
|
|
return other;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-17 16:02:20 +01:00
|
|
|
void ImageViewer::exportImage()
|
|
|
|
|
{
|
|
|
|
|
if (d->file->type() == ImageViewerFile::TypeSvg)
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonExportImage->click();
|
2016-03-17 16:02:20 +01:00
|
|
|
}
|
|
|
|
|
|
2018-01-12 15:32:10 +01:00
|
|
|
void ImageViewer::exportMultiImages()
|
|
|
|
|
{
|
|
|
|
|
if (d->file->type() == ImageViewerFile::TypeSvg)
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonMultiExportImages->click();
|
2018-01-12 15:32:10 +01:00
|
|
|
}
|
|
|
|
|
|
2022-05-07 03:50:41 +09:00
|
|
|
void ImageViewer::copyDataUrl()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonCopyDataUrl->click();
|
2022-05-07 03:50:41 +09:00
|
|
|
}
|
|
|
|
|
|
2012-05-10 15:14:21 +04:00
|
|
|
void ImageViewer::imageSizeUpdated(const QSize &size)
|
|
|
|
|
{
|
|
|
|
|
QString imageSizeText;
|
|
|
|
|
if (size.isValid())
|
|
|
|
|
imageSizeText = QString::fromLatin1("%1x%2").arg(size.width()).arg(size.height());
|
2022-07-08 18:09:57 +02:00
|
|
|
d->labelImageSize->setText(imageSizeText);
|
2012-05-10 15:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
2010-06-18 11:02:48 +02:00
|
|
|
void ImageViewer::scaleFactorUpdate(qreal factor)
|
|
|
|
|
{
|
2010-09-10 10:51:43 +02:00
|
|
|
const QString info = QString::number(factor * 100, 'f', 2) + QLatin1Char('%');
|
2022-07-08 18:09:57 +02:00
|
|
|
d->labelInfo->setText(info);
|
2010-06-18 11:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-18 11:02:50 +02:00
|
|
|
void ImageViewer::switchViewBackground()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonBackground->click();
|
2010-06-18 11:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewer::switchViewOutline()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonOutline->click();
|
2010-06-18 11:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewer::zoomIn()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonZoomIn->click();
|
2010-06-18 11:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewer::zoomOut()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonZoomOut->click();
|
2010-06-18 11:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewer::resetToOriginalSize()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonOriginalSize->click();
|
2010-06-18 11:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewer::fitToScreen()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonFitToScreen->click();
|
2010-06-18 11:02:50 +02:00
|
|
|
}
|
|
|
|
|
|
2016-04-14 09:35:39 +02:00
|
|
|
void ImageViewer::updateToolButtons()
|
|
|
|
|
{
|
2018-01-12 15:32:10 +01:00
|
|
|
const bool isSvg = d->file->type() == ImageViewerFile::TypeSvg;
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonExportImage->setEnabled(isSvg);
|
|
|
|
|
d->toolButtonMultiExportImages->setEnabled(isSvg);
|
2016-04-14 09:35:39 +02:00
|
|
|
updatePauseAction();
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 15:14:21 +04:00
|
|
|
void ImageViewer::togglePlay()
|
|
|
|
|
{
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonPlayPause->click();
|
2012-05-10 15:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImageViewer::playToggled()
|
|
|
|
|
{
|
2015-05-29 13:23:52 +02:00
|
|
|
d->file->setPaused(!d->file->isPaused());
|
2012-05-10 15:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
2015-05-29 13:23:52 +02:00
|
|
|
void ImageViewer::updatePauseAction()
|
2012-05-10 15:14:21 +04:00
|
|
|
{
|
2015-05-29 13:23:52 +02:00
|
|
|
bool isMovie = d->file->type() == ImageViewerFile::TypeMovie;
|
2016-04-14 09:35:39 +02:00
|
|
|
if (isMovie && !d->file->isPaused()) {
|
2022-07-08 18:51:09 +02:00
|
|
|
d->toolButtonPlayPause->setToolTipBase(Tr::tr("Pause Animation"));
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonPlayPause->setIcon(Icons::INTERRUPT_SMALL_TOOLBAR.icon());
|
2016-04-14 09:35:39 +02:00
|
|
|
} else {
|
2022-07-08 18:51:09 +02:00
|
|
|
d->toolButtonPlayPause->setToolTipBase(Tr::tr("Play Animation"));
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonPlayPause->setIcon(Icons::RUN_SMALL_TOOLBAR.icon());
|
|
|
|
|
d->toolButtonPlayPause->setEnabled(isMovie);
|
2012-05-10 15:14:21 +04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 18:51:09 +02:00
|
|
|
// Factory
|
|
|
|
|
|
|
|
|
|
ImageViewerFactory::ImageViewerFactory()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::IMAGEVIEWER_ID);
|
|
|
|
|
setDisplayName(Tr::tr("Image Viewer"));
|
|
|
|
|
setEditorCreator([] { return new ImageViewer; });
|
|
|
|
|
|
|
|
|
|
const QList<QByteArray> supportedMimeTypes = QImageReader::supportedMimeTypes();
|
|
|
|
|
for (const QByteArray &format : supportedMimeTypes)
|
|
|
|
|
addMimeType(QString::fromLatin1(format));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // ImageViewer::Internal
|