Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow document grid visibilty to be toggled via menu and shortcut key #1065

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion qucs/qucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,6 @@ void QucsApp::slotHelpReport()
// Is called when another document is selected via the TabBar.
void QucsApp::slotChangeView()
{

QWidget *w = DocumentTab->currentWidget();
editText->setHidden (true); // disable text edit of component property
QucsDoc * Doc;
Expand Down Expand Up @@ -2086,6 +2085,8 @@ void QucsApp::slotChangeView()
switchSchematicDoc(true);
changeSchematicSymbolMode(d);
}

showGrid->setChecked(d->getGridOn());
}

Doc->becomeCurrent(true);
Expand Down Expand Up @@ -2133,6 +2134,10 @@ void QucsApp::slotFileSettings ()
else {
SettingsDialog * d = new SettingsDialog ((Schematic *) w);
d->exec ();

// TODO: It would be better to emit a signal to notify all subscribers
// that the diagram settings have changed.
showGrid->setChecked(static_cast<Schematic*>(w)->getGridOn());
}
}

Expand Down
3 changes: 2 additions & 1 deletion qucs/qucs.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private slots:

QAction *insWire, *insLabel, *insGround, *insPort, *insEquation, *magPlus,
*editRotate, *editMirror, *editMirrorY, *editPaste, *select,
*editActivate, *wire, *editDelete, *setMarker, *setDiagramLimits, *resetDiagramLimits, *onGrid, *moveText,
*editActivate, *wire, *editDelete, *setMarker, *setDiagramLimits, *resetDiagramLimits, *showGrid, *onGrid, *moveText,
*helpIndex, *helpGetStart, *callEditor, *callFilter, *callLine, *callActiveFilter,
*showMsg, *showNet, *alignTop, *alignBottom, *alignLeft, *alignRight,
*distrHor, *distrVert, *selectAll, *callMatch, *changeProps,
Expand Down Expand Up @@ -381,6 +381,7 @@ public slots:
void slotSetMarker(bool);
void slotSetDiagramLimits(bool);
void slotResetDiagramLimits();
void slotShowGrid(); // turn the grid on or off
void slotOnGrid(bool); // set selected elements on grid
void slotMoveText(bool); // move property text of components
void slotZoomIn(bool);
Expand Down
13 changes: 13 additions & 0 deletions qucs/qucs_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@ void QucsApp::slotResetDiagramLimits()
slotEscape();
}

// -----------------------------------------------------------------------
// Is called, when "show grid" action is triggered.
void QucsApp::slotShowGrid()
{
qDebug() << "slotShowGrid";
Schematic* schematic = static_cast<Schematic*>(DocumentTab->currentWidget());
if(!isTextDocument(schematic)) {
schematic->setGridOn(!schematic->getGridOn());
schematic->setChanged(true);
schematic->viewport()->repaint();
}
}

// -----------------------------------------------------------------------
// Is called, when "move component text" action is triggered.
void QucsApp::slotMoveText(bool on)
Expand Down
11 changes: 10 additions & 1 deletion qucs/qucs_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,13 @@ void QucsApp::initActions()
resetDiagramLimits->setWhatsThis(tr("Reset Diagram Limits\n\nResets the limits for all axis to auto."));
connect(resetDiagramLimits, SIGNAL(triggered()), SLOT(slotResetDiagramLimits()));

showGrid = new QAction(tr("Show Grid (current document)"), this);
showGrid->setCheckable(true);
showGrid->setShortcut(tr("Alt+G"));
showGrid->setStatusTip(tr("Show or hide the grid for the current document."));
showGrid->setWhatsThis(tr("Show / Hide Grid\n\nShow or hide the grid for the current document."));
connect(showGrid, SIGNAL(triggered()), SLOT(slotShowGrid()));

showMsg = new QAction(tr("Show Last Messages"), this);
showMsg->setShortcut(Qt::Key_F5);
showMsg->setStatusTip(tr("Shows last simulation messages"));
Expand Down Expand Up @@ -800,7 +807,9 @@ void QucsApp::initMenuBar()
viewMenu->addAction(magMinus);
viewMenu->addAction(setDiagramLimits);
viewMenu->addSeparator();
//viewMenu->setCheckable(true);
viewMenu->addAction(showGrid);
viewMenu->addSeparator();
//viewMenu->setCheckable(true);
viewMenu->addAction(viewBrowseDock);
viewMenu->addAction(viewOctaveDock);

Expand Down
Loading