ff7tk  0.02
Toolkit for making FF7 Tools
SlotPreview.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 #include "SlotPreview.h"
17 SlotPreview::SlotPreview(int index,qreal Scale, QWidget *parent):QLabel(parent)
18 {
19  scale=Scale;
20  Final = new QVBoxLayout();
21  Final->setContentsMargins(2,2,2,2);
22  setIndex(index);
23  setLayout(Final);
24  setFixedSize(582*scale,135*scale);
25  setStyleSheet(QString("SlotPreview{border:%1px solid;}").arg(QString::number(3*scale)));
26  setCursor(Qt::PointingHandCursor);
27 }
28 
30 {
31  lbl_Slot = new QLabel;
32  lbl_Slot->setText(QString(tr("Slot: %1")).arg(QString::number(index()+1)));
33 
34  btn_remove = new QPushButton(QIcon::fromTheme(QString("edit-clear"),QPixmap(":/common/edit-clear")),"",this);
35  btn_remove->setStyleSheet("QPushButton{border:1px solid;}");
36  btn_remove->setToolTip(tr("Clear Slot"));
37  btn_remove->setMaximumSize(22*scale,22*scale);
38  btn_remove->setCursor(Qt::BitmapCursor);
39 
40  btn_copy = new QPushButton(QIcon::fromTheme(QString("edit-copy"),QPixmap(":/common/edit-copy")),"",this);
41  btn_copy->setStyleSheet("QPushButton{border:1px solid;}");
42  btn_copy->setToolTip(tr("Copy Slot"));
43  btn_copy->setMaximumSize(22*scale,22*scale);
44  btn_copy->setCursor(Qt::BitmapCursor);
45 
46  btn_paste = new QPushButton(QIcon::fromTheme(QString("edit-paste"),QPixmap(":/common/edit-paste")),"",this);
47  btn_paste->setStyleSheet("QPushButton{border:1px solid;}");
48  btn_paste->setToolTip(tr("Paste Into Slot"));
49  btn_paste->setMaximumSize(22*scale,22*scale);
50  btn_paste->setCursor(Qt::BitmapCursor);
51 
52  btnLayout = new QHBoxLayout;
53  btnLayout->setContentsMargins(3,0,3,0);
54  btnLayout->addWidget(lbl_Slot);
55  btnLayout->addWidget(btn_copy);
56  btnLayout->addWidget(btn_paste);
57  btnLayout->addWidget(btn_remove);
58 
59  btn_remove->setHidden(true);
60  btn_copy->setHidden(true);
61  btn_paste->setHidden(true);
62 
63  connect(btn_remove,SIGNAL(clicked()),this,SLOT(removed()));
64  connect(btn_copy,SIGNAL(clicked()),this,SLOT(copy()));
65  connect(btn_paste,SIGNAL(clicked()),this,SLOT(paste()));
66 }
67 void SlotPreview::setMode(int mode)
68 {
69  switch(mode)
70  {
71  case 0: set_empty(); break;
72  case 1: set_psx_game();break;
73  case 2: set_ff7_save();break;
74  }
75 }
77 {
78  init_display();
79  btn_paste->setHidden(false);
80  lbl_Slot->setStyleSheet(QString("font: 75 14pt \"Verdana\";"));
81  QString style=QString("font: 75 14pt \"Verdana\"; color:yellow;");
82  location=new QLabel(tr("-Empty-"));
83  location->setStyleSheet(style);
84  QVBoxLayout *empty_layout = new QVBoxLayout;
85  empty_layout->setContentsMargins(12,12,12,12);
86  empty_layout->addWidget(location);
87  top_layout = new QVBoxLayout;
88  top_layout->setContentsMargins(6,0,0,0);
89  top_layout->addLayout(btnLayout);
90  top_layout->addItem(empty_layout);
91  Final->addLayout(top_layout);
92 }
93 
95 {
96  init_display();
97  lbl_Slot->setStyleSheet(QString("font: 75 14pt \"Verdana\";"));
98  btn_remove->setHidden(false);
99  btn_paste->setHidden(false);
100  icon= new SaveIcon;
101  QString style="font-size: 10pt;";
102  party1 = new QLabel;
103  party1->setFixedSize(96*scale,96*scale);
104  connect(icon,SIGNAL(nextIcon(QPixmap)),this,SLOT(set_Party1(QPixmap)));
105  location = new QLabel;
106  location->setStyleSheet(style);
107  QHBoxLayout *layout = new QHBoxLayout;
108  layout->setContentsMargins(0,0,0,0);
109  layout->addWidget(party1);
110  layout->addWidget(location);
111  top_layout= new QVBoxLayout;
112  top_layout->setContentsMargins(6,0,0,0);
113  top_layout->setSpacing(3);
114  top_layout->addLayout(btnLayout);
115  top_layout->addItem(layout);
116  Final->addLayout(top_layout);
117 }
118 
120 {
121  init_display();
122  lbl_Slot->setStyleSheet(QString("background-color:rgba(0,0,0,0);font: 75 14pt \"Verdana\";color:white"));
123  QString style=QString("background-color:rgba(0,0,0,0);font: 75 14pt \"Verdana\";color:white");
124 
125  party1 = new QLabel;
126  party1->setFixedSize(84*scale,96*scale);
127  party1->setStyleSheet(style);
128 
129  party2 = new QLabel;
130  party2->setFixedSize(84*scale,96*scale);
131  party2->setStyleSheet(style);
132 
133  party3 = new QLabel;
134  party3->setFixedSize(84*scale,96*scale);
135  party3->setStyleSheet(style);
136 
137  lbl_gil = new QLabel;
138  lbl_gil->setStyleSheet(style);
139  lbl_gil->setAlignment(Qt::AlignCenter);
140 
141  name = new QLabel;
142  name->setStyleSheet(style);
143  name->setAlignment(Qt::AlignCenter);
144 
145  lbl_time = new QLabel;
146  lbl_time->setStyleSheet(style);
147  lbl_time->setAlignment(Qt::AlignCenter);
148 
149  lbl_level = new QLabel;
150  lbl_level->setStyleSheet(style);
151  lbl_level->setAlignment(Qt::AlignCenter);
152 
153  location = new QLabel;
154  location->setStyleSheet(style);
155  location->setAlignment(Qt::AlignCenter);
156 
157  QHBoxLayout *partybox = new QHBoxLayout;
158  partybox->addWidget(party1);
159  partybox->addWidget(party2);
160  partybox->addWidget(party3);
161 
162  QHBoxLayout *levelgilbox = new QHBoxLayout;
163  levelgilbox->setContentsMargins(0,0,0,0);
164  levelgilbox->setSpacing(0);
165  levelgilbox->addWidget(lbl_level);
166  levelgilbox->addWidget(lbl_gil);
167 
168  QHBoxLayout *nametimebox =new QHBoxLayout;
169  nametimebox->setContentsMargins(0,0,0,0);
170  nametimebox->setSpacing(0);
171  nametimebox->addWidget(name);
172  nametimebox->addWidget(lbl_time);
173 
174  QVBoxLayout *upperhalf = new QVBoxLayout;
175  upperhalf->addLayout(nametimebox);
176  upperhalf->addLayout(levelgilbox);
177  upperhalf->addWidget(location);
178 
179  QHBoxLayout *midbox = new QHBoxLayout;
180  midbox->addLayout(partybox);
181  midbox->addLayout(upperhalf);
182 
183  btn_remove->setHidden(false);
184  btn_paste->setHidden(false);
185  btn_copy->setHidden(false);
186 
187  top_layout = new QVBoxLayout;
188  top_layout->addLayout(btnLayout);
189  top_layout->addLayout(midbox);
190  top_layout->addWidget(lbl_Slot);
191  top_layout->setContentsMargins(6,0,0,0);
192  top_layout->setSpacing(3);
193  Final->addLayout(top_layout);
194 }
195 
196 void SlotPreview::setParty(QPixmap p1,QPixmap p2,QPixmap p3)
197 {
198  this->set_Party1(p1.scaled(party1->width(),party1->height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
199  this->set_Party2(p2.scaled(party2->width(),party2->height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
200  this->set_Party3(p3.scaled(party3->width(),party3->height(),Qt::KeepAspectRatio,Qt::SmoothTransformation));
201 }
202 
203 void SlotPreview::setParty(QString p1_style,QString p2_style,QString p3_style)
204 {
205  this->set_Party1(p1_style);
206  this->set_Party2(p2_style);
207  this->set_Party3(p3_style);
208 }
209 
210 void SlotPreview::setIndex(int index){this->setObjectName(QString::number(index));}
211 int SlotPreview::index(void){return this->objectName().toInt();}
212 void SlotPreview::set_Party1(QPixmap pix){party1->setPixmap(pix.scaled(party1->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));}
213 void SlotPreview::set_Party1(QString style){party1->setStyleSheet(style);}
214 void SlotPreview::set_Party2(QPixmap pix){party2->setPixmap(pix.scaled(party2->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));}
215 void SlotPreview::set_Party2(QString style){party2->setStyleSheet(style);}
216 void SlotPreview::set_Party3(QPixmap pix){party3->setPixmap(pix.scaled(party3->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));}
217 void SlotPreview::set_Party3(QString style){party3->setStyleSheet(style);}
218 void SlotPreview::setName(QString Name){name->setText(Name);}
219 void SlotPreview::setLevel(int lvl){lbl_level->setText(QString(tr("Level:%1")).arg(QString::number(lvl)));}
220 void SlotPreview::setLocation(QString loc){location->setText(loc);}
221 void SlotPreview::setGil(int gil){lbl_gil->setText(QString(tr("Gil:%1")).arg(QString::number(gil)));}
222 void SlotPreview::setTime(int hr,int min){lbl_time->setText(QString(tr("Time:%1:%2")).arg(QString::number(hr),QString("%1").arg(QString::number(min),2,QChar('0'))));}
226 void SlotPreview::setPsxIcon(QByteArray icon_data,quint8 frames){icon->setAll(icon_data,frames);party1->setPixmap(icon->icon().scaled(party1->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));}
227 void SlotPreview::setPsxIcon(QList<QByteArray> icon_data){icon->setAll(icon_data);party1->setPixmap(icon->icon().scaled(party1->size(),Qt::KeepAspectRatio,Qt::SmoothTransformation));}
228 void SlotPreview::mousePressEvent(QMouseEvent *ev){if(ev->button() ==Qt::LeftButton){emit clicked(index());}}
void set_empty(void)
Definition: SlotPreview.cpp:76
void btn_paste_clicked(int)
Signal: User Clicked on paste .
void set_Party1(QPixmap)
QVBoxLayout * Final
Definition: SlotPreview.h:85
void setAll(QByteArray data, quint8 nbFrames=1)
fill SaveIcon with data
Definition: SaveIcon.cpp:38
QLabel * party1
Definition: SlotPreview.h:71
QPixmap icon(bool chocobo_world_icon=false)
pixmap of your icon
Definition: SaveIcon.cpp:68
void setPsxIcon(QByteArray icon_data, quint8 frames=1)
QLabel * lbl_level
Definition: SlotPreview.h:77
void set_ff7_save(void)
QPushButton * btn_copy
Definition: SlotPreview.h:80
void mousePressEvent(QMouseEvent *ev)
qreal scale
Definition: SlotPreview.h:88
void setLocation(QString)
void setTime(int hour, int min)
void removed(void)
void setMode(int mode)
Definition: SlotPreview.cpp:67
void setIndex(int index)
QLabel * location
Definition: SlotPreview.h:78
void copy(void)
QLabel * party2
Definition: SlotPreview.h:72
void paste(void)
QLabel * lbl_time
Definition: SlotPreview.h:76
QPushButton * btn_remove
Definition: SlotPreview.h:82
QLabel * lbl_Slot
Definition: SlotPreview.h:75
void setGil(int)
void setName(QString)
QLabel * party3
Definition: SlotPreview.h:73
void btn_copy_clicked(int)
Signal: User Clicked on copy .
int index(void)
void set_Party3(QPixmap)
void init_display(void)
Definition: SlotPreview.cpp:29
QHBoxLayout * btnLayout
Definition: SlotPreview.h:84
SaveIcon * icon
Definition: SlotPreview.h:83
void clicked(int)
Signal: User Clicked on preview .
QLabel * lbl_gil
Definition: SlotPreview.h:79
QLabel * name
Definition: SlotPreview.h:74
void setLevel(int)
void setParty(QPixmap p1, QPixmap p2, QPixmap p3)
void set_psx_game(void)
Definition: SlotPreview.cpp:94
PSX icon data as a QPixmap.
Definition: SaveIcon.h:26
void btn_remove_clicked(int)
Signal: User Clicked on remove .
QVBoxLayout * top_layout
Definition: SlotPreview.h:86
SlotPreview(int index=0, qreal Scale=1, QWidget *parent=0)
Definition: SlotPreview.cpp:17
QPushButton * btn_paste
Definition: SlotPreview.h:81
void set_Party2(QPixmap)