diff --git a/lang/qet_en.qm b/lang/qet_en.qm
index e964e5df4..cfb165b6c 100644
Binary files a/lang/qet_en.qm and b/lang/qet_en.qm differ
diff --git a/lang/qet_en.ts b/lang/qet_en.ts
index c577d9cad..a09a6a180 100644
--- a/lang/qet_en.ts
+++ b/lang/qet_en.ts
@@ -949,12 +949,12 @@ Please check rights of the directory
Abscissa :
-
+ Créer un nouvel élément : AssistantCreate a new element : wizard
-
+ ErreurError
@@ -966,27 +966,27 @@ Please check rights of the directory
Étape 1/5 : Sélectionnez une catégorie dans laquelle enregistrer le nouvel élément.
- Step 1 of 5 : Please select a category in which to save the new element.
+ Step 1 of 5 : Please select a category in which to save the new element.Étape 2/5 : Indiquez le nom du fichier dans lequel enregistrer le nouvel élément.
- Step 2 of 5 : Enter the filename for the new element.
+ Step 2 of 5 : Enter the filename for the new element.Étape 3/5 : Indiquez le ou les noms de l'élément.
- Step 3 of 5 : Enter the new element name(s).
+ Step 3 of 5 : Enter the new element name(s).Étape 4/5 : Saisissez les dimensions du nouvel élément ainsi que la position du hotspot (point de saisie de l'élément à la souris) en considérant que l'élément est dans son orientation par défaut.
- Step 4 of 5 : Enter the new element size and its hotspot position (i.e. the spot used to drag the element). Consider the element aims its default orientation.
+ Step 4 of 5 : Enter the new element size and its hotspot position (i.e. the spot used to drag the element). Consider the element aims its default orientation.Étape 5/5 : Indiquez les orientations possibles pour le nouvel élément.
- Step 5 of 5 : Specify the the new element allowed orientations.
+ Step 5 of 5 : Specify the the new element allowed orientations.
@@ -1009,7 +1009,7 @@ Please check rights of the directory
Width :
-
+ Nom du nouvel élémentNew element name
@@ -1041,7 +1041,7 @@ Please check rights of the directory
Précédent
- Back
+ Back
@@ -1066,33 +1066,88 @@ Please check rights of the directory
Suivant
- Next
+ NextValider
- Finish
+ Finish
-
+ Vous devez entrer un nom de fichierYou must enter a filename
-
+ Vous devez sélectionner une catégorie.You must select a category.
-
+ Vous n'êtes pas obligé de préciser l'extension *.elmt. Elle sera ajoutée automatiquement.You don't have to specify the *.elmt extension. It will be added automatically.
-
+ nouvel_elementnew_element
+
+
+ &Suivant >
+ &Next >
+
+
+
+ Étape 1/5 : Catégorie parente
+ Step 1 of 5 : Parent Category
+
+
+
+ Sélectionnez une catégorie dans laquelle enregistrer le nouvel élément.
+ Select a category which to save the new element in.
+
+
+
+ Étape 2/5 : Nom du fichier
+ Step 2 of 5 : Filename
+
+
+
+ Indiquez le nom du fichier dans lequel enregistrer le nouvel élément.
+ Enter the name of the file for the new element.
+
+
+
+ Étape 3/5 : Noms de l'élément
+ Step 3 of 5 : Element names
+
+
+
+ Indiquez le ou les noms de l'élément.
+ Enter one or more names for the element.
+
+
+
+ Étape 4/5 : Dimensions et point de saisie
+ Step 4 of 5 : Size and hotspot
+
+
+
+ Saisissez les dimensions du nouvel élément ainsi que la position du hotspot (point de saisie de l'élément à la souris) en considérant que l'élément est dans son orientation par défaut.
+ Enter the new element size and its hotspot, considering the element is default-oriented.
+
+
+
+ Étape 5/5 : Orientations
+ Step 5 of 5 : Orientations
+
+
+
+ Indiquez les orientations possibles pour le nouvel élément.
+ Enter the allowed and forbidden orientations for the new element.
+ OrientationSetWidget
diff --git a/newelementwizard.cpp b/newelementwizard.cpp
index 328e8ba8c..3def284a4 100644
--- a/newelementwizard.cpp
+++ b/newelementwizard.cpp
@@ -12,48 +12,16 @@
@param parent QWidget parent de ce dialogue
@param f flags pour le dialogue
*/
-NewElementWizard::NewElementWizard(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {
- setFixedSize(480, 280);
- QVBoxLayout *dialog_layout = new QVBoxLayout();
- setLayout(dialog_layout);
-
- // chaines de caracteres utilisees sur les boutons
- str_next = QString(tr("Suivant"));
- str_previous = QString(tr("Pr\351c\351dent"));
- str_finish = QString(tr("Valider"));
-
- buildStep1();
- buildStep2();
- buildStep3();
- buildStep4();
- buildStep5();
-
- // dialogue itself
+NewElementWizard::NewElementWizard(QWidget *parent, Qt::WindowFlags f) : QWizard(parent, f) {
+ setPixmap(LogoPixmap, QPixmap(":/ico/qelectrotech.png").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
setWindowTitle(tr("Cr\351er un nouvel \351l\351ment : Assistant"));
-
- dialog_layout -> addWidget(step1);
- dialog_layout -> addWidget(step2);
- dialog_layout -> addWidget(step3);
- dialog_layout -> addWidget(step4);
- dialog_layout -> addWidget(step5);
- step2 -> hide();
- step3 -> hide();
- step4 -> hide();
- step5 -> hide();
-
- // boutons
- QDialogButtonBox *boutons = new QDialogButtonBox(QDialogButtonBox::Cancel);
- button_previous = new QPushButton(str_previous, this);
- button_previous -> setEnabled(false);
- button_next = new QPushButton(str_next, this);
- boutons -> addButton(button_previous, QDialogButtonBox::ActionRole);
- boutons -> addButton(button_next, QDialogButtonBox::ActionRole);
- connect(button_previous, SIGNAL(released()), this, SLOT(previous()));
- connect(button_next, SIGNAL(released()), this, SLOT(next()));
- connect(boutons, SIGNAL(rejected()), this, SLOT(accept()));
- dialog_layout -> addWidget(boutons);
- current_state = Category;
-
+ setButtonText(QWizard::NextButton, tr("&Suivant >"));
+ addPage(buildStep1());
+ addPage(buildStep2());
+ addPage(buildStep3());
+ addPage(buildStep4());
+ addPage(buildStep5());
+ setFixedSize(705, 325);
}
/**
@@ -62,164 +30,113 @@ NewElementWizard::NewElementWizard(QWidget *parent, Qt::WindowFlags f) : QDialog
NewElementWizard::~NewElementWizard() {
}
-/**
- Passe a l'etape precedente
-*/
-void NewElementWizard::previous() {
- switch(current_state) {
- case Category:
- return;
- case Filename:
- current_state = Category;
- step1 -> show();
- step2 -> hide();
- button_previous -> setEnabled(false);
- break;
- case Names:
- current_state = Filename;
- step2 -> show();
- qle_filename -> setFocus();
- step3 -> hide();
- break;
- case Dimensions:
- current_state = Names;
- step3 -> show();
- step4 -> hide();
- button_next -> setText(str_next);
- break;
- case Orientations:
- current_state = Dimensions;
- step4 -> show();
- step5 -> hide();
- button_next -> setText(str_next);
- }
-}
-
-/**
- Passe a l'etape suivante
-*/
-void NewElementWizard::next() {
- switch(current_state) {
- case Category:
- if (!validStep1()) return;
- current_state = Filename;
- step1 -> hide();
- step2 -> show();
- qle_filename -> setFocus();
- button_previous -> setEnabled(true);
- break;
- case Filename:
- if (!validStep2()) return;
- current_state = Names;
- step2 -> hide();
- step3 -> show();
- break;
- case Names:
- if (!validStep3()) return;
- current_state = Dimensions;
- step3 -> hide();
- step4 -> show();
- break;
- case Dimensions:
- if (!validStep4()) return;
- current_state = Orientations;
- step4 -> hide();
- step5 -> show();
- button_next -> setText(str_finish);
- button_previous -> setEnabled(true);
- break;
- case Orientations:
- if (!validStep5()) return;
- createNewElement();
- }
-}
-
/**
Met en place l'etape 1 : Categorie
*/
-void NewElementWizard::buildStep1() {
- step1 = new QWidget(this);
- QVBoxLayout *step1_layout = new QVBoxLayout();
- QLabel *explication = new QLabel(tr("\311tape 1/5 : S\351lectionnez une cat\351gorie dans laquelle enregistrer le nouvel \351l\351ment."));
- explication -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
- explication -> setWordWrap(true);
- step1_layout -> addWidget(explication);
+QWizardPage *NewElementWizard::buildStep1() {
+ QWizardPage *page = new QWizardPage();
+ page -> setProperty("WizardState", Category);
+ page -> setTitle(tr("\311tape 1/5 : Cat\351gorie parente"));
+ page -> setSubTitle(tr("S\351lectionnez une cat\351gorie dans laquelle enregistrer le nouvel \351l\351ment."));
+ QVBoxLayout *layout = new QVBoxLayout();
+
categories_list = new ElementsCategoriesWidget();
- step1_layout -> addWidget(categories_list);
- step1 -> setLayout(step1_layout);
+ layout -> addWidget(categories_list);
+
+ page -> setLayout(layout);
+ return(page);
}
/**
Met en place l'etape 2 : Nom du fichier
*/
-void NewElementWizard::buildStep2() {
- step2 = new QWidget(this);
- QVBoxLayout *step2_layout = new QVBoxLayout();
- QLabel *explication1 = new QLabel(tr("\311tape 2/5 : Indiquez le nom du fichier dans lequel enregistrer le nouvel \351l\351ment."));
- explication1 -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
- explication1 -> setWordWrap(true);
+QWizardPage *NewElementWizard::buildStep2() {
+ QWizardPage *page = new QWizardPage();
+ page -> setProperty("WizardState", Filename);
+ page -> setTitle(tr("\311tape 2/5 : Nom du fichier"));
+ page -> setSubTitle(tr("Indiquez le nom du fichier dans lequel enregistrer le nouvel \351l\351ment."));
+ QVBoxLayout *layout = new QVBoxLayout();
+
+ qle_filename = new QLineEdit(tr("nouvel_element"));
+ qle_filename -> selectAll();
QLabel *explication2 = new QLabel(tr("Vous n'\352tes pas oblig\351 de pr\351ciser l'extension *.elmt. Elle sera ajout\351e automatiquement."));
explication2 -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
explication2 -> setWordWrap(true);
- step2_layout -> addWidget(explication1);
- qle_filename = new QLineEdit(tr("nouvel_element"));
- qle_filename -> selectAll();
- step2_layout -> addWidget(qle_filename);
- step2_layout -> addWidget(explication2);
- step2_layout -> addSpacing(100);
- step2 -> setLayout(step2_layout);
+ layout -> addWidget(qle_filename);
+ layout -> addWidget(explication2);
+ layout -> addSpacing(100);
+
+ page -> setLayout(layout);
+ return(page);
}
/**
Met en place l'etape 3 : Noms de l'element
*/
-void NewElementWizard::buildStep3() {
- step3 = new QWidget(this);
- QVBoxLayout *step3_layout = new QVBoxLayout();
- QLabel *explication = new QLabel(tr("\311tape 3/5 : Indiquez le ou les noms de l'\351l\351ment."));
- explication -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
- explication -> setWordWrap(true);
- step3_layout -> addWidget(explication);
+QWizardPage *NewElementWizard::buildStep3() {
+ QWizardPage *page = new QWizardPage();
+ page -> setProperty("WizardState", Names);
+ page -> setTitle(tr("\311tape 3/5 : Noms de l'\351l\351ment"));
+ page -> setSubTitle(tr("Indiquez le ou les noms de l'\351l\351ment."));
+ QVBoxLayout *layout = new QVBoxLayout();
+
element_names = new NamesListWidget();
NamesList hash_name;
hash_name.addName(QLocale::system().name().left(2), tr("Nom du nouvel \351l\351ment"));
element_names -> setNames(hash_name);
- step3_layout -> addWidget(element_names);
- step3 -> setLayout(step3_layout);
+ layout -> addWidget(element_names);
+
+ page -> setLayout(layout);
+ return(page);
}
/**
Met en place l'etape 4 : Dimensions et Hotspot
*/
-void NewElementWizard::buildStep4() {
- step4 = new QWidget(this);
- QVBoxLayout *step4_layout = new QVBoxLayout(step4);
- QLabel *explication = new QLabel(tr("\311tape 4/5 : Saisissez les dimensions du nouvel \351l\351ment ainsi que la position du hotspot (point de saisie de l'\351l\351ment \340 la souris) en consid\351rant que l'\351l\351ment est dans son orientation par d\351faut."));
- explication -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
- explication -> setWordWrap(true);
- step4_layout -> addWidget(explication);
+QWizardPage *NewElementWizard::buildStep4() {
+ QWizardPage *page = new QWizardPage();
+ page -> setProperty("WizardState", Dimensions);
+ page -> setTitle(tr("\311tape 4/5 : Dimensions et point de saisie"));
+ page -> setSubTitle(tr("Saisissez les dimensions du nouvel \351l\351ment ainsi que la position du hotspot (point de saisie de l'\351l\351ment \340 la souris) en consid\351rant que l'\351l\351ment est dans son orientation par d\351faut."));
+ QVBoxLayout *layout = new QVBoxLayout();
+
hotspot_editor = new HotspotEditor();
- step4_layout -> addWidget(hotspot_editor, 0);
- step4_layout -> setSpacing(0);
+ layout -> addWidget(hotspot_editor, 0);
+ layout -> setSpacing(0);
+
+ page -> setLayout(layout);
+ return(page);
}
/**
Met en place l'etape 5 : orientations possibles pour le nouvel element
*/
-void NewElementWizard::buildStep5() {
- step5 = new QWidget(this);
-
- QLabel *explication = new QLabel(tr("\311tape 5/5 : Indiquez les orientations possibles pour le nouvel \351l\351ment."));
- explication -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
- explication -> setWordWrap(true);
+QWizardPage *NewElementWizard::buildStep5() {
+ QWizardPage *page = new QWizardPage();
+ page -> setProperty("WizardState", Orientations);
+ page -> setTitle(tr("\311tape 5/5 : Orientations"));
+ page -> setSubTitle(tr("Indiquez les orientations possibles pour le nouvel \351l\351ment."));
+ QVBoxLayout *layout = new QVBoxLayout();
orientation_set = new OrientationSetWidget();
+ layout -> addWidget(orientation_set);
+ layout -> addSpacing(25);
- QVBoxLayout *step5_layout = new QVBoxLayout();
- step5_layout -> addWidget(explication);
- step5_layout -> addWidget(orientation_set);
- step5_layout -> addSpacing(25);
- step5 -> setLayout(step5_layout);
+ page -> setLayout(layout);
+ return(page);
+}
+
+/// @return true si l'etape en cours est validee, false sinon
+bool NewElementWizard::validateCurrentPage() {
+ WizardState wizard_state = static_cast(currentPage() -> property("WizardState").toInt());
+ if (wizard_state == Category) return(validStep1());
+ else if (wizard_state == Filename) return(validStep2());
+ else if (wizard_state == Names) return(element_names -> checkOneName()); // il doit y avoir au moins un nom
+ else if (wizard_state == Orientations) {
+ createNewElement();
+ return(true);
+ }
+ else return(true);
}
/**
@@ -275,35 +192,6 @@ bool NewElementWizard::validStep2() {
return(true);
}
-/**
- Valide l'etape 3
- @return true si l'etape est validee, false sinon
-*/
-bool NewElementWizard::validStep3() {
- // il doit y avoir au moins un nom
- return(element_names -> checkOneName());
-}
-
-/**
- Valide l'etape 4
- @return true si l'etape est validee, false sinon
-*/
-bool NewElementWizard::validStep4() {
- // l'editeur de hotspot se charge deja de valider tout ca
- return(true);
-}
-
-/**
- Valide l'etape 5
- Cette fonction s'assure qu'il y ait toujours exactement une orientation
- "par defaut"
- @return true si l'etape est validee, false sinon
-*/
-bool NewElementWizard::validStep5() {
- // l'editeur d'orientations se charge deja de valider tout ca
- return(true);
-}
-
/**
Cree le nouvel element
*/
@@ -315,5 +203,4 @@ void NewElementWizard::createNewElement() {
edit_new_element -> setOrientations(orientation_set -> orientationSet());
edit_new_element -> setFileName(chosen_file);
edit_new_element -> show();
- accept();
}
diff --git a/newelementwizard.h b/newelementwizard.h
index 99df61eff..b311dfe0f 100644
--- a/newelementwizard.h
+++ b/newelementwizard.h
@@ -16,7 +16,7 @@ class ElementsCategoriesWidget;
class NamesListWidget;
class OrientationSetWidget;
class HotspotEditor;
-class NewElementWizard : public QDialog {
+class NewElementWizard : public QWizard {
Q_OBJECT
// constructeurs, destructeur
@@ -30,34 +30,24 @@ class NewElementWizard : public QDialog {
// attributs
private:
enum WizardState { Category, Filename, Names, Dimensions, Orientations };
- QString str_next, str_previous, str_finish;
- QWidget *step1, *step2, *step3, *step4, *step5;
ElementsCategoriesWidget* categories_list;
QLineEdit *qle_filename;
NamesListWidget *element_names;
OrientationSetWidget *orientation_set;
HotspotEditor *hotspot_editor;
- QPushButton *button_previous;
- QPushButton *button_next;
WizardState current_state;
QString chosen_file;
// methodes
private:
- void buildStep1();
- void buildStep2();
- void buildStep3();
- void buildStep4();
- void buildStep5();
+ QWizardPage *buildStep1();
+ QWizardPage *buildStep2();
+ QWizardPage *buildStep3();
+ QWizardPage *buildStep4();
+ QWizardPage *buildStep5();
bool validStep1();
bool validStep2();
- bool validStep3();
- bool validStep4();
- bool validStep5();
+ bool validateCurrentPage();
void createNewElement();
-
- public slots:
- void previous();
- void next();
};
#endif