QetDiagramEditor : add option 'Display grid'

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4637 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun 2016-08-18 16:30:24 +00:00
parent ea7780540e
commit d63bde3930
3 changed files with 36 additions and 7 deletions

View File

@ -884,7 +884,10 @@ void DiagramView::updateWindowTitle() {
*/
void DiagramView::adjustGridToZoom() {
QRectF viewed_scene = viewedSceneRect();
scene -> setDisplayGrid(viewed_scene.width() < 2000 || viewed_scene.height() < 2000);
if (diagramEditor()->drawGrid())
scene->setDisplayGrid(viewed_scene.width() < 2000 || viewed_scene.height() < 2000);
else
scene->setDisplayGrid(false);
}
/**

View File

@ -277,6 +277,18 @@ void QETDiagramEditor::setUpActions()
this->currentDiagram()->diagram()->update();
});
m_draw_grid = new QAction (tr("Afficher la grille"), this);
m_draw_grid->setStatusTip(tr("Affiche ou masque la grille des folios"));
m_draw_grid->setCheckable(true);
m_draw_grid->setChecked(true);
connect(m_draw_grid, &QAction::triggered, [this](bool checked) {
foreach (ProjectView *prjv, this->openedProjects())
foreach (Diagram *d, prjv->project()->diagrams()) {
d->setDisplayGrid(checked);
d->update();
}
});
infos_diagram = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this);
infos_diagram -> setShortcut( QKeySequence( tr("Ctrl+L") ) );
prj_edit_prop = new QAction(QET::Icons::DialogInformation, tr("Propriétés du projet"), this);
@ -525,6 +537,7 @@ void QETDiagramEditor::setUpToolBar() {
view_bar -> addAction(mode_selection);
view_bar -> addAction(mode_visualise);
view_bar -> addSeparator();
view_bar -> addAction(m_draw_grid);
view_bar -> addAction (m_grey_background);
view_bar -> addSeparator();
view_bar -> addActions(m_zoom_action_toolBar);
@ -617,6 +630,7 @@ void QETDiagramEditor::setUpMenu() {
menu_affichage -> addAction(mode_selection);
menu_affichage -> addAction(mode_visualise);
menu_affichage -> addSeparator();
menu_affichage -> addAction(m_draw_grid);
menu_affichage -> addAction(m_grey_background);
menu_affichage -> addSeparator();
menu_affichage -> addActions(m_zoom_actions_group.actions());
@ -1573,6 +1587,14 @@ ProjectView *QETDiagramEditor::acessCurrentProject (){
return(0);
}
/**
* @brief QETDiagramEditor::drawGrid
* @return true if the grid of folio must be displayed
*/
bool QETDiagramEditor::drawGrid() const {
return m_draw_grid->isChecked();
}
/**
* @brief QETDiagramEditor::acessCurrentDiagramView
* Retrieve current DiagramView used in diagram editor

View File

@ -69,6 +69,7 @@ class QETDiagramEditor : public QETMainWindow {
ProjectView *viewForFile (const QString &) const;
ProjectView *acessCurrentProject ();
DiagramView *acessCurrentDiagramView ();
bool drawGrid() const;
protected:
virtual bool event(QEvent *);
@ -156,7 +157,7 @@ class QETDiagramEditor : public QETMainWindow {
void activeUndoStackCleanChanged (bool clean);
// attributes
public:
private:
// Actions reachable through menus within QElectroTech
QActionGroup *grp_visu_sel; ///< Action group for visualisation vs edition mode
QActionGroup *grp_view_mode; ///< Action group for project
@ -169,14 +170,17 @@ class QETDiagramEditor : public QETMainWindow {
QAction *quit_editor; ///< Quit the diagram editor
QAction *undo; ///< Cancel the latest action
QAction *redo; ///< Redo the latest cancelled operation
public:
QAction *infos_diagram; ///< Show a dialog to edit diagram properties
QAction *conductor_reset; ///< Reset paths of selected conductors
QAction *cut; ///< Cut selection to clipboard
QAction *copy; ///< Copy selection to clipboard
private:
QAction *paste; ///< Paste clipboard content on the current diagram
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 *m_grey_background; ///< Switch the background color in white or grey
QAction *infos_diagram; ///< Show a dialog to edit diagram properties
QAction *m_draw_grid; ///< Switch the background grid display or not
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
@ -196,20 +200,20 @@ class QETDiagramEditor : public QETMainWindow {
QActionGroup m_select_actions_group; ///Action related to global selections
public:
QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram
QActionGroup m_selection_actions_group; ///Action related to edit a selected item
private:
QAction *delete_selection; ///< Delete selection
QAction *rotate_selection; ///< Rotate selected elements and text items by 90 degrees
QAction *rotate_texts; ///< Direct selected text items to a specific angle
QAction *find_element; ///< Find the selected element in the panel
QActionGroup m_row_column_actions_group; /// Action related to add/remove rows/column in diagram
QActionGroup m_file_actions_group; ///Actions related to file (open, close, save...)
QAction *close_file; ///< Close current project file
QAction *save_file; ///< Save current project
QAction *save_file_as; ///< Save current project as a specific file
private:
QMdiArea workspace;
QSignalMapper windowMapper;
/// Directory to use for file dialogs such as File > save