Changeset View
Changeset View
Standalone View
Standalone View
commands/tools/selection/kpToolSelectionResizeScaleCommand.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
90 | QPoint kpToolSelectionResizeScaleCommand::topLeft () const | 90 | QPoint kpToolSelectionResizeScaleCommand::topLeft () const | ||
91 | { | 91 | { | ||
92 | return m_newTopLeft; | 92 | return m_newTopLeft; | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | // public | 95 | // public | ||
96 | void kpToolSelectionResizeScaleCommand::moveTo (const QPoint &point) | 96 | void kpToolSelectionResizeScaleCommand::moveTo (const QPoint &point) | ||
97 | { | 97 | { | ||
98 | if (point == m_newTopLeft) | 98 | if (point == m_newTopLeft) { | ||
99 | return; | 99 | return; | ||
100 | } | ||||
100 | 101 | | |||
101 | m_newTopLeft = point; | 102 | m_newTopLeft = point; | ||
102 | selection ()->moveTo (m_newTopLeft); | 103 | selection ()->moveTo (m_newTopLeft); | ||
103 | } | 104 | } | ||
104 | 105 | | |||
105 | 106 | | |||
106 | // public | 107 | // public | ||
107 | int kpToolSelectionResizeScaleCommand::width () const | 108 | int kpToolSelectionResizeScaleCommand::width () const | ||
108 | { | 109 | { | ||
109 | return m_newWidth; | 110 | return m_newWidth; | ||
110 | } | 111 | } | ||
111 | 112 | | |||
112 | // public | 113 | // public | ||
113 | int kpToolSelectionResizeScaleCommand::height () const | 114 | int kpToolSelectionResizeScaleCommand::height () const | ||
114 | { | 115 | { | ||
115 | return m_newHeight; | 116 | return m_newHeight; | ||
116 | } | 117 | } | ||
117 | 118 | | |||
118 | // public | 119 | // public | ||
119 | void kpToolSelectionResizeScaleCommand::resize (int width, int height, | 120 | void kpToolSelectionResizeScaleCommand::resize (int width, int height, | ||
120 | bool delayed) | 121 | bool delayed) | ||
121 | { | 122 | { | ||
122 | if (width == m_newWidth && height == m_newHeight) | 123 | if (width == m_newWidth && height == m_newHeight) { | ||
123 | return; | 124 | return; | ||
125 | } | ||||
124 | 126 | | |||
125 | m_newWidth = width; | 127 | m_newWidth = width; | ||
126 | m_newHeight = height; | 128 | m_newHeight = height; | ||
127 | 129 | | |||
128 | resizeScaleAndMove (delayed); | 130 | resizeScaleAndMove (delayed); | ||
129 | } | 131 | } | ||
130 | 132 | | |||
131 | 133 | | |||
Show All 22 Lines | 155 | { | |||
154 | m_smoothScaleTimer->stop (); | 156 | m_smoothScaleTimer->stop (); | ||
155 | } | 157 | } | ||
156 | 158 | | |||
157 | 159 | | |||
158 | // protected | 160 | // protected | ||
159 | void kpToolSelectionResizeScaleCommand::resizeScaleAndMove (bool delayed) | 161 | void kpToolSelectionResizeScaleCommand::resizeScaleAndMove (bool delayed) | ||
160 | { | 162 | { | ||
161 | qCDebug(kpLogCommands) << "kpToolSelectionResizeScaleCommand::resizeScaleAndMove(delayed=" | 163 | qCDebug(kpLogCommands) << "kpToolSelectionResizeScaleCommand::resizeScaleAndMove(delayed=" | ||
162 | << delayed << ")" << endl; | 164 | << delayed << ")"; | ||
163 | 165 | | |||
164 | killSmoothScaleTimer (); | 166 | killSmoothScaleTimer (); | ||
165 | 167 | | |||
166 | kpAbstractSelection *newSelPtr = nullptr; | 168 | kpAbstractSelection *newSelPtr = nullptr; | ||
167 | 169 | | |||
168 | if (textSelection ()) | 170 | if (textSelection ()) | ||
169 | { | 171 | { | ||
170 | Q_ASSERT (dynamic_cast <kpTextSelection *> (m_originalSelectionPtr)); | 172 | Q_ASSERT (dynamic_cast <kpTextSelection *> (m_originalSelectionPtr)); | ||
171 | kpTextSelection *orgTextSel = | 173 | auto *orgTextSel = dynamic_cast <kpTextSelection *> (m_originalSelectionPtr); | ||
172 | static_cast <kpTextSelection *> (m_originalSelectionPtr); | | |||
173 | 174 | | |||
174 | newSelPtr = orgTextSel->resized (m_newWidth, m_newHeight); | 175 | newSelPtr = orgTextSel->resized (m_newWidth, m_newHeight); | ||
175 | } | 176 | } | ||
176 | else | 177 | else | ||
177 | { | 178 | { | ||
178 | Q_ASSERT (dynamic_cast <kpAbstractImageSelection *> (m_originalSelectionPtr)); | 179 | Q_ASSERT (dynamic_cast <kpAbstractImageSelection *> (m_originalSelectionPtr)); | ||
179 | kpAbstractImageSelection *imageSel = | 180 | auto *imageSel = dynamic_cast <kpAbstractImageSelection *> (m_originalSelectionPtr); | ||
180 | static_cast <kpAbstractImageSelection *> (m_originalSelectionPtr); | | |||
181 | 181 | | |||
182 | newSelPtr = new kpRectangularImageSelection ( | 182 | newSelPtr = new kpRectangularImageSelection ( | ||
183 | QRect (imageSel->x (), | 183 | QRect (imageSel->x (), | ||
184 | imageSel->y (), | 184 | imageSel->y (), | ||
185 | m_newWidth, | 185 | m_newWidth, | ||
186 | m_newHeight), | 186 | m_newHeight), | ||
187 | kpPixmapFX::scale (imageSel->baseImage (), | 187 | kpPixmapFX::scale (imageSel->baseImage (), | ||
188 | m_newWidth, m_newHeight, | 188 | m_newWidth, m_newHeight, | ||
Show All 16 Lines | |||||
205 | } | 205 | } | ||
206 | 206 | | |||
207 | 207 | | |||
208 | // public | 208 | // public | ||
209 | void kpToolSelectionResizeScaleCommand::finalize () | 209 | void kpToolSelectionResizeScaleCommand::finalize () | ||
210 | { | 210 | { | ||
211 | qCDebug(kpLogCommands) << "kpToolSelectionResizeScaleCommand::finalize()" | 211 | qCDebug(kpLogCommands) << "kpToolSelectionResizeScaleCommand::finalize()" | ||
212 | << " smoothScaleTimer->isActive=" | 212 | << " smoothScaleTimer->isActive=" | ||
213 | << m_smoothScaleTimer->isActive () | 213 | << m_smoothScaleTimer->isActive (); | ||
214 | << endl; | | |||
215 | 214 | | |||
216 | // Make sure the selection contains the final image and the timer won't | 215 | // Make sure the selection contains the final image and the timer won't | ||
217 | // fire afterwards. | 216 | // fire afterwards. | ||
218 | if (m_smoothScaleTimer->isActive ()) | 217 | if (m_smoothScaleTimer->isActive ()) | ||
219 | { | 218 | { | ||
220 | resizeScaleAndMove (); | 219 | resizeScaleAndMove (); | ||
221 | Q_ASSERT (!m_smoothScaleTimer->isActive ()); | 220 | Q_ASSERT (!m_smoothScaleTimer->isActive ()); | ||
222 | } | 221 | } | ||
Show All 32 Lines |