forked from qt-creator/qt-creator
ImageViewer: adjust to style guide
Change-Id: Id0f5a521199b9dc5b29fc3cb7b7bd82521bc00e6 Reviewed-on: http://codereview.qt.nokia.com/4130 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -71,7 +71,7 @@ struct ImageViewPrivate
|
|||||||
|
|
||||||
ImageView::ImageView(QWidget *parent)
|
ImageView::ImageView(QWidget *parent)
|
||||||
: QGraphicsView(parent),
|
: QGraphicsView(parent),
|
||||||
d_ptr(new ImageViewPrivate())
|
d(new ImageViewPrivate())
|
||||||
{
|
{
|
||||||
setScene(new QGraphicsScene(this));
|
setScene(new QGraphicsScene(this));
|
||||||
setTransformationAnchor(AnchorUnderMouse);
|
setTransformationAnchor(AnchorUnderMouse);
|
||||||
@@ -123,8 +123,8 @@ bool ImageView::openFile(QString fileName)
|
|||||||
|
|
||||||
QGraphicsScene *s = scene();
|
QGraphicsScene *s = scene();
|
||||||
|
|
||||||
bool drawBackground = (d_ptr->backgroundItem ? d_ptr->backgroundItem->isVisible() : false);
|
bool drawBackground = (d->backgroundItem ? d->backgroundItem->isVisible() : false);
|
||||||
bool drawOutline = (d_ptr->outlineItem ? d_ptr->outlineItem->isVisible() : true);
|
bool drawOutline = (d->outlineItem ? d->outlineItem->isVisible() : true);
|
||||||
|
|
||||||
s->clear();
|
s->clear();
|
||||||
resetTransform();
|
resetTransform();
|
||||||
@@ -132,40 +132,40 @@ bool ImageView::openFile(QString fileName)
|
|||||||
// image
|
// image
|
||||||
#ifndef QT_NO_SVG
|
#ifndef QT_NO_SVG
|
||||||
if (isSvg) {
|
if (isSvg) {
|
||||||
d_ptr->imageItem = new QGraphicsSvgItem(fileName);
|
d->imageItem = new QGraphicsSvgItem(fileName);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
QPixmap pixmap(fileName);
|
QPixmap pixmap(fileName);
|
||||||
QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap);
|
QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap);
|
||||||
pixmapItem->setTransformationMode(Qt::SmoothTransformation);
|
pixmapItem->setTransformationMode(Qt::SmoothTransformation);
|
||||||
d_ptr->imageItem = pixmapItem;
|
d->imageItem = pixmapItem;
|
||||||
}
|
}
|
||||||
d_ptr->imageItem->setCacheMode(QGraphicsItem::NoCache);
|
d->imageItem->setCacheMode(QGraphicsItem::NoCache);
|
||||||
d_ptr->imageItem->setZValue(0);
|
d->imageItem->setZValue(0);
|
||||||
|
|
||||||
// background item
|
// background item
|
||||||
d_ptr->backgroundItem = new QGraphicsRectItem(d_ptr->imageItem->boundingRect());
|
d->backgroundItem = new QGraphicsRectItem(d->imageItem->boundingRect());
|
||||||
d_ptr->backgroundItem->setBrush(Qt::white);
|
d->backgroundItem->setBrush(Qt::white);
|
||||||
d_ptr->backgroundItem->setPen(Qt::NoPen);
|
d->backgroundItem->setPen(Qt::NoPen);
|
||||||
d_ptr->backgroundItem->setVisible(drawBackground);
|
d->backgroundItem->setVisible(drawBackground);
|
||||||
d_ptr->backgroundItem->setZValue(-1);
|
d->backgroundItem->setZValue(-1);
|
||||||
|
|
||||||
// outline
|
// outline
|
||||||
d_ptr->outlineItem = new QGraphicsRectItem(d_ptr->imageItem->boundingRect());
|
d->outlineItem = new QGraphicsRectItem(d->imageItem->boundingRect());
|
||||||
QPen outline(Qt::black, 1, Qt::DashLine);
|
QPen outline(Qt::black, 1, Qt::DashLine);
|
||||||
outline.setCosmetic(true);
|
outline.setCosmetic(true);
|
||||||
d_ptr->outlineItem->setPen(outline);
|
d->outlineItem->setPen(outline);
|
||||||
d_ptr->outlineItem->setBrush(Qt::NoBrush);
|
d->outlineItem->setBrush(Qt::NoBrush);
|
||||||
d_ptr->outlineItem->setVisible(drawOutline);
|
d->outlineItem->setVisible(drawOutline);
|
||||||
d_ptr->outlineItem->setZValue(1);
|
d->outlineItem->setZValue(1);
|
||||||
|
|
||||||
s->addItem(d_ptr->backgroundItem);
|
s->addItem(d->backgroundItem);
|
||||||
s->addItem(d_ptr->imageItem);
|
s->addItem(d->imageItem);
|
||||||
s->addItem(d_ptr->outlineItem);
|
s->addItem(d->outlineItem);
|
||||||
|
|
||||||
// if image size is 0x0, then it is not loaded
|
// if image size is 0x0, then it is not loaded
|
||||||
if (d_ptr->imageItem->boundingRect().height() == 0 && d_ptr->imageItem->boundingRect().width() == 0)
|
if (d->imageItem->boundingRect().height() == 0 && d->imageItem->boundingRect().width() == 0)
|
||||||
return false;
|
return false;
|
||||||
emitScaleFactor();
|
emitScaleFactor();
|
||||||
|
|
||||||
@@ -174,18 +174,18 @@ bool ImageView::openFile(QString fileName)
|
|||||||
|
|
||||||
void ImageView::setViewBackground(bool enable)
|
void ImageView::setViewBackground(bool enable)
|
||||||
{
|
{
|
||||||
if (!d_ptr->backgroundItem)
|
if (!d->backgroundItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d_ptr->backgroundItem->setVisible(enable);
|
d->backgroundItem->setVisible(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageView::setViewOutline(bool enable)
|
void ImageView::setViewOutline(bool enable)
|
||||||
{
|
{
|
||||||
if (!d_ptr->outlineItem)
|
if (!d->outlineItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d_ptr->outlineItem->setVisible(enable);
|
d->outlineItem->setVisible(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageView::doScale(qreal factor)
|
void ImageView::doScale(qreal factor)
|
||||||
@@ -219,7 +219,7 @@ void ImageView::resetToOriginalSize()
|
|||||||
|
|
||||||
void ImageView::fitToScreen()
|
void ImageView::fitToScreen()
|
||||||
{
|
{
|
||||||
fitInView(d_ptr->imageItem, Qt::KeepAspectRatio);
|
fitInView(d->imageItem, Qt::KeepAspectRatio);
|
||||||
emitScaleFactor();
|
emitScaleFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ protected:
|
|||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<struct ImageViewPrivate> d_ptr;
|
QScopedPointer<struct ImageViewPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -63,52 +63,52 @@ struct ImageViewerPrivate
|
|||||||
|
|
||||||
ImageViewer::ImageViewer(QWidget *parent)
|
ImageViewer::ImageViewer(QWidget *parent)
|
||||||
: IEditor(parent),
|
: IEditor(parent),
|
||||||
d_ptr(new ImageViewerPrivate)
|
d(new ImageViewerPrivate)
|
||||||
{
|
{
|
||||||
d_ptr->file = new ImageViewerFile(this);
|
d->file = new ImageViewerFile(this);
|
||||||
d_ptr->imageView = new ImageView();
|
d->imageView = new ImageView();
|
||||||
|
|
||||||
setContext(Core::Context(Constants::IMAGEVIEWER_ID));
|
setContext(Core::Context(Constants::IMAGEVIEWER_ID));
|
||||||
setWidget(d_ptr->imageView);
|
setWidget(d->imageView);
|
||||||
|
|
||||||
// toolbar
|
// toolbar
|
||||||
d_ptr->toolbar = new QWidget();
|
d->toolbar = new QWidget();
|
||||||
d_ptr->ui_toolbar.setupUi(d_ptr->toolbar);
|
d->ui_toolbar.setupUi(d->toolbar);
|
||||||
|
|
||||||
// icons update - try to use system theme
|
// icons update - try to use system theme
|
||||||
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonZoomIn, "zoom-in");
|
updateButtonIconByTheme(d->ui_toolbar.toolButtonZoomIn, "zoom-in");
|
||||||
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonZoomOut, "zoom-out");
|
updateButtonIconByTheme(d->ui_toolbar.toolButtonZoomOut, "zoom-out");
|
||||||
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonOriginalSize, "zoom-original");
|
updateButtonIconByTheme(d->ui_toolbar.toolButtonOriginalSize, "zoom-original");
|
||||||
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonFitToScreen, "zoom-fit-best");
|
updateButtonIconByTheme(d->ui_toolbar.toolButtonFitToScreen, "zoom-fit-best");
|
||||||
// a display - something is on the background
|
// a display - something is on the background
|
||||||
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonBackground, "video-display");
|
updateButtonIconByTheme(d->ui_toolbar.toolButtonBackground, "video-display");
|
||||||
// "emblem to specify the directory where the user stores photographs"
|
// "emblem to specify the directory where the user stores photographs"
|
||||||
// (photograph has outline - piece of paper)
|
// (photograph has outline - piece of paper)
|
||||||
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonOutline, "emblem-photos");
|
updateButtonIconByTheme(d->ui_toolbar.toolButtonOutline, "emblem-photos");
|
||||||
|
|
||||||
// connections
|
// connections
|
||||||
connect(d_ptr->file, SIGNAL(changed()), this, SIGNAL(changed()));
|
connect(d->file, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||||
|
|
||||||
connect(d_ptr->ui_toolbar.toolButtonZoomIn, SIGNAL(clicked()),
|
connect(d->ui_toolbar.toolButtonZoomIn, SIGNAL(clicked()),
|
||||||
d_ptr->imageView, SLOT(zoomIn()));
|
d->imageView, SLOT(zoomIn()));
|
||||||
connect(d_ptr->ui_toolbar.toolButtonZoomOut, SIGNAL(clicked()),
|
connect(d->ui_toolbar.toolButtonZoomOut, SIGNAL(clicked()),
|
||||||
d_ptr->imageView, SLOT(zoomOut()));
|
d->imageView, SLOT(zoomOut()));
|
||||||
connect(d_ptr->ui_toolbar.toolButtonFitToScreen, SIGNAL(clicked()),
|
connect(d->ui_toolbar.toolButtonFitToScreen, SIGNAL(clicked()),
|
||||||
d_ptr->imageView, SLOT(fitToScreen()));
|
d->imageView, SLOT(fitToScreen()));
|
||||||
connect(d_ptr->ui_toolbar.toolButtonOriginalSize, SIGNAL(clicked()),
|
connect(d->ui_toolbar.toolButtonOriginalSize, SIGNAL(clicked()),
|
||||||
d_ptr->imageView, SLOT(resetToOriginalSize()));
|
d->imageView, SLOT(resetToOriginalSize()));
|
||||||
connect(d_ptr->ui_toolbar.toolButtonBackground, SIGNAL(toggled(bool)),
|
connect(d->ui_toolbar.toolButtonBackground, SIGNAL(toggled(bool)),
|
||||||
d_ptr->imageView, SLOT(setViewBackground(bool)));
|
d->imageView, SLOT(setViewBackground(bool)));
|
||||||
connect(d_ptr->ui_toolbar.toolButtonOutline, SIGNAL(toggled(bool)),
|
connect(d->ui_toolbar.toolButtonOutline, SIGNAL(toggled(bool)),
|
||||||
d_ptr->imageView, SLOT(setViewOutline(bool)));
|
d->imageView, SLOT(setViewOutline(bool)));
|
||||||
connect(d_ptr->imageView, SIGNAL(scaleFactorChanged(qreal)),
|
connect(d->imageView, SIGNAL(scaleFactorChanged(qreal)),
|
||||||
this, SLOT(scaleFactorUpdate(qreal)));
|
this, SLOT(scaleFactorUpdate(qreal)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageViewer::~ImageViewer()
|
ImageViewer::~ImageViewer()
|
||||||
{
|
{
|
||||||
delete d_ptr->imageView;
|
delete d->imageView;
|
||||||
delete d_ptr->toolbar;
|
delete d->toolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageViewer::createNew(const QString &contents)
|
bool ImageViewer::createNew(const QString &contents)
|
||||||
@@ -119,12 +119,12 @@ bool ImageViewer::createNew(const QString &contents)
|
|||||||
|
|
||||||
bool ImageViewer::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
bool ImageViewer::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||||
{
|
{
|
||||||
if (!d_ptr->imageView->openFile(realFileName)) {
|
if (!d->imageView->openFile(realFileName)) {
|
||||||
*errorString = tr("Cannot open image file %1").arg(QDir::toNativeSeparators(realFileName));
|
*errorString = tr("Cannot open image file %1").arg(QDir::toNativeSeparators(realFileName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setDisplayName(QFileInfo(fileName).fileName());
|
setDisplayName(QFileInfo(fileName).fileName());
|
||||||
d_ptr->file->setFileName(fileName);
|
d->file->setFileName(fileName);
|
||||||
// d_ptr->file->setMimeType
|
// d_ptr->file->setMimeType
|
||||||
emit changed();
|
emit changed();
|
||||||
return true;
|
return true;
|
||||||
@@ -132,7 +132,7 @@ bool ImageViewer::open(QString *errorString, const QString &fileName, const QStr
|
|||||||
|
|
||||||
Core::IFile *ImageViewer::file()
|
Core::IFile *ImageViewer::file()
|
||||||
{
|
{
|
||||||
return d_ptr->file;
|
return d->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ImageViewer::id() const
|
QString ImageViewer::id() const
|
||||||
@@ -142,12 +142,12 @@ QString ImageViewer::id() const
|
|||||||
|
|
||||||
QString ImageViewer::displayName() const
|
QString ImageViewer::displayName() const
|
||||||
{
|
{
|
||||||
return d_ptr->displayName;
|
return d->displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::setDisplayName(const QString &title)
|
void ImageViewer::setDisplayName(const QString &title)
|
||||||
{
|
{
|
||||||
d_ptr->displayName = title;
|
d->displayName = title;
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,13 +190,13 @@ bool ImageViewer::isTemporary() const
|
|||||||
|
|
||||||
QWidget *ImageViewer::toolBar()
|
QWidget *ImageViewer::toolBar()
|
||||||
{
|
{
|
||||||
return d_ptr->toolbar;
|
return d->toolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::scaleFactorUpdate(qreal factor)
|
void ImageViewer::scaleFactorUpdate(qreal factor)
|
||||||
{
|
{
|
||||||
const QString info = QString::number(factor * 100, 'f', 2) + QLatin1Char('%');
|
const QString info = QString::number(factor * 100, 'f', 2) + QLatin1Char('%');
|
||||||
d_ptr->ui_toolbar.labelInfo->setText(info);
|
d->ui_toolbar.labelInfo->setText(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageViewer::updateButtonIconByTheme(QAbstractButton *button, const QString &name)
|
bool ImageViewer::updateButtonIconByTheme(QAbstractButton *button, const QString &name)
|
||||||
@@ -214,32 +214,32 @@ bool ImageViewer::updateButtonIconByTheme(QAbstractButton *button, const QString
|
|||||||
|
|
||||||
void ImageViewer::switchViewBackground()
|
void ImageViewer::switchViewBackground()
|
||||||
{
|
{
|
||||||
d_ptr->ui_toolbar.toolButtonBackground->click();
|
d->ui_toolbar.toolButtonBackground->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::switchViewOutline()
|
void ImageViewer::switchViewOutline()
|
||||||
{
|
{
|
||||||
d_ptr->ui_toolbar.toolButtonOutline->click();
|
d->ui_toolbar.toolButtonOutline->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::zoomIn()
|
void ImageViewer::zoomIn()
|
||||||
{
|
{
|
||||||
d_ptr->ui_toolbar.toolButtonZoomIn->click();
|
d->ui_toolbar.toolButtonZoomIn->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::zoomOut()
|
void ImageViewer::zoomOut()
|
||||||
{
|
{
|
||||||
d_ptr->ui_toolbar.toolButtonZoomOut->click();
|
d->ui_toolbar.toolButtonZoomOut->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::resetToOriginalSize()
|
void ImageViewer::resetToOriginalSize()
|
||||||
{
|
{
|
||||||
d_ptr->ui_toolbar.toolButtonOriginalSize->click();
|
d->ui_toolbar.toolButtonOriginalSize->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageViewer::fitToScreen()
|
void ImageViewer::fitToScreen()
|
||||||
{
|
{
|
||||||
d_ptr->ui_toolbar.toolButtonFitToScreen->click();
|
d->ui_toolbar.toolButtonFitToScreen->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -40,8 +40,10 @@
|
|||||||
#include <QtCore/QScopedPointer>
|
#include <QtCore/QScopedPointer>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QAbstractButton)
|
QT_BEGIN_NAMESPACE
|
||||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
class QAbstractButton;
|
||||||
|
class QAction;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ImageViewer {
|
namespace ImageViewer {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -95,7 +97,7 @@ private:
|
|||||||
bool updateButtonIconByTheme(QAbstractButton *button, const QString &name);
|
bool updateButtonIconByTheme(QAbstractButton *button, const QString &name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<struct ImageViewerPrivate> d_ptr;
|
QScopedPointer<struct ImageViewerPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -70,10 +70,10 @@ struct ImageViewerActionHandlerPrivate
|
|||||||
|
|
||||||
ImageViewerActionHandler::ImageViewerActionHandler(QObject *parent) :
|
ImageViewerActionHandler::ImageViewerActionHandler(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
d_ptr(new ImageViewerActionHandlerPrivate)
|
d(new ImageViewerActionHandlerPrivate)
|
||||||
{
|
{
|
||||||
d_ptr->signalMapper = new QSignalMapper(this);
|
d->signalMapper = new QSignalMapper(this);
|
||||||
connect(d_ptr->signalMapper, SIGNAL(mapped(int)), SLOT(actionTriggered(int)));
|
connect(d->signalMapper, SIGNAL(mapped(int)), SLOT(actionTriggered(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageViewerActionHandler::~ImageViewerActionHandler()
|
ImageViewerActionHandler::~ImageViewerActionHandler()
|
||||||
@@ -116,17 +116,17 @@ void ImageViewerActionHandler::actionTriggered(int supportedAction)
|
|||||||
void ImageViewerActionHandler::createActions()
|
void ImageViewerActionHandler::createActions()
|
||||||
{
|
{
|
||||||
registerNewAction(ZoomIn, Constants::ACTION_ZOOM_IN, tr("Zoom In"),
|
registerNewAction(ZoomIn, Constants::ACTION_ZOOM_IN, tr("Zoom In"),
|
||||||
d_ptr->context, QKeySequence(tr("Ctrl++")));
|
d->context, QKeySequence(tr("Ctrl++")));
|
||||||
registerNewAction(ZoomOut, Constants::ACTION_ZOOM_OUT, tr("Zoom Out"),
|
registerNewAction(ZoomOut, Constants::ACTION_ZOOM_OUT, tr("Zoom Out"),
|
||||||
d_ptr->context, QKeySequence(tr("Ctrl+-")));
|
d->context, QKeySequence(tr("Ctrl+-")));
|
||||||
registerNewAction(OriginalSize, Constants::ACTION_ORIGINAL_SIZE, tr("Original Size"),
|
registerNewAction(OriginalSize, Constants::ACTION_ORIGINAL_SIZE, tr("Original Size"),
|
||||||
d_ptr->context, QKeySequence(tr("Ctrl+0")));
|
d->context, QKeySequence(tr("Ctrl+0")));
|
||||||
registerNewAction(FitToScreen, Constants::ACTION_FIT_TO_SCREEN, tr("Fit To Screen"),
|
registerNewAction(FitToScreen, Constants::ACTION_FIT_TO_SCREEN, tr("Fit To Screen"),
|
||||||
d_ptr->context, QKeySequence(tr("Ctrl+=")));
|
d->context, QKeySequence(tr("Ctrl+=")));
|
||||||
registerNewAction(Background, Constants::ACTION_BACKGROUND, tr("Switch Background"),
|
registerNewAction(Background, Constants::ACTION_BACKGROUND, tr("Switch Background"),
|
||||||
d_ptr->context, QKeySequence(tr("Ctrl+[")));
|
d->context, QKeySequence(tr("Ctrl+[")));
|
||||||
registerNewAction(Outline, Constants::ACTION_OUTLINE, tr("Switch Outline"),
|
registerNewAction(Outline, Constants::ACTION_OUTLINE, tr("Switch Outline"),
|
||||||
d_ptr->context, QKeySequence(tr("Ctrl+]")));
|
d->context, QKeySequence(tr("Ctrl+]")));
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *ImageViewerActionHandler::registerNewAction(int actionId, const QString &id,
|
QAction *ImageViewerActionHandler::registerNewAction(int actionId, const QString &id,
|
||||||
@@ -139,8 +139,8 @@ QAction *ImageViewerActionHandler::registerNewAction(int actionId, const QString
|
|||||||
command = actionManager->registerAction(action, id, context);
|
command = actionManager->registerAction(action, id, context);
|
||||||
if (command)
|
if (command)
|
||||||
command->setDefaultKeySequence(key);
|
command->setDefaultKeySequence(key);
|
||||||
connect(action, SIGNAL(triggered()), d_ptr->signalMapper, SLOT(map()));
|
connect(action, SIGNAL(triggered()), d->signalMapper, SLOT(map()));
|
||||||
d_ptr->signalMapper->setMapping(action, actionId);
|
d->signalMapper->setMapping(action, actionId);
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,14 +50,13 @@ namespace Internal {
|
|||||||
class ImageViewerActionHandler : public QObject
|
class ImageViewerActionHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ImageViewerActionHandler(QObject *parent = 0);
|
explicit ImageViewerActionHandler(QObject *parent = 0);
|
||||||
~ImageViewerActionHandler();
|
~ImageViewerActionHandler();
|
||||||
|
|
||||||
void createActions();
|
void createActions();
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void actionTriggered(int supportedAction);
|
void actionTriggered(int supportedAction);
|
||||||
|
|
||||||
@@ -75,11 +74,10 @@ protected:
|
|||||||
const Core::Context &context, const QKeySequence &key);
|
const Core::Context &context, const QKeySequence &key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<struct ImageViewerActionHandlerPrivate> d_ptr;
|
QScopedPointer<struct ImageViewerActionHandlerPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ImageViewer
|
} // namespace ImageViewer
|
||||||
|
|
||||||
|
|
||||||
#endif // IMAGEVIEWERACTIONHANDLER_H
|
#endif // IMAGEVIEWERACTIONHANDLER_H
|
||||||
|
|||||||
@@ -37,16 +37,15 @@
|
|||||||
namespace ImageViewer {
|
namespace ImageViewer {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
const char * const IMAGEVIEWER_ID = "Editors.ImageViewer";
|
const char IMAGEVIEWER_ID[] = "Editors.ImageViewer";
|
||||||
const char * const IMAGEVIEWER_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors", "Image Viewer");
|
const char IMAGEVIEWER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Image Viewer");
|
||||||
|
|
||||||
// actions
|
const char ACTION_ZOOM_IN[] = "ImageViewer.ZoomIn";
|
||||||
const char * const ACTION_ZOOM_IN = "ImageViewer.ZoomIn";
|
const char ACTION_ZOOM_OUT[] = "ImageViewer.ZoomOut";
|
||||||
const char * const ACTION_ZOOM_OUT = "ImageViewer.ZoomOut";
|
const char ACTION_ORIGINAL_SIZE[] = "ImageViewer.OriginalSize";
|
||||||
const char * const ACTION_ORIGINAL_SIZE = "ImageViewer.OriginalSize";
|
const char ACTION_FIT_TO_SCREEN[] = "ImageViewer.FitToScreen";
|
||||||
const char * const ACTION_FIT_TO_SCREEN = "ImageViewer.FitToScreen";
|
const char ACTION_BACKGROUND[] = "ImageViewer.Background";
|
||||||
const char * const ACTION_BACKGROUND = "ImageViewer.Background";
|
const char ACTION_OUTLINE[] = "ImageViewer.Outline";
|
||||||
const char * const ACTION_OUTLINE = "ImageViewer.Outline";
|
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace ImageViewer
|
} // namespace ImageViewer
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ struct ImageViewerFactoryPrivate
|
|||||||
|
|
||||||
ImageViewerFactory::ImageViewerFactory(QObject *parent) :
|
ImageViewerFactory::ImageViewerFactory(QObject *parent) :
|
||||||
Core::IEditorFactory(parent),
|
Core::IEditorFactory(parent),
|
||||||
d_ptr(new ImageViewerFactoryPrivate)
|
d(new ImageViewerFactoryPrivate)
|
||||||
{
|
{
|
||||||
d_ptr->actionHandler = new ImageViewerActionHandler(this);
|
d->actionHandler = new ImageViewerActionHandler(this);
|
||||||
|
|
||||||
QMap<QByteArray, QString> possibleMimeTypes;
|
QMap<QByteArray, QString> possibleMimeTypes;
|
||||||
possibleMimeTypes.insert("bmp", QLatin1String("image/bmp"));
|
possibleMimeTypes.insert("bmp", QLatin1String("image/bmp"));
|
||||||
@@ -76,7 +76,7 @@ ImageViewerFactory::ImageViewerFactory(QObject *parent) :
|
|||||||
foreach (const QByteArray &format, supportedFormats) {
|
foreach (const QByteArray &format, supportedFormats) {
|
||||||
const QString &value = possibleMimeTypes.value(format);
|
const QString &value = possibleMimeTypes.value(format);
|
||||||
if (!value.isEmpty())
|
if (!value.isEmpty())
|
||||||
d_ptr->mimeTypes.append(value);
|
d->mimeTypes.append(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ Core::IEditor *ImageViewerFactory::createEditor(QWidget *parent)
|
|||||||
|
|
||||||
QStringList ImageViewerFactory::mimeTypes() const
|
QStringList ImageViewerFactory::mimeTypes() const
|
||||||
{
|
{
|
||||||
return d_ptr->mimeTypes;
|
return d->mimeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ImageViewerFactory::id() const
|
QString ImageViewerFactory::id() const
|
||||||
@@ -111,7 +111,7 @@ Core::IFile *ImageViewerFactory::open(const QString & /*fileName*/)
|
|||||||
|
|
||||||
void ImageViewerFactory::extensionsInitialized()
|
void ImageViewerFactory::extensionsInitialized()
|
||||||
{
|
{
|
||||||
d_ptr->actionHandler->createActions();
|
d->actionHandler->createActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<struct ImageViewerFactoryPrivate> d_ptr;
|
QScopedPointer<struct ImageViewerFactoryPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user