Kstars

thumbnaileditor.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "thumbnaileditor.h"
8
9#include "thumbnailpicker.h"
10#include "ui_thumbnaileditor.h"
11
12#include <KLocalizedString>
13
14#include <QHBoxLayout>
15#include <QLabel>
16#include <QMouseEvent>
17#include <QPaintEvent>
18#include <QPixmap>
19
20#include <QDebug>
21#include <QDialogButtonBox>
22#include <QPushButton>
23
24ThumbnailEditorUI::ThumbnailEditorUI(QWidget *parent) : QFrame(parent)
25{
26 setupUi(this);
27}
28
29ThumbnailEditor::ThumbnailEditor(ThumbnailPicker *_tp, double _w, double _h) : QDialog(_tp), tp(_tp)
30{
31#ifdef Q_OS_MACOS
32 setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint);
33#endif
34 ui = new ThumbnailEditorUI(this);
35 w = _w;
36 h = _h;
37 ui->MessageLabel->setText(i18n("Crop region will be scaled to [ %1 * %2 ]", w, h));
38
39 setWindowTitle(i18nc("@title:window", "Edit Thumbnail Image"));
40 QVBoxLayout *mainLayout = new QVBoxLayout;
41 mainLayout->addWidget(ui);
42 setLayout(mainLayout);
43
45 mainLayout->addWidget(buttonBox);
46 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
47 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
48
49 ui->ImageCanvas->setCropRect(tp->imageRect()->x(), tp->imageRect()->y(), tp->imageRect()->width(),
50 tp->imageRect()->height());
51 ui->ImageCanvas->setImage(tp->currentListImage());
52
53 //DEBUG
54 //qDebug() << Q_FUNC_INFO << tp->currentListImage()->size();
55
56 connect(ui->ImageCanvas, SIGNAL(cropRegionModified()), SLOT(slotUpdateCropLabel()));
57 slotUpdateCropLabel();
58
59 update();
60}
61
62QPixmap ThumbnailEditor::thumbnail()
63{
64 QImage im = ui->ImageCanvas->croppedImage().toImage();
66 return QPixmap::fromImage(im);
67}
68
69void ThumbnailEditor::slotUpdateCropLabel()
70{
71 QRect *r = ui->ImageCanvas->cropRect();
72 ui->CropLabel->setText(i18n("Crop region: [%1,%2 %3x%4]", r->left(), r->top(), r->width(), r->height()));
73}
Dialog for modifying an object's thumbnail image.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void update(Part *part, const QByteArray &data, qint64 dataSize)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
QImage scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const const
QPixmap fromImage(QImage &&image, Qt::ImageConversionFlags flags)
int height() const const
int left() const const
int top() const const
int width() const const
IgnoreAspectRatio
SmoothTransformation
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.