File indexing completed on 2024-05-12 04:19:34
0001 /* 0002 Gwenview: an image viewer 0003 Copyright 2022 Ilya Pominov <ipominov@astralinux.ru> 0004 0005 This program is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU General Public License 0007 as published by the Free Software Foundation; either version 2 0008 of the License, or (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 GNU General Public License for more details. 0014 0015 You should have received a copy of the GNU General Public License 0016 along with this program; if not, write to the Free Software 0017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 0019 */ 0020 #include "annotatedialog.h" 0021 0022 // Qt 0023 #include <QDialogButtonBox> 0024 #include <QPixmap> 0025 #include <QVBoxLayout> 0026 0027 // KImageAnnotator 0028 #include <kImageAnnotator/KImageAnnotator.h> 0029 0030 namespace Gwenview 0031 { 0032 AnnotateDialog::AnnotateDialog(QWidget *parent) 0033 : QDialog(parent) 0034 , mAnnotator(new kImageAnnotator::KImageAnnotator()) 0035 { 0036 mAnnotator->setParent(this); 0037 auto layout = new QVBoxLayout; 0038 layout->addWidget(mAnnotator); 0039 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 0040 layout->addWidget(buttonBox); 0041 setLayout(layout); 0042 connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 0043 connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 0044 } 0045 0046 AnnotateDialog::~AnnotateDialog() 0047 { 0048 delete mAnnotator; 0049 } 0050 0051 void AnnotateDialog::setImage(const QImage &image) 0052 { 0053 mAnnotator->loadImage(QPixmap::fromImage(image)); 0054 } 0055 0056 QImage AnnotateDialog::getImage() const 0057 { 0058 return mAnnotator->image(); 0059 } 0060 0061 } // namespace