Compare commits

...

No commits in common. "openkylin/yangtze" and "pristine-tar" have entirely different histories.

850 changed files with 3 additions and 310037 deletions

30
.gitignore vendored
View File

@ -1,30 +0,0 @@
# Ignore the following files
*~
*.[oa]
*.diff
*.kate-swp
*.kdev4
.kdev_include_paths
*.kdevelop.pcs
*.moc
*.moc.cpp
*.orig
*.user
.*.swp
.swp.*
Doxyfile
Makefile
avail
random_seed
/build*/
CMakeLists.txt.user*
*.unc-backup*
.cmake/
# LSP & IDE
/.clang-format
/compile_commands.json
.clangd
.cache
.idea
/cmake-build*

View File

@ -1,10 +0,0 @@
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
include:
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/windows.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd-qt6.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/windows-qt6.yml

View File

@ -1,15 +0,0 @@
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0
Dependencies:
- 'on': ['@all']
'require':
'frameworks/extra-cmake-modules': '@stable'
'frameworks/kdoctools': '@stable'
'frameworks/ki18n': '@stable'
'frameworks/kguiaddons': '@stable'
'frameworks/kwidgetsaddons': '@stable'
'frameworks/kio': '@stable'
'frameworks/kxmlgui': '@stable'
'frameworks/ktextwidgets': '@stable'
'frameworks/kjobwidgets': '@stable'

1
.krazy
View File

@ -1 +0,0 @@
EXTRA multiclasses

38
AUTHORS
View File

@ -1,38 +0,0 @@
Authors
=======
Clarence Dang <dang@kde.org>
Project Founder
Thurston Dang <thurston_dang@users.sourceforge.net>
Chief Investigator
Kristof Borrey <borrey@kde.org>
Icons
Kazuki Ohta <mover@hct.zaq.ne.jp>
InputMethod Support
Nuno Pinheiro <nf.pinheiro@gmail.com>
Icons
Danny Allen <dannya40uk@yahoo.co.uk>
Icons
Mike Gashler <gashlerm@yahoo.com>
Imaqe Effects
Laurent Montel <montel@kde.org>
KDE 4 Porting
Martin Koller <kollix@aon.at>
Scanning Support, Current Maintainer
Tasuku Suzuki <stasuku@gmail.com>
InputMethod Support
Thanks To
=========
Thanks to the many others who have helped to make this program possible.

138
BUGS
View File

@ -1,138 +0,0 @@
Please send bug reports and feature requests to http://bugs.kde.org/.
Don't hesitate to report bugs nor hesitate to send us your wishes - it
provides valuable feedback that will help to improve future versions of
KolourPaint and you will not receive flames for reporting duplicates.
This file lists known bugs in this version that are not considered
"release critical" and are difficult to fix:
3. Tool Box & Colour Box RMB ToolBar Menus do not work.
4. Image dialog spinboxes should accept Enter Key (instead of the dialog's
OK button) after the user has typed something.
OR
Spinboxes should signal that their values have changed every time the
user changes the text (rather than after pressing Enter or clicking on
another spinbox etc.).
The need for the "Update Preview" button and the difficulty of keeping
the percentages and dimensions in sync in the Resize / Scale dialog are
manifestations of the current QSpinBox behaviour.
Update: Text input is broken in KDE4.
6. a) The undo history and document modified state are not updated during
the drawing of multi-segment shapes (Polygon, Connected Lines,
Curve). They are however updated after shapes' completion.
b) The brush-like tools set the document modified flag even if
user cancels the draw operation.
c) Select a region, manipulate it (e.g. move), undo - the document is
still marked as modified (because 2 commands - the create selection
and the move - were added but only one was undone).
7. Certain shapes may have the wrong size (usually only a pixel off and
only in extreme cases). This is a Qt bug.
8. At zoom levels that aren't multiples of 100%, parts of the image may
appear to move when the user interacts with it. Other minor redraw
glitches may also occur at such zoom levels.
9. Keyboard shortcut changes do not propagate to other KolourPaint windows
(but will propagate to future windows).
10. "File/Open Recent" entries are not updated interprocess.
11. The blinking text cursor will "disappear" if you type more text than
you can fit in a text box.
12. You cannot select only parts of the text you write.
14. The text cursor may be momentarily misrendered when scrolling the view.
17. a) Using KolourPaint on a remote X display may result in redraw errors
and pixel data corruption.
19. Read support for EPS files is extremely slow. You should not enable
the "Save Preview" dialog when saving to EPS. This is an issue with
KDE.
20. Pasting a large image (esp. one that doesn't compress well as PNG)
into an image editor (not necessarily KolourPaint) running as
different process from the KolourPaint which was the source of the
image, on a sufficiently slow computer, may fail with the following
output to STDERR:
"kolourpaint: ERROR: kpMainWindow::paste() with sel without pixmap
QClipboard: timed out while sending data"
This is a Qt bug.
21. It is not always possible to copy and paste between 2 instances of
KolourPaint running different Qt versions. See
QDataStream::setVersion().
23. Changing tool options while in the middle of a drawing option should
work but confuses KolourPaint instead. For instance:
a) With the brush tools, the cursor incorrectly appears.
b) With the rectangle-based tools, the temporary pixmap does not resize
when the line width increases.
25. Sometimes when you take a screenshot of a window, and then paste in a
new window, it will be greyscale. When pasting again, it will still be
greyscale. Cannot consistently reproduce. [Thurston]
26. Drawing with the keyboard is unreliable. Depending on the X server,
either holding down Enter may continually switch between drawing and
not drawing or KolourPaint may fail to detect the release of the Enter
key.
27. InputMethod had not been tested at zoom levels other than 100%.
28. KolourPaint has not been tested against invalid or malicious clipboard
data.
29. The Tool Box and Color Tool Bar are no longer movable or floatable.
30. The "Skew", "Rotate" and "Smooth Scale" effects produce low quality
results.
31. The rendering quality of a text box with opaque text but a see-through
background, on top of transparent document areas, is lower than in KDE 3
versions of KolourPaint.
Issue with XFree86 <= 3.3.6 with the "Emulate3Buttons" Option
=============================================================
When drawing, clicking the left or right mouse button that did not
initiate the current operation will, in this order:
1. finalise the current drawing operation
2. attempt to paste the contents of the middle-mouse-button clipboard
instead of canceling the current drawing operation.
This is due to XFree86 sending a release notification for the button that
initiated the drawing operation, followed by a press notification for the
emulated 3rd button; instead of just a single press notification for the
button that is intended to cancel the operation. This works correctly in
XFree86 4.x with "Emulate3Buttons" on because it is harder to trigger the
emulation for the 3rd button as it is only invoked if the left and right
buttons are pressed at almost the same time.
Possible solutions:
a) Use XFree86 4.x or an X server from another vendor (e.g. X.org).
b) Press Escape in KolourPaint to cancel the current drawing operation
instead of using the problematic click method described above.
c) Disable "Emulate3Buttons".

View File

@ -1,364 +0,0 @@
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
# KDE Application Version, managed by release script
set(RELEASE_SERVICE_VERSION_MAJOR "22")
set(RELEASE_SERVICE_VERSION_MINOR "12")
set(RELEASE_SERVICE_VERSION_MICRO "3")
set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(kolourpaint VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION "5.15.2")
set(KF5_MIN_VERSION "5.90.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.84.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
add_definitions(-DTRANSLATION_DOMAIN="kolourpaint")
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(ECMSetupVersion)
include(FeatureSummary)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Widgets
PrintSupport
)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
DocTools
I18n
GuiAddons
WidgetsAddons
KIO
XmlGui
TextWidgets
JobWidgets
)
add_definitions(-DQT_USE_QSTRINGBUILDER)
find_package(KF5Sane "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}")
if(KF5Sane_FOUND)
add_definitions(-DHAVE_KSANE=1)
set(KSANE_LIBRARIES KF5::Sane)
else(KF5Sane_FOUND)
add_definitions(-DHAVE_KSANE=0)
endif(KF5Sane_FOUND)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
## Generate header with version number
ecm_setup_version(${RELEASE_SERVICE_VERSION}
VARIABLE_PREFIX KOLOURPAINT
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kpVersion.h"
)
add_subdirectory( pics )
add_subdirectory( doc )
########### next target ###############
macro(CREATE_LICENSE _in_FILE _out_FILE)
FILE(READ ${_in_FILE} _contents)
FILE(WRITE ${_out_FILE} "static const char * const kpLicenseText =")
STRING(REGEX REPLACE "\"" "\\\\\"" _contents "${_contents}" )
STRING(REGEX REPLACE "\n" "\\\\n\"\n\"" _contents "${_contents}" )
FILE(APPEND ${_out_FILE} "\"${_contents}\"")
FILE(APPEND ${_out_FILE} ";\n")
endmacro(CREATE_LICENSE)
#macro_additional_clean_files( ${CMAKE_CURRENT_BINARY_DIR}/kolourpaintlicense.h )
create_license(${CMAKE_CURRENT_SOURCE_DIR}/COPYING ${CMAKE_CURRENT_BINARY_DIR}/kolourpaintlicense.h)
# GENERATED BY ./gen_cmake_srcs | fgrep -v /lgpl/
set(kolourpaint_lib1_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectBalanceCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectBlurSharpenCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectClearCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectCommandBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectEmbossCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectFlattenCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectGrayscaleCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectHSVCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectInvertCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectReduceColorsCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/effects/kpEffectToneEnhanceCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/kpDocumentMetaInfoCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformFlipCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformResizeScaleCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformRotateCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/imagelib/transforms/kpTransformSkewCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommandHistoryBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommandHistory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/kpCommandSize.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/kpMacroCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/kpNamedCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/flow/kpToolFlowCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/kpToolColorPickerCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/kpToolFloodFillCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/polygonal/kpToolPolygonalCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/rectangular/kpToolRectangularCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpAbstractSelectionContentCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolImageSelectionTransparencyCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionCreateCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionDestroyCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionMoveCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionPullFromDocumentCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/kpToolSelectionResizeScaleCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextBackspaceCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextChangeStyleCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextDeleteCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextEnterCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextGiveContentCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/commands/tools/selection/text/kpToolTextInsertCommand.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cursors/kpCursorLightCross.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cursors/kpCursorProvider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/effects/kpEffectsDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/kpDocumentMetaInfoDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformPreviewDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformResizeScaleDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformRotateDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/imagelib/transforms/kpTransformSkewDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/kpColorSimilarityDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/kpDocumentSaveOptionsPreviewDialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument.cpp
${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument_Open.cpp
${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument_Save.cpp
${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocumentSaveOptions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/document/kpDocument_Selection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environments/commands/kpCommandEnvironment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environments/dialogs/imagelib/transforms/kpTransformDialogEnvironment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environments/document/kpDocumentEnvironment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environments/kpEnvironmentBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environments/tools/kpToolEnvironment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environments/tools/selection/kpToolSelectionEnvironment.cpp
${CMAKE_CURRENT_SOURCE_DIR}/generic/kpSetOverrideCursorSaver.cpp
${CMAKE_CURRENT_SOURCE_DIR}/generic/kpWidgetMapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/generic/widgets/kpResizeSignallingLabel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/generic/widgets/kpSubWindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/blitz.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectBalance.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectBlurSharpen.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectEmboss.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectFlatten.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectGrayscale.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectHSV.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectInvert.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectReduceColors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/effects/kpEffectToneEnhance.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpColor_Constants.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpColor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpDocumentMetaInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpFloodFill.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/kpPainter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformAutoCrop.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformCrop.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformCrop_ImageSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imagelib/transforms/kpTransformCrop_TextSelection.cpp
) # kolourpaint_lib1_SRCS
set(kolourpaint_lib2_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/kpLogCategories.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kolourpaint.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kpThumbnail.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kpViewScrollableContainer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpAbstractImageSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpEllipticalImageSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpFreeFormImageSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpImageSelectionTransparency.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/image/kpRectangularImageSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/kpAbstractSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/kpSelectionDrag.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/kpSelectionFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextSelection_Cursor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextSelection_Paint.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpTextStyle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/selections/text/kpPreeditText.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layers/tempImage/kpTempImage.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Colors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Edit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_File.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Image.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Settings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_StatusBar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Text.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_Tools.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_View.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_View_Thumbnail.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mainWindow/kpMainWindow_View_Zoom.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pixmapfx/kpPixmapFX_DrawShapes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pixmapfx/kpPixmapFX_GetSetPixmapParts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pixmapfx/kpPixmapFX_Transforms.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolBrush.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolColorEraser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolEraser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolFlowBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolFlowPixmapBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolPen.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/flow/kpToolSpraycan.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolColorPicker.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_Drawing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolFloodFill.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_KeyboardEvents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_MouseEvents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_OtherEvents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_UserNotifications.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpTool_Utilities.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpToolZoom.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolCurve.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolLine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolPolygonalBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolPolygon.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/polygonal/kpToolPolyline.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolEllipse.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolRectangle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolRectangularBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/rectangular/kpToolRoundedRectangle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpAbstractImageSelectionTool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpAbstractImageSelectionTool_Transparency.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpToolEllipticalSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpToolFreeFormSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/image/kpToolRectSelection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_Create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_KeyboardEvents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_Move.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/kpAbstractSelectionTool_ResizeScale.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_Commands.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_Create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_CursorCalc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_InputMethodEvents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_KeyboardEvents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_KeyboardEvents_HandleArrowKeys.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_KeyboardEvents_HandleTypingKeys.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_Move.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_ResizeScale.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_SelectText.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/selection/text/kpToolText_TextStyle.cpp
) # kolourpaint_lib2_SRCS
if(KF5Sane_FOUND)
set(kolourpaint_lib2_SRCS
${kolourpaint_lib2_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/scan/sanedialog.cpp
)
endif(KF5Sane_FOUND)
set(kolourpaint_app_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/views/kpThumbnailView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/kpUnzoomedThumbnailView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/kpView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/kpView_Events.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/kpView_Paint.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/kpView_Selections.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/kpZoomedThumbnailView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/kpZoomedView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/manager/kpViewManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/manager/kpViewManager_TextCursor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/views/manager/kpViewManager_ViewUpdates.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityCubeRenderer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityFrame.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityHolder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/colorSimilarity/kpColorSimilarityToolBarItem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpNumInput.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectBalanceWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectBlurSharpenWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectEmbossWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectFlattenWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectHSVWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectInvertWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectReduceColorsWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectToneEnhanceWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/imagelib/effects/kpEffectWidgetBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpColorCells.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpColorPalette.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpDefaultColorCollection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpDocumentSaveOptionsWidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpDualColorButton.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpPrintDialogPage.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/kpTransparentColorCell.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/kpColorToolBar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/kpToolToolBar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetBrush.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetEraserSize.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetFillStyle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetLineWidth.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetOpaqueOrTransparent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/widgets/toolbars/options/kpToolWidgetSpraycanSize.cpp
) # set(kolourpaint_app_SRCS
set(kolourpaint_SRCS
${kolourpaint_lib1_SRCS}
${kolourpaint_lib2_SRCS}
${kolourpaint_app_SRCS}
kolourpaint.qrc
)
add_subdirectory(lgpl)
#
# Executable
#
ecm_add_app_icon(kolourpaint_SRCS ICONS
pics/app/16-apps-kolourpaint.png
pics/app/22-apps-kolourpaint.png
pics/app/32-apps-kolourpaint.png
pics/app/48-apps-kolourpaint.png
)
add_executable(kolourpaint ${kolourpaint_SRCS})
target_link_libraries(kolourpaint
KF5::XmlGui
KF5::KIOFileWidgets
KF5::TextWidgets
Qt${QT_MAJOR_VERSION}::PrintSupport
${KSANE_LIBRARIES}
kolourpaint_lgpl
)
if(KSANE_FOUND)
target_link_libraries(kolourpaint
${KSANE_LIBRARY}
)
endif(KSANE_FOUND)
install(TARGETS kolourpaint ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
install(PROGRAMS org.kde.kolourpaint.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES org.kde.kolourpaint.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install(FILES kolourpaintui.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/kolourpaint)
ki18n_install(po)
kdoctools_install(po)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)

139
COPYING
View File

@ -1,139 +0,0 @@
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
Portions Copyright (c) 2005 Kazuki Ohta <mover@hct.zaq.ne.jp>
Portions Copyright (c) 2006-2007 Mike Gashler <gashlerm@yahoo.com>
Portions Copyright (c) 2007,2011 Martin Koller <kollix@aon.at>
Portions Copyright (c) 2007 John Layt <john@layt.net>
Portions Copyright (c) 2010 Tasuku Suzuki <stasuku@gmail.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"libkolourpaint" Library
~~~~~~~~~~~~~~~~~~~~~~~~
The "libkolourpaint" dynamic link library contains various pieces of code,
each with a different license:
License 1
---------
Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
Copyright (C) 2007 Clarence Dang (dang@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
License 2
---------
Copyright (C) 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
License 3
---------
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License 4
---------
Copyright (C) 1997 Martin Jones (mjones@kde.org)
Copyright (C) 2007 Roberto Raggi (roberto@kdevelop.org)
Copyright (C) 2007 Clarence Dang (dang@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
Icons
~~~~~
Copyright (c) Nuno Pinheiro <nf.pinheiro@gmail.com>
Copyright (c) Danny Allen <dannya40uk@yahoo.co.uk>
Portions Copyright (c) Clarence Dang <dang@kde.org>
Portions Copyright (c) Kristof Borrey <borrey@kde.org>

View File

@ -1,397 +0,0 @@
GNU Free Documentation License
Version 1.2, November 2002
Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document "free" in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of "copyleft", which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The "Document", below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as "you". You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A "Modified Version" of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject. (Thus, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The "Invariant Sections" are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The "Cover Texts" are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A "Transparent" copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, LaTeX input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML, PostScript or PDF designed for human modification. Examples of
transparent image formats include PNG, XCF and JPG. Opaque formats
include proprietary formats that can be read and edited only by
proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, "Title Page" means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
A section "Entitled XYZ" means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as "Acknowledgements",
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
of such a section when you modify the Document means that it remains a
section "Entitled XYZ" according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
3. COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
4. MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
C. State on the Title page the name of the publisher of the
Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section Entitled "History", Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled "History" in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the "History" section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
K. For any section Entitled "Acknowledgements" or "Dedications",
Preserve the Title of the section, and preserve in the section all
the substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
M. Delete any section Entitled "Endorsements". Such a section
may not be included in the Modified Version.
N. Do not retitle any existing section to be Entitled "Endorsements"
or to conflict in title with any Invariant Section.
O. Preserve any Warranty Disclaimers.
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled "Endorsements", provided it contains
nothing but endorsements of your Modified Version by various
parties--for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled "History"
in the various original documents, forming one section Entitled
"History"; likewise combine any sections Entitled "Acknowledgements",
and any sections Entitled "Dedications". You must delete all sections
Entitled "Endorsements".
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an "aggregate" if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
8. TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled "Acknowledgements",
"Dedications", or "History", the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
https://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
Copyright (c) YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the "with...Texts." line with this:
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.

View File

@ -1,481 +0,0 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,8 +0,0 @@
For logs of _every_ single change made to KolourPaint between any date or
revision, visit:
https://quickgit.kde.org/?p=kolourpaint.git&a=log
For a summary of user-visible changes between each release, read NEWS.

View File

@ -1,3 +0,0 @@
#! /bin/sh
$EXTRACTRC `find . -name "*.rc" -o -name "*.ui" ` >> rc.cpp
$XGETTEXT `find . -name "*.cpp" -o -name "*.h"` -o $podir/kolourpaint.pot

386
NEWS
View File

@ -1,386 +0,0 @@
KolourPaint - KF5 based
* Port to KF5
KolourPaint 4 Series (trunk/KDE/)
====================
KolourPaint 4.0.0 BETA (Frozen 2007-10-26)
* Port to KDE 4 (Clarence Dang, Laurent Montel)
Note: This is a beta release and has not been through a full QA review.
If you want stability, use KolourPaint/KDE3, which can be
installed in parallel with KolourPaint4 BETA and runs under KDE4.
* Configurable Color Palette
* Add "Hue, Saturation, Value" effect (Mike Gashler)
* Add "Histogram Equalizer" effect (Mike Gashler)
* Add Zoom Tool
* Add "File / Properties..."
* Rectangles, rounded rectangles and ellipsed are now bounded by
the dimensions of the dragged out rectangle
* Add, to the print dialog, a choice between printing the image at the
top-left of the page or at the center (this was previously a hidden
configuration option)
(Bug #33481)
* Add hidden configuration option "Open Images in the Same Window"
(Bug #125116)
* Add "Rotate Left" (CTRL+SHIFT+Left) and "Rotate Right" (CTRL+SHIFT+R)
to "Image" menu as a quick way to access the common types of "Rotate..."
(Bug #135184, #141530))
* Add "Fit to Page", "Fit to Page Width" and "Fit to Page Height" to the
"View" Menu
* Add "Image / Draw Opaque" menu item since some users expect it.
It duplicates the functionality of the already existent Tool Box widget.
* Animate the Color Similarity Tool Bar Item, to highlight the existence
of the feature
- And make the configuration more accessible
- Also add "Image / Draw With Color Similarity" to duplicate the tool
bar item
* Make the Tool Box use as much vertical space as possible, since it
needs it for the option widgets.
* Save local files atomically - KolourPaint will no longer truncate
an existing file if the KImageIO plugin for the file format is
missing or if you run out of disk space.
[also in branches/KDE/3.5]
* Add "File / Scan..." feature (Martin Koller)
[also in branches/KDE/3.5/]
* Fix crash triggered by rapidly deselecting a selection after
drag-scaling the selection (Bug #117866)
[also in branches/KDE/3.[345]/, branches/kolourpaint/1.2_kde3/]
* Add global session save/restore (Bug #94651)
[also in branches/KDE/3.5/]
* Make "File / Open Recent" consistently work when multiple windows are
open
[also in branches/KDE/3.5/]
* CTRL+C'ing a text box also places the text in the middle-mouse-button
clipboard, in lieu of being able to highlight the text to do this
[also in branches/KDE/3.5/]
* Change minimum allowed zoom level for the grid from 600% to 400%
[also in branches/KDE/3.5/]
* Printing improvements (Bug #108976)
- Respect image DPI
- Fit image to page if image is too big
- Center image on page
[also in branches/KDE/3.5/]
* Paste transparent pixels as black instead of uninitialized colors,
when the app does not support pasting transparent pixels (such as
OpenOffice.org)
[also in branches/KDE/3.5/]
* Make "Edit / Paste in New Window" always paste white pixels as white
(it used to paste them as transparent when the selection transparency
mode was set to Transparent)
[also in branches/KDE/3.5/]
* REGRESSION: The "Skew", "Rotate" and "Smooth Scale" effects produce
low quality results
(Bug #30)
* REGRESSION: The rendering quality of a text box with opaque text but
a see-through background, on top of transparent document
areas, is lower than in KDE 3 versions of KolourPaint
(Bug #31)
* REGRESSION: Spinboxes do not support text input
(see the "Update" part of Bug #4)
* REGRESSION: InputMethod support was not ported to Qt4 so has been disabled
(Bug #27)
* REGRESSION: The Tool Box and Color Tool Bar are no longer movable or
floatable
(Bug #29)
KolourPaint 4.0.0 BETA contains all the fixes and features in KolourPaint
1.4.8_relight (KDE 3.5.8), even though not all of them were listed
above.
KolourPaint 1.4_relight Series (branches/KDE/3.5/)
===============================
KolourPaint 1.4.1_relight (Frozen 2006-01-15)
* Updated documentation (Thurston)
KolourPaint 1.4_relight (Frozen 2005-11-08)
* New icons (Danny Allen, Nuno Pinheiro)
* Tool Box icon size is 22x22, not 16x16, at screen resolution >= 1024x768
* CTRL + Mouse Wheel = Zoom
* While freehand selection scaling, holding Shift maintains aspect ratio
* Prevent accidental drags in the Colour Palette from pasting text
containing the colour code
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Cells in the bottom row and cells in the rightmost column of the Colour
Palette are now the same size as the other cells
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Text drops to the empty part of the scrollview will not be placed
outside the document
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Rename icons from "hi" to "cr" - back to the state of 1.0 (Danny Allen)
but leave application icons as "hi" (Jonathan Riddell)
* Enforce text box font height to prevent e.g. Chinese characters in
buggy fonts from enlarging the text box and putting the cursor out of
sync with the text
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Clicking in a text box selects a character based on its midpoint -
not leftmost point - to be consistent with all text editors
(esp. noticeable with big fonts)
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Return and Numpad 5 Key now draw
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Tool Actions placed outside the Tool Box resize with their toolbars
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Ensure Color Similarity maximum is 30, not 29 due to gcc4
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Tool Box traps right clicks (for the RMB Menu) on top of tool options
widgets and the empty part of the Tool Box
[also in branches/KDE/3.[34]/, branches/kolourpaint/1.2_kde3/]
* Correct and update image format associations to all formats supported
by KDE 3.5 (kdelibs/kimgio/:r466654)
* String fixes (Stefan Winter)
[also in branches/KDE/3.4/]
* Other string fixes (Malcolm Hunter, Clarence Dang, Stephan Binner)
KolourPaint 1.4_light Series (branches/KDE/3.4/)
============================
KolourPaint 1.4_light (Frozen 2005-02-22)
* Antialias text when the text box has a transparent background (Bug #24)
[later backported to branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Add Unzoomed Thumbnail Mode and Thumbnail Rectangle
* Add RMB context menu for when a selection tool is active (closing KDE
Bug #92882)
* More intuitive "Set as Image" behaviour (esp. with selection borders).
Thanks to Michael Lake for the feedback.
[later backported to branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* InputMethod support
[later backported to branches/kolourpaint/1.2_kde3/]
* Save "More Effects" dialog's last effect to config file
* Save "Resize / Scale" dialog's last "Keep aspect ratio" setting to
config file
* Add "Help / Acquiring Screenshots"
* Fix selection regressions introduced in 1.2:
- Make selection dragging with CTRL work again (copies selection onto
document)
- When creating freeform selections, include the starting point; also
avoids a QRegion crash with constructing 1-point regions
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Fix other selection bugs:
- When the user drags very quickly on a resize handle, resize the
selection instead of moving it
- Draw resize handles above the grid lines - not below - so that the
handles are always visible if they are supposed to be there
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Smaller selection and text box resize handles (visually not
actually) - covers up fewer selected pixels, doesn't cover up text
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Restore mouse cursor after deselecting selection/text tools
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Empty text clipboard fixes:
- Don't get stuck on a wait cursor after attempting to paste empty
text into a text box
- Prevent pasting text from creating a new text box if text is empty
- Prevent copying of empty text box
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Speed up renderer (most noticeable with diagonal drag-scrolling at
high zoom)
- Don't paint anything outside of the view's visible region
(previously, clipped only on view _widget_ region)
- Region-aware: paint component rectangles of the update region,
rather than the bounding rectangle
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* When changing between colour depth and quality widgets in the save
filedialog, make sure "Convert to:" and "Quality:" are correctly
rendered (hacking around a Qt redraw glitch)
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Fix crash after using the Colour Picker if it was the first used tool
[kolourpaint-1.2.2_kde3-color_picker_crash.diff]
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Fix crash due to text box when scaling image behind it
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Even when the thumbnail has focus (and not the main window), blink the
text cursor in all views
[kolourpaint-1.2.2_kde3-thumbnail_blink_text_cursor.diff]
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Correct "Soften" and "Sharpen" commands' command history names
* Correct invert commands' command history names
* Fix remaining untranslatable strings (closing KDE Bug #85785)
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Update image format associations to all formats supported by KDE 3.4
* Remove unused images in doc directory
[also in branches/KDE/3.3/, branches/kolourpaint/1.2_kde3/]
* Correct kolourpaint.desktop "Terminal=" and "Categories=" syntax
(Benjamin Meyer)
KolourPaint 1.2 Series (branches/KDE/3.3/)
======================
Version 1.2 "ByFiat Everytime" (2004-08-18)
* Add up to 500 levels of Undo/Redo (minimum of 10 levels, maximum of
500 as long as the total history size < 16MB)
* Add freehand resizing of image
* Add freehand smooth scaling of selections
* [also in 1.0 branch] New icons (Kristof Borrey)
* [also in 1.0 branch] Prefer Crystal SVG text icons over KolourPaint's
* [also in 1.0 branch] Add documentation in the KDE Help Centre
* Add drag scrolling
* Add "More Effects" dialog:
- Balance (Brightness, Contrast, Gamma)
- Emboss
- Flatten
- Invert (with choice of channels)
- Reduce Colours
- Soften & Sharpen
* File saving improvements:
- Support colour depths (optional dithering) and "colour monochrome"
- Support JPEG quality
- Realtime file dialog preview with estimated file size
- Retain PNG metadata
- Prompt when attempting lossy save
- Correctly save transparent selections (not as opaque)
* Dither more often when loading (and pasting) images for better quality
* Single key shortcuts for all tools and tool options (automatically
turned off when editing text but can then use Alt+Shift+<key>)
* Arrow keys now move one document pixel - not view pixel - at a time
(more usable when zoomed in)
* Fix selection bugs:
- Fix duplicate "Selection: Create" undo entries (Bug #5a)
- Allow redoing of selection operation if border deselected (Bug #5b)
- Don't print to STDERR when undoing a selection border create
operation and border has already been deselected
- [also in 1.0 branch] When pulling a selection from the document,
only set the bits of the document to the background colour where the
transparent selection is opaque in the same place (this is only
noticeable with colour similarity turned on). Now moving a
selection away and then back to its original place is always a NOP
as it should be.
* Selections can be deselected using Esc or clicking on icon in Tool Box
* Accidental drag detection when deselecting selections or text boxes
* Prevent selection from being moved completely offscreen (at least 1
pixel of the selection will stay within the view)
* Speed up copying selection when transparency is on
* Improve Text Tool usability:
- Allow single click creation of text box with a sane default size
- Allow freehand resizing of text boxes
- Add Opaque/Transparent selector for greater usability and
consistency with selections
- Minimum size is now 7x7 document pixels (1x1 - not 4x4 - border)
- Text cursor doesn't overlap border anymore
- When dropping text, paste at drop point
- When MMB pasting creates a new text box, do so at mouse position
* When MMB pasting text in an existing box, correctly paste multiline
clipboard contents
* Improve text quality:
- With a transparent background, don't antialias foreground opaque
text with arbitrarily chosen black
- Make sure transparent text shows up on opaque (usually, grey was
problematic) background
* Improve Resize/Scale dialog usability:
- Add Smooth Scale (useful for creating screenshot thumbnails)
- Allow manipulating image when selection is active
- Operation choices stand out as massive, easily clickable buttons
- Default focus on operation choices
* Warn if Resize/Scale, Rotate or Skew will take lots of memory
* Limit startup image size to 2048x2048
* Eliminate flicker when scrolling
* Thumbnail fixes:
- Reduce flicker when appearing (Bug #2)
- More reasonable minimum size (actually enforce it)
- [also in 1.0 branch] Use deleteLater()
- [also in 1.0 branch] Save geometry even if it's closed very quickly
after a geometry change
* Restore last used tool and tool options on startup
* Add Export, Copy To File, Paste From File, Paste in New Window,
Full Screen Mode
* Add Zoom In/Out buttons to main toolbar
* Rename Crop options in an attempt to reduce confusion:
- "Autocrop" --> "Remove Internal Border" when selection active
- "Crop Outside Selection" --> "Set as Image (Crop)"
* "Set as Image" changes:
- Enable for text boxes
- Underneath transparent bits of selection, fill image with
transparent rather than with background colour
* Permit "reloading" of an empty document
* Fixes when the current URL doesn't exist:
- Don't reload if underlying file disappeared
- Don't add non-existent file to Recent Files history
- Ask to save before mailing or setting as wallpaper
* Only enable Show Path when there is a URL
* Pop up dialog (instead of printing to STDERR) and disable Edit/Paste
on CTRL+V if the clipboard contents disappeared due to the source
application quitting (and Klipper didn't retain clipboard contents)
* Image/Clear now always sets _everything_ within the selection boundary
to the background colour - including transparent pixels
* Add Preview button to Colour Similarity Dialog to work around Bug #4
regarding spinboxes and enter key
* Colour Picker disallows trying to pick colour outside of image
* Make sure colour palette contains valid and visible colours at 8-bit
* [also in 1.0 branch] Fix (big) memory leak on kpSelection destruction
(Albert Astals Cid)
* Don't leak image dialogs' memory
* [also in 1.0 branch] Don't let C++ destruct the mask bitmap before its
painter when dbl-clicking the color eraser does NOP (avoids
QPaintDevice and X error)
* [also in 1.0 branch] Check for QImageDrag::canDecode() before calling
QImageDrag::decode() (prevents X and valgrind errors)
* [also in 1.0 branch] Fix compilation problem with QT_NO_ASCII_CAST
(Waldo Bastian)
* [also in 1.0 branch] Decrease application preference to below that of
a viewer (Stephan Kulow)
* Remember dialog dimensions
* Remove double dialog margins
* Fix missing i18n()'s
* Fix some untranslatable strings
* [also in 1.0 branch] Corrected several strings
* Remove unused icons
KolourPaint 1.0 Series (branches/kolourpaint/1.0/)
======================
Version 1.0 "Seagull" (2004-02-29)
* First stable release

104
README.md
View File

@ -1,104 +0,0 @@
http://www.kolourpaint.org/
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
For licensing and warranty information, read COPYING.
For known problems with this release of KolourPaint, read BUGS.
For what changes have been made, read NEWS.
For developer information, checkout branches/kolourpaint/control/.
For general information, read this file (README):
What is KolourPaint?
====================
KolourPaint is a free, easy-to-use paint program by KDE.
It aims to be conceptually simple to understand; providing a level of
functionality targeted towards the average user. It's designed for daily
tasks like:
* Painting - drawing diagrams and "finger painting"
* Image Manipulation - editing screenshots and photos; applying effects
* Icon Editing - drawing clipart and logos with transparency
It's not an unusable and monolithic program where simple tasks like drawing
lines become near impossible. Nor is it so simple that it lacks essential
features like Undo/Redo.
KolourPaint is opensource software written in C++ using the Qt and KDE
libraries.
Features
========
* Undo/Redo Support (10-500 levels of history depending on memory usage)
* Tools (single key shortcuts available for all tools)
- Brush, Color Eraser, Color Picker, Connected Lines a.k.a. Polyline
- Curve, Ellipse, Eraser, Flood Fill, Line, Pen, Polygon, Rectangle
- Rounded Rectangle, Spraycan, Text, Zoom
* Selections (fully undo- and redo-able)
- Rectangular, Elliptical, Free-Form shapes
- Choice between Opaque and Transparent selections
- Full Clipboard/Edit Menu support
- Freehand resizeable
* Configurable Color Palette
* Color Similarity means that you can fill regions in dithered images and
photos
* Transparency
- Draw transparent icons and logos on a checkerboard background
- All tools can draw in the "Transparent Color"
* Image Effects
- Autocrop / Remove Internal Border
- Balance (Brightness, Contrast, Gamma)
- Clear, Emboss, Flatten, Flip, Histogram Equalizer
- Hue, Saturation, Value
- Invert (with choice of channels)
- Reduce Colors, Reduce to Grayscale, Resize, Rotate
- Scale, Set as Image (Crop), Skew, Smooth Scale, Soften & Sharpen
* Close-up Editing
- Zoom (from 0.01x to 16x)
- Grid
- Thumbnail
* File Operations
- Open/Save in all file formats provided by KImageIO
(PNG, JPEG, BMP, ICO, PCX, TIFF,...) with preview
- Print, Print Preview
- Mail
- Set as Wallpaper
Updates & More Information
==========================
Visit: http://www.kolourpaint.org/
Support
=======
Visit: http://www.kolourpaint.org/
If you have any questions about compiling, installing or using KolourPaint,
don't be afraid to contact us. We try to support all versions of
KolourPaint and even issues with 3rd party binary packages.
Feedback
========
Please send bug reports and feature requests to http://bugs.kde.org/.
Don't hesitate to report bugs nor hesitate to send us your wishes -- it
provides valuable feedback that will help to improve future versions of
KolourPaint and you will not receive flames for reporting duplicates.

View File

@ -1,55 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectBalanceCommand.h"
#include "imagelib/effects/kpEffectBalance.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpEffectBalanceCommand::kpEffectBalanceCommand (int channels,
int brightness, int contrast, int gamma,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (i18n ("Balance"), actOnSelection, environ),
m_channels (channels),
m_brightness (brightness), m_contrast (contrast), m_gamma (gamma)
{
}
kpEffectBalanceCommand::~kpEffectBalanceCommand () = default;
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectBalanceCommand::applyEffect (const kpImage &image)
{
return kpEffectBalance::applyEffect (image, m_channels,
m_brightness, m_contrast, m_gamma);
}

View File

@ -1,56 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectBalanceCommand_H
#define kpEffectBalanceCommand_H
#include "kpEffectCommandBase.h"
#include "imagelib/kpImage.h"
class kpEffectBalanceCommand : public kpEffectCommandBase
{
public:
// (<brightness>, <contrast> & <gamma> are from -50 to 50)
kpEffectBalanceCommand (int channels,
int brightness, int contrast, int gamma,
bool actOnSelection,
kpCommandEnvironment *environ);
~kpEffectBalanceCommand () override;
protected:
kpImage applyEffect (const kpImage &image) override;
protected:
int m_channels;
int m_brightness, m_contrast, m_gamma;
};
#endif // kpEffectBalanceCommand_H

View File

@ -1,65 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectBlurSharpenCommand.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpEffectBlurSharpenCommand::kpEffectBlurSharpenCommand (kpEffectBlurSharpen::Type type,
int strength,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (kpEffectBlurSharpenCommand::nameForType (type),
actOnSelection, environ),
m_type (type),
m_strength (strength)
{
}
//--------------------------------------------------------------------------------
// public static
QString kpEffectBlurSharpenCommand::nameForType (kpEffectBlurSharpen::Type type)
{
switch (type) {
case kpEffectBlurSharpen::Blur: return i18n ("Soften");
case kpEffectBlurSharpen::Sharpen: return i18n ("Sharpen");
default: return {};
}
}
//--------------------------------------------------------------------------------
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectBlurSharpenCommand::applyEffect (const kpImage &image)
{
return kpEffectBlurSharpen::applyEffect (image, m_type, m_strength);
}

View File

@ -1,57 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectBlurSharpenCommand_H
#define kpEffectBlurSharpenCommand_H
#include "kpEffectCommandBase.h"
#include "imagelib/effects/kpEffectBlurSharpen.h"
#include "imagelib/kpImage.h"
class kpEffectBlurSharpenCommand : public kpEffectCommandBase
{
public:
kpEffectBlurSharpenCommand (kpEffectBlurSharpen::Type type,
int strength,
bool actOnSelection,
kpCommandEnvironment *environ);
static QString nameForType (kpEffectBlurSharpen::Type type);
protected:
kpImage applyEffect (const kpImage &image) override;
protected:
kpEffectBlurSharpen::Type m_type;
int m_strength;
};
#endif // kpEffectBlurSharpenCommand_H

View File

@ -1,110 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectClearCommand.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpEffectClearCommand::kpEffectClearCommand (bool actOnSelection,
const kpColor &newColor,
kpCommandEnvironment *environ)
: kpCommand (environ),
m_actOnSelection (actOnSelection),
m_newColor (newColor),
m_oldImagePtr (nullptr)
{
}
kpEffectClearCommand::~kpEffectClearCommand ()
{
delete m_oldImagePtr;
}
// public virtual [base kpCommand]
QString kpEffectClearCommand::name () const
{
QString opName = i18n ("Clear");
return (m_actOnSelection) ? i18n ("Selection: %1", opName) : opName;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpEffectClearCommand::size () const
{
return ImageSize (m_oldImagePtr);
}
// public virtual [base kpCommand]
void kpEffectClearCommand::execute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
m_oldImagePtr = new kpImage ();
*m_oldImagePtr = doc->image (m_actOnSelection);
// REFACTOR: Would like to derive entire class from kpEffectCommandBase but
// this code makes it difficult since it's not just acting on pixels
// (kpAbstractImageSelection::fill() takes into account the shape of a selection).
if (m_actOnSelection)
{
// OPT: could just edit pixmap directly and signal change
kpAbstractImageSelection *sel = doc->imageSelection ();
Q_ASSERT (sel);
sel->fill (m_newColor);
}
else {
doc->fill (m_newColor);
}
}
// public virtual [base kpCommand]
void kpEffectClearCommand::unexecute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
doc->setImage (m_actOnSelection, *m_oldImagePtr);
delete m_oldImagePtr;
m_oldImagePtr = nullptr;
}

View File

@ -1,62 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectClearCommand_H
#define kpEffectClearCommand_H
#include "commands/kpCommand.h"
#include "imagelib/kpColor.h"
#include "imagelib/kpImage.h"
class kpEffectClearCommand : public kpCommand
{
public:
kpEffectClearCommand (bool actOnSelection,
const kpColor &newColor,
kpCommandEnvironment *environ);
~kpEffectClearCommand () override;
QString name () const override;
SizeType size () const override;
void execute () override;
void unexecute () override;
private:
bool m_actOnSelection;
kpColor m_newColor;
kpImage *m_oldImagePtr;
};
#endif // kpEffectClearCommand_H

View File

@ -1,126 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectCommandBase.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "generic/kpSetOverrideCursorSaver.h"
#include <KLocalizedString>
#include <QCursor>
//--------------------------------------------------------------------------------
struct kpEffectCommandBasePrivate
{
QString name;
bool actOnSelection{false};
kpImage oldImage;
};
kpEffectCommandBase::kpEffectCommandBase (const QString &name,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpCommand (environ),
d (new kpEffectCommandBasePrivate ())
{
d->name = name;
d->actOnSelection = actOnSelection;
}
kpEffectCommandBase::~kpEffectCommandBase ()
{
delete d;
}
// public virtual [base kpCommand]
QString kpEffectCommandBase::name () const
{
return (d->actOnSelection) ? i18n ("Selection: %1", d->name) : d->name;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpEffectCommandBase::size () const
{
return ImageSize (d->oldImage);
}
// public virtual [base kpCommand]
void kpEffectCommandBase::execute ()
{
kpSetOverrideCursorSaver cursorSaver (Qt::WaitCursor);
kpDocument *doc = document ();
Q_ASSERT (doc);
const kpImage oldImage = doc->image (d->actOnSelection);
if (!isInvertible ())
{
d->oldImage = oldImage;
}
kpImage newImage = /*pure virtual*/applyEffect (oldImage);
doc->setImage (d->actOnSelection, newImage);
}
// public virtual [base kpCommand]
void kpEffectCommandBase::unexecute ()
{
kpSetOverrideCursorSaver cursorSaver (Qt::WaitCursor);
kpDocument *doc = document ();
Q_ASSERT (doc);
kpImage newImage;
if (!isInvertible ())
{
newImage = d->oldImage;
}
else
{
newImage = /*pure virtual*/applyEffect (doc->image (d->actOnSelection));
}
doc->setImage (d->actOnSelection, newImage);
d->oldImage = kpImage ();
}

View File

@ -1,66 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectCommandBase_H
#define kpEffectCommandBase_H
#include "commands/kpCommand.h"
#include "imagelib/kpImage.h"
class kpEffectCommandBase : public kpCommand
{
public:
kpEffectCommandBase (const QString &name,
bool actOnSelection,
kpCommandEnvironment *environ);
~kpEffectCommandBase () override;
QString name () const override;
SizeType size () const override;
public:
void execute () override;
void unexecute () override;
public:
// Return true if applyEffect(applyEffect(image)) == image
// to avoid storing the old image, saving memory.
virtual bool isInvertible () const { return false; }
protected:
virtual kpImage applyEffect (const kpImage &image) = 0;
private:
struct kpEffectCommandBasePrivate *d;
};
#endif // kpEffectCommandBase_H

View File

@ -1,55 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_EFFECT_EMBOSS 0
#include "kpEffectEmbossCommand.h"
#include "imagelib/effects/kpEffectEmboss.h"
#include "kpLogCategories.h"
#include <KLocalizedString>
kpEffectEmbossCommand::kpEffectEmbossCommand (int strength,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (i18n ("Emboss"), actOnSelection, environ),
m_strength (strength)
{
}
kpEffectEmbossCommand::~kpEffectEmbossCommand () = default;
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectEmbossCommand::applyEffect (const kpImage &image)
{
return kpEffectEmboss::applyEffect (image, m_strength);
}

View File

@ -1,53 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectEmbossCommand_H
#define kpEffectEmbossCommand_H
#include "kpEffectCommandBase.h"
#include "imagelib/kpImage.h"
class kpEffectEmbossCommand : public kpEffectCommandBase
{
public:
kpEffectEmbossCommand (int strength,
bool actOnSelection,
kpCommandEnvironment *environ);
~kpEffectEmbossCommand () override;
protected:
kpImage applyEffect (const kpImage &image) override;
protected:
int m_strength;
};
#endif // kpEffectEmbossCommand_H

View File

@ -1,61 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_EFFECT_FLATTEN 0
#include "kpEffectFlattenCommand.h"
#include "imagelib/effects/kpEffectFlatten.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpEffectFlattenCommand::kpEffectFlattenCommand (const QColor &color1,
const QColor &color2,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (i18n ("Flatten"), actOnSelection, environ),
m_color1 (color1), m_color2 (color2)
{
}
kpEffectFlattenCommand::~kpEffectFlattenCommand () = default;
//
// kpEffectFlattenCommand implements kpEffectCommandBase interface
//
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectFlattenCommand::applyEffect (const kpImage &image)
{
return kpEffectFlatten::applyEffect (image, m_color1, m_color2);
}

View File

@ -1,59 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectFlattenCommand_H
#define kpEffectFlattenCommand_H
#include <QColor>
#include "kpEffectCommandBase.h"
#include "imagelib/kpImage.h"
class kpEffectFlattenCommand : public kpEffectCommandBase
{
public:
kpEffectFlattenCommand (const QColor &color1, const QColor &color2,
bool actOnSelection,
kpCommandEnvironment *environ);
~kpEffectFlattenCommand () override;
//
// kpEffectCommandBase interface
//
protected:
kpImage applyEffect (const kpImage &image) override;
QColor m_color1, m_color2;
};
#endif // kpEffectFlattenCommand_H

View File

@ -1,59 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectGrayscaleCommand.h"
#include "imagelib/effects/kpEffectGrayscale.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpEffectGrayscaleCommand::kpEffectGrayscaleCommand (
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (
i18n ("Reduce to Grayscale"),
actOnSelection,
environ)
{
}
kpEffectGrayscaleCommand::~kpEffectGrayscaleCommand () = default;
//
// kpEffectGrayscaleCommand implements kpEffectCommandBase interface
//
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectGrayscaleCommand::applyEffect (const kpImage &image)
{
return kpEffectGrayscale::applyEffect (image);
}

View File

@ -1,57 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectGrayscaleCommand_H
#define kpEffectGrayscaleCommand_H
#include "kpEffectCommandBase.h"
#include "imagelib/kpImage.h"
class kpEffectGrayscaleCommand : public kpEffectCommandBase
{
public:
kpEffectGrayscaleCommand (bool actOnSelection,
kpCommandEnvironment *environ);
~kpEffectGrayscaleCommand () override;
//
// kpEffectCommandBase interface
//
public:
bool isInvertible () const override { return false; }
protected:
kpImage applyEffect (const kpImage &image) override;
};
#endif // kpEffectGrayscaleCommand_H

View File

@ -1,50 +0,0 @@
/*
Copyright (c) 2007 Mike Gashler <gashlerm@yahoo.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectHSVCommand.h"
#include "imagelib/effects/kpEffectHSV.h"
#include <KLocalizedString>
//---------------------------------------------------------------------
kpEffectHSVCommand::kpEffectHSVCommand (double hue, double saturation, double value,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (i18n ("Hue, Saturation, Value"), actOnSelection, environ),
m_hue (hue), m_saturation (saturation), m_value (value)
{
}
//---------------------------------------------------------------------
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectHSVCommand::applyEffect (const kpImage &image)
{
return kpEffectHSV::applyEffect (image, m_hue, m_saturation, m_value);
}
//---------------------------------------------------------------------

View File

@ -1,51 +0,0 @@
/*
Copyright (c) 2007 Mike Gashler <gashlerm@yahoo.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectHSVCommand_H
#define kpEffectHSVCommand_H
#include "kpEffectCommandBase.h"
class kpEffectHSVCommand : public kpEffectCommandBase
{
public:
kpEffectHSVCommand (double hue, double saturation, double value,
bool actOnSelection,
kpCommandEnvironment *environ);
protected:
kpImage applyEffect (const kpImage &image) override;
protected:
double m_hue, m_saturation, m_value;
};
#endif // kpEffectHSVCommand_H

View File

@ -1,66 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectInvertCommand.h"
#include "imagelib/effects/kpEffectInvert.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpEffectInvertCommand::kpEffectInvertCommand (int channels,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (channels == kpEffectInvert::RGB ?
i18n ("Invert Colors") : i18n ("Invert"),
actOnSelection, environ),
m_channels (channels)
{
}
kpEffectInvertCommand::kpEffectInvertCommand (bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectInvertCommand(kpEffectInvert::RGB, actOnSelection, environ)
{
}
kpEffectInvertCommand::~kpEffectInvertCommand () = default;
//
// kpEffectInvertCommand implements kpEffectCommandBase interface
//
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectInvertCommand::applyEffect (const kpImage &image)
{
return kpEffectInvert::applyEffect (image, m_channels);
}

View File

@ -1,63 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectInvertCommand_H
#define kpEffectInvertCommand_H
#include "kpEffectCommandBase.h"
#include "imagelib/kpImage.h"
class kpEffectInvertCommand : public kpEffectCommandBase
{
public:
kpEffectInvertCommand (int channels,
bool actOnSelection,
kpCommandEnvironment *environ);
kpEffectInvertCommand (bool actOnSelection,
kpCommandEnvironment *environ);
~kpEffectInvertCommand () override;
//
// kpEffectCommandBase interface
//
public:
bool isInvertible () const override { return true; }
protected:
kpImage applyEffect (const kpImage &image) override;
int m_channels;
};
#endif // kpEffectInvertCommand_H

View File

@ -1,80 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_EFFECT_REDUCE_COLORS 0
#include "kpEffectReduceColorsCommand.h"
#include "imagelib/effects/kpEffectReduceColors.h"
#include <KLocalizedString>
//---------------------------------------------------------------------
kpEffectReduceColorsCommand::kpEffectReduceColorsCommand (int depth, bool dither,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (commandName (depth, dither), actOnSelection, environ),
m_depth (depth), m_dither (dither)
{
}
//---------------------------------------------------------------------
// public
QString kpEffectReduceColorsCommand::commandName (int depth, int dither) const
{
switch (depth) {
case 1: if (dither) {
return i18n ("Reduce to Monochrome (Dithered)");
}
return i18n ("Reduce to Monochrome");
case 8:
if (dither) {
return i18n ("Reduce to 256 Color (Dithered)");
}
return i18n ("Reduce to 256 Color");
default: return {};
}
}
//---------------------------------------------------------------------
//
// kpEffectReduceColorsCommand implements kpEffectCommandBase interface
//
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectReduceColorsCommand::applyEffect (const kpImage &image)
{
return kpEffectReduceColors::applyEffect (image, m_depth, m_dither);
}
//---------------------------------------------------------------------

View File

@ -1,59 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectReduceColorsCommand_H
#define kpEffectReduceColorsCommand_H
#include "kpEffectCommandBase.h"
#include "imagelib/kpImage.h"
class kpEffectReduceColorsCommand : public kpEffectCommandBase
{
public:
// depth must be 1 or 8
kpEffectReduceColorsCommand (int depth, bool dither,
bool actOnSelection,
kpCommandEnvironment *environ);
QString commandName (int depth, int dither) const;
//
// kpEffectCommandBase interface
//
protected:
kpImage applyEffect (const kpImage &image) override;
int m_depth;
bool m_dither;
};
#endif // kpEffectReduceColorsCommand_H

View File

@ -1,54 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
Copyright (c) 2006 Mike Gashler <gashlerm@yahoo.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpEffectToneEnhanceCommand.h"
#include "imagelib/effects/kpEffectToneEnhance.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpEffectToneEnhanceCommand::kpEffectToneEnhanceCommand (double granularity, double amount,
bool actOnSelection,
kpCommandEnvironment *environ)
: kpEffectCommandBase (i18n ("Histogram Equalizer"), actOnSelection, environ),
m_granularity (granularity), m_amount (amount)
{
}
kpEffectToneEnhanceCommand::~kpEffectToneEnhanceCommand () = default;
// protected virtual [base kpEffectCommandBase]
kpImage kpEffectToneEnhanceCommand::applyEffect (const kpImage &image)
{
return kpEffectToneEnhance::applyEffect (image, m_granularity, m_amount);
}

View File

@ -1,53 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
Copyright (c) 2006 Mike Gashler <gashlerm@yahoo.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpEffectToneEnhanceCommand_H
#define kpEffectToneEnhanceCommand_H
#include "kpEffectCommandBase.h"
class kpEffectToneEnhanceCommand : public kpEffectCommandBase
{
public:
kpEffectToneEnhanceCommand (double granularity, double amount,
bool actOnSelection,
kpCommandEnvironment *environ);
~kpEffectToneEnhanceCommand () override;
protected:
kpImage applyEffect (const kpImage &image) override;
protected:
double m_granularity, m_amount;
};
#endif // kpEffectToneEnhanceCommand_H

View File

@ -1,86 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpDocumentMetaInfoCommand.h"
#include "document/kpDocument.h"
#include "imagelib/kpDocumentMetaInfo.h"
#include "kpDefs.h"
struct kpDocumentMetaInfoCommandPrivate
{
kpDocumentMetaInfo metaInfo, oldMetaInfo;
};
kpDocumentMetaInfoCommand::kpDocumentMetaInfoCommand (const QString &name,
const kpDocumentMetaInfo &metaInfo,
const kpDocumentMetaInfo &oldMetaInfo,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
d (new kpDocumentMetaInfoCommandPrivate ())
{
d->metaInfo = metaInfo;
d->oldMetaInfo = oldMetaInfo;
}
kpDocumentMetaInfoCommand::~kpDocumentMetaInfoCommand ()
{
delete d;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpDocumentMetaInfoCommand::size () const
{
return d->metaInfo.size () + d->oldMetaInfo.size ();
}
// public virtual [base kpCommand]
void kpDocumentMetaInfoCommand::execute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
doc->setMetaInfo (d->metaInfo);
doc->setModified ();
}
// public virtual [base kpCommand]
void kpDocumentMetaInfoCommand::unexecute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
// REFACTOR: Document in kpDocument.h that kpDocument::setMetaInfo() does not mutate modified state
doc->setMetaInfo (d->oldMetaInfo);
doc->setModified ();
}

View File

@ -1,58 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpDocumentMetaInfoCommand_H
#define kpDocumentMetaInfoCommand_H
#include "commands/kpNamedCommand.h"
class kpDocumentMetaInfo;
class kpDocumentMetaInfoCommand : public kpNamedCommand
{
public:
kpDocumentMetaInfoCommand (const QString &name,
const kpDocumentMetaInfo &metaInfo,
const kpDocumentMetaInfo &oldMetaInfo,
kpCommandEnvironment *environ);
~kpDocumentMetaInfoCommand () override;
SizeType size () const override;
public:
void execute () override;
void unexecute () override;
private:
struct kpDocumentMetaInfoCommandPrivate * const d;
};
#endif // kpDocumentMetaInfoCommand_H

View File

@ -1,135 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpTransformFlipCommand.h"
#include <QApplication>
#include "kpLogCategories.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "pixmapfx/kpPixmapFX.h"
#include <KLocalizedString>
//---------------------------------------------------------------------
kpTransformFlipCommand::kpTransformFlipCommand (bool actOnSelection,
bool horiz, bool vert,
kpCommandEnvironment *environ)
: kpCommand (environ),
m_actOnSelection (actOnSelection),
m_horiz (horiz), m_vert (vert)
{
}
//---------------------------------------------------------------------
kpTransformFlipCommand::~kpTransformFlipCommand () = default;
//---------------------------------------------------------------------
// public virtual [base kpCommand]
QString kpTransformFlipCommand::name () const
{
QString opName;
#if 1
opName = i18n ("Flip");
#else // re-enable when giving full descriptions for all actions
if (m_horiz && m_vert)
opName = i18n ("Flip horizontally and vertically");
else if (m_horiz)
opName = i18n ("Flip horizontally");
else if (m_vert)
opName = i18n ("Flip vertically");
else
{
qCCritical(kpLogCommands) << "kpTransformFlipCommand::name() not asked to flip";
return {};
}
#endif
if (m_actOnSelection) {
return i18n ("Selection: %1", opName);
}
return opName;
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
kpCommandSize::SizeType kpTransformFlipCommand::size () const
{
return 0;
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpTransformFlipCommand::execute ()
{
flip ();
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpTransformFlipCommand::unexecute ()
{
flip ();
}
//---------------------------------------------------------------------
// private
void kpTransformFlipCommand::flip ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
QApplication::setOverrideCursor (Qt::WaitCursor);
if (m_actOnSelection)
{
Q_ASSERT (doc->imageSelection ());
doc->imageSelection ()->flip (m_horiz, m_vert);
environ ()->somethingBelowTheCursorChanged ();
}
else
{
doc->setImage(doc->image().mirrored(m_horiz, m_vert));
}
QApplication::restoreOverrideCursor ();
}

View File

@ -1,60 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpTransformFlipCommand_H
#define kpTransformFlipCommand_H
#include "commands/kpCommand.h"
class kpTransformFlipCommand : public kpCommand
{
public:
kpTransformFlipCommand (bool actOnSelection,
bool horiz, bool vert,
kpCommandEnvironment *environ);
~kpTransformFlipCommand () override;
QString name () const override;
SizeType size () const override;
void execute () override;
void unexecute () override;
private:
void flip ();
bool m_actOnSelection;
bool m_horiz, m_vert;
};
#endif // kpTransformFlipCommand_H

View File

@ -1,486 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_RESIZE_SCALE_COMMAND 0
#define DEBUG_KP_TOOL_RESIZE_SCALE_DIALOG 0
#include "kpTransformResizeScaleCommand.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "layers/selections/image/kpFreeFormImageSelection.h"
#include "pixmapfx/kpPixmapFX.h"
#include "layers/selections/image/kpRectangularImageSelection.h"
#include "layers/selections/text/kpTextSelection.h"
#include <QApplication>
#include <QPoint>
#include <QPolygon>
#include <QRect>
#include <QSize>
#include <QTransform>
#include "kpLogCategories.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpTransformResizeScaleCommand::kpTransformResizeScaleCommand (bool actOnSelection,
int newWidth, int newHeight,
Type type,
kpCommandEnvironment *environ)
: kpCommand (environ),
m_actOnSelection (actOnSelection),
m_type (type),
m_backgroundColor (environ->backgroundColor ()),
m_oldSelectionPtr (nullptr)
{
kpDocument *doc = document ();
Q_ASSERT (doc);
m_oldWidth = doc->width (m_actOnSelection);
m_oldHeight = doc->height (m_actOnSelection);
m_actOnTextSelection = (m_actOnSelection &&
doc->textSelection ());
resize (newWidth, newHeight);
// If we have a selection _border_ (but not a floating selection),
// then scale the selection with the document
m_scaleSelectionWithImage = (!m_actOnSelection &&
(m_type == Scale || m_type == SmoothScale) &&
document ()->selection () &&
!document ()->selection ()->hasContent ());
}
kpTransformResizeScaleCommand::~kpTransformResizeScaleCommand ()
{
delete m_oldSelectionPtr;
}
// public virtual [base kpCommand]
QString kpTransformResizeScaleCommand::name () const
{
if (m_actOnSelection)
{
if (m_actOnTextSelection)
{
if (m_type == Resize) {
return i18n ("Text: Resize Box");
}
}
else
{
if (m_type == Scale) {
return i18n ("Selection: Scale");
}
if (m_type == SmoothScale) {
return i18n ("Selection: Smooth Scale");
}
}
}
else
{
switch (m_type)
{
case Resize:
return i18n ("Resize");
case Scale:
return i18n ("Scale");
case SmoothScale:
return i18n ("Smooth Scale");
}
}
return {};
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpTransformResizeScaleCommand::size () const
{
return ImageSize (m_oldImage) +
ImageSize (m_oldRightImage) +
ImageSize (m_oldBottomImage) +
SelectionSize (m_oldSelectionPtr);
}
// public
int kpTransformResizeScaleCommand::newWidth () const
{
return m_newWidth;
}
// public
void kpTransformResizeScaleCommand::setNewWidth (int width)
{
resize (width, newHeight ());
}
// public
int kpTransformResizeScaleCommand::newHeight () const
{
return m_newHeight;
}
// public
void kpTransformResizeScaleCommand::setNewHeight (int height)
{
resize (newWidth (), height);
}
// public
QSize kpTransformResizeScaleCommand::newSize () const
{
return {newWidth (), newHeight ()};
}
// public virtual
void kpTransformResizeScaleCommand::resize (int width, int height)
{
m_newWidth = width;
m_newHeight = height;
m_isLosslessScale = ((m_type == Scale) &&
(m_newWidth / m_oldWidth * m_oldWidth == m_newWidth) &&
(m_newHeight / m_oldHeight * m_oldHeight == m_newHeight));
}
// public
bool kpTransformResizeScaleCommand::scaleSelectionWithImage () const
{
return m_scaleSelectionWithImage;
}
// private
void kpTransformResizeScaleCommand::scaleSelectionRegionWithDocument ()
{
#if DEBUG_KP_TOOL_RESIZE_SCALE_COMMAND
qCDebug(kpLogCommands) << "kpTransformResizeScaleCommand::scaleSelectionRegionWithDocument";
#endif
Q_ASSERT (m_oldSelectionPtr);
Q_ASSERT (!m_oldSelectionPtr->hasContent ());
const double horizScale = double (m_newWidth) / double (m_oldWidth);
const double vertScale = double (m_newHeight) / double (m_oldHeight);
const int newX = static_cast<int> (m_oldSelectionPtr->x () * horizScale);
const int newY = static_cast<int> (m_oldSelectionPtr->y () * vertScale);
QPolygon currentPoints = m_oldSelectionPtr->calculatePoints ();
currentPoints.translate (-currentPoints.boundingRect ().x (),
-currentPoints.boundingRect ().y ());
// TODO: refactor into kpPixmapFX
// TODO: Can we get to size 0x0 accidentally?
QTransform scaleMatrix;
scaleMatrix.scale (horizScale, vertScale);
currentPoints = scaleMatrix.map (currentPoints);
currentPoints.translate (
-currentPoints.boundingRect ().x () + newX,
-currentPoints.boundingRect ().y () + newY);
auto *imageSel = dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr);
auto *textSel = dynamic_cast <kpTextSelection *> (m_oldSelectionPtr);
if (imageSel)
{
document ()->setSelection (
kpFreeFormImageSelection (currentPoints, kpImage (),
imageSel->transparency ()));
}
else if (textSel)
{
document ()->setSelection (
kpTextSelection (currentPoints.boundingRect (),
textSel->textLines (),
textSel->textStyle ()));
}
else {
Q_ASSERT (!"Unknown selection type");
}
environ ()->somethingBelowTheCursorChanged ();
}
// public virtual [base kpCommand]
void kpTransformResizeScaleCommand::execute ()
{
#if DEBUG_KP_TOOL_RESIZE_SCALE_COMMAND
qCDebug(kpLogCommands) << "kpTransformResizeScaleCommand::execute() type="
<< (int) m_type
<< " oldWidth=" << m_oldWidth
<< " oldHeight=" << m_oldHeight
<< " newWidth=" << m_newWidth
<< " newHeight=" << m_newHeight;
#endif
if (m_oldWidth == m_newWidth && m_oldHeight == m_newHeight)
return;
if (m_type == Resize)
{
if (m_actOnSelection)
{
if (!m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::execute() resizing sel doesn't make sense");
}
QApplication::setOverrideCursor (Qt::WaitCursor);
kpTextSelection *textSel = textSelection ();
Q_ASSERT (textSel);
kpTextSelection *newSel = textSel->resized (m_newWidth, m_newHeight);
document ()->setSelection (*newSel);
delete newSel;
environ ()->somethingBelowTheCursorChanged ();
QApplication::restoreOverrideCursor ();
}
else
{
QApplication::setOverrideCursor (Qt::WaitCursor);
if (m_newWidth < m_oldWidth)
{
m_oldRightImage = document ()->getImageAt (
QRect (m_newWidth, 0,
m_oldWidth - m_newWidth, m_oldHeight));
}
if (m_newHeight < m_oldHeight)
{
m_oldBottomImage = document ()->getImageAt (
QRect (0, m_newHeight,
m_newWidth, m_oldHeight - m_newHeight));
}
document ()->resize (m_newWidth, m_newHeight, m_backgroundColor);
QApplication::restoreOverrideCursor ();
}
}
// Scale
else
{
QApplication::setOverrideCursor (Qt::WaitCursor);
kpImage oldImage = document ()->image (m_actOnSelection);
if (!m_isLosslessScale) {
m_oldImage = oldImage;
}
kpImage newImage = kpPixmapFX::scale (oldImage, m_newWidth, m_newHeight,
m_type == SmoothScale);
if (!m_oldSelectionPtr && document ()->selection ())
{
// Save sel border
m_oldSelectionPtr = document ()->selection ()->clone ();
m_oldSelectionPtr->deleteContent ();
}
if (m_actOnSelection)
{
if (m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::execute() scaling text sel doesn't make sense");
}
Q_ASSERT (m_oldSelectionPtr);
if ( !m_oldSelectionPtr ) { // make coverity happy
return;
}
QRect newRect = QRect (m_oldSelectionPtr->x (), m_oldSelectionPtr->y (),
newImage.width (), newImage.height ());
// Not possible to retain non-rectangular selection borders on scale
// (think about e.g. a 45 deg line as part of the border & 2x scale)
Q_ASSERT (dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr));
document ()->setSelection (
kpRectangularImageSelection (newRect, newImage,
dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr)
->transparency ()));
environ ()->somethingBelowTheCursorChanged ();
}
else
{
document ()->setImage (newImage);
if (m_scaleSelectionWithImage)
{
scaleSelectionRegionWithDocument ();
}
}
QApplication::restoreOverrideCursor ();
}
}
// public virtual [base kpCommand]
void kpTransformResizeScaleCommand::unexecute ()
{
#if DEBUG_KP_TOOL_RESIZE_SCALE_COMMAND
qCDebug(kpLogCommands) << "kpTransformResizeScaleCommand::unexecute() type="
<< m_type;
#endif
if (m_oldWidth == m_newWidth && m_oldHeight == m_newHeight) {
return;
}
kpDocument *doc = document ();
Q_ASSERT (doc);
if (m_type == Resize)
{
if (m_actOnSelection)
{
if (!m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::unexecute() resizing sel doesn't make sense");
}
QApplication::setOverrideCursor (Qt::WaitCursor);
kpTextSelection *textSel = textSelection ();
Q_ASSERT (textSel);
kpTextSelection *newSel = textSel->resized (m_oldWidth, m_oldHeight);
document ()->setSelection (*newSel);
delete newSel;
environ ()->somethingBelowTheCursorChanged ();
QApplication::restoreOverrideCursor ();
}
else
{
QApplication::setOverrideCursor (Qt::WaitCursor);
kpImage newImage (m_oldWidth, m_oldHeight, QImage::Format_ARGB32_Premultiplied);
kpPixmapFX::setPixmapAt (&newImage, QPoint (0, 0),
doc->image ());
if (m_newWidth < m_oldWidth)
{
kpPixmapFX::setPixmapAt (&newImage,
QPoint (m_newWidth, 0),
m_oldRightImage);
}
if (m_newHeight < m_oldHeight)
{
kpPixmapFX::setPixmapAt (&newImage,
QPoint (0, m_newHeight),
m_oldBottomImage);
}
doc->setImage (newImage);
QApplication::restoreOverrideCursor ();
}
}
// Scale
else
{
QApplication::setOverrideCursor (Qt::WaitCursor);
kpImage oldImage;
if (!m_isLosslessScale) {
oldImage = m_oldImage;
} else {
oldImage = kpPixmapFX::scale (doc->image (m_actOnSelection),
m_oldWidth, m_oldHeight);
}
if (m_actOnSelection)
{
if (m_actOnTextSelection) {
Q_ASSERT (!"kpTransformResizeScaleCommand::unexecute() scaling text sel doesn't make sense");
}
Q_ASSERT (dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr));
auto *oldImageSel = dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr);
kpAbstractImageSelection *oldSelection = oldImageSel->clone ();
oldSelection->setBaseImage (oldImage);
doc->setSelection (*oldSelection);
delete oldSelection;
environ ()->somethingBelowTheCursorChanged ();
}
else
{
doc->setImage (oldImage);
if (m_scaleSelectionWithImage)
{
doc->setSelection (*m_oldSelectionPtr);
environ ()->somethingBelowTheCursorChanged ();
}
}
QApplication::restoreOverrideCursor ();
}
}

View File

@ -1,99 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpTransformResizeScaleCommand_H
#define kpTransformResizeScaleCommand_H
#include "imagelib/kpColor.h"
#include "commands/kpCommand.h"
#include "imagelib/kpImage.h"
class QSize;
class kpAbstractSelection;
// REFACTOR: Split into multiple classes, each doing a different thing
// e.g. resize, scale and smooth scale.
// REFACTOR: Replace kpToolSelectionResizeScaleCommand with us.
class kpTransformResizeScaleCommand : public kpCommand
{
public:
enum Type
{
Resize, Scale, SmoothScale
};
kpTransformResizeScaleCommand (bool actOnSelection,
int newWidth, int newHeight,
Type type,
kpCommandEnvironment *environ);
~kpTransformResizeScaleCommand () override;
QString name () const override;
SizeType size () const override;
public:
int newWidth () const;
void setNewWidth (int width);
int newHeight () const;
void setNewHeight (int height);
QSize newSize () const;
virtual void resize (int width, int height);
public:
bool scaleSelectionWithImage () const;
private:
void scaleSelectionRegionWithDocument ();
public:
void execute () override;
void unexecute () override;
protected:
bool m_actOnSelection;
int m_newWidth, m_newHeight;
Type m_type;
bool m_isLosslessScale;
bool m_scaleSelectionWithImage;
kpColor m_backgroundColor;
int m_oldWidth, m_oldHeight;
bool m_actOnTextSelection;
kpImage m_oldImage, m_oldRightImage, m_oldBottomImage;
kpAbstractSelection *m_oldSelectionPtr;
};
#endif // kpTransformResizeScaleCommand_H

View File

@ -1,220 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_ROTATE 0
#include "kpTransformRotateCommand.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "layers/selections/image/kpFreeFormImageSelection.h"
#include "pixmapfx/kpPixmapFX.h"
#include "layers/selections/image/kpRectangularImageSelection.h"
#include "views/manager/kpViewManager.h"
#include "kpLogCategories.h"
#include <QApplication>
#include <QPolygon>
#include <QTransform>
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpTransformRotateCommand::kpTransformRotateCommand (bool actOnSelection,
double angle,
kpCommandEnvironment *environ)
: kpCommand (environ),
m_actOnSelection (actOnSelection),
m_angle (angle),
m_backgroundColor (environ->backgroundColor (actOnSelection)),
m_losslessRotation (kpPixmapFX::isLosslessRotation (angle)),
m_oldSelectionPtr (nullptr)
{
}
kpTransformRotateCommand::~kpTransformRotateCommand ()
{
delete m_oldSelectionPtr;
}
// public virtual [base kpCommand]
QString kpTransformRotateCommand::name () const
{
QString opName = i18n ("Rotate");
return (m_actOnSelection) ? i18n ("Selection: %1", opName) : opName;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpTransformRotateCommand::size () const
{
return ImageSize (m_oldImage) +
SelectionSize (m_oldSelectionPtr);
}
// public virtual [base kpCommand]
void kpTransformRotateCommand::execute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
QApplication::setOverrideCursor (Qt::WaitCursor);
if (!m_losslessRotation) {
m_oldImage = doc->image (m_actOnSelection);
}
kpImage newImage = kpPixmapFX::rotate (doc->image (m_actOnSelection),
m_angle,
m_backgroundColor);
if (!m_actOnSelection) {
doc->setImage (newImage);
}
else {
kpAbstractImageSelection *sel = doc->imageSelection ();
Q_ASSERT (sel);
// Save old selection
m_oldSelectionPtr = sel->clone ();
// Conserve memmory:
//
// 1. If it's a lossless rotation, we don't need to the store old
// image anywhere at all, as we can reconstruct it by rotating in
// reverse.
// 2. If it's not a lossless rotation, "m_oldImage" already holds
// a copy of the old image. In this case, we actually save very
// little with this line (just, the computed transparency mask) since
// kpImage is copy-on-write.
m_oldSelectionPtr->setBaseImage (kpImage ());
// Calculate new top left (so selection rotates about center)
// (the Times2 trickery is used to reduce integer division error without
// resorting to the troublesome world of floating point)
QPoint oldCenterTimes2 (sel->x () * 2 + sel->width (),
sel->y () * 2 + sel->height ());
QPoint newTopLeftTimes2 (oldCenterTimes2 - QPoint (newImage.width (), newImage.height ()));
QPoint newTopLeft (newTopLeftTimes2.x () / 2, newTopLeftTimes2.y () / 2);
// Calculate rotated points
QPolygon currentPoints = sel->calculatePoints ();
currentPoints.translate (-currentPoints.boundingRect ().x (),
-currentPoints.boundingRect ().y ());
QTransform rotateMatrix = kpPixmapFX::rotateMatrix (doc->image (m_actOnSelection), m_angle);
currentPoints = rotateMatrix.map (currentPoints);
currentPoints.translate (-currentPoints.boundingRect ().x () + newTopLeft.x (),
-currentPoints.boundingRect ().y () + newTopLeft.y ());
if (currentPoints.boundingRect ().width () == newImage.width () &&
currentPoints.boundingRect ().height () == newImage.height ())
{
doc->setSelection (
kpFreeFormImageSelection (
currentPoints, newImage,
m_oldSelectionPtr->transparency ()));
}
else
{
// TODO: fix the latter "victim of" problem in kpAbstractImageSelection by
// allowing the border width & height != pixmap width & height
// Or maybe autocrop?
#if DEBUG_KP_TOOL_ROTATE
qCDebug(kpLogCommands) << "kpTransformRotateCommand::execute() currentPoints.boundingRect="
<< currentPoints.boundingRect ()
<< " newPixmap: w=" << newImage.width ()
<< " h=" << newImage.height ()
<< " (victim of rounding error and/or rotated-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be)";
#endif
doc->setSelection (
kpRectangularImageSelection (
QRect (newTopLeft.x (), newTopLeft.y (),
newImage.width (), newImage.height ()),
newImage,
m_oldSelectionPtr->transparency ()));
}
environ ()->somethingBelowTheCursorChanged ();
}
QApplication::restoreOverrideCursor ();
}
// public virtual [base kpCommand]
void kpTransformRotateCommand::unexecute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
QApplication::setOverrideCursor (Qt::WaitCursor);
kpImage oldImage;
if (!m_losslessRotation)
{
oldImage = m_oldImage;
m_oldImage = kpImage ();
}
else
{
oldImage = kpPixmapFX::rotate (doc->image (m_actOnSelection),
360 - m_angle,
m_backgroundColor);
}
if (!m_actOnSelection) {
doc->setImage (oldImage);
}
else {
m_oldSelectionPtr->setBaseImage (oldImage);
doc->setSelection (*m_oldSelectionPtr);
delete m_oldSelectionPtr; m_oldSelectionPtr = nullptr;
environ ()->somethingBelowTheCursorChanged ();
}
QApplication::restoreOverrideCursor ();
}

View File

@ -1,68 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpTransformRotateCommand_H
#define kpTransformRotateCommand_H
#include "imagelib/kpColor.h"
#include "commands/kpCommand.h"
#include "imagelib/kpImage.h"
class kpAbstractImageSelection;
class kpTransformRotateCommand : public kpCommand
{
public:
kpTransformRotateCommand (bool actOnSelection,
double angle, // 0 <= angle < 360 (clockwise)
kpCommandEnvironment *environ);
~kpTransformRotateCommand () override;
QString name () const override;
SizeType size () const override;
void execute () override;
void unexecute () override;
private:
bool m_actOnSelection;
double m_angle;
kpColor m_backgroundColor;
bool m_losslessRotation;
kpImage m_oldImage;
kpAbstractImageSelection *m_oldSelectionPtr;
};
#endif // kpTransformRotateCommand_H

View File

@ -1,195 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SKEW 0
#define DEBUG_KP_TOOL_SKEW_DIALOG 0
#include "kpTransformSkewCommand.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "layers/selections/image/kpFreeFormImageSelection.h"
#include "pixmapfx/kpPixmapFX.h"
#include "layers/selections/image/kpRectangularImageSelection.h"
#include "kpLogCategories.h"
#include <QApplication>
#include <QTransform>
#include <QPolygon>
// TODO: nasty, should avoid using GUI class in this command class
#include "dialogs/imagelib/transforms/kpTransformSkewDialog.h"
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpTransformSkewCommand::kpTransformSkewCommand (bool actOnSelection,
int hangle, int vangle,
kpCommandEnvironment *environ)
: kpCommand (environ),
m_actOnSelection (actOnSelection),
m_hangle (hangle), m_vangle (vangle),
m_backgroundColor (environ->backgroundColor (actOnSelection)),
m_oldSelectionPtr (nullptr)
{
}
kpTransformSkewCommand::~kpTransformSkewCommand ()
{
delete m_oldSelectionPtr;
}
// public virtual [base kpCommand]
QString kpTransformSkewCommand::name () const
{
QString opName = i18n ("Skew");
return (m_actOnSelection) ? i18n ("Selection: %1", opName) : opName;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpTransformSkewCommand::size () const
{
return ImageSize (m_oldImage) +
SelectionSize (m_oldSelectionPtr);
}
// public virtual [base kpCommand]
void kpTransformSkewCommand::execute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
QApplication::setOverrideCursor (Qt::WaitCursor);
kpImage newImage = kpPixmapFX::skew (doc->image (m_actOnSelection),
kpTransformSkewDialog::horizontalAngleForPixmapFX (m_hangle),
kpTransformSkewDialog::verticalAngleForPixmapFX (m_vangle),
m_backgroundColor);
if (!m_actOnSelection)
{
m_oldImage = doc->image (m_actOnSelection);
doc->setImage (newImage);
}
else
{
kpAbstractImageSelection *sel = doc->imageSelection ();
Q_ASSERT (sel);
// Save old selection
m_oldSelectionPtr = sel->clone ();
// Calculate skewed points
QPolygon currentPoints = sel->calculatePoints ();
currentPoints.translate (-currentPoints.boundingRect ().x (),
-currentPoints.boundingRect ().y ());
QTransform skewMatrix = kpPixmapFX::skewMatrix (
doc->image (m_actOnSelection),
kpTransformSkewDialog::horizontalAngleForPixmapFX (m_hangle),
kpTransformSkewDialog::verticalAngleForPixmapFX (m_vangle));
currentPoints = skewMatrix.map (currentPoints);
currentPoints.translate (-currentPoints.boundingRect ().x () + m_oldSelectionPtr->x (),
-currentPoints.boundingRect ().y () + m_oldSelectionPtr->y ());
if (currentPoints.boundingRect ().width () == newImage.width () &&
currentPoints.boundingRect ().height () == newImage.height ())
{
doc->setSelection (
kpFreeFormImageSelection (
currentPoints, newImage,
m_oldSelectionPtr->transparency ()));
}
else
{
// TODO: fix the latter "victim of" problem in kpAbstractImageSelection by
// allowing the border width & height != pixmap width & height
// Or maybe autocrop?
#if DEBUG_KP_TOOL_SKEW
qCDebug(kpLogCommands) << "kpTransformSkewCommand::execute() currentPoints.boundingRect="
<< currentPoints.boundingRect ()
<< " newPixmap: w=" << newImage.width ()
<< " h=" << newImage.height ()
<< " (victim of rounding error and/or skewed-a-(rectangular)-pixmap-that-was-transparent-in-the-corners-making-sel-uselessly-bigger-than-needs-be))";
#endif
doc->setSelection (
kpRectangularImageSelection (
QRect (currentPoints.boundingRect ().x (),
currentPoints.boundingRect ().y (),
newImage.width (),
newImage.height ()),
newImage,
m_oldSelectionPtr->transparency ()));
}
environ ()->somethingBelowTheCursorChanged ();
}
QApplication::restoreOverrideCursor ();
}
// public virtual [base kpCommand]
void kpTransformSkewCommand::unexecute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
QApplication::setOverrideCursor (Qt::WaitCursor);
if (!m_actOnSelection)
{
doc->setImage (m_oldImage);
m_oldImage = kpImage ();
}
else
{
doc->setSelection (*m_oldSelectionPtr);
delete m_oldSelectionPtr; m_oldSelectionPtr = nullptr;
environ ()->somethingBelowTheCursorChanged ();
}
QApplication::restoreOverrideCursor ();
}

View File

@ -1,65 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpTransformSkewCommand_H
#define kpTransformSkewCommand_H
#include "imagelib/kpColor.h"
#include "imagelib/kpImage.h"
#include "commands/kpCommand.h"
class kpTransformSkewCommand : public kpCommand
{
public:
kpTransformSkewCommand (bool actOnSelection,
int hangle, int vangle,
kpCommandEnvironment *environ);
~kpTransformSkewCommand () override;
QString name () const override;
SizeType size () const override;
void execute () override;
void unexecute () override;
private:
bool m_actOnSelection;
int m_hangle, m_vangle;
kpColor m_backgroundColor;
kpImage m_oldImage;
kpAbstractImageSelection *m_oldSelectionPtr;
};
#endif // kpTransformSkewCommand_H

View File

@ -1,83 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_COMMAND_HISTORY 0
#include "kpCommand.h"
#include "environments/commands/kpCommandEnvironment.h"
kpCommand::kpCommand (kpCommandEnvironment *environ)
: m_environ (environ)
{
Q_ASSERT (environ);
}
kpCommand::~kpCommand () = default;
kpCommandEnvironment *kpCommand::environ () const
{
return m_environ;
}
// protected
kpDocument *kpCommand::document () const
{
return m_environ->document ();
}
// protected
kpAbstractSelection *kpCommand::selection () const
{
return m_environ->selection ();
}
// protected
kpAbstractImageSelection *kpCommand::imageSelection () const
{
return m_environ->imageSelection ();
}
// protected
kpTextSelection *kpCommand::textSelection () const
{
return m_environ->textSelection ();
}
// protected
kpViewManager *kpCommand::viewManager () const
{
return m_environ->viewManager ();
}

View File

@ -1,90 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpCommand_H
#define kpCommand_H
#include "kpCommandSize.h"
#undef environ // macro on win32
class QString;
class kpAbstractImageSelection;
class kpAbstractSelection;
class kpCommandEnvironment;
class kpDocument;
class kpTextSelection;
class kpViewManager;
class kpCommand : public kpCommandSize
{
public:
kpCommand (kpCommandEnvironment *environ);
virtual ~kpCommand ();
public:
virtual QString name () const = 0;
// Returns the estimated size in bytes.
//
// You only have to factor in the size of variables that change according
// to the amount of input e.g. pixmap size, text size. There is no need
// to include the size of O(1) variables unless they are huge.
//
// If in doubt, return the largest possible amount of memory that your
// command will take. This is better than making the user unexpectedly
// run out of memory.
//
// Implement this by measuring the size of all of your fields, using
// kpCommandSize.
virtual SizeType size () const = 0;
virtual void execute () = 0;
virtual void unexecute () = 0;
protected:
kpCommandEnvironment *environ () const;
// Commonly used accessors - simply forwards to environ().
kpDocument *document () const;
kpAbstractSelection *selection () const;
kpAbstractImageSelection *imageSelection () const;
kpTextSelection *textSelection () const;
kpViewManager *viewManager () const;
private:
kpCommandEnvironment * const m_environ;
};
#endif // kpCommand_H

View File

@ -1,131 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_COMMAND_HISTORY 0
#include "kpCommandHistory.h"
#include "layers/selections/kpAbstractSelection.h"
#include "mainWindow/kpMainWindow.h"
#include "tools/kpTool.h"
#include "commands/tools/selection/kpToolSelectionCreateCommand.h"
kpCommandHistory::kpCommandHistory (bool doReadConfig, kpMainWindow *mainWindow)
: kpCommandHistoryBase (doReadConfig, mainWindow->actionCollection ()),
m_mainWindow (mainWindow)
{
}
kpCommandHistory::~kpCommandHistory () = default;
static bool NextUndoCommandIsCreateBorder (kpCommandHistory *commandHistory)
{
Q_ASSERT (commandHistory);
kpCommand *cmd = commandHistory->nextUndoCommand ();
if (!cmd) {
return false;
}
auto *c = dynamic_cast <kpToolSelectionCreateCommand *> (cmd);
if (!c) {
return false;
}
const kpAbstractSelection *sel = c->fromSelection ();
Q_ASSERT (sel);
return (!sel->hasContent ());
}
// public
void kpCommandHistory::addCreateSelectionCommand (kpToolSelectionCreateCommand *cmd,
bool execute)
{
if (cmd->fromSelection ()->hasContent ())
{
addCommand (cmd, execute);
return;
}
if (::NextUndoCommandIsCreateBorder (this))
{
setNextUndoCommand (cmd);
if (execute) {
cmd->execute ();
}
}
else {
addCommand (cmd, execute);
}
}
//---------------------------------------------------------------------
// public slot virtual [base KCommandHistory]
void kpCommandHistory::undo ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistory::undo() CALLED!";
#endif
if (m_mainWindow && m_mainWindow->toolHasBegunShape ())
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\thas begun shape - cancel draw";
#endif
m_mainWindow->tool ()->cancelShapeInternal ();
}
else {
kpCommandHistoryBase::undo ();
}
}
//---------------------------------------------------------------------
// public slot virtual [base KCommandHistory]
void kpCommandHistory::redo ()
{
if (m_mainWindow && m_mainWindow->toolHasBegunShape ())
{
// Not completely obvious but what else can we do?
//
// Ignoring the request would not be intuitive for tools like
// Polygon & Polyline (where it's not always apparent to the user
// that s/he's still drawing a shape even though the mouse isn't
// down).
m_mainWindow->tool ()->cancelShapeInternal ();
}
else {
kpCommandHistoryBase::redo ();
}
}

View File

@ -1,105 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpCommandHistory_H
#define kpCommandHistory_H
#include "kpCommandHistoryBase.h"
class kpMainWindow;
class kpToolSelectionCreateCommand;
//
// KolourPaint-specific command history functionality.
//
// Intercepts Undo/Redo requests:
//
// If the user is currently drawing a shape, it cancels it.
// Else it passes on the Undo/Redo request to kpCommandHistoryBase.
//
// TODO: This is wrong. It won't work if the Undo action is disabled,
// for instance. Later: What about kpToolText::viewEvent()'s use of
// QEvent::ShortcutOverride?
//
// Maybe the real solution is to call kpCommandHistoryBase::addCommand()
// as _soon_ as the shape starts - not after it ends. But the
// trouble with this solution is that if the user Undoes/cancels
// the shape s/he's currently drawing, it would replace a Redo
// slot in the history. Arguably you shouldn't be able to Redo
// something you never finished drawing.
//
// The solution is to add this functionality to kpCommandHistoryBase.
//
class kpCommandHistory : public kpCommandHistoryBase
{
Q_OBJECT
public:
kpCommandHistory (bool doReadConfig, kpMainWindow *mainWindow);
~kpCommandHistory () override;
public:
// Same as addCommand(), except that this has a more desirable behavior
// when adding a selection border creation command: If the next undo command
// also creates a selection border, it overwrites that command
// with the given <cmd>, instead of adding to the undo history.
//
// This helps to reduce the number of consecutive selection border
// creation commands in the history. Exactly one border creation
// command before each "real" selection command is useful as it allows
// users to undo just that "real" operation and then do a different "real"
// operation with the same border (as sometimes, exact borders are difficult
// to recreate). However, multiple consecutive border creation
// commands get annoying since none of them mutate the document,
// so if the user has not done a "real" command with the last selection
// border (i.e. the next undo command), what this method is saying is
// that the user wanted to throw away that border drag anyway.
//
// This special behavior is perfectly safe since border creation commands
// do not mutate the document.
//
// If <cmd> creates a selection that is not just a border, this
// method has the same effect as addCommand().
//
// REFACTOR: Why not just override addCommand() and test if it was given a
// kpToolSelectionCreateCommand?
void addCreateSelectionCommand (kpToolSelectionCreateCommand *cmd,
bool execute = true);
public slots:
void undo () override;
void redo () override;
protected:
kpMainWindow *m_mainWindow;
};
#endif // kpCommandHistory_H

View File

@ -1,714 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_COMMAND_HISTORY 0
#include "kpCommandHistoryBase.h"
#include <climits>
#include <QMenu>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KStandardShortcut>
#include <KStandardAction>
#include <KToolBarPopupAction>
#include <KActionCollection>
#include <KLocalizedString>
#include "kpCommand.h"
#include "kpLogCategories.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "mainWindow/kpMainWindow.h"
#include "tools/kpTool.h"
//---------------------------------------------------------------------
static void ClearPointerList(QList<kpCommand *> &list)
{
qDeleteAll(list);
list.clear();
}
//--------------------------------------------------------------------------------
kpCommandHistoryBase::kpCommandHistoryBase (bool doReadConfig,
KActionCollection *ac)
{
m_actionUndo = new KToolBarPopupAction(QIcon::fromTheme(QStringLiteral("edit-undo")), undoActionText (), this);
ac->addAction (KStandardAction::name (KStandardAction::Undo), m_actionUndo);
ac->setDefaultShortcuts (m_actionUndo, KStandardShortcut::shortcut (KStandardShortcut::Undo));
connect (m_actionUndo, &KToolBarPopupAction::triggered, this, &kpCommandHistoryBase::undo);
m_actionRedo = new KToolBarPopupAction(QIcon::fromTheme(QStringLiteral("edit-redo")), redoActionText (), this);
ac->addAction (KStandardAction::name (KStandardAction::Redo), m_actionRedo);
ac->setDefaultShortcuts (m_actionRedo, KStandardShortcut::shortcut (KStandardShortcut::Redo));
connect (m_actionRedo, &KToolBarPopupAction::triggered, this, &kpCommandHistoryBase::redo );
m_actionUndo->setEnabled (false);
m_actionRedo->setEnabled (false);
connect (m_actionUndo->menu(), &QMenu::triggered,
this, &kpCommandHistoryBase::undoUpToNumber);
connect (m_actionRedo->menu(), &QMenu::triggered,
this, &kpCommandHistoryBase::redoUpToNumber);
m_undoMinLimit = 10;
m_undoMaxLimit = 500;
m_undoMaxLimitSizeLimit = 16 * 1048576;
m_documentRestoredPosition = 0;
if (doReadConfig) {
readConfig ();
}
}
//--------------------------------------------------------------------------------
kpCommandHistoryBase::~kpCommandHistoryBase ()
{
::ClearPointerList(m_undoCommandList);
::ClearPointerList(m_redoCommandList);
}
//--------------------------------------------------------------------------------
// public
int kpCommandHistoryBase::undoLimit () const
{
return undoMinLimit ();
}
// public
void kpCommandHistoryBase::setUndoLimit (int limit)
{
setUndoMinLimit (limit);
}
// public
int kpCommandHistoryBase::undoMinLimit () const
{
return m_undoMinLimit;
}
// public
void kpCommandHistoryBase::setUndoMinLimit (int limit)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::setUndoMinLimit("
<< limit << ")";
#endif
if (limit < 1 || limit > 5000/*"ought to be enough for anybody"*/)
{
qCCritical(kpLogCommands) << "kpCommandHistoryBase::setUndoMinLimit("
<< limit << ")";
return;
}
if (limit == m_undoMinLimit) {
return;
}
m_undoMinLimit = limit;
trimCommandListsUpdateActions ();
}
// public
int kpCommandHistoryBase::undoMaxLimit () const
{
return m_undoMaxLimit;
}
// public
void kpCommandHistoryBase::setUndoMaxLimit (int limit)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::setUndoMaxLimit("
<< limit << ")";
#endif
if (limit < 1 || limit > 5000/*"ought to be enough for anybody"*/)
{
qCCritical(kpLogCommands) << "kpCommandHistoryBase::setUndoMaxLimit("
<< limit << ")";
return;
}
if (limit == m_undoMaxLimit) {
return;
}
m_undoMaxLimit = limit;
trimCommandListsUpdateActions ();
}
// public
kpCommandSize::SizeType kpCommandHistoryBase::undoMaxLimitSizeLimit () const
{
return m_undoMaxLimitSizeLimit;
}
// public
void kpCommandHistoryBase::setUndoMaxLimitSizeLimit (kpCommandSize::SizeType sizeLimit)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::setUndoMaxLimitSizeLimit("
<< sizeLimit << ")";
#endif
if (sizeLimit < 0 ||
sizeLimit > (500 * 1048576)/*"ought to be enough for anybody"*/)
{
qCCritical(kpLogCommands) << "kpCommandHistoryBase::setUndoMaxLimitSizeLimit("
<< sizeLimit << ")";
return;
}
if (sizeLimit == m_undoMaxLimitSizeLimit) {
return;
}
m_undoMaxLimitSizeLimit = sizeLimit;
trimCommandListsUpdateActions ();
}
// public
void kpCommandHistoryBase::readConfig ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::readConfig()";
#endif
KConfigGroup cfg (KSharedConfig::openConfig (), kpSettingsGroupUndoRedo);
setUndoMinLimit (cfg.readEntry (kpSettingUndoMinLimit, undoMinLimit ()));
setUndoMaxLimit (cfg.readEntry (kpSettingUndoMaxLimit, undoMaxLimit ()));
setUndoMaxLimitSizeLimit (
cfg.readEntry <kpCommandSize::SizeType> (kpSettingUndoMaxLimitSizeLimit,
undoMaxLimitSizeLimit ()));
trimCommandListsUpdateActions ();
}
// public
void kpCommandHistoryBase::writeConfig ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::writeConfig()";
#endif
KConfigGroup cfg (KSharedConfig::openConfig (), kpSettingsGroupUndoRedo);
cfg.writeEntry (kpSettingUndoMinLimit, undoMinLimit ());
cfg.writeEntry (kpSettingUndoMaxLimit, undoMaxLimit ());
cfg.writeEntry <kpCommandSize::SizeType> (
kpSettingUndoMaxLimitSizeLimit, undoMaxLimitSizeLimit ());
cfg.sync ();
}
// public
void kpCommandHistoryBase::addCommand (kpCommand *command, bool execute)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::addCommand("
<< command
<< ",execute=" << execute << ")"
#endif
if (execute) {
command->execute ();
}
m_undoCommandList.push_front (command);
::ClearPointerList(m_redoCommandList);
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\tdocumentRestoredPosition=" << m_documentRestoredPosition;
#endif
if (m_documentRestoredPosition != INT_MAX)
{
if (m_documentRestoredPosition > 0) {
m_documentRestoredPosition = INT_MAX;
}
else {
m_documentRestoredPosition--;
}
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\t\tdocumentRestoredPosition=" << m_documentRestoredPosition;
#endif
}
trimCommandListsUpdateActions ();
}
// public
void kpCommandHistoryBase::clear ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::clear()";
#endif
::ClearPointerList(m_undoCommandList);
::ClearPointerList(m_redoCommandList);
m_documentRestoredPosition = 0;
updateActions ();
}
//---------------------------------------------------------------------
// protected slot
void kpCommandHistoryBase::undoInternal ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::undoInternal()";
#endif
kpCommand *undoCommand = nextUndoCommand ();
if (!undoCommand) {
return;
}
undoCommand->unexecute ();
m_undoCommandList.erase (m_undoCommandList.begin ());
m_redoCommandList.push_front (undoCommand);
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\tdocumentRestoredPosition=" << m_documentRestoredPosition;
#endif
if (m_documentRestoredPosition != INT_MAX)
{
m_documentRestoredPosition++;
if (m_documentRestoredPosition == 0)
emit documentRestored ();
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\t\tdocumentRestoredPosition=" << m_documentRestoredPosition;
#endif
}
}
//---------------------------------------------------------------------
// protected slot
void kpCommandHistoryBase::redoInternal ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::redoInternal()";
#endif
kpCommand *redoCommand = nextRedoCommand ();
if (!redoCommand) {
return;
}
redoCommand->execute ();
m_redoCommandList.erase (m_redoCommandList.begin ());
m_undoCommandList.push_front (redoCommand);
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\tdocumentRestoredPosition=" << m_documentRestoredPosition;
#endif
if (m_documentRestoredPosition != INT_MAX)
{
m_documentRestoredPosition--;
if (m_documentRestoredPosition == 0) {
emit documentRestored ();
}
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\t\tdocumentRestoredPosition=" << m_documentRestoredPosition;
#endif
}
}
//---------------------------------------------------------------------
// public slot virtual
void kpCommandHistoryBase::undo ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::undo()";
#endif
undoInternal ();
trimCommandListsUpdateActions ();
}
//---------------------------------------------------------------------
// public slot virtual
void kpCommandHistoryBase::redo ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::redo()";
#endif
redoInternal ();
trimCommandListsUpdateActions ();
}
//---------------------------------------------------------------------
// public slot virtual
void kpCommandHistoryBase::undoUpToNumber (QAction *which)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::undoUpToNumber(" << which << ")";
#endif
for (int i = 0;
i <= which->data().toInt() && !m_undoCommandList.isEmpty ();
i++)
{
undoInternal ();
}
trimCommandListsUpdateActions ();
}
// public slot virtual
void kpCommandHistoryBase::redoUpToNumber (QAction *which)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::redoUpToNumber(" << which << ")";
#endif
for (int i = 0;
i <= which->data().toInt() && !m_redoCommandList.isEmpty ();
i++)
{
redoInternal ();
}
trimCommandListsUpdateActions ();
}
// protected
QString kpCommandHistoryBase::undoActionText () const
{
kpCommand *undoCommand = nextUndoCommand ();
return (undoCommand) ? i18n ("&Undo: %1", undoCommand->name ()) : i18n ("&Undo");
}
// protected
QString kpCommandHistoryBase::redoActionText () const
{
kpCommand *redoCommand = nextRedoCommand ();
return (redoCommand) ? i18n ("&Redo: %1", redoCommand->name ()) : i18n ("&Redo");
}
// protected
QString kpCommandHistoryBase::undoActionToolTip () const
{
kpCommand *undoCommand = nextUndoCommand ();
return (undoCommand) ? i18n ("Undo: %1", undoCommand->name ()) : i18n ("Undo");
}
// protected
QString kpCommandHistoryBase::redoActionToolTip () const
{
kpCommand *redoCommand = nextRedoCommand ();
return (redoCommand) ? i18n ("Redo: %1", redoCommand->name ()) : i18n ("Redo");
}
// protected
void kpCommandHistoryBase::trimCommandListsUpdateActions ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::trimCommandListsUpdateActions()";
#endif
trimCommandLists ();
updateActions ();
}
//--------------------------------------------------------------------------------
// protected
void kpCommandHistoryBase::trimCommandList(QList<kpCommand *> &commandList)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::trimCommandList()";
QTime timer; timer.start ();
qCDebug(kpLogCommands) << "\tsize=" << commandList.size()
<< " undoMinLimit=" << m_undoMinLimit
<< " undoMaxLimit=" << m_undoMaxLimit
<< " undoMaxLimitSizeLimit=" << m_undoMaxLimitSizeLimit;
#endif
if ( commandList.size() <= m_undoMinLimit )
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\t\tsize under undoMinLimit - done";
#endif
return;
}
#if DEBUG_KP_COMMAND_HISTORY && 0
qCDebug(kpLogCommands) << "\tsize over undoMinLimit - iterating thru cmds:";
#endif
QList <kpCommand *>::iterator it = commandList.begin ();
int upto = 0;
kpCommandSize::SizeType sizeSoFar = 0;
while (it != commandList.end ())
{
bool advanceIt = true;
if (sizeSoFar <= m_undoMaxLimitSizeLimit)
{
sizeSoFar += (*it)->size ();
}
#if DEBUG_KP_COMMAND_HISTORY && 0
qCDebug(kpLogCommands) << "\t\t" << upto << ":"
<< " name='" << (*it)->name ()
<< "' size=" << (*it)->size ()
<< " sizeSoFar=" << sizeSoFar;
#endif
if (upto >= m_undoMinLimit)
{
if (upto >= m_undoMaxLimit ||
sizeSoFar > m_undoMaxLimitSizeLimit)
{
#if DEBUG_KP_COMMAND_HISTORY && 0
qCDebug(kpLogCommands) << "\t\t\tkill";
#endif
delete (*it);
it = m_undoCommandList.erase (it);
advanceIt = false;
}
}
if (advanceIt) {
it++;
}
upto++;
}
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\ttook " << timer.elapsed () << "ms";
#endif
}
//--------------------------------------------------------------------------------
// protected
void kpCommandHistoryBase::trimCommandLists ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::trimCommandLists()";
#endif
trimCommandList(m_undoCommandList);
trimCommandList(m_redoCommandList);
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\tdocumentRestoredPosition=" << m_documentRestoredPosition
#endif
if (m_documentRestoredPosition != INT_MAX)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\t\tundoCmdList.size=" << m_undoCommandList.size ()
<< " redoCmdList.size=" << m_redoCommandList.size ();
#endif
if (m_documentRestoredPosition > static_cast<int> (m_redoCommandList.size ()) ||
-m_documentRestoredPosition > static_cast<int> (m_undoCommandList.size ()))
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\t\t\tinvalidate documentRestoredPosition";
#endif
m_documentRestoredPosition = INT_MAX;
}
}
}
static void populatePopupMenu (QMenu *popupMenu,
const QString &undoOrRedo,
const QList <kpCommand *> &commandList)
{
if (!popupMenu) {
return;
}
popupMenu->clear ();
QList <kpCommand *>::const_iterator it = commandList.begin ();
int i = 0;
while (i < 10 && it != commandList.end ())
{
QAction *action = new QAction(i18n ("%1: %2", undoOrRedo, (*it)->name ()), popupMenu);
action->setData(i);
popupMenu->addAction (action);
i++;
it++;
}
if (it != commandList.end ())
{
// TODO: maybe have a scrollview show all the items instead, like KOffice in KDE 3
// LOCOMPAT: should be centered text.
popupMenu->addSection (i18np ("%1 more item", "%1 more items",
commandList.size () - i));
}
}
// protected
void kpCommandHistoryBase::updateActions ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::updateActions()";
#endif
m_actionUndo->setEnabled (static_cast<bool> (nextUndoCommand ()));
// Don't want to keep changing toolbar text.
// TODO: As a bad side-effect, the menu doesn't have "Undo: <action>"
// anymore. In any case, the KDE4 KToolBarPopupAction
// sucks in menus as it forces the clicking of a submenu. IMO,
// there should be no submenu in the menu.
//m_actionUndo->setText (undoActionText ());
// But in icon mode, a tooltip with context is useful.
m_actionUndo->setToolTip (undoActionToolTip ());
#if DEBUG_KP_COMMAND_HISTORY
QTime timer; timer.start ();
#endif
populatePopupMenu (m_actionUndo->menu (),
i18n ("Undo"),
m_undoCommandList);
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\tpopuplatePopupMenu undo=" << timer.elapsed ()
<< "ms";
#endif
m_actionRedo->setEnabled (static_cast<bool> (nextRedoCommand ()));
// Don't want to keep changing toolbar text.
// TODO: As a bad side-effect, the menu doesn't have "Undo: <action>"
// anymore. In any case, the KDE4 KToolBarPopupAction
// sucks in menus as it forces the clicking of a submenu. IMO,
// there should be no submenu in the menu.
//m_actionRedo->setText (redoActionText ());
// But in icon mode, a tooltip with context is useful.
m_actionRedo->setToolTip (redoActionToolTip ());
#if DEBUG_KP_COMMAND_HISTORY
timer.restart ();
#endif
populatePopupMenu (m_actionRedo->menu (),
i18n ("Redo"),
m_redoCommandList);
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\tpopuplatePopupMenu redo=" << timer.elapsed ()
<< "ms";
#endif
}
// public
kpCommand *kpCommandHistoryBase::nextUndoCommand () const
{
if (m_undoCommandList.isEmpty ()) {
return nullptr;
}
return m_undoCommandList.first ();
}
// public
kpCommand *kpCommandHistoryBase::nextRedoCommand () const
{
if (m_redoCommandList.isEmpty ()) {
return nullptr;
}
return m_redoCommandList.first ();
}
// public
void kpCommandHistoryBase::setNextUndoCommand (kpCommand *command)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::setNextUndoCommand("<< command << ")";
#endif
if (m_undoCommandList.isEmpty ()) {
return;
}
delete *m_undoCommandList.begin ();
*m_undoCommandList.begin () = command;
trimCommandListsUpdateActions ();
}
// public slot virtual
void kpCommandHistoryBase::documentSaved ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpCommandHistoryBase::documentSaved()";
#endif
m_documentRestoredPosition = 0;
}

View File

@ -1,146 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpCommandHistoryBase_H
#define kpCommandHistoryBase_H
#include <QObject>
#include <QString>
#include <QList>
#include "commands/kpCommandSize.h"
class QAction;
class KActionCollection;
class KToolBarPopupAction;
class kpCommand;
// Clone of KCommandHistory with features required by KolourPaint but which
// could also be useful for other apps:
// - nextUndoCommand()/nextRedoCommand()
// - undo/redo history limited by both number and size
//
// Features not required by KolourPaint (e.g. commandExecuted()) are not
// implemented and undo limit == redo limit. So compared to
// KCommandHistory, this is only "almost source compatible".
class kpCommandHistoryBase : public QObject
{
Q_OBJECT
public:
kpCommandHistoryBase (bool doReadConfig, KActionCollection *ac);
~kpCommandHistoryBase () override;
public:
// (provided for compatibility with KCommandHistory)
int undoLimit () const;
void setUndoLimit (int limit);
int undoMinLimit () const;
void setUndoMinLimit (int limit);
int undoMaxLimit () const;
void setUndoMaxLimit (int limit);
kpCommandSize::SizeType undoMaxLimitSizeLimit () const;
void setUndoMaxLimitSizeLimit (kpCommandSize::SizeType sizeLimit);
public:
// Read and write above config
void readConfig ();
void writeConfig ();
public:
void addCommand (kpCommand *command, bool execute = true);
void clear ();
protected slots:
// (same as undo() & redo() except they don't call
// trimCommandListsUpdateActions())
void undoInternal ();
void redoInternal ();
public slots:
virtual void undo ();
virtual void redo ();
virtual void undoUpToNumber (QAction *which);
virtual void redoUpToNumber (QAction *which);
protected:
QString undoActionText () const;
QString redoActionText () const;
QString undoActionToolTip () const;
QString redoActionToolTip () const;
void trimCommandListsUpdateActions ();
void trimCommandList(QList<kpCommand *> &commandList);
void trimCommandLists ();
void updateActions ();
public:
kpCommand *nextUndoCommand () const;
kpCommand *nextRedoCommand () const;
void setNextUndoCommand (kpCommand *command);
public slots:
virtual void documentSaved ();
signals:
void documentRestored ();
protected:
KToolBarPopupAction *m_actionUndo, *m_actionRedo;
// (Front element is the next one)
QList <kpCommand *> m_undoCommandList;
QList <kpCommand *> m_redoCommandList;
int m_undoMinLimit, m_undoMaxLimit;
kpCommandSize::SizeType m_undoMaxLimitSizeLimit;
// What you have to do to get back to the document's unmodified state:
// * -x: must Undo x times
// * 0: unmodified
// * +x: must Redo x times
// * INT_MAX: can never become unmodified again
//
// ASSUMPTION: will never have INT_MAX commands in any list.
int m_documentRestoredPosition;
};
#endif // kpCommandHistoryBase_H

View File

@ -1,152 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_COMMAND_SIZE 0
#include "commands/kpCommandSize.h"
#include "layers/selections/kpAbstractSelection.h"
#include <QImage>
#include <QPolygon>
#include <QString>
// public static
kpCommandSize::SizeType kpCommandSize::PixmapSize (const QImage &image)
{
return kpCommandSize::PixmapSize (image.width (), image.height (), image.depth ());
}
// public static
kpCommandSize::SizeType kpCommandSize::PixmapSize (const QImage *image)
{
return (image ? kpCommandSize::PixmapSize (*image) : 0);
}
// public static
kpCommandSize::SizeType kpCommandSize::PixmapSize (int width, int height, int depth)
{
// handle 15bpp
int roundedDepth = (depth > 8 ? (depth + 7) / 8 * 8 : depth);
kpCommandSize::SizeType ret =
static_cast<kpCommandSize::SizeType> (width) * height * roundedDepth / 8;
#if DEBUG_KP_COMMAND_SIZE && 0
qCDebug(kpLogCommands) << "kpCommandSize::PixmapSize() w=" << width
<< " h=" << height
<< " d=" << depth
<< " roundedDepth=" << roundedDepth
<< " ret=" << ret;
#endif
return ret;
}
// public static
kpCommandSize::SizeType kpCommandSize::QImageSize (const QImage &image)
{
return kpCommandSize::QImageSize (image.width (), image.height (), image.depth ());
}
// public static
kpCommandSize::SizeType kpCommandSize::QImageSize (const QImage *image)
{
return (image ? kpCommandSize::QImageSize (*image) : 0);
}
// public static
kpCommandSize::SizeType kpCommandSize::QImageSize (int width, int height, int depth)
{
// handle 15bpp
int roundedDepth = (depth > 8 ? (depth + 7) / 8 * 8 : depth);
kpCommandSize::SizeType ret =
static_cast<kpCommandSize::SizeType> (width) * height * roundedDepth / 8;
#if DEBUG_KP_COMMAND_SIZE && 0
qCDebug(kpLogCommands) << "kpCommandSize::QImageSize() w=" << width
<< " h=" << height
<< " d=" << depth
<< " roundedDepth=" << roundedDepth
<< " ret=" << ret;
#endif
return ret;
}
// public static
kpCommandSize::SizeType kpCommandSize::ImageSize (const kpImage &image)
{
return kpCommandSize::PixmapSize (image);
}
// public static
kpCommandSize::SizeType kpCommandSize::ImageSize (const kpImage *image)
{
return kpCommandSize::PixmapSize (image);
}
// public static
kpCommandSize::SizeType kpCommandSize::SelectionSize (const kpAbstractSelection &sel)
{
return sel.size ();
}
// public static
kpCommandSize::SizeType kpCommandSize::SelectionSize (const kpAbstractSelection *sel)
{
return (sel ? sel->size () : 0);
}
// public static
kpCommandSize::SizeType kpCommandSize::StringSize (const QString &string)
{
#if DEBUG_KP_COMMAND_SIZE && 1
qCDebug(kpLogCommands) << "kpCommandSize::StringSize(" << string << ")"
<< " len=" << string.length ()
<< " sizeof(QChar)=" << sizeof (QChar);
#endif
return static_cast<SizeType> (static_cast<unsigned int> (string.length ()) * sizeof (QChar));
}
// public static
kpCommandSize::SizeType kpCommandSize::PolygonSize (const QPolygon &points)
{
#if DEBUG_KP_COMMAND_SIZE && 1
qCDebug(kpLogCommands) << "kpCommandSize::PolygonSize() points.size="
<< points.size ()
<< " sizeof(QPoint)=" << sizeof (QPoint);
#endif
return static_cast<SizeType> (static_cast<unsigned int> (points.size ()) * sizeof (QPoint));
}

View File

@ -1,87 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpCommandSize_H
#define kpCommandSize_H
#include "imagelib/kpImage.h"
class QImage;
class QPolygon;
class QString;
class kpAbstractSelection;
//
// Estimates the size of the object being pointed to, in bytes.
//
// This is used by the command history to trim stored commands, once a
// certain amount of memory is used by those commands.
//
class kpCommandSize
{
public:
// Force 64-bit arithmetic, instead of 32-bit, to prevent overflow
// when determining whether to clip the command history -- we might be
// adding a large number of large sizes. This will eventually help
// KolourPaint support more than 2GB of image data.
//
// For some reason, GCC doesn't warn of accidental casts to smaller types
// (e.g. 32-bit). An easy way to get around this is to change "SizeType"
// to be "double" temporarily and recompile - every time an implicit cast to
// "int" (32-bit) is made, we'll be warned.
//
// TODO: Exhaustively test that we're not accidentally doing intermediate
// calculations using 32-bit in some places (mainly inside
// implementations of kpCommand::size()).
typedef qlonglong SizeType;
static SizeType PixmapSize (const QImage &image);
static SizeType PixmapSize (const QImage *image);
static SizeType PixmapSize (int width, int height, int depth);
static SizeType QImageSize (const QImage &image);
static SizeType QImageSize (const QImage *image);
static SizeType QImageSize (int width, int height, int depth);
static SizeType ImageSize (const kpImage &image);
static SizeType ImageSize (const kpImage *image);
static SizeType SelectionSize (const kpAbstractSelection &sel);
static SizeType SelectionSize (const kpAbstractSelection *sel);
static SizeType StringSize (const QString &string);
static SizeType PolygonSize (const QPolygon &points);
};
#endif // kpCommandSize_H

View File

@ -1,133 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_COMMAND_HISTORY 0
#include "commands/kpMacroCommand.h"
#include "views/manager/kpViewManager.h"
#include <climits>
#include <QtAlgorithms>
//---------------------------------------------------------------------
kpMacroCommand::kpMacroCommand (const QString &name, kpCommandEnvironment *environ)
: kpNamedCommand (name, environ)
{
}
//---------------------------------------------------------------------
kpMacroCommand::~kpMacroCommand ()
{
qDeleteAll(m_commandList);
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
kpCommandSize::SizeType kpMacroCommand::size () const
{
#if DEBUG_KP_COMMAND_HISTORY && 0
qCDebug(kpLogCommands) << "kpMacroCommand::size()";
#endif
SizeType s = 0;
#if DEBUG_KP_COMMAND_HISTORY && 0
qCDebug(kpLogCommands) << "\tcalculating:";
#endif
foreach (kpCommand *cmd, m_commandList)
{
#if DEBUG_KP_COMMAND_HISTORY && 0
qCDebug(kpLogCommands) << "\t\tcurrentSize=" << s << " + "
<< cmd->name () << ".size=" << cmd->size ();
#endif
s += cmd->size ();
}
#if DEBUG_KP_COMMAND_HISTORY && 0
qCDebug(kpLogCommands) << "\treturning " << s;
#endif
return s;
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpMacroCommand::execute ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpMacroCommand::execute()";
#endif
viewManager()->setQueueUpdates();
foreach (kpCommand *command, m_commandList)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\texecuting " << command->name();
#endif
command->execute();
}
viewManager()->restoreQueueUpdates();
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpMacroCommand::unexecute ()
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "kpMacroCommand::unexecute()";
#endif
viewManager()->setQueueUpdates();
for (int i = m_commandList.count() - 1; i >= 0; i--)
{
#if DEBUG_KP_COMMAND_HISTORY
qCDebug(kpLogCommands) << "\tunexecuting " << m_commandList[i]->name();
#endif
m_commandList[i]->unexecute();
}
viewManager()->restoreQueueUpdates();
}
//---------------------------------------------------------------------
// public
void kpMacroCommand::addCommand(kpCommand *command)
{
m_commandList.append(command);
}
//---------------------------------------------------------------------

View File

@ -1,66 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpMacroCommand_H
#define kpMacroCommand_H
#include "commands/kpNamedCommand.h"
#include <QList>
class kpMacroCommand : public kpNamedCommand
{
public:
kpMacroCommand (const QString &name, kpCommandEnvironment *environ);
~kpMacroCommand () override;
//
// kpCommand Interface
//
SizeType size () const override;
void execute () override;
void unexecute () override;
//
// Interface
//
void addCommand (kpCommand *command);
protected:
QList <kpCommand *> m_commandList;
};
#endif // kpMacroCommand_H

View File

@ -1,45 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "commands/kpNamedCommand.h"
//---------------------------------------------------------------------
kpNamedCommand::kpNamedCommand (const QString &name, kpCommandEnvironment *environ)
: kpCommand (environ),
m_name (name)
{
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
QString kpNamedCommand::name () const
{
return m_name;
}
//---------------------------------------------------------------------

View File

@ -1,50 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpNamedCommand_H
#define kpNamedCommand_H
#include "commands/kpCommand.h"
#include <QString>
class kpNamedCommand : public kpCommand
{
public:
kpNamedCommand (const QString &name, kpCommandEnvironment *environ);
QString name () const override;
protected:
QString m_name;
};
#endif // kpNamedCommand_H

View File

@ -1,140 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_FLOW_COMMAND 0
#include "kpToolFlowCommand.h"
#include "document/kpDocument.h"
#include "imagelib/kpImage.h"
#include "pixmapfx/kpPixmapFX.h"
#include "tools/kpTool.h"
#include "views/manager/kpViewManager.h"
#include <QRect>
struct kpToolFlowCommandPrivate
{
kpImage image;
QRect boundingRect;
};
kpToolFlowCommand::kpToolFlowCommand (const QString &name, kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
d (new kpToolFlowCommandPrivate ())
{
d->image = document ()->image ();
}
kpToolFlowCommand::~kpToolFlowCommand ()
{
delete d;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolFlowCommand::size () const
{
return ImageSize (d->image);
}
// public virtual [base kpCommand]
void kpToolFlowCommand::execute ()
{
swapOldAndNew ();
}
// public virtual [base kpCommand]
void kpToolFlowCommand::unexecute ()
{
swapOldAndNew ();
}
// private
void kpToolFlowCommand::swapOldAndNew ()
{
if (d->boundingRect.isValid ())
{
const kpImage oldImage = document ()->getImageAt (d->boundingRect);
document ()->setImageAt (d->image, d->boundingRect.topLeft ());
d->image = oldImage;
}
}
// public
void kpToolFlowCommand::updateBoundingRect (const QPoint &point)
{
updateBoundingRect (QRect (point, point));
}
// public
void kpToolFlowCommand::updateBoundingRect (const QRect &rect)
{
#if DEBUG_KP_TOOL_FLOW_COMMAND & 0
qCDebug(kpLogCommands) << "kpToolFlowCommand::updateBoundingRect() existing="
<< d->boundingRect
<< " plus="
<< rect;
#endif
d->boundingRect = d->boundingRect.united (rect);
#if DEBUG_KP_TOOL_FLOW_COMMAND & 0
qCDebug(kpLogCommands) << "\tresult=" << d->boundingRect;
#endif
}
// public
void kpToolFlowCommand::finalize ()
{
if (d->boundingRect.isValid ())
{
// Store only the needed part of doc image.
d->image = kpTool::neededPixmap (d->image, d->boundingRect);
}
else
{
d->image = kpImage ();
}
}
// public
void kpToolFlowCommand::cancel ()
{
if (d->boundingRect.isValid ())
{
viewManager ()->setFastUpdates ();
document ()->setImageAt (d->image, d->boundingRect.topLeft ());
viewManager ()->restoreFastUpdates ();
}
}

View File

@ -1,64 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_FLOW_COMMAND_H
#define KP_TOOL_FLOW_COMMAND_H
#include "commands/kpNamedCommand.h"
class QPoint;
class QRect;
class kpToolFlowCommand : public kpNamedCommand
{
public:
kpToolFlowCommand (const QString &name, kpCommandEnvironment *environ);
~kpToolFlowCommand () override;
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
// interface for kpToolFlowBase
void updateBoundingRect (const QPoint &point);
void updateBoundingRect (const QRect &rect);
void finalize ();
void cancel ();
private:
void swapOldAndNew ();
struct kpToolFlowCommandPrivate * const d;
};
#endif // KP_TOOL_FLOW_COMMAND_H

View File

@ -1,81 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_COLOR_PICKER 0
#include "kpToolColorPickerCommand.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include <KLocalizedString>
kpToolColorPickerCommand::kpToolColorPickerCommand (
int mouseButton,
const kpColor &newColor,
const kpColor &oldColor,
kpCommandEnvironment *environ)
: kpCommand (environ),
m_mouseButton (mouseButton),
m_newColor (newColor),
m_oldColor (oldColor)
{
}
kpToolColorPickerCommand::~kpToolColorPickerCommand () = default;
// public virtual [base kpCommand]
QString kpToolColorPickerCommand::name () const
{
return i18n ("Color Picker");
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolColorPickerCommand::size () const
{
return 0;
}
// public virtual [base kpCommand]
void kpToolColorPickerCommand::execute ()
{
environ ()->setColor (m_mouseButton, m_newColor);
}
// public virtual [base kpCommand]
void kpToolColorPickerCommand::unexecute ()
{
environ ()->setColor (m_mouseButton, m_oldColor);
}

View File

@ -1,59 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolColorPickerCommand_H
#define kpToolColorPickerCommand_H
#include "imagelib/kpColor.h"
#include "commands/kpCommand.h"
class kpToolColorPickerCommand : public kpCommand
{
public:
kpToolColorPickerCommand (int mouseButton,
const kpColor &newColor, const kpColor &oldColor,
kpCommandEnvironment *environ);
~kpToolColorPickerCommand () override;
QString name () const override;
SizeType size () const override;
void execute () override;
void unexecute () override;
private:
int m_mouseButton;
kpColor m_newColor;
kpColor m_oldColor;
};
#endif // kpToolColorPickerCommand_H

View File

@ -1,169 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_FLOOD_FILL 0
#include "kpToolFloodFillCommand.h"
#include "imagelib/kpColor.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "imagelib/kpImage.h"
#include "kpLogCategories.h"
#include <QApplication>
#include <KLocalizedString>
//---------------------------------------------------------------------
struct kpToolFloodFillCommandPrivate
{
kpImage oldImage;
bool fillEntireImage{false};
};
//---------------------------------------------------------------------
kpToolFloodFillCommand::kpToolFloodFillCommand (int x, int y,
const kpColor &color, int processedColorSimilarity,
kpCommandEnvironment *environ)
: kpCommand (environ),
kpFloodFill (document ()->imagePointer (), x, y, color, processedColorSimilarity),
d (new kpToolFloodFillCommandPrivate ())
{
d->fillEntireImage = false;
}
//---------------------------------------------------------------------
kpToolFloodFillCommand::~kpToolFloodFillCommand ()
{
delete d;
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
QString kpToolFloodFillCommand::name () const
{
return i18n ("Flood Fill");
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolFloodFillCommand::size () const
{
return kpFloodFill::size () + ImageSize (d->oldImage);
}
//---------------------------------------------------------------------
// public
void kpToolFloodFillCommand::setFillEntireImage (bool yes)
{
d->fillEntireImage = yes;
}
//---------------------------------------------------------------------
// protected virtual [base kpCommand]
void kpToolFloodFillCommand::execute ()
{
#if DEBUG_KP_TOOL_FLOOD_FILL && 1
qCDebug(kpLogCommands) << "kpToolFloodFillCommand::execute() fillEntireImage="
<< d->fillEntireImage;
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
if (d->fillEntireImage)
{
doc->fill (kpFloodFill::color ());
}
else
{
QRect rect = kpFloodFill::boundingRect ();
if (rect.isValid ())
{
QApplication::setOverrideCursor (Qt::WaitCursor);
{
d->oldImage = doc->getImageAt (rect);
kpFloodFill::fill ();
doc->slotContentsChanged (rect);
}
QApplication::restoreOverrideCursor ();
}
else
{
#if DEBUG_KP_TOOL_FLOOD_FILL && 1
qCDebug(kpLogCommands) << "\tinvalid boundingRect - must be NOP case";
#endif
}
}
}
//---------------------------------------------------------------------
// protected virtual [base kpCommand]
void kpToolFloodFillCommand::unexecute ()
{
#if DEBUG_KP_TOOL_FLOOD_FILL && 1
qCDebug(kpLogCommands) << "kpToolFloodFillCommand::unexecute() fillEntireImage="
<< d->fillEntireImage;
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
if (d->fillEntireImage)
{
doc->fill (kpFloodFill::colorToChange ());
}
else
{
QRect rect = kpFloodFill::boundingRect ();
if (rect.isValid ())
{
doc->setImageAt (d->oldImage, rect.topLeft ());
d->oldImage = kpImage ();
doc->slotContentsChanged (rect);
}
}
}
//---------------------------------------------------------------------

View File

@ -1,68 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolFloodFillCommand_H
#define kpToolFloodFillCommand_H
#include "commands/kpCommand.h"
#include "imagelib/kpFloodFill.h"
class kpColor;
class kpCommandEnvironment;
struct kpToolFloodFillCommandPrivate;
class kpToolFloodFillCommand : public kpCommand, public kpFloodFill
{
public:
kpToolFloodFillCommand (int x, int y,
const kpColor &color, int processedColorSimilarity,
kpCommandEnvironment *environ);
~kpToolFloodFillCommand () override;
QString name () const override;
kpCommandSize::SizeType size () const override;
// Optimization hack: filling a fresh, unmodified document does not require
// reading any pixels - just set the whole document to
// <color>.
void setFillEntireImage (bool yes = true);
void execute () override;
void unexecute () override;
private:
kpToolFloodFillCommandPrivate * const d;
};
#endif // kpToolFloodFillCommand_H

View File

@ -1,123 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_POLYGON 0
#include "kpToolPolygonalCommand.h"
#include "document/kpDocument.h"
#include "kpDefs.h"
#include "imagelib/kpImage.h"
struct kpToolPolygonalCommandPrivate
{
kpToolPolygonalBase::DrawShapeFunc drawShapeFunc{};
QPolygon points;
QRect boundingRect;
kpColor fcolor;
int penWidth{};
kpColor bcolor;
kpImage oldImage;
};
kpToolPolygonalCommand::kpToolPolygonalCommand (const QString &name,
kpToolPolygonalBase::DrawShapeFunc drawShapeFunc,
const QPolygon &points,
const QRect &boundingRect,
const kpColor &fcolor, int penWidth,
const kpColor &bcolor,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
d (new kpToolPolygonalCommandPrivate ())
{
d->drawShapeFunc = drawShapeFunc;
d->points = points;
d->boundingRect = boundingRect;
d->fcolor = fcolor;
d->penWidth = penWidth;
d->bcolor = bcolor;
}
kpToolPolygonalCommand::~kpToolPolygonalCommand ()
{
delete d;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolPolygonalCommand::size () const
{
return PolygonSize (d->points) +
ImageSize (d->oldImage);
}
// public virtual [base kpCommand]
void kpToolPolygonalCommand::execute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
// Store Undo info.
Q_ASSERT (d->oldImage.isNull ());
d->oldImage = doc->getImageAt (d->boundingRect);
// Invoke shape drawing function passed in ctor.
kpImage image = d->oldImage;
QPolygon pointsTranslated = d->points;
pointsTranslated.translate (-d->boundingRect.x (), -d->boundingRect.y ());
(*d->drawShapeFunc) (&image,
pointsTranslated,
d->fcolor, d->penWidth,
d->bcolor,
true/*final shape*/);
doc->setImageAt (image, d->boundingRect.topLeft ());
}
// public virtual [base kpCommand]
void kpToolPolygonalCommand::unexecute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
Q_ASSERT (!d->oldImage.isNull ());
doc->setImageAt (d->oldImage, d->boundingRect.topLeft ());
d->oldImage = kpImage ();
}

View File

@ -1,68 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolPolygonalCommand_H
#define kpToolPolygonalCommand_H
#include "commands/kpNamedCommand.h"
#include "tools/polygonal/kpToolPolygonalBase.h"
class QPolygon;
class QRect;
class kpColor;
// TODO: merge with kpToolRectangularCommand due to code duplication.
class kpToolPolygonalCommand : public kpNamedCommand
{
public:
// <boundingRect> = the bounding rectangle for <points> including <penWidth>.
kpToolPolygonalCommand (const QString &name,
kpToolPolygonalBase::DrawShapeFunc drawShapeFunc,
const QPolygon &points,
const QRect &boundingRect,
const kpColor &fcolor, int penWidth,
const kpColor &bcolor,
kpCommandEnvironment *environ);
~kpToolPolygonalCommand () override;
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
private:
struct kpToolPolygonalCommandPrivate * const d;
kpToolPolygonalCommand &operator= (const kpToolPolygonalCommand &) const;
};
#endif // kpToolPolygonalCommand_H

View File

@ -1,126 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_RECTANGULAR_COMMAND 0
#include "kpToolRectangularCommand.h"
#include "imagelib/kpColor.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "imagelib/kpPainter.h"
#include "pixmapfx/kpPixmapFX.h"
#include "layers/tempImage/kpTempImage.h"
#include "widgets/toolbars/kpToolToolBar.h"
#include "widgets/toolbars/options/kpToolWidgetFillStyle.h"
#include "widgets/toolbars/options/kpToolWidgetLineWidth.h"
#include "views/kpView.h"
#include "views/manager/kpViewManager.h"
#include "kpLogCategories.h"
struct kpToolRectangularCommandPrivate
{
kpToolRectangularBase::DrawShapeFunc drawShapeFunc{};
QRect rect;
kpColor fcolor;
int penWidth{};
kpColor bcolor;
kpImage oldImage;
};
kpToolRectangularCommand::kpToolRectangularCommand (const QString &name,
kpToolRectangularBase::DrawShapeFunc drawShapeFunc,
const QRect &rect,
const kpColor &fcolor, int penWidth,
const kpColor &bcolor,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
d (new kpToolRectangularCommandPrivate ())
{
d->drawShapeFunc = drawShapeFunc;
d->rect = rect;
d->fcolor = fcolor;
d->penWidth = penWidth;
d->bcolor = bcolor;
}
kpToolRectangularCommand::~kpToolRectangularCommand ()
{
delete d;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolRectangularCommand::size () const
{
return ImageSize (d->oldImage);
}
// public virtual [base kpCommand]
void kpToolRectangularCommand::execute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
// Store Undo info.
// OPT: For a pure rectangle, can do better if there is no bcolor, by only
// saving 4 pixmaps corresponding to the pixels dirtied by the 4 edges.
Q_ASSERT (d->oldImage.isNull ());
d->oldImage = doc->getImageAt (d->rect);
// Invoke shape drawing function passed in ctor.
kpImage image = d->oldImage;
(*d->drawShapeFunc) (&image,
0, 0, d->rect.width (), d->rect.height (),
d->fcolor, d->penWidth,
d->bcolor);
doc->setImageAt (image, d->rect.topLeft ());
}
// public virtual [base kpCommand]
void kpToolRectangularCommand::unexecute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
Q_ASSERT (!d->oldImage.isNull ());
doc->setImageAt (d->oldImage, d->rect.topLeft ());
d->oldImage = kpImage ();
}

View File

@ -1,62 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_RECTANGULAR_COMMAND_H
#define KP_TOOL_RECTANGULAR_COMMAND_H
#include "commands/kpNamedCommand.h"
#include "tools/rectangular/kpToolRectangularBase.h"
class kpColor;
class kpToolRectangularCommand : public kpNamedCommand
{
public:
kpToolRectangularCommand (const QString &name,
kpToolRectangularBase::DrawShapeFunc drawShapeFunc,
const QRect &rect,
const kpColor &fcolor, int penWidth,
const kpColor &bcolor,
kpCommandEnvironment *environ);
~kpToolRectangularCommand () override;
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
private:
struct kpToolRectangularCommandPrivate * const d;
kpToolRectangularCommand &operator= (const kpToolRectangularCommand &) const;
};
#endif // KP_TOOL_RECTANGULAR_COMMAND_H

View File

@ -1,69 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpAbstractSelectionContentCommand.h"
#include "layers/selections/kpAbstractSelection.h"
struct kpAbstractSelectionContentCommandPrivate
{
const kpAbstractSelection *orgSelBorder;
};
kpAbstractSelectionContentCommand::kpAbstractSelectionContentCommand (
const kpAbstractSelection &originalSelBorder,
const QString &name,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
d (new kpAbstractSelectionContentCommandPrivate ())
{
Q_ASSERT (!originalSelBorder.hasContent ());
d->orgSelBorder = originalSelBorder.clone ();
}
kpAbstractSelectionContentCommand::~kpAbstractSelectionContentCommand ()
{
delete d->orgSelBorder;
delete d;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpAbstractSelectionContentCommand::size () const
{
return d->orgSelBorder->size ();
}
// public
const kpAbstractSelection *kpAbstractSelectionContentCommand::originalSelection () const
{
return d->orgSelBorder;
}

View File

@ -1,71 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpAbstractSelectionContentCommand_H
#define kpAbstractSelectionContentCommand_H
#include "commands/kpNamedCommand.h"
// Converts a selection border to a selection with content.
// This must be executed before any manipulations can be made
// to a selection.
//
// Its construction and execution always follows that of a
// kpToolSelectionCreateCommand, which must be given a selection with
// no content.
//
// It's always the first subcommand of a kpMacroCommand, with the following
// subcommands being whatever the selection operation is (e.g. movement,
// resizing).
class kpAbstractSelectionContentCommand : public kpNamedCommand
{
// LOREFACTOR: Pull up more methods into here? Looking at the code, not
// much could be dragged up without unnecessarily complicated
// abstraction.
public:
// <originalSelBorder> must be a border i.e. have no content.
kpAbstractSelectionContentCommand (
const kpAbstractSelection &originalSelBorder,
const QString &name,
kpCommandEnvironment *environ);
~kpAbstractSelectionContentCommand () override;
kpCommandSize::SizeType size () const override;
// Note: Returned pointer is only valid for as long as this command is
// alive.
const kpAbstractSelection *originalSelection () const;
private:
struct kpAbstractSelectionContentCommandPrivate * const d;
};
#endif // kpAbstractSelectionContentCommand_H

View File

@ -1,96 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SELECTION 0
#include "kpToolImageSelectionTransparencyCommand.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "generic/kpSetOverrideCursorSaver.h"
#include "kpLogCategories.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include <QCursor>
//--------------------------------------------------------------------------------
kpToolImageSelectionTransparencyCommand::kpToolImageSelectionTransparencyCommand (
const QString &name,
const kpImageSelectionTransparency &st,
const kpImageSelectionTransparency &oldST,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_st (st),
m_oldST (oldST)
{
}
kpToolImageSelectionTransparencyCommand::~kpToolImageSelectionTransparencyCommand () = default;
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolImageSelectionTransparencyCommand::size () const
{
return 0;
}
// public virtual [base kpCommand]
void kpToolImageSelectionTransparencyCommand::execute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolImageSelectionTransparencyCommand::execute()";
#endif
kpSetOverrideCursorSaver cursorSaver (Qt::WaitCursor);
environ ()->setImageSelectionTransparency (m_st, true/*force colour change*/);
if (imageSelection ()) {
imageSelection ()->setTransparency (m_st);
}
}
// public virtual [base kpCommand]
void kpToolImageSelectionTransparencyCommand::unexecute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolImageSelectionTransparencyCommand::unexecute()";
#endif
kpSetOverrideCursorSaver cursorSaver (Qt::WaitCursor);
environ ()->setImageSelectionTransparency (m_oldST, true/*force colour change*/);
if (imageSelection ()) {
imageSelection ()->setTransparency (m_oldST);
}
}

View File

@ -1,56 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolImageSelectionTransparencyCommand_H
#define kpToolImageSelectionTransparencyCommand_H
#include "commands/kpNamedCommand.h"
#include "layers/selections/image/kpImageSelectionTransparency.h"
class kpToolImageSelectionTransparencyCommand : public kpNamedCommand
{
public:
kpToolImageSelectionTransparencyCommand (const QString &name,
const kpImageSelectionTransparency &st,
const kpImageSelectionTransparency &oldST,
kpCommandEnvironment *environ);
~kpToolImageSelectionTransparencyCommand () override;
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
private:
kpImageSelectionTransparency m_st, m_oldST;
};
#endif // kpToolImageSelectionTransparencyCommand_H

View File

@ -1,152 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SELECTION 0
#include "commands/tools/selection/kpToolSelectionCreateCommand.h"
#include "layers/selections/kpAbstractSelection.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "commands/kpCommandHistory.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "layers/selections/text/kpTextSelection.h"
#include "widgets/toolbars/options/kpToolWidgetOpaqueOrTransparent.h"
#include "views/kpView.h"
#include "views/manager/kpViewManager.h"
#include "kpLogCategories.h"
kpToolSelectionCreateCommand::kpToolSelectionCreateCommand (const QString &name,
const kpAbstractSelection &fromSelection,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_fromSelection (nullptr),
m_textRow (0), m_textCol (0)
{
setFromSelection (fromSelection);
}
kpToolSelectionCreateCommand::~kpToolSelectionCreateCommand ()
{
delete m_fromSelection;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolSelectionCreateCommand::size () const
{
return SelectionSize (m_fromSelection);
}
// public
const kpAbstractSelection *kpToolSelectionCreateCommand::fromSelection () const
{
return m_fromSelection;
}
// public
void kpToolSelectionCreateCommand::setFromSelection (const kpAbstractSelection &fromSelection)
{
delete m_fromSelection;
m_fromSelection = fromSelection.clone ();
}
// public virtual [base kpCommand]
void kpToolSelectionCreateCommand::execute ()
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "kpToolSelectionCreateCommand::execute()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
if (m_fromSelection)
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "\tusing fromSelection";
qCDebug(kpLogCommands) << "\t\thave sel=" << doc->selection () << endl;
#endif
kpAbstractImageSelection *imageSel =
dynamic_cast <kpAbstractImageSelection *> (m_fromSelection);
kpTextSelection *textSel =
dynamic_cast <kpTextSelection *> (m_fromSelection);
if (imageSel)
{
if (imageSel->transparency () != environ ()->imageSelectionTransparency ()) {
environ ()->setImageSelectionTransparency (imageSel->transparency ());
}
}
else if (textSel)
{
if (textSel->textStyle () != environ ()->textStyle ()) {
environ ()->setTextStyle (textSel->textStyle ());
}
}
else {
Q_ASSERT (!"Unknown selection type");
}
viewManager ()->setTextCursorPosition (m_textRow, m_textCol);
doc->setSelection (*m_fromSelection);
environ ()->somethingBelowTheCursorChanged ();
}
}
// public virtual [base kpCommand]
void kpToolSelectionCreateCommand::unexecute ()
{
kpDocument *doc = document ();
Q_ASSERT (doc);
if (!doc->selection ())
{
// Was just a border that got deselected?
if (m_fromSelection && !m_fromSelection->hasContent ()) {
return;
}
Q_ASSERT (!"kpToolSelectionCreateCommand::unexecute() without sel region");
return;
}
m_textRow = viewManager ()->textCursorRow ();
m_textCol = viewManager ()->textCursorCol ();
doc->selectionDelete ();
environ ()->somethingBelowTheCursorChanged ();
}

View File

@ -1,62 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolSelectionCreateCommand_H
#define kpToolSelectionCreateCommand_H
#include "commands/kpNamedCommand.h"
class kpAbstractSelection;
class kpToolSelectionCreateCommand : public kpNamedCommand
{
public:
// (if fromSelection doesn't have a pixmap, it will only recreate the region)
kpToolSelectionCreateCommand (const QString &name, const kpAbstractSelection &fromSelection,
kpCommandEnvironment *environ);
~kpToolSelectionCreateCommand () override;
kpCommandSize::SizeType size () const override;
const kpAbstractSelection *fromSelection () const;
void setFromSelection (const kpAbstractSelection &fromSelection);
void execute () override;
void unexecute () override;
private:
kpAbstractSelection *m_fromSelection;
int m_textRow, m_textCol;
};
#endif // kpToolSelectionCreateCommand_H

View File

@ -1,176 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SELECTION 0
#include "kpToolSelectionDestroyCommand.h"
#include "kpLogCategories.h"
#include "layers/selections/kpAbstractSelection.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "layers/selections/text/kpTextSelection.h"
#include "views/manager/kpViewManager.h"
//---------------------------------------------------------------------
kpToolSelectionDestroyCommand::kpToolSelectionDestroyCommand (const QString &name,
bool pushOntoDocument,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_pushOntoDocument (pushOntoDocument),
m_oldSelectionPtr (nullptr),
m_textRow(0), m_textCol(0)
{
}
//---------------------------------------------------------------------
kpToolSelectionDestroyCommand::~kpToolSelectionDestroyCommand ()
{
delete m_oldSelectionPtr;
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolSelectionDestroyCommand::size () const
{
return ImageSize (m_oldDocImage) +
SelectionSize (m_oldSelectionPtr);
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpToolSelectionDestroyCommand::execute ()
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "kpToolSelectionDestroyCommand::execute () CALLED";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
Q_ASSERT (doc->selection ());
m_textRow = viewManager ()->textCursorRow ();
m_textCol = viewManager ()->textCursorCol ();
Q_ASSERT (!m_oldSelectionPtr);
m_oldSelectionPtr = doc->selection ()->clone ();
if (m_pushOntoDocument)
{
m_oldDocImage = doc->getImageAt (doc->selection ()->boundingRect ());
doc->selectionPushOntoDocument ();
}
else {
doc->selectionDelete ();
}
environ ()->somethingBelowTheCursorChanged ();
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpToolSelectionDestroyCommand::unexecute ()
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "kpToolSelectionDestroyCommand::unexecute () CALLED";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
if (doc->selection ())
{
// not error because it's possible that the user dragged out a new
// region (without pulling image), and then CTRL+Z
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "kpToolSelectionDestroyCommand::unexecute() already has sel region";
#endif
if (doc->selection ()->hasContent ())
{
Q_ASSERT (!"kpToolSelectionDestroyCommand::unexecute() already has sel content");
return;
}
}
Q_ASSERT (m_oldSelectionPtr);
if (m_pushOntoDocument)
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "\tunpush oldDocImage onto doc first";
#endif
doc->setImageAt (m_oldDocImage, m_oldSelectionPtr->topLeft ());
}
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "\tsetting selection to: rect=" << m_oldSelectionPtr->boundingRect ()
<< " hasContent=" << m_oldSelectionPtr->hasContent ();
#endif
kpAbstractImageSelection *imageSel =
dynamic_cast <kpAbstractImageSelection *> (m_oldSelectionPtr);
kpTextSelection *textSel =
dynamic_cast <kpTextSelection *> (m_oldSelectionPtr);
if (imageSel)
{
if (imageSel->transparency () != environ ()->imageSelectionTransparency ()) {
environ ()->setImageSelectionTransparency (imageSel->transparency ());
}
if (dynamic_cast <kpTextSelection *> (doc->selection())) {
doc->selectionPushOntoDocument();
}
}
else if (textSel)
{
if (textSel->textStyle () != environ ()->textStyle ()) {
environ ()->setTextStyle (textSel->textStyle ());
}
if (dynamic_cast <kpAbstractImageSelection *> (doc->selection())) {
doc->selectionPushOntoDocument();
}
}
else {
Q_ASSERT (!"Unknown selection type");
}
viewManager ()->setTextCursorPosition (m_textRow, m_textCol);
doc->setSelection (*m_oldSelectionPtr);
environ ()->somethingBelowTheCursorChanged ();
delete m_oldSelectionPtr;
m_oldSelectionPtr = nullptr;
}

View File

@ -1,61 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolSelectionDestroyCommand_H
#define kpToolSelectionDestroyCommand_H
#include "imagelib/kpImage.h"
#include "commands/kpNamedCommand.h"
class kpAbstractSelection;
class kpToolSelectionDestroyCommand : public kpNamedCommand
{
public:
kpToolSelectionDestroyCommand (const QString &name, bool pushOntoDocument,
kpCommandEnvironment *environ);
~kpToolSelectionDestroyCommand () override;
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
private:
bool m_pushOntoDocument;
kpImage m_oldDocImage;
kpAbstractSelection *m_oldSelectionPtr;
int m_textRow, m_textCol;
};
#endif // kpToolSelectionDestroyCommand_H

View File

@ -1,219 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SELECTION 0
#include "kpToolSelectionMoveCommand.h"
#include "layers/selections/kpAbstractSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "tools/kpTool.h"
#include "widgets/toolbars/options/kpToolWidgetOpaqueOrTransparent.h"
#include "views/manager/kpViewManager.h"
#include "kpLogCategories.h"
//--------------------------------------------------------------------------------
kpToolSelectionMoveCommand::kpToolSelectionMoveCommand (const QString &name,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ)
{
kpDocument *doc = document ();
Q_ASSERT (doc);
Q_ASSERT (doc->selection ());
m_startPoint = m_endPoint = doc->selection ()->topLeft ();
}
kpToolSelectionMoveCommand::~kpToolSelectionMoveCommand () = default;
// public
kpAbstractSelection *kpToolSelectionMoveCommand::originalSelectionClone () const
{
kpDocument *doc = document ();
Q_ASSERT (doc);
Q_ASSERT (doc->selection ());
kpAbstractSelection *selection = doc->selection ()->clone ();
selection->moveTo (m_startPoint);
return selection;
}
// public virtual [base kpComand]
kpCommandSize::SizeType kpToolSelectionMoveCommand::size () const
{
return ImageSize (m_oldDocumentImage) +
PolygonSize (m_copyOntoDocumentPoints);
}
// public virtual [base kpCommand]
void kpToolSelectionMoveCommand::execute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolSelectionMoveCommand::execute()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
kpAbstractSelection *sel = doc->selection ();
// Must have content before it can be moved.
Q_ASSERT (sel && sel->hasContent ());
kpViewManager *vm = viewManager ();
Q_ASSERT (vm);
vm->setQueueUpdates ();
{
for (const auto &p : m_copyOntoDocumentPoints)
{
sel->moveTo (p);
doc->selectionCopyOntoDocument ();
}
sel->moveTo (m_endPoint);
environ ()->somethingBelowTheCursorChanged ();
}
vm->restoreQueueUpdates ();
}
// public virtual [base kpCommand]
void kpToolSelectionMoveCommand::unexecute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolSelectionMoveCommand::unexecute()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
kpAbstractSelection *sel = doc->selection ();
// Must have content before it can be un-moved.
Q_ASSERT (sel && sel->hasContent ());
kpViewManager *vm = viewManager ();
Q_ASSERT (vm);
vm->setQueueUpdates ();
if (!m_oldDocumentImage.isNull ()) {
doc->setImageAt (m_oldDocumentImage, m_documentBoundingRect.topLeft ());
}
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "\tmove to startPoint=" << m_startPoint;
#endif
sel->moveTo (m_startPoint);
environ ()->somethingBelowTheCursorChanged ();
vm->restoreQueueUpdates ();
}
// public
void kpToolSelectionMoveCommand::moveTo (const QPoint &point, bool moveLater)
{
#if DEBUG_KP_TOOL_SELECTION && 0
qCDebug(kpLogCommands) << "kpToolSelectionMoveCommand::moveTo" << point
<< " moveLater=" << moveLater;
#endif
if (!moveLater)
{
kpDocument *doc = document ();
Q_ASSERT (doc);
kpAbstractSelection *sel = doc->selection ();
// Must have content before it can be moved.
Q_ASSERT (sel && sel->hasContent ());
if (point == sel->topLeft ()) {
return;
}
sel->moveTo (point);
}
m_endPoint = point;
}
// public
void kpToolSelectionMoveCommand::moveTo (int x, int y, bool moveLater)
{
moveTo (QPoint (x, y), moveLater);
}
// public
void kpToolSelectionMoveCommand::copyOntoDocument ()
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "kpToolSelectionMoveCommand::copyOntoDocument()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
kpAbstractSelection *sel = doc->selection ();
// Must have content before we allow it be stamped onto the document,
// to be consistent with the requirement on other selection operations.
Q_ASSERT (sel && sel->hasContent ());
if (m_oldDocumentImage.isNull ()) {
m_oldDocumentImage = doc->image ();
}
QRect selBoundingRect = sel->boundingRect ();
m_documentBoundingRect = m_documentBoundingRect.united (selBoundingRect);
doc->selectionCopyOntoDocument ();
m_copyOntoDocumentPoints.putPoints (m_copyOntoDocumentPoints.count (),
1,
selBoundingRect.x (),
selBoundingRect.y ());
}
// public
void kpToolSelectionMoveCommand::finalize ()
{
if (!m_oldDocumentImage.isNull () && !m_documentBoundingRect.isNull ())
{
m_oldDocumentImage = kpTool::neededPixmap (m_oldDocumentImage,
m_documentBoundingRect);
}
}

View File

@ -1,74 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolSelectionMoveCommand_H
#define kpToolSelectionMoveCommand_H
#include <QPoint>
#include <QPolygon>
#include <QRect>
#include "imagelib/kpImage.h"
#include "commands/kpNamedCommand.h"
class kpAbstractSelection;
class kpToolSelectionMoveCommand : public kpNamedCommand
{
public:
kpToolSelectionMoveCommand (const QString &name, kpCommandEnvironment *environ);
~kpToolSelectionMoveCommand () override;
kpAbstractSelection *originalSelectionClone () const;
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
void moveTo (const QPoint &point, bool moveLater = false);
void moveTo (int x, int y, bool moveLater = false);
void copyOntoDocument ();
void finalize ();
private:
QPoint m_startPoint, m_endPoint;
kpImage m_oldDocumentImage;
// area of document affected (not the bounding rect of the sel)
QRect m_documentBoundingRect;
QPolygon m_copyOntoDocumentPoints;
};
#endif // kpToolSelectionMoveCommand_H

View File

@ -1,140 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SELECTION 0
#include "kpToolSelectionPullFromDocumentCommand.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "document/kpDocument.h"
#include "views/manager/kpViewManager.h"
#include "kpLogCategories.h"
kpToolSelectionPullFromDocumentCommand::kpToolSelectionPullFromDocumentCommand (
const kpAbstractImageSelection &originalSelBorder,
const kpColor &backgroundColor,
const QString &name,
kpCommandEnvironment *environ)
: kpAbstractSelectionContentCommand (originalSelBorder, name, environ),
m_backgroundColor (backgroundColor)
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolSelectionPullFromDocumentCommand::<ctor>() environ="
<< environ;
#endif
}
kpToolSelectionPullFromDocumentCommand::~kpToolSelectionPullFromDocumentCommand () = default;
// public virtual [base kpCommand]
void kpToolSelectionPullFromDocumentCommand::execute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolSelectionPullFromDocumentCommand::execute()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
kpViewManager *vm = viewManager ();
Q_ASSERT (vm);
vm->setQueueUpdates ();
{
//
// Recreate border
//
// The previously executed command is required to have been a
// kpToolSelectionCreateCommand, which must have been given an image
// selection with no content.
//
// However, there is a tricky case. Suppose we are called for the first
// time, where the above precondition holds. We would add content
// to the selection as expected. But the user then undoes (CTRL+Z) the
// operation, calling unexecute(). There is now no content again.
// Since selection is only a border, the user can freely deselect it
// and/or select another region without changing the command history
// or document modified state. Therefore, if they now call us again
// by redoing (CTRL+Shift+Z), there is potentially no selection at all
// or it is at an arbitrary location.
//
// This assertion covers all 3 possibilities:
//
// 1. First call: image selection with no content
// 2. Later calls:
// a) no image selection (due to deselection)
// b) image selection with no content, at an arbitrary location
Q_ASSERT (!imageSelection () || !imageSelection ()->hasContent ());
const auto *originalImageSel = dynamic_cast <const kpAbstractImageSelection *>
(originalSelection ());
if (originalImageSel->transparency () !=
environ ()->imageSelectionTransparency ())
{
environ ()->setImageSelectionTransparency (originalImageSel->transparency ());
}
doc->setSelection (*originalSelection ());
//
// Add content
//
doc->imageSelectionPullFromDocument (m_backgroundColor);
}
vm->restoreQueueUpdates ();
}
// public virtual [base kpCommand]
void kpToolSelectionPullFromDocumentCommand::unexecute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolSelectionPullFromDocumentCommand::unexecute()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
// Must have selection image content.
Q_ASSERT (doc->imageSelection () && doc->imageSelection ()->hasContent ());
// We can have faith that this is the state of the selection after
// execute(), rather than after the user tried to throw us off by
// simply selecting another region as to do that, a destroy command
// must have been used.
doc->selectionCopyOntoDocument (false/*use opaque pixmap*/);
doc->imageSelection ()->deleteContent ();
}

View File

@ -1,59 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolSelectionPullFromDocumentCommand_H
#define kpToolSelectionPullFromDocumentCommand_H
#include "kpAbstractSelectionContentCommand.h"
#include "imagelib/kpColor.h"
class kpAbstractImageSelection;
class kpToolSelectionPullFromDocumentCommand :
public kpAbstractSelectionContentCommand
{
public:
kpToolSelectionPullFromDocumentCommand (
const kpAbstractImageSelection &originalSelBorder,
const kpColor &backgroundColor,
const QString &name,
kpCommandEnvironment *environ);
~kpToolSelectionPullFromDocumentCommand () override;
void execute () override;
void unexecute () override;
private:
kpColor m_backgroundColor;
};
#endif // kpToolSelectionPullFromDocumentCommand_H

View File

@ -1,256 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SELECTION 0
#include "kpToolSelectionResizeScaleCommand.h"
#include "layers/selections/kpAbstractSelection.h"
#include "layers/selections/image/kpAbstractImageSelection.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "kpDefs.h"
#include "document/kpDocument.h"
#include "layers/selections/image/kpRectangularImageSelection.h"
#include "layers/selections/text/kpTextSelection.h"
#include "kpLogCategories.h"
#include <QApplication>
#include <QTimer>
#include <KLocalizedString>
//--------------------------------------------------------------------------------
kpToolSelectionResizeScaleCommand::kpToolSelectionResizeScaleCommand (
kpCommandEnvironment *environ)
: kpNamedCommand (environ->textSelection () ?
i18n ("Text: Resize Box") :
i18n ("Selection: Smooth Scale"),
environ),
m_smoothScaleTimer (new QTimer (this))
{
m_originalSelectionPtr = selection ()->clone ();
m_newTopLeft = selection ()->topLeft ();
m_newWidth = selection ()->width ();
m_newHeight = selection ()->height ();
m_smoothScaleTimer->setSingleShot (true);
connect (m_smoothScaleTimer, &QTimer::timeout, this, [this]{resizeScaleAndMove(false);});
}
kpToolSelectionResizeScaleCommand::~kpToolSelectionResizeScaleCommand ()
{
delete m_originalSelectionPtr;
}
// public virtual
kpCommandSize::SizeType kpToolSelectionResizeScaleCommand::size () const
{
return SelectionSize (m_originalSelectionPtr);
}
// public
const kpAbstractSelection *kpToolSelectionResizeScaleCommand::originalSelection () const
{
return m_originalSelectionPtr;
}
// public
QPoint kpToolSelectionResizeScaleCommand::topLeft () const
{
return m_newTopLeft;
}
// public
void kpToolSelectionResizeScaleCommand::moveTo (const QPoint &point)
{
if (point == m_newTopLeft) {
return;
}
m_newTopLeft = point;
selection ()->moveTo (m_newTopLeft);
}
// public
int kpToolSelectionResizeScaleCommand::width () const
{
return m_newWidth;
}
// public
int kpToolSelectionResizeScaleCommand::height () const
{
return m_newHeight;
}
// public
void kpToolSelectionResizeScaleCommand::resize (int width, int height,
bool delayed)
{
if (width == m_newWidth && height == m_newHeight) {
return;
}
m_newWidth = width;
m_newHeight = height;
resizeScaleAndMove (delayed);
}
// public
void kpToolSelectionResizeScaleCommand::resizeAndMoveTo (int width, int height,
const QPoint &point,
bool delayed)
{
if (width == m_newWidth && height == m_newHeight &&
point == m_newTopLeft)
{
return;
}
m_newWidth = width;
m_newHeight = height;
m_newTopLeft = point;
resizeScaleAndMove (delayed);
}
// protected
void kpToolSelectionResizeScaleCommand::killSmoothScaleTimer ()
{
m_smoothScaleTimer->stop ();
}
// protected
void kpToolSelectionResizeScaleCommand::resizeScaleAndMove (bool delayed)
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "kpToolSelectionResizeScaleCommand::resizeScaleAndMove(delayed="
<< delayed << ")";
#endif
killSmoothScaleTimer ();
kpAbstractSelection *newSelPtr = nullptr;
if (textSelection ())
{
Q_ASSERT (dynamic_cast <kpTextSelection *> (m_originalSelectionPtr));
auto *orgTextSel = dynamic_cast <kpTextSelection *> (m_originalSelectionPtr);
newSelPtr = orgTextSel->resized (m_newWidth, m_newHeight);
}
else
{
Q_ASSERT (dynamic_cast <kpAbstractImageSelection *> (m_originalSelectionPtr));
auto *imageSel = dynamic_cast <kpAbstractImageSelection *> (m_originalSelectionPtr);
newSelPtr = new kpRectangularImageSelection (
QRect (imageSel->x (),
imageSel->y (),
m_newWidth,
m_newHeight),
kpPixmapFX::scale (imageSel->baseImage (),
m_newWidth, m_newHeight,
!delayed/*if not delayed, smooth*/),
imageSel->transparency ());
if (delayed)
{
// Call self (once) with delayed==false in 200ms
m_smoothScaleTimer->start (200/*ms*/);
}
}
Q_ASSERT (newSelPtr);
newSelPtr->moveTo (m_newTopLeft);
document ()->setSelection (*newSelPtr);
delete newSelPtr;
}
// public
void kpToolSelectionResizeScaleCommand::finalize ()
{
#if DEBUG_KP_TOOL_SELECTION
qCDebug(kpLogCommands) << "kpToolSelectionResizeScaleCommand::finalize()"
<< " smoothScaleTimer->isActive="
<< m_smoothScaleTimer->isActive ();
#endif
// Make sure the selection contains the final image and the timer won't
// fire afterwards.
if (m_smoothScaleTimer->isActive ())
{
resizeScaleAndMove ();
Q_ASSERT (!m_smoothScaleTimer->isActive ());
}
}
// public virtual [base kpToolResizeScaleCommand]
void kpToolSelectionResizeScaleCommand::execute ()
{
QApplication::setOverrideCursor (Qt::WaitCursor);
killSmoothScaleTimer ();
resizeScaleAndMove ();
environ ()->somethingBelowTheCursorChanged ();
QApplication::restoreOverrideCursor ();
}
// public virtual [base kpToolResizeScaleCommand]
void kpToolSelectionResizeScaleCommand::unexecute ()
{
QApplication::setOverrideCursor (Qt::WaitCursor);
killSmoothScaleTimer ();
document ()->setSelection (*m_originalSelectionPtr);
environ ()->somethingBelowTheCursorChanged ();
QApplication::restoreOverrideCursor ();
}

View File

@ -1,104 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolSelectionResizeScaleCommand_H
#define kpToolSelectionResizeScaleCommand_H
#include <QObject>
#include <QPoint>
#include "commands/kpNamedCommand.h"
class QTimer;
class kpAbstractSelection;
// You could subclass kpToolResizeScaleCommand and/or
// kpToolSelectionMoveCommand instead if want a disaster.
// This is different to kpToolResizeScaleCommand in that:
//
// 1. This only works for selections.
// 2. This is designed for the size and position to change several times
// before execute().
//
// REFACTOR: Later: I take that all back. We should merge with
// kpToolResizeScaleCommand to reduce code duplication.
class kpToolSelectionResizeScaleCommand : public QObject,
public kpNamedCommand
{
Q_OBJECT
public:
kpToolSelectionResizeScaleCommand (kpCommandEnvironment *environ);
~kpToolSelectionResizeScaleCommand () override;
kpCommandSize::SizeType size () const override;
public:
const kpAbstractSelection *originalSelection () const;
QPoint topLeft () const;
void moveTo (const QPoint &point);
int width () const;
int height () const;
void resize (int width, int height, bool delayed = false);
// (equivalent to resize() followed by moveTo() but faster)
void resizeAndMoveTo (int width, int height, const QPoint &point,
bool delayed = false);
protected:
void killSmoothScaleTimer ();
// If <delayed>, does a fast, low-quality scale and then calls itself
// with <delayed> unset for a smooth scale, a short time later.
// If acting on a text box, <delayed> is ignored.
void resizeScaleAndMove (bool delayed = false);
public:
void finalize ();
public:
void execute () override;
void unexecute () override;
protected:
kpAbstractSelection *m_originalSelectionPtr;
QPoint m_newTopLeft;
int m_newWidth, m_newHeight;
QTimer *m_smoothScaleTimer;
};
#endif // kpToolSelectionResizeScaleCommand_H

View File

@ -1,152 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_TEXT 0
#include "kpToolTextBackspaceCommand.h"
#include "layers/selections/text/kpTextSelection.h"
#include "views/manager/kpViewManager.h"
#include <QList>
kpToolTextBackspaceCommand::kpToolTextBackspaceCommand (const QString &name,
int row, int col, Action action,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_row (row), m_col (col),
m_numBackspaces (0)
{
viewManager ()->setTextCursorPosition (m_row, m_col);
if (action == AddBackspaceNow) {
addBackspace ();
}
}
kpToolTextBackspaceCommand::~kpToolTextBackspaceCommand () = default;
// public
void kpToolTextBackspaceCommand::addBackspace ()
{
QList <QString> textLines = textSelection ()->textLines ();
if (m_col > 0)
{
m_deletedText.prepend (textLines [m_row][m_col - 1]);
textLines [m_row] = textLines [m_row].left (m_col - 1) +
textLines [m_row].mid (m_col);
m_col--;
}
else
{
if (m_row > 0)
{
int newCursorRow = m_row - 1;
int newCursorCol = textLines [newCursorRow].length ();
m_deletedText.prepend ('\n');
textLines [newCursorRow] += textLines [m_row];
textLines.erase (textLines.begin () + m_row);
m_row = newCursorRow;
m_col = newCursorCol;
}
}
textSelection ()->setTextLines (textLines);
viewManager ()->setTextCursorPosition (m_row, m_col);
m_numBackspaces++;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolTextBackspaceCommand::size () const
{
return static_cast<kpCommandSize::SizeType>
(static_cast<unsigned int> (m_deletedText.length ()) * sizeof (QChar));
}
// public virtual [base kpCommand]
void kpToolTextBackspaceCommand::execute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
m_deletedText.clear ();
int oldNumBackspaces = m_numBackspaces;
m_numBackspaces = 0;
for (int i = 0; i < oldNumBackspaces; i++) {
addBackspace ();
}
}
// public virtual [base kpCommand]
void kpToolTextBackspaceCommand::unexecute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
QList <QString> textLines = textSelection ()->textLines ();
for (auto && i : m_deletedText)
{
if (i == '\n')
{
const QString rightHalf = textLines [m_row].mid (m_col);
textLines [m_row].truncate (m_col);
textLines.insert (textLines.begin () + m_row + 1, rightHalf);
m_row++;
m_col = 0;
}
else
{
const QString leftHalf = textLines [m_row].left (m_col);
const QString rightHalf = textLines [m_row].mid (m_col);
textLines [m_row] = leftHalf + i + rightHalf;
m_col++;
}
}
m_deletedText.clear ();
textSelection ()->setTextLines (textLines);
viewManager ()->setTextCursorPosition (m_row, m_col);
}

View File

@ -1,64 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_TEXT_BACKSPACE_COMMAND_H
#define KP_TOOL_TEXT_BACKSPACE_COMMAND_H
#include "commands/kpNamedCommand.h"
class kpToolTextBackspaceCommand : public kpNamedCommand
{
public:
enum Action
{
DontAddBackspaceYet,
AddBackspaceNow
};
kpToolTextBackspaceCommand (const QString &name,
int row, int col, Action action,
kpCommandEnvironment *environ);
~kpToolTextBackspaceCommand () override;
void addBackspace ();
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
protected:
int m_row, m_col;
int m_numBackspaces;
QString m_deletedText;
};
#endif // KP_TOOL_TEXT_BACKSPACE_COMMAND_H

View File

@ -1,96 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_TEXT 0
#include "kpToolTextChangeStyleCommand.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "layers/selections/text/kpTextSelection.h"
#include "kpLogCategories.h"
kpToolTextChangeStyleCommand::kpToolTextChangeStyleCommand (const QString &name,
const kpTextStyle &newTextStyle, const kpTextStyle &oldTextStyle,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_newTextStyle (newTextStyle),
m_oldTextStyle (oldTextStyle)
{
}
kpToolTextChangeStyleCommand::~kpToolTextChangeStyleCommand () = default;
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolTextChangeStyleCommand::size () const
{
return 0;
}
// public virtual [base kpCommand]
void kpToolTextChangeStyleCommand::execute ()
{
#if DEBUG_KP_TOOL_TEXT && 1
qCDebug(kpLogCommands) << "kpToolTextChangeStyleCommand::execute()"
<< " font=" << m_newTextStyle.fontFamily ()
<< " fontSize=" << m_newTextStyle.fontSize ()
<< " isBold=" << m_newTextStyle.isBold ()
<< " isItalic=" << m_newTextStyle.isItalic ()
<< " isUnderline=" << m_newTextStyle.isUnderline ()
<< " isStrikeThru=" << m_newTextStyle.isStrikeThru ();
#endif
environ ()->setTextStyle (m_newTextStyle);
if (textSelection ()) {
textSelection ()->setTextStyle (m_newTextStyle);
}
}
// public virtual [base kpCommand]
void kpToolTextChangeStyleCommand::unexecute ()
{
#if DEBUG_KP_TOOL_TEXT && 1
qCDebug(kpLogCommands) << "kpToolTextChangeStyleCommand::unexecute()"
<< " font=" << m_newTextStyle.fontFamily ()
<< " fontSize=" << m_newTextStyle.fontSize ()
<< " isBold=" << m_newTextStyle.isBold ()
<< " isItalic=" << m_newTextStyle.isItalic ()
<< " isUnderline=" << m_newTextStyle.isUnderline ()
<< " isStrikeThru=" << m_newTextStyle.isStrikeThru ();
#endif
environ ()->setTextStyle (m_oldTextStyle);
if (textSelection ())
textSelection ()->setTextStyle (m_oldTextStyle);
}

View File

@ -1,55 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_TEXT_CHANGE_STYLE_COMMAND_H
#define KP_TOOL_TEXT_CHANGE_STYLE_COMMAND_H
#include "commands/kpNamedCommand.h"
#include "layers/selections/text/kpTextStyle.h"
class kpToolTextChangeStyleCommand : public kpNamedCommand
{
public:
kpToolTextChangeStyleCommand (const QString &name,
const kpTextStyle &newTextStyle, const kpTextStyle &oldTextStyle,
kpCommandEnvironment *environ);
~kpToolTextChangeStyleCommand () override;
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
protected:
kpTextStyle m_newTextStyle, m_oldTextStyle;
};
#endif // KP_TOOL_TEXT_CHANGE_STYLE_COMMAND_H

View File

@ -1,140 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_TEXT 0
#include "kpToolTextDeleteCommand.h"
#include "layers/selections/text/kpTextSelection.h"
#include "views/manager/kpViewManager.h"
#include <QList>
kpToolTextDeleteCommand::kpToolTextDeleteCommand (const QString &name,
int row, int col, Action action,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_row (row), m_col (col),
m_numDeletes (0)
{
viewManager ()->setTextCursorPosition (m_row, m_col);
if (action == AddDeleteNow) {
addDelete ();
}
}
kpToolTextDeleteCommand::~kpToolTextDeleteCommand () = default;
// public
void kpToolTextDeleteCommand::addDelete ()
{
QList <QString> textLines = textSelection ()->textLines ();
if (m_col < static_cast<int> (textLines [m_row].length ()))
{
m_deletedText.prepend (textLines [m_row][m_col]);
textLines [m_row] = textLines [m_row].left (m_col) +
textLines [m_row].mid (m_col + 1);
}
else
{
if (m_row < static_cast<int> (textLines.size () - 1))
{
m_deletedText.prepend ('\n');
textLines [m_row] += textLines [m_row + 1];
textLines.erase (textLines.begin () + m_row + 1);
}
}
textSelection ()->setTextLines (textLines);
viewManager ()->setTextCursorPosition (m_row, m_col);
m_numDeletes++;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolTextDeleteCommand::size () const
{
return static_cast<kpCommandSize::SizeType>
(static_cast<unsigned int> (m_deletedText.length ()) * sizeof (QChar));
}
// public virtual [base kpCommand]
void kpToolTextDeleteCommand::execute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
m_deletedText.clear ();
int oldNumDeletes = m_numDeletes;
m_numDeletes = 0;
for (int i = 0; i < oldNumDeletes; i++) {
addDelete ();
}
}
// public virtual [base kpCommand]
void kpToolTextDeleteCommand::unexecute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
QList <QString> textLines = textSelection ()->textLines ();
for (auto && i : m_deletedText)
{
if (i == '\n')
{
const QString rightHalf = textLines [m_row].mid (m_col);
textLines [m_row].truncate (m_col);
textLines.insert (textLines.begin () + m_row + 1, rightHalf);
}
else
{
const QString leftHalf = textLines [m_row].left (m_col);
const QString rightHalf = textLines [m_row].mid (m_col);
textLines [m_row] = leftHalf + i + rightHalf;
}
}
m_deletedText.clear ();
textSelection ()->setTextLines (textLines);
viewManager ()->setTextCursorPosition (m_row, m_col);
}

View File

@ -1,64 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_TEXT_DELETE_COMMAND_H
#define KP_TOOL_TEXT_DELETE_COMMAND_H
#include "commands/kpNamedCommand.h"
class kpToolTextDeleteCommand : public kpNamedCommand
{
public:
enum Action
{
DontAddDeleteYet,
AddDeleteNow
};
kpToolTextDeleteCommand (const QString &name,
int row, int col, Action action,
kpCommandEnvironment *environ);
~kpToolTextDeleteCommand () override;
void addDelete ();
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
protected:
int m_row, m_col;
int m_numDeletes;
QString m_deletedText;
};
#endif // KP_TOOL_TEXT_DELETE_COMMAND_H

View File

@ -1,126 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_TEXT 0
#include "kpToolTextEnterCommand.h"
#include "layers/selections/text/kpTextSelection.h"
#include "views/manager/kpViewManager.h"
#include <QList>
kpToolTextEnterCommand::kpToolTextEnterCommand (const QString &name,
int row, int col, Action action,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_row (row), m_col (col),
m_numEnters (0)
{
viewManager ()->setTextCursorPosition (m_row, m_col);
if (action == AddEnterNow) {
addEnter ();
}
}
kpToolTextEnterCommand::~kpToolTextEnterCommand () = default;
// public
void kpToolTextEnterCommand::addEnter ()
{
QList <QString> textLines = textSelection ()->textLines ();
const QString rightHalf = textLines [m_row].mid (m_col);
textLines [m_row].truncate (m_col);
textLines.insert (textLines.begin () + m_row + 1, rightHalf);
textSelection ()->setTextLines (textLines);
m_row++;
m_col = 0;
viewManager ()->setTextCursorPosition (m_row, m_col);
m_numEnters++;
}
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolTextEnterCommand::size () const
{
return 0;
}
// public virtual [base kpCommand]
void kpToolTextEnterCommand::execute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
int oldNumEnters = m_numEnters;
m_numEnters = 0;
for (int i = 0; i < oldNumEnters; i++) {
addEnter ();
}
}
// public virtual [base kpCommand]
void kpToolTextEnterCommand::unexecute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
QList <QString> textLines = textSelection ()->textLines ();
for (int i = 0; i < m_numEnters; i++)
{
Q_ASSERT (m_col == 0);
if (m_row <= 0) {
break;
}
int newRow = m_row - 1;
int newCol = textLines [newRow].length ();
textLines [newRow] += textLines [m_row];
textLines.erase (textLines.begin () + m_row);
m_row = newRow;
m_col = newCol;
}
textSelection ()->setTextLines (textLines);
viewManager ()->setTextCursorPosition (m_row, m_col);
}

View File

@ -1,63 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_TEXT_ENTER_COMMAND_H
#define KP_TOOL_TEXT_ENTER_COMMAND_H
#include "commands/kpNamedCommand.h"
class kpToolTextEnterCommand : public kpNamedCommand
{
public:
enum Action
{
DontAddEnterYet,
AddEnterNow
};
kpToolTextEnterCommand (const QString &name,
int row, int col, Action action,
kpCommandEnvironment *environ);
~kpToolTextEnterCommand () override;
void addEnter ();
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
protected:
int m_row, m_col;
int m_numEnters;
};
#endif // KP_TOOL_TEXT_ENTER_COMMAND_H

View File

@ -1,151 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_SELECTION 0
#include "kpToolTextGiveContentCommand.h"
#include "environments/commands/kpCommandEnvironment.h"
#include "document/kpDocument.h"
#include "layers/selections/text/kpTextSelection.h"
#include "views/manager/kpViewManager.h"
#include "kpLogCategories.h"
kpToolTextGiveContentCommand::kpToolTextGiveContentCommand (
const kpTextSelection &originalSelBorder,
const QString &name,
kpCommandEnvironment *environ)
: kpAbstractSelectionContentCommand (originalSelBorder, name, environ)
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::<ctor>() environ="
<< environ
#endif
}
kpToolTextGiveContentCommand::~kpToolTextGiveContentCommand () = default;
// public virtual [base kpCommand]
void kpToolTextGiveContentCommand::execute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::execute()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
kpViewManager *vm = viewManager ();
Q_ASSERT (vm);
// See API Doc for kpViewManager::textCursorRow() & textCursorCol().
Q_ASSERT (vm->textCursorRow () == 0 && vm->textCursorCol () == 0);
vm->setQueueUpdates ();
{
//
// Recreate border
//
// The previously executed command is required to have been a
// kpToolSelectionCreateCommand, which must have been given a text
// selection with no content.
//
// However, there is a tricky case. Suppose we are called for the first
// time, where the above precondition holds. We would add content
// to the selection as expected. But the user then undoes (CTRL+Z) the
// operation, calling unexecute(). There is now no content again.
// Since selection is only a border, the user can freely deselect it
// and/or select another region without changing the command history
// or document modified state. Therefore, if they now call us again
// by redoing (CTRL+Shift+Z), there is potentially no selection at all
// or it is at an arbitrary location.
//
// This assertion covers all 3 possibilities:
//
// 1. First call: text selection with no content
// 2. Later calls:
// a) no text selection (due to deselection)
// b) text selection with no content, at an arbitrary location
Q_ASSERT (!textSelection () || !textSelection ()->hasContent ());
const auto *originalTextSel = dynamic_cast <const kpTextSelection *>
(originalSelection ());
if (originalTextSel->textStyle () != environ ()->textStyle ()) {
environ ()->setTextStyle (originalTextSel->textStyle ());
}
doc->setSelection (*originalSelection ());
//
// Add Content
//
QList <QString> listOfOneEmptyString;
listOfOneEmptyString.append (QString ());
textSelection ()->setTextLines (listOfOneEmptyString);
}
vm->restoreQueueUpdates ();
// This should not have changed from the start of the method.
Q_ASSERT (vm->textCursorRow () == 0 && vm->textCursorCol () == 0);
}
// public virtual [base kpCommand]
void kpToolTextGiveContentCommand::unexecute ()
{
#if DEBUG_KP_TOOL_SELECTION && 1
qCDebug(kpLogCommands) << "kpToolTextGiveContentCommand::unexecute()";
#endif
kpDocument *doc = document ();
Q_ASSERT (doc);
// Must have selection text content.
Q_ASSERT (doc->textSelection () && doc->textSelection ()->hasContent ());
kpViewManager *vm = viewManager ();
Q_ASSERT (vm);
// All the commands after us have been unexecuted, so we must be back
// to the state we were after our execute().
Q_ASSERT (vm->textCursorRow () == 0 && vm->textCursorCol () == 0);
// We can have faith that this is the state of the selection after
// execute(), rather than after the user tried to throw us off by
// simply selecting another region as to do that, a destroy command
// must have been used.
doc->textSelection ()->deleteContent ();
// This should not have changed from the start of the method.
Q_ASSERT (vm->textCursorRow () == 0 && vm->textCursorCol () == 0);
}

View File

@ -1,59 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef kpToolTextGiveContentCommand_H
#define kpToolTextGiveContentCommand_H
#include "commands/tools/selection/kpAbstractSelectionContentCommand.h"
class kpTextSelection;
// Converts a text border (no text lines) to a text selection with 1 empty
// text line. This must be executed before any manipulations can be made
// to a text selection.
//
// Text analog of kpToolSelectionPullFromDocumentCommand.
class kpToolTextGiveContentCommand :
public kpAbstractSelectionContentCommand
{
public:
kpToolTextGiveContentCommand (
const kpTextSelection &originalSelBorder,
const QString &name,
kpCommandEnvironment *environ);
~kpToolTextGiveContentCommand () override;
void execute () override;
void unexecute () override;
};
#endif // kpToolTextGiveContentCommand_H

View File

@ -1,110 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_TOOL_TEXT 0
#include "kpToolTextInsertCommand.h"
#include "layers/selections/text/kpTextSelection.h"
#include "views/manager/kpViewManager.h"
#include <QList>
//---------------------------------------------------------------------
kpToolTextInsertCommand::kpToolTextInsertCommand (const QString &name,
int row, int col, const QString& newText,
kpCommandEnvironment *environ)
: kpNamedCommand (name, environ),
m_row (row), m_col (col)
{
viewManager ()->setTextCursorPosition (m_row, m_col);
addText (newText);
}
//---------------------------------------------------------------------
// public
void kpToolTextInsertCommand::addText (const QString &moreText)
{
if (moreText.isEmpty ()) {
return;
}
QList <QString> textLines = textSelection ()->textLines ();
const QString leftHalf = textLines [m_row].left (m_col);
const QString rightHalf = textLines [m_row].mid (m_col);
textLines [m_row] = leftHalf + moreText + rightHalf;
textSelection ()->setTextLines (textLines);
m_newText += moreText;
m_col += moreText.length ();
viewManager ()->setTextCursorPosition (m_row, m_col);
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
kpCommandSize::SizeType kpToolTextInsertCommand::size () const
{
return static_cast<kpCommandSize::SizeType>
(static_cast<unsigned int> (m_newText.length ()) * sizeof (QChar));
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpToolTextInsertCommand::execute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
QString text = m_newText;
m_newText.clear ();
addText (text);
}
//---------------------------------------------------------------------
// public virtual [base kpCommand]
void kpToolTextInsertCommand::unexecute ()
{
viewManager ()->setTextCursorPosition (m_row, m_col);
QList <QString> textLines = textSelection ()->textLines ();
const QString leftHalf = textLines [m_row].left (m_col - m_newText.length ());
const QString rightHalf = textLines [m_row].mid (m_col);
textLines [m_row] = leftHalf + rightHalf;
textSelection ()->setTextLines (textLines);
m_col -= m_newText.length ();
viewManager ()->setTextCursorPosition (m_row, m_col);
}
//---------------------------------------------------------------------

View File

@ -1,56 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_TOOL_TEXT_INSERT_COMMAND_H
#define KP_TOOL_TEXT_INSERT_COMMAND_H
#include "commands/kpNamedCommand.h"
class kpToolTextInsertCommand : public kpNamedCommand
{
public:
kpToolTextInsertCommand (const QString &name,
int row, int col, const QString& newText,
kpCommandEnvironment *environ);
void addText (const QString &moreText);
kpCommandSize::SizeType size () const override;
void execute () override;
void unexecute () override;
protected:
int m_row, m_col;
QString m_newText;
};
#endif // KP_TOOL_TEXT_INSERT_COMMAND_H

View File

@ -1,131 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define DEBUG_KP_CURSOR_LIGHT_CROSS 0
#include "kpCursorLightCross.h"
#include "kpLogCategories.h"
#include <QBitmap>
#include <QCursor>
enum PixelValue
{
White, Black, Transparent
};
static void setPixel (unsigned char *colorBitmap,
unsigned char *maskBitmap,
int width,
int y, int x, enum PixelValue pv)
{
const int ColorBlack = 1;
const int ColorWhite = 0;
const int MaskOpaque = 1;
const int MaskTransparent = 0;
int colorValue, maskValue;
switch (pv)
{
case White:
colorValue = ColorWhite;
maskValue = MaskOpaque;
break;
case Black:
colorValue = ColorBlack;
maskValue = MaskOpaque;
break;
case Transparent:
colorValue = ColorWhite;
maskValue = MaskTransparent;
break;
}
if (colorValue) {
colorBitmap [y * (width / 8) + (x / 8)] |= (1 << (x % 8));
}
if (maskValue) {
maskBitmap [y * (width / 8) + (x / 8)] |= (1 << (x % 8));
}
}
const QCursor *kpCursorLightCrossCreate ()
{
#if DEBUG_KP_CURSOR_LIGHT_CROSS
qCDebug(kpLogMisc) << "kpCursorLightCrossCreate() ";
#endif
const int side = 24;
const int byteSize = (side * side) / 8;
auto *colorBitmap = new unsigned char [byteSize];
auto *maskBitmap = new unsigned char [byteSize];
memset (colorBitmap, 0, byteSize);
memset (maskBitmap, 0, byteSize);
const int oddSide = side - 1;
const int strokeLen = oddSide * 3 / 8;
for (int i = 0; i < strokeLen; i++)
{
const enum PixelValue pv = (i % 2) ? Black : White;
#define X_(val) (val)
#define Y_(val) (val)
#define DRAW(y,x) setPixel (colorBitmap, maskBitmap, side, (y), (x), pv)
// horizontal
DRAW (Y_(side / 2), X_(1 + i));
DRAW (Y_(side / 2), X_(side - 1 - i));
// vertical
DRAW (Y_(1 + i), X_(side / 2));
DRAW (Y_(side - 1 - i), X_(side / 2));
#undef DRAW
#undef Y_
#undef X_
}
const QSize size (side, side);
QCursor *cursor = new QCursor (
QBitmap::fromData (size, colorBitmap, QImage::Format_MonoLSB),
QBitmap::fromData (size, maskBitmap, QImage::Format_MonoLSB));
delete [] maskBitmap;
delete [] colorBitmap;
return cursor;
}

View File

@ -1,39 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_CURSOR_LIGHT_CROSS_H
#define KP_CURSOR_LIGHT_CROSS_H
class QCursor;
const QCursor *kpCursorLightCrossCreate ();
#endif // KP_CURSOR_LIGHT_CROSS_H

View File

@ -1,48 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "kpCursorProvider.h"
#include "kpCursorLightCross.h"
#include <QCursor>
static const QCursor *TheLightCursor = nullptr;
// public static
QCursor kpCursorProvider::lightCross ()
{
// TODO: don't leak (although it's cleaned up on exit by OS anyway)
if (!::TheLightCursor) {
::TheLightCursor = kpCursorLightCrossCreate ();
}
return *::TheLightCursor;
}

View File

@ -1,43 +0,0 @@
/*
Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KP_CURSOR_PROVIDER_H
#define KP_CURSOR_PROVIDER_H
class QCursor;
class kpCursorProvider
{
public:
static QCursor lightCross ();
};
#endif // KP_CURSOR_PROVIDER_H

17
debian/changelog vendored
View File

@ -1,17 +0,0 @@
kolourpaint (4:22.12.3-ok1) yangtze; urgency=medium
* New upstream release (22.12.3).
-- rtlhq <nobelxyz@163.com> Wed, 01 Mar 2023 11:58:27 +0800
kolourpaint (4:22.12.1-ok1) yangtze; urgency=medium
* New upstream release (22.12.1).
-- rtlhq <nobelxyz@163.com> Sat, 07 Jan 2023 12:07:32 +0800
kolourpaint (4:22.08.3-ok1) yangtze; urgency=medium
* Build for openkylin.
-- rtlhq <nobelxyz@163.com> Tue, 13 Sep 2022 15:49:05 +0800

40
debian/control vendored
View File

@ -1,40 +0,0 @@
Source: kolourpaint
Section: kde
Priority: optional
Maintainer: openKylin KDE SIG <kde@lists.openkylin.top>
Uploaders: rtlhq <nobelxyz@163.com>,
Build-Depends: cmake (>= 3.10.0~),
debhelper-compat (= 13),
dh-sequence-kf5,
extra-cmake-modules (>= 5.90.0~),
gettext,
libkf5doctools-dev (>= 5.90.0~),
libkf5guiaddons-dev (>= 5.90.0~),
libkf5i18n-dev (>= 5.90.0~),
libkf5jobwidgets-dev (>= 5.90.0~),
libkf5kio-dev (>= 5.90.0~),
libkf5sane-dev (>= 21.12~),
libkf5textwidgets-dev (>= 5.90.0~),
libkf5widgetsaddons-dev (>= 5.90.0~),
libkf5xmlgui-dev (>= 5.90.0~),
pkg-config,
qtbase5-dev (>= 5.15.2~),
Standards-Version: 4.6.2
Rules-Requires-Root: no
Homepage: https://apps.kde.org/en/kolourpaint
Vcs-Browser: https://gitee.com/openkylin/kolourpaint
Vcs-Git: https://gitee.com/openkylin/kolourpaint.git
Package: kolourpaint
Section: graphics
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends},
Breaks: kolourpaint4 (<< 4:17.04),
Replaces: kolourpaint4 (<< 4:17.04),
Description: simple image editor and drawing application
KolourPaint is a simple drawing and image editing application for KDE.
It aims to be easy to use, providing a level of functionality targeted towards
the average user. It is ideal for common tasks such as drawing simple graphics
and touching-up photos.
.
This package is part of the KDE graphics module.

Some files were not shown because too many files have changed in this diff Show More