1 /*
2 * Copyright (C) 2021 Damir Porobic <damir.porobic@gmx.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "RotateWidget.h"
21
22 namespace kImageAnnotator {
23
RotateWidget()24 RotateWidget::RotateWidget() :
25 mAnnotationArea(nullptr),
26 mView(new QGraphicsView),
27 mMainLayout(new QVBoxLayout(this))
28 {
29 initGui();
30 }
31
~RotateWidget()32 RotateWidget::~RotateWidget()
33 {
34 delete mView;
35 }
36
activate(AnnotationArea * annotationArea)37 void RotateWidget::activate(AnnotationArea *annotationArea)
38 {
39 Q_ASSERT(annotationArea != nullptr);
40
41 mAnnotationArea = annotationArea;
42 mView->setScene(annotationArea);
43 showDialog();
44 }
45
initGui()46 void RotateWidget::initGui()
47 {
48 mMainLayout->addWidget(mView);
49 setLayout(mMainLayout);
50 }
51
showDialog()52 void RotateWidget::showDialog()
53 {
54 RotateDialog rotateDialog(this);
55 connect(&rotateDialog, &RotateDialog::rotate, this, &RotateWidget::rotate);
56 connect(&rotateDialog, &RotateDialog::flip, this, &RotateWidget::flip);
57 rotateDialog.exec();
58
59 emit closing();
60 }
61
rotate(qreal angel)62 void RotateWidget::rotate(qreal angel)
63 {
64 Q_ASSERT(mAnnotationArea != nullptr);
65
66 mAnnotationArea->rotate(angel);
67 }
68
flip(FlipDirection direction)69 void RotateWidget::flip(FlipDirection direction)
70 {
71 Q_ASSERT(mAnnotationArea != nullptr);
72
73 mAnnotationArea->flip(direction);
74 }
75
76 } // namespace kImageAnnotator