[qet] [869] Les proprietes (noms, dimensions, point de saisie, orientations, connexions internes et informations complementaires) des elements sont desormais accessibles en mode lecture seule.

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 869
Author:   xavier
Date:     2010-02-28 03:52:10 +0100 (Sun, 28 Feb 2010)
Log Message:
-----------
Les proprietes (noms, dimensions, point de saisie, orientations, connexions internes et informations complementaires) des elements sont desormais accessibles en mode lecture seule.

Modified Paths:
--------------
    trunk/sources/editor/elementscene.cpp
    trunk/sources/editor/qetelementeditor.cpp
    trunk/sources/hotspoteditor.cpp
    trunk/sources/hotspoteditor.h
    trunk/sources/orientationsetwidget.cpp
    trunk/sources/orientationsetwidget.h

Modified: trunk/sources/editor/elementscene.cpp
===================================================================
--- trunk/sources/editor/elementscene.cpp	2010-02-28 02:17:25 UTC (rev 868)
+++ trunk/sources/editor/elementscene.cpp	2010-02-28 02:52:10 UTC (rev 869)
@@ -807,6 +807,8 @@
 	(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 @@
 	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 @@
 	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 @@
 	// 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 @@
 	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 @@
 	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 @@
 	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 @@
 	// 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));
 	}

Modified: trunk/sources/editor/qetelementeditor.cpp
===================================================================
--- trunk/sources/editor/qetelementeditor.cpp	2010-02-28 02:17:25 UTC (rev 868)
+++ trunk/sources/editor/qetelementeditor.cpp	2010-02-28 02:52:10 UTC (rev 869)
@@ -446,10 +446,6 @@
 	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

Modified: trunk/sources/hotspoteditor.cpp
===================================================================
--- trunk/sources/hotspoteditor.cpp	2010-02-28 02:17:25 UTC (rev 868)
+++ trunk/sources/hotspoteditor.cpp	2010-02-28 02:52:10 UTC (rev 869)
@@ -34,10 +34,12 @@
 	
 	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"));
 	
@@ -224,6 +226,24 @@
 }
 
 /**
+	@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
 */
 void HotspotEditor::updateScene() {

Modified: trunk/sources/hotspoteditor.h
===================================================================
--- trunk/sources/hotspoteditor.h	2010-02-28 02:17:25 UTC (rev 868)
+++ trunk/sources/hotspoteditor.h	2010-02-28 02:52:10 UTC (rev 869)
@@ -70,6 +70,8 @@
 	bool partsRectEnabled();
 	bool mustTranslateParts() const;
 	QPoint offsetParts() const;
+	bool isReadOnly() const;
+	void setReadOnly(bool);
 	
 	public slots:
 	void updateScene();

Modified: trunk/sources/orientationsetwidget.cpp
===================================================================
--- trunk/sources/orientationsetwidget.cpp	2010-02-28 02:17:25 UTC (rev 868)
+++ trunk/sources/orientationsetwidget.cpp	2010-02-28 02:52:10 UTC (rev 869)
@@ -99,6 +99,27 @@
 }
 
 /**
+	@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
 	impossible a modifier.

Modified: trunk/sources/orientationsetwidget.h
===================================================================
--- trunk/sources/orientationsetwidget.h	2010-02-28 02:17:25 UTC (rev 868)
+++ trunk/sources/orientationsetwidget.h	2010-02-28 02:52:10 UTC (rev 869)
@@ -49,6 +49,8 @@
 	public:
 	OrientationSet orientationSet() const;
 	void setOrientationSet(const OrientationSet &);
+	bool isReadOnly() const;
+	void setReadOnly(bool);
 	
 	private:
 	void updateForm();


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/