From 6c5f4d6ed7b811fbb3250541ed02688138261834 Mon Sep 17 00:00:00 2001 From: xavier Date: Sun, 28 Feb 2010 02:52:10 +0000 Subject: [PATCH] Les proprietes (noms, dimensions, point de saisie, orientations, connexions internes et informations complementaires) des elements sont desormais accessibles en mode lecture seule. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@869 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/editor/elementscene.cpp | 41 ++++++++++++++++++----------- sources/editor/qetelementeditor.cpp | 4 --- sources/hotspoteditor.cpp | 20 ++++++++++++++ sources/hotspoteditor.h | 2 ++ sources/orientationsetwidget.cpp | 21 +++++++++++++++ sources/orientationsetwidget.h | 2 ++ 6 files changed, 71 insertions(+), 19 deletions(-) diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index 03160b556..4c9e85c67 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -807,6 +807,8 @@ void ElementScene::slot_delete() { (hotspot) de l'element. */ void ElementScene::slot_editSizeHotSpot() { + bool is_read_only = element_editor && element_editor -> isReadOnly(); + // cree un dialogue QDialog dialog_sh(element_editor); dialog_sh.setModal(true); @@ -824,23 +826,25 @@ void ElementScene::slot_editSizeHotSpot() { hotspot_editor -> setOldHotspot(hotspot()); hotspot_editor -> setPartsRect(itemsBoundingRect()); hotspot_editor -> setPartsRectEnabled(true); + hotspot_editor -> setReadOnly(is_read_only); dialog_layout -> addWidget(hotspot_editor); // ajoute deux boutons au dialogue - QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox *dialog_buttons = new QDialogButtonBox(is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog_layout -> addWidget(dialog_buttons); connect(dialog_buttons, SIGNAL(accepted()), &dialog_sh, SLOT(accept())); connect(dialog_buttons, SIGNAL(rejected()), &dialog_sh, SLOT(reject())); // lance le dialogue - if (dialog_sh.exec() != QDialog::Accepted) return; - QSize new_size(hotspot_editor -> elementSize()); - QSize old_size(width(), height()); - QPoint new_hotspot(hotspot_editor -> hotspot()); - QPoint old_hotspot(_hotspot); - - if (new_size != old_size || new_hotspot != old_hotspot) { - undo_stack.push(new ChangeHotspotCommand(this, old_size, new_size, old_hotspot, new_hotspot, hotspot_editor -> offsetParts())); + if (dialog_sh.exec() == QDialog::Accepted && is_read_only) { + QSize new_size(hotspot_editor -> elementSize()); + QSize old_size(width(), height()); + QPoint new_hotspot(hotspot_editor -> hotspot()); + QPoint old_hotspot(_hotspot); + + if (new_size != old_size || new_hotspot != old_hotspot) { + undo_stack.push(new ChangeHotspotCommand(this, old_size, new_size, old_hotspot, new_hotspot, hotspot_editor -> offsetParts())); + } } } @@ -848,6 +852,7 @@ void ElementScene::slot_editSizeHotSpot() { Lance un dialogue pour editer les noms de cete element */ void ElementScene::slot_editOrientations() { + bool is_read_only = element_editor && element_editor -> isReadOnly(); // cree un dialogue QDialog dialog_ori(element_editor); @@ -868,21 +873,23 @@ void ElementScene::slot_editOrientations() { // ajoute un OrientationSetWidget au dialogue OrientationSetWidget *ori_widget = new OrientationSetWidget(); ori_widget -> setOrientationSet(ori); + ori_widget -> setReadOnly(is_read_only); dialog_layout -> addWidget(ori_widget); // ajoute une case a cocher pour les connexions internes QCheckBox *ic_checkbox = new QCheckBox(tr("Autoriser les connexions internes")); ic_checkbox -> setChecked(internal_connections); + ic_checkbox -> setDisabled(is_read_only); dialog_layout -> addWidget(ic_checkbox); dialog_layout -> addStretch(); // ajoute deux boutons au dialogue - QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox *dialog_buttons = new QDialogButtonBox(is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog_layout -> addWidget(dialog_buttons); connect(dialog_buttons, SIGNAL(accepted()), &dialog_ori, SLOT(accept())); connect(dialog_buttons, SIGNAL(rejected()), &dialog_ori, SLOT(reject())); // lance le dialogue - if (dialog_ori.exec() == QDialog::Accepted) { + if (dialog_ori.exec() == QDialog::Accepted && !is_read_only) { OrientationSet new_ori = ori_widget -> orientationSet(); if (new_ori != ori) { undoStack().push(new ChangeOrientationsCommand(this, ori, new_ori)); @@ -899,6 +906,7 @@ void ElementScene::slot_editOrientations() { sur l'auteur de l'element, sa licence, etc. */ void ElementScene::slot_editAuthorInformations() { + bool is_read_only = element_editor && element_editor -> isReadOnly(); // cree un dialogue QDialog dialog_author(element_editor); @@ -920,16 +928,17 @@ void ElementScene::slot_editAuthorInformations() { QTextEdit *text_field = new QTextEdit(); text_field -> setAcceptRichText(false); text_field -> setPlainText(informations()); + text_field -> setReadOnly(is_read_only); dialog_layout -> addWidget(text_field); // ajoute deux boutons au dialogue - QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox *dialog_buttons = new QDialogButtonBox(is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog_layout -> addWidget(dialog_buttons); connect(dialog_buttons, SIGNAL(accepted()), &dialog_author, SLOT(accept())); connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject())); // lance le dialogue - if (dialog_author.exec() == QDialog::Accepted) { + if (dialog_author.exec() == QDialog::Accepted && !is_read_only) { QString new_infos = text_field -> toPlainText(); if (new_infos != informations()) { undoStack().push(new ChangeInformationsCommand(this, informations(), new_infos)); @@ -941,6 +950,7 @@ void ElementScene::slot_editAuthorInformations() { Lance un dialogue pour editer les noms de cet element */ void ElementScene::slot_editNames() { + bool is_read_only = element_editor && element_editor -> isReadOnly(); // cree un dialogue QDialog dialog(element_editor); @@ -961,17 +971,18 @@ void ElementScene::slot_editNames() { // ajoute un NamesListWidget au dialogue NamesListWidget *names_widget = new NamesListWidget(); names_widget -> setNames(_names); + names_widget -> setReadOnly(is_read_only); dialog_layout -> addWidget(names_widget); // ajoute deux boutons au dialogue - QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + QDialogButtonBox *dialog_buttons = new QDialogButtonBox(is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel); dialog_layout -> addWidget(dialog_buttons); connect(dialog_buttons, SIGNAL(accepted()), names_widget, SLOT(check())); connect(names_widget, SIGNAL(inputChecked()), &dialog, SLOT(accept())); connect(dialog_buttons, SIGNAL(rejected()), &dialog, SLOT(reject())); // lance le dialogue - if (dialog.exec() == QDialog::Accepted) { + if (dialog.exec() == QDialog::Accepted && !is_read_only) { NamesList new_names(names_widget -> names()); if (new_names != _names) undoStack().push(new ChangeNamesCommand(this, _names, new_names)); } diff --git a/sources/editor/qetelementeditor.cpp b/sources/editor/qetelementeditor.cpp index 3cf9dc8c3..a2783d13c 100644 --- a/sources/editor/qetelementeditor.cpp +++ b/sources/editor/qetelementeditor.cpp @@ -446,10 +446,6 @@ void QETElementEditor::slot_updateMenus() { inv_select -> setEnabled(!read_only); paste_from_file -> setEnabled(!read_only); paste_from_elmt -> setEnabled(!read_only); - edit_size_hs -> setEnabled(!read_only); - edit_names -> setEnabled(!read_only); - edit_ori -> setEnabled(!read_only); - edit_author -> setEnabled(!read_only); parts_list -> setEnabled(!read_only); // actions dependant de la presence de parties selectionnees diff --git a/sources/hotspoteditor.cpp b/sources/hotspoteditor.cpp index 4434d3738..716c492bc 100644 --- a/sources/hotspoteditor.cpp +++ b/sources/hotspoteditor.cpp @@ -34,10 +34,12 @@ HotspotEditor::HotspotEditor(QWidget *parent) : sb_width = new QSpinBox(); sb_width -> setMinimum(1); + sb_width -> setMaximum(1000); sb_width -> setValue(3); sb_width -> setSuffix(tr(" \32710 px")); sb_height = new QSpinBox(); sb_height -> setMinimum(1); + sb_height -> setMaximum(1000); sb_height -> setValue(7); sb_height -> setSuffix(tr(" \32710 px")); @@ -223,6 +225,24 @@ QPoint HotspotEditor::offsetParts() const { else return(old_hotspot - hotspot()); } +/** + @return true si ce widget est en lecture seule, false sinon +*/ +bool HotspotEditor::isReadOnly() const { + return(sb_width -> isReadOnly()); +} + +/** + @param ro true pour passer ce widget en lecture seule, false sinon +*/ +void HotspotEditor::setReadOnly(bool ro) { + sb_width -> setReadOnly(ro); + sb_height -> setReadOnly(ro); + sb_hotspot_x -> setReadOnly(ro); + sb_hotspot_y -> setReadOnly(ro); + hotspot_sync -> setDisabled(ro); +} + /** Met a jour le schema */ diff --git a/sources/hotspoteditor.h b/sources/hotspoteditor.h index a337b66ba..32c520504 100644 --- a/sources/hotspoteditor.h +++ b/sources/hotspoteditor.h @@ -70,6 +70,8 @@ class HotspotEditor : public QWidget { bool partsRectEnabled(); bool mustTranslateParts() const; QPoint offsetParts() const; + bool isReadOnly() const; + void setReadOnly(bool); public slots: void updateScene(); diff --git a/sources/orientationsetwidget.cpp b/sources/orientationsetwidget.cpp index 086396463..042b47b43 100644 --- a/sources/orientationsetwidget.cpp +++ b/sources/orientationsetwidget.cpp @@ -98,6 +98,27 @@ void OrientationSetWidget::setOrientationSet(const OrientationSet &os) { updateForm(); } +/** + @return true si ce widget est en lecture seule, false sinon +*/ +bool OrientationSetWidget::isReadOnly() const { + return(!north_orientation -> isEnabled()); +} + +/** + @param ro true pour passer ce widget en lecture seule, false sinon +*/ +void OrientationSetWidget::setReadOnly(bool ro) { + north_orientation -> setDisabled(ro); + east_orientation -> setDisabled(ro); + south_orientation -> setDisabled(ro); + west_orientation -> setDisabled(ro); + north_default -> setDisabled(ro); + east_default -> setDisabled(ro); + south_default -> setDisabled(ro); + west_default -> setDisabled(ro); +} + /** Slot gerant le changement d'orientation par defaut. L'orientation concernee affiche alors "Possible" et ce statut devient diff --git a/sources/orientationsetwidget.h b/sources/orientationsetwidget.h index 6716e49f0..120e68bac 100644 --- a/sources/orientationsetwidget.h +++ b/sources/orientationsetwidget.h @@ -49,6 +49,8 @@ class OrientationSetWidget : public QWidget { public: OrientationSet orientationSet() const; void setOrientationSet(const OrientationSet &); + bool isReadOnly() const; + void setReadOnly(bool); private: void updateForm();