프로젝트

일반

사용자정보

개정판 902f44a9

ID902f44a9bff84a80846357420d8e19d2541b0d52
상위 2903d889
하위 4ced36d5

백흠경이(가) 5년 이상 전에 추가함

issue #1048: 프로그램 인자가 넘어왔을때 도면을 바로 연다

Change-Id: Ice791998dddaac6363980fa13a10367bc80b23f9

차이점 보기:

HYTOS/HYTOS/App.py
113 113
    if True:
114 114
        AppDocData.instance().ex = exceptionHandler
115 115
        app._mainWnd = MainWindow.instance()
116
        if len(sys.argv) == 2: app._mainWnd.open_drawing(sys.argv[1])
116 117
        app._mainWnd.show()
117 118
        sys.exit(app.exec_())
HYTOS/HYTOS/MainWindow.py
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:
HYTOS/HYTOS/MainWindow_UI.py
2 2

  
3 3
# Form implementation generated from reading ui file '.\UI\MainWindow.ui'
4 4
#
5
# Created by: PyQt5 UI code generator 5.13.0
5
# Created by: PyQt5 UI code generator 5.12.3
6 6
#
7 7
# WARNING! All changes made in this file will be lost!
8 8

  
......
389 389
        self.actionOpen = QtWidgets.QAction(MainWindow)
390 390
        self.actionOpen.setObjectName("actionOpen")
391 391
        self.menu.addAction(self.actionNew)
392
        self.menu.addAction(self.actionOpen)
392 393
        self.menu.addAction(self.actionSave)
393 394
        self.menu.addSeparator()
394 395
        self.menu.addAction(self.actionConfiguration)
HYTOS/HYTOS/UI/MainWindow.ui
59 59
     </property>
60 60
    </widget>
61 61
    <addaction name="actionNew"/>
62
    <addaction name="actionOpen"/>
62 63
    <addaction name="actionSave"/>
63 64
    <addaction name="separator"/>
64 65
    <addaction name="actionConfiguration"/>

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)