From d5a3dbc461f1a4a97782d9e07fe2967b1525873f Mon Sep 17 00:00:00 2001 From: xavier Date: Wed, 9 May 2012 21:17:12 +0000 Subject: [PATCH] TBT editor: added informative texts regarding labels and values. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1783 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/titleblock/templatecellwidget.cpp | 59 ++++++++++++++++++++--- sources/titleblock/templatecellwidget.h | 2 + sources/titleblockpropertieswidget.cpp | 2 +- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/sources/titleblock/templatecellwidget.cpp b/sources/titleblock/templatecellwidget.cpp index 73aa7ec3c..01fc429a2 100644 --- a/sources/titleblock/templatecellwidget.cpp +++ b/sources/titleblock/templatecellwidget.cpp @@ -245,7 +245,7 @@ void TitleBlockTemplateCellWidget::editLabelDisplayed() { */ void TitleBlockTemplateCellWidget::editLabel() { if (!edited_cell_) return; - editTranslatableValue(edited_cell_ -> label, "label", tr("Label de cette cellule :")); + editTranslatableValue(edited_cell_ -> label, "label", tr("Label de cette cellule")); label_input_ -> setText(edited_cell_ -> label.name()); } @@ -255,7 +255,7 @@ void TitleBlockTemplateCellWidget::editLabel() { */ void TitleBlockTemplateCellWidget::editValue() { if (!edited_cell_) return; - editTranslatableValue(edited_cell_ -> value, "value", tr("Valeur de cette cellule :")); + editTranslatableValue(edited_cell_ -> value, "value", tr("Valeur de cette cellule")); value_input_ -> setText(edited_cell_ -> value.name()); } @@ -372,19 +372,28 @@ bool TitleBlockTemplateCellWidget::isReadOnly() const { ModifyTitleBlockCellCommand object through the cellModified() signal. @param names Translatable string to be edited @param attribute Name of the edited cell attribute - @param label Label to be displayed when editing the string + @param title Title of the dialog window */ -void TitleBlockTemplateCellWidget::editTranslatableValue(NamesList &names, const QString &attribute, const QString &label) const { +void TitleBlockTemplateCellWidget::editTranslatableValue(NamesList &names, const QString &attribute, const QString &title) const { NamesListWidget *names_widget = new NamesListWidget(); names_widget -> setNames(names); QDialogButtonBox * buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QLabel *information = new QLabel(labelValueInformationString()); + information -> setTextFormat(Qt::RichText); + information -> setWordWrap(true); + + QLabel *def_var_label = new QLabel(defaultVariablesString()); + def_var_label -> setTextFormat(Qt::RichText); + QVBoxLayout *editor_layout = new QVBoxLayout(); - editor_layout -> addWidget(new QLabel(label)); + editor_layout -> addWidget(information); editor_layout -> addWidget(names_widget); + editor_layout -> addWidget(def_var_label); editor_layout -> addWidget(buttons); QDialog edit_dialog; + edit_dialog.setWindowTitle(title); connect(buttons, SIGNAL(rejected()), &edit_dialog, SLOT(reject())); connect(buttons, SIGNAL(accepted()), &edit_dialog, SLOT(accept())); edit_dialog.setLayout(editor_layout); @@ -410,8 +419,46 @@ void TitleBlockTemplateCellWidget::emitModification(const QString &attribute, co ModifyTitleBlockCellCommand *command = new ModifyTitleBlockCellCommand(edited_cell_); command -> addModification(attribute, new_value); command -> setText( - tr("Édition d'une cellule : %1", "label of and undo command when editing a cell") + tr("\311dition d'une cellule : %1", "label of and undo command when editing a cell") .arg(TitleBlockCell::attributeName(attribute)) ); emit(cellModified(command)); } + +/** + @return a string describing the various variables provided by default by + the application. +*/ +QString TitleBlockTemplateCellWidget::defaultVariablesString() const { + QString def_var_string = tr( + "Par d\351faut, les variables suivantes sont disponibles :" + "" + ); + return(def_var_string); +} + +/** + @return a string describing what the user may enter as cell label / value. +*/ +QString TitleBlockTemplateCellWidget::labelValueInformationString() const { + QString lab_val_inf_string = tr( + "Chaque cellule d'un cartouche affiche une valeur, optionnellement " + "pr\351c\351d\351e d'un label. Tous deux peuvent \352tre traduits en " + "plusieurs langues." + "
" + "Comme ce que vous \351ditez actuellement est un " + "mod\350le de cartouche, ne saisissez pas directement des " + "donn\351es brutes : ins\351rez plut\364t des variables sous la forme " + "%{nom-de-variable}, qui seront ensuite remplac\351es par la valeur " + "ad\351quate sur le folio." + ); + return(lab_val_inf_string); +} diff --git a/sources/titleblock/templatecellwidget.h b/sources/titleblock/templatecellwidget.h index f9d983c5f..a23b87b3c 100644 --- a/sources/titleblock/templatecellwidget.h +++ b/sources/titleblock/templatecellwidget.h @@ -86,6 +86,8 @@ class TitleBlockTemplateCellWidget : public QWidget { protected: void editTranslatableValue(NamesList &, const QString &, const QString &) const; void emitModification(const QString &, const QVariant &) const; + QString defaultVariablesString() const; + QString labelValueInformationString() const; private: void initWidgets(); diff --git a/sources/titleblockpropertieswidget.cpp b/sources/titleblockpropertieswidget.cpp index 79f2b354b..bcea3d8d9 100644 --- a/sources/titleblockpropertieswidget.cpp +++ b/sources/titleblockpropertieswidget.cpp @@ -338,7 +338,7 @@ void TitleBlockPropertiesWidget::initWidgets(const TitleBlockProperties &titlebl tr( "Vous pouvez définir ici vos propres associations noms/valeurs pour" " que le cartouche en tienne compte. Exemple : associer le nom " - "\"volta\" et la valeur \"1745\" remplacera %volta par 1745 dans le " + "\"volta\" et la valeur \"1745\" remplacera %{volta} par 1745 dans le " "cartouche." ) );