[neon/backports-noble/kimageannotator-noble/Neon/release] /: New upstream version 0.4.2
Boyuan Yang
null at kde.org
Wed Jul 3 14:54:12 BST 2024
Git commit 4e60eb4f166317b07d6d5d6570420c9a73cec863 by Boyuan Yang.
Committed on 03/04/2021 at 14:26.
Pushed by jriddell into branch 'Neon/release'.
New upstream version 0.4.2
M +16 -0 CHANGELOG.md
M +13 -6 CMakeLists.txt
M +1 -1 README.md
M +1 -1 include/kImageAnnotator/KImageAnnotator.h
M +1 -0 src/CMakeLists.txt
M +22 -10 src/annotations/core/AnnotationArea.cpp
M +2 -1 src/annotations/core/AnnotationArea.h
M +2 -2 src/annotations/core/imageEffects/ImageEffectFactory.cpp
M +2 -1 src/annotations/items/AnnotationText.cpp
M +2 -1 src/annotations/items/AnnotationTextArrow.cpp
M +2 -1 src/annotations/items/AnnotationTextPointer.cpp
M +8 -7 src/annotations/items/text/AnnotationTextHandler.cpp
M +1 -1 src/annotations/items/text/AnnotationTextHandler.h
M +0 -2 src/annotations/items/text/CapsLockStatusChecker.cpp
M +1 -1 src/annotations/items/text/KeyInputHelper.cpp
M +11 -4 src/annotations/items/text/TextCursor.cpp
M +3 -2 src/annotations/items/text/TextCursor.h
M +3 -3 src/annotations/modifiers/AnnotationItemModifier.cpp
M +1 -1 src/annotations/modifiers/AnnotationItemModifier.h
M +3 -9 src/annotations/modifiers/AnnotationItemResizer.cpp
M +1 -3 src/annotations/modifiers/AnnotationItemResizer.h
M +2 -2 src/annotations/modifiers/AnnotationItemSelector.cpp
M +1 -1 src/annotations/modifiers/AnnotationItemSelector.h
M +3 -4 src/annotations/modifiers/AnnotationMultiItemResizer.cpp
M +2 -2 src/annotations/modifiers/AnnotationMultiItemResizer.h
M +46 -11 src/backend/Config.cpp
M +8 -8 src/common/helper/ConfigNameHelper.cpp
M +2 -2 src/common/helper/IconLoader.cpp
A +88 -0 src/common/provider/ScaledSizeProvider.cpp [License: LGPL (v3+)]
C +24 -27 src/common/provider/ScaledSizeProvider.h [from: src/widgets/ColorPicker.h - 053% similarity]
M +1 -1 src/gui/CoreView.h
M +0 -2 src/gui/KImageAnnotator.cpp
M +6 -6 src/gui/annotator/AnnotationSettings.cpp
M +5 -1 src/gui/annotator/AnnotationView.cpp
M +2 -2 src/gui/annotator/AnnotationWidget.cpp
M +1 -0 src/gui/annotator/AnnotationWidget.h
M +3 -2 src/gui/cropper/CropHandles.cpp
M +1 -1 src/gui/cropper/CropHandles.h
M +5 -4 src/gui/cropper/CropWidget.cpp
M +1 -0 src/gui/cropper/CropWidget.h
M +4 -4 src/gui/scaler/ScaleDialog.cpp
M +3 -3 src/widgets/ColorPicker.cpp
M +1 -1 src/widgets/ColorPicker.h
M +2 -0 src/widgets/CustomSpinBox.cpp
M +1 -1 src/widgets/CustomToolButton.cpp
M +2 -0 src/widgets/CustomToolButton.h
M +2 -2 src/widgets/CustomToolButtonAction.cpp
M +1 -1 src/widgets/CustomToolButtonAction.h
M +7 -7 src/widgets/FillModePicker.cpp
M +1 -1 src/widgets/FillModePicker.h
M +8 -8 src/widgets/ImageEffectPicker.cpp
M +1 -1 src/widgets/ImageEffectPicker.h
M +3 -3 src/widgets/NumberPicker.cpp
M +1 -1 src/widgets/NumberPicker.h
M +23 -23 src/widgets/StickerPicker.cpp
M +2 -2 src/widgets/StickerPicker.h
M +20 -20 src/widgets/ToolPicker.cpp
M +5 -5 src/widgets/ZoomIndicator.cpp
M +1 -1 src/widgets/ZoomIndicator.h
M +3 -5 src/widgets/menuButtons/GridMenuButton.cpp
M +1 -1 src/widgets/menuButtons/GridMenuButton.h
M +1 -1 src/widgets/menuButtons/ListMenuItem.cpp
M +1 -1 src/widgets/menuButtons/ListMenuItem.h
M +7 -1 tests/CMakeLists.txt
M +42 -14 tests/annotations/items/helper/TextCursorTest.cpp
M +4 -2 tests/annotations/items/helper/TextCursorTest.h
M +6 -6 tests/annotations/modifiers/AnnotationItemModifierTest.cpp
M +1 -1 tests/annotations/modifiers/AnnotationItemResizerTest.cpp
M +7 -7 tests/annotations/modifiers/AnnotationMultiItemResizerTest.cpp
M +1 -0 translations/CMakeLists.txt
M +18 -18 translations/kImageAnnotator_de.ts
M +14 -14 translations/kImageAnnotator_no.ts
M +63 -14 translations/kImageAnnotator_pt_BR.ts
M +16 -16 translations/kImageAnnotator_ru.ts
https://invent.kde.org/neon/backports-noble/kimageannotator-noble/-/commit/4e60eb4f166317b07d6d5d6570420c9a73cec863
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 94c35d3..891715a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,21 @@
# Change log
+## Release 0.4.2
+* Fixed: Fetching image from annotator with HiDPI enabled pixelates image. ([#218](https://github.com/ksnip/kImageAnnotator/issues/218))
+* Fixed: Keep aspect ratio only work when pressing CTRL before moving resize handle. ([#219](https://github.com/ksnip/kImageAnnotator/issues/219))
+
+## Release 0.4.1
+* Changed: Horizontally align text inside spin box. ([#203](https://github.com/ksnip/kImageAnnotator/issues/203))
+* Changed: Change zoom with mouse wheel to CTRL+Wheel. ([#210](https://github.com/ksnip/kImageAnnotator/issues/210))
+* Fixed: Brazilian Portuguese translation not loaded. ([#176](https://github.com/ksnip/kImageAnnotator/issues/176))
+* Fixed: error: control reaches end of non-void function. ([#177](https://github.com/ksnip/kImageAnnotator/issues/177))
+* Fixed: Cursor in Text tool have too bad visibility. ([#184](https://github.com/ksnip/kImageAnnotator/issues/184))
+* Fixed: bumped SONAME without name change. ([#185](https://github.com/ksnip/kImageAnnotator/issues/185))
+* Fixed: Entering multiple characters at once moves the text cursor only for one character. ([#186](https://github.com/ksnip/kImageAnnotator/issues/186))
+* Fixed: Activating context menu while drawing item leaves item in error state. ([#196](https://github.com/ksnip/kImageAnnotator/issues/196))
+* Fixed: Icons not scaled on gnome with hdpi enabled. ([#201](https://github.com/ksnip/kImageAnnotator/issues/201))
+* Fixed: Text/Number Pointer and Text/Number Arrow don't inherit Text/Number Font in Settings. ([#208](https://github.com/ksnip/kImageAnnotator/issues/208))
+
## Release 0.4.0
* New: Add Pixelate image area tool. ([#140](https://github.com/ksnip/kImageAnnotator/issues/140))
* New: Zoom in and out. ([#123](https://github.com/ksnip/kImageAnnotator/issues/123))
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6cf69d2..47ce4a4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,10 +1,13 @@
cmake_minimum_required(VERSION 3.5)
-project(kImageAnnotator LANGUAGES CXX VERSION 0.4.0)
+project(kImageAnnotator LANGUAGES CXX VERSION 0.4.2)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
@@ -31,11 +34,10 @@ endif ()
include(FeatureSummary)
-set(KCOLORPICKER_MIN_VERSION "0.1.4")
+set(KCOLORPICKER_MIN_VERSION "0.1.5")
find_package(kColorPicker ${KCOLORPICKER_MIN_VERSION} REQUIRED)
-set(BASEPATH "${CMAKE_CURRENT_SOURCE_DIR}")
-include_directories("${BASEPATH}")
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(src)
add_subdirectory(translations)
@@ -70,7 +72,11 @@ target_include_directories(kImageAnnotator
target_link_libraries(kImageAnnotator PUBLIC Qt5::Widgets Qt5::Svg PRIVATE kColorPicker::kColorPicker)
if (UNIX AND NOT APPLE)
- target_link_libraries(kImageAnnotator PRIVATE X11)
+ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14.0)
+ target_link_libraries(kImageAnnotator PRIVATE X11::X11)
+ else()
+ target_link_libraries(kImageAnnotator PRIVATE X11)
+ endif()
endif ()
target_compile_definitions(kImageAnnotator PRIVATE KIMAGEANNOTATOR_LIB)
@@ -80,7 +86,8 @@ set_target_properties(kImageAnnotator
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin
- SOVERSION ${PROJECT_VERSION}
+ VERSION ${PROJECT_VERSION}
+ SOVERSION 0
)
install(TARGETS kImageAnnotator
diff --git a/README.md b/README.md
index f2f61fd..53a3d5b 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# kImageAnnotator [![Build Status][travis-badge]][travis-url] [![Translation status][weblate-badge]][weblate-url]
Tool for annotating images
-Version 0.4.0 - Work in Progress
+Version 0.4.2
![kImageAnnotator](https://i.imgur.com/4vlPDUn.png "kImageAnnotator")
diff --git a/include/kImageAnnotator/KImageAnnotator.h b/include/kImageAnnotator/KImageAnnotator.h
index 025f8ee..67a188f 100644
--- a/include/kImageAnnotator/KImageAnnotator.h
+++ b/include/kImageAnnotator/KImageAnnotator.h
@@ -41,7 +41,7 @@ public:
QImage imageAt(int index) const;
QAction *undoAction();
QAction *redoAction();
- QSize sizeHint() const;
+ QSize sizeHint() const override;
void showAnnotator();
void showCropper();
void showScaler();
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 29acd38..d1f6e97 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -94,6 +94,7 @@ set(KIMAGEANNOTATOR_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/annotations/misc/NumberManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/backend/Config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/provider/DevicePixelRatioScaler.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/common/provider/ScaledSizeProvider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/helper/CursorHelper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/helper/KeyHelper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/common/helper/MathHelper.cpp
diff --git a/src/annotations/core/AnnotationArea.cpp b/src/annotations/core/AnnotationArea.cpp
index 2ad009e..b30c237 100644
--- a/src/annotations/core/AnnotationArea.cpp
+++ b/src/annotations/core/AnnotationArea.cpp
@@ -104,16 +104,19 @@ QImage AnnotationArea::image()
setSceneRect(itemsBoundingRect().united(graphicsEffectRect)); // Cover all items
auto scaleFactor = mDevicePixelRatioScaler->scaleFactor();
- QImage image(sceneRect().size().toSize() * scaleFactor, QImage::Format_ARGB32_Premultiplied);
+ auto sceneRect = this->sceneRect();
+ auto scaledSceneSize = sceneRect.size().toSize() * scaleFactor;
+ auto scaledSceneRect = QRectF(sceneRect.topLeft(), scaledSceneSize);
+ QImage image(scaledSceneSize, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::white);
+ image.setDevicePixelRatio(scaleFactor);
QPainter painter(&image);
painter.setRenderHint(QPainter::Antialiasing);
- render(&painter);
+ render(&painter, QRectF(), scaledSceneRect);
setSceneRect(mImage->boundingRect()); // Reset scene rect
- image.setDevicePixelRatio(scaleFactor);
return image;
}
@@ -218,7 +221,7 @@ void AnnotationArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (mCurrentItem) {
addPointToCurrentItem(event->scenePos());
} else {
- mItemModifier->handleMouseMove(event->scenePos());
+ mItemModifier->handleMouseMove(event->scenePos(), mKeyHelper->isControlPressed());
}
}
@@ -230,18 +233,25 @@ void AnnotationArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (event->button() == Qt::LeftButton) {
if (mSettingsProvider->toolType() == Tools::Select) {
mItemModifier->handleMouseRelease(mItems);
- } else if (mCurrentItem != nullptr) {
- mCurrentItem->finish();
- mCurrentItem = nullptr;
- if (mConfig->switchToSelectToolAfterDrawingItem()) {
- mSettingsProvider->activateSelectTool();
- }
}
+ finishDrawingItem(event->scenePos());
}
QGraphicsScene::mouseReleaseEvent(event);
}
+void AnnotationArea::finishDrawingItem(const QPointF &pos)
+{
+ if(mCurrentItem != nullptr) {
+ mCurrentItem->finish();
+ mCurrentItem = nullptr;
+
+ if (mConfig->switchToSelectToolAfterDrawingItem()) {
+ mSettingsProvider->activateSelectTool();
+ }
+ }
+}
+
void AnnotationArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton && mSettingsProvider->toolType() == Tools::Select) {
@@ -251,6 +261,8 @@ void AnnotationArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void AnnotationArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
{
+ finishDrawingItem(event->scenePos());
+
mItemModifier->handleSelectionAt(event->scenePos(), mItems, mKeyHelper->isControlPressed());
auto selectedItems = mItemModifier->selectedItems();
diff --git a/src/annotations/core/AnnotationArea.h b/src/annotations/core/AnnotationArea.h
index 5fc5f69..a65fa51 100644
--- a/src/annotations/core/AnnotationArea.h
+++ b/src/annotations/core/AnnotationArea.h
@@ -67,7 +67,7 @@ public:
virtual void scale(const QSize& size);
virtual void clearSelection();
virtual void toolChanged(Tools toolType) override;
- void itemSettingsChanged();
+ void itemSettingsChanged() override;
void firstBadgeNumberChanged(int number) override;
int firstBadgeNumber() const override;
void imageEffectChanged(ImageEffects effect) override;
@@ -108,6 +108,7 @@ private:
void resetAnnotationArea();
void removeAllItems();
void replaceBackgroundImage(const QPixmap &image);
+ void finishDrawingItem(const QPointF &pos);
private slots:
void deleteSelectedItems();
diff --git a/src/annotations/core/imageEffects/ImageEffectFactory.cpp b/src/annotations/core/imageEffects/ImageEffectFactory.cpp
index ecfc530..1c12379 100644
--- a/src/annotations/core/imageEffects/ImageEffectFactory.cpp
+++ b/src/annotations/core/imageEffects/ImageEffectFactory.cpp
@@ -22,13 +22,13 @@
QGraphicsEffect *kImageAnnotator::ImageEffectFactory::create(kImageAnnotator::ImageEffects effect)
{
switch (effect) {
- case ImageEffects::NoEffect:
- return new NoImageEffect;
case ImageEffects::DropShadow:
return new DropShadowImageEffect;
case ImageEffects::Border:
return new BorderImageEffect;
case ImageEffects::Grayscale:
return new GrayscaleImageEffect;
+ default:
+ return new NoImageEffect;
}
}
diff --git a/src/annotations/items/AnnotationText.cpp b/src/annotations/items/AnnotationText.cpp
index 2bbc87c..8f0b1b9 100644
--- a/src/annotations/items/AnnotationText.cpp
+++ b/src/annotations/items/AnnotationText.cpp
@@ -68,7 +68,8 @@ void AnnotationText::paint(QPainter *painter, const QStyleOptionGraphicsItem *st
auto font = textProperties()->font();
auto color = textProperties()->textColor();
auto margin = textProperties()->width();
- mTextHandler.paintText(painter, mRect, font, color, margin);
+ auto isShadowEnabled = properties()->shadowEnabled();
+ mTextHandler.paintText(painter, mRect, font, color, margin, isShadowEnabled);
}
void AnnotationText::finish()
diff --git a/src/annotations/items/AnnotationTextArrow.cpp b/src/annotations/items/AnnotationTextArrow.cpp
index 754d1be..90a0d33 100644
--- a/src/annotations/items/AnnotationTextArrow.cpp
+++ b/src/annotations/items/AnnotationTextArrow.cpp
@@ -85,7 +85,8 @@ void AnnotationTextArrow::paint(QPainter *painter, const QStyleOptionGraphicsIte
auto font = textProperties()->font();
auto color = textProperties()->textColor();
auto margin = textProperties()->width();
- mTextHandler.paintText(painter, mRect, font, color, margin);
+ auto isShadowEnabled = properties()->shadowEnabled();
+ mTextHandler.paintText(painter, mRect, font, color, margin, isShadowEnabled);
}
} // namespace kImageAnnotator
\ No newline at end of file
diff --git a/src/annotations/items/AnnotationTextPointer.cpp b/src/annotations/items/AnnotationTextPointer.cpp
index 7e9ed17..147d72f 100644
--- a/src/annotations/items/AnnotationTextPointer.cpp
+++ b/src/annotations/items/AnnotationTextPointer.cpp
@@ -119,7 +119,8 @@ void AnnotationTextPointer::paint(QPainter *painter, const QStyleOptionGraphicsI
auto font = textProperties()->font();
auto color = textProperties()->textColor();
auto margin = textProperties()->width();
- mTextHandler.paintText(painter, mRect, font, color, margin);
+ auto isShadowEnabled = properties()->shadowEnabled();
+ mTextHandler.paintText(painter, mRect, font, color, margin, isShadowEnabled);
}
void AnnotationTextPointer::connectSlots()
diff --git a/src/annotations/items/text/AnnotationTextHandler.cpp b/src/annotations/items/text/AnnotationTextHandler.cpp
index 60df464..23d94bc 100644
--- a/src/annotations/items/text/AnnotationTextHandler.cpp
+++ b/src/annotations/items/text/AnnotationTextHandler.cpp
@@ -40,7 +40,7 @@ AnnotationTextHandler::AnnotationTextHandler(const AnnotationTextHandler &other)
void AnnotationTextHandler::insertText(const QString &text)
{
mText.insert(mTextCursor.position(), text);
- mTextCursor.move(TextPositions::Next, mText);
+ mTextCursor.moveForwardBy(mText, text.length());
emit changed();
}
@@ -92,7 +92,7 @@ void AnnotationTextHandler::disableEditing()
emit changed();
}
-void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFont& font, const QColor& color, int margin)
+void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFont &font, const QColor &color, int margin, bool isShadowEnabled)
{
auto textArea = rect->toRect();
if (mIsInEditMode && textArea.isValid()) {
@@ -101,9 +101,10 @@ void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFo
painter->drawRect(textArea);
}
- // Workaround for issue #70 -> Cursor not drawn with with Qt 5.9
- if (mIsInEditMode) {
- painter->setBrush(QColor(255,255,255,10));
+ // Workaround for issue #70 / #184 -> Cursor not drawn with with Qt 5.9
+ // https://bugreports.qt.io/browse/QTBUG-82022
+ if (mIsInEditMode && isShadowEnabled) {
+ painter->setBrush(QColor(255,255,255,50));
painter->drawRect(*rect);
}
@@ -142,7 +143,7 @@ void AnnotationTextHandler::paintText(QPainter *painter, QRectF *rect, const QFo
textLayout.draw(painter, QPoint(0, boxHeight));
if (mTextCursor.isVisible() && isCursorInBlock(blockPosition, blockLength)) {
- textLayout.drawCursor(painter, QPointF(1, boxHeight), mTextCursor.position() - blockPosition, 2);
+ textLayout.drawCursor(painter, QPointF(0, boxHeight), mTextCursor.position() - blockPosition, 1);
}
boxHeight += blockHeight;
}
@@ -177,7 +178,7 @@ QRect AnnotationTextHandler::getTextRect(QRectF *rect, const QFont& font, int ma
{
QFontMetrics fontMetrics(font);
auto newRect = fontMetrics.boundingRect(rect->toRect().normalized(), Qt::AlignLeft, mText);
- newRect.adjust(0, 0, margin * 2, margin * 2);
+ newRect.adjust(0, 2, (margin * 2) + 2, margin * 2);
return newRect;
}
diff --git a/src/annotations/items/text/AnnotationTextHandler.h b/src/annotations/items/text/AnnotationTextHandler.h
index a670aa4..57748d7 100644
--- a/src/annotations/items/text/AnnotationTextHandler.h
+++ b/src/annotations/items/text/AnnotationTextHandler.h
@@ -40,7 +40,7 @@ public:
void insertText(const QString &text);
void enableEditing();
void disableEditing();
- void paintText(QPainter *painter, QRectF *rect, const QFont& font, const QColor& color, int margin);
+ void paintText(QPainter *painter, QRectF *rect, const QFont &font, const QColor &color, int margin, bool isShadowEnabled);
void updateRect(QRectF *rect, const QFont &font, int margin) const;
QRect getTextRect(QRectF *rect, const QFont& font, int margin) const;
void handleKeyEvent(QKeyEvent *event);
diff --git a/src/annotations/items/text/CapsLockStatusChecker.cpp b/src/annotations/items/text/CapsLockStatusChecker.cpp
index 9948afe..e73eb4c 100644
--- a/src/annotations/items/text/CapsLockStatusChecker.cpp
+++ b/src/annotations/items/text/CapsLockStatusChecker.cpp
@@ -26,10 +26,8 @@
*/
#if defined(__linux__)
-
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
-
#endif
namespace kImageAnnotator {
diff --git a/src/annotations/items/text/KeyInputHelper.cpp b/src/annotations/items/text/KeyInputHelper.cpp
index 703c127..ed68730 100644
--- a/src/annotations/items/text/KeyInputHelper.cpp
+++ b/src/annotations/items/text/KeyInputHelper.cpp
@@ -30,7 +30,7 @@ void KeyInputHelper::handleKeyPress(const QKeyEvent *event)
case Qt::Key_Return:
case Qt::Key_Enter:
if (isShiftPressed(event)) {
- emit insert(QStringLiteral("\n"));
+ emit insert(QLatin1String("\n"));
} else {
emit escape();
}
diff --git a/src/annotations/items/text/TextCursor.cpp b/src/annotations/items/text/TextCursor.cpp
index 40f7355..ff64669 100644
--- a/src/annotations/items/text/TextCursor.cpp
+++ b/src/annotations/items/text/TextCursor.cpp
@@ -43,7 +43,7 @@ void TextCursor::move(TextPositions direction, const QString &text)
{
switch (direction) {
case TextPositions::Next:
- moveCursorForward(text);
+ moveCursorForwardBy(text, 1);
break;
case TextPositions::Previous:
moveCursorBack(text);
@@ -58,8 +58,15 @@ void TextCursor::move(TextPositions direction, const QString &text)
mIsVisible = true;
}
+void TextCursor::moveForwardBy(const QString &text, int moveBy)
+{
+ moveCursorForwardBy(text, moveBy);
+ mIsVisible = true;
+}
+
void TextCursor::start()
{
+ mIsVisible = true;
mBlinkTimer->start(mBlinkIntervalInMs);
}
@@ -84,11 +91,11 @@ bool TextCursor::isVisible() const
return mIsVisible;
}
-void TextCursor::moveCursorForward(const QString &text)
+void TextCursor::moveCursorForwardBy(const QString &text, int moveBy)
{
- mPosition++;
+ mPosition += moveBy;
if (mPosition > text.length()) {
- mPosition = 0;
+ mPosition = mPosition - text.length() - 1;
}
}
diff --git a/src/annotations/items/text/TextCursor.h b/src/annotations/items/text/TextCursor.h
index 8043274..d182062 100644
--- a/src/annotations/items/text/TextCursor.h
+++ b/src/annotations/items/text/TextCursor.h
@@ -36,6 +36,7 @@ public:
TextCursor(const TextCursor &other);
~TextCursor() override;
void move(TextPositions direction, const QString &text);
+ void moveForwardBy(const QString &text, int moveBy);
void start();
void stop();
int position() const;
@@ -46,12 +47,12 @@ signals:
void tick() const;
private:
- int mBlinkIntervalInMs = 1000;
+ int mBlinkIntervalInMs = 800;
QTimer *mBlinkTimer;
int mPosition = 0;
bool mIsVisible = false;
- void moveCursorForward(const QString &text);
+ void moveCursorForwardBy(const QString &text, int moveBy);
void moveCursorBack(const QString &text);
void moveCursorUp(const QString &text);
void moveCursorDown(const QString &text);
diff --git a/src/annotations/modifiers/AnnotationItemModifier.cpp b/src/annotations/modifiers/AnnotationItemModifier.cpp
index 6e31bd0..108e4f2 100644
--- a/src/annotations/modifiers/AnnotationItemModifier.cpp
+++ b/src/annotations/modifiers/AnnotationItemModifier.cpp
@@ -48,7 +48,7 @@ void AnnotationItemModifier::handleMousePress(const QPointF &pos, QList<Abstract
{
mItemEditor->clear();
- mItemResizer->grabHandle(pos, isCtrlPressed);
+ mItemResizer->grabHandle(pos);
if (mItemResizer->isResizing()) {
mItemResizer->hideCurrentResizer();
return;
@@ -68,10 +68,10 @@ void AnnotationItemModifier::handleMousePress(const QPointF &pos, QList<Abstract
updateCursor(mItemMover->cursor());
}
-void AnnotationItemModifier::handleMouseMove(const QPointF &pos)
+void AnnotationItemModifier::handleMouseMove(const QPointF &pos, bool isCtrlPressed)
{
if (mItemResizer->isResizing()) {
- mItemResizer->moveHandle(pos);
+ mItemResizer->moveHandle(pos, isCtrlPressed);
updateCursor(mItemResizer->cursorForCurrentHandle());
} else if (mItemSelector->isSelecting()) {
mItemSelector->extendSelectionRectWhenShown(pos);
diff --git a/src/annotations/modifiers/AnnotationItemModifier.h b/src/annotations/modifiers/AnnotationItemModifier.h
index dfed02b..7a76ea4 100644
--- a/src/annotations/modifiers/AnnotationItemModifier.h
+++ b/src/annotations/modifiers/AnnotationItemModifier.h
@@ -39,7 +39,7 @@ public:
explicit AnnotationItemModifier(ZoomValueProvider *zoomValueProvider);
~AnnotationItemModifier() override;
void handleMousePress(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isCtrlPressed);
- void handleMouseMove(const QPointF &pos);
+ void handleMouseMove(const QPointF &pos, bool isCtrlPressed);
void handleMouseRelease(QList<AbstractAnnotationItem *> *items);
void handleMouseDoubleClick(const QPointF &pos, QList<AbstractAnnotationItem *> *items);
void handleSelectionAt(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isCtrlPressed);
diff --git a/src/annotations/modifiers/AnnotationItemResizer.cpp b/src/annotations/modifiers/AnnotationItemResizer.cpp
index 3866497..35ed08c 100644
--- a/src/annotations/modifiers/AnnotationItemResizer.cpp
+++ b/src/annotations/modifiers/AnnotationItemResizer.cpp
@@ -24,8 +24,7 @@ namespace kImageAnnotator {
AnnotationItemResizer::AnnotationItemResizer(AbstractAnnotationItem *item, ZoomValueProvider *zoomValueProvider) :
mAnnotationItem(item),
mZoomValueProvider(zoomValueProvider),
- mCurrentHandle(-1),
- mKeepAspectRatio(false)
+ mCurrentHandle(-1)
{
mResizeHandles = ResizeHandlesFactory::createResizeHandles(item, zoomValueProvider->zoomValue());
connect(zoomValueProvider, &ZoomValueProvider::zoomValueChanged, this, &AnnotationItemResizer::applyZoomValue);
@@ -52,10 +51,10 @@ void AnnotationItemResizer::grabHandle(const QPointF &pos)
}
}
-void AnnotationItemResizer::moveHandle(const QPointF &pos)
+void AnnotationItemResizer::moveHandle(const QPointF &pos, bool isCtrlPressed)
{
if (mCurrentHandle != -1) {
- emit newCommand(new ResizeCommand(mAnnotationItem, mCurrentHandle, pos - mClickOffset, mKeepAspectRatio));
+ emit newCommand(new ResizeCommand(mAnnotationItem, mCurrentHandle, pos - mClickOffset, isCtrlPressed));
}
}
@@ -80,11 +79,6 @@ bool AnnotationItemResizer::isItemVisible() const
return mAnnotationItem != nullptr && mAnnotationItem->isVisible();
}
-void AnnotationItemResizer::setKeepAspectRatio(bool keepAspectRatio)
-{
- mKeepAspectRatio = keepAspectRatio;
-}
-
Qt::CursorShape AnnotationItemResizer::cursorForPos(const QPointF &pos)
{
return mResizeHandles->cursorForPos(pos);
diff --git a/src/annotations/modifiers/AnnotationItemResizer.h b/src/annotations/modifiers/AnnotationItemResizer.h
index 94a2e25..b1356fa 100644
--- a/src/annotations/modifiers/AnnotationItemResizer.h
+++ b/src/annotations/modifiers/AnnotationItemResizer.h
@@ -36,12 +36,11 @@ public:
~AnnotationItemResizer() override;
QRectF boundingRect() const override;
void grabHandle(const QPointF &pos);
- void moveHandle(const QPointF &pos);
+ void moveHandle(const QPointF &pos, bool isCtrlPressed);
void releaseHandle();
bool isResizing() const;
void refresh();
bool isItemVisible() const;
- void setKeepAspectRatio(bool keepAspectRatio);
Qt::CursorShape cursorForPos(const QPointF &pos);
Qt::CursorShape cursorForCurrentHandle();
@@ -57,7 +56,6 @@ private:
ZoomValueProvider *mZoomValueProvider;
int mCurrentHandle;
QPointF mClickOffset;
- bool mKeepAspectRatio;
void applyZoomValue(double value);
};
diff --git a/src/annotations/modifiers/AnnotationItemSelector.cpp b/src/annotations/modifiers/AnnotationItemSelector.cpp
index df35c32..401a486 100644
--- a/src/annotations/modifiers/AnnotationItemSelector.cpp
+++ b/src/annotations/modifiers/AnnotationItemSelector.cpp
@@ -47,9 +47,9 @@ QRectF AnnotationItemSelector::boundingRect() const
}
}
-void AnnotationItemSelector::handleSelectionOrShowSelectionRectAt(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isModifing)
+void AnnotationItemSelector::handleSelectionOrShowSelectionRectAt(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isModifying)
{
- handleSelectionAt(pos, items, isModifing);
+ handleSelectionAt(pos, items, isModifying);
if (mSelectedItems->count() > 0) {
return;
diff --git a/src/annotations/modifiers/AnnotationItemSelector.h b/src/annotations/modifiers/AnnotationItemSelector.h
index d46d36c..f76b06e 100644
--- a/src/annotations/modifiers/AnnotationItemSelector.h
+++ b/src/annotations/modifiers/AnnotationItemSelector.h
@@ -33,7 +33,7 @@ public:
explicit AnnotationItemSelector(ZoomValueProvider *zoomValueProvider);
~AnnotationItemSelector() override;
QRectF boundingRect() const override;
- void handleSelectionOrShowSelectionRectAt(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isModifing);
+ void handleSelectionOrShowSelectionRectAt(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool isModifying);
void extendSelectionRectWhenShown(const QPointF &pos);
void finishSelectionRectWhenShown(QList<AbstractAnnotationItem *> *items);
void handleSelectionAt(const QPointF &pos, QList<AbstractAnnotationItem *> *items, bool modifying);
diff --git a/src/annotations/modifiers/AnnotationMultiItemResizer.cpp b/src/annotations/modifiers/AnnotationMultiItemResizer.cpp
index d299525..6589a78 100644
--- a/src/annotations/modifiers/AnnotationMultiItemResizer.cpp
+++ b/src/annotations/modifiers/AnnotationMultiItemResizer.cpp
@@ -54,27 +54,26 @@ void AnnotationMultiItemResizer::detach()
mCurrentResizer = nullptr;
}
-void AnnotationMultiItemResizer::grabHandle(const QPointF &pos, bool keepAspectRatio)
+void AnnotationMultiItemResizer::grabHandle(const QPointF &pos)
{
for (auto item : childItems()) {
auto resizer = castToResizer(item);
resizer->grabHandle(pos);
if (resizer->isResizing()) {
mCurrentResizer = resizer;
- mCurrentResizer->setKeepAspectRatio(keepAspectRatio);
return;
}
}
mCurrentResizer = nullptr;
}
-void AnnotationMultiItemResizer::moveHandle(const QPointF &pos)
+void AnnotationMultiItemResizer::moveHandle(const QPointF &pos, bool isCtrlPressed)
{
if (mCurrentResizer == nullptr) {
return;
}
- mCurrentResizer->moveHandle(pos);
+ mCurrentResizer->moveHandle(pos, isCtrlPressed);
}
void AnnotationMultiItemResizer::releaseHandle()
diff --git a/src/annotations/modifiers/AnnotationMultiItemResizer.h b/src/annotations/modifiers/AnnotationMultiItemResizer.h
index be05360..73d1266 100644
--- a/src/annotations/modifiers/AnnotationMultiItemResizer.h
+++ b/src/annotations/modifiers/AnnotationMultiItemResizer.h
@@ -38,8 +38,8 @@ public:
QRectF boundingRect() const override;
void attachTo(const QList<AbstractAnnotationItem *>& items);
void detach();
- void grabHandle(const QPointF &pos, bool keepAspectRatio);
- void moveHandle(const QPointF &pos);
+ void grabHandle(const QPointF &pos);
+ void moveHandle(const QPointF &pos, bool isCtrlPressed);
void releaseHandle();
bool isResizing() const;
void refresh();
diff --git a/src/backend/Config.cpp b/src/backend/Config.cpp
index 184bec9..f4b414e 100644
--- a/src/backend/Config.cpp
+++ b/src/backend/Config.cpp
@@ -131,7 +131,18 @@ void Config::setToolFillType(FillModes fillType, Tools tool)
QFont Config::toolFont(Tools toolType) const
{
- return mToolToFont[toolType];
+ switch (toolType) {
+ case Tools::Number:
+ case Tools::NumberPointer:
+ case Tools::NumberArrow:
+ return mToolToFont[Tools::Number];
+ case Tools::Text:
+ case Tools::TextPointer:
+ case Tools::TextArrow:
+ return mToolToFont[Tools::Text];
+ default:
+ return mToolToFont[toolType];
+ }
}
void Config::setToolFont(const QFont &font, Tools toolType)
@@ -142,12 +153,25 @@ void Config::setToolFont(const QFont &font, Tools toolType)
return;
}
- mToolToFont[toolType] = tmpFont;
+ switch (toolType) {
+ case Tools::Number:
+ case Tools::NumberPointer:
+ case Tools::NumberArrow:
+ mToolToFont[Tools::Number] = tmpFont;
+ break;
+ case Tools::Text:
+ case Tools::TextPointer:
+ case Tools::TextArrow:
+ mToolToFont[Tools::Text] = tmpFont;
+ break;
+ default:
+ mToolToFont[toolType] = tmpFont;
+ }
}
int Config::toolFontSize(Tools toolType) const
{
- return mToolToFont[toolType].pointSize();
+ return toolFont(toolType).pointSize();
}
void Config::setToolFontSize(int fontSize, Tools toolType)
@@ -156,8 +180,23 @@ void Config::setToolFontSize(int fontSize, Tools toolType)
return;
}
- mToolToFont[toolType].setPointSize(fontSize);
- saveToolFontSize(toolType, fontSize);
+ switch (toolType) {
+ case Tools::Number:
+ case Tools::NumberPointer:
+ case Tools::NumberArrow:
+ mToolToFont[Tools::Number].setPointSize(fontSize);
+ saveToolFontSize(Tools::Number, fontSize);
+ break;
+ case Tools::Text:
+ case Tools::TextPointer:
+ case Tools::TextArrow:
+ mToolToFont[Tools::Text].setPointSize(fontSize);
+ saveToolFontSize(Tools::Text, fontSize);
+ break;
+ default:
+ mToolToFont[toolType].setPointSize(fontSize);
+ saveToolFontSize(toolType, fontSize);
+ }
}
bool Config::itemShadowEnabled() const
@@ -273,14 +312,10 @@ void Config::initToolFillTypes()
void Config::initToolFonts()
{
- auto textFont = QFont(QLatin1Literal("Times"), loadToolFontSize(Tools::Text), QFont::Bold);
- auto numberFont = QFont(QLatin1Literal("Helvetica"), loadToolFontSize(Tools::Number), QFont::Bold);
+ auto textFont = QFont(QLatin1String("Times"), loadToolFontSize(Tools::Text), QFont::Bold);
+ auto numberFont = QFont(QLatin1String("Helvetica"), loadToolFontSize(Tools::Number), QFont::Bold);
mToolToFont[Tools::Text] = textFont;
- mToolToFont[Tools::TextPointer] = textFont;
- mToolToFont[Tools::TextArrow] = textFont;
mToolToFont[Tools::Number] = numberFont;
- mToolToFont[Tools::NumberPointer] = numberFont;
- mToolToFont[Tools::NumberArrow] = numberFont;
}
void Config::initObfuscateFactor()
diff --git a/src/common/helper/ConfigNameHelper.cpp b/src/common/helper/ConfigNameHelper.cpp
index 090cba1..2e7753c 100644
--- a/src/common/helper/ConfigNameHelper.cpp
+++ b/src/common/helper/ConfigNameHelper.cpp
@@ -23,42 +23,42 @@ namespace kImageAnnotator {
QString ConfigNameHelper::annotator()
{
- return QLatin1Literal("KImageAnnotator/");
+ return QLatin1String("KImageAnnotator/");
}
QString ConfigNameHelper::toolType()
{
- return annotator() + QLatin1Literal("ToolType");
+ return annotator() + QLatin1String("ToolType");
}
QString ConfigNameHelper::toolWidth(Tools tool)
{
- return annotator() + QLatin1Literal("ToolWidth_") + QString::number(static_cast<int>(tool));
+ return annotator() + QLatin1String("ToolWidth_") + QString::number(static_cast<int>(tool));
}
QString ConfigNameHelper::toolColor(Tools tool)
{
- return annotator() + QLatin1Literal("ToolColor_") + QString::number(static_cast<int>(tool));
+ return annotator() + QLatin1String("ToolColor_") + QString::number(static_cast<int>(tool));
}
QString ConfigNameHelper::toolTextColor(Tools tool)
{
- return annotator() + QLatin1Literal("ToolTextColor_") + QString::number(static_cast<int>(tool));
+ return annotator() + QLatin1String("ToolTextColor_") + QString::number(static_cast<int>(tool));
}
QString ConfigNameHelper::toolFillType(Tools tool)
{
- return annotator() + QLatin1Literal("ToolFillType_") + QString::number(static_cast<int>(tool));
+ return annotator() + QLatin1String("ToolFillType_") + QString::number(static_cast<int>(tool));
}
QString ConfigNameHelper::toolFontSize(Tools tool)
{
- return annotator() + QLatin1Literal("ToolFontSize_") + QString::number(static_cast<int>(tool));
+ return annotator() + QLatin1String("ToolFontSize_") + QString::number(static_cast<int>(tool));
}
QString ConfigNameHelper::obfuscateFactor(Tools tool)
{
- return annotator() + QLatin1Literal("ToolObfuscateFactor_") + QString::number(static_cast<int>(tool));
+ return annotator() + QLatin1String("ToolObfuscateFactor_") + QString::number(static_cast<int>(tool));
}
}
\ No newline at end of file
diff --git a/src/common/helper/IconLoader.cpp b/src/common/helper/IconLoader.cpp
index 266f941..0c1fa4d 100644
--- a/src/common/helper/IconLoader.cpp
+++ b/src/common/helper/IconLoader.cpp
@@ -24,12 +24,12 @@ namespace kImageAnnotator {
QIcon IconLoader::load(QString name)
{
auto type = getThemePrefix();
- return QIcon(QStringLiteral(":/icons/") + type + name);
+ return QIcon(QLatin1String(":/icons/") + type + name);
}
QString IconLoader::getThemePrefix()
{
- return isDarkTheme() ? QStringLiteral("dark/") : QStringLiteral("light/");
+ return isDarkTheme() ? QLatin1String("dark/") : QLatin1String("light/");
}
double IconLoader::getThemeLuma()
diff --git a/src/common/provider/ScaledSizeProvider.cpp b/src/common/provider/ScaledSizeProvider.cpp
new file mode 100644
index 0000000..af573a3
--- /dev/null
+++ b/src/common/provider/ScaledSizeProvider.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2021 Damir Porobic <damir.porobic at gmx.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ScaledSizeProvider.h"
+
+namespace kImageAnnotator {
+
+int ScaledSizeProvider::scaledWidth(int width)
+{
+ return (int)(width * scaleFactor());
+}
+
+QSize ScaledSizeProvider::scaledSize(const QSize &size)
+{
+ return size * scaleFactor();
+}
+
+QSize ScaledSizeProvider::toolButtonIconSize()
+{
+ return scaledSize(Constants::ToolButtonIconSize);
+}
+
+QSize ScaledSizeProvider::settingsWidgetSize()
+{
+ return scaledSize(Constants::SettingsWidgetSize);
+}
+
+QSize ScaledSizeProvider::settingsWidgetIconSize()
+{
+ return scaledSize(Constants::SettingsWidgetIconSize);
+}
+
+QSize ScaledSizeProvider::menuItemIconSize()
+{
+ return scaledSize(Constants::MenuItemIconSize);
+}
+
+int ScaledSizeProvider::resizeHandleSize()
+{
+ return scaledWidth(Constants::ResizeHandleSize);
+}
+
+qreal ScaledSizeProvider::scaleFactor()
+{
+ static auto scaleFactor = getScaleFactor();
+ return scaleFactor;
+}
+
+qreal ScaledSizeProvider::getScaleFactor()
+{
+#if defined(__linux__)
+ if(isGnomeEnvironment()) {
+ auto screen = QApplication::primaryScreen();
+ auto logicalDotsPerInch = (int) screen->logicalDotsPerInch();
+ auto physicalDotsPerInch = (int) screen->physicalDotsPerInch();
+ return (qreal)logicalDotsPerInch / (qreal)physicalDotsPerInch;
+ }
+#endif
+
+ return 1;
+}
+
+#if defined(__linux__)
+bool ScaledSizeProvider::isGnomeEnvironment()
+{
+ auto currentDesktop = QString(qgetenv("XDG_CURRENT_DESKTOP"));
+ return currentDesktop.contains(QLatin1String("gnome"), Qt::CaseInsensitive)
+ || currentDesktop.contains(QLatin1String("unity"), Qt::CaseInsensitive);
+}
+#endif
+
+} // namespace kImageAnnotator
\ No newline at end of file
diff --git a/src/widgets/ColorPicker.h b/src/common/provider/ScaledSizeProvider.h
similarity index 53%
copy from src/widgets/ColorPicker.h
copy to src/common/provider/ScaledSizeProvider.h
index 869a89b..2791718 100644
--- a/src/widgets/ColorPicker.h
+++ b/src/common/provider/ScaledSizeProvider.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018 Damir Porobic <damir.porobic at gmx.com>
+ * Copyright (C) 2021 Damir Porobic <damir.porobic at gmx.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -17,46 +17,43 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef KIMAGEANNOTATOR_COLORPICKER_H
-#define KIMAGEANNOTATOR_COLORPICKER_H
+#ifndef KIMAGEANNOTATOR_SCALEDSIZEPROVIDER_H
+#define KIMAGEANNOTATOR_SCALEDSIZEPROVIDER_H
-#include <QWidget>
-#include <QHBoxLayout>
-#include <QLabel>
+#include <QSize>
-#include <kColorPicker/KColorPicker.h>
+#if defined(__linux__)
+#include <QApplication>
+#include <QScreen>
+#endif
#include "src/common/constants/Constants.h"
-using kColorPicker::KColorPicker;
-
namespace kImageAnnotator {
-class ColorPicker : public QWidget
+class ScaledSizeProvider
{
-Q_OBJECT
public:
- explicit ColorPicker(QWidget *parent);
- ~ColorPicker() override;
- void setColor(const QColor &color);
- QColor color() const;
- void setToolTip(const QString &toolTip);
- void setIcon(const QIcon &icon);
-
-signals:
- void colorSelected(const QColor &color);
+ static int scaledWidth(int width);
+ static QSize scaledSize(const QSize &size);
+ static QSize toolButtonIconSize();
+ static QSize settingsWidgetSize();
+ static QSize settingsWidgetIconSize();
+ static QSize menuItemIconSize();
+ static int resizeHandleSize();
private:
- QHBoxLayout *mLayout;
- QLabel *mLabel;
- KColorPicker *mkColorPicker;
+ static qreal scaleFactor();
+ static qreal getScaleFactor();
- void initGui();
+#if defined(__linux__)
+ static bool isGnomeEnvironment();
+#endif
-private slots:
- void colorChanged(const QColor &color);
+ ScaledSizeProvider() = default;
+ ~ScaledSizeProvider() = default;
};
} // namespace kImageAnnotator
-#endif // KIMAGEANNOTATOR_COLORPICKER_H
+#endif //KIMAGEANNOTATOR_SCALEDSIZEPROVIDER_H
diff --git a/src/gui/CoreView.h b/src/gui/CoreView.h
index 27880c4..b1f9ff6 100644
--- a/src/gui/CoreView.h
+++ b/src/gui/CoreView.h
@@ -39,7 +39,7 @@ public:
QImage imageAt(int index) const;
QAction *undoAction();
QAction *redoAction();
- QSize sizeHint() const;
+ QSize sizeHint() const override;
void reloadConfig();
signals:
diff --git a/src/gui/KImageAnnotator.cpp b/src/gui/KImageAnnotator.cpp
index e4461de..05cb6cb 100644
--- a/src/gui/KImageAnnotator.cpp
+++ b/src/gui/KImageAnnotator.cpp
@@ -206,8 +206,6 @@ KImageAnnotatorPrivate::KImageAnnotatorPrivate(KImageAnnotator *kImageAnnotator)
{
initResource();
- QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
-
mMainLayout.addWidget(&mCoreView);
kImageAnnotator->setLayout(&mMainLayout);
kImageAnnotator->hide();
diff --git a/src/gui/annotator/AnnotationSettings.cpp b/src/gui/annotator/AnnotationSettings.cpp
index 73ea59c..e94d631 100644
--- a/src/gui/annotator/AnnotationSettings.cpp
+++ b/src/gui/annotator/AnnotationSettings.cpp
@@ -97,24 +97,24 @@ Tools AnnotationSettings::toolType() const
void AnnotationSettings::initGui()
{
- mColorPicker->setIcon(IconLoader::load(QLatin1Literal("color.svg")));
+ mColorPicker->setIcon(IconLoader::load(QLatin1String("color.svg")));
mColorPicker->setToolTip(tr("Color"));
- mTextColorPicker->setIcon(IconLoader::load(QLatin1Literal("textColor.svg")));
+ mTextColorPicker->setIcon(IconLoader::load(QLatin1String("textColor.svg")));
mTextColorPicker->setToolTip(tr("Text Color"));
- mWidthPicker->setIcon(IconLoader::load(QLatin1Literal("width.svg")));
+ mWidthPicker->setIcon(IconLoader::load(QLatin1String("width.svg")));
mWidthPicker->setToolTip(tr("Width"));
- mFontSizePicker->setIcon(IconLoader::load(QLatin1Literal("fontSize.svg")));
+ mFontSizePicker->setIcon(IconLoader::load(QLatin1String("fontSize.svg")));
mFontSizePicker->setToolTip(tr("Font Size"));
mFontSizePicker->setRange(10, 40);
- mFirstNumberPicker->setIcon(IconLoader::load(QLatin1Literal("number.svg")));
+ mFirstNumberPicker->setIcon(IconLoader::load(QLatin1String("number.svg")));
mFirstNumberPicker->setToolTip(tr("Starting Number"));
mFirstNumberPicker->setRange(1, 100);
- mObfuscateFactorPicker->setIcon(IconLoader::load(QLatin1Literal("obfuscateFactor.svg")));
+ mObfuscateFactorPicker->setIcon(IconLoader::load(QLatin1String("obfuscateFactor.svg")));
mObfuscateFactorPicker->setToolTip(tr("Obfuscation Factor"));
mObfuscateFactorPicker->setRange(1, 20);
diff --git a/src/gui/annotator/AnnotationView.cpp b/src/gui/annotator/AnnotationView.cpp
index 784493a..9d5d638 100644
--- a/src/gui/annotator/AnnotationView.cpp
+++ b/src/gui/annotator/AnnotationView.cpp
@@ -82,7 +82,11 @@ void AnnotationView::mouseReleaseEvent(QMouseEvent *event)
void AnnotationView::wheelEvent(QWheelEvent *event)
{
- mAnnotationViewZoomer->wheelZoom(event);
+ if(event->modifiers() & Qt::ControlModifier ) {
+ mAnnotationViewZoomer->wheelZoom(event);
+ } else {
+ QGraphicsView::wheelEvent(event);
+ }
}
void AnnotationView::scrollTo(const QPoint &pos)
diff --git a/src/gui/annotator/AnnotationWidget.cpp b/src/gui/annotator/AnnotationWidget.cpp
index add45cb..8dac6b7 100644
--- a/src/gui/annotator/AnnotationWidget.cpp
+++ b/src/gui/annotator/AnnotationWidget.cpp
@@ -41,8 +41,8 @@ QSize AnnotationWidget::sizeHint() const
auto sceneSize = mAnnotationTabWidget->sizeHint();
auto width = minSize.width() + sceneSize.width();
auto height = (minSize.height() > sceneSize.height()) ? minSize.height() : sceneSize.height();
- auto offset = QSize(100, 100);
- return QSize(static_cast<int>(width), static_cast<int>(height)) + offset;
+ auto offset = ScaledSizeProvider::scaledSize(QSize(100, 100));
+ return QSize(width, height) + offset;
}
void AnnotationWidget::initGui()
diff --git a/src/gui/annotator/AnnotationWidget.h b/src/gui/annotator/AnnotationWidget.h
index 1e22d56..b8f3930 100644
--- a/src/gui/annotator/AnnotationWidget.h
+++ b/src/gui/annotator/AnnotationWidget.h
@@ -24,6 +24,7 @@
#include "src/gui/annotator/tabs/AnnotationTabWidget.h"
#include "src/annotations/core/AnnotationArea.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/src/gui/cropper/CropHandles.cpp b/src/gui/cropper/CropHandles.cpp
index 5fb3791..7b96606 100644
--- a/src/gui/cropper/CropHandles.cpp
+++ b/src/gui/cropper/CropHandles.cpp
@@ -23,8 +23,9 @@ namespace kImageAnnotator {
CropHandles::CropHandles() : mGrabbedIndex(-1)
{
+ auto size = ScaledSizeProvider::resizeHandleSize();
for (auto i = 0; i < 8; i++) {
- mHandles.append(QRectF(0, 0, Constants::ResizeHandleSize, Constants::ResizeHandleSize));
+ mHandles.append(QRectF(0, 0, size, size));
}
}
@@ -57,7 +58,7 @@ int CropHandles::grabbedIndex() const
void CropHandles::updateHandles(const QRectF &selection)
{
- auto rectSize = Constants::ResizeHandleSize / 2;
+ auto rectSize = ScaledSizeProvider::resizeHandleSize() / 2;
mHandles[0].moveTopLeft(ShapeHelper::rectTopLeftWithOffset(selection, 0).toPoint());
mHandles[1].moveCenter(ShapeHelper::rectTopWithOffset(selection, -rectSize).toPoint());
mHandles[2].moveTopRight(ShapeHelper::rectTopRightWithOffset(selection, 0).toPoint());
diff --git a/src/gui/cropper/CropHandles.h b/src/gui/cropper/CropHandles.h
index 2057af1..371d519 100644
--- a/src/gui/cropper/CropHandles.h
+++ b/src/gui/cropper/CropHandles.h
@@ -23,7 +23,7 @@
#include <QRectF>
#include <QVector>
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
#include "src/common/helper/ShapeHelper.h"
namespace kImageAnnotator {
diff --git a/src/gui/cropper/CropWidget.cpp b/src/gui/cropper/CropWidget.cpp
index 02919db..3f64724 100644
--- a/src/gui/cropper/CropWidget.cpp
+++ b/src/gui/cropper/CropWidget.cpp
@@ -85,9 +85,10 @@ void CropWidget::initGui()
auto label = new QLabel(tr("X:"));
mPanelLayout->addWidget(label, 0, Qt::AlignCenter);
+ auto width = ScaledSizeProvider::scaledWidth(40);
mPositionXLineEdit = new QLineEdit();
mPositionXLineEdit->setValidator(new QIntValidator(0, 9999, mPositionXLineEdit));
- mPositionXLineEdit->setFixedSize(40, mPositionXLineEdit->minimumSizeHint().height());
+ mPositionXLineEdit->setFixedSize(width, mPositionXLineEdit->minimumSizeHint().height());
connect(mPositionXLineEdit, &QLineEdit::textEdited, this, &CropWidget::xChanged);
mPanelLayout->addWidget(mPositionXLineEdit, 0, Qt::AlignCenter);
@@ -96,7 +97,7 @@ void CropWidget::initGui()
mPositionYLineEdit = new QLineEdit();
mPositionYLineEdit->setValidator(new QIntValidator(0, 9999, mPositionYLineEdit));
- mPositionYLineEdit->setFixedSize(40, mPositionYLineEdit->minimumSizeHint().height());
+ mPositionYLineEdit->setFixedSize(width, mPositionYLineEdit->minimumSizeHint().height());
connect(mPositionYLineEdit, &QLineEdit::textEdited, this, &CropWidget::yChanged);
mPanelLayout->addWidget(mPositionYLineEdit, 0, Qt::AlignCenter);
@@ -105,7 +106,7 @@ void CropWidget::initGui()
mWidthLineEdit = new QLineEdit();
mWidthLineEdit->setValidator(new QIntValidator(0, 9999, mWidthLineEdit));
- mWidthLineEdit->setFixedSize(40, mWidthLineEdit->minimumSizeHint().height());
+ mWidthLineEdit->setFixedSize(width, mWidthLineEdit->minimumSizeHint().height());
connect(mWidthLineEdit, &QLineEdit::textEdited, this, &CropWidget::widthChanged);
mPanelLayout->addWidget(mWidthLineEdit, 0, Qt::AlignCenter);
@@ -114,7 +115,7 @@ void CropWidget::initGui()
mHeightLineEdit = new QLineEdit();
mHeightLineEdit->setValidator(new QIntValidator(0, 9999, mHeightLineEdit));
- mHeightLineEdit->setFixedSize(40, mHeightLineEdit->minimumSizeHint().height());
+ mHeightLineEdit->setFixedSize(width, mHeightLineEdit->minimumSizeHint().height());
connect(mHeightLineEdit, &QLineEdit::textEdited, this, &CropWidget::heightChanged);
mPanelLayout->addWidget(mHeightLineEdit, 0, Qt::AlignCenter);
diff --git a/src/gui/cropper/CropWidget.h b/src/gui/cropper/CropWidget.h
index 9210993..185f7bd 100644
--- a/src/gui/cropper/CropWidget.h
+++ b/src/gui/cropper/CropWidget.h
@@ -31,6 +31,7 @@
#include "CropSelectionHandler.h"
#include "src/annotations/core/AnnotationArea.h"
#include "src/common/helper/KeyHelper.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/src/gui/scaler/ScaleDialog.cpp b/src/gui/scaler/ScaleDialog.cpp
index 9a8db89..216b666 100644
--- a/src/gui/scaler/ScaleDialog.cpp
+++ b/src/gui/scaler/ScaleDialog.cpp
@@ -71,7 +71,7 @@ void ScaleDialog::initGui()
mHeightPercentLabel->setText(tr("Height:"));
mWidthPixelSpinBox = new CustomSpinBox(this);
- mWidthPixelSpinBox->setSuffix(QStringLiteral("px"));
+ mWidthPixelSpinBox->setSuffix(QLatin1String("px"));
mWidthPixelSpinBox->setMinimum(1);
mWidthPixelSpinBox->setMaximum(4000);
mWidthPixelSpinBox->setValueSilent(mSizeHandler.size().width());
@@ -80,7 +80,7 @@ void ScaleDialog::initGui()
connect(&mSizeHandler, &ScaleSizeHandler::widthPixelChanged, mWidthPixelSpinBox, &CustomSpinBox::setValueSilent);
mHeightPixelSpinBox = new CustomSpinBox(this);
- mHeightPixelSpinBox->setSuffix(QStringLiteral("px"));
+ mHeightPixelSpinBox->setSuffix(QLatin1String("px"));
mHeightPixelSpinBox->setMinimum(1);
mHeightPixelSpinBox->setMaximum(4000);
mHeightPixelSpinBox->setValueSilent(mSizeHandler.size().height());
@@ -89,7 +89,7 @@ void ScaleDialog::initGui()
connect(&mSizeHandler, &ScaleSizeHandler::heightPixelChanged, mHeightPixelSpinBox, &CustomSpinBox::setValueSilent);
mWidthPercentSpinBox = new CustomSpinBox(this);
- mWidthPercentSpinBox->setSuffix(QStringLiteral("%"));
+ mWidthPercentSpinBox->setSuffix(QLatin1String("%"));
mWidthPercentSpinBox->setMinimum(1);
mWidthPercentSpinBox->setMaximum(400);
mWidthPercentSpinBox->setValueSilent(100);
@@ -98,7 +98,7 @@ void ScaleDialog::initGui()
connect(&mSizeHandler, &ScaleSizeHandler::widthPercentChanged, mWidthPercentSpinBox, &CustomSpinBox::setValueSilent);
mHeightPercentSpinBox = new CustomSpinBox(this);
- mHeightPercentSpinBox->setSuffix(QStringLiteral("%"));
+ mHeightPercentSpinBox->setSuffix(QLatin1String("%"));
mHeightPercentSpinBox->setMinimum(1);
mHeightPercentSpinBox->setMaximum(400);
mHeightPercentSpinBox->setValueSilent(100);
diff --git a/src/widgets/ColorPicker.cpp b/src/widgets/ColorPicker.cpp
index ac60be4..e34a222 100644
--- a/src/widgets/ColorPicker.cpp
+++ b/src/widgets/ColorPicker.cpp
@@ -58,16 +58,16 @@ void ColorPicker::setToolTip(const QString &toolTip)
void ColorPicker::setIcon(const QIcon &icon)
{
- mLabel->setPixmap(icon.pixmap(Constants::SettingsWidgetIconSize));
+ mLabel->setPixmap(icon.pixmap(ScaledSizeProvider::settingsWidgetIconSize()));
}
void ColorPicker::initGui()
{
mLayout->setContentsMargins(0, 0, 0, 0);
- mLabel->setFixedSize(Constants::SettingsWidgetIconSize);
+ mLabel->setFixedSize(ScaledSizeProvider::settingsWidgetIconSize());
- mkColorPicker->setFixedSize(Constants::SettingsWidgetSize);
+ mkColorPicker->setFixedSize(ScaledSizeProvider::settingsWidgetSize());
mkColorPicker->setFocusPolicy(Qt::NoFocus);
mLayout->addWidget(mLabel);
diff --git a/src/widgets/ColorPicker.h b/src/widgets/ColorPicker.h
index 869a89b..90649a3 100644
--- a/src/widgets/ColorPicker.h
+++ b/src/widgets/ColorPicker.h
@@ -26,7 +26,7 @@
#include <kColorPicker/KColorPicker.h>
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
using kColorPicker::KColorPicker;
diff --git a/src/widgets/CustomSpinBox.cpp b/src/widgets/CustomSpinBox.cpp
index ea966ff..1d555e1 100644
--- a/src/widgets/CustomSpinBox.cpp
+++ b/src/widgets/CustomSpinBox.cpp
@@ -23,6 +23,8 @@ namespace kImageAnnotator {
kImageAnnotator::CustomSpinBox::CustomSpinBox(QWidget *parent) : QSpinBox(parent)
{
+ setAlignment(Qt::AlignHCenter);
+
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &CustomSpinBox::valueChanged);
}
diff --git a/src/widgets/CustomToolButton.cpp b/src/widgets/CustomToolButton.cpp
index 888d593..b7fd646 100644
--- a/src/widgets/CustomToolButton.cpp
+++ b/src/widgets/CustomToolButton.cpp
@@ -25,7 +25,7 @@ CustomToolButton::CustomToolButton(QWidget *parent) : QToolButton(parent)
{
setCheckable(true);
setAutoRaise(true);
- setIconSize(QSize(24, 24));
+ setIconSize(ScaledSizeProvider::scaledSize(QSize(24, 24)));
setFocusPolicy(Qt::NoFocus);
connect(this, &CustomToolButton::triggered, this, &CustomToolButton::setActiveAction);
}
diff --git a/src/widgets/CustomToolButton.h b/src/widgets/CustomToolButton.h
index 7b70a48..8ac84fe 100644
--- a/src/widgets/CustomToolButton.h
+++ b/src/widgets/CustomToolButton.h
@@ -24,6 +24,8 @@
#include <QAction>
#include <QMenu>
+#include "src/common/provider/ScaledSizeProvider.h"
+
namespace kImageAnnotator {
class CustomToolButton : public QToolButton
diff --git a/src/widgets/CustomToolButtonAction.cpp b/src/widgets/CustomToolButtonAction.cpp
index 136594b..7fcfd6a 100644
--- a/src/widgets/CustomToolButtonAction.cpp
+++ b/src/widgets/CustomToolButtonAction.cpp
@@ -37,7 +37,7 @@ CustomToolButtonAction::~CustomToolButtonAction()
void CustomToolButtonAction::updateDefaultWidget()
{
mText->setText(toolTip());
- mImage->setPixmap(icon().pixmap(Constants::MenuItemIconSize));
+ mImage->setPixmap(icon().pixmap(ScaledSizeProvider::menuItemIconSize()));
mMenuItem->setToolTip(toolTip());
setDefaultWidget(mMenuItem);
@@ -53,7 +53,7 @@ void CustomToolButtonAction::initDefaultWidget()
mLayout->addWidget(mImage);
mLayout->addWidget(mText);
mMenuItem->setLayout(mLayout);
- mMenuItem->setStyleSheet(QStringLiteral(":hover{background-color:palette(highlight);}"));
+ mMenuItem->setStyleSheet(QLatin1String(":hover{background-color:palette(highlight);}"));
}
}
diff --git a/src/widgets/CustomToolButtonAction.h b/src/widgets/CustomToolButtonAction.h
index a290331..1e9303c 100644
--- a/src/widgets/CustomToolButtonAction.h
+++ b/src/widgets/CustomToolButtonAction.h
@@ -25,7 +25,7 @@
#include <QHBoxLayout>
#include <QWidget>
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/src/widgets/FillModePicker.cpp b/src/widgets/FillModePicker.cpp
index eea35d8..9cd9c92 100644
--- a/src/widgets/FillModePicker.cpp
+++ b/src/widgets/FillModePicker.cpp
@@ -61,16 +61,16 @@ void FillModePicker::initGui()
{
mLayout->setContentsMargins(0, 0, 0, 0);
- auto icon = IconLoader::load(QLatin1Literal("fillType.svg"));
- mLabel->setPixmap(icon.pixmap(Constants::SettingsWidgetIconSize));
+ auto icon = IconLoader::load(QLatin1String("fillType.svg"));
+ mLabel->setPixmap(icon.pixmap(ScaledSizeProvider::settingsWidgetIconSize()));
mLabel->setToolTip(tr("Border And Fill Visibility"));
- insertItem(FillModes::BorderAndFill, QLatin1Literal("fillType_borderAndFill.svg"), tr("Border and Fill"));
- insertItem(FillModes::BorderAndNoFill, QLatin1Literal("fillType_borderAndNoFill.svg"), tr("Border and No Fill"));
- insertItem(FillModes::NoBorderAndNoFill, QLatin1Literal("fillType_noBorderAndNoFill.svg"), tr("No Border and No Fill"));
+ insertItem(FillModes::BorderAndFill, QLatin1String("fillType_borderAndFill.svg"), tr("Border and Fill"));
+ insertItem(FillModes::BorderAndNoFill, QLatin1String("fillType_borderAndNoFill.svg"), tr("Border and No Fill"));
+ insertItem(FillModes::NoBorderAndNoFill, QLatin1String("fillType_noBorderAndNoFill.svg"), tr("No Border and No Fill"));
- mToolButton->setFixedSize(Constants::SettingsWidgetSize);
- mToolButton->setIconSize(Constants::ToolButtonIconSize);
+ mToolButton->setFixedSize(ScaledSizeProvider::settingsWidgetSize());
+ mToolButton->setIconSize(ScaledSizeProvider::toolButtonIconSize());
mToolButton->setFocusPolicy(Qt::NoFocus);
connect(mToolButton, &ListMenuToolButton::selectionChanged, this, &FillModePicker::selectionChanged);
diff --git a/src/widgets/FillModePicker.h b/src/widgets/FillModePicker.h
index 319d02b..5a9266e 100644
--- a/src/widgets/FillModePicker.h
+++ b/src/widgets/FillModePicker.h
@@ -28,9 +28,9 @@
#include <QAction>
#include "src/widgets/menuButtons/ListMenuToolButton.h"
-#include "src/common/constants/Constants.h"
#include "src/common/enum/FillModes.h"
#include "src/common/helper/IconLoader.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/src/widgets/ImageEffectPicker.cpp b/src/widgets/ImageEffectPicker.cpp
index 15ce61c..e8ac5ab 100644
--- a/src/widgets/ImageEffectPicker.cpp
+++ b/src/widgets/ImageEffectPicker.cpp
@@ -51,17 +51,17 @@ void ImageEffectPicker::initGui()
{
mLayout->setContentsMargins(0, 0, 0, 0);
- auto icon = IconLoader::load(QLatin1Literal("effect.svg"));
- mLabel->setPixmap(icon.pixmap(Constants::SettingsWidgetIconSize));
+ auto icon = IconLoader::load(QLatin1String("effect.svg"));
+ mLabel->setPixmap(icon.pixmap(ScaledSizeProvider::settingsWidgetIconSize()));
mLabel->setToolTip(tr("Image Effects"));
- insertItem(ImageEffects::NoEffect, QLatin1Literal("noImageEffect.svg"), tr("No Effect"));
- insertItem(ImageEffects::DropShadow, QLatin1Literal("dropShadowImageEffect.svg"), tr("Drop Shadow"));
- insertItem(ImageEffects::Grayscale, QLatin1Literal("grayscaleImageEffect.svg"), tr("Grayscale"));
- insertItem(ImageEffects::Border, QLatin1Literal("borderImageEffect.svg"), tr("Border"));
+ insertItem(ImageEffects::NoEffect, QLatin1String("noImageEffect.svg"), tr("No Effect"));
+ insertItem(ImageEffects::DropShadow, QLatin1String("dropShadowImageEffect.svg"), tr("Drop Shadow"));
+ insertItem(ImageEffects::Grayscale, QLatin1String("grayscaleImageEffect.svg"), tr("Grayscale"));
+ insertItem(ImageEffects::Border, QLatin1String("borderImageEffect.svg"), tr("Border"));
- mToolButton->setFixedSize(Constants::SettingsWidgetSize);
- mToolButton->setIconSize(Constants::ToolButtonIconSize);
+ mToolButton->setFixedSize(ScaledSizeProvider::settingsWidgetSize());
+ mToolButton->setIconSize(ScaledSizeProvider::toolButtonIconSize());
mToolButton->setFocusPolicy(Qt::NoFocus);
connect(mToolButton, &ListMenuToolButton::selectionChanged, this, &ImageEffectPicker::selectionChanged);
diff --git a/src/widgets/ImageEffectPicker.h b/src/widgets/ImageEffectPicker.h
index 16a02a6..63a4a42 100644
--- a/src/widgets/ImageEffectPicker.h
+++ b/src/widgets/ImageEffectPicker.h
@@ -28,7 +28,7 @@
#include <QAction>
#include "src/widgets/menuButtons/ListMenuToolButton.h"
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
#include "src/common/enum/ImageEffects.h"
#include "src/common/helper/IconLoader.h"
diff --git a/src/widgets/NumberPicker.cpp b/src/widgets/NumberPicker.cpp
index 3c198de..6cbcb78 100644
--- a/src/widgets/NumberPicker.cpp
+++ b/src/widgets/NumberPicker.cpp
@@ -48,9 +48,9 @@ void NumberPicker::initGui()
{
mLayout->setContentsMargins(0, 0, 0, 0);
- mLabel->setFixedSize(Constants::SettingsWidgetIconSize);
+ mLabel->setFixedSize(ScaledSizeProvider::settingsWidgetIconSize());
- mSpinBox->setFixedSize(Constants::SettingsWidgetSize);
+ mSpinBox->setFixedSize(ScaledSizeProvider::settingsWidgetSize());
mSpinBox->setMinimum(1);
mSpinBox->setMaximum(20);
mSpinBox->setFocusPolicy(Qt::NoFocus);
@@ -93,7 +93,7 @@ void NumberPicker::setToolTip(const QString &toolTip)
void NumberPicker::setIcon(const QIcon &icon)
{
- mLabel->setPixmap(icon.pixmap(Constants::SettingsWidgetIconSize));
+ mLabel->setPixmap(icon.pixmap(ScaledSizeProvider::settingsWidgetIconSize()));
}
} // namespace kImageAnnotator
diff --git a/src/widgets/NumberPicker.h b/src/widgets/NumberPicker.h
index ed389ac..59ae0cc 100644
--- a/src/widgets/NumberPicker.h
+++ b/src/widgets/NumberPicker.h
@@ -26,7 +26,7 @@
#include <QIcon>
#include "CustomSpinBox.h"
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/src/widgets/StickerPicker.cpp b/src/widgets/StickerPicker.cpp
index e268cc8..13d3939 100644
--- a/src/widgets/StickerPicker.cpp
+++ b/src/widgets/StickerPicker.cpp
@@ -51,12 +51,12 @@ void StickerPicker::init()
{
mLayout->setContentsMargins(0, 0, 0, 0);
- auto icon = IconLoader::load(QLatin1Literal("sticker.svg"));
- mLabel->setPixmap(icon.pixmap(Constants::SettingsWidgetIconSize));
+ auto icon = IconLoader::load(QLatin1String("sticker.svg"));
+ mLabel->setPixmap(icon.pixmap(ScaledSizeProvider::settingsWidgetIconSize()));
mLabel->setToolTip(tr("Sticker"));
- mToolButton->setFixedSize(Constants::SettingsWidgetSize);
- mToolButton->setIconSize(Constants::ToolButtonIconSize);
+ mToolButton->setFixedSize(ScaledSizeProvider::settingsWidgetSize());
+ mToolButton->setIconSize(ScaledSizeProvider::toolButtonIconSize());
mToolButton->setFocusPolicy(Qt::NoFocus);
mToolButton->setPopupMode(QToolButton::InstantPopup);
@@ -73,23 +73,23 @@ void StickerPicker::init()
void StickerPicker::addDefaultStickers()
{
- QStringList defaultStickers{ QLatin1Literal("face_blowing_a_kiss"),
- QLatin1Literal("face_savoring_food"),
- QLatin1Literal("grinning_face_with_big_eyes"),
- QLatin1Literal("grinning_face_with_smiling_eyes"),
- QLatin1Literal("grinning_face_with_sweat"),
- QLatin1Literal("grinning_squinting_face"),
- QLatin1Literal("hushed_face"),
- QLatin1Literal("nerd_face"),
- QLatin1Literal("neutral_face"),
- QLatin1Literal("smiling_face_with_heart_eyes"),
- QLatin1Literal("smiling_face_with_hearts"),
- QLatin1Literal("confused_face"),
- QLatin1Literal("face_with_symbols_on_mouth"),
- QLatin1Literal("pouting_face"),
- QLatin1Literal("smiling_face_with_sunglasses"),
- QLatin1Literal("check_mark"),
- QLatin1Literal("cross_mark")
+ QStringList defaultStickers{ QLatin1String("face_blowing_a_kiss"),
+ QLatin1String("face_savoring_food"),
+ QLatin1String("grinning_face_with_big_eyes"),
+ QLatin1String("grinning_face_with_smiling_eyes"),
+ QLatin1String("grinning_face_with_sweat"),
+ QLatin1String("grinning_squinting_face"),
+ QLatin1String("hushed_face"),
+ QLatin1String("nerd_face"),
+ QLatin1String("neutral_face"),
+ QLatin1String("smiling_face_with_heart_eyes"),
+ QLatin1String("smiling_face_with_hearts"),
+ QLatin1String("confused_face"),
+ QLatin1String("face_with_symbols_on_mouth"),
+ QLatin1String("pouting_face"),
+ QLatin1String("smiling_face_with_sunglasses"),
+ QLatin1String("check_mark"),
+ QLatin1String("cross_mark")
};
for(const auto& sticker : defaultStickers) {
@@ -97,9 +97,9 @@ void StickerPicker::addDefaultStickers()
}
}
-QString StickerPicker::getResourcePath(const QString &name) const
+QString StickerPicker::getResourcePath(const QString &name)
{
- return QLatin1Literal(":/stickers/") + name + QLatin1Literal(".svg");
+ return QLatin1String(":/stickers/") + name + QLatin1String(".svg");
}
void StickerPicker::addItem(const QString &path)
diff --git a/src/widgets/StickerPicker.h b/src/widgets/StickerPicker.h
index 9abb940..154e84e 100644
--- a/src/widgets/StickerPicker.h
+++ b/src/widgets/StickerPicker.h
@@ -25,7 +25,7 @@
#include <QLabel>
#include "src/widgets/menuButtons/GridMenuToolButton.h"
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
#include "src/common/helper/IconLoader.h"
#include "src/common/helper/PathHelper.h"
@@ -55,7 +55,7 @@ private:
private slots:
void selectionChanged();
- QString getResourcePath(const QString &name) const;
+ static QString getResourcePath(const QString &name);
void addDefaultStickers();
};
diff --git a/src/widgets/ToolPicker.cpp b/src/widgets/ToolPicker.cpp
index b65e0b7..fc5f145 100644
--- a/src/widgets/ToolPicker.cpp
+++ b/src/widgets/ToolPicker.cpp
@@ -55,71 +55,71 @@ void ToolPicker::initGui()
mActionGroup = new QActionGroup(this);
connect(mActionGroup, &QActionGroup::triggered, this, &ToolPicker::actionTriggered);
- auto action = createAction(tr("Select"), IconLoader::load(QLatin1Literal("select.svg")), Qt::Key_S, Tools::Select);
+ auto action = createAction(tr("Select"), IconLoader::load(QLatin1String("select.svg")), Qt::Key_S, Tools::Select);
auto button = createButton(action);
mLayout->addWidget(button, 0, 0);
auto menu = new QMenu();
- action = createAction(tr("Arrow"), IconLoader::load(QLatin1Literal("arrow.svg")), Qt::Key_A, Tools::Arrow);
+ action = createAction(tr("Arrow"), IconLoader::load(QLatin1String("arrow.svg")), Qt::Key_A, Tools::Arrow);
menu->addAction(action);
- action = createAction(tr("Double Arrow"), IconLoader::load(QLatin1Literal("doubleArrow.svg")), Qt::Key_D, Tools::DoubleArrow);
+ action = createAction(tr("Double Arrow"), IconLoader::load(QLatin1String("doubleArrow.svg")), Qt::Key_D, Tools::DoubleArrow);
menu->addAction(action);
- action = createAction(tr("Line"), IconLoader::load(QLatin1Literal("line.svg")), Qt::Key_L, Tools::Line);
+ action = createAction(tr("Line"), IconLoader::load(QLatin1String("line.svg")), Qt::Key_L, Tools::Line);
menu->addAction(action);
button = createButton(menu);
mLayout->addWidget(button, 0, 1);
- action = createAction(tr("Pen"), IconLoader::load(QLatin1Literal("pen.svg")), Qt::Key_P, Tools::Pen);
+ action = createAction(tr("Pen"), IconLoader::load(QLatin1String("pen.svg")), Qt::Key_P, Tools::Pen);
button = createButton(action);
mLayout->addWidget(button, 1, 0);
menu = new QMenu();
- action = createAction(tr("Marker Rectangle"), IconLoader::load(QLatin1Literal("markerRect.svg")), Qt::Key_J, Tools::MarkerRect);
+ action = createAction(tr("Marker Rectangle"), IconLoader::load(QLatin1String("markerRect.svg")), Qt::Key_J, Tools::MarkerRect);
menu->addAction(action);
- action = createAction(tr("Marker Ellipse"), IconLoader::load(QLatin1Literal("markerEllipse.svg")), Qt::Key_K, Tools::MarkerEllipse);
+ action = createAction(tr("Marker Ellipse"), IconLoader::load(QLatin1String("markerEllipse.svg")), Qt::Key_K, Tools::MarkerEllipse);
menu->addAction(action);
- action = createAction(tr("Marker Pen"), IconLoader::load(QLatin1Literal("markerPen.svg")), Qt::Key_M, Tools::MarkerPen);
+ action = createAction(tr("Marker Pen"), IconLoader::load(QLatin1String("markerPen.svg")), Qt::Key_M, Tools::MarkerPen);
menu->addAction(action);
button = createButton(menu);
mLayout->addWidget(button, 1, 1);
menu = new QMenu();
- action = createAction(tr("Text"), IconLoader::load(QLatin1Literal("text.svg")), Qt::Key_T, Tools::Text);
+ action = createAction(tr("Text"), IconLoader::load(QLatin1String("text.svg")), Qt::Key_T, Tools::Text);
menu->addAction(action);
- action = createAction(tr("Text Pointer"), IconLoader::load(QLatin1Literal("textPointer.svg")), Qt::Key_C, Tools::TextPointer);
+ action = createAction(tr("Text Pointer"), IconLoader::load(QLatin1String("textPointer.svg")), Qt::Key_C, Tools::TextPointer);
menu->addAction(action);
- action = createAction(tr("Text Arrow"), IconLoader::load(QLatin1Literal("textArrow.svg")), Qt::Key_H, Tools::TextArrow);
+ action = createAction(tr("Text Arrow"), IconLoader::load(QLatin1String("textArrow.svg")), Qt::Key_H, Tools::TextArrow);
menu->addAction(action);
button = createButton(menu);
mLayout->addWidget(button, 2, 0);
menu = new QMenu();
- action = createAction(tr("Number"), IconLoader::load(QLatin1Literal("number.svg")), Qt::Key_N, Tools::Number);
+ action = createAction(tr("Number"), IconLoader::load(QLatin1String("number.svg")), Qt::Key_N, Tools::Number);
menu->addAction(action);
- action = createAction(tr("Number Pointer"), IconLoader::load(QLatin1Literal("numberPointer.svg")), Qt::Key_O, Tools::NumberPointer);
+ action = createAction(tr("Number Pointer"), IconLoader::load(QLatin1String("numberPointer.svg")), Qt::Key_O, Tools::NumberPointer);
menu->addAction(action);
- action = createAction(tr("Number Arrow"), IconLoader::load(QLatin1Literal("numberArrow.svg")), Qt::Key_W, Tools::NumberArrow);
+ action = createAction(tr("Number Arrow"), IconLoader::load(QLatin1String("numberArrow.svg")), Qt::Key_W, Tools::NumberArrow);
menu->addAction(action);
button = createButton(menu);
mLayout->addWidget(button, 2, 1);
menu = new QMenu();
- action = createAction(tr("Blur"), IconLoader::load(QLatin1Literal("blur.svg")), Qt::Key_B, Tools::Blur);
+ action = createAction(tr("Blur"), IconLoader::load(QLatin1String("blur.svg")), Qt::Key_B, Tools::Blur);
menu->addAction(action);
- action = createAction(tr("Pixelate"), IconLoader::load(QLatin1Literal("pixelate.svg")), Qt::Key_X, Tools::Pixelate);
+ action = createAction(tr("Pixelate"), IconLoader::load(QLatin1String("pixelate.svg")), Qt::Key_X, Tools::Pixelate);
menu->addAction(action);
button = createButton(menu);
mLayout->addWidget(button, 3, 0);
menu = new QMenu();
- action = createAction(tr("Rectangle"), IconLoader::load(QLatin1Literal("rect.svg")), Qt::Key_R, Tools::Rect);
+ action = createAction(tr("Rectangle"), IconLoader::load(QLatin1String("rect.svg")), Qt::Key_R, Tools::Rect);
menu->addAction(action);
- action = createAction(tr("Ellipse"), IconLoader::load(QLatin1Literal("ellipse.svg")), Qt::Key_E, Tools::Ellipse);
+ action = createAction(tr("Ellipse"), IconLoader::load(QLatin1String("ellipse.svg")), Qt::Key_E, Tools::Ellipse);
menu->addAction(action);
button = createButton(menu);
mLayout->addWidget(button, 3, 1);
- action = createAction(tr("Sticker"), IconLoader::load(QLatin1Literal("sticker.svg")), Qt::Key_I, Tools::Sticker);
+ action = createAction(tr("Sticker"), IconLoader::load(QLatin1String("sticker.svg")), Qt::Key_I, Tools::Sticker);
button = createButton(action);
mLayout->addWidget(button, 4, 0);
@@ -133,7 +133,7 @@ QAction *ToolPicker::createAction(const QString &tooltip, const QIcon &icon, Qt:
action->setCheckable(true);
action->setIcon(icon);
action->setShortcut(shortcut);
- action->setToolTip(tooltip + QLatin1Literal(" (") + shortcut + QLatin1Literal(")"));
+ action->setToolTip(tooltip + QLatin1String(" (") + shortcut + QLatin1String(")"));
action->updateDefaultWidget();
mActionToTool[action] = toolType;
mActionGroup->addAction(action);
diff --git a/src/widgets/ZoomIndicator.cpp b/src/widgets/ZoomIndicator.cpp
index 357e432..37b3e9f 100644
--- a/src/widgets/ZoomIndicator.cpp
+++ b/src/widgets/ZoomIndicator.cpp
@@ -33,17 +33,17 @@ ZoomIndicator::ZoomIndicator(QWidget *parent) :
void ZoomIndicator::init()
{
mLayout->setContentsMargins(0, 0, 0, 0);
-
- auto icon = IconLoader::load(QLatin1Literal("zoom.svg"));
- mLabel->setPixmap(icon.pixmap(SettingsWidgetIconSize));
+
+ auto icon = IconLoader::load(QLatin1String("zoom.svg"));
+ mLabel->setPixmap(icon.pixmap(ScaledSizeProvider::settingsWidgetIconSize()));
mLabel->setToolTip(tr("Zoom Level"));
- mSpinBox->setFixedSize(SettingsWidgetSize);
+ mSpinBox->setFixedSize(ScaledSizeProvider::settingsWidgetSize());
mSpinBox->setFocusPolicy(Qt::NoFocus);
mSpinBox->setReadOnly(true);
mSpinBox->setRange(0, 800);
mSpinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
- mSpinBox->setSuffix(QLatin1Literal("%"));
+ mSpinBox->setSuffix(QLatin1String("%"));
mSpinBox->setToolTip(mLabel->toolTip());
mLayout->addWidget(mLabel);
diff --git a/src/widgets/ZoomIndicator.h b/src/widgets/ZoomIndicator.h
index e86107f..22c7208 100644
--- a/src/widgets/ZoomIndicator.h
+++ b/src/widgets/ZoomIndicator.h
@@ -26,7 +26,7 @@
#include <QHBoxLayout>
#include "src/common/helper/IconLoader.h"
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/src/widgets/menuButtons/GridMenuButton.cpp b/src/widgets/menuButtons/GridMenuButton.cpp
index 23b9e7c..c102c37 100644
--- a/src/widgets/menuButtons/GridMenuButton.cpp
+++ b/src/widgets/menuButtons/GridMenuButton.cpp
@@ -27,9 +27,9 @@ GridMenuButton::GridMenuButton(const QIcon &icon, const QString &toolTip, QVaria
setIcon(icon);
setToolTip(toolTip);
- setIconSize(QSize(32, 32));
+ setIconSize(ScaledSizeProvider::scaledSize(QSize(32, 32)));
setCheckable(true);
- setFixedSize(iconSize() + QSize(4,4));
+ setFixedSize(iconSize() + ScaledSizeProvider::scaledSize(QSize(4,4)));
}
QVariant kImageAnnotator::GridMenuButton::data() const
@@ -43,9 +43,7 @@ void GridMenuButton::paintEvent(QPaintEvent *event)
QStyleOption styleOption;
styleOption.initFrom(this);
auto buttonRect = event->rect().adjusted(0, 0, -1, -1);
-
- qDebug("Pen w %s", qPrintable(QString::number(painter.pen().widthF())));
-
+
if(styleOption.state & QStyle::State_MouseOver)
{
auto defaultPen = painter.pen();
diff --git a/src/widgets/menuButtons/GridMenuButton.h b/src/widgets/menuButtons/GridMenuButton.h
index 49ce72c..829ed34 100644
--- a/src/widgets/menuButtons/GridMenuButton.h
+++ b/src/widgets/menuButtons/GridMenuButton.h
@@ -26,7 +26,7 @@
#include <QPainter>
#include <QPaintEvent>
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/src/widgets/menuButtons/ListMenuItem.cpp b/src/widgets/menuButtons/ListMenuItem.cpp
index bab98f9..eb9cbf3 100644
--- a/src/widgets/menuButtons/ListMenuItem.cpp
+++ b/src/widgets/menuButtons/ListMenuItem.cpp
@@ -33,7 +33,7 @@ ListMenuItem::ListMenuItem(const QIcon &icon, const QString &text, const QVarian
{
setMouseTracking(true);
- mIconSize = Constants::MenuItemIconSize;
+ mIconSize = ScaledSizeProvider::menuItemIconSize();
auto offsetForTextWidth = 1.15; // Width not correct calculated on windows #117
mTextSize = QSize(fontMetrics().width(mText) * offsetForTextWidth, fontMetrics().height());
mIconOffset = QPoint(mMargin, mMargin);
diff --git a/src/widgets/menuButtons/ListMenuItem.h b/src/widgets/menuButtons/ListMenuItem.h
index c6a4c0a..3677922 100644
--- a/src/widgets/menuButtons/ListMenuItem.h
+++ b/src/widgets/menuButtons/ListMenuItem.h
@@ -25,7 +25,7 @@
#include <QPaintEvent>
#include <QMouseEvent>
-#include "src/common/constants/Constants.h"
+#include "src/common/provider/ScaledSizeProvider.h"
namespace kImageAnnotator {
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e23b94d..80c72f7 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -54,7 +54,13 @@ set(TESTUTILS_SRC
add_library(KIMAGEANNOTATOR_STATIC STATIC ${KIMAGEANNOTATOR_SRCS})
-target_link_libraries(KIMAGEANNOTATOR_STATIC Qt5::Widgets Qt5::Svg kImageAnnotator)
+target_link_libraries(KIMAGEANNOTATOR_STATIC Qt5::Widgets Qt5::Svg kImageAnnotator kColorPicker::kColorPicker)
+
+if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.14.0)
+ target_link_libraries(KIMAGEANNOTATOR_STATIC X11::X11)
+else()
+ target_link_libraries(KIMAGEANNOTATOR_STATIC X11)
+endif()
foreach (UnitTest ${UNITTEST_SRC})
get_filename_component(UnitTestName ${UnitTest} NAME_WE)
diff --git a/tests/annotations/items/helper/TextCursorTest.cpp b/tests/annotations/items/helper/TextCursorTest.cpp
index 603d164..f59f649 100644
--- a/tests/annotations/items/helper/TextCursorTest.cpp
+++ b/tests/annotations/items/helper/TextCursorTest.cpp
@@ -23,7 +23,7 @@
void TextCursorTest::TestMove_Should_MoveCursorByOnePointToRight_When_DirectionNext()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
QCOMPARE(textCursor.position(), 0);
@@ -33,10 +33,10 @@ void TextCursorTest::TestMove_Should_MoveCursorByOnePointToRight_When_DirectionN
QCOMPARE(textCursor.position(), 1);
}
-void TextCursorTest::TestMove_Should_MoveCursorByOnePointToLeft_When_DirectionPreviouse()
+void TextCursorTest::TestMove_Should_MoveCursorByOnePointToLeft_When_DirectionPrevious()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Next, text);
@@ -47,10 +47,10 @@ void TextCursorTest::TestMove_Should_MoveCursorByOnePointToLeft_When_DirectionPr
QCOMPARE(textCursor.position(), 0);
}
-void TextCursorTest::TestMove_Should_MoveCursorToEnd_When_DirectionPreviouseAndCurrentPositionAtStart()
+void TextCursorTest::TestMove_Should_MoveCursorToEnd_When_DirectionPreviousAndCurrentPositionAtStart()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
QCOMPARE(textCursor.position(), 0);
@@ -63,7 +63,7 @@ void TextCursorTest::TestMove_Should_MoveCursorToEnd_When_DirectionPreviouseAndC
void TextCursorTest::TestMove_Should_MoveCursorToStart_When_DirectionNextAndCurrentPositionAtEnd()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Previous, text);
@@ -77,7 +77,7 @@ void TextCursorTest::TestMove_Should_MoveCursorToStart_When_DirectionNextAndCurr
void TextCursorTest::TestMove_Should_MoveCursorToNextLineSamePosition_When_DirectionDown()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
QCOMPARE(textCursor.position(), 0);
@@ -90,7 +90,7 @@ void TextCursorTest::TestMove_Should_MoveCursorToNextLineSamePosition_When_Direc
void TextCursorTest::TestMove_Should_NotMoveCursor_When_DirectionDownAndInLastLine()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Down, text);
@@ -105,7 +105,7 @@ void TextCursorTest::TestMove_Should_NotMoveCursor_When_DirectionDownAndInLastLi
void TextCursorTest::TestMove_Should_NotMoveCursor_When_DirectionUpAndInFirstLine()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
QCOMPARE(textCursor.position(), 0);
@@ -118,7 +118,7 @@ void TextCursorTest::TestMove_Should_NotMoveCursor_When_DirectionUpAndInFirstLin
void TextCursorTest::TestMove_Should_MoveCursorToPreviousLineSamePosition_When_DirectionUpAndNotInFirstLine()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Down, text);
@@ -133,7 +133,7 @@ void TextCursorTest::TestMove_Should_MoveCursorToPreviousLineSamePosition_When_D
void TextCursorTest::TestMove_Should_MoveCursorToEndOfNextLine_When_DirectionDownAndPositionAtEndOfLineAndLineBelowIsSmaller()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Next, text);
@@ -150,7 +150,7 @@ void TextCursorTest::TestMove_Should_MoveCursorToEndOfNextLine_When_DirectionDow
void TextCursorTest::TestMove_Should_MoveCursorToEndOfPreviousLine_When_DirectionUpAndPositionAtEndOfLineAndLineAboveIsSmaller()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Down, text);
@@ -172,7 +172,7 @@ void TextCursorTest::TestMove_Should_MoveCursorToEndOfPreviousLine_When_Directio
void TextCursorTest::TestMove_Should_MoveCursorToSamePositionOfPreviousLine_When_DirectionUpAndPositionAtEndOfLineAndLineAboveIsLarger()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Down, text);
@@ -189,7 +189,7 @@ void TextCursorTest::TestMove_Should_MoveCursorToSamePositionOfPreviousLine_When
void TextCursorTest::TestMove_Should_MoveCursorToSamePositionOfNextLine_When_DirectionDownAndPositionAtEndOfLineAndLineBelowIsLarger()
{
TextCursor textCursor;
- QString text = QStringLiteral("Test\n"
+ QString text = QLatin1String("Test\n"
"123\n"
"test123");
textCursor.move(TextPositions::Down, text);
@@ -203,4 +203,32 @@ void TextCursorTest::TestMove_Should_MoveCursorToSamePositionOfNextLine_When_Dir
QCOMPARE(textCursor.position(), 12);
}
+void TextCursorTest::TestMoveForwardBy_Should_MoveCursorForwardByRequestedSteps()
+{
+ TextCursor textCursor;
+ QString text = QLatin1String("Test\n"
+ "123\n"
+ "test123");
+ QCOMPARE(textCursor.position(), 0);
+
+ textCursor.moveForwardBy(text, 2);
+
+ QCOMPARE(textCursor.position(), 2);
+}
+
+void TextCursorTest::TestMoveForwardBy_Should_MoveCursorToStartPlusRemainingSteps_When_RequestedSteps_LargerThenTextLength()
+{
+ TextCursor textCursor;
+ QString text = QLatin1String("Test\n"
+ "123\n"
+ "test123");
+ textCursor.move(TextPositions::Previous, text);
+ textCursor.move(TextPositions::Previous, text);
+ QCOMPARE(textCursor.position(), text.length() - 1);
+
+ textCursor.moveForwardBy(text, 3);
+
+ QCOMPARE(textCursor.position(), 1);
+}
+
QTEST_MAIN(TextCursorTest);
diff --git a/tests/annotations/items/helper/TextCursorTest.h b/tests/annotations/items/helper/TextCursorTest.h
index 93285ea..d681a7d 100644
--- a/tests/annotations/items/helper/TextCursorTest.h
+++ b/tests/annotations/items/helper/TextCursorTest.h
@@ -33,8 +33,8 @@ Q_OBJECT
private slots:
void TestMove_Should_MoveCursorByOnePointToRight_When_DirectionNext();
- void TestMove_Should_MoveCursorByOnePointToLeft_When_DirectionPreviouse();
- void TestMove_Should_MoveCursorToEnd_When_DirectionPreviouseAndCurrentPositionAtStart();
+ void TestMove_Should_MoveCursorByOnePointToLeft_When_DirectionPrevious();
+ void TestMove_Should_MoveCursorToEnd_When_DirectionPreviousAndCurrentPositionAtStart();
void TestMove_Should_MoveCursorToStart_When_DirectionNextAndCurrentPositionAtEnd();
void TestMove_Should_MoveCursorToNextLineSamePosition_When_DirectionDown();
void TestMove_Should_NotMoveCursor_When_DirectionDownAndInLastLine();
@@ -44,6 +44,8 @@ private slots:
void TestMove_Should_MoveCursorToEndOfPreviousLine_When_DirectionUpAndPositionAtEndOfLineAndLineAboveIsSmaller();
void TestMove_Should_MoveCursorToSamePositionOfPreviousLine_When_DirectionUpAndPositionAtEndOfLineAndLineAboveIsLarger();
void TestMove_Should_MoveCursorToSamePositionOfNextLine_When_DirectionDownAndPositionAtEndOfLineAndLineBelowIsLarger();
+ void TestMoveForwardBy_Should_MoveCursorForwardByRequestedSteps();
+ void TestMoveForwardBy_Should_MoveCursorToStartPlusRemainingSteps_When_RequestedSteps_LargerThenTextLength();
};
#endif // KIMAGEANNOTATOR_TEXTCURSORTEST_H
diff --git a/tests/annotations/modifiers/AnnotationItemModifierTest.cpp b/tests/annotations/modifiers/AnnotationItemModifierTest.cpp
index 916348a..c90dab6 100644
--- a/tests/annotations/modifiers/AnnotationItemModifierTest.cpp
+++ b/tests/annotations/modifiers/AnnotationItemModifierTest.cpp
@@ -39,7 +39,7 @@ void AnnotationItemModifierTest::TestHandleMousePressMoveRelease_Should_MoveResi
modifer.handleMouseRelease(&items);
modifer.handleMousePress(p1, &items, false);
- modifer.handleMouseMove(p3);
+ modifer.handleMouseMove(p3, false);
QCOMPARE(line.line().p1(), p3);
QCOMPARE(line.line().p2(), p2);
@@ -62,7 +62,7 @@ void AnnotationItemModifierTest::TestHandleMousePressMove_Should_NotMoveResizerH
modifer.handleMouseRelease(&items);
modifer.handleMousePress(p3, &items, false);
- modifer.handleMouseMove(p4);
+ modifer.handleMouseMove(p4, false);
QCOMPARE(line.line().p1(), p1);
QCOMPARE(line.line().p2(), p2);
@@ -87,7 +87,7 @@ void AnnotationItemModifierTest::TestHandleMousePressMoveRelease_Should_SelectMu
AnnotationItemModifier modifer(&zoomValueProvider);
modifer.handleMousePress(p1 + QPointF(-5, -5), &items, false);
- modifer.handleMouseMove(p4 + QPointF(5, 5));
+ modifer.handleMouseMove(p4 + QPointF(5, 5), false);
modifer.handleMouseRelease(&items);
auto results = modifer.selectedItems();
@@ -113,7 +113,7 @@ void AnnotationItemModifierTest::TestHandleMousePressMove_Should_MoveClickedItem
connect(&modifer, &AnnotationItemModifier::newCommand, &undoStack, &QUndoStack::push);
modifer.handleMousePress(clickPos, &items, false);
- modifer.handleMouseMove(movePos);
+ modifer.handleMouseMove(movePos, false);
QCOMPARE(line.boundingRect().topLeft(), movePos - (clickPos - p1));
}
@@ -140,12 +140,12 @@ void AnnotationItemModifierTest::TestHandleMousePressMove_Should_MoveSelectedIte
QUndoStack undoStack;
connect(&modifer, &AnnotationItemModifier::newCommand, &undoStack, &QUndoStack::push);
modifer.handleMousePress(p1 + QPointF(-5, -5), &items, false);
- modifer.handleMouseMove(p4 + QPointF(5, 5));
+ modifer.handleMouseMove(p4 + QPointF(5, 5), false);
modifer.handleMouseRelease(&items);
QCOMPARE(modifer.selectedItems().count(), 2);
modifer.handleMousePress(clickPos, &items, false);
- modifer.handleMouseMove(movePos);
+ modifer.handleMouseMove(movePos, false);
QCOMPARE(line1.boundingRect().topLeft(), movePos - (clickPos - p1));
QCOMPARE(line2.boundingRect().topLeft(), movePos - (clickPos - p3));
diff --git a/tests/annotations/modifiers/AnnotationItemResizerTest.cpp b/tests/annotations/modifiers/AnnotationItemResizerTest.cpp
index 95c7e2d..62d288f 100644
--- a/tests/annotations/modifiers/AnnotationItemResizerTest.cpp
+++ b/tests/annotations/modifiers/AnnotationItemResizerTest.cpp
@@ -67,7 +67,7 @@ void AnnotationItemResizerTest::TestGrabHandle_Should_MoveResizeHandle_When_Hand
connect(&itemResizer, &AnnotationItemResizer::newCommand, &undoStack, &QUndoStack::push);
itemResizer.grabHandle(p1);
- itemResizer.moveHandle(p3);
+ itemResizer.moveHandle(p3, false);
QCOMPARE(lineItem.line().p1(), p3);
}
diff --git a/tests/annotations/modifiers/AnnotationMultiItemResizerTest.cpp b/tests/annotations/modifiers/AnnotationMultiItemResizerTest.cpp
index cf584ee..9a0f601 100644
--- a/tests/annotations/modifiers/AnnotationMultiItemResizerTest.cpp
+++ b/tests/annotations/modifiers/AnnotationMultiItemResizerTest.cpp
@@ -32,7 +32,7 @@ void AnnotationMultiItemResizerTest::TestGrabHandle_Should_GrabHandle_When_Provi
AnnotationMultiItemResizer itemResizer(&zoomValueProvider);
itemResizer.attachTo(items);
- itemResizer.grabHandle(line1.p1(), false);
+ itemResizer.grabHandle(line1.p1());
QCOMPARE(itemResizer.isResizing(), true);
}
@@ -48,7 +48,7 @@ void AnnotationMultiItemResizerTest::TestGrabHandle_Should_NotGrabHandle_When_Pr
AnnotationMultiItemResizer itemResizer(&zoomValueProvider);
itemResizer.attachTo(items);
- itemResizer.grabHandle(line1.p1() + QPointF(-10, -10), false);
+ itemResizer.grabHandle(line1.p1() + QPointF(-10, -10));
QCOMPARE(itemResizer.isResizing(), false);
}
@@ -67,8 +67,8 @@ void AnnotationMultiItemResizerTest::TestGrabHandle_Should_MoveResizeHandle_When
connect(&itemResizer, &AnnotationMultiItemResizer::newCommand, &undoStack, &QUndoStack::push);
itemResizer.attachTo(items);
- itemResizer.grabHandle(line1.p1(), false);
- itemResizer.moveHandle(newPoint);
+ itemResizer.grabHandle(line1.p1());
+ itemResizer.moveHandle(newPoint, false);
QCOMPARE(item1.line().p1(), newPoint);
}
@@ -90,8 +90,8 @@ void AnnotationMultiItemResizerTest::TestGrabHandle_Should_OnlyMoveOneResizeHand
connect(&itemResizer, &AnnotationMultiItemResizer::newCommand, &undoStack, &QUndoStack::push);
itemResizer.attachTo(items);
- itemResizer.grabHandle(line1.p1(), false);
- itemResizer.moveHandle(newPoint);
+ itemResizer.grabHandle(line1.p1());
+ itemResizer.moveHandle(newPoint, false);
QCOMPARE(item1.line().p1(), newPoint);
QCOMPARE(item1.line().p2(), line1.p2());
@@ -109,7 +109,7 @@ void AnnotationMultiItemResizerTest::TestReleaseHandle_Should_ReleaseHandle()
MockZoomValueProvider zoomValueProvider;
AnnotationMultiItemResizer itemResizer(&zoomValueProvider);
itemResizer.attachTo(items);
- itemResizer.grabHandle(line1.p1(), false);
+ itemResizer.grabHandle(line1.p1());
QCOMPARE(itemResizer.isResizing(), true);
itemResizer.releaseHandle();
diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt
index a619c24..499dcd7 100644
--- a/translations/CMakeLists.txt
+++ b/translations/CMakeLists.txt
@@ -18,6 +18,7 @@ set(KIMAGEANNOTATOR_LANG_TS
kImageAnnotator_no.ts
kImageAnnotator_pl.ts
kImageAnnotator_pt.ts
+ kImageAnnotator_pt_BR.ts
kImageAnnotator_ru.ts
kImageAnnotator_sv.ts
kImageAnnotator_tr.ts
diff --git a/translations/kImageAnnotator_de.ts b/translations/kImageAnnotator_de.ts
index ca131c3..73687ad 100644
--- a/translations/kImageAnnotator_de.ts
+++ b/translations/kImageAnnotator_de.ts
@@ -68,7 +68,7 @@
</message>
<message>
<source>Obfuscation Factor</source>
- <translation type="unfinished"></translation>
+ <translation>Obfuskierungs-Faktor</translation>
</message>
</context>
<context>
@@ -87,11 +87,11 @@
</message>
<message>
<source>Close All to the Left</source>
- <translation>Alle nach links schließen</translation>
+ <translation>Alle linksseitig schließen</translation>
</message>
<message>
<source>Close All to the Right</source>
- <translation>Alle nach rechts schließen</translation>
+ <translation>Alle rechtsseitig schließen</translation>
</message>
</context>
<context>
@@ -125,42 +125,42 @@
<name>kImageAnnotator::FillModePicker</name>
<message>
<source>Border And Fill Visibility</source>
- <translation type="unfinished">Sichtbarkeit von Rahmen und Füllungen</translation>
+ <translation>Sichtbarkeit von Rahmen und Füllungen</translation>
</message>
<message>
<source>Border and Fill</source>
- <translation type="unfinished">Rahmen und Füllung</translation>
+ <translation>Rahmen und Füllung</translation>
</message>
<message>
<source>Border and No Fill</source>
- <translation type="unfinished">Rahmen und keine Füllung</translation>
+ <translation>Rahmen und keine Füllung</translation>
</message>
<message>
<source>No Border and No Fill</source>
- <translation type="unfinished">Kein Rahmen und keine Füllung</translation>
+ <translation>Kein Rahmen und keine Füllung</translation>
</message>
</context>
<context>
<name>kImageAnnotator::ImageEffectPicker</name>
<message>
<source>Image Effects</source>
- <translation type="unfinished"></translation>
+ <translation>Bildeffekte</translation>
</message>
<message>
<source>No Effect</source>
- <translation type="unfinished"></translation>
+ <translation>Kein Effekt</translation>
</message>
<message>
<source>Drop Shadow</source>
- <translation type="unfinished"></translation>
+ <translation>Schlagschatten</translation>
</message>
<message>
<source>Grayscale</source>
- <translation type="unfinished"></translation>
+ <translation>Graustufen</translation>
</message>
<message>
<source>Border</source>
- <translation type="unfinished"></translation>
+ <translation>Rand</translation>
</message>
</context>
<context>
@@ -202,7 +202,7 @@
<name>kImageAnnotator::StickerPicker</name>
<message>
<source>Sticker</source>
- <translation type="unfinished">Aufkleber</translation>
+ <translation>Aufkleber</translation>
</message>
</context>
<context>
@@ -269,26 +269,26 @@
</message>
<message>
<source>Pixelate</source>
- <translation type="unfinished"></translation>
+ <translation>Verpixelung</translation>
</message>
<message>
<source>Text Pointer</source>
- <translation type="unfinished"></translation>
+ <translation>Sprechblase</translation>
</message>
<message>
<source>Text Arrow</source>
- <translation type="unfinished"></translation>
+ <translation>Pfeil mit Text</translation>
</message>
<message>
<source>Number Arrow</source>
- <translation type="unfinished"></translation>
+ <translation>Pfeil mit Zahl</translation>
</message>
</context>
<context>
<name>kImageAnnotator::ZoomIndicator</name>
<message>
<source>Zoom Level</source>
- <translation type="unfinished"></translation>
+ <translation>Zoomstufe</translation>
</message>
</context>
</TS>
diff --git a/translations/kImageAnnotator_no.ts b/translations/kImageAnnotator_no.ts
index dba46b4..b4497e6 100644
--- a/translations/kImageAnnotator_no.ts
+++ b/translations/kImageAnnotator_no.ts
@@ -68,7 +68,7 @@
</message>
<message>
<source>Obfuscation Factor</source>
- <translation type="unfinished"></translation>
+ <translation>Dekkevnefaktor</translation>
</message>
</context>
<context>
@@ -129,38 +129,38 @@
</message>
<message>
<source>Border and Fill</source>
- <translation type="unfinished">Rammelinje og utfylling</translation>
+ <translation type="unfinished">Kantlinje og utfylling</translation>
</message>
<message>
<source>Border and No Fill</source>
- <translation type="unfinished">Rammelinje og ingen utfylling</translation>
+ <translation type="unfinished">Kantlinje og ingen utfylling</translation>
</message>
<message>
<source>No Border and No Fill</source>
- <translation type="unfinished">Ingen rammelinje og ingen utfylling</translation>
+ <translation type="unfinished">Ingen kantlinje og ingen utfylling</translation>
</message>
</context>
<context>
<name>kImageAnnotator::ImageEffectPicker</name>
<message>
<source>Image Effects</source>
- <translation type="unfinished"></translation>
+ <translation>Bildeeffekter</translation>
</message>
<message>
<source>No Effect</source>
- <translation type="unfinished"></translation>
+ <translation>Ingen effekt</translation>
</message>
<message>
<source>Drop Shadow</source>
- <translation type="unfinished"></translation>
+ <translation>Kastskygge</translation>
</message>
<message>
<source>Grayscale</source>
- <translation type="unfinished"></translation>
+ <translation>Gråskala</translation>
</message>
<message>
<source>Border</source>
- <translation type="unfinished"></translation>
+ <translation>Kantlinje</translation>
</message>
</context>
<context>
@@ -269,26 +269,26 @@
</message>
<message>
<source>Pixelate</source>
- <translation type="unfinished"></translation>
+ <translation>Pikseler</translation>
</message>
<message>
<source>Text Pointer</source>
- <translation type="unfinished"></translation>
+ <translation>Tekstpeker</translation>
</message>
<message>
<source>Text Arrow</source>
- <translation type="unfinished"></translation>
+ <translation>Tekstpil</translation>
</message>
<message>
<source>Number Arrow</source>
- <translation type="unfinished"></translation>
+ <translation>Nummerpil</translation>
</message>
</context>
<context>
<name>kImageAnnotator::ZoomIndicator</name>
<message>
<source>Zoom Level</source>
- <translation type="unfinished"></translation>
+ <translation>Forstørrelsesnivå</translation>
</message>
</context>
</TS>
diff --git a/translations/kImageAnnotator_pt_BR.ts b/translations/kImageAnnotator_pt_BR.ts
index 62c4de3..d0396b8 100644
--- a/translations/kImageAnnotator_pt_BR.ts
+++ b/translations/kImageAnnotator_pt_BR.ts
@@ -62,21 +62,13 @@
<source>Font Size</source>
<translation>Tamanho da fonte</translation>
</message>
- <message>
- <source>Border And Fill Visibility</source>
- <translation>Modo de desenho da borda e do preenchimento</translation>
- </message>
<message>
<source>Starting Number</source>
<translation>Número inicial</translation>
</message>
<message>
- <source>Blur Radius</source>
- <translation>Raio de desfoque</translation>
- </message>
- <message>
- <source>Sticker</source>
- <translation>Adesivo</translation>
+ <source>Obfuscation Factor</source>
+ <translation>Fator de Obfuscação</translation>
</message>
</context>
<context>
@@ -130,10 +122,10 @@
</message>
</context>
<context>
- <name>kImageAnnotator::FillTypePicker</name>
+ <name>kImageAnnotator::FillModePicker</name>
<message>
- <source>No Border and No Fill</source>
- <translation>Sem borda e sem preenchimento</translation>
+ <source>Border And Fill Visibility</source>
+ <translation type="unfinished">Modo de desenho da borda e do preenchimento</translation>
</message>
<message>
<source>Border and Fill</source>
@@ -143,6 +135,33 @@
<source>Border and No Fill</source>
<translation>Com borda e sem preenchimento</translation>
</message>
+ <message>
+ <source>No Border and No Fill</source>
+ <translation>Sem borda e sem preenchimento</translation>
+ </message>
+</context>
+<context>
+ <name>kImageAnnotator::ImageEffectPicker</name>
+ <message>
+ <source>Image Effects</source>
+ <translation>Efeitos para a imagem</translation>
+ </message>
+ <message>
+ <source>No Effect</source>
+ <translation>Sem Efeito</translation>
+ </message>
+ <message>
+ <source>Drop Shadow</source>
+ <translation>Sombreado</translation>
+ </message>
+ <message>
+ <source>Grayscale</source>
+ <translation>Escala de cinza</translation>
+ </message>
+ <message>
+ <source>Border</source>
+ <translation>Borda</translation>
+ </message>
</context>
<context>
<name>kImageAnnotator::ScaleDialog</name>
@@ -179,6 +198,13 @@
<translation>Porcentagem</translation>
</message>
</context>
+<context>
+ <name>kImageAnnotator::StickerPicker</name>
+ <message>
+ <source>Sticker</source>
+ <translation>Figurinha</translation>
+ </message>
+</context>
<context>
<name>kImageAnnotator::ToolPicker</name>
<message>
@@ -239,7 +265,30 @@
</message>
<message>
<source>Sticker</source>
- <translation>Adesivo</translation>
+ <translation>Figurinha</translation>
+ </message>
+ <message>
+ <source>Text Pointer</source>
+ <translation>Texto com ponteiro</translation>
+ </message>
+ <message>
+ <source>Text Arrow</source>
+ <translation>Texto com seta</translation>
+ </message>
+ <message>
+ <source>Number Arrow</source>
+ <translation>Número com seta</translation>
+ </message>
+ <message>
+ <source>Pixelate</source>
+ <translation>Pixelizar</translation>
+ </message>
+</context>
+<context>
+ <name>kImageAnnotator::ZoomIndicator</name>
+ <message>
+ <source>Zoom Level</source>
+ <translation>Nível de zoom</translation>
</message>
</context>
</TS>
diff --git a/translations/kImageAnnotator_ru.ts b/translations/kImageAnnotator_ru.ts
index c27ce86..b94a0ff 100644
--- a/translations/kImageAnnotator_ru.ts
+++ b/translations/kImageAnnotator_ru.ts
@@ -68,7 +68,7 @@
</message>
<message>
<source>Obfuscation Factor</source>
- <translation type="unfinished"></translation>
+ <translation>Уровень обфускации</translation>
</message>
</context>
<context>
@@ -125,42 +125,42 @@
<name>kImageAnnotator::FillModePicker</name>
<message>
<source>Border And Fill Visibility</source>
- <translation type="unfinished">Видимость обводки и заливки</translation>
+ <translation>Видимость обводки и заливки</translation>
</message>
<message>
<source>Border and Fill</source>
- <translation type="unfinished">Обводка и заливка</translation>
+ <translation>Обводка и заливка</translation>
</message>
<message>
<source>Border and No Fill</source>
- <translation type="unfinished">Обводка без заливки</translation>
+ <translation>Обводка без заливки</translation>
</message>
<message>
<source>No Border and No Fill</source>
- <translation type="unfinished">Без обводки и заливки</translation>
+ <translation>Без обводки и заливки</translation>
</message>
</context>
<context>
<name>kImageAnnotator::ImageEffectPicker</name>
<message>
<source>Image Effects</source>
- <translation type="unfinished"></translation>
+ <translation>Графические эффекты</translation>
</message>
<message>
<source>No Effect</source>
- <translation type="unfinished"></translation>
+ <translation>Без эффекта</translation>
</message>
<message>
<source>Drop Shadow</source>
- <translation type="unfinished"></translation>
+ <translation>Отбросить тень</translation>
</message>
<message>
<source>Grayscale</source>
- <translation type="unfinished"></translation>
+ <translation>Оттенки серого</translation>
</message>
<message>
<source>Border</source>
- <translation type="unfinished"></translation>
+ <translation>Рамка</translation>
</message>
</context>
<context>
@@ -202,7 +202,7 @@
<name>kImageAnnotator::StickerPicker</name>
<message>
<source>Sticker</source>
- <translation type="unfinished">Стикер</translation>
+ <translation>Стикер</translation>
</message>
</context>
<context>
@@ -269,26 +269,26 @@
</message>
<message>
<source>Pixelate</source>
- <translation type="unfinished"></translation>
+ <translation>Пикселизовать</translation>
</message>
<message>
<source>Text Pointer</source>
- <translation type="unfinished"></translation>
+ <translation>Текстовый указатель</translation>
</message>
<message>
<source>Text Arrow</source>
- <translation type="unfinished"></translation>
+ <translation>Стрелка с текстом</translation>
</message>
<message>
<source>Number Arrow</source>
- <translation type="unfinished"></translation>
+ <translation>Стрелка с цифрой</translation>
</message>
</context>
<context>
<name>kImageAnnotator::ZoomIndicator</name>
<message>
<source>Zoom Level</source>
- <translation type="unfinished"></translation>
+ <translation>Уровень масштабирования</translation>
</message>
</context>
</TS>
More information about the Neon-commits
mailing list