Changeset View
Changeset View
Standalone View
Standalone View
tools/selection/image/kpAbstractImageSelectionTool_Transparency.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
57 | 57 | | |||
58 | // protected | 58 | // protected | ||
59 | bool kpAbstractImageSelectionTool::shouldChangeImageSelectionTransparency () const | 59 | bool kpAbstractImageSelectionTool::shouldChangeImageSelectionTransparency () const | ||
60 | { | 60 | { | ||
61 | if (environ ()->settingImageSelectionTransparency ()) | 61 | if (environ ()->settingImageSelectionTransparency ()) | ||
62 | { | 62 | { | ||
63 | #if DEBUG_KP_TOOL_SELECTION | 63 | #if DEBUG_KP_TOOL_SELECTION | ||
64 | qCDebug(kpLogTools) << "\trecursion - abort setting selection transparency: " | 64 | qCDebug(kpLogTools) << "\trecursion - abort setting selection transparency: " | ||
65 | << environ ()->settingImageSelectionTransparency () << endl; | 65 | << environ ()->settingImageSelectionTransparency (); | ||
66 | #endif | 66 | #endif | ||
67 | return false; | 67 | return false; | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | if (!document ()->imageSelection ()) | 70 | if (!document ()->imageSelection ()) { | ||
71 | return false; | 71 | return false; | ||
72 | } | ||||
72 | 73 | | |||
73 | // TODO: Can probably return false if the selection transparency mode | 74 | // TODO: Can probably return false if the selection transparency mode | ||
74 | // is Opaque, since neither background color nor color similarity | 75 | // is Opaque, since neither background color nor color similarity | ||
75 | // would matter. | 76 | // would matter. | ||
76 | 77 | | |||
77 | return true; | 78 | return true; | ||
78 | } | 79 | } | ||
79 | 80 | | |||
80 | // protected | 81 | // protected | ||
81 | void kpAbstractImageSelectionTool::changeImageSelectionTransparency ( | 82 | void kpAbstractImageSelectionTool::changeImageSelectionTransparency ( | ||
82 | const QString &name, | 83 | const QString &name, | ||
83 | const kpImageSelectionTransparency &newTrans, | 84 | const kpImageSelectionTransparency &newTrans, | ||
84 | const kpImageSelectionTransparency &oldTrans) | 85 | const kpImageSelectionTransparency &oldTrans) | ||
85 | { | 86 | { | ||
86 | #if DEBUG_KP_TOOL_SELECTION | 87 | #if DEBUG_KP_TOOL_SELECTION | ||
87 | qCDebug(kpLogTools) << "CALL(" << name << ")"; | 88 | qCDebug(kpLogTools) << "CALL(" << name << ")"; | ||
88 | #endif | 89 | #endif | ||
89 | 90 | | |||
90 | kpSetOverrideCursorSaver cursorSaver (Qt::WaitCursor); | 91 | kpSetOverrideCursorSaver cursorSaver (Qt::WaitCursor); | ||
91 | 92 | | |||
92 | if (hasBegunShape ()) | 93 | if (hasBegunShape ()) { | ||
93 | endShapeInternal (); | 94 | endShapeInternal (); | ||
95 | } | ||||
94 | 96 | | |||
95 | kpAbstractImageSelection *imageSel = document ()->imageSelection (); | 97 | kpAbstractImageSelection *imageSel = document ()->imageSelection (); | ||
96 | 98 | | |||
97 | if (imageSel->hasContent () && newTrans.isTransparent ()) | 99 | if (imageSel->hasContent () && newTrans.isTransparent ()) { | ||
98 | environ ()->flashColorSimilarityToolBarItem (); | 100 | environ ()->flashColorSimilarityToolBarItem (); | ||
101 | } | ||||
99 | 102 | | |||
100 | imageSel->setTransparency (newTrans); | 103 | imageSel->setTransparency (newTrans); | ||
101 | 104 | | |||
102 | // We _must_ add the command even if kpAbstractImageSelection::setTransparency() | 105 | // We _must_ add the command even if kpAbstractImageSelection::setTransparency() | ||
103 | // above did not change the selection transparency mask at all. | 106 | // above did not change the selection transparency mask at all. | ||
104 | // Consider the following case: | 107 | // Consider the following case: | ||
105 | // | 108 | // | ||
106 | // 0. Ensure that selection transparency is opaque and any | 109 | // 0. Ensure that selection transparency is opaque and any | ||
Show All 33 Lines | |||||
140 | 143 | | |||
141 | // protected slot virtual [kpAbstractSelectionTool] | 144 | // protected slot virtual [kpAbstractSelectionTool] | ||
142 | void kpAbstractImageSelectionTool::slotIsOpaqueChanged (bool /*isOpaque*/) | 145 | void kpAbstractImageSelectionTool::slotIsOpaqueChanged (bool /*isOpaque*/) | ||
143 | { | 146 | { | ||
144 | #if DEBUG_KP_TOOL_SELECTION | 147 | #if DEBUG_KP_TOOL_SELECTION | ||
145 | qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotIsOpaqueChanged()"; | 148 | qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotIsOpaqueChanged()"; | ||
146 | #endif | 149 | #endif | ||
147 | 150 | | |||
148 | if (!shouldChangeImageSelectionTransparency ()) | 151 | if (!shouldChangeImageSelectionTransparency ()) { | ||
149 | return; | 152 | return; | ||
153 | } | ||||
150 | 154 | | |||
151 | kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); | 155 | kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); | ||
152 | 156 | | |||
153 | kpImageSelectionTransparency oldST = st; | 157 | kpImageSelectionTransparency oldST = st; | ||
154 | oldST.setOpaque (!oldST.isOpaque ()); | 158 | oldST.setOpaque (!oldST.isOpaque ()); | ||
155 | 159 | | |||
156 | changeImageSelectionTransparency ( | 160 | changeImageSelectionTransparency ( | ||
157 | st.isOpaque () ? | 161 | st.isOpaque () ? | ||
158 | i18n ("Selection: Opaque") : | 162 | i18n ("Selection: Opaque") : | ||
159 | i18n ("Selection: Transparent"), | 163 | i18n ("Selection: Transparent"), | ||
160 | st, oldST); | 164 | st, oldST); | ||
161 | } | 165 | } | ||
162 | 166 | | |||
163 | // protected slot virtual [base kpTool] | 167 | // protected slot virtual [base kpTool] | ||
164 | void kpAbstractImageSelectionTool::slotBackgroundColorChanged (const kpColor &) | 168 | void kpAbstractImageSelectionTool::slotBackgroundColorChanged (const kpColor &) | ||
165 | { | 169 | { | ||
166 | #if DEBUG_KP_TOOL_SELECTION | 170 | #if DEBUG_KP_TOOL_SELECTION | ||
167 | qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotBackgroundColorChanged()"; | 171 | qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotBackgroundColorChanged()"; | ||
168 | #endif | 172 | #endif | ||
169 | 173 | | |||
170 | if (!shouldChangeImageSelectionTransparency ()) | 174 | if (!shouldChangeImageSelectionTransparency ()) { | ||
171 | return; | 175 | return; | ||
176 | } | ||||
172 | 177 | | |||
173 | kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); | 178 | kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); | ||
174 | 179 | | |||
175 | kpImageSelectionTransparency oldST = st; | 180 | kpImageSelectionTransparency oldST = st; | ||
176 | oldST.setTransparentColor (oldBackgroundColor ()); | 181 | oldST.setTransparentColor (oldBackgroundColor ()); | ||
177 | 182 | | |||
178 | changeImageSelectionTransparency ( | 183 | changeImageSelectionTransparency ( | ||
179 | i18n ("Selection: Transparency Color"), | 184 | i18n ("Selection: Transparency Color"), | ||
180 | st, oldST); | 185 | st, oldST); | ||
181 | } | 186 | } | ||
182 | 187 | | |||
183 | // protected slot virtual [base kpTool] | 188 | // protected slot virtual [base kpTool] | ||
184 | void kpAbstractImageSelectionTool::slotColorSimilarityChanged (double, int) | 189 | void kpAbstractImageSelectionTool::slotColorSimilarityChanged (double, int) | ||
185 | { | 190 | { | ||
186 | #if DEBUG_KP_TOOL_SELECTION | 191 | #if DEBUG_KP_TOOL_SELECTION | ||
187 | qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotColorSimilarityChanged()"; | 192 | qCDebug(kpLogTools) << "kpAbstractImageSelectionTool::slotColorSimilarityChanged()"; | ||
188 | #endif | 193 | #endif | ||
189 | 194 | | |||
190 | if (!shouldChangeImageSelectionTransparency ()) | 195 | if (!shouldChangeImageSelectionTransparency ()) { | ||
191 | return; | 196 | return; | ||
197 | } | ||||
192 | 198 | | |||
193 | kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); | 199 | kpImageSelectionTransparency st = environ ()->imageSelectionTransparency (); | ||
194 | 200 | | |||
195 | kpImageSelectionTransparency oldST = st; | 201 | kpImageSelectionTransparency oldST = st; | ||
196 | oldST.setColorSimilarity (oldColorSimilarity ()); | 202 | oldST.setColorSimilarity (oldColorSimilarity ()); | ||
197 | 203 | | |||
198 | changeImageSelectionTransparency ( | 204 | changeImageSelectionTransparency ( | ||
199 | i18n ("Selection: Transparency Color Similarity"), | 205 | i18n ("Selection: Transparency Color Similarity"), | ||
200 | st, oldST); | 206 | st, oldST); | ||
201 | } | 207 | } |