Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Krita
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tusooa Zhu
Krita
Commits
64274b57
Commit
64274b57
authored
Aug 09, 2019
by
Tusooa Zhu
➡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port calligraphy and text tools and defaulttool geometry tab to new strokes
parent
1d6e688c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
176 deletions
+68
-176
plugins/tools/defaulttool/defaulttool/DefaultToolGeometryWidget.cpp
...ols/defaulttool/defaulttool/DefaultToolGeometryWidget.cpp
+39
-31
plugins/tools/karbonplugins/tools/CalligraphyTool/KarbonCalligraphyTool.cpp
...onplugins/tools/CalligraphyTool/KarbonCalligraphyTool.cpp
+8
-10
plugins/tools/svgtexttool/CMakeLists.txt
plugins/tools/svgtexttool/CMakeLists.txt
+0
-1
plugins/tools/svgtexttool/SvgTextChangeCommand.cpp
plugins/tools/svgtexttool/SvgTextChangeCommand.cpp
+0
-69
plugins/tools/svgtexttool/SvgTextChangeCommand.h
plugins/tools/svgtexttool/SvgTextChangeCommand.h
+0
-52
plugins/tools/svgtexttool/SvgTextTool.cpp
plugins/tools/svgtexttool/SvgTextTool.cpp
+21
-13
No files found.
plugins/tools/defaulttool/defaulttool/DefaultToolGeometryWidget.cpp
View file @
64274b57
...
...
@@ -29,12 +29,6 @@
#include <KoSelectedShapesProxy.h>
#include <KoSelection.h>
#include <KoUnit.h>
#include <commands/KoShapeResizeCommand.h>
#include <commands/KoShapeMoveCommand.h>
#include <commands/KoShapeSizeCommand.h>
#include <commands/KoShapeTransformCommand.h>
#include <commands/KoShapeKeepAspectRatioCommand.h>
#include <commands/KoShapeTransparencyCommand.h>
#include "SelectionDecorator.h"
#include <KoShapeGroup.h>
...
...
@@ -55,6 +49,7 @@
#include "kis_acyclic_signal_connector.h"
#include "kis_signal_compressor.h"
#include "kis_signals_blocker.h"
#include <KoCanvasStrokeHelperBase.h>
DefaultToolGeometryWidget
::
DefaultToolGeometryWidget
(
KoInteractionTool
*
tool
,
QWidget
*
parent
)
...
...
@@ -229,10 +224,16 @@ void DefaultToolGeometryWidget::slotAspectButtonToggled()
KoSelection
*
selection
=
m_tool
->
canvas
()
->
selectedShapesProxy
()
->
selection
();
QList
<
KoShape
*>
shapes
=
selection
->
selectedEditableShapes
();
KUndo2Command
*
cmd
=
new
KoShapeKeepAspectRatioCommand
(
shapes
,
aspectButton
->
keepAspectRatio
());
m_tool
->
canvas
()
->
addCommand
(
cmd
);
if
(
!
shapes
.
isEmpty
())
{
bool
keepAspectRatio
=
aspectButton
->
keepAspectRatio
();
m_tool
->
canvas
()
->
strokeHelper
()
->
run
(
kundo2_i18n
(
"Keep Aspect Ratio"
),
[
shapes
,
keepAspectRatio
]()
{
Q_FOREACH
(
KoShape
*
shape
,
shapes
)
{
shape
->
setKeepAspectRatio
(
keepAspectRatio
);
}
return
true
;
});
}
}
void
DefaultToolGeometryWidget
::
slotUpdateAspectButton
()
...
...
@@ -284,10 +285,16 @@ void DefaultToolGeometryWidget::slotOpacitySliderChanged(qreal newOpacity)
QList
<
KoShape
*>
shapes
=
selection
->
selectedEditableShapes
();
if
(
shapes
.
isEmpty
())
return
;
KUndo2Command
*
cmd
=
new
KoShapeTransparencyCommand
(
shapes
,
1.0
-
newOpacity
);
qreal
transparency
=
1.0
-
newOpacity
;
m_tool
->
canvas
()
->
addCommand
(
cmd
);
m_tool
->
canvas
()
->
strokeHelper
()
->
run
(
kundo2_i18n
(
"Set opacity"
),
[
shapes
,
transparency
]()
{
Q_FOREACH
(
KoShape
*
shape
,
shapes
)
{
shape
->
setTransparency
(
transparency
);
shape
->
update
();
}
return
true
;
});
}
void
DefaultToolGeometryWidget
::
slotUpdateOpacitySlider
()
...
...
@@ -371,18 +378,16 @@ void DefaultToolGeometryWidget::slotRepositionShapes()
if
(
diff
.
manhattanLength
()
<
eps
)
return
;
QList
<
QPointF
>
oldPositions
;
QList
<
QPointF
>
newPositions
;
Q_FOREACH
(
KoShape
*
shape
,
shapes
)
{
const
QPointF
oldShapePosition
=
shape
->
absolutePosition
(
anchor
);
oldPositions
<<
shape
->
absolutePosition
(
anchor
);
newPositions
<<
oldShapePosition
+
diff
;
}
m_tool
->
canvas
()
->
strokeHelper
()
->
run
(
kundo2_i18n
(
"Move shapes"
),
[
shapes
,
diff
,
anchor
]()
{
Q_FOREACH
(
KoShape
*
shape
,
shapes
)
{
const
QPointF
oldShapePosition
=
shape
->
absolutePosition
(
anchor
);
KUndo2Command
*
cmd
=
new
KoShapeMoveCommand
(
shapes
,
oldPositions
,
newPositions
,
anchor
);
m_tool
->
canvas
()
->
addCommand
(
cmd
);
shape
->
setAbsolutePosition
(
oldShapePosition
+
diff
,
anchor
);
shape
->
update
();
}
return
true
;
});
}
void
DefaultToolGeometryWidget
::
slotResizeShapes
()
...
...
@@ -411,13 +416,16 @@ void DefaultToolGeometryWidget::slotResizeShapes()
const
bool
usePostScaling
=
shapes
.
size
()
>
1
||
chkUniformScaling
->
isChecked
();
KUndo2Command
*
cmd
=
new
KoShapeResizeCommand
(
shapes
,
scaleX
,
scaleY
,
bounds
.
topLeft
(),
useGlobalSize
,
usePostScaling
,
selection
->
transformation
());
m_tool
->
canvas
()
->
addCommand
(
cmd
);
m_tool
->
canvas
()
->
strokeHelper
()
->
run
(
kundo2_i18n
(
"Resize shapes"
),
[
shapes
,
scaleX
,
scaleY
,
bounds
,
useGlobalSize
,
usePostScaling
,
selection
]()
{
Q_FOREACH
(
KoShape
*
shape
,
shapes
)
{
const
QRectF
oldDirtyRect
=
shape
->
boundingRect
();
KoFlake
::
resizeShape
(
shape
,
scaleX
,
scaleY
,
bounds
.
topLeft
(),
useGlobalSize
,
usePostScaling
,
selection
->
transformation
());
shape
->
updateAbsolute
(
oldDirtyRect
|
shape
->
boundingRect
());
}
return
true
;
});
}
void
DefaultToolGeometryWidget
::
setUnit
(
const
KoUnit
&
unit
)
...
...
plugins/tools/karbonplugins/tools/CalligraphyTool/KarbonCalligraphyTool.cpp
View file @
64274b57
...
...
@@ -42,6 +42,8 @@
#include <klocalizedstring.h>
#include <QPainter>
#include <KoCanvasStrokeHelperBase.h>
#include <cmath>
#undef M_PI
...
...
@@ -148,16 +150,12 @@ void KarbonCalligraphyTool::mouseReleaseEvent(KoPointerEvent *event)
m_shape
->
simplifyGuidePath
();
KUndo2Command
*
cmd
=
canvas
()
->
shapeController
()
->
addShape
(
m_shape
,
0
,
0
);
if
(
cmd
)
{
m_lastShape
=
m_shape
;
canvas
()
->
addCommand
(
cmd
);
canvas
()
->
updateCanvas
(
m_shape
->
boundingRect
());
}
else
{
// don't leak shape when command could not be created
delete
m_shape
;
}
KoShape
*
currentShape
=
m_shape
;
canvas
()
->
strokeHelper
()
->
run
(
kundo2_i18n
(
"Create shape"
),
[
this
,
currentShape
]()
{
canvas
()
->
shapeController
()
->
addShape
(
currentShape
,
0
);
return
true
;
});
m_shape
=
0
;
}
...
...
plugins/tools/svgtexttool/CMakeLists.txt
View file @
64274b57
...
...
@@ -5,7 +5,6 @@ set(CMAKE_AUTORCC ON)
set
(
SvgTextTool_SRCS
BasicXMLSyntaxHighlighter.cpp
Plugin.cpp
SvgTextChangeCommand.cpp
SvgRichTextCtrl.cpp
SvgTextEditor.cpp
SvgTextTool.cpp
...
...
plugins/tools/svgtexttool/SvgTextChangeCommand.cpp
deleted
100644 → 0
View file @
1d6e688c
/* This file is part of the KDE project
Copyright 2017 Boudewijn Rempt <boud@valdyas.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.
*/
#include "SvgTextChangeCommand.h"
#include <math.h>
#include <klocalizedstring.h>
#include <KoImageData.h>
#include "KoSvgTextShape.h"
#include "KoSvgTextShapeMarkupConverter.h"
SvgTextChangeCommand
::
SvgTextChangeCommand
(
KoSvgTextShape
*
shape
,
const
QString
&
svg
,
const
QString
&
defs
,
bool
richTextPreferred
,
KUndo2Command
*
parent
)
:
KUndo2Command
(
parent
)
,
m_shape
(
shape
)
,
m_svg
(
svg
)
,
m_defs
(
defs
)
,
m_richTextPreferred
(
richTextPreferred
)
{
Q_ASSERT
(
shape
);
setText
(
kundo2_i18n
(
"Change SvgTextTool"
));
m_oldRichTextPreferred
=
m_shape
->
isRichTextPreferred
();
KoSvgTextShapeMarkupConverter
converter
(
m_shape
);
converter
.
convertToSvg
(
&
m_oldSvg
,
&
m_oldDefs
);
}
SvgTextChangeCommand
::~
SvgTextChangeCommand
()
{
}
void
SvgTextChangeCommand
::
redo
()
{
m_shape
->
update
();
KoSvgTextShapeMarkupConverter
converter
(
m_shape
);
// Hardcoded resolution?
converter
.
convertFromSvg
(
m_svg
,
m_defs
,
m_shape
->
boundingRect
(),
72.0
);
m_shape
->
setRichTextPreferred
(
m_richTextPreferred
);
m_shape
->
update
();
}
void
SvgTextChangeCommand
::
undo
()
{
m_shape
->
update
();
KoSvgTextShapeMarkupConverter
converter
(
m_shape
);
// Hardcoded resolution?
converter
.
convertFromSvg
(
m_oldSvg
,
m_oldDefs
,
m_shape
->
boundingRect
(),
72.0
);
m_shape
->
setRichTextPreferred
(
m_oldRichTextPreferred
);
m_shape
->
update
();
}
plugins/tools/svgtexttool/SvgTextChangeCommand.h
deleted
100644 → 0
View file @
1d6e688c
/* This file is part of the KDE project
Copyright 2017 Boudewijn Rempt <boud@valdyas.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.
*/
#ifndef CHANGETEXTNGDATACOMMAND_H
#define CHANGETEXTNGDATACOMMAND_H
#include <kundo2command.h>
#include <QByteArray>
#include "KoSvgTextShape.h"
class
SvgTextChangeCommand
:
public
KUndo2Command
{
public:
SvgTextChangeCommand
(
KoSvgTextShape
*
shape
,
const
QString
&
svg
,
const
QString
&
defs
,
bool
richTextPreferred
,
KUndo2Command
*
parent
=
0
);
virtual
~
SvgTextChangeCommand
();
/// redo the command
virtual
void
redo
();
/// revert the actions done in redo
virtual
void
undo
();
private:
KoSvgTextShape
*
m_shape
;
QString
m_svg
;
QString
m_defs
;
QString
m_oldSvg
;
QString
m_oldDefs
;
bool
m_oldRichTextPreferred
=
true
;
bool
m_richTextPreferred
=
true
;
};
#endif
/* CHANGETEXTNGDATACOMMAND_H */
plugins/tools/svgtexttool/SvgTextTool.cpp
View file @
64274b57
...
...
@@ -20,7 +20,6 @@
#include "SvgTextTool.h"
#include "KoSvgTextShape.h"
#include "SvgTextChangeCommand.h"
#include <QLabel>
#include <QToolButton>
...
...
@@ -56,7 +55,8 @@
#include "SvgTextEditor.h"
#include "KisHandlePainterHelper.h"
#include <commands/KoKeepShapesSelectedCommand.h>
#include <KoCanvasStrokeHelperBase.h>
#include <KoSvgTextShapeMarkupConverter.h>
SvgTextTool
::
SvgTextTool
(
KoCanvasBase
*
canvas
)
...
...
@@ -244,8 +244,16 @@ void SvgTextTool::showEditor()
void
SvgTextTool
::
textUpdated
(
KoSvgTextShape
*
shape
,
const
QString
&
svg
,
const
QString
&
defs
,
bool
richTextUpdated
)
{
SvgTextChangeCommand
*
cmd
=
new
SvgTextChangeCommand
(
shape
,
svg
,
defs
,
richTextUpdated
);
canvas
()
->
addCommand
(
cmd
);
canvas
()
->
strokeHelper
()
->
run
(
kundo2_i18n
(
"Change SvgTextTool"
),
[
shape
,
svg
,
defs
,
richTextUpdated
]()
{
KoSvgTextShapeMarkupConverter
converter
(
shape
);
shape
->
update
();
// Hardcoded resolution?
converter
.
convertFromSvg
(
svg
,
defs
,
shape
->
boundingRect
(),
72.0
);
shape
->
setRichTextPreferred
(
richTextUpdated
);
shape
->
update
();
return
true
;
});
}
void
SvgTextTool
::
slotTextEditorClosed
()
...
...
@@ -388,16 +396,16 @@ void SvgTextTool::mouseReleaseEvent(KoPointerEvent *event)
}
KoShape
*
textShape
=
factory
->
createShape
(
params
,
canvas
()
->
shapeController
()
->
resourceManager
());
K
Undo2Command
*
parentCommand
=
new
KUndo2Command
();
K
oSelection
*
selection
=
koSelection
();
new
KoKeepShapesSelectedCommand
(
koSelection
()
->
selectedShapes
(),
{},
canvas
()
->
selectedShapesProxy
(),
false
,
parentCommand
);
KUndo2Command
*
cmd
=
canvas
()
->
shapeController
()
->
addShape
(
textShape
,
0
,
parentCommand
);
parentCommand
->
setText
(
cmd
->
text
()
);
new
KoKeepShapesSelectedCommand
({},
{
textShape
},
canvas
()
->
selectedShapesProxy
(),
true
,
parentCommand
)
;
canvas
()
->
addCommand
(
parentCommand
);
canvas
()
->
strokeHelper
()
->
run
(
kundo2_i18n
(
"Create shape"
),
[
this
,
selection
,
textShape
]()
{
canvas
()
->
shapeController
()
->
addShape
(
textShape
,
0
);
selection
->
deselectAll
(
);
selection
->
select
(
textShape
);
return
true
;
}
);
showEditor
();
event
->
accept
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment