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
This commit is contained in:
xavier
2010-02-28 02:52:10 +00:00
parent 4b9696e60d
commit 6c5f4d6ed7
6 changed files with 71 additions and 19 deletions

View File

@@ -807,6 +807,8 @@ void ElementScene::slot_delete() {
(hotspot) de l'element. (hotspot) de l'element.
*/ */
void ElementScene::slot_editSizeHotSpot() { void ElementScene::slot_editSizeHotSpot() {
bool is_read_only = element_editor && element_editor -> isReadOnly();
// cree un dialogue // cree un dialogue
QDialog dialog_sh(element_editor); QDialog dialog_sh(element_editor);
dialog_sh.setModal(true); dialog_sh.setModal(true);
@@ -824,23 +826,25 @@ void ElementScene::slot_editSizeHotSpot() {
hotspot_editor -> setOldHotspot(hotspot()); hotspot_editor -> setOldHotspot(hotspot());
hotspot_editor -> setPartsRect(itemsBoundingRect()); hotspot_editor -> setPartsRect(itemsBoundingRect());
hotspot_editor -> setPartsRectEnabled(true); hotspot_editor -> setPartsRectEnabled(true);
hotspot_editor -> setReadOnly(is_read_only);
dialog_layout -> addWidget(hotspot_editor); dialog_layout -> addWidget(hotspot_editor);
// ajoute deux boutons au dialogue // 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); dialog_layout -> addWidget(dialog_buttons);
connect(dialog_buttons, SIGNAL(accepted()), &dialog_sh, SLOT(accept())); connect(dialog_buttons, SIGNAL(accepted()), &dialog_sh, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog_sh, SLOT(reject())); connect(dialog_buttons, SIGNAL(rejected()), &dialog_sh, SLOT(reject()));
// lance le dialogue // lance le dialogue
if (dialog_sh.exec() != QDialog::Accepted) return; if (dialog_sh.exec() == QDialog::Accepted && is_read_only) {
QSize new_size(hotspot_editor -> elementSize()); QSize new_size(hotspot_editor -> elementSize());
QSize old_size(width(), height()); QSize old_size(width(), height());
QPoint new_hotspot(hotspot_editor -> hotspot()); QPoint new_hotspot(hotspot_editor -> hotspot());
QPoint old_hotspot(_hotspot); QPoint old_hotspot(_hotspot);
if (new_size != old_size || new_hotspot != old_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())); 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 Lance un dialogue pour editer les noms de cete element
*/ */
void ElementScene::slot_editOrientations() { void ElementScene::slot_editOrientations() {
bool is_read_only = element_editor && element_editor -> isReadOnly();
// cree un dialogue // cree un dialogue
QDialog dialog_ori(element_editor); QDialog dialog_ori(element_editor);
@@ -868,21 +873,23 @@ void ElementScene::slot_editOrientations() {
// ajoute un OrientationSetWidget au dialogue // ajoute un OrientationSetWidget au dialogue
OrientationSetWidget *ori_widget = new OrientationSetWidget(); OrientationSetWidget *ori_widget = new OrientationSetWidget();
ori_widget -> setOrientationSet(ori); ori_widget -> setOrientationSet(ori);
ori_widget -> setReadOnly(is_read_only);
dialog_layout -> addWidget(ori_widget); dialog_layout -> addWidget(ori_widget);
// ajoute une case a cocher pour les connexions internes // ajoute une case a cocher pour les connexions internes
QCheckBox *ic_checkbox = new QCheckBox(tr("Autoriser les connexions internes")); QCheckBox *ic_checkbox = new QCheckBox(tr("Autoriser les connexions internes"));
ic_checkbox -> setChecked(internal_connections); ic_checkbox -> setChecked(internal_connections);
ic_checkbox -> setDisabled(is_read_only);
dialog_layout -> addWidget(ic_checkbox); dialog_layout -> addWidget(ic_checkbox);
dialog_layout -> addStretch(); dialog_layout -> addStretch();
// ajoute deux boutons au dialogue // 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); dialog_layout -> addWidget(dialog_buttons);
connect(dialog_buttons, SIGNAL(accepted()), &dialog_ori, SLOT(accept())); connect(dialog_buttons, SIGNAL(accepted()), &dialog_ori, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog_ori, SLOT(reject())); connect(dialog_buttons, SIGNAL(rejected()), &dialog_ori, SLOT(reject()));
// lance le dialogue // lance le dialogue
if (dialog_ori.exec() == QDialog::Accepted) { if (dialog_ori.exec() == QDialog::Accepted && !is_read_only) {
OrientationSet new_ori = ori_widget -> orientationSet(); OrientationSet new_ori = ori_widget -> orientationSet();
if (new_ori != ori) { if (new_ori != ori) {
undoStack().push(new ChangeOrientationsCommand(this, ori, new_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. sur l'auteur de l'element, sa licence, etc.
*/ */
void ElementScene::slot_editAuthorInformations() { void ElementScene::slot_editAuthorInformations() {
bool is_read_only = element_editor && element_editor -> isReadOnly();
// cree un dialogue // cree un dialogue
QDialog dialog_author(element_editor); QDialog dialog_author(element_editor);
@@ -920,16 +928,17 @@ void ElementScene::slot_editAuthorInformations() {
QTextEdit *text_field = new QTextEdit(); QTextEdit *text_field = new QTextEdit();
text_field -> setAcceptRichText(false); text_field -> setAcceptRichText(false);
text_field -> setPlainText(informations()); text_field -> setPlainText(informations());
text_field -> setReadOnly(is_read_only);
dialog_layout -> addWidget(text_field); dialog_layout -> addWidget(text_field);
// ajoute deux boutons au dialogue // 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); dialog_layout -> addWidget(dialog_buttons);
connect(dialog_buttons, SIGNAL(accepted()), &dialog_author, SLOT(accept())); connect(dialog_buttons, SIGNAL(accepted()), &dialog_author, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject())); connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject()));
// lance le dialogue // lance le dialogue
if (dialog_author.exec() == QDialog::Accepted) { if (dialog_author.exec() == QDialog::Accepted && !is_read_only) {
QString new_infos = text_field -> toPlainText(); QString new_infos = text_field -> toPlainText();
if (new_infos != informations()) { if (new_infos != informations()) {
undoStack().push(new ChangeInformationsCommand(this, informations(), new_infos)); 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 Lance un dialogue pour editer les noms de cet element
*/ */
void ElementScene::slot_editNames() { void ElementScene::slot_editNames() {
bool is_read_only = element_editor && element_editor -> isReadOnly();
// cree un dialogue // cree un dialogue
QDialog dialog(element_editor); QDialog dialog(element_editor);
@@ -961,17 +971,18 @@ void ElementScene::slot_editNames() {
// ajoute un NamesListWidget au dialogue // ajoute un NamesListWidget au dialogue
NamesListWidget *names_widget = new NamesListWidget(); NamesListWidget *names_widget = new NamesListWidget();
names_widget -> setNames(_names); names_widget -> setNames(_names);
names_widget -> setReadOnly(is_read_only);
dialog_layout -> addWidget(names_widget); dialog_layout -> addWidget(names_widget);
// ajoute deux boutons au dialogue // 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); dialog_layout -> addWidget(dialog_buttons);
connect(dialog_buttons, SIGNAL(accepted()), names_widget, SLOT(check())); connect(dialog_buttons, SIGNAL(accepted()), names_widget, SLOT(check()));
connect(names_widget, SIGNAL(inputChecked()), &dialog, SLOT(accept())); connect(names_widget, SIGNAL(inputChecked()), &dialog, SLOT(accept()));
connect(dialog_buttons, SIGNAL(rejected()), &dialog, SLOT(reject())); connect(dialog_buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
// lance le dialogue // lance le dialogue
if (dialog.exec() == QDialog::Accepted) { if (dialog.exec() == QDialog::Accepted && !is_read_only) {
NamesList new_names(names_widget -> names()); NamesList new_names(names_widget -> names());
if (new_names != _names) undoStack().push(new ChangeNamesCommand(this, _names, new_names)); if (new_names != _names) undoStack().push(new ChangeNamesCommand(this, _names, new_names));
} }

View File

@@ -446,10 +446,6 @@ void QETElementEditor::slot_updateMenus() {
inv_select -> setEnabled(!read_only); inv_select -> setEnabled(!read_only);
paste_from_file -> setEnabled(!read_only); paste_from_file -> setEnabled(!read_only);
paste_from_elmt -> 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); parts_list -> setEnabled(!read_only);
// actions dependant de la presence de parties selectionnees // actions dependant de la presence de parties selectionnees

View File

@@ -34,10 +34,12 @@ HotspotEditor::HotspotEditor(QWidget *parent) :
sb_width = new QSpinBox(); sb_width = new QSpinBox();
sb_width -> setMinimum(1); sb_width -> setMinimum(1);
sb_width -> setMaximum(1000);
sb_width -> setValue(3); sb_width -> setValue(3);
sb_width -> setSuffix(tr(" \32710 px")); sb_width -> setSuffix(tr(" \32710 px"));
sb_height = new QSpinBox(); sb_height = new QSpinBox();
sb_height -> setMinimum(1); sb_height -> setMinimum(1);
sb_height -> setMaximum(1000);
sb_height -> setValue(7); sb_height -> setValue(7);
sb_height -> setSuffix(tr(" \32710 px")); sb_height -> setSuffix(tr(" \32710 px"));
@@ -223,6 +225,24 @@ QPoint HotspotEditor::offsetParts() const {
else return(old_hotspot - hotspot()); 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 Met a jour le schema
*/ */

View File

@@ -70,6 +70,8 @@ class HotspotEditor : public QWidget {
bool partsRectEnabled(); bool partsRectEnabled();
bool mustTranslateParts() const; bool mustTranslateParts() const;
QPoint offsetParts() const; QPoint offsetParts() const;
bool isReadOnly() const;
void setReadOnly(bool);
public slots: public slots:
void updateScene(); void updateScene();

View File

@@ -98,6 +98,27 @@ void OrientationSetWidget::setOrientationSet(const OrientationSet &os) {
updateForm(); 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. Slot gerant le changement d'orientation par defaut.
L'orientation concernee affiche alors "Possible" et ce statut devient L'orientation concernee affiche alors "Possible" et ce statut devient

View File

@@ -49,6 +49,8 @@ class OrientationSetWidget : public QWidget {
public: public:
OrientationSet orientationSet() const; OrientationSet orientationSet() const;
void setOrientationSet(const OrientationSet &); void setOrientationSet(const OrientationSet &);
bool isReadOnly() const;
void setReadOnly(bool);
private: private:
void updateForm(); void updateForm();