|
42 | 42 | from src.figure_editor import StlMovePanel
|
43 | 43 | from src.qt_utils import ClickableLineEdit, LineEdit
|
44 | 44 | from src.settings_widget import SettingsWidget
|
| 45 | +import os |
45 | 46 | import os.path as path
|
46 | 47 | import logging
|
47 | 48 |
|
@@ -854,16 +855,34 @@ def save_dialog(
|
854 | 855 | self,
|
855 | 856 | caption,
|
856 | 857 | format="STL (*.stl *.STL);;Gcode (*.gcode)",
|
857 |
| - directory="/home/l1va/Downloads/5axes_3d_printer/test", |
858 |
| - ): # TODO: fix path |
| 858 | + directory="", |
| 859 | + ): |
| 860 | + base_dir = getattr(sett(), "project_path", "") or os.getcwd() |
| 861 | + if not base_dir or not path.isdir(base_dir): |
| 862 | + base_dir = path.expanduser("~") |
| 863 | + |
| 864 | + if directory: |
| 865 | + directory = directory if path.isabs(directory) else path.join(base_dir, directory) |
| 866 | + else: |
| 867 | + directory = base_dir |
| 868 | + |
859 | 869 | return QFileDialog.getSaveFileName(None, caption, directory, format)[0]
|
860 | 870 |
|
861 | 871 | def open_dialog(
|
862 | 872 | self,
|
863 | 873 | caption,
|
864 | 874 | format="STL (*.stl *.STL);;Gcode (*.gcode)",
|
865 |
| - directory="/home/l1va/Downloads/5axes_3d_printer/test", |
866 |
| - ): # TODO: fix path |
| 875 | + directory="", |
| 876 | + ): |
| 877 | + base_dir = getattr(sett(), "project_path", "") or os.getcwd() |
| 878 | + if not base_dir or not path.isdir(base_dir): |
| 879 | + base_dir = path.expanduser("~") |
| 880 | + |
| 881 | + if directory: |
| 882 | + directory = directory if path.isabs(directory) else path.join(base_dir, directory) |
| 883 | + else: |
| 884 | + directory = base_dir |
| 885 | + |
867 | 886 | return QFileDialog.getOpenFileName(None, caption, directory, format)[0]
|
868 | 887 |
|
869 | 888 | def load_stl(self, stl_actor):
|
|
0 commit comments