summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@theqtcompany.com>2016-04-14 09:35:39 +0200
committerAlessandro Portale <alessandro.portale@theqtcompany.com>2016-04-15 10:11:58 +0000
commit62fc258ac01dc31caada235568c2e92e21d3208d (patch)
tree79b1483dd892802d466fae1819a0bd84d7215cc2 /src/plugins
parent2b05793083008865a913645e943609f97a16966c (diff)
downloadqt-creator-62fc258ac01dc31caada235568c2e92e21d3208d.tar.gz
ImageViewer: Update toolbar items for split/duplicated editors
The "export" button in a split/duplicated view was enabled for other image formats than svg. The image size label was empty. Fixes for all views (not just the split ones): The play button is now disabled instead of "empty" for non-movies. The size of svgs is displayed. Change-Id: I1f6a2c47f3aa06ed052ba78e5e2d1edd51a0ec69 Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/imageviewer/imageviewer.cpp32
-rw-r--r--src/plugins/imageviewer/imageviewer.h1
-rw-r--r--src/plugins/imageviewer/imageviewerfile.cpp4
3 files changed, 20 insertions, 17 deletions
diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp
index f3121d62d0..f279125f38 100644
--- a/src/plugins/imageviewer/imageviewer.cpp
+++ b/src/plugins/imageviewer/imageviewer.cpp
@@ -151,6 +151,8 @@ void ImageViewer::ctor()
this, &ImageViewer::imageSizeUpdated);
connect(d->file.data(), &ImageViewerFile::openFinished,
d->imageView, &ImageView::createScene);
+ connect(d->file.data(), &ImageViewerFile::openFinished,
+ this, &ImageViewer::updateToolButtons);
connect(d->file.data(), &ImageViewerFile::aboutToReload,
d->imageView, &ImageView::reset);
connect(d->file.data(), &ImageViewerFile::reloadFinished,
@@ -159,12 +161,6 @@ void ImageViewer::ctor()
this, &ImageViewer::updatePauseAction);
connect(d->imageView, &ImageView::scaleFactorChanged,
this, &ImageViewer::scaleFactorUpdate);
-
- connect(d->file.data(), &ImageViewerFile::openFinished,
- this, [this](bool success)
- {
- d->ui_toolbar.toolButtonExportImage->setEnabled(success && d->file->type() == ImageViewerFile::TypeSvg);
- });
}
ImageViewer::~ImageViewer()
@@ -188,6 +184,8 @@ Core::IEditor *ImageViewer::duplicate()
{
auto other = new ImageViewer(d->file);
other->d->imageView->createScene();
+ other->updateToolButtons();
+ other->d->ui_toolbar.labelImageSize->setText(d->ui_toolbar.labelImageSize->text());
return other;
}
@@ -241,6 +239,12 @@ void ImageViewer::fitToScreen()
d->ui_toolbar.toolButtonFitToScreen->click();
}
+void ImageViewer::updateToolButtons()
+{
+ d->ui_toolbar.toolButtonExportImage->setEnabled(d->file->type() == ImageViewerFile::TypeSvg);
+ updatePauseAction();
+}
+
void ImageViewer::togglePlay()
{
d->ui_toolbar.toolButtonPlayPause->click();
@@ -254,15 +258,13 @@ void ImageViewer::playToggled()
void ImageViewer::updatePauseAction()
{
bool isMovie = d->file->type() == ImageViewerFile::TypeMovie;
- d->ui_toolbar.toolButtonPlayPause->setVisible(isMovie);
- if (isMovie) {
- if (d->file->isPaused()) {
- d->ui_toolbar.toolButtonPlayPause->setToolTipBase(tr("Play Animation"));
- d->ui_toolbar.toolButtonPlayPause->setIcon(Core::Icons::RUN_SMALL.pixmap());
- } else {
- d->ui_toolbar.toolButtonPlayPause->setToolTipBase(tr("Pause Animation"));
- d->ui_toolbar.toolButtonPlayPause->setIcon(Core::Icons::INTERRUPT_SMALL.pixmap());
- }
+ if (isMovie && !d->file->isPaused()) {
+ d->ui_toolbar.toolButtonPlayPause->setToolTipBase(tr("Pause Animation"));
+ d->ui_toolbar.toolButtonPlayPause->setIcon(Core::Icons::INTERRUPT_SMALL.icon());
+ } else {
+ d->ui_toolbar.toolButtonPlayPause->setToolTipBase(tr("Play Animation"));
+ d->ui_toolbar.toolButtonPlayPause->setIcon(Core::Icons::RUN_SMALL.icon());
+ d->ui_toolbar.toolButtonPlayPause->setEnabled(isMovie);
}
}
diff --git a/src/plugins/imageviewer/imageviewer.h b/src/plugins/imageviewer/imageviewer.h
index 5d65c6760a..d2bbb32541 100644
--- a/src/plugins/imageviewer/imageviewer.h
+++ b/src/plugins/imageviewer/imageviewer.h
@@ -66,6 +66,7 @@ public slots:
void zoomOut();
void resetToOriginalSize();
void fitToScreen();
+ void updateToolButtons();
void togglePlay();
private slots:
diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp
index f5192db521..031ca999d4 100644
--- a/src/plugins/imageviewer/imageviewerfile.cpp
+++ b/src/plugins/imageviewer/imageviewerfile.cpp
@@ -108,7 +108,7 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString, cons
if (format.startsWith("svg")) {
m_tempSvgItem = new QGraphicsSvgItem(fileName);
QRectF bound = m_tempSvgItem->boundingRect();
- if (bound.width() == 0 && bound.height() == 0) {
+ if (qFuzzyIsNull(bound.width()) && qFuzzyIsNull(bound.height())) {
delete m_tempSvgItem;
m_tempSvgItem = 0;
if (errorString)
@@ -116,7 +116,7 @@ Core::IDocument::OpenResult ImageViewerFile::openImpl(QString *errorString, cons
return OpenResult::CannotHandle;
}
m_type = TypeSvg;
- emit imageSizeChanged(QSize());
+ emit imageSizeChanged(m_tempSvgItem->boundingRect().size().toSize());
} else
#endif
if (QMovie::supportedFormats().contains(format)) {