[qet] [4022] Add a new button in the display tool bar to switch the background color in white or grey on the fly.

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


Revision: 4022
Author:   nuri
Date:     2015-06-21 13:00:08 +0200 (Sun, 21 Jun 2015)
Log Message:
-----------
Add a new button in the display tool bar to switch the background color in white or grey on the fly.
The check box for this functionality in the DiagramProporties window was deleted.

Modified Paths:
--------------
    trunk/qelectrotech.qrc
    trunk/sources/diagramview.cpp
    trunk/sources/diagramview.h
    trunk/sources/qetdiagrameditor.cpp
    trunk/sources/qetdiagrameditor.h
    trunk/sources/qeticons.cpp
    trunk/sources/qeticons.h
    trunk/sources/ui/borderpropertieswidget.cpp
    trunk/sources/ui/borderpropertieswidget.h

Added Paths:
-----------
    trunk/ico/22x22/diagram_bg.png

Added: trunk/ico/22x22/diagram_bg.png
===================================================================
(Binary files differ)


Property changes on: trunk/ico/22x22/diagram_bg.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: trunk/qelectrotech.qrc
===================================================================
--- trunk/qelectrotech.qrc	2015-06-20 09:10:57 UTC (rev 4021)
+++ trunk/qelectrotech.qrc	2015-06-21 11:00:08 UTC (rev 4022)
@@ -244,5 +244,6 @@
         <file>ico/16x16/folio-new.png</file>
         <file>ico/48x48/document-print-frame.png</file>
         <file>ico/22x22/Actions-player-time-icon.png</file>
+        <file>ico/22x22/diagram_bg.png</file>
     </qresource>
 </RCC>

Modified: trunk/sources/diagramview.cpp
===================================================================
--- trunk/sources/diagramview.cpp	2015-06-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/diagramview.cpp	2015-06-21 11:00:08 UTC (rev 4022)
@@ -350,6 +350,16 @@
 }
 
 /**
+ * @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-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/diagramview.h	2015-06-21 11:00:08 UTC (rev 4022)
@@ -135,6 +135,7 @@
 	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-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/qetdiagrameditor.cpp	2015-06-21 11:00:08 UTC (rev 4022)
@@ -210,6 +210,13 @@
 	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()));
+
     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);
     prj_add_diagram   = new QAction(QET::Icons::DiagramAdd,            tr("Ajouter un folio"),                    this);
@@ -440,6 +447,22 @@
 }
 
 /**
+ * @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() {
@@ -469,6 +492,8 @@
 	view_bar -> addAction(mode_selection);
 	view_bar -> addAction(mode_visualise);
 	view_bar -> addSeparator();
+    view_bar -> addAction (m_grey_background);
+    view_bar -> addSeparator();
 	view_bar -> addActions(m_zoom_action_toolBar);
 
 	diagram_bar -> addAction (infos_diagram);
@@ -1069,6 +1094,13 @@
 }
 
 /**
+    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() {
@@ -1310,10 +1342,12 @@
 	if (!dv)
 	{
 		grp_visu_sel -> setEnabled(false);
+        m_grey_background -> setDisabled(true);
 	}
 	else
 	{
-		switch((int)(dv -> dragMode()))
+        m_grey_background -> setEnabled(true);
+        switch((int)(dv -> dragMode()))
 		{
 			case QGraphicsView::NoDrag:
 				grp_visu_sel -> setEnabled(false);

Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h	2015-06-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/qetdiagrameditor.h	2015-06-21 11:00:08 UTC (rev 4022)
@@ -118,6 +118,8 @@
 		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();
@@ -186,7 +188,8 @@
 		QAction *conductor_reset;    ///< Reset paths of selected conductors
 		QAction *m_auto_conductor;   ///< Enable/Disable the use of auto conductor
 		QAction *conductor_default;  ///< Show a dialog to edit default conductor properties
-		QAction *infos_diagram;      ///< Show a dialog to edit diagram properties
+        QAction *m_grey_background;  ///< Switch the background color in white or grey
+        QAction *infos_diagram;      ///< Show a dialog to edit diagram properties
 		QAction *prj_edit_prop;      ///< Edit the properties of the current project.
 		QAction *prj_add_diagram;    ///< Add a diagram to the current project.
 		QAction *prj_del_diagram;    ///< Delete a diagram from the current project

Modified: trunk/sources/qeticons.cpp
===================================================================
--- trunk/sources/qeticons.cpp	2015-06-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/qeticons.cpp	2015-06-21 11:00:08 UTC (rev 4022)
@@ -40,7 +40,8 @@
 		QIcon DefaultConductor;
 		QIcon DiagramAdd;
 		QIcon Diagram;
-		QIcon DiagramDelete;
+        QIcon DiagramBg;
+        QIcon DiagramDelete;
 		QIcon DialogCancel;
 		QIcon DialogInformation;
 		QIcon DialogOk;
@@ -219,7 +220,8 @@
 	DefaultConductor    .addFile(":/ico/22x22/conductor3.png");
 	DiagramAdd          .addFile(":/ico/22x22/diagram_add.png");
 	Diagram             .addFile(":/ico/diagram.png");
-	DiagramDelete       .addFile(":/ico/22x22/diagram_del.png");
+    DiagramBg           .addFile(":/ico/22x22/diagram_bg.png");
+    DiagramDelete       .addFile(":/ico/22x22/diagram_del.png");
 	DialogCancel        .addFile(":/ico/16x16/dialog-cancel.png");
 	DialogCancel        .addFile(":/ico/22x22/dialog-cancel.png");
 	DialogInformation   .addFile(":/ico/22x22/dialog-information.png");

Modified: trunk/sources/qeticons.h
===================================================================
--- trunk/sources/qeticons.h	2015-06-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/qeticons.h	2015-06-21 11:00:08 UTC (rev 4022)
@@ -47,6 +47,7 @@
 		extern QIcon DefaultConductor;
 		extern QIcon DiagramAdd;
 		extern QIcon Diagram;
+        extern QIcon DiagramBg;
 		extern QIcon DiagramDelete;
 		extern QIcon DialogCancel;
 		extern QIcon DialogInformation;

Modified: trunk/sources/ui/borderpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/borderpropertieswidget.cpp	2015-06-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/ui/borderpropertieswidget.cpp	2015-06-21 11:00:08 UTC (rev 4022)
@@ -55,7 +55,6 @@
 	ui -> m_rows_count_sp      ->setValue   (m_properties.rows_count);
 	ui -> m_rows_height_sp     ->setValue   (m_properties.rows_height);
 	ui -> m_display_rows_cb    ->setChecked (m_properties.display_rows);
-	ui -> m_grey_bg_cb         ->setChecked (Diagram::background_color != Qt::white);
 }
 
 /**
@@ -80,14 +79,3 @@
 void BorderPropertiesWidget::setReadOnly(const bool &ro) {
 	ui->border_gb->setDisabled(ro);
 }
-
-/**
- * @brief BorderPropertiesWidget::on_m_grey_bg_cb_clicked
- * @param checked
- */
-void BorderPropertiesWidget::on_m_grey_bg_cb_clicked(bool checked) {
-	if (checked)
-		Diagram::background_color = Qt::gray;
-	else
-		Diagram::background_color = Qt::white;
-}

Modified: trunk/sources/ui/borderpropertieswidget.h
===================================================================
--- trunk/sources/ui/borderpropertieswidget.h	2015-06-20 09:10:57 UTC (rev 4021)
+++ trunk/sources/ui/borderpropertieswidget.h	2015-06-21 11:00:08 UTC (rev 4022)
@@ -42,7 +42,6 @@
 		void setReadOnly (const bool &ro);
 
 	private slots:
-		void on_m_grey_bg_cb_clicked(bool checked);
 
 	private:
 		Ui::BorderPropertiesWidget *ui;


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