|
|
@@ -7,7 +7,7 @@
|
|
|
############################################################
|
|
|
|
|
|
from PyQt5 import QtGui, QtCore, QtWidgets
|
|
|
-from PyQt5.QtCore import Qt
|
|
|
+from PyQt5.QtCore import Qt, QSettings
|
|
|
from GUIElements import *
|
|
|
import platform
|
|
|
|
|
|
@@ -405,136 +405,19 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|
|
self.exc_edit_toolbar.setObjectName('ExcEditor_TB')
|
|
|
self.addToolBar(self.exc_edit_toolbar)
|
|
|
self.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
|
|
|
- self.geo_edit_toolbar.setVisible(False)
|
|
|
self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
|
|
|
self.addToolBar(self.geo_edit_toolbar)
|
|
|
- self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
|
|
|
- self.snap_toolbar.setObjectName('Snap_TB')
|
|
|
- # self.snap_toolbar.setMaximumHeight(30)
|
|
|
- self.addToolBar(self.snap_toolbar)
|
|
|
-
|
|
|
- ### File Toolbar ###
|
|
|
- self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
|
|
|
- "Open GERBER")
|
|
|
- self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
|
|
|
- self.toolbarfile.addSeparator()
|
|
|
- self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
|
|
|
- self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
|
|
|
-
|
|
|
- ### Edit Toolbar ###
|
|
|
- self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
|
|
|
- self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
|
|
|
- self.toolbargeo.addSeparator()
|
|
|
- self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
|
|
|
- self.update_obj_btn = self.toolbargeo.addAction(
|
|
|
- QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor"
|
|
|
- )
|
|
|
- self.update_obj_btn.setEnabled(False)
|
|
|
- self.toolbargeo.addSeparator()
|
|
|
- self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
|
|
|
-
|
|
|
- ### View Toolbar ###
|
|
|
- self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
|
|
|
- self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
|
|
|
- self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
|
|
|
- self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
|
|
|
- self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
|
|
|
-
|
|
|
- # self.toolbarview.setVisible(False)
|
|
|
-
|
|
|
- ### Tools Toolbar ###
|
|
|
- self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
|
|
|
-
|
|
|
- ### Drill Editor Toolbar ###
|
|
|
- self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
|
|
|
- self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
|
|
|
- self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
|
|
|
- QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
|
|
|
- self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
|
|
|
- self.exc_edit_toolbar.addSeparator()
|
|
|
-
|
|
|
- self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
|
|
|
- self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
|
|
|
-
|
|
|
- self.exc_edit_toolbar.addSeparator()
|
|
|
- self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
|
|
|
-
|
|
|
- self.exc_edit_toolbar.setDisabled(True)
|
|
|
- self.exc_edit_toolbar.setVisible(False)
|
|
|
-
|
|
|
- ### Geometry Editor Toolbar ###
|
|
|
- self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
|
|
|
- self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
|
|
|
- self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
|
|
|
- self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle')
|
|
|
-
|
|
|
- self.geo_edit_toolbar.addSeparator()
|
|
|
- self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
|
|
|
- self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
|
|
|
- self.geo_edit_toolbar.addSeparator()
|
|
|
- self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
|
|
|
- self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
|
|
|
- self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
|
|
|
-
|
|
|
- self.geo_edit_toolbar.addSeparator()
|
|
|
- self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
|
|
|
- self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
|
|
|
- 'Polygon Intersection')
|
|
|
- self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'), 'Polygon Subtraction')
|
|
|
-
|
|
|
- self.geo_edit_toolbar.addSeparator()
|
|
|
- self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
|
|
|
- self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
|
|
|
- self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
|
|
|
- self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Shape '-'")
|
|
|
-
|
|
|
- self.geo_edit_toolbar.addSeparator()
|
|
|
- self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
|
|
|
-
|
|
|
- ### Snap Toolbar ###
|
|
|
- # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
|
|
|
- # self.addToolBar(self.snap_toolbar)
|
|
|
-
|
|
|
- self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
|
|
|
- self.grid_gap_x_entry = FCEntry2()
|
|
|
- self.grid_gap_x_entry.setMaximumWidth(70)
|
|
|
- self.grid_gap_x_entry.setToolTip("Grid X distance")
|
|
|
- self.snap_toolbar.addWidget(self.grid_gap_x_entry)
|
|
|
-
|
|
|
- self.grid_gap_y_entry = FCEntry2()
|
|
|
- self.grid_gap_y_entry.setMaximumWidth(70)
|
|
|
- self.grid_gap_y_entry.setToolTip("Grid Y distance")
|
|
|
- self.snap_toolbar.addWidget(self.grid_gap_y_entry)
|
|
|
-
|
|
|
- self.grid_space_label = QtWidgets.QLabel(" ")
|
|
|
- self.snap_toolbar.addWidget(self.grid_space_label)
|
|
|
- self.grid_gap_link_cb = FCCheckBox()
|
|
|
- self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
|
|
|
- "is copied to the Grid_Y value.")
|
|
|
- self.snap_toolbar.addWidget(self.grid_gap_link_cb)
|
|
|
-
|
|
|
- self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
|
|
|
-
|
|
|
- self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
|
|
|
-
|
|
|
- self.snap_max_dist_entry = FCEntry()
|
|
|
- self.snap_max_dist_entry.setMaximumWidth(70)
|
|
|
- self.snap_max_dist_entry.setToolTip("Max. magnet distance")
|
|
|
- self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
|
|
|
-
|
|
|
- self.grid_snap_btn.setCheckable(True)
|
|
|
- self.corner_snap_btn.setCheckable(True)
|
|
|
-
|
|
|
|
|
|
################
|
|
|
### Splitter ###
|
|
|
################
|
|
|
+
|
|
|
+ # IMPORTANT #
|
|
|
+ # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
|
|
|
+ # desired.
|
|
|
self.splitter = QtWidgets.QSplitter()
|
|
|
self.setCentralWidget(self.splitter)
|
|
|
|
|
|
- ################
|
|
|
- ### Notebook ###
|
|
|
- ################
|
|
|
self.notebook = QtWidgets.QTabWidget()
|
|
|
self.splitter.addWidget(self.notebook)
|
|
|
|
|
|
@@ -543,6 +426,28 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|
|
self.splitter_left.addWidget(self.notebook)
|
|
|
self.splitter_left.setHandleWidth(0)
|
|
|
|
|
|
+ self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
|
|
|
+ self.snap_toolbar.setObjectName('Snap_TB')
|
|
|
+
|
|
|
+ settings = QSettings("Open Source", "FlatCAM")
|
|
|
+ if settings.contains("theme"):
|
|
|
+ theme = settings.value('theme', type=str)
|
|
|
+ if theme == 'standard':
|
|
|
+ self.addToolBar(self.snap_toolbar)
|
|
|
+ elif theme == 'compact':
|
|
|
+ self.snap_toolbar.setMaximumHeight(30)
|
|
|
+ self.splitter_left.addWidget(self.snap_toolbar)
|
|
|
+ else:
|
|
|
+ self.addToolBar(self.snap_toolbar)
|
|
|
+
|
|
|
+ # add the actions/widgets to the toolbars
|
|
|
+ self.populate_toolbars()
|
|
|
+
|
|
|
+
|
|
|
+ ################
|
|
|
+ ### Notebook ###
|
|
|
+ ################
|
|
|
+
|
|
|
### Project ###
|
|
|
self.project_tab = QtWidgets.QWidget()
|
|
|
# project_tab.setMinimumWidth(250) # Hack
|
|
|
@@ -879,14 +784,190 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|
|
self.filename = ""
|
|
|
self.setAcceptDrops(True)
|
|
|
|
|
|
+ # # restore the Toolbar State from file
|
|
|
+ # try:
|
|
|
+ # with open(self.app.data_path + '\gui_state.config', 'rb') as stream:
|
|
|
+ # self.restoreState(QtCore.QByteArray(stream.read()))
|
|
|
+ # log.debug("FlatCAMGUI.__init__() --> UI state restored.")
|
|
|
+ # except IOError:
|
|
|
+ # log.debug("FlatCAMGUI.__init__() --> UI state not restored. IOError")
|
|
|
+ # pass
|
|
|
+
|
|
|
+ ######################
|
|
|
+ ### INITIALIZE GUI ###
|
|
|
+ ######################
|
|
|
+
|
|
|
+ self.grid_snap_btn.setCheckable(True)
|
|
|
+ self.corner_snap_btn.setCheckable(True)
|
|
|
+ self.update_obj_btn.setEnabled(False)
|
|
|
+ # start with GRID activated
|
|
|
+ self.grid_snap_btn.trigger()
|
|
|
+
|
|
|
# restore the Toolbar State from file
|
|
|
- try:
|
|
|
- with open(self.app.data_path + '\gui_state.config', 'rb') as stream:
|
|
|
- self.restoreState(QtCore.QByteArray(stream.read()))
|
|
|
+ settings = QSettings("Open Source", "FlatCAM")
|
|
|
+ if settings.contains("saved_gui_state"):
|
|
|
+ saved_gui_state = settings.value('saved_gui_state')
|
|
|
+ self.restoreState(saved_gui_state)
|
|
|
log.debug("FlatCAMGUI.__init__() --> UI state restored.")
|
|
|
- except IOError:
|
|
|
- log.debug("FlatCAMGUI.__init__() --> UI state not restored. IOError")
|
|
|
- pass
|
|
|
+
|
|
|
+ if settings.contains("theme"):
|
|
|
+ theme = settings.value('theme', type=str)
|
|
|
+ if theme == 'standard':
|
|
|
+ self.exc_edit_toolbar.setVisible(False)
|
|
|
+ self.exc_edit_toolbar.setDisabled(True)
|
|
|
+ self.geo_edit_toolbar.setVisible(False)
|
|
|
+ self.geo_edit_toolbar.setDisabled(True)
|
|
|
+
|
|
|
+ self.g_editor_cmenu.setEnabled(False)
|
|
|
+ self.e_editor_cmenu.setEnabled(False)
|
|
|
+
|
|
|
+ self.corner_snap_btn.setVisible(False)
|
|
|
+ self.snap_magnet.setVisible(False)
|
|
|
+ elif theme == 'compact':
|
|
|
+ self.exc_edit_toolbar.setDisabled(True)
|
|
|
+ self.geo_edit_toolbar.setDisabled(True)
|
|
|
+ self.snap_magnet.setVisible(True)
|
|
|
+ self.corner_snap_btn.setVisible(True)
|
|
|
+ else:
|
|
|
+ self.exc_edit_toolbar.setVisible(False)
|
|
|
+ self.exc_edit_toolbar.setDisabled(True)
|
|
|
+ self.geo_edit_toolbar.setVisible(False)
|
|
|
+ self.geo_edit_toolbar.setDisabled(True)
|
|
|
+
|
|
|
+ self.g_editor_cmenu.setEnabled(False)
|
|
|
+ self.e_editor_cmenu.setEnabled(False)
|
|
|
+
|
|
|
+ self.corner_snap_btn.setVisible(False)
|
|
|
+ self.snap_magnet.setVisible(False)
|
|
|
+
|
|
|
+ def populate_toolbars(self):
|
|
|
+ ### File Toolbar ###
|
|
|
+ self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
|
|
|
+ "Open GERBER")
|
|
|
+ self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
|
|
|
+ self.toolbarfile.addSeparator()
|
|
|
+ self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
|
|
|
+ self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
|
|
|
+
|
|
|
+ ### Edit Toolbar ###
|
|
|
+ self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
|
|
|
+ self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
|
|
|
+ self.toolbargeo.addSeparator()
|
|
|
+ self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
|
|
|
+ self.update_obj_btn = self.toolbargeo.addAction(
|
|
|
+ QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor"
|
|
|
+ )
|
|
|
+
|
|
|
+ self.toolbargeo.addSeparator()
|
|
|
+ self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
|
|
|
+
|
|
|
+ ### View Toolbar ###
|
|
|
+ self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
|
|
|
+ self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
|
|
|
+ self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
|
|
|
+ self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
|
|
|
+ self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
|
|
|
+
|
|
|
+ # self.toolbarview.setVisible(False)
|
|
|
+
|
|
|
+ ### Tools Toolbar ###
|
|
|
+ self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
|
|
|
+
|
|
|
+ ### Drill Editor Toolbar ###
|
|
|
+ self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
|
|
|
+ self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
|
|
|
+ self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
|
|
|
+ QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
|
|
|
+ self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
|
|
|
+ self.exc_edit_toolbar.addSeparator()
|
|
|
+
|
|
|
+ self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
|
|
|
+ self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
|
|
|
+
|
|
|
+ self.exc_edit_toolbar.addSeparator()
|
|
|
+ self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
|
|
|
+
|
|
|
+ ### Geometry Editor Toolbar ###
|
|
|
+ self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
|
|
|
+ self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
|
|
|
+ self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
|
|
|
+ self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle')
|
|
|
+
|
|
|
+ self.geo_edit_toolbar.addSeparator()
|
|
|
+ self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
|
|
|
+ self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
|
|
|
+ self.geo_edit_toolbar.addSeparator()
|
|
|
+ self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
|
|
|
+ self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
|
|
|
+ self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
|
|
|
+
|
|
|
+ self.geo_edit_toolbar.addSeparator()
|
|
|
+ self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
|
|
|
+ self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
|
|
|
+ 'Polygon Intersection')
|
|
|
+ self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'), 'Polygon Subtraction')
|
|
|
+
|
|
|
+ self.geo_edit_toolbar.addSeparator()
|
|
|
+ self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
|
|
|
+ self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
|
|
|
+ self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
|
|
|
+ self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Shape '-'")
|
|
|
+
|
|
|
+ self.geo_edit_toolbar.addSeparator()
|
|
|
+ self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
|
|
|
+
|
|
|
+ ### Snap Toolbar ###
|
|
|
+ # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
|
|
|
+ # self.addToolBar(self.snap_toolbar)
|
|
|
+
|
|
|
+ self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
|
|
|
+ self.grid_gap_x_entry = FCEntry2()
|
|
|
+ self.grid_gap_x_entry.setMaximumWidth(70)
|
|
|
+ self.grid_gap_x_entry.setToolTip("Grid X distance")
|
|
|
+ self.snap_toolbar.addWidget(self.grid_gap_x_entry)
|
|
|
+
|
|
|
+ self.grid_gap_y_entry = FCEntry2()
|
|
|
+ self.grid_gap_y_entry.setMaximumWidth(70)
|
|
|
+ self.grid_gap_y_entry.setToolTip("Grid Y distance")
|
|
|
+ self.snap_toolbar.addWidget(self.grid_gap_y_entry)
|
|
|
+
|
|
|
+ self.grid_space_label = QtWidgets.QLabel(" ")
|
|
|
+ self.snap_toolbar.addWidget(self.grid_space_label)
|
|
|
+ self.grid_gap_link_cb = FCCheckBox()
|
|
|
+ self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
|
|
|
+ "is copied to the Grid_Y value.")
|
|
|
+ self.snap_toolbar.addWidget(self.grid_gap_link_cb)
|
|
|
+
|
|
|
+ self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
|
|
|
+
|
|
|
+ self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
|
|
|
+
|
|
|
+ self.snap_max_dist_entry = FCEntry()
|
|
|
+ self.snap_max_dist_entry.setMaximumWidth(70)
|
|
|
+ self.snap_max_dist_entry.setToolTip("Max. magnet distance")
|
|
|
+ self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
|
|
|
+
|
|
|
+ settings = QSettings("Open Source", "FlatCAM")
|
|
|
+ if settings.contains("theme"):
|
|
|
+ theme = settings.value('theme', type=str)
|
|
|
+ if theme == 'standard':
|
|
|
+ self.exc_edit_toolbar.setVisible(False)
|
|
|
+ self.exc_edit_toolbar.setDisabled(True)
|
|
|
+ self.geo_edit_toolbar.setVisible(False)
|
|
|
+ self.geo_edit_toolbar.setDisabled(True)
|
|
|
+
|
|
|
+ self.corner_snap_btn.setVisible(False)
|
|
|
+ self.snap_magnet.setVisible(False)
|
|
|
+ elif theme == 'compact':
|
|
|
+ self.exc_edit_toolbar.setVisible(True)
|
|
|
+ self.exc_edit_toolbar.setDisabled(True)
|
|
|
+ self.geo_edit_toolbar.setVisible(True)
|
|
|
+ self.geo_edit_toolbar.setDisabled(True)
|
|
|
+
|
|
|
+ self.corner_snap_btn.setVisible(True)
|
|
|
+ self.snap_magnet.setVisible(True)
|
|
|
+ self.corner_snap_btn.setDisabled(True)
|
|
|
+ self.snap_magnet.setDisabled(True)
|
|
|
|
|
|
def dragEnterEvent(self, event):
|
|
|
if event.mimeData().hasUrls:
|
|
|
@@ -954,10 +1035,19 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
|
|
self.final_save.emit()
|
|
|
|
|
|
if self.app.should_we_quit is True:
|
|
|
+ # # save toolbar state to file
|
|
|
+ # with open(self.app.data_path + '\gui_state.config', 'wb') as stream:
|
|
|
+ # stream.write(self.saveState().data())
|
|
|
+ # log.debug("FlatCAMGUI.__init__() --> UI state saved.")
|
|
|
+ # QtWidgets.qApp.quit()
|
|
|
+
|
|
|
# save toolbar state to file
|
|
|
- with open(self.app.data_path + '\gui_state.config', 'wb') as stream:
|
|
|
- stream.write(self.saveState().data())
|
|
|
- log.debug("FlatCAMGUI.__init__() --> UI state saved.")
|
|
|
+ settings = QSettings("Open Source", "FlatCAM")
|
|
|
+ settings.setValue('saved_gui_state', self.saveState())
|
|
|
+
|
|
|
+ # This will write the setting to the platform specific storage.
|
|
|
+ del settings
|
|
|
+ log.debug("FlatCAMGUI.__init__() --> UI state saved.")
|
|
|
QtWidgets.qApp.quit()
|
|
|
else:
|
|
|
self.app.should_we_quit = True
|
|
|
@@ -1119,6 +1209,11 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
|
|
)
|
|
|
self.gridy_entry = LengthEntry()
|
|
|
|
|
|
+ # Snap Max Entry
|
|
|
+ self.snap_max_label = QtWidgets.QLabel('Snap Max:')
|
|
|
+ self.snap_max_label.setToolTip("Max. magnet distance")
|
|
|
+ self.snap_max_dist_entry = FCEntry()
|
|
|
+
|
|
|
# Workspace
|
|
|
self.workspace_lbl = QtWidgets.QLabel('Workspace:')
|
|
|
self.workspace_lbl.setToolTip(
|
|
|
@@ -1324,6 +1419,7 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
|
|
self.theme_combo = FCComboBox()
|
|
|
self.theme_combo.addItem("Standard")
|
|
|
self.theme_combo.addItem("Compact")
|
|
|
+ self.theme_combo.setCurrentIndex(0)
|
|
|
|
|
|
# Just to add empty rows
|
|
|
self.spacelabel = QtWidgets.QLabel('')
|
|
|
@@ -1334,6 +1430,7 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
|
|
|
|
|
self.form_box.addRow(self.gridx_label, self.gridx_entry)
|
|
|
self.form_box.addRow(self.gridy_label, self.gridy_entry)
|
|
|
+ self.form_box.addRow(self.snap_max_label, self.snap_max_dist_entry)
|
|
|
|
|
|
self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
|
|
|
self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
|