2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2010-06-18 11:02:48 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 Denis Mingulov.
|
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-06-18 11:02:48 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-06-18 11:02:48 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-06-18 11:02:48 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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 "imageviewerfile.h"
|
|
|
|
|
#include "imageviewerconstants.h"
|
|
|
|
|
#include "imageview.h"
|
|
|
|
|
|
|
|
|
|
#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-02-15 10:42:41 +01:00
|
|
|
#include <QMap>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QWidget>
|
2012-08-06 13:42:46 +02:00
|
|
|
#include <QDebug>
|
2022-07-08 18:09:57 +02:00
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace Utils;
|
2010-06-18 11:02:48 +02:00
|
|
|
|
|
|
|
|
namespace ImageViewer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
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());
|
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);
|
|
|
|
|
d->toolButtonBackground->setChecked(false);
|
|
|
|
|
|
|
|
|
|
d->toolButtonOutline->setCheckable(true);
|
|
|
|
|
d->toolButtonOutline->setChecked(true);
|
|
|
|
|
|
|
|
|
|
d->toolButtonFitToScreen->setCheckable(false);
|
|
|
|
|
|
|
|
|
|
d->toolButtonZoomIn->setAutoRepeat(true);
|
|
|
|
|
|
|
|
|
|
d->toolButtonZoomOut->setAutoRepeat(true);
|
|
|
|
|
|
|
|
|
|
d->toolButtonExportImage->setToolTipBase(tr("Export as Image"));
|
|
|
|
|
d->toolButtonMultiExportImages->setToolTipBase(tr("Export Images of Multiple Sizes"));
|
|
|
|
|
d->toolButtonOutline->setToolTipBase(tr("Show Outline"));
|
|
|
|
|
d->toolButtonFitToScreen->setToolTipBase(tr("Fit to Screen"));
|
|
|
|
|
d->toolButtonOriginalSize->setToolTipBase(tr("Original Size"));
|
|
|
|
|
d->toolButtonZoomIn->setToolTipBase(tr("Zoom In"));
|
|
|
|
|
d->toolButtonZoomOut->setToolTipBase(tr("Zoom Out"));
|
|
|
|
|
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonBackground);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonOutline);
|
|
|
|
|
horizontalLayout->addWidget(d->toolButtonFitToScreen);
|
|
|
|
|
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-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonFitToScreen, &QAbstractButton::clicked,
|
2015-09-21 16:19:04 +02:00
|
|
|
d->imageView, &ImageView::fitToScreen);
|
2022-07-08 18:09:57 +02:00
|
|
|
connect(d->toolButtonOriginalSize, &QAbstractButton::clicked,
|
2015-09-21 16:19:04 +02:00
|
|
|
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);
|
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:09:57 +02:00
|
|
|
d->toolButtonPlayPause->setToolTipBase(tr("Pause Animation"));
|
|
|
|
|
d->toolButtonPlayPause->setIcon(Icons::INTERRUPT_SMALL_TOOLBAR.icon());
|
2016-04-14 09:35:39 +02:00
|
|
|
} else {
|
2022-07-08 18:09:57 +02:00
|
|
|
d->toolButtonPlayPause->setToolTipBase(tr("Play Animation"));
|
|
|
|
|
d->toolButtonPlayPause->setIcon(Icons::RUN_SMALL_TOOLBAR.icon());
|
|
|
|
|
d->toolButtonPlayPause->setEnabled(isMovie);
|
2012-05-10 15:14:21 +04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-18 11:02:48 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ImageViewer
|