52 |
52 |
from DisplayColors import DisplayOptions
|
53 |
53 |
import uuid
|
54 |
54 |
|
55 |
|
|
56 |
55 |
class MainWindow(QMainWindow, MainWindow_UI.Ui_MainWindow, SingletonInstane):
|
57 |
56 |
""" This is MainWindow class """
|
58 |
57 |
addMessage = pyqtSignal(Enum, str)
|
... | ... | |
106 |
105 |
self.actionGroup.triggered.connect(self.actionGroupTriggered)
|
107 |
106 |
self.actionClose.triggered.connect(self.close)
|
108 |
107 |
self.actionNew.triggered.connect(self.new_drawing)
|
109 |
|
self.actionOpen.triggered.connect(self.open_drawing)
|
|
108 |
self.actionOpen.triggered.connect(self.on_open_drawing)
|
110 |
109 |
self.actionSave.triggered.connect(self.actionSaveCliked)
|
111 |
110 |
self.actionCalculation.triggered.connect(self.calculation)
|
112 |
111 |
self.actionLine.triggered.connect(self.onPlaceLine)
|
... | ... | |
831 |
830 |
if not os.path.splitext(name)[1]: name += '.hytos'
|
832 |
831 |
|
833 |
832 |
app_doc_data = AppDocData.instance()
|
834 |
|
matches = [drawing for drawing in app_doc_data.getDrawings() if drawing.path == name]
|
|
833 |
matches = [drawing for drawing in app_doc_data.getDrawings() if os.path.samefile(drawing.path, name)]
|
835 |
834 |
if not matches:
|
836 |
835 |
drawing = Drawing(str(uuid.uuid4()), name, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
837 |
836 |
app_doc_data.saveDrawing(drawing)
|
... | ... | |
843 |
842 |
self.open_border_file()
|
844 |
843 |
self.load_data(name)
|
845 |
844 |
|
846 |
|
def open_drawing(self):
|
|
845 |
def on_open_drawing(self):
|
847 |
846 |
""" open selected drawing by user """
|
|
847 |
options = QFileDialog.Options()
|
|
848 |
options |= QFileDialog.DontUseNativeDialog
|
|
849 |
name, _ = QFileDialog.getOpenFileName(self, 'open drawing', '', 'HYTOS File(*.hytos)', options=options)
|
|
850 |
if name: self.open_drawing(name)
|
|
851 |
|
|
852 |
def open_drawing(self, name):
|
|
853 |
""" open given drawing has name """
|
848 |
854 |
import uuid
|
849 |
855 |
from Drawing import Drawing
|
850 |
856 |
from datetime import datetime
|
851 |
857 |
|
852 |
|
options = QFileDialog.Options()
|
853 |
|
options |= QFileDialog.DontUseNativeDialog
|
854 |
|
name, _ = QFileDialog.getOpenFileName(self, 'open drawing', '', 'HYTOS File(*.hytos)', options=options)
|
855 |
|
if name:
|
856 |
|
app_doc_data = AppDocData.instance()
|
857 |
|
drawings = app_doc_data.getDrawings()
|
858 |
|
matches = [drawing for drawing in drawings if drawing.path == name]
|
859 |
|
if not matches:
|
860 |
|
drawing = Drawing(str(uuid.uuid4()), name, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
861 |
|
app_doc_data.saveDrawing(drawing)
|
|
858 |
app_doc_data = AppDocData.instance()
|
|
859 |
drawings = app_doc_data.getDrawings()
|
|
860 |
matches = [drawing for drawing in drawings if os.path.samefile(drawing.path, name)]
|
|
861 |
if not matches:
|
|
862 |
drawing = Drawing(str(uuid.uuid4()), name, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
|
863 |
app_doc_data.saveDrawing(drawing)
|
862 |
864 |
|
863 |
|
self.load_drawing_list()
|
864 |
|
else:
|
865 |
|
drawing = matches[0]
|
|
865 |
self.load_drawing_list()
|
|
866 |
else:
|
|
867 |
drawing = matches[0]
|
866 |
868 |
|
867 |
|
self.open_border_file()
|
868 |
|
self.load_data(drawing)
|
|
869 |
self.open_border_file()
|
|
870 |
self.load_data(drawing)
|
869 |
871 |
|
870 |
872 |
def changeViewCheckedState(self, checked, clear=True):
|
871 |
873 |
'''
|
... | ... | |
1203 |
1205 |
app = App(sys.argv)
|
1204 |
1206 |
try:
|
1205 |
1207 |
app._mainWnd = MainWindow.instance()
|
|
1208 |
if len(sys.argv) == 2: app._mainWnd.open_drawing(sys.argv[1])
|
1206 |
1209 |
app._mainWnd.show()
|
1207 |
1210 |
sys.exit(app.exec_())
|
1208 |
1211 |
except Exception as ex:
|