Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Rename zoom modes to look shorter

Dmitry Kazakov3f3e0964906f
diff --git a/libs/flake/KoZoomMode.cpp b/libs/flake/KoZoomMode.cpp
index 89ee594878..3c21d0d02f 100644
--- a/libs/flake/KoZoomMode.cpp
+++ b/libs/flake/KoZoomMode.cpp
@@ -14,53 +14,21 @@
#include <ksharedconfig.h>
#include <cmath>
-
-const char* const KoZoomMode::modes[] =
-{
- QT_TRANSLATE_NOOP("", "%1%"),
- QT_TRANSLATE_NOOP("", "Fit View"),
- QT_TRANSLATE_NOOP("", "Fit View Width"),
- 0,
- QT_TRANSLATE_NOOP("", "Actual Pixels"),
- 0,
- 0,
- 0,
- QT_TRANSLATE_NOOP("", "Fit Text Width"),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- QT_TRANSLATE_NOOP("", "Fit View Height")
-};
+#include "kis_assert.h"
QString KoZoomMode::toString(Mode mode)
{
- return i18n(modes[mode]);
-}
-
-KoZoomMode::Mode KoZoomMode::toMode(const QString& mode)
-{
- if (mode == i18n(modes[ZOOM_PAGE]))
- return ZOOM_PAGE;
- else
- if (mode == i18n(modes[ZOOM_WIDTH]))
- return ZOOM_WIDTH;
- else
- if (mode == i18n(modes[ZOOM_PIXELS]))
- return ZOOM_PIXELS;
- else
- if (mode == i18n(modes[ZOOM_HEIGHT]))
- return ZOOM_HEIGHT;
- else
- return ZOOM_CONSTANT;
- // we return ZOOM_CONSTANT else because then we can pass '10%' or '15%'
- // or whatever, it's automatically converted. ZOOM_CONSTANT is
- // changeable, whereas all other zoom modes (non-constants) are normal
- // text like "Fit to xxx". they let the view grow/shrink according
- // to windowsize, hence the term 'non-constant'
+ switch (mode) {
+ case KoZoomMode::ZOOM_CONSTANT:
+ KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(0 && "constant zoom has no user-friendly representation", "XXX");
+ case KoZoomMode::ZOOM_PAGE:
+ return i18n("Fit View");
+ case KoZoomMode::ZOOM_WIDTH:
+ return i18n("Fit Width");
+ case KoZoomMode::ZOOM_HEIGHT:
+ return i18n("Fit Height");
+ }
+ return "";
}
QVector<qreal> KoZoomMode::generateStandardZoomLevels(qreal minZoom, qreal maxZoom)
@@ -129,9 +97,6 @@ QDebug operator<<(QDebug dbg, const KoZoomMode::Mode &mode)
case KoZoomMode::ZOOM_HEIGHT:
dbg << "ZOOM_HEIGHT";
break;
- case KoZoomMode::ZOOM_PIXELS:
- dbg << "ZOOM_PIXELS";
- break;
default:
dbg << "UNKNOWN";
break;
diff --git a/libs/flake/KoZoomMode.h b/libs/flake/KoZoomMode.h
index 5e78a8c64e..1f4ccac41b 100644
--- a/libs/flake/KoZoomMode.h
+++ b/libs/flake/KoZoomMode.h
@@ -25,15 +25,10 @@ public:
ZOOM_PAGE = 1, ///< zoom page
ZOOM_WIDTH = 2, ///< zoom pagewidth
ZOOM_HEIGHT = 16, ///< zoom pageheight
- ZOOM_PIXELS = 4 ///< zoom to actual pixels TODO: remove!!!
};
Q_DECLARE_FLAGS(Modes, Mode)
- /// \param mode the mode name
- /// \return the to Mode converted QString \c mode
- static Mode toMode(const QString& mode);
-
/// \return the to QString converted and translated Mode \c mode
static QString toString(Mode mode);