blocknote fonctionnel
This commit is contained in:
parent
78cd25df39
commit
f872ca13c2
@ -27,3 +27,6 @@ FORMS += \
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
RESOURCES += \
|
||||
data.qrc
|
||||
|
||||
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Gitea repo - Raccourci.lnk
Normal file
BIN
Gitea repo - Raccourci.lnk
Normal file
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
#include "character.h"
|
||||
#include <iostream>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
@ -35,6 +35,8 @@ Character::Character(QFile *file){
|
||||
taille = json["taille"].toDouble();
|
||||
vie = json["vie"].toInt();
|
||||
image = json["image"].toString();
|
||||
texteBlocNote = json["blocNote"].toString();
|
||||
texteBackPack = json["backPack"].toString();
|
||||
|
||||
QJsonArray skillArray = json["skills"].toArray();
|
||||
for (int i = 0; i < skillArray.size(); ++i) {
|
||||
|
||||
25
character.h
25
character.h
@ -15,11 +15,13 @@ private:
|
||||
int niveau;
|
||||
QString sexe;
|
||||
float taille;
|
||||
int vie;
|
||||
QString image;
|
||||
QString texteBlocNote;
|
||||
QString texteBackPack;
|
||||
QList<int> skills;
|
||||
QList<int> skillsMod;
|
||||
QList<int> stats;
|
||||
int vie;
|
||||
QString image;
|
||||
|
||||
public:
|
||||
Character();
|
||||
@ -33,10 +35,27 @@ public:
|
||||
int getNiveau(){return niveau;}
|
||||
QString getSexe(){return sexe;}
|
||||
float getTaille(){return taille;}
|
||||
int getVie(){return vie;}
|
||||
QString getTexteBlocNote(){return texteBlocNote;}
|
||||
QString getTexteBackPack(){return texteBackPack;}
|
||||
QList<int> getSkills(){return skills;}
|
||||
QList<int> getSkillsMod(){return skillsMod;}
|
||||
QList<int> getStats(){return stats;}
|
||||
int getVie(){return vie;}
|
||||
|
||||
void setImage(QString i){image = i;}
|
||||
void setNom(QString n){nom = n;}
|
||||
void setAge(int a){age = a;}
|
||||
void setRace(QString r){race = r;}
|
||||
void setClasse(QString c){classe = c;}
|
||||
void setNiveau(int n){niveau = n;}
|
||||
void setSexe(QString s){sexe = s;}
|
||||
void setTaille(float t){taille = t;}
|
||||
void setVie(int v){vie = v;}
|
||||
void setTexteBlocNote(QString bN){texteBlocNote = bN;}
|
||||
void setTexteBackPack(QString bP){texteBackPack = bP;}
|
||||
void setSkills(QList<int> sk){skills = sk;}
|
||||
void setSkillsMod(QList<int> skM){skillsMod = skM;}
|
||||
void setStats(QList<int> st){stats = st;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
27
data.qrc
Normal file
27
data.qrc
Normal file
@ -0,0 +1,27 @@
|
||||
<RCC>
|
||||
<qresource prefix="/data/images">
|
||||
<file>data/images/add.png</file>
|
||||
<file>data/images/bold.png</file>
|
||||
<file>data/images/copy.png</file>
|
||||
<file>data/images/create.png</file>
|
||||
<file>data/images/cut.png</file>
|
||||
<file>data/images/edit_redo.png</file>
|
||||
<file>data/images/edit_undo.png</file>
|
||||
<file>data/images/exit.png</file>
|
||||
<file>data/images/font.png</file>
|
||||
<file>data/images/font-color.png</file>
|
||||
<file>data/images/font-size.png</file>
|
||||
<file>data/images/info.png</file>
|
||||
<file>data/images/italic.png</file>
|
||||
<file>data/images/logo.png</file>
|
||||
<file>data/images/new.png</file>
|
||||
<file>data/images/open.png</file>
|
||||
<file>data/images/overline.png</file>
|
||||
<file>data/images/paste.png</file>
|
||||
<file>data/images/pencil.png</file>
|
||||
<file>data/images/print.png</file>
|
||||
<file>data/images/save.png</file>
|
||||
<file>data/images/save_as.png</file>
|
||||
<file>data/images/underline.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
49
data/a.txt
Normal file
49
data/a.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "dghdgdgfgd",
|
||||
"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": 6619181
|
||||
}
|
||||
49
data/b.txt
Normal file
49
data/b.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "ssd",
|
||||
"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": 6619181
|
||||
}
|
||||
14
data/p1.txt
14
data/p1.txt
@ -1,14 +0,0 @@
|
||||
{
|
||||
name : "ujunb",
|
||||
age : 12,
|
||||
race : "zifzi",
|
||||
classe : "uhuh",
|
||||
niveau : 2,
|
||||
sexe : "H",
|
||||
taille : 1.2,
|
||||
vie : 2,
|
||||
image : "data/images/logo.png",
|
||||
skills : [1,1,1,1,1,1],
|
||||
skillsMod : [1,1,1,1,1,1],
|
||||
stats : [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
|
||||
}
|
||||
49
data/test.txt
Normal file
49
data/test.txt
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"age": 0,
|
||||
"backPack": "",
|
||||
"blocNote": "sfsfsffsd",
|
||||
"classe": "",
|
||||
"image": "data/images/logo.png",
|
||||
"name": "Gio",
|
||||
"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
|
||||
}
|
||||
2
main.cpp
2
main.cpp
@ -8,6 +8,8 @@ int main(int argc, char *argv[])
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
|
||||
//Il faut mettre à jour les fonctions de save, et de lad et de création pour les nouveaux attributs
|
||||
}
|
||||
|
||||
|
||||
|
||||
247
mainwindow.cpp
247
mainwindow.cpp
@ -6,6 +6,8 @@
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -14,6 +16,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
notePad = new NotePad();
|
||||
connect(notePad, &NotePad::demandeSauvegarde, this, &MainWindow::recevoirSauvegarde);
|
||||
Character* c = new Character();
|
||||
currentCharacter = c;
|
||||
characters.append(c);
|
||||
@ -55,39 +59,10 @@ void MainWindow::loadNewCharacter(){
|
||||
}
|
||||
|
||||
void MainWindow::createNewCharacter(Character* p) {
|
||||
notePad->setTexte(p->getTexteBlocNote());
|
||||
currentCharacter = p;
|
||||
characters.append(p);
|
||||
|
||||
ui->nomLineEdit->setText(p->getNom());
|
||||
ui->ageLineEdit->setText(QString::number(p->getAge()));
|
||||
ui->raceLineEdit->setText(p->getRace());
|
||||
ui->classeLineEdit->setText(p->getClasse());
|
||||
ui->niveauLineEdit->setText(QString::number(p->getNiveau()));
|
||||
ui->sexeLineEdit->setText(p->getSexe());
|
||||
ui->tailleLineEdit->setText(QString::number(p->getTaille()));
|
||||
|
||||
ui->charismeSpinBox->setValue(p->getSkills()[0]);
|
||||
ui->dexteriteSpinBox->setValue(p->getSkills()[1]);
|
||||
ui->enduranceSpinBox->setValue(p->getSkills()[2]);
|
||||
ui->forceSpinBox->setValue(p->getSkills()[3]);
|
||||
ui->intelligenceSpinBox->setValue(p->getSkills()[4]);
|
||||
ui->sagesseSpinBox->setValue(p->getSkills()[5]);
|
||||
|
||||
ui->modCharismeSpinBox->setValue(p->getSkillsMod()[0]);
|
||||
ui->modDexteriteSpinBox->setValue(p->getSkillsMod()[1]);
|
||||
ui->modEnduranceSpinBox->setValue(p->getSkillsMod()[2]);
|
||||
ui->modForceSpinBox->setValue(p->getSkillsMod()[3]);
|
||||
ui->modIntelligenceSpinBox->setValue(p->getSkillsMod()[4]);
|
||||
ui->modSagesseSpinBox->setValue(p->getSkillsMod()[5]);
|
||||
|
||||
for (int i = 0; i < p->getStats().size(); ++i) {
|
||||
QString spinBoxName = QString("spinBox%1").arg(i+1);
|
||||
QSpinBox* spinBox = this->findChild<QSpinBox*>(spinBoxName);
|
||||
if (spinBox) {
|
||||
spinBox->setValue(p->getStats()[i]);
|
||||
}
|
||||
}
|
||||
loadImage(p->getImage());
|
||||
setUi(p);
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +89,7 @@ void MainWindow::loadImage(QString fileName) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::exportJson(){
|
||||
void MainWindow::saveJson(){
|
||||
QString fileName;
|
||||
if (currentFile.isEmpty()) {
|
||||
fileName = QFileDialog::getSaveFileName(this, "Save");
|
||||
@ -127,49 +102,47 @@ void MainWindow::exportJson(){
|
||||
QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString());
|
||||
return;
|
||||
}
|
||||
setWindowTitle(fileName);
|
||||
|
||||
if(edition){
|
||||
//appelle a funct qui prend val ui pour mettre dans c
|
||||
getUi();
|
||||
}
|
||||
//Prend de c pour mettre dans json
|
||||
notePad->getUi();
|
||||
currentCharacter->setTexteBlocNote(notePad->getTexte());
|
||||
QJsonObject json;
|
||||
/*
|
||||
json["name"] = ui->titleEdit->text();
|
||||
json["city"] =ui->locEdit->text();
|
||||
json["departement"] = ui->depSpin->text();
|
||||
json["difficulty"] = ui->diffSpin->value();
|
||||
json["duration"] = ui->durationSpin->value();
|
||||
json["length"] = ui->lengthSpin->value();
|
||||
json["image"] = ui->imagePath->text();
|
||||
json["name"] = currentCharacter->getNom();
|
||||
json["age"] = currentCharacter->getAge();
|
||||
json["race"] = currentCharacter->getRace();
|
||||
json["classe"] = currentCharacter->getClasse();
|
||||
json["niveau"] = currentCharacter->getNiveau();
|
||||
json["sexe"] = currentCharacter->getSexe();
|
||||
json["taille"] = currentCharacter->getTaille();
|
||||
json["vie"] = currentCharacter->getVie();
|
||||
json["image"] = currentCharacter->getImage();
|
||||
json["blocNote"] = currentCharacter->getTexteBlocNote();
|
||||
json["backPack"] = currentCharacter->getTexteBackPack();
|
||||
|
||||
QJsonArray steps;
|
||||
int cpt=0;
|
||||
for(Step step: currentPath->getStep()){
|
||||
cpt++;
|
||||
QJsonObject stepObject;
|
||||
stepObject["numero"] = cpt;
|
||||
stepObject["title"] = step.getTitle();
|
||||
stepObject["GPS"] = step.toGPSFormat();
|
||||
stepObject["reponse"] = step.getResponse();
|
||||
QJsonArray dialogues;
|
||||
for(int i=0; i<step.getTexte().size(); i++){
|
||||
QJsonObject dialogueObject;
|
||||
dialogueObject["personnage"] = step.getPersonnage()[i];
|
||||
dialogueObject["texte"] = step.getTexte()[i];
|
||||
dialogues.append(dialogueObject);
|
||||
QJsonArray skillsArray;
|
||||
for(int i=0; i<currentCharacter->getSkills().size(); i++){
|
||||
skillsArray.append(QJsonValue(currentCharacter->getSkills()[i]));
|
||||
}
|
||||
stepObject["dialogue"] = dialogues;
|
||||
steps.append(stepObject);
|
||||
json["skills"] = skillsArray;
|
||||
QJsonArray skillsModArray;
|
||||
for(int i=0; i<currentCharacter->getSkillsMod().size(); i++){
|
||||
skillsModArray.append(QJsonValue(currentCharacter->getSkillsMod()[i]));
|
||||
}
|
||||
json["steps"] = steps;
|
||||
json["skillsMod"] = skillsModArray;
|
||||
QJsonArray statsArray;
|
||||
for(int i=0; i<currentCharacter->getStats().size(); i++){
|
||||
statsArray.append(QJsonValue(currentCharacter->getStats()[i]));
|
||||
}
|
||||
json["stats"] = statsArray;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
file.write(doc.toJson());
|
||||
*/
|
||||
file.close();
|
||||
}
|
||||
|
||||
void MainWindow::exportJsonAs(){
|
||||
void MainWindow::saveAsJson(){
|
||||
QString fileName = QFileDialog::getSaveFileName(this, "Save as");
|
||||
QFile file(fileName);
|
||||
|
||||
@ -181,45 +154,123 @@ void MainWindow::exportJsonAs(){
|
||||
currentFile = fileName;
|
||||
|
||||
if(edition){
|
||||
//appelle a funct qui prend val ui pour mettre dans c
|
||||
getUi();
|
||||
}
|
||||
//Prend de c pour mettre dans json
|
||||
notePad->getUi();
|
||||
currentCharacter->setTexteBlocNote(notePad->getTexte());
|
||||
QJsonObject json;
|
||||
/*
|
||||
json["name"] = ui->titleEdit->text();
|
||||
json["city"] =ui->locEdit->text();
|
||||
json["departement"] = ui->depSpin->text();
|
||||
json["difficulty"] = ui->diffSpin->value();
|
||||
json["duration"] = ui->durationSpin->value();
|
||||
json["length"] = ui->lengthSpin->value();
|
||||
json["image"] = ui->imagePath->text();
|
||||
json["name"] = currentCharacter->getNom();
|
||||
json["age"] = currentCharacter->getAge();
|
||||
json["race"] = currentCharacter->getRace();
|
||||
json["classe"] = currentCharacter->getClasse();
|
||||
json["niveau"] = currentCharacter->getNiveau();
|
||||
json["sexe"] = currentCharacter->getSexe();
|
||||
json["taille"] = currentCharacter->getTaille();
|
||||
json["vie"] = currentCharacter->getVie();
|
||||
json["image"] = currentCharacter->getImage();
|
||||
json["blocNote"] = currentCharacter->getTexteBlocNote();
|
||||
json["backPack"] = currentCharacter->getTexteBackPack();
|
||||
|
||||
QJsonArray steps;
|
||||
int cpt=0;
|
||||
for(Step step: currentPath->getStep()){
|
||||
cpt++;
|
||||
QJsonObject stepObject;
|
||||
stepObject["numero"] = cpt;
|
||||
stepObject["title"] = step.getTitle();
|
||||
stepObject["GPS"] = step.toGPSFormat();
|
||||
stepObject["reponse"] = step.getResponse();
|
||||
QJsonArray dialogues;
|
||||
for(int i=0; i<step.getTexte().size(); i++){
|
||||
QJsonObject dialogueObject;
|
||||
dialogueObject["personnage"] = step.getPersonnage()[i];
|
||||
dialogueObject["texte"] = step.getTexte()[i];
|
||||
dialogues.append(dialogueObject);
|
||||
QJsonArray skillsArray;
|
||||
for(int i=0; i<currentCharacter->getSkills().size(); i++){
|
||||
skillsArray.append(QJsonValue(currentCharacter->getSkills()[i]));
|
||||
}
|
||||
stepObject["dialogue"] = dialogues;
|
||||
steps.append(stepObject);
|
||||
json["skills"] = skillsArray;
|
||||
QJsonArray skillsModArray;
|
||||
for(int i=0; i<currentCharacter->getSkillsMod().size(); i++){
|
||||
skillsModArray.append(QJsonValue(currentCharacter->getSkillsMod()[i]));
|
||||
}
|
||||
json["steps"] = steps;
|
||||
json["skillsMod"] = skillsModArray;
|
||||
QJsonArray statsArray;
|
||||
for(int i=0; i<currentCharacter->getStats().size(); i++){
|
||||
statsArray.append(QJsonValue(currentCharacter->getStats()[i]));
|
||||
}
|
||||
json["stats"] = statsArray;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
file.write(doc.toJson());
|
||||
*/
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::getUi(){
|
||||
currentCharacter->setNom(ui->nomLineEdit->text());
|
||||
currentCharacter->setAge(ui->ageLineEdit->text().toInt());
|
||||
currentCharacter->setRace(ui->raceLineEdit->text());
|
||||
currentCharacter->setClasse(ui->classeLineEdit->text());
|
||||
currentCharacter->setNiveau(ui->niveauLineEdit->text().toInt());
|
||||
currentCharacter->setSexe(ui->sexeLineEdit->text());
|
||||
currentCharacter->setTaille(ui->tailleLineEdit->text().toFloat());
|
||||
|
||||
QList<int> skills;
|
||||
skills.append(ui->charismeSpinBox->value());
|
||||
skills.append(ui->dexteriteSpinBox->value());
|
||||
skills.append(ui->enduranceSpinBox->value());
|
||||
skills.append(ui->forceSpinBox->value());
|
||||
skills.append(ui->intelligenceSpinBox->value());
|
||||
skills.append(ui->sagesseSpinBox->value());
|
||||
skills.append(ui->pvSpinBox->value());
|
||||
currentCharacter->setSkills(skills);
|
||||
QList<int> skillsMod;
|
||||
skillsMod.append(ui->modCharismeSpinBox->value());
|
||||
skillsMod.append(ui->modDexteriteSpinBox->value());
|
||||
skillsMod.append(ui->modEnduranceSpinBox->value());
|
||||
skillsMod.append(ui->modForceSpinBox->value());
|
||||
skillsMod.append(ui->modIntelligenceSpinBox->value());
|
||||
skillsMod.append(ui->modSagesseSpinBox->value());
|
||||
currentCharacter->setSkills(skillsMod);
|
||||
QList<int> stats;
|
||||
for (int i = 0; i < currentCharacter->getStats().size(); ++i) {
|
||||
QString spinBoxName = QString("spinBox%1").arg(i+1);
|
||||
QSpinBox* spinBox = this->findChild<QSpinBox*>(spinBoxName);
|
||||
if (spinBox) {
|
||||
stats.append(spinBox->value());
|
||||
}
|
||||
}
|
||||
currentCharacter->setStats(stats);
|
||||
//currentCharacter->setImage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::setUi(Character* p){
|
||||
ui->nomLineEdit->setText(p->getNom());
|
||||
ui->ageLineEdit->setText(QString::number(p->getAge()));
|
||||
ui->raceLineEdit->setText(p->getRace());
|
||||
ui->classeLineEdit->setText(p->getClasse());
|
||||
ui->niveauLineEdit->setText(QString::number(p->getNiveau()));
|
||||
ui->sexeLineEdit->setText(p->getSexe());
|
||||
ui->tailleLineEdit->setText(QString::number(p->getTaille()));
|
||||
|
||||
ui->charismeSpinBox->setValue(p->getSkills()[0]);
|
||||
ui->dexteriteSpinBox->setValue(p->getSkills()[1]);
|
||||
ui->enduranceSpinBox->setValue(p->getSkills()[2]);
|
||||
ui->forceSpinBox->setValue(p->getSkills()[3]);
|
||||
ui->intelligenceSpinBox->setValue(p->getSkills()[4]);
|
||||
ui->sagesseSpinBox->setValue(p->getSkills()[5]);
|
||||
ui->pvSpinBox->setValue(p->getVie());
|
||||
|
||||
ui->modCharismeSpinBox->setValue(p->getSkillsMod()[0]);
|
||||
ui->modDexteriteSpinBox->setValue(p->getSkillsMod()[1]);
|
||||
ui->modEnduranceSpinBox->setValue(p->getSkillsMod()[2]);
|
||||
ui->modForceSpinBox->setValue(p->getSkillsMod()[3]);
|
||||
ui->modIntelligenceSpinBox->setValue(p->getSkillsMod()[4]);
|
||||
ui->modSagesseSpinBox->setValue(p->getSkillsMod()[5]);
|
||||
|
||||
for (int i = 0; i < p->getStats().size(); ++i) {
|
||||
QString spinBoxName = QString("spinBox%1").arg(i+1);
|
||||
QSpinBox* spinBox = this->findChild<QSpinBox*>(spinBoxName);
|
||||
if (spinBox) {
|
||||
spinBox->setValue(p->getStats()[i]);
|
||||
}
|
||||
}
|
||||
loadImage(p->getImage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::on_actionEditer_triggered(){
|
||||
if(edition){
|
||||
//Mode edition
|
||||
@ -231,14 +282,20 @@ void MainWindow::on_actionEditer_triggered(){
|
||||
|
||||
|
||||
void MainWindow::on_actionBlocNote_triggered(){
|
||||
notePad = new NotePad();
|
||||
this->notePad->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::recevoirSauvegarde(QString contenu){
|
||||
currentCharacter->setTexteBlocNote(contenu);
|
||||
saveJson();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::on_actionOuvrir_une_fiche_triggered(){this->loadNewCharacter();}
|
||||
void MainWindow::on_actionNouvelle_fiche_triggered(){this->createNewCharacter(new Character());}
|
||||
void MainWindow::on_actionSauvegarder_triggered(){this->exportJson();}
|
||||
void MainWindow::on_actionEnregistrer_sous_triggered(){this->exportJsonAs();}
|
||||
void MainWindow::on_actionSauvegarder_triggered(){this->saveJson();}
|
||||
void MainWindow::on_actionEnregistrer_sous_triggered(){this->saveAsJson();}
|
||||
void MainWindow::on_actionFermer_triggered(){QApplication::quit();}
|
||||
|
||||
|
||||
12
mainwindow.h
12
mainwindow.h
@ -23,8 +23,10 @@ public:
|
||||
void loadImage(QString fileName);
|
||||
void createNewCharacter(Character* p);
|
||||
void loadNewCharacter();
|
||||
void exportJson();
|
||||
void exportJsonAs();
|
||||
void saveJson();
|
||||
void saveAsJson();
|
||||
void getUi();
|
||||
void setUi(Character* p);
|
||||
|
||||
private slots:
|
||||
void on_actionEditer_triggered();
|
||||
@ -32,16 +34,16 @@ private slots:
|
||||
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 recevoirSauvegarde(QString contenu);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
NotePad *notePad;
|
||||
|
||||
bool edition = false;
|
||||
bool edition = true;
|
||||
bool backPack = false;
|
||||
QString currentFile;
|
||||
QList<Character*> characters;
|
||||
|
||||
@ -1004,20 +1004,7 @@
|
||||
<addaction name="actionEnregistrer_sous"/>
|
||||
<addaction name="actionFermer"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdition">
|
||||
<property name="title">
|
||||
<string>Edition</string>
|
||||
</property>
|
||||
<addaction name="actionCopier"/>
|
||||
<addaction name="actionColler"/>
|
||||
<addaction name="actionCouper"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRetour_arri_re"/>
|
||||
<addaction name="actionRetour_avant"/>
|
||||
</widget>
|
||||
<addaction name="menuFichier"/>
|
||||
<addaction name="menuEdition"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
@ -1037,45 +1024,32 @@
|
||||
<property name="text">
|
||||
<string>Ouvrir une fiche</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSauvegarder">
|
||||
<property name="text">
|
||||
<string>Enregistrer</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnregistrer_sous">
|
||||
<property name="text">
|
||||
<string>Enregistrer sous</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFermer">
|
||||
<property name="text">
|
||||
<string>Fermer</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopier">
|
||||
<property name="text">
|
||||
<string>Copier</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionColler">
|
||||
<property name="text">
|
||||
<string>Coller</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCouper">
|
||||
<property name="text">
|
||||
<string>Couper</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRetour_arri_re">
|
||||
<property name="text">
|
||||
<string>Retour arrière</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRetour_avant">
|
||||
<property name="text">
|
||||
<string>Retour avant</string>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEditer">
|
||||
@ -1104,6 +1078,9 @@
|
||||
<property name="text">
|
||||
<string>Nouvelle fiche</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
125
notepad.cpp
125
notepad.cpp
@ -1,6 +1,10 @@
|
||||
#include "notepad.h"
|
||||
#include "ui_notepad.h"
|
||||
|
||||
#include <QInputDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QColorDialog>
|
||||
|
||||
using namespace std;
|
||||
|
||||
NotePad::NotePad(QWidget *parent)
|
||||
@ -13,3 +17,124 @@ NotePad::NotePad(QWidget *parent)
|
||||
NotePad::~NotePad(){
|
||||
|
||||
}
|
||||
|
||||
void NotePad::on_actionFontSize_triggered(){
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||
|
||||
if (plainTextEdit) {
|
||||
QTextCursor cursor = plainTextEdit->textCursor();
|
||||
bool ok;
|
||||
int size = QInputDialog::getInt(this, "Taille de la police", "Entrez la taille de la police:", cursor.charFormat().font().pointSize(), 1, 100, 1, &ok);
|
||||
|
||||
if (ok) {
|
||||
QTextCharFormat format;
|
||||
QFont font = cursor.charFormat().font();
|
||||
font.setPointSize(size);
|
||||
format.setFont(font);
|
||||
plainTextEdit->mergeCurrentCharFormat(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotePad::on_actionFontColor_triggered(){
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||
|
||||
if (plainTextEdit) {
|
||||
QColor color = QColorDialog::getColor(Qt::black, this, "Choisir une couleur");
|
||||
QTextCursor cursor = plainTextEdit->textCursor();
|
||||
if (color.isValid()) {
|
||||
QTextCharFormat format;
|
||||
format.setForeground(color);
|
||||
plainTextEdit->mergeCurrentCharFormat(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotePad::on_actionFont_triggered(){
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||
|
||||
if (plainTextEdit) {
|
||||
QTextCursor cursor = plainTextEdit->textCursor();
|
||||
bool ok;
|
||||
QFont font = QFontDialog::getFont(&ok, cursor.charFormat().font(), this, "Choisir une police");
|
||||
if (ok) {
|
||||
QTextCharFormat format;
|
||||
format.setFont(font);
|
||||
plainTextEdit->mergeCurrentCharFormat(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotePad::on_actionBold_triggered(){
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||
|
||||
if (plainTextEdit) {
|
||||
QTextCursor cursor = plainTextEdit->textCursor();
|
||||
QTextCharFormat format;
|
||||
QFont font = cursor.charFormat().font();
|
||||
font.setBold(!font.bold());
|
||||
format.setFont(font);
|
||||
plainTextEdit->mergeCurrentCharFormat(format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotePad::on_actionItalic_triggered(){
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||
|
||||
if (plainTextEdit) {
|
||||
QTextCursor cursor = plainTextEdit->textCursor();
|
||||
QTextCharFormat format;
|
||||
QFont font = cursor.charFormat().font();
|
||||
font.setItalic(!font.italic());
|
||||
format.setFont(font);
|
||||
plainTextEdit->mergeCurrentCharFormat(format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotePad::on_actionOverline_triggered(){
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||
|
||||
if (plainTextEdit) {
|
||||
QTextCursor cursor = plainTextEdit->textCursor();
|
||||
QTextCharFormat format;
|
||||
QFont font = cursor.charFormat().font();
|
||||
font.setOverline(!font.overline());
|
||||
format.setFont(font);
|
||||
plainTextEdit->mergeCurrentCharFormat(format);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NotePad::on_actionUnderline_triggered(){
|
||||
QWidget *focused = QApplication::focusWidget();
|
||||
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||
|
||||
if (plainTextEdit) {
|
||||
QTextCursor cursor = plainTextEdit->textCursor();
|
||||
QTextCharFormat format;
|
||||
QFont font = cursor.charFormat().font();
|
||||
font.setUnderline(!font.underline());
|
||||
format.setFont(font);
|
||||
plainTextEdit->mergeCurrentCharFormat(format);
|
||||
}
|
||||
}
|
||||
|
||||
void NotePad::setTexte(QString t){
|
||||
texte = t;
|
||||
setUi(t);
|
||||
}
|
||||
void NotePad::setUi(QString t){ui->plainTextEdit->setPlainText(t);}
|
||||
void NotePad::getUi(){texte = ui->plainTextEdit->toPlainText();}
|
||||
void NotePad::on_actionSauvegarder_triggered(){emit demandeSauvegarde(ui->plainTextEdit->toPlainText());}
|
||||
|
||||
|
||||
19
notepad.h
19
notepad.h
@ -17,8 +17,27 @@ public:
|
||||
NotePad(QWidget *parent = nullptr);
|
||||
~NotePad();
|
||||
|
||||
void getUi();
|
||||
void setUi(QString t);
|
||||
QString getTexte(){return texte;}
|
||||
void setTexte(QString t);
|
||||
|
||||
private slots:
|
||||
void on_actionFontSize_triggered();
|
||||
void on_actionFontColor_triggered();
|
||||
void on_actionFont_triggered();
|
||||
void on_actionBold_triggered();
|
||||
void on_actionItalic_triggered();
|
||||
void on_actionOverline_triggered();
|
||||
void on_actionUnderline_triggered();
|
||||
void on_actionSauvegarder_triggered();
|
||||
|
||||
signals:
|
||||
void demandeSauvegarde(QString contenu);
|
||||
|
||||
private:
|
||||
Ui::NotePad *ui;
|
||||
QString texte;
|
||||
};
|
||||
|
||||
#endif // NOTEPAD_H
|
||||
|
||||
148
notepad.ui
148
notepad.ui
@ -13,7 +13,18 @@
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -25,7 +36,140 @@
|
||||
</property>
|
||||
</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="actionSauvegarder"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFontColor"/>
|
||||
<addaction name="actionFont"/>
|
||||
<addaction name="actionFontSize"/>
|
||||
<addaction name="actionBold"/>
|
||||
<addaction name="actionItalic"/>
|
||||
<addaction name="actionOverline"/>
|
||||
<addaction name="actionUnderline"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<action name="actionFontSize">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/font-size.png</normaloff>:/data/images/data/images/font-size.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>FontSize</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFontColor">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/font-color.png</normaloff>:/data/images/data/images/font-color.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>FontColor</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFont">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/font.png</normaloff>:/data/images/data/images/font.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionBold">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/bold.png</normaloff>:/data/images/data/images/bold.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Bold</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionItalic">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/italic.png</normaloff>:/data/images/data/images/italic.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Italic</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOverline">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/overline.png</normaloff>:/data/images/data/images/overline.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Overline</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUnderline">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/underline.png</normaloff>:/data/images/data/images/underline.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Underline</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+U</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSauvegarder">
|
||||
<property name="icon">
|
||||
<iconset resource="data.qrc">
|
||||
<normaloff>:/data/images/data/images/save.png</normaloff>:/data/images/data/images/save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Sauvegarder</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::MenuRole::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="data.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user