From ab1d558f61f7bba779d1f1b4223039614b59b3d3 Mon Sep 17 00:00:00 2001 From: nuri Date: Sun, 21 Jun 2015 11:00:08 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4022 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- ico/22x22/diagram_bg.png | Bin 0 -> 359 bytes qelectrotech.qrc | 1 + sources/diagramview.cpp | 10 +++++++ sources/diagramview.h | 1 + sources/qetdiagrameditor.cpp | 36 +++++++++++++++++++++++++- sources/qetdiagrameditor.h | 5 +++- sources/qeticons.cpp | 6 +++-- sources/qeticons.h | 1 + sources/ui/borderpropertieswidget.cpp | 12 --------- sources/ui/borderpropertieswidget.h | 1 - 10 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 ico/22x22/diagram_bg.png diff --git a/ico/22x22/diagram_bg.png b/ico/22x22/diagram_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..558b572c5e89d5b6a45fa6167b971d84bfdd71f5 GIT binary patch literal 359 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~t2{5eyz2HNO+cY9o-U3d7N@UXIlZdcK!EMR|0(-Y z=bhhPV5;P}Nl<*3prD|5Qs`K zuX>i+jcvRP7Vkn6FPkVReW~3qKPOev;`xQB|MT{;NGA)p3fA2JFJ3Jb=G9o-XLEl2 zvH4BA*D(t&%)LF^a`wYbIu9-Qo>lIfy`8h~v4j(c#OEDf!w*Jfb0|(wIr&OS?$Be4 zrjCHntIM=^b6+pzRXSwAGh6)4JDAnqPl5|NDK7^N8;D>^(UjT7mv&@O1TaS?83{1OTXW BjvoL3 literal 0 HcmV?d00001 diff --git a/qelectrotech.qrc b/qelectrotech.qrc index e7eef6ac5..9f78232a2 100644 --- a/qelectrotech.qrc +++ b/qelectrotech.qrc @@ -244,5 +244,6 @@ ico/16x16/folio-new.png ico/48x48/document-print-frame.png ico/22x22/Actions-player-time-icon.png + ico/22x22/diagram_bg.png diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 6d684cea8..b9dd1c954 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -349,6 +349,16 @@ void DiagramView::setSelectionMode() { emit(modeChanged()); } +/** + * @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 diff --git a/sources/diagramview.h b/sources/diagramview.h index 793047a90..e30ec2b67 100644 --- a/sources/diagramview.h +++ b/sources/diagramview.h @@ -135,6 +135,7 @@ class DiagramView : public QGraphicsView { void rotateTexts(); void setVisualisationMode(); void setSelectionMode(); + void refreshBg(); void zoomIn(); void zoomOut(); void zoomInSlowly(); diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 02b649a67..49bdd02fa 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -210,6 +210,13 @@ void QETDiagramEditor::setUpActions() { 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); @@ -439,6 +446,22 @@ void QETDiagramEditor::setUpActions() { connect(infos_diagram, SIGNAL(triggered()), this, SLOT(editCurrentDiagramProperties())); } +/** + * @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 */ @@ -469,6 +492,8 @@ void QETDiagramEditor::setUpToolBar() { 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); @@ -1068,6 +1093,13 @@ void QETDiagramEditor::slot_paste() { if(currentDiagram()) currentDiagram() -> paste(); } +/** + 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 */ @@ -1310,10 +1342,12 @@ void QETDiagramEditor::slot_updateModeActions() { 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); diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index 8ecefc455..02286476e 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -118,6 +118,8 @@ class QETDiagramEditor : public QETMainWindow { 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 @@ class QETDiagramEditor : public QETMainWindow { 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 diff --git a/sources/qeticons.cpp b/sources/qeticons.cpp index bdb35098e..5878fdc4a 100644 --- a/sources/qeticons.cpp +++ b/sources/qeticons.cpp @@ -40,7 +40,8 @@ namespace QET { QIcon DefaultConductor; QIcon DiagramAdd; QIcon Diagram; - QIcon DiagramDelete; + QIcon DiagramBg; + QIcon DiagramDelete; QIcon DialogCancel; QIcon DialogInformation; QIcon DialogOk; @@ -219,7 +220,8 @@ void QET::Icons::initIcons() { 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"); diff --git a/sources/qeticons.h b/sources/qeticons.h index 11cbab70d..c9f9b15e2 100644 --- a/sources/qeticons.h +++ b/sources/qeticons.h @@ -47,6 +47,7 @@ namespace QET { extern QIcon DefaultConductor; extern QIcon DiagramAdd; extern QIcon Diagram; + extern QIcon DiagramBg; extern QIcon DiagramDelete; extern QIcon DialogCancel; extern QIcon DialogInformation; diff --git a/sources/ui/borderpropertieswidget.cpp b/sources/ui/borderpropertieswidget.cpp index d15d46e62..4a3448b69 100644 --- a/sources/ui/borderpropertieswidget.cpp +++ b/sources/ui/borderpropertieswidget.cpp @@ -55,7 +55,6 @@ void BorderPropertiesWidget::setProperties(const BorderProperties &bp) { 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 @@ const BorderProperties &BorderPropertiesWidget::properties () { 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; -} diff --git a/sources/ui/borderpropertieswidget.h b/sources/ui/borderpropertieswidget.h index 3966fbccd..fc8c8a7e6 100644 --- a/sources/ui/borderpropertieswidget.h +++ b/sources/ui/borderpropertieswidget.h @@ -42,7 +42,6 @@ class BorderPropertiesWidget : public QWidget void setReadOnly (const bool &ro); private slots: - void on_m_grey_bg_cb_clicked(bool checked); private: Ui::BorderPropertiesWidget *ui;