Changeset View
Changeset View
Standalone View
Standalone View
dialogs/imagelib/transforms/kpTransformRotateDialog.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | { | 72 | { | ||
73 | s_lastAngleCustom = 0; | 73 | s_lastAngleCustom = 0; | ||
74 | 74 | | |||
75 | 75 | | |||
76 | createDirectionGroupBox (); | 76 | createDirectionGroupBox (); | ||
77 | createAngleGroupBox (); | 77 | createAngleGroupBox (); | ||
78 | 78 | | |||
79 | 79 | | |||
80 | if (s_lastWidth > 0 && s_lastHeight > 0) | 80 | if (s_lastWidth > 0 && s_lastHeight > 0) { | ||
81 | resize (s_lastWidth, s_lastHeight); | 81 | resize (s_lastWidth, s_lastHeight); | ||
82 | } | ||||
82 | 83 | | |||
83 | 84 | | |||
84 | slotAngleCustomRadioButtonToggled (m_angleCustomRadioButton->isChecked ()); | 85 | slotAngleCustomRadioButtonToggled (m_angleCustomRadioButton->isChecked ()); | ||
85 | slotUpdate (); | 86 | slotUpdate (); | ||
86 | } | 87 | } | ||
87 | 88 | | |||
88 | kpTransformRotateDialog::~kpTransformRotateDialog () | 89 | kpTransformRotateDialog::~kpTransformRotateDialog () | ||
89 | { | 90 | { | ||
90 | s_lastWidth = width (); | 91 | s_lastWidth = width (); | ||
91 | s_lastHeight = height (); | 92 | s_lastHeight = height (); | ||
92 | } | 93 | } | ||
93 | 94 | | |||
94 | 95 | | |||
95 | // private | 96 | // private | ||
96 | void kpTransformRotateDialog::createDirectionGroupBox () | 97 | void kpTransformRotateDialog::createDirectionGroupBox () | ||
97 | { | 98 | { | ||
98 | QGroupBox *directionGroupBox = new QGroupBox (i18n ("Direction"), mainWidget ()); | 99 | auto *directionGroupBox = new QGroupBox (i18n ("Direction"), mainWidget ()); | ||
99 | addCustomWidget (directionGroupBox); | 100 | addCustomWidget (directionGroupBox); | ||
100 | 101 | | |||
101 | 102 | | |||
102 | QLabel *antiClockwisePixmapLabel = new QLabel (directionGroupBox); | 103 | auto *antiClockwisePixmapLabel = new QLabel (directionGroupBox); | ||
103 | antiClockwisePixmapLabel->setPixmap (UserIcon ("image_rotate_anticlockwise")); | 104 | antiClockwisePixmapLabel->setPixmap (UserIcon ("image_rotate_anticlockwise")); | ||
104 | 105 | | |||
105 | QLabel *clockwisePixmapLabel = new QLabel (directionGroupBox); | 106 | auto *clockwisePixmapLabel = new QLabel (directionGroupBox); | ||
106 | clockwisePixmapLabel->setPixmap (UserIcon ("image_rotate_clockwise")); | 107 | clockwisePixmapLabel->setPixmap (UserIcon ("image_rotate_clockwise")); | ||
107 | 108 | | |||
108 | 109 | | |||
109 | m_antiClockwiseRadioButton = new QRadioButton (i18n ("Cou&nterclockwise"), directionGroupBox); | 110 | m_antiClockwiseRadioButton = new QRadioButton (i18n ("Cou&nterclockwise"), directionGroupBox); | ||
110 | m_clockwiseRadioButton = new QRadioButton (i18n ("C&lockwise"), directionGroupBox); | 111 | m_clockwiseRadioButton = new QRadioButton (i18n ("C&lockwise"), directionGroupBox); | ||
111 | 112 | | |||
112 | 113 | | |||
113 | m_antiClockwiseRadioButton->setChecked (!s_lastIsClockwise); | 114 | m_antiClockwiseRadioButton->setChecked (!s_lastIsClockwise); | ||
114 | m_clockwiseRadioButton->setChecked (s_lastIsClockwise); | 115 | m_clockwiseRadioButton->setChecked (s_lastIsClockwise); | ||
115 | 116 | | |||
116 | 117 | | |||
117 | QGridLayout *directionLayout = new QGridLayout (directionGroupBox ); | 118 | auto *directionLayout = new QGridLayout (directionGroupBox ); | ||
118 | directionLayout->addWidget (antiClockwisePixmapLabel, 0, 0, Qt::AlignCenter); | 119 | directionLayout->addWidget (antiClockwisePixmapLabel, 0, 0, Qt::AlignCenter); | ||
119 | directionLayout->addWidget (clockwisePixmapLabel, 0, 1, Qt::AlignCenter); | 120 | directionLayout->addWidget (clockwisePixmapLabel, 0, 1, Qt::AlignCenter); | ||
120 | directionLayout->addWidget (m_antiClockwiseRadioButton, 1, 0, Qt::AlignCenter); | 121 | directionLayout->addWidget (m_antiClockwiseRadioButton, 1, 0, Qt::AlignCenter); | ||
121 | directionLayout->addWidget (m_clockwiseRadioButton, 1, 1, Qt::AlignCenter); | 122 | directionLayout->addWidget (m_clockwiseRadioButton, 1, 1, Qt::AlignCenter); | ||
122 | 123 | | |||
123 | 124 | | |||
124 | connect (m_antiClockwiseRadioButton, &QRadioButton::toggled, | 125 | connect (m_antiClockwiseRadioButton, &QRadioButton::toggled, | ||
125 | this, &kpTransformRotateDialog::slotUpdate); | 126 | this, &kpTransformRotateDialog::slotUpdate); | ||
126 | 127 | | |||
127 | connect (m_clockwiseRadioButton, &QRadioButton::toggled, | 128 | connect (m_clockwiseRadioButton, &QRadioButton::toggled, | ||
128 | this, &kpTransformRotateDialog::slotUpdate); | 129 | this, &kpTransformRotateDialog::slotUpdate); | ||
129 | } | 130 | } | ||
130 | 131 | | |||
131 | // private | 132 | // private | ||
132 | void kpTransformRotateDialog::createAngleGroupBox () | 133 | void kpTransformRotateDialog::createAngleGroupBox () | ||
133 | { | 134 | { | ||
134 | QGroupBox *angleGroupBox = new QGroupBox (i18n ("Angle"), mainWidget ()); | 135 | auto *angleGroupBox = new QGroupBox (i18n ("Angle"), mainWidget ()); | ||
135 | addCustomWidget (angleGroupBox); | 136 | addCustomWidget (angleGroupBox); | ||
136 | 137 | | |||
137 | 138 | | |||
138 | m_angle90RadioButton = new QRadioButton (i18n ("90 °rees"), angleGroupBox); | 139 | m_angle90RadioButton = new QRadioButton (i18n ("90 °rees"), angleGroupBox); | ||
139 | m_angle180RadioButton = new QRadioButton (i18n ("180 d&egrees"), angleGroupBox); | 140 | m_angle180RadioButton = new QRadioButton (i18n ("180 d&egrees"), angleGroupBox); | ||
140 | m_angle270RadioButton = new QRadioButton (i18n ("270 de&grees"), angleGroupBox); | 141 | m_angle270RadioButton = new QRadioButton (i18n ("270 de&grees"), angleGroupBox); | ||
141 | 142 | | |||
142 | m_angleCustomRadioButton = new QRadioButton (i18n ("C&ustom:"), angleGroupBox); | 143 | m_angleCustomRadioButton = new QRadioButton (i18n ("C&ustom:"), angleGroupBox); | ||
143 | m_angleCustomInput = new QSpinBox; | 144 | m_angleCustomInput = new QSpinBox; | ||
144 | m_angleCustomInput->setMinimum(-359); | 145 | m_angleCustomInput->setMinimum(-359); | ||
145 | m_angleCustomInput->setMaximum(+359); | 146 | m_angleCustomInput->setMaximum(+359); | ||
146 | m_angleCustomInput->setValue(s_lastAngleCustom); | 147 | m_angleCustomInput->setValue(s_lastAngleCustom); | ||
147 | QLabel *degreesLabel = new QLabel (i18n ("degrees"), angleGroupBox); | 148 | auto *degreesLabel = new QLabel (i18n ("degrees"), angleGroupBox); | ||
148 | 149 | | |||
149 | 150 | | |||
150 | m_angleCustomRadioButton->setChecked (true); | 151 | m_angleCustomRadioButton->setChecked (true); | ||
151 | 152 | | |||
152 | 153 | | |||
153 | QGridLayout *angleLayout = new QGridLayout (angleGroupBox ); | 154 | auto *angleLayout = new QGridLayout (angleGroupBox ); | ||
154 | 155 | | |||
155 | angleLayout->addWidget (m_angle90RadioButton, 0, 0, 1, 3); | 156 | angleLayout->addWidget (m_angle90RadioButton, 0, 0, 1, 3); | ||
156 | angleLayout->addWidget (m_angle180RadioButton, 1, 0, 1, 3); | 157 | angleLayout->addWidget (m_angle180RadioButton, 1, 0, 1, 3); | ||
157 | angleLayout->addWidget (m_angle270RadioButton, 2, 0, 1, 3); | 158 | angleLayout->addWidget (m_angle270RadioButton, 2, 0, 1, 3); | ||
158 | 159 | | |||
159 | angleLayout->addWidget (m_angleCustomRadioButton, 3, 0); | 160 | angleLayout->addWidget (m_angleCustomRadioButton, 3, 0); | ||
160 | angleLayout->addWidget (m_angleCustomInput, 3, 1); | 161 | angleLayout->addWidget (m_angleCustomInput, 3, 1); | ||
161 | angleLayout->addWidget (degreesLabel, 3, 2); | 162 | angleLayout->addWidget (degreesLabel, 3, 2); | ||
Show All 27 Lines | |||||
189 | } | 190 | } | ||
190 | 191 | | |||
191 | // public | 192 | // public | ||
192 | int kpTransformRotateDialog::angle () const | 193 | int kpTransformRotateDialog::angle () const | ||
193 | { | 194 | { | ||
194 | int retAngle; | 195 | int retAngle; | ||
195 | 196 | | |||
196 | 197 | | |||
197 | if (m_angle90RadioButton->isChecked ()) | 198 | if (m_angle90RadioButton->isChecked ()) { | ||
198 | retAngle = 90; | 199 | retAngle = 90; | ||
199 | else if (m_angle180RadioButton->isChecked ()) | 200 | } | ||
201 | else if (m_angle180RadioButton->isChecked ()) { | ||||
200 | retAngle = 180; | 202 | retAngle = 180; | ||
201 | else if (m_angle270RadioButton->isChecked ()) | 203 | } | ||
204 | else if (m_angle270RadioButton->isChecked ()) { | ||||
202 | retAngle = 270; | 205 | retAngle = 270; | ||
203 | else // if (m_angleCustomRadioButton->isChecked ()) | 206 | } | ||
207 | else { // if (m_angleCustomRadioButton->isChecked ()) | ||||
204 | retAngle = m_angleCustomInput->value (); | 208 | retAngle = m_angleCustomInput->value (); | ||
209 | } | ||||
205 | 210 | | |||
206 | 211 | | |||
207 | if (m_antiClockwiseRadioButton->isChecked ()) | 212 | if (m_antiClockwiseRadioButton->isChecked ()) { | ||
208 | retAngle *= -1; | 213 | retAngle *= -1; | ||
214 | } | ||||
209 | 215 | | |||
210 | 216 | | |||
211 | if (retAngle < 0) | 217 | if (retAngle < 0) { | ||
212 | retAngle += ((0 - retAngle) / 360 + 1) * 360; | 218 | retAngle += ((0 - retAngle) / 360 + 1) * 360; | ||
219 | } | ||||
213 | 220 | | |||
214 | if (retAngle >= 360) | 221 | if (retAngle >= 360) { | ||
215 | retAngle -= ((retAngle - 360) / 360 + 1) * 360; | 222 | retAngle -= ((retAngle - 360) / 360 + 1) * 360; | ||
223 | } | ||||
216 | 224 | | |||
217 | 225 | | |||
218 | return retAngle; | 226 | return retAngle; | ||
219 | } | 227 | } | ||
220 | 228 | | |||
221 | 229 | | |||
222 | // private virtual [base kpTransformPreviewDialog] | 230 | // private virtual [base kpTransformPreviewDialog] | ||
223 | QSize kpTransformRotateDialog::newDimensions () const | 231 | QSize kpTransformRotateDialog::newDimensions () const | ||
Show All 13 Lines | |||||
237 | } | 245 | } | ||
238 | 246 | | |||
239 | 247 | | |||
240 | // private slot | 248 | // private slot | ||
241 | void kpTransformRotateDialog::slotAngleCustomRadioButtonToggled (bool isChecked) | 249 | void kpTransformRotateDialog::slotAngleCustomRadioButtonToggled (bool isChecked) | ||
242 | { | 250 | { | ||
243 | m_angleCustomInput->setEnabled (isChecked); | 251 | m_angleCustomInput->setEnabled (isChecked); | ||
244 | 252 | | |||
245 | if (isChecked) | 253 | if (isChecked) { | ||
246 | m_angleCustomInput->setFocus(); | 254 | m_angleCustomInput->setFocus(); | ||
247 | } | 255 | } | ||
256 | } | ||||
248 | 257 | | |||
249 | // private slot virtual [base kpTransformPreviewDialog] | 258 | // private slot virtual [base kpTransformPreviewDialog] | ||
250 | void kpTransformRotateDialog::slotUpdate () | 259 | void kpTransformRotateDialog::slotUpdate () | ||
251 | { | 260 | { | ||
252 | s_lastIsClockwise = m_clockwiseRadioButton->isChecked (); | 261 | s_lastIsClockwise = m_clockwiseRadioButton->isChecked (); | ||
253 | s_lastAngleCustom = m_angleCustomInput->value (); | 262 | s_lastAngleCustom = m_angleCustomInput->value (); | ||
254 | 263 | | |||
255 | kpTransformPreviewDialog::slotUpdate (); | 264 | kpTransformPreviewDialog::slotUpdate (); | ||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |