ff7tk  0.02
Toolkit for making FF7 Tools
DialogPreview.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // copyright 2012 -2016 Chris Rizzitello <sithlord48@gmail.com> //
3 // //
4 // This file is part of FF7tk //
5 // //
6 // FF7tk 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 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // FF7tk 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 
17 #include "DialogPreview.h"
18 
19 DialogPreview::DialogPreview(QWidget *parent) : QLabel(parent)
20 {
21  btn_ul = new QPushButton(this);
22  btn_ur = new QPushButton(this);
23  btn_ll = new QPushButton(this);
24  btn_lr = new QPushButton(this);
25  QString style=QString("QPushButton:enabled{background-color: rgba(0,0,0,0);border:0px solid;} QPushButton:hover{background-color:rgba(%1,%2,%3,96);}").arg(QString::number(this->palette().highlight().color().red()),QString::number(this->palette().highlight().color().green()),QString::number(this->palette().highlight().color().blue()));
26  btn_ul->setStyleSheet(style);
27  btn_ur->setStyleSheet(style);
28  btn_ll->setStyleSheet(style);
29  btn_lr->setStyleSheet(style);
30  setMinimumSize(60,30);
31  draw();
32  connect(btn_ul,SIGNAL(clicked()),this,SLOT(btn_ul_clicked()));
33  connect(btn_ur,SIGNAL(clicked()),this,SLOT(btn_ur_clicked()));
34  connect(btn_ll,SIGNAL(clicked()),this,SLOT(btn_ll_clicked()));
35  connect(btn_lr,SIGNAL(clicked()),this,SLOT(btn_lr_clicked()));
36 }
37 
38 void DialogPreview::SetLLeft(QColor color) {lower_left=color; draw(); emit LL_ColorChanged(lower_left);}
39 void DialogPreview::SetULeft(QColor color) {upper_left=color; draw(); emit UL_ColorChanged(upper_left);}
42 
43 QColor DialogPreview::ll(){return lower_left;}
44 QColor DialogPreview::lr(){return lower_right;}
45 QColor DialogPreview::ul(){return upper_left;}
46 QColor DialogPreview::ur(){return upper_right;}
47 
48 void DialogPreview::btn_ll_clicked(){QColor color = QColorDialog::getColor(lower_left,this); if(color.isValid()){SetLLeft(color);}}
49 void DialogPreview::btn_lr_clicked(){QColor color = QColorDialog::getColor(lower_right,this); if(color.isValid()){SetLRight(color);}}
50 void DialogPreview::btn_ul_clicked(){QColor color = QColorDialog::getColor(upper_left,this); if(color.isValid()){SetULeft(color);}}
51 void DialogPreview::btn_ur_clicked(){QColor color = QColorDialog::getColor(upper_right,this);if(color.isValid()){SetURight(color);}}
52 
54 {
55  QImage image(2, 2, QImage::Format_ARGB32);
56  image.setPixel(0, 0, upper_left.rgb());
57  image.setPixel(0, 1, lower_left.rgb());
58  image.setPixel(1, 0, upper_right.rgb());
59  image.setPixel(1, 1, lower_right.rgb());
60  QImage gradient = image.scaled(width(),height(),Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
61  setPixmap(QPixmap::fromImage(gradient));
62  btn_ul->setGeometry(0,0,width()/2,height()/2);
63  btn_ur->setGeometry(btn_ul->width(),0,width()/2,height()/2);
64  btn_ll->setGeometry(0,height()/2,width()/2,height()/2);
65  btn_lr->setGeometry(btn_ll->width(),height()/2,width()/2,height()/2);
66 }
67 void DialogPreview::resizeEvent(QResizeEvent*){draw();}
QColor upper_right
Definition: DialogPreview.h:47
void btn_ur_clicked()
QPushButton * btn_ur
Definition: DialogPreview.h:41
void btn_ul_clicked()
void SetURight(QColor)
QPushButton * btn_lr
Definition: DialogPreview.h:43
QColor lower_right
Definition: DialogPreview.h:49
void LR_ColorChanged(QColor color)
QColor lower_left
Definition: DialogPreview.h:48
void SetLLeft(QColor)
void btn_ll_clicked()
void LL_ColorChanged(QColor color)
QPushButton * btn_ll
Definition: DialogPreview.h:42
DialogPreview(QWidget *parent=0)
void UL_ColorChanged(QColor color)
QPushButton * btn_ul
Definition: DialogPreview.h:40
void resizeEvent(QResizeEvent *)
void UR_ColorChanged(QColor color)
void btn_lr_clicked()
QColor upper_left
Definition: DialogPreview.h:46
void SetULeft(QColor)
void SetLRight(QColor)