프로젝트

일반

사용자정보

개정판 f5f79e97

IDf5f79e973dc8577f0564b90830d1dea3dc68b18d
상위 17747be3
하위 6dbc71ea

함의성이(가) 약 5년 전에 추가함

issue #622: add save alert

Change-Id: I0a77f0377fb8f14c23e4b8174aea8a7d436f3f5d

차이점 보기:

DTI_PID/DTI_PID/ConfigurationDialog.py
400 400
        self.ui.tableWidgetColorProperty.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
401 401
        self.setPropertyToggle(self.ui.radioButtonProperty.isChecked())
402 402

  
403
        configs = docData.getConfigs('Data Save', 'Time')
404
        self.ui.spinBoxSaveAlarm.setValue(int(configs[0].value)) if 1 == len(configs) else \
405
            self.ui.spinBoxSaveAlarm.setValue(15)
403 406
        configs = docData.getConfigs('Data Load', 'Xml First')
404 407
        if configs:
405 408
            size = int(configs[0].value)
......
1052 1055
            configs.append(Config('Text Style', 'Font Size', str(
1053 1056
                self.ui.spinBoxFontSize.value()) if self.ui.radioButtonFixedSize.isChecked() else '-1'))
1054 1057

  
1058
            configs.append(Config('Data Save', 'Time', self.ui.spinBoxSaveAlarm.value()))
1055 1059
            configs.append(Config('Data Load', 'Xml First', '1' if self.ui.radioButtonLoadXmlYes.isChecked() else \
1056 1060
                        ('-1' if self.ui.radioButtonLoadXmlNo.isChecked() else '2')))
1057 1061
            configs.append(
DTI_PID/DTI_PID/Configuration_UI.py
132 132
        sizePolicy.setVerticalStretch(0)
133 133
        sizePolicy.setHeightForWidth(self.maxTextSizeSpinBox.sizePolicy().hasHeightForWidth())
134 134
        self.maxTextSizeSpinBox.setSizePolicy(sizePolicy)
135
        self.maxTextSizeSpinBox.setMaximum(150)
135 136
        self.maxTextSizeSpinBox.setProperty("value", 60)
136 137
        self.maxTextSizeSpinBox.setObjectName("maxTextSizeSpinBox")
137 138
        self.gridLayout_25.addWidget(self.maxTextSizeSpinBox, 6, 3, 1, 1)
......
639 640
        self.gridLayout_23.setObjectName("gridLayout_23")
640 641
        self.gridLayout_31 = QtWidgets.QGridLayout()
641 642
        self.gridLayout_31.setObjectName("gridLayout_31")
642
        self.label_30 = QtWidgets.QLabel(self.groupBox_11)
643
        self.label_30.setObjectName("label_30")
644
        self.gridLayout_31.addWidget(self.label_30, 0, 0, 1, 1)
645
        self.label_34 = QtWidgets.QLabel(self.groupBox_11)
646
        self.label_34.setObjectName("label_34")
647
        self.gridLayout_31.addWidget(self.label_34, 1, 0, 1, 1)
648
        self.label_31 = QtWidgets.QLabel(self.groupBox_11)
649
        self.label_31.setMinimumSize(QtCore.QSize(200, 0))
650
        self.label_31.setObjectName("label_31")
651
        self.gridLayout_31.addWidget(self.label_31, 2, 0, 1, 1)
652 643
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
653 644
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
654 645
        self.radioButtonLoadXmlOnly = QtWidgets.QRadioButton(self.groupBox_11)
......
667 658
        self.radioButtonLoadXmlNo.setObjectName("radioButtonLoadXmlNo")
668 659
        self.buttonGroup.addButton(self.radioButtonLoadXmlNo)
669 660
        self.horizontalLayout_3.addWidget(self.radioButtonLoadXmlNo)
670
        self.gridLayout_31.addLayout(self.horizontalLayout_3, 0, 1, 1, 1)
661
        self.gridLayout_31.addLayout(self.horizontalLayout_3, 1, 1, 1, 1)
662
        self.label_34 = QtWidgets.QLabel(self.groupBox_11)
663
        self.label_34.setObjectName("label_34")
664
        self.gridLayout_31.addWidget(self.label_34, 2, 0, 1, 1)
671 665
        spacerItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
672
        self.gridLayout_31.addItem(spacerItem6, 0, 2, 1, 1)
666
        self.gridLayout_31.addItem(spacerItem6, 1, 2, 1, 1)
667
        self.label_30 = QtWidgets.QLabel(self.groupBox_11)
668
        self.label_30.setObjectName("label_30")
669
        self.gridLayout_31.addWidget(self.label_30, 1, 0, 1, 1)
673 670
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
674 671
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
675 672
        self.radioButtonSaveUnknownYes = QtWidgets.QRadioButton(self.groupBox_11)
......
684 681
        self.radioButtonSaveUnknownNo.setObjectName("radioButtonSaveUnknownNo")
685 682
        self.buttonGroup_2.addButton(self.radioButtonSaveUnknownNo)
686 683
        self.horizontalLayout_4.addWidget(self.radioButtonSaveUnknownNo)
687
        self.gridLayout_31.addLayout(self.horizontalLayout_4, 1, 1, 1, 1)
684
        self.gridLayout_31.addLayout(self.horizontalLayout_4, 2, 1, 1, 1)
688 685
        self.pushButtonClearAccessInfo = QtWidgets.QPushButton(self.groupBox_11)
689 686
        self.pushButtonClearAccessInfo.setObjectName("pushButtonClearAccessInfo")
690
        self.gridLayout_31.addWidget(self.pushButtonClearAccessInfo, 2, 1, 1, 1)
687
        self.gridLayout_31.addWidget(self.pushButtonClearAccessInfo, 3, 1, 1, 1)
688
        self.label_31 = QtWidgets.QLabel(self.groupBox_11)
689
        self.label_31.setMinimumSize(QtCore.QSize(200, 0))
690
        self.label_31.setObjectName("label_31")
691
        self.gridLayout_31.addWidget(self.label_31, 3, 0, 1, 1)
692
        self.label_49 = QtWidgets.QLabel(self.groupBox_11)
693
        self.label_49.setObjectName("label_49")
694
        self.gridLayout_31.addWidget(self.label_49, 0, 0, 1, 1)
695
        self.spinBoxSaveAlarm = QtWidgets.QSpinBox(self.groupBox_11)
696
        self.spinBoxSaveAlarm.setMaximum(100)
697
        self.spinBoxSaveAlarm.setSingleStep(10)
698
        self.spinBoxSaveAlarm.setObjectName("spinBoxSaveAlarm")
699
        self.gridLayout_31.addWidget(self.spinBoxSaveAlarm, 0, 1, 1, 1)
691 700
        self.gridLayout_23.addLayout(self.gridLayout_31, 0, 0, 1, 1)
692 701
        self.gridLayout_21.addWidget(self.groupBox_11, 0, 0, 1, 1)
693 702
        self.groupBox_13 = QtWidgets.QGroupBox(self.tabETC)
......
915 924
        self.radioButtonBackTextYes.setText(_translate("ConfigurationDialog", "Yes"))
916 925
        self.radioButtonBackTextNo.setText(_translate("ConfigurationDialog", "No"))
917 926
        self.groupBox_11.setTitle(_translate("ConfigurationDialog", "Program Data"))
918
        self.label_30.setText(_translate("ConfigurationDialog", "Load Data From"))
919
        self.label_34.setText(_translate("ConfigurationDialog", "Save Unknown Item to XML Only"))
920
        self.label_31.setText(_translate("ConfigurationDialog", "Clear Drawing Access Information"))
921 927
        self.radioButtonLoadXmlOnly.setText(_translate("ConfigurationDialog", "XML Only"))
922 928
        self.radioButtonLoadXmlYes.setText(_translate("ConfigurationDialog", "XML Frist"))
923 929
        self.radioButtonLoadXmlNo.setText(_translate("ConfigurationDialog", "Database Only"))
930
        self.label_34.setText(_translate("ConfigurationDialog", "Save Unknown Item to XML Only"))
931
        self.label_30.setText(_translate("ConfigurationDialog", "Load Data From"))
924 932
        self.radioButtonSaveUnknownYes.setText(_translate("ConfigurationDialog", "Yes"))
925 933
        self.radioButtonSaveUnknownNo.setText(_translate("ConfigurationDialog", "No"))
926 934
        self.pushButtonClearAccessInfo.setText(_translate("ConfigurationDialog", "Clear"))
935
        self.label_31.setText(_translate("ConfigurationDialog", "Clear Drawing Access Information"))
936
        self.label_49.setText(_translate("ConfigurationDialog", "Save Alarm(min)"))
927 937
        self.groupBox_13.setTitle(_translate("ConfigurationDialog", "Recognition Engine"))
928 938
        self.radioButtonTextAreaLocal.setText(_translate("ConfigurationDialog", "Local"))
929 939
        self.radioButtonTextAreaServer.setText(_translate("ConfigurationDialog", "Server"))
DTI_PID/DTI_PID/MainWindow.py
130 130
        # set title
131 131
        self.setWindowTitle(self.title)
132 132

  
133
        # save timer
134
        self.save_timer = None
135

  
133 136
        self.lineComboBox = QComboBox(self.toolBar)
134 137
        for condition in LineTypeConditions.items():
135 138
            self.lineComboBox.addItem(condition.name)
......
755 758

  
756 759
        app_doc_data = AppDocData.instance()
757 760
        if app_doc_data.activeDrawing and app_doc_data.activeDrawing.modified:
758
            if QMessageBox.Yes == QMessageBox.question(self, self.tr("Question"),
759
                                                       self.tr("Do you want to save drawing?"),
760
                                                       QMessageBox.Yes | QMessageBox.No):
761
                # self.actionSaveCliked()
762
                return True
761
            #if QMessageBox.Yes == QMessageBox.question(self, self.tr("Question"),
762
            #                                           self.tr("Do you want to save drawing?"),
763
            #                                           QMessageBox.Yes | QMessageBox.No):
764
            #    self.actionSaveCliked()
765
            #    return True
766
            if QMessageBox.Yes == QMessageBox.question(self, self.tr('Continue?'),
767
                                                       self.tr('Changes may not have been saved.'),
768
                                                       QMessageBox.Yes | QMessageBox.Cancel):
769
                return False
763 770

  
764 771
    '''
765 772
        @brief      action save click event
......
780 787
            if not self.actionSave.isEnabled():
781 788
                return
782 789
            self.actionSave.setEnabled(False)
790

  
791
            # save alarm
792
            self.save_alarm_enable(False)
793

  
783 794
            app_doc_data = AppDocData.instance()
784 795
            if app_doc_data.imgName is None:
785 796
                self.showImageSelectionMessageBox()
......
838 849
        self.setWindowTitle(title[:-1] if title[-1] == '*' else title)
839 850

  
840 851
        self.actionSave.setEnabled(True)
852
        
853
        # save alarm
854
        self.save_alarm_enable(True)
841 855

  
842 856
    '''
843 857
        @brief      refresh resultPropertyTableWidget
......
1372 1386
        from Drawing import Drawing
1373 1387

  
1374 1388
        try:
1389
            app_doc_data = AppDocData.instance()
1390

  
1375 1391
            if not self.actionSave.isEnabled():
1376 1392
                return
1377 1393

  
1378 1394
            if self.save_drawing_if_necessary():
1379 1395
                return
1380 1396

  
1397
            if not app_doc_data.set_occupying_drawing(drawing.UID):
1398
                QMessageBox.about(self.graphicsView, self.tr("Notice"),
1399
                                    self.tr("The drawing is locked for editing by another user"))
1400
                return
1401

  
1402
            # save alarm
1403
            self.save_alarm_enable(False)
1404

  
1381 1405
            if hasattr(self, '_save_work_cmd'):
1382 1406
                self._save_work_cmd.wait()
1383 1407

  
1384
            app_doc_data = AppDocData.instance()
1385 1408
            project = app_doc_data.getCurrentProject()
1386 1409

  
1387 1410
            self.path = self.graphicsView.loadImageFromFile(drawing)
......
1391 1414

  
1392 1415
                app_doc_data.setImgFilePath(self.path)
1393 1416
                app_doc_data.activeDrawing = drawing
1394
                if not app_doc_data.set_occupying_drawing(app_doc_data.activeDrawing.UID):
1395
                    QMessageBox.about(self.graphicsView, self.tr("Notice"),
1396
                                      self.tr("The drawing is locked for editing by another user"))
1397
                    return
1417
                
1398 1418
                app_doc_data.activeDrawing.set_pid_source(Image.open(self.path))
1399 1419
                self.itemTreeWidget.setCurrentPID(app_doc_data.activeDrawing.name)
1400 1420

  
......
1433 1453

  
1434 1454
                self.changeViewCheckedState(True)
1435 1455
                self.setWindowTitle(self.title)
1456

  
1457
                # save alarm
1458
                self.save_alarm_enable(True)
1436 1459
        except Exception as ex:
1437 1460
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1438 1461
                                                           sys.exc_info()[-1].tb_lineno)
......
1440 1463

  
1441 1464
        return self.path
1442 1465

  
1466
    def save_alarm_enable(self, enable):
1467
        app_doc_data = AppDocData.instance()
1468
        configs = app_doc_data.getConfigs('Data Save', 'Time')
1469
        time_min = int(configs[0].value) if 1 == len(configs) else 0
1470

  
1471
        if enable and time_min > 0:
1472
            if not self.save_timer:
1473
                self.save_timer = QTimer()
1474
                self.save_timer.timeout.connect(self.save_alarm)
1475
                self.save_timer.setInterval(60000 * time_min)
1476
            
1477
            if 60000 * time_min != self.save_timer.interval():
1478
                self.save_timer.setInterval(60000 * time_min)
1479

  
1480
            self.save_timer.start()
1481
        else:
1482
            if self.save_timer:
1483
                self.save_timer.stop()
1484

  
1485
    def save_alarm(self):
1486
        self.save_timer.stop()
1487
        if self.graphicsView.hasFocus():
1488
            QMessageBox.information(self, self.tr('Information'), self.tr('Please save Drawing'))
1489
        self.save_timer.start()
1490

  
1443 1491
    def export_as_svg(self):
1444 1492
        """export scene to svg file"""
1445 1493
        from ExportCommand import ExportCommand
......
2056 2104
            self.showImageSelectionMessageBox()
2057 2105
            return
2058 2106

  
2107
        # save alarm
2108
        self.save_alarm_enable(False)
2109

  
2059 2110
        try:
2060 2111
            appDocData = AppDocData.instance()
2061 2112

  
......
2092 2143
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2093 2144
                                                           sys.exc_info()[-1].tb_lineno)
2094 2145
            self.addMessage.emit(MessageType.Error, message)
2146
        finally:
2147
            # save alarm
2148
            self.save_alarm_enable(True)
2095 2149

  
2096 2150
    '''
2097 2151
        @brief      remove item from tree widget and then remove from scene
......
2200 2254
            self.showImageSelectionMessageBox()
2201 2255
            return
2202 2256

  
2257
        # save alarm
2258
        self.save_alarm_enable(False)
2259

  
2203 2260
        try:
2204 2261
            dlg = QConnectAttrDialog(self, self.graphicsView.scene())
2205 2262
            dlg.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
......
2225 2282
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
2226 2283
                                                           sys.exc_info()[-1].tb_lineno)
2227 2284
            self.addMessage.emit(MessageType.Error, message)
2285
        finally:
2286
            # save alarm
2287
            self.save_alarm_enable(True)
2228 2288

  
2229 2289
    '''
2230 2290
        @history    2018.05.25  Jeongwoo    Moved from MainWindow
DTI_PID/DTI_PID/UI/Configuration.ui
264 264
                <verstretch>0</verstretch>
265 265
               </sizepolicy>
266 266
              </property>
267
              <property name="maximum">
268
               <number>150</number>
269
              </property>
267 270
              <property name="value">
268 271
               <number>60</number>
269 272
              </property>
......
1355 1358
           <layout class="QGridLayout" name="gridLayout_23">
1356 1359
            <item row="0" column="0">
1357 1360
             <layout class="QGridLayout" name="gridLayout_31">
1358
              <item row="0" column="0">
1359
               <widget class="QLabel" name="label_30">
1360
                <property name="text">
1361
                 <string>Load Data From</string>
1362
                </property>
1363
               </widget>
1364
              </item>
1365
              <item row="1" column="0">
1366
               <widget class="QLabel" name="label_34">
1367
                <property name="text">
1368
                 <string>Save Unknown Item to XML Only</string>
1369
                </property>
1370
               </widget>
1371
              </item>
1372
              <item row="2" column="0">
1373
               <widget class="QLabel" name="label_31">
1374
                <property name="minimumSize">
1375
                 <size>
1376
                  <width>200</width>
1377
                  <height>0</height>
1378
                 </size>
1379
                </property>
1380
                <property name="text">
1381
                 <string>Clear Drawing Access Information</string>
1382
                </property>
1383
               </widget>
1384
              </item>
1385
              <item row="0" column="1">
1361
              <item row="1" column="1">
1386 1362
               <layout class="QHBoxLayout" name="horizontalLayout_3">
1387 1363
                <item>
1388 1364
                 <widget class="QRadioButton" name="radioButtonLoadXmlOnly">
......
1422 1398
                </item>
1423 1399
               </layout>
1424 1400
              </item>
1425
              <item row="0" column="2">
1401
              <item row="2" column="0">
1402
               <widget class="QLabel" name="label_34">
1403
                <property name="text">
1404
                 <string>Save Unknown Item to XML Only</string>
1405
                </property>
1406
               </widget>
1407
              </item>
1408
              <item row="1" column="2">
1426 1409
               <spacer name="horizontalSpacer_3">
1427 1410
                <property name="orientation">
1428 1411
                 <enum>Qt::Horizontal</enum>
......
1435 1418
                </property>
1436 1419
               </spacer>
1437 1420
              </item>
1438
              <item row="1" column="1">
1421
              <item row="1" column="0">
1422
               <widget class="QLabel" name="label_30">
1423
                <property name="text">
1424
                 <string>Load Data From</string>
1425
                </property>
1426
               </widget>
1427
              </item>
1428
              <item row="2" column="1">
1439 1429
               <layout class="QHBoxLayout" name="horizontalLayout_4">
1440 1430
                <item>
1441 1431
                 <widget class="QRadioButton" name="radioButtonSaveUnknownYes">
......
1465 1455
                </item>
1466 1456
               </layout>
1467 1457
              </item>
1468
              <item row="2" column="1">
1458
              <item row="3" column="1">
1469 1459
               <widget class="QPushButton" name="pushButtonClearAccessInfo">
1470 1460
                <property name="text">
1471 1461
                 <string>Clear</string>
1472 1462
                </property>
1473 1463
               </widget>
1474 1464
              </item>
1465
              <item row="3" column="0">
1466
               <widget class="QLabel" name="label_31">
1467
                <property name="minimumSize">
1468
                 <size>
1469
                  <width>200</width>
1470
                  <height>0</height>
1471
                 </size>
1472
                </property>
1473
                <property name="text">
1474
                 <string>Clear Drawing Access Information</string>
1475
                </property>
1476
               </widget>
1477
              </item>
1478
              <item row="0" column="0">
1479
               <widget class="QLabel" name="label_49">
1480
                <property name="text">
1481
                 <string>Save Alarm(min)</string>
1482
                </property>
1483
               </widget>
1484
              </item>
1485
              <item row="0" column="1">
1486
               <widget class="QSpinBox" name="spinBoxSaveAlarm">
1487
                <property name="maximum">
1488
                 <number>100</number>
1489
                </property>
1490
                <property name="singleStep">
1491
                 <number>10</number>
1492
                </property>
1493
               </widget>
1494
              </item>
1475 1495
             </layout>
1476 1496
            </item>
1477 1497
           </layout>

내보내기 Unified diff

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