1 /**
2 * This file is a part of Luminance HDR package.
3 * ----------------------------------------------------------------------
4 * Copyright (C) 2009 Franco Comida
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * ----------------------------------------------------------------------
20 *
21 * @author Franco Comida <fcomida@users.sourceforge.net>
22 */
23
24 #include <QMenu>
25
26 #include "PreviewLabel.h"
27
PreviewLabel(QWidget * parent,TMOperator tm_operator)28 PreviewLabel::PreviewLabel(QWidget *parent, TMOperator tm_operator)
29 : QLabel(parent),
30 m_TMOptions(new TonemappingOptions),
31 m_index(-1),
32 m_isFromPanel(true) {
33 m_TMOptions->tmoperator = tm_operator;
34 }
35
PreviewLabel(QWidget * parent,TonemappingOptions * tonemappingOptions,int index)36 PreviewLabel::PreviewLabel(QWidget *parent,
37 TonemappingOptions *tonemappingOptions, int index)
38 : QLabel(parent),
39 m_TMOptions(tonemappingOptions),
40 m_index(index),
41 m_isFromPanel(false) {}
42
~PreviewLabel()43 PreviewLabel::~PreviewLabel() { delete m_TMOptions; }
44
mousePressEvent(QMouseEvent * event)45 void PreviewLabel::mousePressEvent(QMouseEvent *event) {
46 if (event->buttons() == Qt::LeftButton) {
47 (m_isFromPanel) ? emit clicked(m_TMOptions) : emit clicked(m_index);
48 } else if (event->buttons() == Qt::RightButton) {
49 QMenu menu(this);
50 menu.addActions(actions());
51 menu.exec(event->globalPos());
52 }
53 }
54
mouseDoubleClickEvent(QMouseEvent * event)55 void PreviewLabel::mouseDoubleClickEvent(QMouseEvent *event) {
56 emit clicked(m_TMOptions);
57 }
58
assignNewQImage(QSharedPointer<QImage> new_qimage)59 void PreviewLabel::assignNewQImage(QSharedPointer<QImage> new_qimage) {
60 setPixmap(QPixmap::fromImage(*new_qimage));
61 adjustSize();
62 }
63
setComment(QString comment)64 void PreviewLabel::setComment(QString comment) { m_comment = comment; }
65
getComment()66 QString PreviewLabel::getComment() { return m_comment; }
67
setIndex(int index)68 void PreviewLabel::setIndex(int index) { m_index = index; }
69