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 "imageviewerplugin.h"
|
2022-07-08 18:51:09 +02:00
|
|
|
|
2016-03-15 14:18:20 +01:00
|
|
|
#include "imageviewer.h"
|
2010-06-18 11:02:48 +02:00
|
|
|
#include "imageviewerconstants.h"
|
2022-07-08 18:51:09 +02:00
|
|
|
#include "imageviewertr.h"
|
2010-06-18 11:02:48 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2016-03-15 14:18:20 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2018-01-31 12:41:04 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2016-03-15 14:18:20 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2020-01-22 15:37:47 +01:00
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QKeySequence>
|
|
|
|
|
|
|
|
|
|
using namespace Core;
|
2020-06-26 13:59:38 +02:00
|
|
|
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
|
|
|
|
2020-01-22 15:37:47 +01:00
|
|
|
class ImageViewerAction final : public QAction
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ImageViewerAction(Id id,
|
|
|
|
|
const std::function<void(ImageViewer *v)> &onTriggered,
|
|
|
|
|
const QString &title = {},
|
|
|
|
|
const QKeySequence &key = {})
|
|
|
|
|
: QAction(title)
|
|
|
|
|
{
|
|
|
|
|
Command *command = ActionManager::registerAction(this, id, Context(Constants::IMAGEVIEWER_ID));
|
|
|
|
|
if (!key.isEmpty())
|
|
|
|
|
command->setDefaultKeySequence(key);
|
|
|
|
|
|
|
|
|
|
connect(this, &QAction::triggered, this, [onTriggered] {
|
|
|
|
|
if (auto iv = qobject_cast<ImageViewer *>(EditorManager::currentEditor()))
|
|
|
|
|
onTriggered(iv);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ImageViewerPluginPrivate final
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ImageViewerFactory imageViewerFactory;
|
|
|
|
|
|
|
|
|
|
ImageViewerAction zoomInAction {
|
|
|
|
|
Core::Constants::ZOOM_IN,
|
|
|
|
|
&ImageViewer::zoomIn
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction zoomOutAction {
|
|
|
|
|
Core::Constants::ZOOM_OUT,
|
|
|
|
|
&ImageViewer::zoomOut
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction zoomResetAction {
|
|
|
|
|
Core::Constants::ZOOM_RESET,
|
|
|
|
|
&ImageViewer::resetToOriginalSize
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction fitToScreenAction {
|
|
|
|
|
Constants::ACTION_FIT_TO_SCREEN,
|
|
|
|
|
&ImageViewer::fitToScreen,
|
2022-07-08 18:51:09 +02:00
|
|
|
Tr::tr("Fit to Screen"),
|
|
|
|
|
Tr::tr("Ctrl+=")
|
2020-01-22 15:37:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction switchBackgroundAction {
|
|
|
|
|
Constants::ACTION_BACKGROUND,
|
|
|
|
|
&ImageViewer::switchViewBackground,
|
2022-07-08 18:51:09 +02:00
|
|
|
Tr::tr("Switch Background"),
|
|
|
|
|
Tr::tr("Ctrl+[")
|
2020-01-22 15:37:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction switchOutlineAction {
|
|
|
|
|
Constants::ACTION_OUTLINE,
|
|
|
|
|
&ImageViewer::switchViewOutline,
|
2022-07-08 18:51:09 +02:00
|
|
|
Tr::tr("Switch Outline"),
|
|
|
|
|
Tr::tr("Ctrl+]")
|
2020-01-22 15:37:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction toggleAnimationAction {
|
|
|
|
|
Constants::ACTION_TOGGLE_ANIMATION,
|
|
|
|
|
&ImageViewer::togglePlay,
|
2022-07-08 18:51:09 +02:00
|
|
|
Tr::tr("Toggle Animation")
|
2020-01-22 15:37:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction exportImageAction {
|
|
|
|
|
Constants::ACTION_EXPORT_IMAGE,
|
|
|
|
|
&ImageViewer::exportImage,
|
2022-07-08 18:51:09 +02:00
|
|
|
Tr::tr("Export Image")
|
2020-01-22 15:37:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerAction exportMulitImagesAction {
|
|
|
|
|
Constants::ACTION_EXPORT_MULTI_IMAGES,
|
|
|
|
|
&ImageViewer::exportMultiImages,
|
2022-07-08 18:51:09 +02:00
|
|
|
Tr::tr("Export Multiple Images"),
|
2020-01-22 15:37:47 +01:00
|
|
|
};
|
2022-05-07 03:50:41 +09:00
|
|
|
|
|
|
|
|
ImageViewerAction copyDataUrlAction {
|
|
|
|
|
Constants::ACTION_COPY_DATA_URL,
|
|
|
|
|
&ImageViewer::copyDataUrl,
|
2022-07-08 18:51:09 +02:00
|
|
|
Tr::tr("Copy as Data URL"),
|
2022-05-07 03:50:41 +09:00
|
|
|
};
|
2020-01-22 15:37:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ImageViewerPlugin::~ImageViewerPlugin()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
2010-06-18 11:02:48 +02:00
|
|
|
|
|
|
|
|
bool ImageViewerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(arguments)
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(errorMessage)
|
2010-06-18 11:02:48 +02:00
|
|
|
|
2020-01-22 15:37:47 +01:00
|
|
|
d = new ImageViewerPluginPrivate;
|
2018-02-08 09:00:30 +01:00
|
|
|
|
2010-06-18 11:02:48 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 18:51:09 +02:00
|
|
|
} // ImageViewer::Internal
|