diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-01-31 12:41:04 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-02-05 10:42:25 +0000 |
commit | e1d2d35c20163083266e2e450ef54bfb15d2b47d (patch) | |
tree | 626c4c17f8dd1868ff01244b2475d94d6d29f937 /src/plugins/imageviewer | |
parent | d110b2f4db5bd817a5905924dcac0caf7b9cae4c (diff) |
Unify zooming actions of image viewer and model editor
Change-Id: I5761ab579beda5b2cd0b725869ed216cb97e900c
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins/imageviewer')
-rw-r--r-- | src/plugins/imageviewer/imageviewer.cpp | 19 | ||||
-rw-r--r-- | src/plugins/imageviewer/imageviewerconstants.h | 3 | ||||
-rw-r--r-- | src/plugins/imageviewer/imageviewerplugin.cpp | 13 | ||||
-rw-r--r-- | src/plugins/imageviewer/imageviewerplugin.h | 5 |
4 files changed, 19 insertions, 21 deletions
diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp index b891524d1c7..e1ce2a9f553 100644 --- a/src/plugins/imageviewer/imageviewer.cpp +++ b/src/plugins/imageviewer/imageviewer.cpp @@ -33,6 +33,7 @@ #include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> +#include <coreplugin/coreconstants.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> #include <utils/utilsicons.h> @@ -107,14 +108,14 @@ void ImageViewer::ctor() {QLatin1String(":/utils/images/desktopdevicesmall.png"), Utils::Theme::IconsBaseColor}}); d->ui_toolbar.toolButtonBackground->setIcon(backgroundIcon.icon()); d->ui_toolbar.toolButtonOutline->setIcon(Utils::Icons::BOUNDING_RECT.icon()); - d->ui_toolbar.toolButtonZoomIn->setIcon(Utils::Icons::ZOOMIN_TOOLBAR.icon()); - d->ui_toolbar.toolButtonZoomOut->setIcon(Utils::Icons::ZOOMOUT_TOOLBAR.icon()); + d->ui_toolbar.toolButtonZoomIn->setIcon( + Core::ActionManager::command(Core::Constants::ZOOM_IN)->action()->icon()); + d->ui_toolbar.toolButtonZoomOut->setIcon( + Core::ActionManager::command(Core::Constants::ZOOM_OUT)->action()->icon()); + d->ui_toolbar.toolButtonOriginalSize->setIcon( + Core::ActionManager::command(Core::Constants::ZOOM_RESET)->action()->icon()); d->ui_toolbar.toolButtonFitToScreen->setIcon(Utils::Icons::FITTOVIEW_TOOLBAR.icon()); - d->ui_toolbar.toolButtonOriginalSize->setIcon(Utils::Icons::EYE_OPEN_TOOLBAR.icon()); // icons update - try to use system theme - updateButtonIconByTheme(d->ui_toolbar.toolButtonZoomIn, QLatin1String("zoom-in")); - updateButtonIconByTheme(d->ui_toolbar.toolButtonZoomOut, QLatin1String("zoom-out")); - updateButtonIconByTheme(d->ui_toolbar.toolButtonOriginalSize, QLatin1String("zoom-original")); updateButtonIconByTheme(d->ui_toolbar.toolButtonFitToScreen, QLatin1String("zoom-fit-best")); // a display - something is on the background updateButtonIconByTheme(d->ui_toolbar.toolButtonBackground, QLatin1String("video-display")); @@ -123,9 +124,9 @@ void ImageViewer::ctor() updateButtonIconByTheme(d->ui_toolbar.toolButtonOutline, QLatin1String("emblem-photos")); d->ui_toolbar.toolButtonExportImage->setCommandId(Constants::ACTION_EXPORT_IMAGE); - d->ui_toolbar.toolButtonZoomIn->setCommandId(Constants::ACTION_ZOOM_IN); - d->ui_toolbar.toolButtonZoomOut->setCommandId(Constants::ACTION_ZOOM_OUT); - d->ui_toolbar.toolButtonOriginalSize->setCommandId(Constants::ACTION_ORIGINAL_SIZE); + d->ui_toolbar.toolButtonZoomIn->setCommandId(Core::Constants::ZOOM_IN); + d->ui_toolbar.toolButtonZoomOut->setCommandId(Core::Constants::ZOOM_OUT); + d->ui_toolbar.toolButtonOriginalSize->setCommandId(Core::Constants::ZOOM_RESET); d->ui_toolbar.toolButtonFitToScreen->setCommandId(Constants::ACTION_FIT_TO_SCREEN); d->ui_toolbar.toolButtonBackground->setCommandId(Constants::ACTION_BACKGROUND); d->ui_toolbar.toolButtonOutline->setCommandId(Constants::ACTION_OUTLINE); diff --git a/src/plugins/imageviewer/imageviewerconstants.h b/src/plugins/imageviewer/imageviewerconstants.h index 496d3a8d6a9..1fac9a69067 100644 --- a/src/plugins/imageviewer/imageviewerconstants.h +++ b/src/plugins/imageviewer/imageviewerconstants.h @@ -33,9 +33,6 @@ 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_ZOOM_IN[] = "ImageViewer.ZoomIn"; -const char ACTION_ZOOM_OUT[] = "ImageViewer.ZoomOut"; -const char ACTION_ORIGINAL_SIZE[] = "ImageViewer.OriginalSize"; const char ACTION_FIT_TO_SCREEN[] = "ImageViewer.FitToScreen"; const char ACTION_BACKGROUND[] = "ImageViewer.Background"; const char ACTION_OUTLINE[] = "ImageViewer.Outline"; diff --git a/src/plugins/imageviewer/imageviewerplugin.cpp b/src/plugins/imageviewer/imageviewerplugin.cpp index 6a453eb90e2..dbed73f0825 100644 --- a/src/plugins/imageviewer/imageviewerplugin.cpp +++ b/src/plugins/imageviewer/imageviewerplugin.cpp @@ -36,6 +36,7 @@ #include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> +#include <coreplugin/coreconstants.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/id.h> #include <extensionsystem/pluginmanager.h> @@ -62,22 +63,19 @@ static inline ImageViewer *currentImageViewer() void ImageViewerPlugin::extensionsInitialized() { - QAction *a = registerNewAction(Constants::ACTION_ZOOM_IN, tr("Zoom In"), - QKeySequence(tr("Ctrl++"))); + QAction *a = registerNewAction(Core::Constants::ZOOM_IN); connect(a, &QAction::triggered, this, []() { if (ImageViewer *iv = currentImageViewer()) iv->zoomIn(); }); - a = registerNewAction(Constants::ACTION_ZOOM_OUT, tr("Zoom Out"), - QKeySequence(tr("Ctrl+-"))); + a = registerNewAction(Core::Constants::ZOOM_OUT); connect(a, &QAction::triggered, this, []() { if (ImageViewer *iv = currentImageViewer()) iv->zoomOut(); }); - a = registerNewAction(Constants::ACTION_ORIGINAL_SIZE, tr("Original Size"), - QKeySequence(Core::UseMacShortcuts ? tr("Meta+0") : tr("Ctrl+0"))); + a = registerNewAction(Core::Constants::ZOOM_RESET); connect(a, &QAction::triggered, this, []() { if (ImageViewer *iv = currentImageViewer()) iv->resetToOriginalSize(); @@ -125,7 +123,8 @@ QAction *ImageViewerPlugin::registerNewAction(Core::Id id, Core::Context context(Constants::IMAGEVIEWER_ID); QAction *action = new QAction(title, this); Core::Command *command = Core::ActionManager::registerAction(action, id, context); - command->setDefaultKeySequence(key); + if (!key.isEmpty()) + command->setDefaultKeySequence(key); return action; } diff --git a/src/plugins/imageviewer/imageviewerplugin.h b/src/plugins/imageviewer/imageviewerplugin.h index 83868edc118..88d671a3e9d 100644 --- a/src/plugins/imageviewer/imageviewerplugin.h +++ b/src/plugins/imageviewer/imageviewerplugin.h @@ -28,12 +28,12 @@ #include <extensionsystem/iplugin.h> +#include <QKeySequence> #include <QPointer> #include <QtPlugin> QT_BEGIN_NAMESPACE class QAction; -class QKeySequence; QT_END_NAMESPACE namespace Core { class Id; } @@ -55,7 +55,8 @@ public: void extensionsInitialized(); private: - QAction *registerNewAction(Core::Id id, const QString &title, const QKeySequence &key); + QAction *registerNewAction(Core::Id id, const QString &title = QString(), + const QKeySequence &key = QKeySequence()); QPointer<ImageViewerFactory> m_factory; }; |