add of fiche button
This commit is contained in:
parent
646ec2fb0c
commit
24c4685cb2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -5,7 +5,9 @@
|
||||
#include <QJsonArray>
|
||||
#include <QDebug>
|
||||
|
||||
Character::Character(){
|
||||
Character::Character()
|
||||
: age(0), niveau(0), taille(0), vie(0)
|
||||
{
|
||||
for(int i = 0; i<6; i++){skills.append(0);}
|
||||
for(int i = 0; i<6; i++){skillsMod.append(0);}
|
||||
for(int i = 0; i<18; i++){stats.append(0);}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <QList>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Character{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"age": 1,
|
||||
"backPack": "ssdgfsdgd",
|
||||
"backPack": "'(y'eyhrhyrhr",
|
||||
"blocNote": "'(y'eyhrhyrhr",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
|
||||
49
data/fuu.txt
Normal file
49
data/fuu.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "dgdfg",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/m.txt
Normal file
49
data/m.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "ssfsf",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/mn.txt
Normal file
49
data/mn.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "ssfsf",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/moi.txt
Normal file
49
data/moi.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/mp.txt
Normal file
49
data/mp.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "ccc",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/n.txt
Normal file
49
data/n.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/o.txt
Normal file
49
data/o.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/ok.txt
Normal file
49
data/ok.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "s",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/pl.txt
Normal file
49
data/pl.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "zhfzui",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/po
Normal file
49
data/po
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/s.txt
Normal file
49
data/s.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/t.txt
Normal file
49
data/t.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/v.txt
Normal file
49
data/v.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
49
data/wq.txt
Normal file
49
data/wq.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "fsfs",
|
||||
"niveau": 0,
|
||||
"race": "",
|
||||
"sexe": "",
|
||||
"skills": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"skillsMod": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"stats": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"taille": 0,
|
||||
"vie": 0
|
||||
}
|
||||
136
mainwindow.cpp
136
mainwindow.cpp
@ -8,6 +8,8 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -16,29 +18,31 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
addWindow();
|
||||
notePad = new NotePad();
|
||||
connect(notePad, &NotePad::demandeSauvegarde, this, &MainWindow::recevoirSauvegarde);
|
||||
Character* c = new Character();
|
||||
currentCharacter = c;
|
||||
characters.append(c);
|
||||
currentFile = QString();
|
||||
files.append(currentFile);
|
||||
ui->ageLineEdit->setValidator(new QIntValidator(0, 999999, ui->ageLineEdit));
|
||||
ui->niveauLineEdit->setValidator(new QIntValidator(0, 999999, ui->niveauLineEdit));
|
||||
ui->tailleLineEdit->setValidator(new QDoubleValidator(0.0, 999999.0, 1,ui->tailleLineEdit));
|
||||
ui->BackPack->setHidden(true);
|
||||
|
||||
|
||||
loadImage(QString("data/images/logo.png"));
|
||||
ui->Fenetre->setStyleSheet("background-color: #f2f2f2;");
|
||||
qobject_cast<QPushButton*>(ui->Fenetre->children()[0])->setStyleSheet("background-color: white;");
|
||||
}
|
||||
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
delete notePad;
|
||||
delete currentCharacter;
|
||||
|
||||
for(Character* c : characters) {
|
||||
delete c;
|
||||
}
|
||||
for(Character* c : characters) {delete c;}
|
||||
}
|
||||
|
||||
|
||||
@ -57,16 +61,27 @@ void MainWindow::loadNewCharacter(){
|
||||
Character* c = new Character(&file);
|
||||
currentCharacter = c;
|
||||
characters.append(c);
|
||||
createNewCharacter(c);
|
||||
currentFile = fileName;
|
||||
files.append(fileName);
|
||||
createNewCharacter(c, fileName);
|
||||
}
|
||||
|
||||
void MainWindow::createNewCharacter(Character* p) {
|
||||
void MainWindow::createNewCharacter(Character* p, QString s) {
|
||||
addWindow(s);
|
||||
notePad->setTexte(p->getTexteBlocNote());
|
||||
ui->BackPackPlainTextEdit->setPlainText(p->getTexteBlocNote());
|
||||
currentCharacter = p;
|
||||
characters.append(p);
|
||||
setUi(p);
|
||||
if(s.toStdString() == ""){
|
||||
currentCharacter = p;
|
||||
characters.append(p);
|
||||
currentFile = s;
|
||||
files.append(s);
|
||||
}
|
||||
for(int i=0; i<ui->Fenetre->children().size(); i++){
|
||||
QPushButton* bt = qobject_cast<QPushButton*>(ui->Fenetre->children()[i]);
|
||||
bt->setStyleSheet("background-color: #f2f2f2;");
|
||||
}
|
||||
qobject_cast<QPushButton*>(ui->Fenetre->children()[ui->Fenetre->children().size()-1])->setStyleSheet("background-color: white;");
|
||||
}
|
||||
|
||||
|
||||
@ -95,7 +110,15 @@ void MainWindow::loadImage(QString fileName) {
|
||||
|
||||
void MainWindow::saveJson(){
|
||||
QString fileName;
|
||||
if (currentFile.isEmpty()) {
|
||||
|
||||
int indice = 0;
|
||||
for (int i = 0; i < characters.size(); ++i) {
|
||||
if (characters[i] == currentCharacter) {
|
||||
indice = i;
|
||||
}
|
||||
}
|
||||
QPushButton* button = qobject_cast<QPushButton*>(ui->Fenetre->children()[indice]);
|
||||
if (button->objectName().toStdString() == "") {
|
||||
fileName = QFileDialog::getSaveFileName(this, "Save");
|
||||
currentFile = fileName;
|
||||
} else {
|
||||
@ -107,6 +130,7 @@ void MainWindow::saveJson(){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
getUi();
|
||||
notePad->getUi();
|
||||
currentCharacter->setTexteBlocNote(notePad->getTexte());
|
||||
@ -142,6 +166,14 @@ void MainWindow::saveJson(){
|
||||
QJsonDocument doc(json);
|
||||
file.write(doc.toJson());
|
||||
file.close();
|
||||
if (button) {
|
||||
if (button->objectName() != currentFile) {
|
||||
std::cout << "oui" << std::endl;
|
||||
button->setObjectName(currentFile);
|
||||
button->setText(extractFileName(currentFile));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::saveAsJson(){
|
||||
@ -190,6 +222,22 @@ void MainWindow::saveAsJson(){
|
||||
QJsonDocument doc(json);
|
||||
file.write(doc.toJson());
|
||||
file.close();
|
||||
|
||||
int indice = 0;
|
||||
for (int i = 0; i < characters.size(); ++i) {
|
||||
if (characters[i] == currentCharacter) {
|
||||
indice = i;
|
||||
}
|
||||
}
|
||||
QPushButton* button = qobject_cast<QPushButton*>(ui->Fenetre->children()[indice]);
|
||||
|
||||
if (button) {
|
||||
if (button->objectName() != currentFile) {
|
||||
button->setObjectName(currentFile);
|
||||
button->setText(extractFileName(currentFile));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +277,6 @@ void MainWindow::getUi(){
|
||||
}
|
||||
currentCharacter->setStats(stats);
|
||||
currentCharacter->setTexteBackPack(ui->BackPackPlainTextEdit->toPlainText());
|
||||
//currentCharacter->setImage();
|
||||
}
|
||||
|
||||
|
||||
@ -292,6 +339,67 @@ void MainWindow::on_actionNouvelle_fiche_triggered(){this->createNewCharacter(ne
|
||||
void MainWindow::on_actionSauvegarder_triggered(){this->saveJson();}
|
||||
void MainWindow::on_actionEnregistrer_sous_triggered(){this->saveAsJson();}
|
||||
void MainWindow::on_actionFermer_triggered(){QApplication::quit();}
|
||||
void MainWindow::on_actionBlocNote_triggered(){this->notePad->show();}
|
||||
void MainWindow::on_actionBackPack_triggered(){this->toogleBackPack();}
|
||||
|
||||
void MainWindow::on_imagePushButton_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Open the file");
|
||||
if (fileName.isEmpty()) return;
|
||||
this->loadImage(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionBloc_note_triggered(){this->notePad->show();}
|
||||
void MainWindow::on_actionCaract_ristiques_triggered(){this->toogleBackPack();}
|
||||
|
||||
void MainWindow::addWindow(const QString& s){
|
||||
int nb = ui->Fenetre->children().size();
|
||||
QPushButton* button;
|
||||
if(s == ""){
|
||||
button = new QPushButton("Sans titre", ui->Fenetre);
|
||||
button->setObjectName(QString());
|
||||
}else{
|
||||
button = new QPushButton(extractFileName(s), ui->Fenetre);
|
||||
button->setObjectName(s);
|
||||
}
|
||||
button->setFixedSize(100, 35);
|
||||
button->move(nb * 100, 0);
|
||||
button->setProperty("id", idFicheButtonCounter);
|
||||
button->show();
|
||||
connect(button, &QPushButton::clicked, this, &MainWindow::changer_fiche_clicked);
|
||||
idFicheButtonCounter++;
|
||||
}
|
||||
|
||||
|
||||
QString MainWindow::extractFileName(QString s){
|
||||
QFileInfo infoFichier(s);
|
||||
return infoFichier.fileName();
|
||||
}
|
||||
|
||||
void MainWindow::changer_fiche_clicked(){
|
||||
changeCurrentChracter();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::changeCurrentChracter(){
|
||||
getUi();
|
||||
notePad->getUi();
|
||||
currentCharacter->setTexteBlocNote(notePad->getTexte());
|
||||
|
||||
QPushButton* button = qobject_cast<QPushButton*>(sender());
|
||||
if (!button) return;
|
||||
int index = button->property("id").toInt();
|
||||
if (index >= 0 && index < characters.size()) {
|
||||
currentCharacter = characters[index];
|
||||
currentFile = files[index];
|
||||
setUi(currentCharacter);
|
||||
notePad->setUi(currentCharacter->getTexteBlocNote());
|
||||
} else {
|
||||
qWarning("ID de fiche invalide !");
|
||||
}
|
||||
|
||||
for(int i=0; i<ui->Fenetre->children().size(); i++){
|
||||
QPushButton* bt = qobject_cast<QPushButton*>(ui->Fenetre->children()[i]);
|
||||
bt->setStyleSheet("background-color: #f2f2f2;");
|
||||
}
|
||||
button->setStyleSheet("background-color: white;");
|
||||
}
|
||||
|
||||
|
||||
14
mainwindow.h
14
mainwindow.h
@ -21,24 +21,28 @@ public:
|
||||
~MainWindow();
|
||||
|
||||
void loadImage(QString fileName);
|
||||
void createNewCharacter(Character* p);
|
||||
void createNewCharacter(Character* p, QString s = QString());
|
||||
void loadNewCharacter();
|
||||
void saveJson();
|
||||
void saveAsJson();
|
||||
void getUi();
|
||||
void setUi(Character* p);
|
||||
void toogleBackPack();
|
||||
void addWindow(const QString& s = QString());
|
||||
QString extractFileName(QString s);
|
||||
void changeCurrentChracter();
|
||||
|
||||
private slots:
|
||||
void on_actionBlocNote_triggered();
|
||||
void on_actionOuvrir_une_fiche_triggered();
|
||||
void on_actionNouvelle_fiche_triggered();
|
||||
void on_actionSauvegarder_triggered();
|
||||
void on_actionEnregistrer_sous_triggered();
|
||||
void on_actionFermer_triggered();
|
||||
void on_actionBackPack_triggered();
|
||||
|
||||
void on_imagePushButton_clicked();
|
||||
void recevoirSauvegarde(QString contenu);
|
||||
void on_actionBloc_note_triggered();
|
||||
void on_actionCaract_ristiques_triggered();
|
||||
void changer_fiche_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
@ -47,6 +51,8 @@ private:
|
||||
bool edition = true;
|
||||
QString currentFile;
|
||||
QList<Character*> characters;
|
||||
QList<QString> files;
|
||||
Character* currentCharacter;
|
||||
int idFicheButtonCounter = 0;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
125
mainwindow.ui
125
mainwindow.ui
@ -21,7 +21,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>35</y>
|
||||
<width>800</width>
|
||||
<height>590</height>
|
||||
</rect>
|
||||
@ -49,7 +49,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<width>390</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -59,7 +59,7 @@
|
||||
<widget class="QLabel" name="ageLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<x>190</x>
|
||||
<y>54</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
@ -79,7 +79,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Logo</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
@ -88,7 +88,7 @@
|
||||
<widget class="QLabel" name="nomLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<x>190</x>
|
||||
<y>17</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
@ -101,7 +101,7 @@
|
||||
<widget class="QLineEdit" name="nomLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<x>250</x>
|
||||
<y>17</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
@ -111,7 +111,7 @@
|
||||
<widget class="QLineEdit" name="ageLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<x>250</x>
|
||||
<y>54</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
@ -121,7 +121,7 @@
|
||||
<widget class="QLabel" name="raceLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<x>190</x>
|
||||
<y>91</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
@ -134,7 +134,7 @@
|
||||
<widget class="QLabel" name="niveauLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<x>190</x>
|
||||
<y>165</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
@ -147,7 +147,7 @@
|
||||
<widget class="QLabel" name="classeLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<x>190</x>
|
||||
<y>128</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
@ -160,7 +160,7 @@
|
||||
<widget class="QLabel" name="sexeLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<x>190</x>
|
||||
<y>202</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
@ -173,7 +173,7 @@
|
||||
<widget class="QLabel" name="tailleLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<x>190</x>
|
||||
<y>239</y>
|
||||
<width>63</width>
|
||||
<height>20</height>
|
||||
@ -186,7 +186,7 @@
|
||||
<widget class="QLineEdit" name="raceLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<x>250</x>
|
||||
<y>91</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
@ -196,7 +196,7 @@
|
||||
<widget class="QLineEdit" name="classeLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<x>250</x>
|
||||
<y>128</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
@ -206,7 +206,7 @@
|
||||
<widget class="QLineEdit" name="niveauLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<x>250</x>
|
||||
<y>165</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
@ -216,7 +216,7 @@
|
||||
<widget class="QLineEdit" name="sexeLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<x>250</x>
|
||||
<y>202</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
@ -226,20 +226,33 @@
|
||||
<widget class="QLineEdit" name="tailleLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<x>250</x>
|
||||
<y>239</y>
|
||||
<width>113</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="imagePushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>200</y>
|
||||
<width>130</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choisir une image</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QFrame" name="topRightFrame">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<x>390</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<width>411</width>
|
||||
<height>278</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1004,7 +1017,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>35</y>
|
||||
<width>800</width>
|
||||
<height>590</height>
|
||||
</rect>
|
||||
@ -1026,6 +1039,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QFrame" name="Fenetre">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>35</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Shape::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>BackPack</zorder>
|
||||
<zorder>Edition</zorder>
|
||||
<zorder>Fenetre</zorder>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
@ -1046,22 +1078,15 @@
|
||||
<addaction name="actionEnregistrer_sous"/>
|
||||
<addaction name="actionFermer"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuAffichage">
|
||||
<property name="title">
|
||||
<string>Affichage</string>
|
||||
</property>
|
||||
<addaction name="actionCaract_ristiques"/>
|
||||
<addaction name="actionBloc_note"/>
|
||||
</widget>
|
||||
<addaction name="menuFichier"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionBlocNote"/>
|
||||
<addaction name="actionBackPack"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuAffichage"/>
|
||||
</widget>
|
||||
<action name="actionOuvrir_une_fiche">
|
||||
<property name="text">
|
||||
@ -1095,17 +1120,6 @@
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionBlocNote">
|
||||
<property name="icon">
|
||||
<iconset theme="QIcon::ThemeIcon::DocumentPageSetup"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>BlocNote</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNouvelle_fiche">
|
||||
<property name="text">
|
||||
<string>Nouvelle fiche</string>
|
||||
@ -1114,15 +1128,20 @@
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionBackPack">
|
||||
<property name="icon">
|
||||
<iconset theme="folder"/>
|
||||
</property>
|
||||
<action name="actionBloc_note">
|
||||
<property name="text">
|
||||
<string>BackPack</string>
|
||||
<string>Bloc note</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCaract_ristiques">
|
||||
<property name="text">
|
||||
<string>Caractéristiques / Sac à dos</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+,</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user