[qet] [4029] Revamp the action white/grey background

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


Revision: 4029
Author:   blacksun
Date:     2015-06-25 20:23:47 +0200 (Thu, 25 Jun 2015)
Log Message:
-----------
Revamp the action white/grey background

Modified Paths:
--------------
    trunk/sources/diagramview.cpp
    trunk/sources/diagramview.h
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2015-06-24 16:55:43 UTC (rev 4028)
+++ trunk/sources/diagramview.cpp	2015-06-25 18:23:47 UTC (rev 4029)
@@ -350,16 +350,6 @@
 }
 
 /**
- * @brief DiagramView::refreshBg
- * Workaround to refresh the background color
- */
-void DiagramView::refreshBg() {
-	scale(2, 2);
-	scale(0.5, 0.5);
-	adjustGridToZoom();
-}
-
-/**
  * @brief DiagramView::zoomIn
  * Zoom in the current folio
  */

Modified: trunk/sources/diagramview.h
===================================================================
--- trunk/sources/diagramview.h	2015-06-24 16:55:43 UTC (rev 4028)
+++ trunk/sources/diagramview.h	2015-06-25 18:23:47 UTC (rev 4029)
@@ -135,7 +135,6 @@
 	void rotateTexts();
 	void setVisualisationMode();
 	void setSelectionMode();
-	void refreshBg();
 	void zoomIn();
 	void zoomOut();
 	void zoomInSlowly();

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2015-06-24 16:55:43 UTC (rev 4028)
+++ trunk/sources/qetdiagrameditor.cpp	2015-06-25 18:23:47 UTC (rev 4029)
@@ -189,8 +189,8 @@
  * @brief QETDiagramEditor::setUpActions
  * Set up all Qaction
  */
-void QETDiagramEditor::setUpActions() {
-	// icones et labels
+void QETDiagramEditor::setUpActions()
+{
 	export_diagram    = new QAction(QET::Icons::DocumentExport,        tr("E&xporter"),                            this);
 	print             = new QAction(QET::Icons::DocumentPrint,         tr("Imprimer"),                             this);
 	quit_editor       = new QAction(QET::Icons::ApplicationExit,       tr("&Quitter"),                             this);
@@ -207,15 +207,16 @@
 	m_auto_conductor = new QAction   (QET::Icons::Autoconnect, tr("Création automatique de conducteur(s)","Tool tip of auto conductor"), this);
 	m_auto_conductor -> setStatusTip (tr("Utiliser la création automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor"));
 	m_auto_conductor -> setCheckable (true);
-	m_auto_conductor -> setDisabled  (true);
 	connect(m_auto_conductor, SIGNAL(triggered(bool)), this, SLOT(slot_autoConductor(bool)));
 
 	m_grey_background = new QAction   (QET::Icons::DiagramBg, tr("Couleur de fond blanc/gris","Tool tip of white/grey background button"), this);
 	m_grey_background -> setStatusTip (tr("Affiche la couleur de fond du folio en blanc ou en gris", "Status tip of white/grey background button"));
 	m_grey_background -> setCheckable (true);
-	m_grey_background -> setDisabled  (true);
-	connect(m_grey_background, SIGNAL(triggered(bool)), this, SLOT(slot_whgyBackground(bool)));
-	connect(m_grey_background, SIGNAL(triggered(bool)), this, SLOT(slot_refreshBg()));
+	connect (m_grey_background, &QAction::triggered, [this](bool checked) {
+		Diagram::background_color = checked ? Qt::darkGray : Qt::white;
+		if (this->currentDiagram() &&  this->currentDiagram()->diagram())
+			this->currentDiagram()->diagram()->update();
+	});
 
 	infos_diagram     = new QAction(QET::Icons::DialogInformation,     tr("Propriétés du folio"),                 this);
 	prj_edit_prop     = new QAction(QET::Icons::DialogInformation,     tr("Propriétés du projet"),                 this);
@@ -447,22 +448,6 @@
 }
 
 /**
- * @brief QETDiagramEditor::slot_whgyBackground
- * @param checked
- */
-
-void QETDiagramEditor::slot_whgyBackground(bool checked) {
-	if (checked)
-	{
-		Diagram::background_color = Qt::darkGray;
-	}
-	else
-	{
-		Diagram::background_color = Qt::white;
-	}
-}
-
-/**
  * @brief QETDiagramEditor::setUpToolBar
  */
 void QETDiagramEditor::setUpToolBar() {
@@ -584,6 +569,8 @@
 	menu_affichage -> addAction(mode_selection);
 	menu_affichage -> addAction(mode_visualise);
 	menu_affichage -> addSeparator();
+	menu_affichage -> addAction(m_grey_background);
+	menu_affichage -> addSeparator();
 	menu_affichage -> addActions(m_zoom_actions_group.actions());
 
 	// menu Fenetres
@@ -1094,13 +1081,6 @@
 }
 
 /**
-    Do action "refresh background" on the current diagram
-*/
-void QETDiagramEditor::slot_refreshBg() {
-    if(currentDiagram()) currentDiagram() -> refreshBg();
-}
-
-/**
 	Effectue l'action "zoom avant" sur le diagram en cours
 */
 void QETDiagramEditor::slot_zoomIn() {
@@ -1228,6 +1208,7 @@
 	m_select_actions_group.    setEnabled(opened_diagram);
 	m_add_item_actions_group.  setEnabled(editable_project);
 	m_row_column_actions_group.setEnabled(editable_project);
+	m_grey_background->setEnabled(opened_diagram);
 
 
 	slot_updateUndoStack();
@@ -1336,17 +1317,14 @@
  * @brief QETDiagramEditor::slot_updateModeActions
  * Manage action who need an opened diagram or project to be updated
  */
-void QETDiagramEditor::slot_updateModeActions() {
+void QETDiagramEditor::slot_updateModeActions()
+{
 	DiagramView *dv = currentDiagram();
 	
 	if (!dv)
-	{
 		grp_visu_sel -> setEnabled(false);
-		m_grey_background -> setDisabled(true);
-	}
 	else
 	{
-		m_grey_background -> setEnabled(true);
 		switch((int)(dv -> dragMode()))
 		{
 			case QGraphicsView::NoDrag:
@@ -1363,7 +1341,6 @@
 		}
 	}
 
-
 	if (ProjectView *pv = currentProject())
 	{
 		m_auto_conductor -> setEnabled (true);

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2015-06-24 16:55:43 UTC (rev 4028)
+++ trunk/sources/qetdiagrameditor.h	2015-06-25 18:23:47 UTC (rev 4029)
@@ -118,8 +118,6 @@
 		void editSelectionProperties();
 		void slot_resetConductors();
 		void slot_autoConductor(bool ac);
-		void slot_whgyBackground(bool checked);
-		void slot_refreshBg();
 		void slot_addText();
 		void slot_addImage();
 		void slot_addLine();


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