forked from qt-creator/qt-creator
ImageViewer: Convert to Tr::tr
Change-Id: Id12dc265ed60be942ec68ac5a80f57144c2d086f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -11,7 +11,6 @@ add_qtc_plugin(ImageViewer
|
||||
imageview.cpp imageview.h
|
||||
imageviewer.cpp imageviewer.h
|
||||
imageviewerconstants.h
|
||||
imageviewerfactory.cpp imageviewerfactory.h
|
||||
imageviewerfile.cpp imageviewerfile.h
|
||||
imageviewerplugin.cpp imageviewerplugin.h
|
||||
multiexportdialog.cpp multiexportdialog.h
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "exportdialog.h"
|
||||
|
||||
#include "imageview.h" // ExportData
|
||||
#include "imageviewertr.h"
|
||||
|
||||
#include <coreplugin/coreicons.h>
|
||||
|
||||
@@ -54,7 +56,7 @@ QString ExportDialog::imageNameFilterString()
|
||||
static QString result;
|
||||
if (result.isEmpty()) {
|
||||
QMimeDatabase mimeDatabase;
|
||||
const QString separator = QStringLiteral(";;");
|
||||
const QString separator = ";;";
|
||||
foreach (const QByteArray &mimeType, QImageWriter::supportedMimeTypes()) {
|
||||
const QString filter = mimeDatabase.mimeTypeForName(QLatin1String(mimeType)).filterString();
|
||||
if (!filter.isEmpty()) {
|
||||
@@ -85,7 +87,7 @@ ExportDialog::ExportDialog(QWidget *parent)
|
||||
m_pathChooser->setMinimumWidth(screen()->availableGeometry().width() / 5);
|
||||
m_pathChooser->setExpectedKind(Utils::PathChooser::SaveFile);
|
||||
m_pathChooser->setPromptDialogFilter(imageNameFilterString());
|
||||
formLayout->addRow(tr("File:"), m_pathChooser);
|
||||
formLayout->addRow(Tr::tr("File:"), m_pathChooser);
|
||||
|
||||
auto sizeLayout = new QHBoxLayout;
|
||||
m_widthSpinBox->setMinimum(exportMinimumSize);
|
||||
@@ -94,18 +96,18 @@ ExportDialog::ExportDialog(QWidget *parent)
|
||||
this, &ExportDialog::exportWidthChanged);
|
||||
sizeLayout->addWidget(m_widthSpinBox);
|
||||
//: Multiplication, as in 32x32
|
||||
sizeLayout->addWidget(new QLabel(tr("x")));
|
||||
sizeLayout->addWidget(new QLabel(Tr::tr("x")));
|
||||
m_heightSpinBox->setMinimum(exportMinimumSize);
|
||||
m_heightSpinBox->setMaximum(exportMaximumSize);
|
||||
connect(m_heightSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, &ExportDialog::exportHeightChanged);
|
||||
sizeLayout->addWidget(m_heightSpinBox);
|
||||
auto resetButton = new QToolButton(this);
|
||||
resetButton->setIcon(QIcon(QStringLiteral(":/qt-project.org/styles/commonstyle/images/refresh-32.png")));
|
||||
resetButton->setIcon(QIcon(":/qt-project.org/styles/commonstyle/images/refresh-32.png"));
|
||||
sizeLayout->addWidget(resetButton);
|
||||
sizeLayout->addStretch();
|
||||
connect(resetButton, &QAbstractButton::clicked, this, &ExportDialog::resetExportSize);
|
||||
formLayout->addRow(tr("Size:"), sizeLayout);
|
||||
formLayout->addRow(Tr::tr("Size:"), sizeLayout);
|
||||
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
@@ -121,7 +123,7 @@ void ExportDialog::accept()
|
||||
}
|
||||
const QString fileName = exportFileName();
|
||||
if (QFileInfo::exists(fileName)) {
|
||||
const QString question = tr("%1 already exists.\nWould you like to overwrite it?")
|
||||
const QString question = Tr::tr("%1 already exists.\nWould you like to overwrite it?")
|
||||
.arg(QDir::toNativeSeparators(fileName));
|
||||
if (QMessageBox::question(this, windowTitle(), question, QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
@@ -31,14 +31,12 @@ QT_FORWARD_DECLARE_CLASS(QSpinBox)
|
||||
|
||||
namespace Utils { class PathChooser; }
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
struct ExportData;
|
||||
|
||||
class ExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExportDialog(QWidget *parent = nullptr);
|
||||
|
||||
@@ -69,5 +67,4 @@ private:
|
||||
qreal m_aspectRatio;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Internal
|
||||
|
||||
@@ -27,8 +27,9 @@
|
||||
#include "imageview.h"
|
||||
|
||||
#include "exportdialog.h"
|
||||
#include "multiexportdialog.h"
|
||||
#include "imageviewerfile.h"
|
||||
#include "imageviewertr.h"
|
||||
#include "multiexportdialog.h"
|
||||
#include "utils/mimeutils.h"
|
||||
|
||||
#include <coreplugin/messagemanager.h>
|
||||
@@ -36,19 +37,17 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QGraphicsRectItem>
|
||||
|
||||
#include <QWheelEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QClipboard>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QGuiApplication>
|
||||
#include <QImage>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include <qmath.h>
|
||||
|
||||
@@ -176,14 +175,14 @@ bool ImageView::exportSvg(const ExportData &ed)
|
||||
{
|
||||
const bool result = renderSvg(ed.size).save(ed.fileName);
|
||||
if (result) {
|
||||
const QString message = tr("Exported \"%1\", %2x%3, %4 bytes")
|
||||
const QString message = Tr::tr("Exported \"%1\", %2x%3, %4 bytes")
|
||||
.arg(QDir::toNativeSeparators(ed.fileName))
|
||||
.arg(ed.size.width()).arg(ed.size.height())
|
||||
.arg(QFileInfo(ed.fileName).size());
|
||||
Core::MessageManager::writeDisrupting(message);
|
||||
} else {
|
||||
const QString message = tr("Could not write file \"%1\".").arg(QDir::toNativeSeparators(ed.fileName));
|
||||
QMessageBox::critical(this, tr("Export Image"), message);
|
||||
const QString message = Tr::tr("Could not write file \"%1\".").arg(QDir::toNativeSeparators(ed.fileName));
|
||||
QMessageBox::critical(this, Tr::tr("Export Image"), message);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -214,7 +213,7 @@ void ImageView::exportImage()
|
||||
|
||||
const QFileInfo origFi = m_file->filePath().toFileInfo();
|
||||
ExportDialog exportDialog(this);
|
||||
exportDialog.setWindowTitle(tr("Export %1").arg(origFi.fileName()));
|
||||
exportDialog.setWindowTitle(Tr::tr("Export %1").arg(origFi.fileName()));
|
||||
exportDialog.setExportSize(svgSize());
|
||||
exportDialog.setExportFileName(suggestedExportFileName(origFi));
|
||||
|
||||
@@ -230,7 +229,7 @@ void ImageView::exportMultiImages()
|
||||
const QFileInfo origFi = m_file->filePath().toFileInfo();
|
||||
const QSize size = svgSize();
|
||||
const QString title =
|
||||
tr("Export a Series of Images from %1 (%2x%3)")
|
||||
Tr::tr("Export a Series of Images from %1 (%2x%3)")
|
||||
.arg(origFi.fileName()).arg(size.width()).arg(size.height());
|
||||
MultiExportDialog multiExportDialog;
|
||||
multiExportDialog.setWindowTitle(title);
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QImage)
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
class ImageViewerFile;
|
||||
|
||||
@@ -85,5 +84,4 @@ private:
|
||||
bool m_showOutline = true;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Internal
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
|
||||
#include "imageviewer.h"
|
||||
|
||||
#include "imageviewerfile.h"
|
||||
#include "imageviewerconstants.h"
|
||||
#include "imageview.h"
|
||||
#include "imageviewerconstants.h"
|
||||
#include "imageviewerfile.h"
|
||||
#include "imageviewertr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
@@ -42,22 +43,21 @@
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QMap>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
#include <QImageReader>
|
||||
#include <QLabel>
|
||||
#include <QMap>
|
||||
#include <QSpacerItem>
|
||||
#include <QWidget>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal{
|
||||
|
||||
struct ImageViewerPrivate
|
||||
{
|
||||
@@ -145,13 +145,13 @@ void ImageViewer::ctor()
|
||||
|
||||
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->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"));
|
||||
|
||||
d->toolButtonExportImage->setIcon(Icons::EXPORTFILE_TOOLBAR.icon());
|
||||
d->toolButtonMultiExportImages->setIcon(Icons::MULTIEXPORTFILE_TOOLBAR.icon());
|
||||
@@ -359,14 +359,26 @@ void ImageViewer::updatePauseAction()
|
||||
{
|
||||
bool isMovie = d->file->type() == ImageViewerFile::TypeMovie;
|
||||
if (isMovie && !d->file->isPaused()) {
|
||||
d->toolButtonPlayPause->setToolTipBase(tr("Pause Animation"));
|
||||
d->toolButtonPlayPause->setToolTipBase(Tr::tr("Pause Animation"));
|
||||
d->toolButtonPlayPause->setIcon(Icons::INTERRUPT_SMALL_TOOLBAR.icon());
|
||||
} else {
|
||||
d->toolButtonPlayPause->setToolTipBase(tr("Play Animation"));
|
||||
d->toolButtonPlayPause->setToolTipBase(Tr::tr("Play Animation"));
|
||||
d->toolButtonPlayPause->setIcon(Icons::RUN_SMALL_TOOLBAR.icon());
|
||||
d->toolButtonPlayPause->setEnabled(isMovie);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
// 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
|
||||
|
||||
@@ -27,16 +27,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QStringList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
class QAction;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
class ImageViewerFile;
|
||||
@@ -78,4 +71,10 @@ private:
|
||||
struct ImageViewerPrivate *d;
|
||||
};
|
||||
|
||||
class ImageViewerFactory final : public Core::IEditorFactory
|
||||
{
|
||||
public:
|
||||
ImageViewerFactory();
|
||||
};
|
||||
|
||||
} // ImageViewer::Internal
|
||||
|
||||
@@ -23,8 +23,6 @@ QtcPlugin {
|
||||
"imageviewer.cpp",
|
||||
"imageviewer.h",
|
||||
"imageviewerconstants.h",
|
||||
"imageviewerfactory.cpp",
|
||||
"imageviewerfactory.h",
|
||||
"imageviewerfile.cpp",
|
||||
"imageviewerfile.h",
|
||||
"imageviewerplugin.cpp",
|
||||
|
||||
@@ -28,11 +28,9 @@
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Constants {
|
||||
namespace ImageViewer::Constants {
|
||||
|
||||
const char IMAGEVIEWER_ID[] = "Editors.ImageViewer";
|
||||
const char IMAGEVIEWER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Image Viewer");
|
||||
|
||||
const char ACTION_EXPORT_IMAGE[] = "ImageViewer.ExportImage";
|
||||
const char ACTION_EXPORT_MULTI_IMAGES[] = "ImageViewer.ExportMultiImages";
|
||||
@@ -42,5 +40,4 @@ const char ACTION_BACKGROUND[] = "ImageViewer.Background";
|
||||
const char ACTION_OUTLINE[] = "ImageViewer.Outline";
|
||||
const char ACTION_TOGGLE_ANIMATION[] = "ImageViewer.ToggleAnimation";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Constants
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 Denis Mingulov.
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "imageviewerfactory.h"
|
||||
#include "imageviewerconstants.h"
|
||||
#include "imageviewer.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QImageReader>
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
|
||||
ImageViewerFactory::ImageViewerFactory()
|
||||
{
|
||||
setId(Constants::IMAGEVIEWER_ID);
|
||||
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME));
|
||||
setEditorCreator([] { return new ImageViewer; });
|
||||
|
||||
const QList<QByteArray> supportedMimeTypes = QImageReader::supportedMimeTypes();
|
||||
for (const QByteArray &format : supportedMimeTypes)
|
||||
addMimeType(QString::fromLatin1(format));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
@@ -1,41 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 Denis Mingulov.
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
|
||||
class ImageViewerFactory final : public Core::IEditorFactory
|
||||
{
|
||||
public:
|
||||
ImageViewerFactory();
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
@@ -25,26 +25,29 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "imageviewerfile.h"
|
||||
#include "imageviewer.h"
|
||||
|
||||
#include "imageviewerconstants.h"
|
||||
#include "imageviewertr.h"
|
||||
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/mimeutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#ifndef QT_NO_SVG
|
||||
#include <QGraphicsSvgItem>
|
||||
#endif
|
||||
#include <QImageReader>
|
||||
#include <QMovie>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
#ifndef QT_NO_SVG
|
||||
#include <QGraphicsSvgItem>
|
||||
#endif
|
||||
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
class MovieItem : public QObject, public QGraphicsPixmapItem
|
||||
{
|
||||
@@ -103,7 +106,7 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString,
|
||||
// if it is impossible to recognize a file format - file will not be open correctly
|
||||
if (format.isEmpty()) {
|
||||
if (errorString)
|
||||
*errorString = tr("Image format not supported.");
|
||||
*errorString = Tr::tr("Image format not supported.");
|
||||
return OpenResult::CannotHandle;
|
||||
}
|
||||
|
||||
@@ -115,7 +118,7 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString,
|
||||
delete m_tempSvgItem;
|
||||
m_tempSvgItem = nullptr;
|
||||
if (errorString)
|
||||
*errorString = tr("Failed to read SVG image.");
|
||||
*errorString = Tr::tr("Failed to read SVG image.");
|
||||
return OpenResult::CannotHandle;
|
||||
}
|
||||
m_type = TypeSvg;
|
||||
@@ -128,7 +131,7 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString,
|
||||
m_movie->jumpToNextFrame();
|
||||
if (!m_movie->isValid()) {
|
||||
if (errorString)
|
||||
*errorString = tr("Failed to read image.");
|
||||
*errorString = Tr::tr("Failed to read image.");
|
||||
delete m_movie;
|
||||
m_movie = nullptr;
|
||||
return OpenResult::CannotHandle;
|
||||
@@ -152,7 +155,7 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString,
|
||||
m_pixmap = new QPixmap(fileName);
|
||||
if (m_pixmap->isNull()) {
|
||||
if (errorString)
|
||||
*errorString = tr("Failed to read image.");
|
||||
*errorString = Tr::tr("Failed to read image.");
|
||||
delete m_pixmap;
|
||||
m_pixmap = nullptr;
|
||||
return OpenResult::CannotHandle;
|
||||
@@ -243,7 +246,7 @@ void ImageViewerFile::updateVisibility()
|
||||
if (!m_movie || m_isPaused)
|
||||
return;
|
||||
bool visible = false;
|
||||
foreach (Core::IEditor *editor, Core::DocumentModel::editorsForDocument(this)) {
|
||||
for (Core::IEditor *editor : Core::DocumentModel::editorsForDocument(this)) {
|
||||
if (editor->widget()->isVisible()) {
|
||||
visible = true;
|
||||
break;
|
||||
@@ -265,5 +268,4 @@ void ImageViewerFile::cleanUp()
|
||||
m_type = TypeInvalid;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Internal
|
||||
|
||||
@@ -39,8 +39,7 @@ class QGraphicsSvgItem;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
class ImageViewerFile : public Core::IDocument
|
||||
{
|
||||
@@ -89,5 +88,4 @@ private:
|
||||
bool m_isPaused = false;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Internal
|
||||
|
||||
@@ -25,9 +25,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "imageviewerplugin.h"
|
||||
|
||||
#include "imageviewer.h"
|
||||
#include "imageviewerfactory.h"
|
||||
#include "imageviewerconstants.h"
|
||||
#include "imageviewertr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
@@ -42,8 +43,7 @@
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
class ImageViewerAction final : public QAction
|
||||
{
|
||||
@@ -67,8 +67,6 @@ public:
|
||||
|
||||
class ImageViewerPluginPrivate final
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(Imageviewer::Internal::ImageViewerPlugin)
|
||||
|
||||
public:
|
||||
ImageViewerFactory imageViewerFactory;
|
||||
|
||||
@@ -90,46 +88,46 @@ public:
|
||||
ImageViewerAction fitToScreenAction {
|
||||
Constants::ACTION_FIT_TO_SCREEN,
|
||||
&ImageViewer::fitToScreen,
|
||||
tr("Fit to Screen"),
|
||||
tr("Ctrl+=")
|
||||
Tr::tr("Fit to Screen"),
|
||||
Tr::tr("Ctrl+=")
|
||||
};
|
||||
|
||||
ImageViewerAction switchBackgroundAction {
|
||||
Constants::ACTION_BACKGROUND,
|
||||
&ImageViewer::switchViewBackground,
|
||||
tr("Switch Background"),
|
||||
tr("Ctrl+[")
|
||||
Tr::tr("Switch Background"),
|
||||
Tr::tr("Ctrl+[")
|
||||
};
|
||||
|
||||
ImageViewerAction switchOutlineAction {
|
||||
Constants::ACTION_OUTLINE,
|
||||
&ImageViewer::switchViewOutline,
|
||||
tr("Switch Outline"),
|
||||
tr("Ctrl+]")
|
||||
Tr::tr("Switch Outline"),
|
||||
Tr::tr("Ctrl+]")
|
||||
};
|
||||
|
||||
ImageViewerAction toggleAnimationAction {
|
||||
Constants::ACTION_TOGGLE_ANIMATION,
|
||||
&ImageViewer::togglePlay,
|
||||
tr("Toggle Animation")
|
||||
Tr::tr("Toggle Animation")
|
||||
};
|
||||
|
||||
ImageViewerAction exportImageAction {
|
||||
Constants::ACTION_EXPORT_IMAGE,
|
||||
&ImageViewer::exportImage,
|
||||
tr("Export Image")
|
||||
Tr::tr("Export Image")
|
||||
};
|
||||
|
||||
ImageViewerAction exportMulitImagesAction {
|
||||
Constants::ACTION_EXPORT_MULTI_IMAGES,
|
||||
&ImageViewer::exportMultiImages,
|
||||
tr("Export Multiple Images"),
|
||||
Tr::tr("Export Multiple Images"),
|
||||
};
|
||||
|
||||
ImageViewerAction copyDataUrlAction {
|
||||
Constants::ACTION_COPY_DATA_URL,
|
||||
&ImageViewer::copyDataUrl,
|
||||
tr("Copy as Data URL"),
|
||||
Tr::tr("Copy as Data URL"),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -148,5 +146,4 @@ bool ImageViewerPlugin::initialize(const QStringList &arguments, QString *errorM
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Internal
|
||||
|
||||
@@ -28,8 +28,7 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
class ImageViewerPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
@@ -46,5 +45,4 @@ private:
|
||||
class ImageViewerPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Internal
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "multiexportdialog.h"
|
||||
|
||||
#include "exportdialog.h"
|
||||
#include "imageview.h" // ExportData
|
||||
#include "imageviewertr.h"
|
||||
|
||||
#include <coreplugin/coreicons.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -47,8 +49,7 @@
|
||||
#include <QToolButton>
|
||||
#include <QWidgetAction>
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
static const int standardIconSizesValues[] = {16, 24, 32, 48, 64, 128, 256};
|
||||
|
||||
@@ -180,11 +181,11 @@ MultiExportDialog::MultiExportDialog(QWidget *parent)
|
||||
m_pathChooser->setExpectedKind(Utils::PathChooser::SaveFile);
|
||||
m_pathChooser->setPromptDialogFilter(ExportDialog::imageNameFilterString());
|
||||
const QString pathChooserToolTip =
|
||||
tr("Enter a file name containing place holders %1 "
|
||||
Tr::tr("Enter a file name containing place holders %1 "
|
||||
"which will be replaced by the width and height of the image, respectively.")
|
||||
.arg("%1, %2");
|
||||
m_pathChooser->setToolTip(pathChooserToolTip);
|
||||
QLabel *pathChooserLabel = new QLabel(tr("File:"));
|
||||
QLabel *pathChooserLabel = new QLabel(Tr::tr("File:"));
|
||||
pathChooserLabel->setToolTip(pathChooserToolTip);
|
||||
formLayout->addRow(pathChooserLabel, m_pathChooser);
|
||||
|
||||
@@ -192,18 +193,18 @@ MultiExportDialog::MultiExportDialog(QWidget *parent)
|
||||
sizeEditButton->setFocusPolicy(Qt::NoFocus);
|
||||
sizeEditButton->setIcon(Utils::Icons::ARROW_DOWN.icon());
|
||||
auto sizeEditMenu = new QMenu(this);
|
||||
sizeEditMenu->addAction(tr("Clear"),
|
||||
sizeEditMenu->addAction(Tr::tr("Clear"),
|
||||
m_sizesLineEdit, &QLineEdit::clear);
|
||||
sizeEditMenu->addAction(tr("Set Standard Icon Sizes"), this,
|
||||
sizeEditMenu->addAction(Tr::tr("Set Standard Icon Sizes"), this,
|
||||
&MultiExportDialog::setStandardIconSizes);
|
||||
sizeEditMenu->addAction(tr("Generate Sizes"), this,
|
||||
sizeEditMenu->addAction(Tr::tr("Generate Sizes"), this,
|
||||
&MultiExportDialog::setGeneratedSizes);
|
||||
sizeEditButton->setMenu(sizeEditMenu);
|
||||
sizeEditButton->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
const QString sizesToolTip =
|
||||
tr("A comma-separated list of size specifications of the form \"<width>x<height>\".");
|
||||
auto sizesLabel = new QLabel(tr("Sizes:"));
|
||||
Tr::tr("A comma-separated list of size specifications of the form \"<width>x<height>\".");
|
||||
auto sizesLabel = new QLabel(Tr::tr("Sizes:"));
|
||||
sizesLabel->setToolTip(sizesToolTip);
|
||||
formLayout->addRow(sizesLabel, m_sizesLineEdit);
|
||||
m_sizesLineEdit->setToolTip(sizesToolTip);
|
||||
@@ -279,19 +280,19 @@ void MultiExportDialog::accept()
|
||||
|
||||
const QString &sizeSpec = sizesSpecification();
|
||||
if (sizeSpec.isEmpty()) {
|
||||
QMessageBox::warning(this, windowTitle(), tr("Please specify some sizes."));
|
||||
QMessageBox::warning(this, windowTitle(), Tr::tr("Please specify some sizes."));
|
||||
return;
|
||||
}
|
||||
|
||||
const QVector<ExportData> &data = exportData();
|
||||
if (data.isEmpty()) {
|
||||
QMessageBox::warning(this, windowTitle(),
|
||||
tr("Invalid size specification: %1").arg(sizeSpec));
|
||||
Tr::tr("Invalid size specification: %1").arg(sizeSpec));
|
||||
return;
|
||||
}
|
||||
if (data.size() > 1 && data.at(0).fileName == data.at(1).fileName) {
|
||||
QMessageBox::warning(this, windowTitle(),
|
||||
tr("The file name must contain one of the placeholders %1, %2.")
|
||||
Tr::tr("The file name must contain one of the placeholders %1, %2.")
|
||||
.arg(QString("%1"), QString("%2")));
|
||||
return;
|
||||
}
|
||||
@@ -305,9 +306,9 @@ void MultiExportDialog::accept()
|
||||
}
|
||||
if (!existingFiles.isEmpty()) {
|
||||
const QString message = existingFiles.size() == 1
|
||||
? tr("The file %1 already exists.\nWould you like to overwrite it?")
|
||||
? Tr::tr("The file %1 already exists.\nWould you like to overwrite it?")
|
||||
.arg(QDir::toNativeSeparators(existingFiles.constFirst()))
|
||||
: tr("The files %1 already exist.\nWould you like to overwrite them?")
|
||||
: Tr::tr("The files %1 already exist.\nWould you like to overwrite them?")
|
||||
.arg(QDir::toNativeSeparators(existingFiles.join(", ")));
|
||||
QMessageBox messageBox(QMessageBox::Question, windowTitle(), message,
|
||||
QMessageBox::Yes | QMessageBox::No, this);
|
||||
@@ -331,5 +332,4 @@ void MultiExportDialog::setExportFileName(QString f)
|
||||
m_pathChooser->setFilePath(Utils::FilePath::fromString(f));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer:Internal
|
||||
|
||||
@@ -35,8 +35,7 @@ QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
||||
|
||||
namespace Utils { class PathChooser; }
|
||||
|
||||
namespace ImageViewer {
|
||||
namespace Internal {
|
||||
namespace ImageViewer::Internal {
|
||||
|
||||
struct ExportData;
|
||||
|
||||
@@ -61,12 +60,12 @@ public:
|
||||
QSize svgSize() const { return m_svgSize; }
|
||||
void setSvgSize(const QSize &svgSize) { m_svgSize = svgSize; }
|
||||
|
||||
public slots:
|
||||
void setStandardIconSizes();
|
||||
void setGeneratedSizes();
|
||||
void suggestSizes();
|
||||
|
||||
private:
|
||||
void setStandardIconSizes();
|
||||
void setGeneratedSizes();
|
||||
|
||||
QString sizesSpecification() const;
|
||||
|
||||
Utils::PathChooser *m_pathChooser;
|
||||
@@ -75,5 +74,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ImageViewer
|
||||
} // ImageViewer::Internal
|
||||
|
||||
Reference in New Issue
Block a user