├── .github ├── FUNDING.yml ├── scripts │ ├── build_kImageAnnotator.sh │ ├── linux │ │ └── setup_linux_build_variables.sh │ ├── setup_build_variables.sh │ ├── setup_googleTest.sh │ ├── setup_kColorPicker.sh │ └── windows │ │ └── setup_windows_build_variables.sh └── workflows │ ├── linux.yml │ └── windows.yml ├── .gitignore ├── CHANGELOG.md ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── cmake_uninstall.cmake.in └── kImageAnnotatorConfig.cmake.in ├── example ├── CMakeLists.txt └── main.cpp ├── include └── kImageAnnotator │ ├── KImageAnnotator.h │ └── KImageAnnotatorExport.h ├── resources ├── icons │ ├── dark │ │ ├── arrow.svg │ │ ├── blur.svg │ │ ├── bold.svg │ │ ├── border.svg │ │ ├── check.svg │ │ ├── color.svg │ │ ├── crop.svg │ │ ├── cut.svg │ │ ├── disabled.svg │ │ ├── doubleArrow.svg │ │ ├── dragHandle.svg │ │ ├── dropShadow.svg │ │ ├── duplicate.svg │ │ ├── effect.svg │ │ ├── ellipse.svg │ │ ├── fillType.svg │ │ ├── fillType_borderAndFill.svg │ │ ├── fillType_borderAndNoFill.svg │ │ ├── fillType_noBorderAndNoFill.svg │ │ ├── fitImage.svg │ │ ├── grayscale.svg │ │ ├── invertColor.svg │ │ ├── italic.svg │ │ ├── line.svg │ │ ├── markerEllipse.svg │ │ ├── markerPen.svg │ │ ├── markerRect.svg │ │ ├── modifycanvas.svg │ │ ├── number.svg │ │ ├── numberArrow.svg │ │ ├── numberPointer.svg │ │ ├── obfuscateFactor.svg │ │ ├── opacity.svg │ │ ├── pen.svg │ │ ├── pixelate.svg │ │ ├── rect.svg │ │ ├── redo.svg │ │ ├── resetZoom.svg │ │ ├── rotate.svg │ │ ├── scale.svg │ │ ├── select.svg │ │ ├── sticker.svg │ │ ├── text.svg │ │ ├── textArrow.svg │ │ ├── textColor.svg │ │ ├── textPointer.svg │ │ ├── underline.svg │ │ ├── undo.svg │ │ ├── width.svg │ │ └── zoom.svg │ └── light │ │ ├── arrow.svg │ │ ├── blur.svg │ │ ├── bold.svg │ │ ├── border.svg │ │ ├── check.svg │ │ ├── color.svg │ │ ├── crop.svg │ │ ├── cut.svg │ │ ├── disabled.svg │ │ ├── doubleArrow.svg │ │ ├── dragHandle.svg │ │ ├── dropShadow.svg │ │ ├── duplicate.svg │ │ ├── effect.svg │ │ ├── ellipse.svg │ │ ├── fillType.svg │ │ ├── fillType_borderAndFill.svg │ │ ├── fillType_borderAndNoFill.svg │ │ ├── fillType_noBorderAndNoFill.svg │ │ ├── fitImage.svg │ │ ├── grayscale.svg │ │ ├── invertColor.svg │ │ ├── italic.svg │ │ ├── line.svg │ │ ├── markerEllipse.svg │ │ ├── markerPen.svg │ │ ├── markerRect.svg │ │ ├── modifycanvas.svg │ │ ├── number.svg │ │ ├── numberArrow.svg │ │ ├── numberPointer.svg │ │ ├── obfuscateFactor.svg │ │ ├── opacity.svg │ │ ├── pen.svg │ │ ├── pixelate.svg │ │ ├── rect.svg │ │ ├── redo.svg │ │ ├── resetZoom.svg │ │ ├── rotate.svg │ │ ├── scale.svg │ │ ├── select.svg │ │ ├── sticker.svg │ │ ├── text.svg │ │ ├── textArrow.svg │ │ ├── textColor.svg │ │ ├── textPointer.svg │ │ ├── underline.svg │ │ ├── undo.svg │ │ ├── width.svg │ │ └── zoom.svg ├── kImageAnnotator_resources.qrc └── stickers │ ├── check_mark.svg │ ├── confused_face.svg │ ├── cross_mark.svg │ ├── cursor.svg │ ├── face_blowing_a_kiss.svg │ ├── face_savoring_food.svg │ ├── face_with_symbols_on_mouth.svg │ ├── grinning_face_with_big_eyes.svg │ ├── grinning_face_with_smiling_eyes.svg │ ├── grinning_face_with_sweat.svg │ ├── grinning_squinting_face.svg │ ├── hushed_face.svg │ ├── nerd_face.svg │ ├── neutral_face.svg │ ├── pouting_face.svg │ ├── smiling_face_with_heart_eyes.svg │ ├── smiling_face_with_hearts.svg │ └── smiling_face_with_sunglasses.svg ├── src ├── CMakeLists.txt ├── annotations │ ├── core │ │ ├── AbstractSettingsProvider.cpp │ │ ├── AbstractSettingsProvider.h │ │ ├── AnnotationArea.cpp │ │ ├── AnnotationArea.h │ │ ├── AnnotationItemFactory.cpp │ │ ├── AnnotationItemFactory.h │ │ ├── AnnotationPropertiesFactory.cpp │ │ ├── AnnotationPropertiesFactory.h │ │ ├── ISettingsListener.h │ │ ├── ZoomValueProvider.cpp │ │ ├── ZoomValueProvider.h │ │ └── imageEffects │ │ │ ├── BorderImageEffect.cpp │ │ │ ├── BorderImageEffect.h │ │ │ ├── DropShadowImageEffect.cpp │ │ │ ├── DropShadowImageEffect.h │ │ │ ├── GrayscaleImageEffect.cpp │ │ │ ├── GrayscaleImageEffect.h │ │ │ ├── ImageEffectFactory.cpp │ │ │ ├── ImageEffectFactory.h │ │ │ ├── InvertColorImageEffect.cpp │ │ │ ├── InvertColorImageEffect.h │ │ │ ├── NoImageEffect.cpp │ │ │ └── NoImageEffect.h │ ├── items │ │ ├── AbstractAnnotationItem.cpp │ │ ├── AbstractAnnotationItem.h │ │ ├── AbstractAnnotationLine.cpp │ │ ├── AbstractAnnotationLine.h │ │ ├── AbstractAnnotationObfuscate.cpp │ │ ├── AbstractAnnotationObfuscate.h │ │ ├── AbstractAnnotationPath.cpp │ │ ├── AbstractAnnotationPath.h │ │ ├── AbstractAnnotationPointerRect.cpp │ │ ├── AbstractAnnotationPointerRect.h │ │ ├── AbstractAnnotationRect.cpp │ │ ├── AbstractAnnotationRect.h │ │ ├── AnnotationArrow.cpp │ │ ├── AnnotationArrow.h │ │ ├── AnnotationBlur.cpp │ │ ├── AnnotationBlur.h │ │ ├── AnnotationDoubleArrow.cpp │ │ ├── AnnotationDoubleArrow.h │ │ ├── AnnotationDuplicate.cpp │ │ ├── AnnotationDuplicate.h │ │ ├── AnnotationEllipse.cpp │ │ ├── AnnotationEllipse.h │ │ ├── AnnotationImage.cpp │ │ ├── AnnotationImage.h │ │ ├── AnnotationLine.cpp │ │ ├── AnnotationLine.h │ │ ├── AnnotationMarkerEllipse.cpp │ │ ├── AnnotationMarkerEllipse.h │ │ ├── AnnotationMarkerPen.cpp │ │ ├── AnnotationMarkerPen.h │ │ ├── AnnotationMarkerRect.cpp │ │ ├── AnnotationMarkerRect.h │ │ ├── AnnotationNumber.cpp │ │ ├── AnnotationNumber.h │ │ ├── AnnotationNumberArrow.cpp │ │ ├── AnnotationNumberArrow.h │ │ ├── AnnotationNumberPointer.cpp │ │ ├── AnnotationNumberPointer.h │ │ ├── AnnotationPen.cpp │ │ ├── AnnotationPen.h │ │ ├── AnnotationPixelate.cpp │ │ ├── AnnotationPixelate.h │ │ ├── AnnotationRect.cpp │ │ ├── AnnotationRect.h │ │ ├── AnnotationSticker.cpp │ │ ├── AnnotationSticker.h │ │ ├── AnnotationText.cpp │ │ ├── AnnotationText.h │ │ ├── AnnotationTextArrow.cpp │ │ ├── AnnotationTextArrow.h │ │ ├── AnnotationTextPointer.cpp │ │ ├── AnnotationTextPointer.h │ │ ├── BaseAnnotationNumber.cpp │ │ ├── BaseAnnotationNumber.h │ │ ├── helper │ │ │ ├── AnnotationShapeCreator.cpp │ │ │ ├── AnnotationShapeCreator.h │ │ │ ├── NumberRectHelper.cpp │ │ │ └── NumberRectHelper.h │ │ ├── interfaces │ │ │ └── EditableItem.h │ │ └── text │ │ │ ├── AnnotationTextHandler.cpp │ │ │ ├── AnnotationTextHandler.h │ │ │ ├── CapsLockStatusChecker.cpp │ │ │ ├── CapsLockStatusChecker.h │ │ │ ├── KeyInputHelper.cpp │ │ │ ├── KeyInputHelper.h │ │ │ ├── TextCursor.cpp │ │ │ ├── TextCursor.h │ │ │ ├── TextHandlerItem.cpp │ │ │ └── TextHandlerItem.h │ ├── misc │ │ ├── AbstractCloneableItemEffect.cpp │ │ ├── AbstractCloneableItemEffect.h │ │ ├── AnnotationContextMenu.cpp │ │ ├── AnnotationContextMenu.h │ │ ├── AnnotationItemClipboard.cpp │ │ ├── AnnotationItemClipboard.h │ │ ├── CanvasPainter.cpp │ │ ├── CanvasPainter.h │ │ ├── ImageBlurrer.cpp │ │ ├── ImageBlurrer.h │ │ ├── NumberManager.cpp │ │ ├── NumberManager.h │ │ └── itemEffects │ │ │ ├── NoEffect.cpp │ │ │ ├── NoEffect.h │ │ │ ├── ShadowEffect.cpp │ │ │ └── ShadowEffect.h │ ├── modifiers │ │ ├── AnnotationItemArranger.cpp │ │ ├── AnnotationItemArranger.h │ │ ├── AnnotationItemEditor.cpp │ │ ├── AnnotationItemEditor.h │ │ ├── AnnotationItemModifier.cpp │ │ ├── AnnotationItemModifier.h │ │ ├── AnnotationItemMover.cpp │ │ ├── AnnotationItemMover.h │ │ ├── AnnotationItemResizer.cpp │ │ ├── AnnotationItemResizer.h │ │ ├── AnnotationItemSelector.cpp │ │ ├── AnnotationItemSelector.h │ │ ├── AnnotationMultiItemResizer.cpp │ │ ├── AnnotationMultiItemResizer.h │ │ └── resizeHandles │ │ │ ├── AbstractItemResizeHandles.cpp │ │ │ ├── AbstractItemResizeHandles.h │ │ │ ├── AbstractRectResizeHandles.cpp │ │ │ ├── AbstractRectResizeHandles.h │ │ │ ├── LineResizeHandles.cpp │ │ │ ├── LineResizeHandles.h │ │ │ ├── PathResizeHandles.cpp │ │ │ ├── PathResizeHandles.h │ │ │ ├── PointerRectResizeHandles.cpp │ │ │ ├── PointerRectResizeHandles.h │ │ │ ├── RectResizeHandles.cpp │ │ │ ├── RectResizeHandles.h │ │ │ ├── ResizeHandle.cpp │ │ │ ├── ResizeHandle.h │ │ │ ├── ResizeHandlesFactory.cpp │ │ │ └── ResizeHandlesFactory.h │ ├── properties │ │ ├── AnnotationObfuscateProperties.cpp │ │ ├── AnnotationObfuscateProperties.h │ │ ├── AnnotationPathProperties.cpp │ │ ├── AnnotationPathProperties.h │ │ ├── AnnotationProperties.cpp │ │ ├── AnnotationProperties.h │ │ ├── AnnotationStickerProperties.cpp │ │ ├── AnnotationStickerProperties.h │ │ ├── AnnotationTextProperties.cpp │ │ └── AnnotationTextProperties.h │ └── undo │ │ ├── AddCommand.cpp │ │ ├── AddCommand.h │ │ ├── ArrangeCommand.cpp │ │ ├── ArrangeCommand.h │ │ ├── ChangePropertiesCommand.cpp │ │ ├── ChangePropertiesCommand.h │ │ ├── CropCommand.cpp │ │ ├── CropCommand.h │ │ ├── CutCommand.cpp │ │ ├── CutCommand.h │ │ ├── DeleteCommand.cpp │ │ ├── DeleteCommand.h │ │ ├── FlipCommand.cpp │ │ ├── FlipCommand.h │ │ ├── ModifyCanvasCommand.cpp │ │ ├── ModifyCanvasCommand.h │ │ ├── MoveCommand.cpp │ │ ├── MoveCommand.h │ │ ├── PasteCommand.cpp │ │ ├── PasteCommand.h │ │ ├── ResizeCommand.cpp │ │ ├── ResizeCommand.h │ │ ├── RotateCommand.cpp │ │ ├── RotateCommand.h │ │ ├── ScaleCommand.cpp │ │ ├── ScaleCommand.h │ │ ├── UndoStack.cpp │ │ └── UndoStack.h ├── backend │ ├── Config.cpp │ ├── Config.h │ ├── ISettings.h │ ├── SettingsAdapter.cpp │ └── SettingsAdapter.h ├── common │ ├── constants │ │ └── Constants.h │ ├── enum │ │ ├── DesktopEnvironmentType.h │ │ ├── FillModes.h │ │ ├── FlipDirection.h │ │ ├── ImageEffects.h │ │ ├── NumberUpdateMode.h │ │ └── Tools.h │ ├── filter │ │ ├── IKeyEventListener.h │ │ ├── IgnoreShortcutsFilter.cpp │ │ ├── IgnoreShortcutsFilter.h │ │ ├── KeyEventFilter.cpp │ │ └── KeyEventFilter.h │ ├── helper │ │ ├── ConfigNameHelper.cpp │ │ ├── ConfigNameHelper.h │ │ ├── CursorHelper.cpp │ │ ├── CursorHelper.h │ │ ├── DesktopEnvironmentChecker.cpp │ │ ├── DesktopEnvironmentChecker.h │ │ ├── IconLoader.cpp │ │ ├── IconLoader.h │ │ ├── ItemHelper.cpp │ │ ├── ItemHelper.h │ │ ├── KeyHelper.cpp │ │ ├── KeyHelper.h │ │ ├── MathHelper.cpp │ │ ├── MathHelper.h │ │ ├── PathHelper.cpp │ │ ├── PathHelper.h │ │ ├── RectSizeHelper.cpp │ │ ├── RectSizeHelper.h │ │ ├── ShapeHelper.cpp │ │ └── ShapeHelper.h │ ├── platform │ │ ├── PlatformChecker.cpp │ │ └── PlatformChecker.h │ └── provider │ │ ├── DevicePixelRatioScaler.cpp │ │ ├── DevicePixelRatioScaler.h │ │ ├── IDevicePixelRatioScaler.h │ │ ├── ScaledSizeProvider.cpp │ │ └── ScaledSizeProvider.h ├── gui │ ├── CoreView.cpp │ ├── CoreView.h │ ├── KImageAnnotator.cpp │ ├── annotator │ │ ├── AnnotationView.cpp │ │ ├── AnnotationView.h │ │ ├── AnnotationWidget.cpp │ │ ├── AnnotationWidget.h │ │ ├── docks │ │ │ ├── AbstractAnnotationDockWidgetContent.cpp │ │ │ ├── AbstractAnnotationDockWidgetContent.h │ │ │ ├── AnnotationDockWidget.cpp │ │ │ ├── AnnotationDockWidget.h │ │ │ ├── AnnotationDockWidgetDragHandle.cpp │ │ │ └── AnnotationDockWidgetDragHandle.h │ │ ├── settings │ │ │ ├── AnnotationControlsWidget.cpp │ │ │ ├── AnnotationControlsWidget.h │ │ │ ├── AnnotationGeneralSettings.cpp │ │ │ ├── AnnotationGeneralSettings.h │ │ │ ├── AnnotationImageSettings.cpp │ │ │ ├── AnnotationImageSettings.h │ │ │ ├── AnnotationItemSettings.cpp │ │ │ ├── AnnotationItemSettings.h │ │ │ ├── AnnotationSettingsAdapter.cpp │ │ │ ├── AnnotationSettingsAdapter.h │ │ │ ├── AnnotationToolSelection.cpp │ │ │ ├── AnnotationToolSelection.h │ │ │ ├── ExistingItemEditInfo.h │ │ │ ├── ItemSettingsWidgetConfigurator.cpp │ │ │ └── ItemSettingsWidgetConfigurator.h │ │ └── tabs │ │ │ ├── AnnotationTabClickEventFilter.cpp │ │ │ ├── AnnotationTabClickEventFilter.h │ │ │ ├── AnnotationTabCloser.cpp │ │ │ ├── AnnotationTabCloser.h │ │ │ ├── AnnotationTabContent.cpp │ │ │ ├── AnnotationTabContent.h │ │ │ ├── AnnotationTabContextMenu.cpp │ │ │ ├── AnnotationTabContextMenu.h │ │ │ ├── AnnotationTabWidget.cpp │ │ │ └── AnnotationTabWidget.h │ ├── canvasModifier │ │ ├── ModifyCanvasSelectionRestrictor.cpp │ │ ├── ModifyCanvasSelectionRestrictor.h │ │ ├── ModifyCanvasView.cpp │ │ ├── ModifyCanvasView.h │ │ ├── ModifyCanvasWidget.cpp │ │ └── ModifyCanvasWidget.h │ ├── cropper │ │ ├── CropSelectionRestrictor.cpp │ │ ├── CropSelectionRestrictor.h │ │ ├── CropView.cpp │ │ ├── CropView.h │ │ ├── CropWidget.cpp │ │ └── CropWidget.h │ ├── cutter │ │ ├── CutSelectionRestrictor.cpp │ │ ├── CutSelectionRestrictor.h │ │ ├── CutView.cpp │ │ ├── CutView.h │ │ ├── CutWidget.cpp │ │ └── CutWidget.h │ ├── rotator │ │ ├── RotateDialog.cpp │ │ ├── RotateDialog.h │ │ ├── RotateWidget.cpp │ │ └── RotateWidget.h │ ├── scaler │ │ ├── ScaleDialog.cpp │ │ ├── ScaleDialog.h │ │ ├── ScaleSizeHandler.cpp │ │ ├── ScaleSizeHandler.h │ │ ├── ScaleWidget.cpp │ │ └── ScaleWidget.h │ ├── scrollAndZoomView │ │ ├── ScrollAndZoomView.cpp │ │ ├── ScrollAndZoomView.h │ │ ├── ViewZoomer.cpp │ │ └── ViewZoomer.h │ └── selection │ │ ├── BaseSelectionHandles.cpp │ │ ├── BaseSelectionHandles.h │ │ ├── BaseSelectionView.cpp │ │ ├── BaseSelectionView.h │ │ ├── ISelectionHandles.h │ │ ├── ISelectionRestrictor.h │ │ ├── SelectionHandler.cpp │ │ ├── SelectionHandler.h │ │ ├── SelectionHandlesAll.cpp │ │ ├── SelectionHandlesAll.h │ │ ├── SelectionHandlesHorizontal.cpp │ │ ├── SelectionHandlesHorizontal.h │ │ ├── SelectionHandlesVertical.cpp │ │ ├── SelectionHandlesVertical.h │ │ ├── SelectionMoveHelper.cpp │ │ └── SelectionMoveHelper.h └── widgets │ ├── ColorDialogButton.cpp │ ├── ColorDialogButton.h │ ├── Controls.cpp │ ├── Controls.h │ ├── CustomFontComboBox.cpp │ ├── CustomFontComboBox.h │ ├── CustomSpinBox.cpp │ ├── CustomSpinBox.h │ ├── CustomToolButton.cpp │ ├── CustomToolButton.h │ ├── CustomToolButtonAction.cpp │ ├── CustomToolButtonAction.h │ ├── ToggleButton.cpp │ ├── ToggleButton.h │ ├── ToolPicker.cpp │ ├── ToolPicker.h │ ├── menuButtons │ ├── GridMenu.cpp │ ├── GridMenu.h │ ├── GridMenuButton.cpp │ ├── GridMenuButton.h │ ├── GridMenuToolButton.cpp │ ├── GridMenuToolButton.h │ ├── ListItemGroup.cpp │ ├── ListItemGroup.h │ ├── ListMenu.cpp │ ├── ListMenu.h │ ├── ListMenuItem.cpp │ ├── ListMenuItem.h │ ├── ListMenuToolButton.cpp │ └── ListMenuToolButton.h │ ├── misc │ ├── AbstractExpandingWidget.cpp │ ├── AbstractExpandingWidget.h │ ├── AttachedSeparator.cpp │ ├── AttachedSeparator.h │ ├── FlowLayout.cpp │ └── FlowLayout.h │ └── settingsPicker │ ├── BoolPicker.cpp │ ├── BoolPicker.h │ ├── ColorPicker.cpp │ ├── ColorPicker.h │ ├── FillModePicker.cpp │ ├── FillModePicker.h │ ├── FontPicker.cpp │ ├── FontPicker.h │ ├── ImageEffectPicker.cpp │ ├── ImageEffectPicker.h │ ├── NumberPicker.cpp │ ├── NumberPicker.h │ ├── SettingsPickerWidget.cpp │ ├── SettingsPickerWidget.h │ ├── StickerPicker.cpp │ ├── StickerPicker.h │ ├── ZoomPicker.cpp │ └── ZoomPicker.h ├── tests ├── CMakeLists.txt ├── annotations │ ├── core │ │ ├── AnnotationAreaTest.cpp │ │ ├── AnnotationAreaTest.h │ │ ├── AnnotationItemFactoryTest.cpp │ │ ├── AnnotationItemFactoryTest.h │ │ ├── AnnotationPropertiesFactoryTest.cpp │ │ └── AnnotationPropertiesFactoryTest.h │ ├── items │ │ └── helper │ │ │ ├── KeyInputHelperTest.cpp │ │ │ ├── KeyInputHelperTest.h │ │ │ ├── TextCursorTest.cpp │ │ │ └── TextCursorTest.h │ ├── misc │ │ ├── AnnotationItemClipboardTest.cpp │ │ ├── AnnotationItemClipboardTest.h │ │ ├── NumberManagerTest.cpp │ │ └── NumberManagerTest.h │ ├── modifiers │ │ ├── AnnotationItemArrangerTest.cpp │ │ ├── AnnotationItemArrangerTest.h │ │ ├── AnnotationItemModifierTest.cpp │ │ ├── AnnotationItemModifierTest.h │ │ ├── AnnotationItemMoverTest.cpp │ │ ├── AnnotationItemMoverTest.h │ │ ├── AnnotationItemResizerTest.cpp │ │ ├── AnnotationItemResizerTest.h │ │ ├── AnnotationItemSelectorTest.cpp │ │ ├── AnnotationItemSelectorTest.h │ │ ├── AnnotationMultiItemResizerTest.cpp │ │ ├── AnnotationMultiItemResizerTest.h │ │ └── resizeHandles │ │ │ ├── LineResizeHandlesTest.cpp │ │ │ ├── LineResizeHandlesTest.h │ │ │ ├── PointerRectResizeHandlesTest.cpp │ │ │ ├── PointerRectResizeHandlesTest.h │ │ │ ├── RectResizeHandlesTest.cpp │ │ │ └── RectResizeHandlesTest.h │ └── undo │ │ ├── AddCommandTest.cpp │ │ ├── AddCommandTest.h │ │ ├── ArrangeCommandTest.cpp │ │ ├── ArrangeCommandTest.h │ │ ├── CropCommandTest.cpp │ │ ├── CropCommandTest.h │ │ ├── DeleteCommandTest.cpp │ │ ├── DeleteCommandTest.h │ │ ├── ModifyCanvasCommandTest.cpp │ │ ├── ModifyCanvasCommandTest.h │ │ ├── MoveCommandTest.cpp │ │ ├── MoveCommandTest.h │ │ ├── PasteCommandTest.cpp │ │ ├── PasteCommandTest.h │ │ ├── ResizeCommandTest.cpp │ │ ├── ResizeCommandTest.h │ │ ├── RotateCommandTest.cpp │ │ ├── RotateCommandTest.h │ │ ├── ScaleCommandTest.cpp │ │ └── ScaleCommandTest.h ├── backend │ ├── ConfigTest.cpp │ └── ConfigTest.h ├── common │ └── helper │ │ ├── ItemHelperTest.cpp │ │ ├── ItemHelperTest.h │ │ ├── KeyHelperTest.cpp │ │ ├── KeyHelperTest.h │ │ ├── MathHelperTest.cpp │ │ ├── MathHelperTest.h │ │ ├── PathHelperTest.cpp │ │ ├── PathHelperTest.h │ │ ├── ShapeHelperTest.cpp │ │ └── ShapeHelperTest.h ├── gui │ ├── annotator │ │ └── tabs │ │ │ ├── AnnotationTabCloserTest.cpp │ │ │ ├── AnnotationTabCloserTest.h │ │ │ ├── AnnotationTabContextMenuTest.cpp │ │ │ └── AnnotationTabContextMenuTest.h │ ├── canvasModifier │ │ ├── ModifyCanvasSelectionRestrictorTest.cpp │ │ └── ModifyCanvasSelectionRestrictorTest.h │ ├── cropper │ │ ├── CropSelectionRestrictorTest.cpp │ │ └── CropSelectionRestrictorTest.h │ ├── scaler │ │ ├── ScaleSizeHandlerTest.cpp │ │ └── ScaleSizeHandlerTest.h │ └── selection │ │ ├── SelectionHandlerTest.cpp │ │ ├── SelectionHandlerTest.h │ │ ├── SelectionHandlesAllTest.cpp │ │ ├── SelectionHandlesAllTest.h │ │ ├── SelectionMoveHelperTest.cpp │ │ └── SelectionMoveHelperTest.h ├── mocks │ ├── MockDefaultParameters.h │ ├── MockDevicePixelRatioScaler.cpp │ ├── MockDevicePixelRatioScaler.h │ ├── MockSelectionRestrictor.cpp │ ├── MockSelectionRestrictor.h │ ├── MockSettingsProvider.cpp │ ├── MockSettingsProvider.h │ ├── MockZoomValueProvider.cpp │ ├── MockZoomValueProvider.h │ ├── backend │ │ └── SettingsMock.h │ └── gui │ │ └── selection │ │ └── SelectionHandlesMock.h ├── utils │ └── TestRunner.h └── widgets │ ├── CustomSpinBoxTest.cpp │ ├── CustomSpinBoxTest.h │ ├── misc │ ├── AttachedSeparatorTest.cpp │ └── AttachedSeparatorTest.h │ └── settingsPicker │ ├── ColorPickerTest.cpp │ ├── ColorPickerTest.h │ ├── FillModePickerTest.cpp │ ├── FillModePickerTest.h │ ├── ImageEffectPickerTest.cpp │ ├── ImageEffectPickerTest.h │ ├── NumberPickerTest.cpp │ ├── NumberPickerTest.h │ ├── StickerPickerTest.cpp │ ├── StickerPickerTest.h │ ├── ToolPickerTest.cpp │ ├── ToolPickerTest.h │ ├── ZoomPickerTest.cpp │ └── ZoomPickerTest.h └── translations ├── CMakeLists.txt ├── kImageAnnotator_ar.ts ├── kImageAnnotator_bg.ts ├── kImageAnnotator_ca.ts ├── kImageAnnotator_cs.ts ├── kImageAnnotator_da.ts ├── kImageAnnotator_de.ts ├── kImageAnnotator_el.ts ├── kImageAnnotator_es.ts ├── kImageAnnotator_et.ts ├── kImageAnnotator_eu.ts ├── kImageAnnotator_fr.ts ├── kImageAnnotator_fr_CA.ts ├── kImageAnnotator_gl.ts ├── kImageAnnotator_hr.ts ├── kImageAnnotator_hu.ts ├── kImageAnnotator_id.ts ├── kImageAnnotator_it.ts ├── kImageAnnotator_ja.ts ├── kImageAnnotator_ko.ts ├── kImageAnnotator_nl.ts ├── kImageAnnotator_no.ts ├── kImageAnnotator_pl.ts ├── kImageAnnotator_pt.ts ├── kImageAnnotator_pt_BR.ts ├── kImageAnnotator_ro.ts ├── kImageAnnotator_ru.ts ├── kImageAnnotator_si.ts ├── kImageAnnotator_sq.ts ├── kImageAnnotator_sv.ts ├── kImageAnnotator_ta.ts ├── kImageAnnotator_tr.ts ├── kImageAnnotator_uk.ts └── kImageAnnotator_zh_CN.ts /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: DamirPorobic 4 | liberapay: dporobic 5 | patreon: dporobic 6 | open_collective: ksnip 7 | custom: paypal.me/damirporobic 8 | -------------------------------------------------------------------------------- /.github/scripts/build_kImageAnnotator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir build && cd build 4 | 5 | cmake .. -G"${CMAKE_GENERATOR}" -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} 6 | ${MAKE_BINARY} VERBOSE=1 -------------------------------------------------------------------------------- /.github/scripts/linux/setup_linux_build_variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "MAKE_BINARY=make" >> $GITHUB_ENV 4 | echo "CMAKE_GENERATOR=Unix Makefiles" >> $GITHUB_ENV 5 | -------------------------------------------------------------------------------- /.github/scripts/setup_build_variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | WORKSPACE="$GITHUB_WORKSPACE" 4 | INSTALL_PREFIX="$WORKSPACE/tmp" 5 | 6 | echo "WORKSPACE=$WORKSPACE" >> $GITHUB_ENV 7 | echo "INSTALL_PREFIX=$INSTALL_PREFIX" >> $GITHUB_ENV 8 | -------------------------------------------------------------------------------- /.github/scripts/setup_googleTest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone --depth 1 https://github.com/google/googletest 4 | cd googletest || exit 5 | mkdir build && cd build || exit 6 | cmake .. -G"${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" -DBUILD_SHARED_LIBS=ON 7 | ${MAKE_BINARY} && ${MAKE_BINARY} install -------------------------------------------------------------------------------- /.github/scripts/setup_kColorPicker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone --depth 1 https://github.com/ksnip/kColorPicker.git 4 | 5 | cd kColorPicker || exit 6 | mkdir build && cd build || exit 7 | cmake .. -G"${CMAKE_GENERATOR}" -DBUILD_EXAMPLE=OFF -DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" 8 | ${MAKE_BINARY} && ${MAKE_BINARY} install -------------------------------------------------------------------------------- /.github/scripts/windows/setup_windows_build_variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "MAKE_BINARY=nmake" >> $GITHUB_ENV 4 | echo "CMAKE_GENERATOR=NMake Makefiles" >> $GITHUB_ENV 5 | 6 | echo "LIB=$LIB;$INSTALL_PREFIX/lib" >> $GITHUB_ENV 7 | echo "INCLUDE=$INCLUDE;$INSTALL_PREFIX/include" >> $GITHUB_ENV -------------------------------------------------------------------------------- /.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: linux 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v2 15 | 16 | - name: Set up build variables 17 | run: bash ./.github/scripts/setup_build_variables.sh 18 | 19 | - name: Set up linux build variables 20 | run: bash ./.github/scripts/linux/setup_linux_build_variables.sh 21 | 22 | - name: Install Qt 23 | uses: jurplel/install-qt-action@v2 24 | with: 25 | version: '5.15.2' 26 | host: 'linux' 27 | install-deps: 'true' 28 | 29 | - name: Install dependencies 30 | run: sudo apt-get install extra-cmake-modules xvfb 31 | 32 | - name: Set up GoogleTest 33 | run: bash ./.github/scripts/setup_googleTest.sh 34 | 35 | - name: Set up kColorPicker 36 | run: bash ./.github/scripts/setup_kColorPicker.sh 37 | 38 | - name: Build 39 | run: bash ./.github/scripts/build_kImageAnnotator.sh 40 | 41 | - name: Test 42 | working-directory: ${{github.workspace}}/build/tests 43 | run: xvfb-run --auto-servernum --server-num=1 --server-args="-screen 0 1024x768x24" ctest --extra-verbose 44 | 45 | -------------------------------------------------------------------------------- /.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: windows 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: windows-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v2 15 | 16 | - name: Set up build variables 17 | run: bash ./.github/scripts/setup_build_variables.sh 18 | 19 | - name: Set up windows build variables 20 | run: bash ./.github/scripts/windows/setup_windows_build_variables.sh 21 | 22 | - name: Install Qt 23 | uses: jurplel/install-qt-action@v2 24 | with: 25 | version: '5.15.2' 26 | host: 'windows' 27 | install-deps: 'true' 28 | arch: 'win64_msvc2019_64' 29 | 30 | - name: Set up nmake 31 | uses: ilammy/msvc-dev-cmd@v1 32 | 33 | - name: Set up kColorPicker 34 | run: bash ./.github/scripts/setup_kColorPicker.sh 35 | 36 | - name: Set up GoogleTest 37 | run: bash ./.github/scripts/setup_googleTest.sh 38 | 39 | - name: Add GoogleTest bin dir to PATH 40 | uses: myci-actions/export-env-var-powershell@1 41 | with: 42 | name: PATH 43 | value: $env:PATH;$env:INSTALL_PREFIX/bin 44 | 45 | - name: Build 46 | run: bash ./.github/scripts/build_kImageAnnotator.sh 47 | 48 | - name: Test 49 | working-directory: ${{github.workspace}}/build/tests 50 | run: ctest --extra-verbose 51 | 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # C++ objects and libs 2 | *.slo 3 | *.lo 4 | *.o 5 | *.a 6 | *.la 7 | *.lai 8 | *.so 9 | *.dll 10 | *.dylib 11 | 12 | # Qt-es 13 | /.qmake.cache 14 | /.qmake.stash 15 | *.pro.user 16 | *.pro.user.* 17 | *.qbs.user 18 | *.qbs.user.* 19 | *.moc 20 | moc_*.cpp 21 | qrc_*.cpp 22 | ui_*.h 23 | Makefile* 24 | *build-* 25 | 26 | # QtCreator 27 | *.autosave 28 | 29 | # QtCtreator Qml 30 | *.qmlproject.user 31 | *.qmlproject.user.* 32 | 33 | # QtCtreator CMake 34 | CMakeLists.txt.user 35 | 36 | 37 | # kdevelop 38 | apidocs 39 | .kdev4 40 | build 41 | *~ 42 | *.kdev4 43 | *.bak 44 | *.orig 45 | *.rej 46 | doxygen.log 47 | Doxyfile 48 | *.kdevelop 49 | *.kdevelop.filelist 50 | *.kdevelop.pcs 51 | *.kdevses 52 | .*kate-swp 53 | build/ 54 | mem.log.* 55 | massif.* 56 | callgrind.* 57 | perf.data* 58 | 59 | # from kdiff3 60 | *.BACKUP.* 61 | *.BASE.* 62 | *.LOCAL.* 63 | *.REMOTE.* 64 | 65 | # visual studio code 66 | *.vscode/ 67 | 68 | # clion 69 | *.idea 70 | *.idea/ 71 | 72 | # misc 73 | .directory -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) 22 | 23 | -------------------------------------------------------------------------------- /cmake/kImageAnnotatorConfig.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | 3 | @PACKAGE_INIT@ 4 | 5 | find_dependency(Qt@QT_MAJOR_VERSION@ @QT_MIN_VERSION@ COMPONENTS Widgets) 6 | if(NOT TARGET kImageAnnotator::kImageAnnotator) 7 | include("${CMAKE_CURRENT_LIST_DIR}/kImageAnnotator-targets.cmake") 8 | endif() 9 | -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(kImageAnnotator-example main.cpp) 2 | 3 | target_link_libraries(kImageAnnotator-example kImageAnnotator) 4 | -------------------------------------------------------------------------------- /include/kImageAnnotator/KImageAnnotatorExport.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_KIMAGEANNOTATOR_EXPORT_H 21 | #define KIMAGEANNOTATOR_KIMAGEANNOTATOR_EXPORT_H 22 | 23 | #include 24 | 25 | #if defined(_WIN32) 26 | # define KIMAGEANNOTATOR_EXPORT 27 | #else 28 | #if defined(KIMAGEANNOTATOR_LIB) 29 | # define KIMAGEANNOTATOR_EXPORT Q_DECL_EXPORT 30 | #else 31 | # define KIMAGEANNOTATOR_EXPORT Q_DECL_IMPORT 32 | #endif 33 | #endif 34 | 35 | #endif // KIMAGEANNOTATOR_KIMAGEANNOTATOR_EXPORT_H -------------------------------------------------------------------------------- /src/annotations/core/ISettingsListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ISETTINGSLISTENER_H 21 | #define KIMAGEANNOTATOR_ISETTINGSLISTENER_H 22 | 23 | #include "src/common/enum/Tools.h" 24 | #include "src/common/enum/ImageEffects.h" 25 | 26 | namespace kImageAnnotator { 27 | 28 | class ISettingsListener 29 | { 30 | public: 31 | virtual void toolChanged(Tools toolType) = 0; 32 | virtual void itemSettingsChanged() = 0; 33 | virtual void numberToolSeedChanged(int numberToolSeed) = 0; 34 | virtual int numberToolSeed() const = 0; 35 | virtual void imageEffectChanged(ImageEffects effect) = 0; 36 | }; 37 | 38 | } // namespace kImageAnnotator 39 | 40 | #endif //KIMAGEANNOTATOR_ISETTINGSLISTENER_H 41 | -------------------------------------------------------------------------------- /src/annotations/core/ZoomValueProvider.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ZoomValueProvider.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | kImageAnnotator::ZoomValueProvider::ZoomValueProvider(QObject *parent) 25 | : QObject(parent) 26 | { 27 | 28 | } 29 | 30 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/core/ZoomValueProvider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ZOOMVALUEPROVIDER_H 21 | #define KIMAGEANNOTATOR_ZOOMVALUEPROVIDER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class ZoomValueProvider : public QObject 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit ZoomValueProvider(QObject *parent = nullptr); 32 | ~ZoomValueProvider() override = default; 33 | virtual double zoomValue() const = 0; 34 | virtual void setZoomValue(double zoomValue) = 0; 35 | virtual void fitImageToView() = 0; 36 | 37 | signals: 38 | void zoomValueChanged(double value); 39 | }; 40 | 41 | } // namespace kImageAnnotator 42 | 43 | #endif // KIMAGEANNOTATOR_ZOOMVALUEPROVIDER_H 44 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/BorderImageEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "BorderImageEffect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void BorderImageEffect::draw(QPainter *painter) 25 | { 26 | QPoint offset; 27 | const auto pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); 28 | painter->drawPixmap(offset, pixmap); 29 | painter->drawRect(pixmap.rect()); 30 | } 31 | 32 | } // namespace kImageAnnotator 33 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/BorderImageEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_BORDERIMAGEEFFECT_H 21 | #define KIMAGEANNOTATOR_BORDERIMAGEEFFECT_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class BorderImageEffect : public QGraphicsEffect 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit BorderImageEffect() = default; 33 | ~BorderImageEffect() override = default; 34 | 35 | protected: 36 | void draw(QPainter * painter) override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_BORDERIMAGEEFFECT_H 42 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/DropShadowImageEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "DropShadowImageEffect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | DropShadowImageEffect::DropShadowImageEffect() 25 | { 26 | setColor(QColor(0, 0, 0)); 27 | setBlurRadius(30); 28 | setOffset(QPoint(0, 2)); 29 | } 30 | 31 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/DropShadowImageEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_DROPSHADOWIMAGEEFFECT_H 21 | #define KIMAGEANNOTATOR_DROPSHADOWIMAGEEFFECT_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class DropShadowImageEffect : public QGraphicsDropShadowEffect 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit DropShadowImageEffect(); 32 | ~DropShadowImageEffect() override = default; 33 | }; 34 | 35 | } // namespace kImageAnnotator 36 | 37 | #endif //KIMAGEANNOTATOR_DROPSHADOWIMAGEEFFECT_H 38 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/GrayscaleImageEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "GrayscaleImageEffect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void GrayscaleImageEffect::draw(QPainter *painter) 25 | { 26 | QPoint offset; 27 | const auto pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); 28 | painter->drawImage(offset, pixmap.toImage().convertToFormat(QImage::Format_Grayscale8)); 29 | } 30 | 31 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/GrayscaleImageEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_GRAYSCALEIMAGEEFFECT_H 21 | #define KIMAGEANNOTATOR_GRAYSCALEIMAGEEFFECT_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class GrayscaleImageEffect : public QGraphicsEffect 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit GrayscaleImageEffect() = default; 33 | ~GrayscaleImageEffect() override = default; 34 | 35 | protected: 36 | void draw(QPainter * painter) override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_GRAYSCALEIMAGEEFFECT_H 42 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/ImageEffectFactory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ImageEffectFactory.h" 21 | 22 | QGraphicsEffect *kImageAnnotator::ImageEffectFactory::create(kImageAnnotator::ImageEffects effect) 23 | { 24 | switch (effect) { 25 | case ImageEffects::DropShadow: 26 | return new DropShadowImageEffect; 27 | case ImageEffects::Border: 28 | return new BorderImageEffect; 29 | case ImageEffects::Grayscale: 30 | return new GrayscaleImageEffect; 31 | case ImageEffects::InvertColor: 32 | return new InvertColorImageEffect; 33 | default: 34 | return new NoImageEffect; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/ImageEffectFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_IMAGEEFFECTFACTORY_H 21 | #define KIMAGEANNOTATOR_IMAGEEFFECTFACTORY_H 22 | 23 | #include 24 | 25 | #include "NoImageEffect.h" 26 | #include "DropShadowImageEffect.h" 27 | #include "GrayscaleImageEffect.h" 28 | #include "BorderImageEffect.h" 29 | #include "InvertColorImageEffect.h" 30 | #include "src/common/enum/ImageEffects.h" 31 | 32 | namespace kImageAnnotator { 33 | 34 | class ImageEffectFactory 35 | { 36 | public: 37 | explicit ImageEffectFactory() = default; 38 | ~ImageEffectFactory() = default; 39 | static QGraphicsEffect* create(ImageEffects effect); 40 | }; 41 | 42 | } // namespace kImageAnnotator 43 | 44 | #endif //KIMAGEANNOTATOR_IMAGEEFFECTFACTORY_H 45 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/InvertColorImageEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "InvertColorImageEffect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void InvertColorImageEffect::draw(QPainter *painter) 25 | { 26 | QPoint offset; 27 | auto image = sourcePixmap(Qt::LogicalCoordinates, &offset).toImage(); 28 | image.invertPixels(); 29 | painter->drawImage(offset, image); 30 | } 31 | 32 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/InvertColorImageEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_INVERTCOLORIMAGEEFFECT_H 21 | #define KIMAGEANNOTATOR_INVERTCOLORIMAGEEFFECT_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class InvertColorImageEffect : public QGraphicsEffect 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit InvertColorImageEffect() = default; 33 | ~InvertColorImageEffect() override = default; 34 | 35 | protected: 36 | void draw(QPainter * painter) override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | 42 | #endif //KIMAGEANNOTATOR_INVERTCOLORIMAGEEFFECT_H 43 | -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/NoImageEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "NoImageEffect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void NoImageEffect::draw(QPainter *painter) 25 | { 26 | QPoint offset; 27 | const auto pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); 28 | painter->drawPixmap(offset, pixmap); 29 | } 30 | 31 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/core/imageEffects/NoImageEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_NOIMAGEEFFECT_H 21 | #define KIMAGEANNOTATOR_NOIMAGEEFFECT_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class NoImageEffect : public QGraphicsEffect 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit NoImageEffect() = default; 33 | ~NoImageEffect() override = default; 34 | 35 | protected: 36 | void draw(QPainter * painter) override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_NOIMAGEEFFECT_H 42 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationArrow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONARROW_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONARROW_H 22 | 23 | #include "src/annotations/items/AbstractAnnotationLine.h" 24 | #include "src/annotations/items/helper/AnnotationShapeCreator.h" 25 | 26 | namespace kImageAnnotator { 27 | 28 | class AnnotationArrow : public AbstractAnnotationLine 29 | { 30 | public: 31 | AnnotationArrow(const QPointF &startPosition, const PropertiesPtr &properties); 32 | AnnotationArrow(const AnnotationArrow &other); 33 | ~AnnotationArrow() override = default; 34 | Tools toolType() const override; 35 | 36 | protected: 37 | void updateShape() override; 38 | }; 39 | 40 | } // namespace kImageAnnotator 41 | 42 | #endif // KIMAGEANNOTATOR_ANNOTATIONARROW_H 43 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationBlur.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationBlur.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationBlur::AnnotationBlur(const QPointF &startPosition, const ObfuscatePropertiesPtr &properties) : AbstractAnnotationObfuscate(startPosition, properties) 25 | { 26 | } 27 | 28 | AnnotationBlur::AnnotationBlur(const AnnotationBlur &other) : AbstractAnnotationObfuscate(other) 29 | { 30 | } 31 | 32 | Tools AnnotationBlur::toolType() const 33 | { 34 | return Tools::Blur; 35 | } 36 | 37 | QImage AnnotationBlur::obfuscateBackground(const QImage &sceneBehindItem) const 38 | { 39 | return mItemBlurrer.blurred(sceneBehindItem, obfuscateProperties()->factor(), false); 40 | } 41 | 42 | } // namespace kImageAnnotator 43 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationDoubleArrow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONDOUBLEARROW_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONDOUBLEARROW_H 22 | 23 | #include "AnnotationArrow.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AnnotationDoubleArrow : public AnnotationArrow 28 | { 29 | public: 30 | AnnotationDoubleArrow(const QPointF &startPosition, const PropertiesPtr &properties); 31 | explicit AnnotationDoubleArrow(const AnnotationArrow &other); 32 | ~AnnotationDoubleArrow() override = default; 33 | Tools toolType() const override; 34 | 35 | protected: 36 | void updateShape() override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_ANNOTATIONDOUBLEARROW_H 42 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationEllipse.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationEllipse.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationEllipse::AnnotationEllipse(const QPointF &startPosition, const PropertiesPtr &properties) : AbstractAnnotationRect(startPosition, properties) 25 | { 26 | } 27 | 28 | AnnotationEllipse::AnnotationEllipse(const AnnotationEllipse &other) : AbstractAnnotationRect(other) 29 | { 30 | 31 | } 32 | 33 | Tools AnnotationEllipse::toolType() const 34 | { 35 | return Tools::Ellipse; 36 | } 37 | 38 | void AnnotationEllipse::updateShape() 39 | { 40 | QPainterPath path; 41 | path.addEllipse(*mRect); 42 | setShape(path); 43 | } 44 | 45 | } // namespace kImageAnnotator 46 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationEllipse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONELLIPSE_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONELLIPSE_H 22 | 23 | #include "AbstractAnnotationRect.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AnnotationEllipse : public AbstractAnnotationRect 28 | { 29 | public: 30 | AnnotationEllipse(const QPointF &startPosition, const PropertiesPtr &properties); 31 | AnnotationEllipse(const AnnotationEllipse &other); 32 | ~AnnotationEllipse() override = default; 33 | Tools toolType() const override; 34 | 35 | protected: 36 | void updateShape() override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif // KIMAGEANNOTATOR_ANNOTATIONELLIPSE_H 42 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationImage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONIMAGE_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONIMAGE_H 22 | 23 | #include "AnnotationRect.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AnnotationImage : public AnnotationRect 28 | { 29 | public: 30 | AnnotationImage(const QPointF &startPosition, const QPixmap &image, const PropertiesPtr &properties); 31 | AnnotationImage(const AnnotationImage &other); 32 | ~AnnotationImage() override = default; 33 | Tools toolType() const override; 34 | 35 | protected: 36 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override; 37 | 38 | private: 39 | QPixmap mImage; 40 | }; 41 | 42 | } // namespace kImageAnnotator 43 | 44 | #endif //KIMAGEANNOTATOR_ANNOTATIONIMAGE_H 45 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationLine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationLine.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationLine::AnnotationLine(const QPointF &startPosition, const PropertiesPtr &properties) : AbstractAnnotationLine(startPosition, properties) 25 | { 26 | } 27 | 28 | AnnotationLine::AnnotationLine(const AnnotationLine &other) : AbstractAnnotationLine(other) 29 | { 30 | 31 | } 32 | 33 | Tools AnnotationLine::toolType() const 34 | { 35 | return Tools::Line; 36 | } 37 | 38 | void AnnotationLine::updateShape() 39 | { 40 | QPainterPath path(mLine->p1()); 41 | path.lineTo(mLine->p2()); 42 | setShape(path); 43 | } 44 | 45 | } // namespace kImageAnnotator 46 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationLine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONLINE_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONLINE_H 22 | 23 | #include "AbstractAnnotationLine.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AnnotationLine : public AbstractAnnotationLine 28 | { 29 | public: 30 | AnnotationLine(const QPointF &startPosition, const PropertiesPtr &properties); 31 | AnnotationLine(const AnnotationLine &other); 32 | ~AnnotationLine() override = default; 33 | Tools toolType() const override; 34 | 35 | protected: 36 | void updateShape() override; 37 | }; 38 | 39 | } 40 | 41 | #endif // KIMAGEANNOTATOR_ANNOTATIONLINE_H 42 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationPen.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationPen.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationPen::AnnotationPen(const QPointF &startPosition, const PropertiesPtr &properties) : 25 | AbstractAnnotationPath(startPosition, properties) 26 | { 27 | updateShape(); 28 | } 29 | 30 | AnnotationPen::AnnotationPen(const AnnotationPen &other) : AbstractAnnotationPath(other) 31 | { 32 | 33 | } 34 | 35 | Tools AnnotationPen::toolType() const 36 | { 37 | return Tools::Pen; 38 | } 39 | 40 | void AnnotationPen::updateShape() 41 | { 42 | QPainterPath path(*mPath); 43 | setShape(path); 44 | } 45 | 46 | } // namespace kImageAnnotator 47 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationPen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONPEN_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONPEN_H 22 | 23 | #include "AbstractAnnotationPath.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AnnotationPen : public AbstractAnnotationPath 28 | { 29 | public: 30 | AnnotationPen(const QPointF &startPosition, const PropertiesPtr &properties); 31 | AnnotationPen(const AnnotationPen &other); 32 | ~AnnotationPen() override = default; 33 | Tools toolType() const override; 34 | 35 | protected: 36 | void updateShape() override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_ANNOTATIONPEN_H 42 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationPixelate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONPIXELATE_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONPIXELATE_H 22 | 23 | #include "AbstractAnnotationObfuscate.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AnnotationPixelate : public AbstractAnnotationObfuscate 28 | { 29 | public: 30 | AnnotationPixelate(const QPointF &startPosition, const ObfuscatePropertiesPtr &properties); 31 | AnnotationPixelate(const AnnotationPixelate &other); 32 | ~AnnotationPixelate() override = default; 33 | Tools toolType() const override; 34 | 35 | protected: 36 | QImage obfuscateBackground(const QImage &sceneBehindItem) const override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_ANNOTATIONPIXELATE_H 42 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationRect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationRect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationRect::AnnotationRect(const QPointF &startPosition, const PropertiesPtr &properties) : AbstractAnnotationRect(startPosition, properties) 25 | { 26 | } 27 | 28 | AnnotationRect::AnnotationRect(const AnnotationRect &other) : AbstractAnnotationRect(other) 29 | { 30 | } 31 | 32 | Tools AnnotationRect::toolType() const 33 | { 34 | return Tools::Rect; 35 | } 36 | 37 | void AnnotationRect::updateShape() 38 | { 39 | QPainterPath path; 40 | path.addRect(*mRect); 41 | setShape(path); 42 | } 43 | 44 | } // namespace kImageAnnotator 45 | -------------------------------------------------------------------------------- /src/annotations/items/AnnotationRect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONRECT_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONRECT_H 22 | 23 | #include "AbstractAnnotationRect.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AnnotationRect : public AbstractAnnotationRect 28 | { 29 | Q_OBJECT 30 | public: 31 | AnnotationRect(const QPointF &startPosition, const PropertiesPtr &properties); 32 | AnnotationRect(const AnnotationRect &other); 33 | ~AnnotationRect() override = default; 34 | Tools toolType() const override; 35 | 36 | protected: 37 | void updateShape() override; 38 | }; 39 | 40 | } // namespace kImageAnnotator 41 | 42 | #endif // KIMAGEANNOTATOR_ANNOTATIONRECT_H 43 | -------------------------------------------------------------------------------- /src/annotations/items/BaseAnnotationNumber.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "BaseAnnotationNumber.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void BaseAnnotationNumber::setNumber(int number) 25 | { 26 | mNumberString = QString::number(number); 27 | updateRect(); 28 | } 29 | 30 | int BaseAnnotationNumber::number() const 31 | { 32 | return mNumberString.toInt(); 33 | } 34 | 35 | QString BaseAnnotationNumber::numberString() const 36 | { 37 | return mNumberString; 38 | } 39 | 40 | void BaseAnnotationNumber::updateRect(QRectF *rect, const QFont &font) const 41 | { 42 | mNumberRectHelper.updateRect(rect, mNumberString, font); 43 | } 44 | 45 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/items/helper/AnnotationShapeCreator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONSHAPECREATOR_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONSHAPECREATOR_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class AnnotationShapeCreator 29 | { 30 | public: 31 | static QPolygonF createPointer(qreal width, qreal length); 32 | static QPolygonF createArrowHead(int scaleFactor); 33 | static QPolygonF translate(const QPolygonF &shape, const QPointF &pos, qreal angle); 34 | }; 35 | 36 | } // namespace kImageAnnotator 37 | 38 | #endif //KIMAGEANNOTATOR_ANNOTATIONSHAPECREATOR_H 39 | -------------------------------------------------------------------------------- /src/annotations/items/helper/NumberRectHelper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "NumberRectHelper.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void NumberRectHelper::updateRect(QRectF *rect, const QString &text, const QFont &font) const 25 | { 26 | auto center = rect->center(); 27 | auto size = getTextRectSize(text, font); 28 | rect->setSize(size); 29 | rect->moveCenter(center); 30 | } 31 | 32 | QSizeF NumberRectHelper::getTextRectSize(const QString &text, const QFont &font) const 33 | { 34 | QFontMetricsF metrics(font); 35 | auto boundingRect = metrics.boundingRect(text).adjusted(-5, -5, 5, 5); 36 | auto largestSite = boundingRect.width() > boundingRect.height() ? boundingRect.width() : boundingRect.height(); 37 | return { largestSite, largestSite }; 38 | } 39 | 40 | } // namespace kImageAnnotator 41 | -------------------------------------------------------------------------------- /src/annotations/items/helper/NumberRectHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_NUMBERRECTHELPER_H 21 | #define KIMAGEANNOTATOR_NUMBERRECTHELPER_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace kImageAnnotator { 30 | 31 | class NumberRectHelper 32 | { 33 | public: 34 | NumberRectHelper() = default; 35 | ~NumberRectHelper() = default; 36 | void updateRect(QRectF *rect, const QString &text, const QFont &font) const; 37 | 38 | protected: 39 | QSizeF getTextRectSize(const QString &text, const QFont &font) const; 40 | }; 41 | 42 | } // namespace kImageAnnotator 43 | 44 | #endif //KIMAGEANNOTATOR_NUMBERRECTHELPER_H 45 | -------------------------------------------------------------------------------- /src/annotations/items/interfaces/EditableItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_EDITABLEITEM_H 21 | #define KIMAGEANNOTATOR_EDITABLEITEM_H 22 | 23 | class EditableItem 24 | { 25 | public: 26 | virtual void enableEditing() = 0; 27 | virtual void disableEditing() = 0; 28 | }; 29 | 30 | #endif //KIMAGEANNOTATOR_EDITABLEITEM_H 31 | -------------------------------------------------------------------------------- /src/annotations/items/text/CapsLockStatusChecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CAPSLOCKSTATUSCHECKER_H 21 | #define KIMAGEANNOTATOR_CAPSLOCKSTATUSCHECKER_H 22 | 23 | namespace kImageAnnotator { 24 | 25 | class CapsLockStatusChecker 26 | { 27 | public: 28 | static bool isCapsLockEnabled(); 29 | 30 | protected: 31 | explicit CapsLockStatusChecker() = default; 32 | ~CapsLockStatusChecker() = default; 33 | }; 34 | 35 | } // namespace kImageAnnotator 36 | 37 | #endif //KIMAGEANNOTATOR_CAPSLOCKSTATUSCHECKER_H 38 | -------------------------------------------------------------------------------- /src/annotations/misc/AbstractCloneableItemEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AbstractClonableItemEffect.h" 21 | -------------------------------------------------------------------------------- /src/annotations/misc/AbstractCloneableItemEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ABSTRACTITEMEFFECT_H 21 | #define KIMAGEANNOTATOR_ABSTRACTITEMEFFECT_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AbstractClonableItemEffect 28 | { 29 | 30 | }; 31 | 32 | } // namespace kImageAnnotator 33 | 34 | #endif //KIMAGEANNOTATOR_ABSTRACTITEMEFFECT_H 35 | -------------------------------------------------------------------------------- /src/annotations/misc/CanvasPainter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CANVASPAINTER_H 21 | #define KIMAGEANNOTATOR_CANVASPAINTER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class CanvasPainter 28 | { 29 | public: 30 | CanvasPainter(); 31 | ~CanvasPainter(); 32 | void paint(QPainter *painter, const QRectF &rect, const QColor &color); 33 | 34 | private: 35 | QImage *mCanvasBackground; 36 | void createTiledBackground(); 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_CANVASPAINTER_H 42 | -------------------------------------------------------------------------------- /src/annotations/misc/ImageBlurrer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_IMAGEBLURRER_H 21 | #define KIMAGEANNOTATOR_IMAGEBLURRER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class ImageBlurrer 28 | { 29 | public: 30 | explicit ImageBlurrer() = default; 31 | ~ImageBlurrer() = default; 32 | 33 | QImage blurred(const QImage &image, int radius, bool alphaOnly) const; 34 | 35 | private: 36 | int getAlpha(int radius) const; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_IMAGEBLURRER_H 42 | -------------------------------------------------------------------------------- /src/annotations/misc/itemEffects/NoEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "NoEffect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void NoEffect::draw(QPainter *painter) 25 | { 26 | QPoint offset; 27 | const auto pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset); 28 | painter->drawPixmap(offset, pixmap); 29 | } 30 | 31 | } // namespace kImageAnnotator 32 | -------------------------------------------------------------------------------- /src/annotations/misc/itemEffects/NoEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_NOEFFECT_H 21 | #define KIMAGEANNOTATOR_NOEFFECT_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class NoEffect : public QGraphicsEffect 29 | { 30 | public: 31 | explicit NoEffect() = default; 32 | ~NoEffect() override = default; 33 | 34 | protected: 35 | void draw(QPainter * painter) override; 36 | }; 37 | 38 | } // namespace kImageAnnotator 39 | 40 | 41 | #endif //KIMAGEANNOTATOR_NOEFFECT_H 42 | -------------------------------------------------------------------------------- /src/annotations/misc/itemEffects/ShadowEffect.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ShadowEffect.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | ShadowEffect::ShadowEffect() 25 | { 26 | setColor(QColor(63, 63, 63, 190)); 27 | setBlurRadius(7); 28 | setOffset(QPoint(2, 2)); 29 | } 30 | 31 | } // namespace kImageAnnotator 32 | -------------------------------------------------------------------------------- /src/annotations/misc/itemEffects/ShadowEffect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SHADOWEFFECT_H 21 | #define KIMAGEANNOTATOR_SHADOWEFFECT_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class ShadowEffect : public QGraphicsDropShadowEffect 28 | { 29 | public: 30 | explicit ShadowEffect(); 31 | ~ShadowEffect() override = default; 32 | }; 33 | 34 | } // namespace kImageAnnotator 35 | 36 | #endif //KIMAGEANNOTATOR_SHADOWEFFECT_H 37 | -------------------------------------------------------------------------------- /src/annotations/modifiers/resizeHandles/LineResizeHandles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_LINERESIZEHANDLES_H 21 | #define KIMAGEANNOTATOR_LINERESIZEHANDLES_H 22 | 23 | #include "AbstractItemResizeHandles.h" 24 | #include "src/annotations/items/AbstractAnnotationLine.h" 25 | #include "src/common/helper/ShapeHelper.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class LineResizeHandles : public AbstractItemResizeHandles 30 | { 31 | public: 32 | LineResizeHandles(AbstractAnnotationLine *lineItem, double zoomValue); 33 | ~LineResizeHandles() override = default; 34 | void update() override; 35 | 36 | protected: 37 | void initCursors() override; 38 | 39 | private: 40 | AbstractAnnotationLine *mLineItem; 41 | }; 42 | 43 | } // namespace kImageAnnotator 44 | 45 | #endif //KIMAGEANNOTATOR_LINERESIZEHANDLES_H 46 | -------------------------------------------------------------------------------- /src/annotations/modifiers/resizeHandles/PathResizeHandles.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "PathResizeHandles.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | PathResizeHandles::PathResizeHandles(AbstractAnnotationPath *pathItem, double zoomValue) : 25 | mPathItem(pathItem) 26 | { 27 | initHandles(8, zoomValue); 28 | initCursors(); 29 | update(); 30 | } 31 | 32 | QRectF PathResizeHandles::getRect() const 33 | { 34 | return getItemBoundingRect(); 35 | } 36 | 37 | double PathResizeHandles::getOffset() const 38 | { 39 | return 0.0; 40 | } 41 | 42 | QRectF PathResizeHandles::getItemBoundingRect() const 43 | { 44 | return mPathItem->boundingRect(); 45 | } 46 | 47 | } // namespace kImageAnnotator 48 | -------------------------------------------------------------------------------- /src/annotations/modifiers/resizeHandles/PointerRectResizeHandles.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_POINTERRECTRESIZEHANDLES_H 21 | #define KIMAGEANNOTATOR_POINTERRECTRESIZEHANDLES_H 22 | 23 | #include "RectResizeHandles.h" 24 | #include "src/annotations/items/AbstractAnnotationPointerRect.h" 25 | 26 | namespace kImageAnnotator { 27 | 28 | class PointerRectResizeHandles : public RectResizeHandles 29 | { 30 | public: 31 | PointerRectResizeHandles(AbstractAnnotationPointerRect *pointerRectItem, double zoomValue); 32 | ~PointerRectResizeHandles() override = default; 33 | void update() override; 34 | 35 | protected: 36 | void initCursors() override; 37 | 38 | private: 39 | AbstractAnnotationPointerRect *mPointerRectItem; 40 | }; 41 | 42 | } // namespace kImageAnnotator 43 | 44 | #endif //KIMAGEANNOTATOR_POINTERRECTRESIZEHANDLES_H 45 | -------------------------------------------------------------------------------- /src/annotations/modifiers/resizeHandles/RectResizeHandles.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "RectResizeHandles.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | RectResizeHandles::RectResizeHandles(AbstractAnnotationRect *rectItem, double zoomValue) : 25 | mRectItem(rectItem) 26 | { 27 | initHandles(8, zoomValue); 28 | initCursors(); 29 | update(); 30 | } 31 | 32 | QRectF RectResizeHandles::getRect() const 33 | { 34 | return mRectItem->rect(); 35 | } 36 | 37 | double RectResizeHandles::getOffset() const 38 | { 39 | return 0.5 * mRectItem->properties()->width(); 40 | } 41 | 42 | QRectF RectResizeHandles::getItemBoundingRect() const 43 | { 44 | return mRectItem->rect().normalized(); 45 | } 46 | 47 | } // namespace kImageAnnotator 48 | -------------------------------------------------------------------------------- /src/annotations/modifiers/resizeHandles/ResizeHandle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_RESIZEHANDLE_H 21 | #define KIMAGEANNOTATOR_RESIZEHANDLE_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class ResizeHandle : public QRectF 28 | { 29 | public: 30 | explicit ResizeHandle(double zoomValue = 1.0); 31 | ~ResizeHandle() = default; 32 | 33 | QPointF anchor() const; 34 | void setAnchor(const QPointF &pos); 35 | 36 | void applyZoomValue(double value); 37 | double handleSize() const; 38 | 39 | private: 40 | static double mDefaultHandleSize; 41 | 42 | QPointF mOffset; 43 | }; 44 | 45 | } // namespace kImageAnnotator 46 | 47 | #endif //KIMAGEANNOTATOR_RESIZEHANDLE_H 48 | -------------------------------------------------------------------------------- /src/annotations/properties/AnnotationObfuscateProperties.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationObfuscateProperties.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationObfuscateProperties::AnnotationObfuscateProperties(const AnnotationObfuscateProperties &other) : 25 | AnnotationProperties(other), 26 | mFactor(1) 27 | { 28 | mFactor = other.mFactor; 29 | } 30 | 31 | PropertiesPtr AnnotationObfuscateProperties::clone() const 32 | { 33 | return PropertiesPtr(new AnnotationObfuscateProperties(*this)); 34 | } 35 | 36 | int AnnotationObfuscateProperties::factor() const 37 | { 38 | return mFactor; 39 | } 40 | 41 | void AnnotationObfuscateProperties::setFactor(int factor) 42 | { 43 | mFactor = factor; 44 | } 45 | 46 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/properties/AnnotationTextProperties.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationTextProperties.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationTextProperties::AnnotationTextProperties(const QColor &color, int size) : AnnotationProperties(color, size) 25 | { 26 | 27 | } 28 | 29 | AnnotationTextProperties::AnnotationTextProperties(const AnnotationTextProperties &other) : AnnotationProperties(other) 30 | { 31 | mFont = other.mFont; 32 | } 33 | 34 | PropertiesPtr AnnotationTextProperties::clone() const 35 | { 36 | return PropertiesPtr(new AnnotationTextProperties(*this)); 37 | } 38 | 39 | QFont AnnotationTextProperties::font() const 40 | { 41 | return mFont; 42 | } 43 | 44 | void AnnotationTextProperties::setFont(const QFont &font) 45 | { 46 | mFont = font; 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/annotations/undo/AddCommand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AddCommand.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AddCommand::AddCommand(AbstractAnnotationItem *item, AnnotationArea *annotationArea) 25 | { 26 | mItem = item; 27 | mAnnotationArea = annotationArea; 28 | } 29 | 30 | void AddCommand::undo() 31 | { 32 | mAnnotationArea->removeAnnotationItem(mItem); 33 | mItem->hide(); 34 | } 35 | 36 | void AddCommand::redo() 37 | { 38 | mAnnotationArea->addAnnotationItem(mItem); 39 | mItem->show(); 40 | } 41 | 42 | } // namespace kImageAnnotator 43 | -------------------------------------------------------------------------------- /src/annotations/undo/AddCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ADDCOMMAND_H 21 | #define KIMAGEANNOTATOR_ADDCOMMAND_H 22 | 23 | #include 24 | 25 | #include "src/annotations/items/AbstractAnnotationItem.h" 26 | #include "src/annotations/core/AnnotationArea.h" 27 | 28 | namespace kImageAnnotator { 29 | 30 | class AnnotationArea; 31 | 32 | class AddCommand : public QUndoCommand 33 | { 34 | public: 35 | AddCommand(AbstractAnnotationItem *item, AnnotationArea *annotationArea); 36 | ~AddCommand() = default; 37 | virtual void undo() override; 38 | virtual void redo() override; 39 | 40 | private: 41 | AbstractAnnotationItem *mItem; 42 | AnnotationArea *mAnnotationArea; 43 | }; 44 | 45 | } // namespace kImageAnnotator 46 | 47 | #endif //KIMAGEANNOTATOR_ADDCOMMAND_H 48 | -------------------------------------------------------------------------------- /src/annotations/undo/ChangePropertiesCommand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ChangePropertiesCommand.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | ChangePropertiesCommand::ChangePropertiesCommand(AbstractAnnotationItem *item, const PropertiesPtr &properties) 25 | { 26 | mItem = item; 27 | mNewProperties = properties; 28 | mOldProperties = mItem->properties(); 29 | } 30 | 31 | void ChangePropertiesCommand::undo() 32 | { 33 | mItem->setProperties(mOldProperties); 34 | } 35 | 36 | void ChangePropertiesCommand::redo() 37 | { 38 | mItem->setProperties(mNewProperties); 39 | } 40 | 41 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/undo/CropCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CROPCOMMAND_H 21 | #define KIMAGEANNOTATOR_CROPCOMMAND_H 22 | 23 | #include 24 | 25 | #include "src/annotations/core/AnnotationArea.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class CropCommand : public QUndoCommand 30 | { 31 | public: 32 | CropCommand(QGraphicsPixmapItem *backgroundImage, const QRectF &cropRect, AnnotationArea *annotationArea); 33 | ~CropCommand() override = default; 34 | void undo() override; 35 | void redo() override; 36 | 37 | private: 38 | AnnotationArea *mAnnotationArea; 39 | QPixmap mOriginalImage; 40 | QPixmap mCroppedImage; 41 | QGraphicsPixmapItem *mBackgroundImage; 42 | QPointF mNewItemOffset; 43 | }; 44 | 45 | } // namespace kImageAnnotator 46 | 47 | #endif //KIMAGEANNOTATOR_CROPCOMMAND_H 48 | -------------------------------------------------------------------------------- /src/annotations/undo/DeleteCommand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "DeleteCommand.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | DeleteCommand::DeleteCommand(QList items, AnnotationArea *annotationArea) 25 | { 26 | mItems = items; 27 | mAnnotationArea = annotationArea; 28 | } 29 | 30 | void DeleteCommand::undo() 31 | { 32 | for (auto item : mItems) { 33 | mAnnotationArea->addAnnotationItem(item); 34 | item->show(); 35 | } 36 | } 37 | 38 | void DeleteCommand::redo() 39 | { 40 | for (auto item : mItems) { 41 | mAnnotationArea->removeAnnotationItem(item); 42 | item->hide(); 43 | } 44 | } 45 | 46 | } // namespace kImageAnnotator 47 | -------------------------------------------------------------------------------- /src/annotations/undo/DeleteCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_DELETECOMMAND_H 21 | #define KIMAGEANNOTATOR_DELETECOMMAND_H 22 | 23 | #include 24 | 25 | #include "src/annotations/items/AbstractAnnotationItem.h" 26 | #include "src/annotations/core/AnnotationArea.h" 27 | 28 | namespace kImageAnnotator { 29 | 30 | class AnnotationArea; 31 | 32 | class DeleteCommand : public QUndoCommand 33 | { 34 | public: 35 | DeleteCommand(QList items, AnnotationArea *annotationArea); 36 | virtual void undo() override; 37 | virtual void redo() override; 38 | 39 | private: 40 | QList mItems; 41 | AnnotationArea *mAnnotationArea; 42 | }; 43 | 44 | } // namespace kImageAnnotator 45 | 46 | #endif //KIMAGEANNOTATOR_DELETECOMMAND_H 47 | -------------------------------------------------------------------------------- /src/annotations/undo/FlipCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_FLIPCOMMAND_H 21 | #define KIMAGEANNOTATOR_FLIPCOMMAND_H 22 | 23 | #include 24 | #include 25 | 26 | #include "src/common/enum/FlipDirection.h" 27 | 28 | namespace kImageAnnotator { 29 | 30 | class FlipCommand : public QUndoCommand 31 | { 32 | public: 33 | FlipCommand(QGraphicsPixmapItem *backgroundImage, FlipDirection direction); 34 | ~FlipCommand() override = default; 35 | void undo() override; 36 | void redo() override; 37 | 38 | private: 39 | QGraphicsPixmapItem *mBackgroundImage; 40 | QPixmap mOldPixmap; 41 | QPixmap mNewPixmap; 42 | 43 | static QPixmap flipPixmap(const QPixmap &sourcePixmap, FlipDirection direction); 44 | }; 45 | 46 | } // namespace kImageAnnotator 47 | 48 | #endif //KIMAGEANNOTATOR_FLIPCOMMAND_H 49 | -------------------------------------------------------------------------------- /src/annotations/undo/PasteCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_PASTECOMMAND_H 21 | #define KIMAGEANNOTATOR_PASTECOMMAND_H 22 | 23 | #include 24 | 25 | #include "src/annotations/core/AnnotationArea.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class PasteCommand : public QUndoCommand 30 | { 31 | public: 32 | PasteCommand(const QHash &itemsWithOffset, const QPointF &position, AnnotationItemFactory *itemFactory, AnnotationArea *annotationArea); 33 | ~PasteCommand(); 34 | void undo() override; 35 | void redo() override; 36 | 37 | private: 38 | AnnotationArea *mAnnotationArea; 39 | QVector mPastedItems; 40 | }; 41 | 42 | } // namespace kImageAnnotator 43 | 44 | #endif //KIMAGEANNOTATOR_PASTECOMMAND_H 45 | -------------------------------------------------------------------------------- /src/annotations/undo/UndoStack.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "UndoStack.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/annotations/undo/UndoStack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_UNDOSTACK_H 21 | #define KIMAGEANNOTATOR_UNDOSTACK_H 22 | 23 | #include 24 | 25 | #include "AddCommand.h" 26 | #include "DeleteCommand.h" 27 | 28 | namespace kImageAnnotator { 29 | 30 | class UndoStack : public QUndoStack 31 | { 32 | public: 33 | explicit UndoStack() = default; 34 | ~UndoStack() override = default; 35 | }; 36 | 37 | } // namespace kImageAnnotator 38 | 39 | #endif //KIMAGEANNOTATOR_UNDOSTACK_H 40 | -------------------------------------------------------------------------------- /src/backend/ISettings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ISETTINGS_H 21 | #define KIMAGEANNOTATOR_ISETTINGS_H 22 | 23 | namespace kImageAnnotator { 24 | 25 | class ISettings 26 | { 27 | public: 28 | explicit ISettings() = default; 29 | virtual ~ISettings() = default; 30 | virtual void sync() = 0; 31 | virtual void setValue(const QString &key, const QVariant &value) = 0; 32 | virtual QVariant value(const QString &key, const QVariant &defaultValue) const = 0; 33 | }; 34 | 35 | } // namespace kImageAnnotator 36 | 37 | #endif //KIMAGEANNOTATOR_ISETTINGS_H 38 | -------------------------------------------------------------------------------- /src/backend/SettingsAdapter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "SettingsAdapter.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void SettingsAdapter::sync() 25 | { 26 | mSettings.sync(); 27 | } 28 | 29 | void SettingsAdapter::setValue(const QString &key, const QVariant &value) 30 | { 31 | mSettings.setValue(key, value); 32 | } 33 | 34 | QVariant SettingsAdapter::value(const QString &key, const QVariant &defaultValue) const 35 | { 36 | return mSettings.value(key, defaultValue); 37 | } 38 | 39 | } // namespace kImageAnnotator 40 | -------------------------------------------------------------------------------- /src/backend/SettingsAdapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SETTINGSADAPTER_H 21 | #define KIMAGEANNOTATOR_SETTINGSADAPTER_H 22 | 23 | #include 24 | 25 | #include "ISettings.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class SettingsAdapter : public ISettings 30 | { 31 | public: 32 | explicit SettingsAdapter() = default; 33 | ~SettingsAdapter() override = default; 34 | void sync() override; 35 | void setValue(const QString &key, const QVariant &value) override; 36 | QVariant value(const QString &key, const QVariant &defaultValue) const override; 37 | 38 | private: 39 | QSettings mSettings; 40 | }; 41 | 42 | } // namespace kImageAnnotator 43 | 44 | #endif //KIMAGEANNOTATOR_SETTINGSADAPTER_H 45 | -------------------------------------------------------------------------------- /src/common/constants/Constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONCONSTANTS_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONCONSTANTS_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | inline namespace Constants { 29 | 30 | const int MinPathResizeRectSize = 20; 31 | 32 | const int ResizeHandleSize = 16; 33 | 34 | const QSize SettingsWidgetSize(64, 32); 35 | 36 | const QSize ToolButtonIconSize(28, 28); 37 | 38 | const QSize MenuItemIconSize(20, 20); 39 | 40 | const QSize SettingsWidgetIconSize(20, 20); 41 | 42 | const QColor HoverColor(173, 216, 230); // "#add8e6" 43 | 44 | } // namespace Constants 45 | 46 | } // namespace kImageAnnotator 47 | 48 | #endif //KIMAGEANNOTATOR_ANNOTATIONCONSTANTS_H 49 | -------------------------------------------------------------------------------- /src/common/enum/DesktopEnvironmentType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_DESKTOPENVIRONMENTTYPE_H 21 | #define KIMAGEANNOTATOR_DESKTOPENVIRONMENTTYPE_H 22 | 23 | namespace kImageAnnotator { 24 | 25 | enum class DesktopEnvironmentType 26 | { 27 | Unknown, 28 | Kde, 29 | Gnome 30 | }; 31 | 32 | } // namespace kImageAnnotator 33 | 34 | #endif //KIMAGEANNOTATOR_DESKTOPENVIRONMENTTYPE_H 35 | -------------------------------------------------------------------------------- /src/common/enum/FillModes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_FILLMODES_H 21 | #define KIMAGEANNOTATOR_FILLMODES_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | enum class FillModes 28 | { 29 | BorderAndNoFill, 30 | BorderAndFill, 31 | NoBorderAndNoFill, 32 | NoBorderAndFill 33 | }; 34 | 35 | } // namespace kImageAnnotator 36 | 37 | Q_DECLARE_METATYPE(kImageAnnotator::FillModes); 38 | 39 | #endif // KIMAGEANNOTATOR_FILLMODES_H 40 | -------------------------------------------------------------------------------- /src/common/enum/FlipDirection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_FLIPDIRECTION_H 21 | #define KIMAGEANNOTATOR_FLIPDIRECTION_H 22 | 23 | namespace kImageAnnotator { 24 | 25 | enum class FlipDirection 26 | { 27 | Horizontal, 28 | Vertical 29 | }; 30 | 31 | } // namespace kImageAnnotator 32 | 33 | Q_DECLARE_METATYPE(kImageAnnotator::FlipDirection); 34 | 35 | #endif //KIMAGEANNOTATOR_FLIPDIRECTION_H 36 | -------------------------------------------------------------------------------- /src/common/enum/ImageEffects.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_IMAGEEFFECTS_H 21 | #define KIMAGEANNOTATOR_IMAGEEFFECTS_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | enum class ImageEffects 28 | { 29 | NoEffect, 30 | DropShadow, 31 | Grayscale, 32 | Border, 33 | InvertColor, 34 | }; 35 | 36 | } // namespace kImageAnnotator 37 | 38 | Q_DECLARE_METATYPE(kImageAnnotator::ImageEffects); 39 | 40 | #endif // KIMAGEANNOTATOR_IMAGEEFFECTS_H 41 | -------------------------------------------------------------------------------- /src/common/enum/NumberUpdateMode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_NUMBERUPDATEMODE_H 21 | #define KIMAGEANNOTATOR_NUMBERUPDATEMODE_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | enum class NumberUpdateMode 28 | { 29 | UpdateAllNumbers, 30 | UpdateOnlyNewNumbers 31 | }; 32 | 33 | } // namespace kImageAnnotator 34 | 35 | #endif // KIMAGEANNOTATOR_NUMBERUPDATEMODE_H 36 | -------------------------------------------------------------------------------- /src/common/enum/Tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_TOOLS_H 21 | #define KIMAGEANNOTATOR_TOOLS_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | enum class Tools 28 | { 29 | Select, 30 | Pen, 31 | MarkerPen, 32 | MarkerRect, 33 | MarkerEllipse, 34 | Line, 35 | Arrow, 36 | DoubleArrow, 37 | Rect, 38 | Ellipse, 39 | Number, 40 | NumberPointer, 41 | NumberArrow, 42 | Text, 43 | TextPointer, 44 | TextArrow, 45 | Blur, 46 | Image, 47 | Sticker, 48 | Pixelate, 49 | Duplicate 50 | }; 51 | 52 | inline uint qHash(const Tools &tool, uint seed) 53 | { 54 | Q_UNUSED(seed) 55 | 56 | return static_cast(tool); 57 | } 58 | 59 | } // namespace kImageAnnotator 60 | 61 | Q_DECLARE_METATYPE(kImageAnnotator::Tools) 62 | 63 | #endif // KIMAGEANNOTATOR_TOOLS_H 64 | -------------------------------------------------------------------------------- /src/common/filter/IKeyEventListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_IKEYEVENTLISTENER_H 21 | #define KIMAGEANNOTATOR_IKEYEVENTLISTENER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class IKeyEventListener 28 | { 29 | public: 30 | virtual void keyPressed(QKeyEvent *keyEvent) = 0; 31 | virtual void keyReleased(QKeyEvent *keyEvent) = 0; 32 | }; 33 | 34 | } // namespace kImageAnnotator 35 | 36 | #endif //KIMAGEANNOTATOR_IKEYEVENTLISTENER_H 37 | -------------------------------------------------------------------------------- /src/common/filter/IgnoreShortcutsFilter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "IgnoreShortcutsFilter.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void IgnoreShortcutsFilter::apply() 25 | { 26 | QCoreApplication::instance()->installEventFilter(this); 27 | } 28 | 29 | void IgnoreShortcutsFilter::remove() 30 | { 31 | QCoreApplication::instance()->removeEventFilter(this); 32 | } 33 | 34 | bool IgnoreShortcutsFilter::eventFilter(QObject *watched, QEvent *event) 35 | { 36 | if(event->type() == QEvent::ShortcutOverride) { 37 | event->accept(); 38 | return true; 39 | } 40 | 41 | return QObject::eventFilter(watched, event); 42 | } 43 | 44 | } // namespace kImageAnnotator 45 | -------------------------------------------------------------------------------- /src/common/filter/IgnoreShortcutsFilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_IGNORESHORTCUTSFILTER_H 21 | #define KIMAGEANNOTATOR_IGNORESHORTCUTSFILTER_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class IgnoreShortcutsFilter : public QObject 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit IgnoreShortcutsFilter() = default; 33 | ~IgnoreShortcutsFilter() override = default; 34 | void apply(); 35 | void remove(); 36 | 37 | protected: 38 | bool eventFilter(QObject *watched, QEvent *event) override; 39 | }; 40 | 41 | } // namespace kImageAnnotator 42 | 43 | #endif //KIMAGEANNOTATOR_IGNORESHORTCUTSFILTER_H 44 | -------------------------------------------------------------------------------- /src/common/helper/CursorHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CURSORHELPER_H 21 | #define KIMAGEANNOTATOR_CURSORHELPER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class CursorHelper 28 | { 29 | public: 30 | Qt::CursorShape static defaultCursor(); 31 | Qt::CursorShape static verticalResizeCursor(); 32 | Qt::CursorShape static horizontalResizeCursor(); 33 | Qt::CursorShape static bDiagResizeCursor(); 34 | Qt::CursorShape static fDiagResizeCursor(); 35 | Qt::CursorShape static allResizeCursor(); 36 | Qt::CursorShape static movableCursor(); 37 | Qt::CursorShape static movingCursor(); 38 | }; 39 | 40 | } // namespace kImageAnnotator 41 | 42 | #endif // KIMAGEANNOTATOR_CURSORHELPER_H 43 | -------------------------------------------------------------------------------- /src/common/helper/DesktopEnvironmentChecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_DESKTOPENVIRONMENTCHECKER_H 21 | #define KIMAGEANNOTATOR_DESKTOPENVIRONMENTCHECKER_H 22 | 23 | #include 24 | 25 | #include "src/common/enum/DesktopEnvironmentType.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class DesktopEnvironmentChecker 30 | { 31 | public: 32 | DesktopEnvironmentChecker() = default; 33 | ~DesktopEnvironmentChecker() = default; 34 | 35 | DesktopEnvironmentType getDesktopEnvironment(); 36 | 37 | static bool contains(const QString &value1, const QLatin1String &value2) ; 38 | }; 39 | 40 | } // namespace kImageAnnotator 41 | 42 | #endif //KIMAGEANNOTATOR_DESKTOPENVIRONMENTCHECKER_H 43 | -------------------------------------------------------------------------------- /src/common/helper/IconLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ICONLOADER_H 21 | #define KIMAGEANNOTATOR_ICONLOADER_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | namespace kImageAnnotator { 28 | 29 | class IconLoader 30 | { 31 | public: 32 | static QIcon load(const QString &name); 33 | static QPixmap loadAsPixmap(const QString &name); 34 | 35 | private: 36 | IconLoader() = default; 37 | ~IconLoader() = default; 38 | static bool isDarkTheme(); 39 | static QString getThemePrefix(); 40 | static double getThemeLuma(); 41 | }; 42 | 43 | } // namespace kImageAnnotator 44 | 45 | #endif //KIMAGEANNOTATOR_ICONLOADER_H 46 | -------------------------------------------------------------------------------- /src/common/helper/ItemHelper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ItemHelper.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | bool ItemHelper::zValueGreaterThen(const AbstractAnnotationItem *item1, const AbstractAnnotationItem *item2) 25 | { 26 | return item1->zValue() > item2->zValue(); 27 | } 28 | 29 | void ItemHelper::sortItemsByZValueDesc(QList *items) 30 | { 31 | std::sort(items->begin(), items->end(), ItemHelper::zValueGreaterThen); 32 | } 33 | 34 | } // namespace kImageAnnotator 35 | -------------------------------------------------------------------------------- /src/common/helper/ItemHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ITEMHELPER_H 21 | #define KIMAGEANNOTATOR_ITEMHELPER_H 22 | 23 | #include "src/annotations/items/AbstractAnnotationItem.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class ItemHelper 28 | { 29 | public: 30 | static bool zValueGreaterThen(const AbstractAnnotationItem *item1, const AbstractAnnotationItem *item2); 31 | static void sortItemsByZValueDesc(QList *items); 32 | }; 33 | 34 | } // namespace kImageAnnotator 35 | 36 | #endif //KIMAGEANNOTATOR_ITEMHELPER_H 37 | -------------------------------------------------------------------------------- /src/common/helper/MathHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_MATHHELPER_H 21 | #define KIMAGEANNOTATOR_MATHHELPER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class MathHelper 28 | { 29 | public: 30 | static qreal roundAngleTo(qreal currentAngle, int increments); 31 | static qreal smallerValue(qreal value1, qreal value2); 32 | static qreal distanceBetweenPoints(const QPointF &point1, const QPointF &point2); 33 | }; 34 | 35 | } // namespace kImageAnnotator 36 | 37 | #endif // KIMAGEANNOTATOR_MATHHELPER_H 38 | -------------------------------------------------------------------------------- /src/common/helper/PathHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_PATHHELPER_H 21 | #define KIMAGEANNOTATOR_PATHHELPER_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class PathHelper 29 | { 30 | public: 31 | static QString extractFilename(const QString &path); 32 | static QString extractFilenameWithFormat(const QString &path); 33 | static QString prettyFilename(const QString &filename); 34 | }; 35 | 36 | } // namespace kImageAnnotator 37 | 38 | #endif //KIMAGEANNOTATOR_PATHHELPER_H 39 | -------------------------------------------------------------------------------- /src/common/helper/RectSizeHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_RECTSIZEHELPER_H 21 | #define KIMAGEANNOTATOR_RECTSIZEHELPER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class RectSizeHelper 28 | { 29 | public: 30 | static QRectF setSizeButKeepDirection(const QRectF &rect, const QSizeF &newSize); 31 | static QRectF limitToSize(const QRectF &rect, const QSizeF &minSize); 32 | 33 | private: 34 | RectSizeHelper() = default; 35 | ~RectSizeHelper() = default; 36 | 37 | static qreal getSign(const qreal &value); 38 | }; 39 | 40 | } // namespace kImageAnnotator 41 | 42 | #endif //KIMAGEANNOTATOR_RECTSIZEHELPER_H 43 | -------------------------------------------------------------------------------- /src/common/platform/PlatformChecker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "PlatformChecker.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | PlatformChecker *PlatformChecker::instance() 25 | { 26 | static PlatformChecker instance; 27 | return &instance; 28 | } 29 | 30 | bool PlatformChecker::isWayland() const 31 | { 32 | return mIsWayland; 33 | } 34 | 35 | PlatformChecker::PlatformChecker() 36 | { 37 | auto output = qgetenv("XDG_CURRENT_DESKTOP"); 38 | mIsWayland = output.contains("wayland"); 39 | } 40 | 41 | } // namespace kImageAnnotator 42 | -------------------------------------------------------------------------------- /src/common/platform/PlatformChecker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_PLATFORMCHECKER_H 21 | #define KIMAGEANNOTATOR_PLATFORMCHECKER_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class PlatformChecker 28 | { 29 | public: 30 | virtual ~PlatformChecker() = default; 31 | 32 | static PlatformChecker *instance(); 33 | 34 | bool isWayland() const; 35 | 36 | private: 37 | bool mIsWayland; 38 | 39 | PlatformChecker(); 40 | }; 41 | 42 | } // namespace kImageAnnotator 43 | 44 | #endif //KIMAGEANNOTATOR_PLATFORMCHECKER_H 45 | -------------------------------------------------------------------------------- /src/common/provider/DevicePixelRatioScaler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "DevicePixelRatioScaler.h" 21 | 22 | #include 23 | 24 | namespace kImageAnnotator { 25 | 26 | QRectF DevicePixelRatioScaler::scale(const QRectF &rect) const 27 | { 28 | auto factor = scaleFactor(); 29 | return {rect.left() * factor, rect.top() * factor, rect.width() * factor, rect.height() * factor}; 30 | } 31 | 32 | qreal DevicePixelRatioScaler::scaleFactor() const 33 | { 34 | return qGuiApp->devicePixelRatio(); 35 | } 36 | 37 | } // namespace kImageAnnotator 38 | -------------------------------------------------------------------------------- /src/common/provider/DevicePixelRatioScaler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_DEVICEPIXELRATIOSCALER_H 21 | #define KIMAGEANNOTATOR_DEVICEPIXELRATIOSCALER_H 22 | 23 | #include 24 | 25 | #include "IDevicePixelRatioScaler.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class DevicePixelRatioScaler : public IDevicePixelRatioScaler 30 | { 31 | public: 32 | DevicePixelRatioScaler() = default; 33 | ~DevicePixelRatioScaler() override = default; 34 | 35 | QRectF scale(const QRectF &rect) const override; 36 | qreal scaleFactor() const override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_DEVICEPIXELRATIOSCALER_H 42 | -------------------------------------------------------------------------------- /src/common/provider/IDevicePixelRatioScaler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_IDEVICEPIXELRATIOSCALER_H 21 | #define KIMAGEANNOTATOR_IDEVICEPIXELRATIOSCALER_H 22 | 23 | namespace kImageAnnotator { 24 | 25 | class IDevicePixelRatioScaler 26 | { 27 | public: 28 | virtual ~IDevicePixelRatioScaler() = default; 29 | virtual QRectF scale(const QRectF &rect) const = 0; 30 | virtual qreal scaleFactor() const = 0; 31 | }; 32 | 33 | } // namespace kImageAnnotator 34 | 35 | #endif //KIMAGEANNOTATOR_IDEVICEPIXELRATIOSCALER_H 36 | -------------------------------------------------------------------------------- /src/gui/annotator/AnnotationView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AnnotationView.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | AnnotationView::AnnotationView(QWidget *parent) : 25 | ScrollAndZoomView(parent) 26 | { 27 | 28 | } 29 | 30 | void AnnotationView::drawBackground(QPainter *painter, const QRectF &rect) 31 | { 32 | auto annotationArea = dynamic_cast(scene()); 33 | mCanvasPainter.paint(painter, annotationArea->canvasRect(), annotationArea->canvasColor()); 34 | } 35 | 36 | } // namespace kImageAnnotator 37 | -------------------------------------------------------------------------------- /src/gui/annotator/settings/ExistingItemEditInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_EXISTINGITEMEDITINFO_H 21 | #define KIMAGEANNOTATOR_EXISTINGITEMEDITINFO_H 22 | 23 | namespace kImageAnnotator { 24 | 25 | struct ExistingItemEditInfo { 26 | public: 27 | ExistingItemEditInfo() 28 | { 29 | mIsEdit = false; 30 | mToolType = Tools::Select; 31 | } 32 | 33 | void startEdit(Tools tool) 34 | { 35 | mIsEdit = true; 36 | mToolType = tool; 37 | } 38 | 39 | void stopEdit() 40 | { 41 | mIsEdit = false; 42 | } 43 | 44 | bool isEdit() const 45 | { 46 | return mIsEdit; 47 | } 48 | 49 | Tools toolType() const 50 | { 51 | return mToolType; 52 | } 53 | 54 | private: 55 | bool mIsEdit; 56 | Tools mToolType; 57 | }; 58 | 59 | } // namespace kImageAnnotator 60 | 61 | #endif //KIMAGEANNOTATOR_EXISTINGITEMEDITINFO_H 62 | -------------------------------------------------------------------------------- /src/gui/cropper/CropSelectionRestrictor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CROPSELECTIONRESTRICTOR_H 21 | #define KIMAGEANNOTATOR_CROPSELECTIONRESTRICTOR_H 22 | 23 | #include 24 | 25 | #include "src/gui/selection/ISelectionRestrictor.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class CropSelectionRestrictor : public ISelectionRestrictor 30 | { 31 | public: 32 | explicit CropSelectionRestrictor() = default; 33 | ~CropSelectionRestrictor() override = default; 34 | 35 | QRectF &restrictResize(QRectF &newRect, const QRectF ¤tRect, const QRectF &rectLimit) const override; 36 | QRectF &restrictMove(QRectF &newRect, const QRectF &rectLimit) const override; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_CROPSELECTIONRESTRICTOR_H 42 | -------------------------------------------------------------------------------- /src/gui/cropper/CropView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CROPVIEW_H 21 | #define KIMAGEANNOTATOR_CROPVIEW_H 22 | 23 | #include "src/gui/selection/BaseSelectionView.h" 24 | #include "src/annotations/misc/CanvasPainter.h" 25 | 26 | namespace kImageAnnotator { 27 | 28 | class CropView : public BaseSelectionView 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit CropView(SelectionHandler *selectionHandler, KeyHelper *keyHelper, QWidget *parent); 33 | ~CropView() override = default; 34 | 35 | protected: 36 | void drawForeground(QPainter *painter, const QRectF &rect) override; 37 | void drawBackground(QPainter *painter, const QRectF &rect) override; 38 | 39 | private: 40 | CanvasPainter mCanvasPainter; 41 | }; 42 | 43 | } // namespace kImageAnnotator 44 | 45 | #endif //KIMAGEANNOTATOR_CROPVIEW_H 46 | -------------------------------------------------------------------------------- /src/gui/cutter/CutSelectionRestrictor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CUTSELECTIONRESTRICTOR_H 21 | #define KIMAGEANNOTATOR_CUTSELECTIONRESTRICTOR_H 22 | 23 | #include 24 | 25 | #include "src/gui/selection/ISelectionRestrictor.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class CutSelectionRestrictor : public ISelectionRestrictor 30 | { 31 | public: 32 | explicit CutSelectionRestrictor() = default; 33 | ~CutSelectionRestrictor() override = default; 34 | 35 | QRectF &restrictResize(QRectF &newRect, const QRectF ¤tRect, const QRectF &rectLimit) const override; 36 | QRectF &restrictMove(QRectF &newRect, const QRectF &rectLimit) const override; 37 | }; 38 | 39 | } // kImageAnnotator namespace 40 | 41 | #endif //KIMAGEANNOTATOR_CUTSELECTIONRESTRICTOR_H 42 | -------------------------------------------------------------------------------- /src/gui/cutter/CutView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "CutView.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | CutView::CutView(SelectionHandler *selectionHandler, KeyHelper *keyHelper, QWidget *parent) : 25 | BaseSelectionView(selectionHandler, keyHelper, parent) 26 | { 27 | 28 | } 29 | 30 | void CutView::drawForeground(QPainter *painter, const QRectF &rect) 31 | { 32 | painter->setBrush(QColor(0, 0, 0, 150)); 33 | painter->drawRect(currentSelection().toRect()); 34 | 35 | BaseSelectionView::drawForeground(painter, rect); 36 | } 37 | 38 | void CutView::drawBackground(QPainter *painter, const QRectF &rect) 39 | { 40 | auto annotationArea = dynamic_cast(scene()); 41 | mCanvasPainter.paint(painter, annotationArea->canvasRect(), annotationArea->canvasColor()); 42 | } 43 | 44 | } // kImageAnnotator namespace 45 | -------------------------------------------------------------------------------- /src/gui/cutter/CutView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CUTVIEW_H 21 | #define KIMAGEANNOTATOR_CUTVIEW_H 22 | 23 | #include "src/gui/selection/BaseSelectionView.h" 24 | #include "src/annotations/misc/CanvasPainter.h" 25 | 26 | namespace kImageAnnotator { 27 | 28 | class CutView : public BaseSelectionView 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit CutView(SelectionHandler *selectionHandler, KeyHelper *keyHelper, QWidget *parent); 33 | ~CutView() override = default; 34 | 35 | protected: 36 | void drawForeground(QPainter *painter, const QRectF &rect) override; 37 | void drawBackground(QPainter *painter, const QRectF &rect) override; 38 | 39 | private: 40 | CanvasPainter mCanvasPainter; 41 | }; 42 | 43 | } // kImageAnnotator namespace 44 | 45 | #endif //KIMAGEANNOTATOR_CUTVIEW_H 46 | -------------------------------------------------------------------------------- /src/gui/selection/ISelectionRestrictor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ISELECTIONRESTRICTOR_H 21 | #define KIMAGEANNOTATOR_ISELECTIONRESTRICTOR_H 22 | 23 | namespace kImageAnnotator { 24 | 25 | class ISelectionRestrictor 26 | { 27 | public: 28 | explicit ISelectionRestrictor() = default; 29 | virtual ~ISelectionRestrictor() = default; 30 | 31 | virtual QRectF &restrictResize(QRectF &newRect, const QRectF ¤tRect, const QRectF &rectLimit) const = 0; 32 | virtual QRectF &restrictMove(QRectF &newRect, const QRectF &rectLimit) const = 0; 33 | }; 34 | 35 | } // namespace kImageAnnotator 36 | 37 | #endif //KIMAGEANNOTATOR_ISELECTIONRESTRICTOR_H 38 | -------------------------------------------------------------------------------- /src/gui/selection/SelectionHandlesAll.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "SelectionHandlesAll.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | SelectionHandlesAll::SelectionHandlesAll() : 25 | BaseSelectionHandles() 26 | { 27 | insertHandle(0); 28 | insertHandle(1); 29 | insertHandle(2); 30 | insertHandle(3); 31 | insertHandle(4); 32 | insertHandle(5); 33 | insertHandle(6); 34 | insertHandle(7); 35 | } 36 | 37 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/gui/selection/SelectionHandlesAll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SELECTIONHANDLESALL_H 21 | #define KIMAGEANNOTATOR_SELECTIONHANDLESALL_H 22 | 23 | #include "BaseSelectionHandles.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class SelectionHandlesAll : public BaseSelectionHandles 28 | { 29 | public: 30 | explicit SelectionHandlesAll(); 31 | ~SelectionHandlesAll() override = default; 32 | }; 33 | 34 | } // namespace kImageAnnotator 35 | 36 | #endif //KIMAGEANNOTATOR_SELECTIONHANDLESALL_H 37 | -------------------------------------------------------------------------------- /src/gui/selection/SelectionHandlesHorizontal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "SelectionHandlesHorizontal.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | 25 | SelectionHandlesHorizontal::SelectionHandlesHorizontal() : 26 | BaseSelectionHandles() 27 | { 28 | insertHandle(1); 29 | insertHandle(5); 30 | } 31 | 32 | } // namespace kImageAnnotator 33 | -------------------------------------------------------------------------------- /src/gui/selection/SelectionHandlesHorizontal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SELECTIONHANDLESHORIZONTAL_H 21 | #define KIMAGEANNOTATOR_SELECTIONHANDLESHORIZONTAL_H 22 | 23 | #include "BaseSelectionHandles.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class SelectionHandlesHorizontal : public BaseSelectionHandles 28 | { 29 | public: 30 | explicit SelectionHandlesHorizontal(); 31 | ~SelectionHandlesHorizontal() override = default; 32 | }; 33 | 34 | } // namespace kImageAnnotator 35 | 36 | #endif //KIMAGEANNOTATOR_SELECTIONHANDLESHORIZONTAL_H 37 | -------------------------------------------------------------------------------- /src/gui/selection/SelectionHandlesVertical.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "SelectionHandlesVertical.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | SelectionHandlesVertical::SelectionHandlesVertical() : 25 | BaseSelectionHandles() 26 | { 27 | insertHandle(3); 28 | insertHandle(7); 29 | } 30 | 31 | } // namespace kImageAnnotator 32 | -------------------------------------------------------------------------------- /src/gui/selection/SelectionHandlesVertical.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SELECTIONHANDLESVERTICAL_H 21 | #define KIMAGEANNOTATOR_SELECTIONHANDLESVERTICAL_H 22 | 23 | #include "BaseSelectionHandles.h" 24 | 25 | namespace kImageAnnotator { 26 | 27 | class SelectionHandlesVertical : public BaseSelectionHandles 28 | { 29 | public: 30 | explicit SelectionHandlesVertical(); 31 | ~SelectionHandlesVertical() override = default; 32 | }; 33 | 34 | } // namespace kImageAnnotator 35 | 36 | #endif //KIMAGEANNOTATOR_SELECTIONHANDLESVERTICAL_H 37 | -------------------------------------------------------------------------------- /src/gui/selection/SelectionMoveHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SELECTIONMOVEHELPER_H 21 | #define KIMAGEANNOTATOR_SELECTIONMOVEHELPER_H 22 | 23 | #include 24 | #include 25 | 26 | namespace kImageAnnotator { 27 | 28 | class SelectionMoveHelper 29 | { 30 | public: 31 | explicit SelectionMoveHelper(); 32 | ~SelectionMoveHelper() = default; 33 | void grabSelection(const QPointF &position, const QRectF &selection); 34 | void releaseSelection(); 35 | bool isSelectionGabbed() const; 36 | QPointF grabOffset() const; 37 | 38 | private: 39 | bool mIsSelectionGabbed{}; 40 | QPointF mGrabOffset; 41 | }; 42 | 43 | } // namespace kImageAnnotator 44 | 45 | #endif //KIMAGEANNOTATOR_SELECTIONMOVEHELPER_H 46 | -------------------------------------------------------------------------------- /src/widgets/CustomFontComboBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CUSTOMFONTCOMBOBOX_H 21 | #define KIMAGEANNOTATOR_CUSTOMFONTCOMBOBOX_H 22 | 23 | #include 24 | #include 25 | 26 | #include "src/common/provider/ScaledSizeProvider.h" 27 | 28 | namespace kImageAnnotator { 29 | 30 | class CustomFontComboBox : public QFontComboBox 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit CustomFontComboBox(QWidget *parent); 35 | ~CustomFontComboBox() override = default; 36 | QString selectItemText() const; 37 | 38 | protected: 39 | void resizeEvent(QResizeEvent *event) override; 40 | 41 | private slots: 42 | void elideCurrentText(); 43 | }; 44 | 45 | } // namespace kImageAnnotator 46 | 47 | #endif //KIMAGEANNOTATOR_CUSTOMFONTCOMBOBOX_H 48 | -------------------------------------------------------------------------------- /src/widgets/CustomSpinBox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "CustomSpinBox.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | kImageAnnotator::CustomSpinBox::CustomSpinBox(QWidget *parent) : QSpinBox(parent) 25 | { 26 | setAlignment(Qt::AlignHCenter); 27 | 28 | connect(this, static_cast(&QSpinBox::valueChanged), this, &CustomSpinBox::valueChanged); 29 | } 30 | 31 | void CustomSpinBox::setValueSilent(int value) 32 | { 33 | blockSignals(true); 34 | 35 | QSpinBox::setValue(value); 36 | 37 | blockSignals(false); 38 | } 39 | 40 | } // namespace kImageAnnotator 41 | -------------------------------------------------------------------------------- /src/widgets/CustomSpinBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CUSTOMSPINBOX_H 21 | #define KIMAGEANNOTATOR_CUSTOMSPINBOX_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class CustomSpinBox : public QSpinBox 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit CustomSpinBox(QWidget *parent = nullptr); 32 | ~CustomSpinBox() override = default; 33 | void setValueSilent(int value); 34 | 35 | signals: 36 | void valueChanged(int) const; 37 | }; 38 | 39 | } // namespace kImageAnnotator 40 | 41 | #endif //KIMAGEANNOTATOR_CUSTOMSPINBOX_H 42 | -------------------------------------------------------------------------------- /src/widgets/CustomToolButtonAction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CUSTOMTOOLBUTTONMENU_H 21 | #define KIMAGEANNOTATOR_CUSTOMTOOLBUTTONMENU_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "src/common/provider/ScaledSizeProvider.h" 29 | 30 | namespace kImageAnnotator { 31 | 32 | class CustomToolButtonAction : public QWidgetAction 33 | { 34 | public: 35 | explicit CustomToolButtonAction(QObject *parent); 36 | ~CustomToolButtonAction() override; 37 | void updateDefaultWidget(); 38 | 39 | private: 40 | QLabel *mImage; 41 | QLabel *mText; 42 | QHBoxLayout *mLayout; 43 | QWidget *mMenuItem; 44 | 45 | void initDefaultWidget(); 46 | }; 47 | 48 | } // namespace kImageAnnotator 49 | 50 | #endif //KIMAGEANNOTATOR_CUSTOMTOOLBUTTONMENU_H 51 | -------------------------------------------------------------------------------- /src/widgets/ToggleButton.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ToggleButton.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | ToggleButton::ToggleButton(QWidget *parent) : 25 | QToolButton(parent) 26 | { 27 | setCheckable(true); 28 | 29 | setFocusPolicy(Qt::NoFocus); 30 | } 31 | 32 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/widgets/ToggleButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_TOGGLEBUTTON_H 21 | #define KIMAGEANNOTATOR_TOGGLEBUTTON_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class ToggleButton : public QToolButton 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit ToggleButton(QWidget *parent); 32 | ~ToggleButton() override = default; 33 | }; 34 | 35 | } // namespace kImageAnnotator 36 | 37 | #endif //KIMAGEANNOTATOR_TOGGLEBUTTON_H 38 | -------------------------------------------------------------------------------- /src/widgets/menuButtons/GridMenuButton.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_GRIDMENUBUTTON_H 21 | #define KIMAGEANNOTATOR_GRIDMENUBUTTON_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "src/common/provider/ScaledSizeProvider.h" 30 | 31 | namespace kImageAnnotator { 32 | 33 | class GridMenuButton : public QToolButton 34 | { 35 | Q_OBJECT 36 | public: 37 | GridMenuButton(const QIcon &icon, const QString &toolTip, QVariant data); 38 | ~GridMenuButton() override = default; 39 | QVariant data() const; 40 | 41 | protected slots: 42 | void paintEvent(QPaintEvent *event) override; 43 | 44 | private: 45 | QVariant mData; 46 | }; 47 | 48 | } // namespace kImageAnnotator 49 | 50 | #endif //KIMAGEANNOTATOR_GRIDMENUBUTTON_H 51 | -------------------------------------------------------------------------------- /src/widgets/misc/AbstractExpandingWidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "AbstractExpandingWidget.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | void AbstractExpandingWidget::setExpanding(bool enabled) 25 | { 26 | auto horizontalPolicy = enabled ? QSizePolicy::Expanding : QSizePolicy::Preferred; 27 | expandingWidget()->setSizePolicy(horizontalPolicy, QSizePolicy::Preferred); 28 | } 29 | 30 | } // namespace kImageAnnotator -------------------------------------------------------------------------------- /src/widgets/misc/AbstractExpandingWidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ABSTRACTEXPANDINGWIDGET_H 21 | #define KIMAGEANNOTATOR_ABSTRACTEXPANDINGWIDGET_H 22 | 23 | #include 24 | 25 | namespace kImageAnnotator { 26 | 27 | class AbstractExpandingWidget 28 | { 29 | public: 30 | AbstractExpandingWidget() = default; 31 | ~AbstractExpandingWidget() = default; 32 | virtual void setExpanding(bool enabled); 33 | 34 | protected: 35 | virtual QWidget* expandingWidget() = 0; 36 | }; 37 | 38 | } // namespace kImageAnnotator 39 | 40 | #endif //KIMAGEANNOTATOR_ABSTRACTEXPANDINGWIDGET_H 41 | -------------------------------------------------------------------------------- /src/widgets/misc/AttachedSeparator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ATTACHEDSEPARATOR_H 21 | #define KIMAGEANNOTATOR_ATTACHEDSEPARATOR_H 22 | 23 | #include 24 | #include 25 | 26 | #include "src/widgets/settingsPicker/SettingsPickerWidget.h" 27 | 28 | namespace kImageAnnotator { 29 | 30 | class AttachedSeparator : public QFrame 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit AttachedSeparator(SettingsPickerWidget *target); 35 | ~AttachedSeparator() override = default; 36 | 37 | protected: 38 | void changeEvent(QEvent *event) override; 39 | 40 | private: 41 | SettingsPickerWidget *mTarget; 42 | 43 | void updateVisibility(); 44 | 45 | private slots: 46 | void targetVisibilityChanged(bool visible); 47 | }; 48 | 49 | } // namespace kImageAnnotator 50 | 51 | #endif //KIMAGEANNOTATOR_ATTACHEDSEPARATOR_H 52 | -------------------------------------------------------------------------------- /src/widgets/settingsPicker/SettingsPickerWidget.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "SettingsPickerWidget.h" 21 | 22 | namespace kImageAnnotator { 23 | 24 | SettingsPickerWidget::SettingsPickerWidget(QWidget *parent) : 25 | QWidget(parent) 26 | { 27 | 28 | } 29 | 30 | void SettingsPickerWidget::showEvent(QShowEvent *event) 31 | { 32 | emit visibilityChanged(true); 33 | QWidget::showEvent(event); 34 | } 35 | 36 | void SettingsPickerWidget::hideEvent(QHideEvent *event) 37 | { 38 | emit visibilityChanged(false); 39 | QWidget::hideEvent(event); 40 | } 41 | 42 | } // namespace kImageAnnotator 43 | -------------------------------------------------------------------------------- /src/widgets/settingsPicker/SettingsPickerWidget.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SETTINGSPICKERWIDGET_H 21 | #define KIMAGEANNOTATOR_SETTINGSPICKERWIDGET_H 22 | 23 | #include 24 | 25 | #include "src/widgets/misc/AbstractExpandingWidget.h" 26 | 27 | namespace kImageAnnotator { 28 | 29 | class SettingsPickerWidget : public QWidget, public AbstractExpandingWidget 30 | { 31 | Q_OBJECT 32 | public: 33 | explicit SettingsPickerWidget(QWidget *parent); 34 | ~SettingsPickerWidget() override = default; 35 | 36 | signals: 37 | void visibilityChanged(bool visible); 38 | 39 | protected: 40 | void showEvent(QShowEvent *event) override; 41 | void hideEvent(QHideEvent *event) override; 42 | }; 43 | 44 | } // namespace kImageAnnotator 45 | 46 | #endif //KIMAGEANNOTATOR_SETTINGSPICKERWIDGET_H 47 | -------------------------------------------------------------------------------- /tests/annotations/undo/PasteCommandTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_PASTECOMMANDTEST_H 21 | #define KIMAGEANNOTATOR_PASTECOMMANDTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | 27 | class PasteCommandTest : public QObject 28 | { 29 | Q_OBJECT 30 | 31 | private slots: 32 | void TestRedo_Should_AddPastedItemsToAnnotationAreaAtGivenPosition(); 33 | void TestUndo_Should_RemovePastedItemsFromAnnotationArea(); 34 | }; 35 | 36 | #endif // KIMAGEANNOTATOR_PASTECOMMANDTEST_H 37 | -------------------------------------------------------------------------------- /tests/annotations/undo/RotateCommandTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ROTATECOMMANDTEST_H 21 | #define KIMAGEANNOTATOR_ROTATECOMMANDTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/annotations/undo/RotateCommand.h" 27 | #include "tests/mocks/MockSettingsProvider.h" 28 | #include "tests/mocks/MockDevicePixelRatioScaler.h" 29 | 30 | using kImageAnnotator::RotateCommand; 31 | using kImageAnnotator::AnnotationArea; 32 | 33 | class RotateCommandTest : public QObject 34 | { 35 | Q_OBJECT 36 | private slots: 37 | void Redo_Should_RotatePixmapByProvidedAngel(); 38 | void Redo_Should_TrimPixmapAndRemoveTransparentPart_WhenRotatedBy45DegreeTwice(); 39 | void Undo_Should_RevertBackToInitialImage(); 40 | }; 41 | 42 | 43 | #endif //KIMAGEANNOTATOR_ROTATECOMMANDTEST_H 44 | -------------------------------------------------------------------------------- /tests/backend/ConfigTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CONFIGTEST_H 21 | #define KIMAGEANNOTATOR_CONFIGTEST_H 22 | 23 | #include 24 | #include 25 | 26 | #include "tests/utils/TestRunner.h" 27 | #include "tests/mocks/backend/SettingsMock.h" 28 | #include "src/backend/Config.h" 29 | #include "src/common/enum/Tools.h" 30 | 31 | using kImageAnnotator::Config; 32 | using kImageAnnotator::ConfigNameHelper; 33 | using kImageAnnotator::Tools; 34 | 35 | class ConfigTest : public QObject 36 | { 37 | Q_OBJECT 38 | 39 | private slots: 40 | void TestSetSelectedTool_Should_NotSaveSelection_When_SaveToolSelectionDisabled(); 41 | void TestSetSelectedTool_Should_SaveSelection_When_SaveToolSelectionEnabled(); 42 | }; 43 | 44 | #endif // KIMAGEANNOTATOR_CONFIGTEST_H 45 | -------------------------------------------------------------------------------- /tests/gui/annotator/tabs/AnnotationTabContextMenuTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ANNOTATIONTABCONTEXTMENUTEST_H 21 | #define KIMAGEANNOTATOR_ANNOTATIONTABCONTEXTMENUTEST_H 22 | 23 | #include 24 | #include 25 | 26 | #include "tests/utils/TestRunner.h" 27 | #include "src/gui/annotator/tabs/AnnotationTabContextMenu.h" 28 | 29 | using kImageAnnotator::AnnotationTabContextMenu; 30 | 31 | class AnnotationTabContextMenuTest : public QObject 32 | { 33 | Q_OBJECT 34 | private slots: 35 | void TestCustomActionTriggered_Should_CallInnerActionWithCorrectTabIndexSetInData(); 36 | void TestAddCustomActions_Should_SetTextIconAndToolTipInOuterAction(); 37 | void TestCustomActionChanged_Should_UpdateEnabledStateOfOuterAction(); 38 | }; 39 | 40 | 41 | #endif //KIMAGEANNOTATOR_ANNOTATIONTABCONTEXTMENUTEST_H 42 | -------------------------------------------------------------------------------- /tests/gui/selection/SelectionMoveHelperTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SELECTIONMOVEHELPERTEST_H 21 | #define KIMAGEANNOTATOR_SELECTIONMOVEHELPERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/gui/selection/SelectionMoveHelper.h" 27 | 28 | using kImageAnnotator::SelectionMoveHelper; 29 | 30 | class SelectionMoveHelperTest : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | private slots: 35 | void TestGrabSelection_Should_GrabSelection_WhenPositionWithinSelection(); 36 | void TestGrabSelection_Should_NotGrabSelection_WhenPositionOutsideSelection(); 37 | void TestGrabSelection_Should_SetCorrectOffset(); 38 | void TestReleaseSelection_Should_ReleaseSelection(); 39 | }; 40 | 41 | #endif // KIMAGEANNOTATOR_SELECTIONMOVEHELPERTEST_H 42 | -------------------------------------------------------------------------------- /tests/mocks/MockDevicePixelRatioScaler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "MockDevicePixelRatioScaler.h" 21 | 22 | MockDevicePixelRatioScaler::MockDevicePixelRatioScaler() : 23 | mScaleFactor(1.0) 24 | { 25 | 26 | } 27 | 28 | QRectF MockDevicePixelRatioScaler::scale(const QRectF &rect) const 29 | { 30 | return {rect.left() * mScaleFactor, rect.top() * mScaleFactor, rect.width() * mScaleFactor, rect.height() * mScaleFactor}; 31 | } 32 | 33 | qreal MockDevicePixelRatioScaler::scaleFactor() const 34 | { 35 | return mScaleFactor; 36 | } 37 | 38 | void MockDevicePixelRatioScaler::setScaleFactor(qreal factor) 39 | { 40 | mScaleFactor = factor; 41 | } 42 | -------------------------------------------------------------------------------- /tests/mocks/MockDevicePixelRatioScaler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_MOCKDEVICEPIXELRATIOSCALER_H 21 | #define KIMAGEANNOTATOR_MOCKDEVICEPIXELRATIOSCALER_H 22 | 23 | #include 24 | 25 | #include "src/common/provider/IDevicePixelRatioScaler.h" 26 | 27 | using kImageAnnotator::IDevicePixelRatioScaler; 28 | 29 | class MockDevicePixelRatioScaler : public IDevicePixelRatioScaler 30 | { 31 | public: 32 | MockDevicePixelRatioScaler(); 33 | ~MockDevicePixelRatioScaler() override = default; 34 | 35 | QRectF scale(const QRectF &rect) const override; 36 | qreal scaleFactor() const override; 37 | void setScaleFactor(qreal factor); 38 | 39 | private: 40 | qreal mScaleFactor; 41 | }; 42 | 43 | #endif //KIMAGEANNOTATOR_MOCKDEVICEPIXELRATIOSCALER_H 44 | -------------------------------------------------------------------------------- /tests/mocks/MockSelectionRestrictor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "MockSelectionRestrictor.h" 21 | 22 | QRectF &MockSelectionRestrictor::restrictResize(QRectF &newRect, const QRectF ¤tRect, const QRectF &rectLimit) const 23 | { 24 | return newRect; 25 | } 26 | 27 | QRectF &MockSelectionRestrictor::restrictMove(QRectF &newRect, const QRectF &rectLimit) const 28 | { 29 | return newRect; 30 | } 31 | -------------------------------------------------------------------------------- /tests/mocks/MockSelectionRestrictor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_MOCKSELECTIONRESTRICTOR_H 21 | #define KIMAGEANNOTATOR_MOCKSELECTIONRESTRICTOR_H 22 | 23 | #include 24 | 25 | #include "src/gui/selection/ISelectionRestrictor.h" 26 | 27 | using kImageAnnotator::ISelectionRestrictor; 28 | 29 | class MockSelectionRestrictor : public ISelectionRestrictor 30 | { 31 | public: 32 | explicit MockSelectionRestrictor() = default; 33 | ~MockSelectionRestrictor() override = default; 34 | 35 | QRectF &restrictResize(QRectF &newRect, const QRectF ¤tRect, const QRectF &rectLimit) const override; 36 | QRectF &restrictMove(QRectF &newRect, const QRectF &rectLimit) const override; 37 | }; 38 | 39 | 40 | #endif //KIMAGEANNOTATOR_MOCKSELECTIONRESTRICTOR_H 41 | -------------------------------------------------------------------------------- /tests/mocks/MockZoomValueProvider.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "MockZoomValueProvider.h" 21 | 22 | MockZoomValueProvider::MockZoomValueProvider(QObject *parent) : ZoomValueProvider(parent), mZoomValue(1.0) 23 | { 24 | } 25 | 26 | double MockZoomValueProvider::zoomValue() const 27 | { 28 | return mZoomValue; 29 | } 30 | 31 | void MockZoomValueProvider::setZoomValue(double value) 32 | { 33 | if (value == mZoomValue) 34 | return; 35 | mZoomValue = value; 36 | emit zoomValueChanged(value); 37 | } 38 | 39 | void MockZoomValueProvider::fitImageToView() 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /tests/mocks/MockZoomValueProvider.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_MOCKZOOMVALUEPROVIDER_H 21 | #define KIMAGEANNOTATOR_MOCKZOOMVALUEPROVIDER_H 22 | 23 | #include "src/annotations/core/ZoomValueProvider.h" 24 | 25 | using kImageAnnotator::ZoomValueProvider; 26 | 27 | class MockZoomValueProvider : public ZoomValueProvider 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit MockZoomValueProvider(QObject *parent = nullptr); 32 | double zoomValue() const override; 33 | void setZoomValue(double value) override; 34 | void fitImageToView() override; 35 | 36 | private: 37 | double mZoomValue; 38 | }; 39 | 40 | #endif // KIMAGEANNOTATOR_MOCKZOOMVALUEPROVIDER_H 41 | -------------------------------------------------------------------------------- /tests/mocks/backend/SettingsMock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_SETTINGSMOCK_H 21 | #define KIMAGEANNOTATOR_SETTINGSMOCK_H 22 | 23 | #include "src/backend/ISettings.h" 24 | 25 | using kImageAnnotator::ISettings; 26 | 27 | class SettingsMock : public ISettings 28 | { 29 | public: 30 | explicit SettingsMock() = default; 31 | ~SettingsMock() override = default; 32 | 33 | MOCK_METHOD(void, sync, (), (override)); 34 | MOCK_METHOD(void, setValue, (const QString &key, const QVariant &value), (override)); 35 | MOCK_METHOD(QVariant, value, (const QString &key, const QVariant &defaultValue), (const, override)); 36 | }; 37 | 38 | #endif //KIMAGEANNOTATOR_SETTINGSMOCK_H 39 | -------------------------------------------------------------------------------- /tests/widgets/CustomSpinBoxTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "CustomSpinBoxTest.h" 21 | 22 | void CustomSpinBoxTest::TestSetValue_Should_EmitValueChangedSignal() 23 | { 24 | auto newValue = 23; 25 | CustomSpinBox spinBox; 26 | QSignalSpy spy(&spinBox, &CustomSpinBox::valueChanged); 27 | 28 | spinBox.setValue(newValue); 29 | 30 | QCOMPARE(spy.count(), 1); 31 | auto resultValue = qvariant_cast(spy.at(0).at(0)); 32 | QCOMPARE(resultValue, newValue); 33 | } 34 | 35 | void CustomSpinBoxTest::TestSetValueSilent_Should_NotEmitValueChangedSignal() 36 | { 37 | CustomSpinBox spinBox; 38 | QSignalSpy spy(&spinBox, &CustomSpinBox::valueChanged); 39 | 40 | spinBox.setValueSilent(23); 41 | 42 | QCOMPARE(spy.count(), 0); 43 | } 44 | 45 | TEST_MAIN(CustomSpinBoxTest); 46 | -------------------------------------------------------------------------------- /tests/widgets/CustomSpinBoxTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_CUSTOMSPINBOXTEST_H 21 | #define KIMAGEANNOTATOR_CUSTOMSPINBOXTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/CustomSpinBox.h" 27 | 28 | using kImageAnnotator::CustomSpinBox; 29 | 30 | class CustomSpinBoxTest : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | private slots: 35 | void TestSetValue_Should_EmitValueChangedSignal(); 36 | void TestSetValueSilent_Should_NotEmitValueChangedSignal(); 37 | }; 38 | 39 | #endif // KIMAGEANNOTATOR_CUSTOMSPINBOXTEST_H 40 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ColorPickerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ColorPickerTest.h" 21 | 22 | void ColorPickerTest::TestSelectColor_Should_EmitSignal_When_ColorChanged() 23 | { 24 | ColorPicker colorPicker(nullptr); 25 | QSignalSpy spy(&colorPicker, &ColorPicker::colorSelected); 26 | auto expectedColor = QColor(Qt::blue); 27 | 28 | colorPicker.setColor(expectedColor); 29 | 30 | QCOMPARE(spy.count(), 1); 31 | auto resultColor = qvariant_cast(spy.at(0).at(0)); 32 | QCOMPARE(resultColor, expectedColor); 33 | } 34 | 35 | TEST_MAIN(ColorPickerTest); 36 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ColorPickerTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_COLORPICKERTEST_H 21 | #define KIMAGEANNOTATOR_COLORPICKERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/settingsPicker/ColorPicker.h" 27 | 28 | using kImageAnnotator::ColorPicker; 29 | 30 | class ColorPickerTest : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | private slots: 35 | void TestSelectColor_Should_EmitSignal_When_ColorChanged(); 36 | }; 37 | 38 | #endif // KIMAGEANNOTATOR_COLORPICKERTEST_H 39 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/FillModePickerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "FillModePickerTest.h" 21 | 22 | void FillModePickerTest::TestSelectFill_Should_EmitSignal_When_FillChanged() 23 | { 24 | qRegisterMetaType("FillModes"); 25 | FillModePicker fillPicker(nullptr); 26 | QSignalSpy spy(&fillPicker, &FillModePicker::fillSelected); 27 | auto expectedFill = FillModes::BorderAndNoFill; 28 | 29 | fillPicker.setFillType(expectedFill); 30 | 31 | QCOMPARE(spy.count(), 1); 32 | auto resultFill = qvariant_cast(spy.at(0).at(0)); 33 | QCOMPARE(resultFill, expectedFill); 34 | } 35 | 36 | TEST_MAIN(FillModePickerTest); 37 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/FillModePickerTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_FILLPICKERTEST_H 21 | #define KIMAGEANNOTATOR_FILLPICKERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/settingsPicker/FillModePicker.h" 27 | 28 | using kImageAnnotator::FillModePicker; 29 | using kImageAnnotator::FillModes; 30 | 31 | class FillModePickerTest : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | private slots: 36 | void TestSelectFill_Should_EmitSignal_When_FillChanged(); 37 | }; 38 | 39 | #endif // KIMAGEANNOTATOR_FILLPICKERTEST_H 40 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ImageEffectPickerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ImageEffectPickerTest.h" 21 | 22 | void ImageEffectPickerTest::TestSelectEffect_Should_EmitSignal_When_EffectChanged() 23 | { 24 | qRegisterMetaType("ImageEffects"); 25 | ImageEffectPicker effectPicker(nullptr); 26 | QSignalSpy spy(&effectPicker, &ImageEffectPicker::effectSelected); 27 | auto expectedEffect = ImageEffects::DropShadow; 28 | 29 | effectPicker.setEffect(expectedEffect); 30 | 31 | QCOMPARE(spy.count(), 1); 32 | auto resultFill = qvariant_cast(spy.at(0).at(0)); 33 | QCOMPARE(resultFill, expectedEffect); 34 | } 35 | 36 | TEST_MAIN(ImageEffectPickerTest); 37 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ImageEffectPickerTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_IMAGEEFFECTPICKERTEST_H 21 | #define KIMAGEANNOTATOR_IMAGEEFFECTPICKERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/settingsPicker/ImageEffectPicker.h" 27 | 28 | using kImageAnnotator::ImageEffectPicker; 29 | using kImageAnnotator::ImageEffects; 30 | 31 | class ImageEffectPickerTest : public QObject 32 | { 33 | Q_OBJECT 34 | private slots: 35 | void TestSelectEffect_Should_EmitSignal_When_EffectChanged(); 36 | }; 37 | 38 | 39 | #endif //KIMAGEANNOTATOR_IMAGEEFFECTPICKERTEST_H 40 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/NumberPickerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "NumberPickerTest.h" 21 | 22 | void NumberPickerTest::TestSelectNumber_Should_EmitSignal_When_NumberChanged() 23 | { 24 | NumberPicker sizePicker(nullptr); 25 | QSignalSpy spy(&sizePicker, &NumberPicker::numberSelected); 26 | auto expectedSize = 8; 27 | 28 | sizePicker.setNumber(expectedSize); 29 | 30 | QCOMPARE(spy.count(), 1); 31 | auto resultSize = qvariant_cast(spy.at(0).at(0)); 32 | QCOMPARE(resultSize, expectedSize); 33 | } 34 | 35 | TEST_MAIN(NumberPickerTest); 36 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/NumberPickerTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_NUMBERPICKERTEST_H 21 | #define KIMAGEANNOTATOR_NUMBERPICKERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/settingsPicker/NumberPicker.h" 27 | 28 | using kImageAnnotator::NumberPicker; 29 | 30 | class NumberPickerTest : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | private slots: 35 | void TestSelectNumber_Should_EmitSignal_When_NumberChanged(); 36 | }; 37 | 38 | #endif // KIMAGEANNOTATOR_NUMBERPICKERTEST_H 39 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/StickerPickerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "StickerPickerTest.h" 21 | 22 | void StickerPickerTest::TestSelectSticker_Should_EmitSignal_When_StickerChanged() 23 | { 24 | StickerPicker stickerPicker(nullptr); 25 | QSignalSpy spy(&stickerPicker, &StickerPicker::stickerSelected); 26 | auto expectedStickerPath = QStringLiteral(":/stickers/nerd_face.svg"); 27 | 28 | stickerPicker.setSticker(expectedStickerPath); 29 | 30 | QCOMPARE(spy.count(), 1); 31 | auto resultSize = qvariant_cast(spy.at(0).at(0)); 32 | QCOMPARE(resultSize, expectedStickerPath); 33 | } 34 | 35 | TEST_MAIN(StickerPickerTest); 36 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/StickerPickerTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_STICKERPICKERTEST_H 21 | #define KIMAGEANNOTATOR_STICKERPICKERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/settingsPicker/StickerPicker.h" 27 | 28 | using kImageAnnotator::StickerPicker; 29 | 30 | class StickerPickerTest : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | private slots: 35 | void TestSelectSticker_Should_EmitSignal_When_StickerChanged(); 36 | }; 37 | 38 | #endif //KIMAGEANNOTATOR_STICKERPICKERTEST_H 39 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ToolPickerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ToolPickerTest.h" 21 | 22 | void ToolPickerTest::TestSelectTool_Should_EmitSignal_When_ToolChanged() 23 | { 24 | qRegisterMetaType("Tools"); 25 | ToolPicker toolPicker(nullptr); 26 | QSignalSpy spy(&toolPicker, &ToolPicker::toolSelected); 27 | 28 | toolPicker.setTool(Tools::Arrow); 29 | 30 | QCOMPARE(spy.count(), 1); 31 | auto type = qvariant_cast(spy.at(0).at(0)); 32 | QCOMPARE(type, Tools::Arrow); 33 | } 34 | 35 | void ToolPickerTest::TestTool_Should_ReturnSelectedTool() 36 | { 37 | ToolPicker toolPicker(nullptr); 38 | toolPicker.setTool(Tools::Arrow); 39 | 40 | auto result = toolPicker.tool(); 41 | 42 | QCOMPARE(result, Tools::Arrow); 43 | } 44 | 45 | TEST_MAIN(ToolPickerTest); 46 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ToolPickerTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_TOOLPICKERTEST_H 21 | #define KIMAGEANNOTATOR_TOOLPICKERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/ToolPicker.h" 27 | #include "src/common/enum/Tools.h" 28 | 29 | using kImageAnnotator::ToolPicker; 30 | using kImageAnnotator::Tools; 31 | 32 | class ToolPickerTest : public QObject 33 | { 34 | Q_OBJECT 35 | private slots: 36 | void TestSelectTool_Should_EmitSignal_When_ToolChanged(); 37 | void TestTool_Should_ReturnSelectedTool(); 38 | }; 39 | 40 | #endif // KIMAGEANNOTATOR_TOOLPICKERTEST_H 41 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ZoomPickerTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "ZoomPickerTest.h" 21 | 22 | void ZoomPickerTest::SetZoomValue_Should_NotEmitSignalForChangedZoomValue() 23 | { 24 | ZoomPicker zoomIndicator(nullptr); 25 | QSignalSpy spy(&zoomIndicator, &ZoomPicker::zoomValueChanged); 26 | 27 | zoomIndicator.setZoomValue(7.77); 28 | 29 | QCOMPARE(spy.count(), 0); 30 | } 31 | 32 | TEST_MAIN(ZoomPickerTest); 33 | -------------------------------------------------------------------------------- /tests/widgets/settingsPicker/ZoomPickerTest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Damir Porobic 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | * Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef KIMAGEANNOTATOR_ZOOMPICKERTEST_H 21 | #define KIMAGEANNOTATOR_ZOOMPICKERTEST_H 22 | 23 | #include 24 | 25 | #include "tests/utils/TestRunner.h" 26 | #include "src/widgets/settingsPicker/ZoomPicker.h" 27 | 28 | using kImageAnnotator::ZoomPicker; 29 | 30 | class ZoomPickerTest : public QObject 31 | { 32 | Q_OBJECT 33 | private slots: 34 | void SetZoomValue_Should_NotEmitSignalForChangedZoomValue(); 35 | }; 36 | 37 | #endif //KIMAGEANNOTATOR_ZOOMPICKERTEST_H 38 | -------------------------------------------------------------------------------- /translations/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Qt${QT_MAJOR_VERSION}LinguistTools) 2 | 3 | set(KIMAGEANNOTATOR_LANG_TS 4 | kImageAnnotator_ar.ts 5 | kImageAnnotator_bg.ts 6 | kImageAnnotator_ca.ts 7 | kImageAnnotator_cs.ts 8 | kImageAnnotator_da.ts 9 | kImageAnnotator_de.ts 10 | kImageAnnotator_el.ts 11 | kImageAnnotator_es.ts 12 | kImageAnnotator_eu.ts 13 | kImageAnnotator_fr.ts 14 | kImageAnnotator_fr_CA.ts 15 | kImageAnnotator_gl.ts 16 | kImageAnnotator_hr.ts 17 | kImageAnnotator_hu.ts 18 | kImageAnnotator_id.ts 19 | kImageAnnotator_it.ts 20 | kImageAnnotator_ja.ts 21 | kImageAnnotator_ko.ts 22 | kImageAnnotator_nl.ts 23 | kImageAnnotator_no.ts 24 | kImageAnnotator_pl.ts 25 | kImageAnnotator_pt.ts 26 | kImageAnnotator_pt_BR.ts 27 | kImageAnnotator_ro.ts 28 | kImageAnnotator_ru.ts 29 | kImageAnnotator_si.ts 30 | kImageAnnotator_sq.ts 31 | kImageAnnotator_sv.ts 32 | kImageAnnotator_tr.ts 33 | kImageAnnotator_uk.ts 34 | kImageAnnotator_zh_CN.ts) 35 | 36 | if (DEFINED UPDATE_TS_FILES) 37 | qt_create_translation(KIMAGEANNOTATOR_LANG_QM ${CMAKE_SOURCE_DIR}/translations ${KIMAGEANNOTATOR_SRCS} ${KIMAGEANNOTATOR_LANG_TS} OPTIONS "-no-obsolete") 38 | else () 39 | qt_add_translation(KIMAGEANNOTATOR_LANG_QM ${KIMAGEANNOTATOR_LANG_TS}) 40 | endif () 41 | 42 | add_custom_target(translations ALL DEPENDS ${KIMAGEANNOTATOR_LANG_QM}) 43 | 44 | install(FILES ${KIMAGEANNOTATOR_LANG_QM} DESTINATION ${KIMAGEANNOTATOR_LANG_INSTALL_DIR}) 45 | 46 | --------------------------------------------------------------------------------