Skip to content

Commit 603922c

Browse files
committed
Added docs link to examples and tweaked quit code
1 parent 7fbe048 commit 603922c

9 files changed

Lines changed: 35 additions & 2 deletions

cq_editor/main_window.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from PyQt5.QtWidgets import (
77
QLabel,
88
QMainWindow,
9+
QMessageBox,
910
QToolBar,
1011
QDockWidget,
1112
QAction,
@@ -218,9 +219,20 @@ def closeEvent(self, event):
218219

219220
if self.components["editor"].document().isModified():
220221

221-
rv = confirm(self, "Confirm close", "Close without saving?")
222+
dlg = QMessageBox(self)
223+
dlg.setWindowTitle("Unsaved changes")
224+
dlg.setText("Save changes before closing?")
225+
dlg.setStandardButtons(
226+
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel
227+
)
228+
dlg.setDefaultButton(QMessageBox.Save)
229+
rv = dlg.exec_()
222230

223-
if rv:
231+
if rv == QMessageBox.Save:
232+
self.components["editor"].save()
233+
event.accept()
234+
super(MainWindow, self).closeEvent(event)
235+
elif rv == QMessageBox.Discard:
224236
event.accept()
225237
super(MainWindow, self).closeEvent(event)
226238
else:
@@ -309,6 +321,11 @@ def prepare_menubar(self):
309321
examples_menu = menu_file.addMenu("Examples")
310322
self._populate_examples_menu(examples_menu)
311323

324+
menu_file.addSeparator()
325+
menu_file.addAction(
326+
QAction("Quit", self, shortcut="ctrl+Q", triggered=self.close)
327+
)
328+
312329
# global menu elements
313330
menu_view.addSeparator()
314331
for d in self.findChildren(QDockWidget):

examples/01_hello_box.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# "YZ" — side face of the box
1010
#
1111
# .box(length, width, height) creates a box centered on the workplane origin.
12+
#
13+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
1214

1315
import cadquery as cq
1416

examples/02_selectors_and_fillets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#
1313
# .fillet(radius) rounds the selected edges.
1414
# .chamfer(length) cuts a 45-degree bevel instead.
15+
#
16+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
1517

1618
import cadquery as cq
1719

examples/03_extruded_profile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# .extrude(depth) extrudes the closed profile in the workplane's normal direction.
1313
#
1414
# This example draws an L-shaped bracket profile and extrudes it.
15+
#
16+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
1517

1618
import cadquery as cq
1719

examples/04_holes_and_counterbores.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#
1414
# .workplane() switches the active workplane to the selected face so that
1515
# subsequent operations happen relative to it.
16+
#
17+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
1618

1719
import cadquery as cq
1820

examples/05_loft.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#
1313
# This example transitions from a square base to a circular top, like a
1414
# funnel or adapter fitting.
15+
#
16+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
1517

1618
import cadquery as cq
1719

examples/06_sweep.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#
1313
# This example creates a curved pipe — a circular cross-section swept along
1414
# a quarter-circle arc.
15+
#
16+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
1517

1618
import cadquery as cq
1719

examples/07_pillow_block.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# - Fillets
1515
#
1616
# All dimensions are in millimetres.
17+
#
18+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
1719

1820
import cadquery as cq
1921

examples/08_assembly.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
# · · · · · · · · · gasket (z = +4 to +6)
2323
# ───────────────── lower plate (z = −4 to +4)
2424
# nut
25+
#
26+
# For more examples and the full API reference, see https://cadquery.readthedocs.io/en/latest/
2527

2628
import cadquery as cq
2729

0 commit comments

Comments
 (0)