개정판 2ee6d0db
issue #1118: add NewDrawing files
Change-Id: I6f80db29b04e6ac5fa5a76cad14f17eb0483dc4f
HYTOS/HYTOS/NewDrawingDialog.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
|
|
3 |
import os |
|
4 |
import sys |
|
5 |
import sqlite3 |
|
6 |
import New_UI |
|
7 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
8 |
from PyQt5.QtWidgets import * |
|
9 |
from AppDocData import AppDocData, MessageType |
|
10 |
from datetime import datetime |
|
11 |
import uuid |
|
12 |
|
|
13 |
class QNewDialog(QDialog): |
|
14 |
def __init__(self, parent): |
|
15 |
QDialog.__init__(self, parent) |
|
16 |
_translate = QtCore.QCoreApplication.translate |
|
17 |
|
|
18 |
self.result = False |
|
19 |
self.ui = New_UI.Ui_Dialog() |
|
20 |
self.ui.setupUi(self) |
|
21 |
self.setWindowTitle(_translate('New Dialog', 'New')) |
|
22 |
|
|
23 |
def showDialog(self): |
|
24 |
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint & ~QtCore.Qt.WindowContextHelpButtonHint) |
|
25 |
self.exec_() |
|
26 |
|
|
27 |
return self.result |
|
28 |
|
|
29 |
def accept(self): |
|
30 |
drawingName = self.ui.lineEditDrawingName.text().strip() |
|
31 |
|
|
32 |
if not self.validationCheck(drawingName): |
|
33 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Drawing name is empty.')) |
|
34 |
return |
|
35 |
|
|
36 |
if self.exists_drawing(drawingName): |
|
37 |
QMessageBox.warning(self, self.tr('Notice'), self.tr('Drawing name already exists.')) |
|
38 |
return |
|
39 |
|
|
40 |
self.saveDrawing(drawingName) |
|
41 |
|
|
42 |
self.result = True |
|
43 |
QDialog.accept(self) |
|
44 |
|
|
45 |
def reject(self): |
|
46 |
|
|
47 |
self.result = False |
|
48 |
QDialog.reject(self) |
|
49 |
|
|
50 |
def validationCheck(self, drawingName): |
|
51 |
if not drawingName: |
|
52 |
return False |
|
53 |
|
|
54 |
return True |
|
55 |
|
|
56 |
def exists_drawing(self, drawingName): |
|
57 |
return AppDocData.instance().exists_drawing(drawingName) |
|
58 |
|
|
59 |
def saveDrawing(self, drawingName): |
|
60 |
drawings = [] |
|
61 |
drawings.append([str(uuid.uuid4()), drawingName, str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))]) |
|
62 |
|
|
63 |
AppDocData.instance().saveDrawings(drawings) |
HYTOS/HYTOS/NewDrawing_UI.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
|
|
3 |
# Form implementation generated from reading ui file '.\UI\New.ui' |
|
4 |
# |
|
5 |
# Created by: PyQt5 UI code generator 5.11.3 |
|
6 |
# |
|
7 |
# WARNING! All changes made in this file will be lost! |
|
8 |
|
|
9 |
from PyQt5 import QtCore, QtGui, QtWidgets |
|
10 |
|
|
11 |
class Ui_Dialog(object): |
|
12 |
def setupUi(self, Dialog): |
|
13 |
Dialog.setObjectName("Dialog") |
|
14 |
Dialog.resize(368, 97) |
|
15 |
Dialog.setLocale(QtCore.QLocale(QtCore.QLocale.Korean, QtCore.QLocale.SouthKorea)) |
|
16 |
self.gridLayout = QtWidgets.QGridLayout(Dialog) |
|
17 |
self.gridLayout.setObjectName("gridLayout") |
|
18 |
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) |
|
19 |
font = QtGui.QFont() |
|
20 |
font.setFamily("맑은 고딕") |
|
21 |
font.setBold(True) |
|
22 |
font.setWeight(75) |
|
23 |
self.buttonBox.setFont(font) |
|
24 |
self.buttonBox.setOrientation(QtCore.Qt.Horizontal) |
|
25 |
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) |
|
26 |
self.buttonBox.setObjectName("buttonBox") |
|
27 |
self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1) |
|
28 |
self.horizontalLayout = QtWidgets.QHBoxLayout() |
|
29 |
self.horizontalLayout.setObjectName("horizontalLayout") |
|
30 |
self.label = QtWidgets.QLabel(Dialog) |
|
31 |
font = QtGui.QFont() |
|
32 |
font.setFamily("맑은 고딕") |
|
33 |
self.label.setFont(font) |
|
34 |
self.label.setObjectName("label") |
|
35 |
self.horizontalLayout.addWidget(self.label) |
|
36 |
self.lineEditDrawingName = QtWidgets.QLineEdit(Dialog) |
|
37 |
font = QtGui.QFont() |
|
38 |
font.setFamily("맑은 고딕") |
|
39 |
self.lineEditDrawingName.setFont(font) |
|
40 |
self.lineEditDrawingName.setObjectName("lineEditDrawingName") |
|
41 |
self.horizontalLayout.addWidget(self.lineEditDrawingName) |
|
42 |
self.gridLayout.addLayout(self.horizontalLayout, 1, 1, 1, 1) |
|
43 |
|
|
44 |
self.retranslateUi(Dialog) |
|
45 |
self.buttonBox.accepted.connect(Dialog.accept) |
|
46 |
self.buttonBox.rejected.connect(Dialog.reject) |
|
47 |
QtCore.QMetaObject.connectSlotsByName(Dialog) |
|
48 |
|
|
49 |
def retranslateUi(self, Dialog): |
|
50 |
_translate = QtCore.QCoreApplication.translate |
|
51 |
Dialog.setWindowTitle(_translate("Dialog", "New")) |
|
52 |
self.label.setText(_translate("Dialog", "Drawing Name")) |
|
53 |
|
HYTOS/HYTOS/UI/NewDrawing.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>Dialog</class> |
|
4 |
<widget class="QDialog" name="Dialog"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>368</width> |
|
10 |
<height>97</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="windowTitle"> |
|
14 |
<string>New</string> |
|
15 |
</property> |
|
16 |
<property name="locale"> |
|
17 |
<locale language="Korean" country="SouthKorea"/> |
|
18 |
</property> |
|
19 |
<layout class="QGridLayout" name="gridLayout"> |
|
20 |
<item row="2" column="1"> |
|
21 |
<widget class="QDialogButtonBox" name="buttonBox"> |
|
22 |
<property name="font"> |
|
23 |
<font> |
|
24 |
<family>맑은 고딕</family> |
|
25 |
<weight>75</weight> |
|
26 |
<bold>true</bold> |
|
27 |
</font> |
|
28 |
</property> |
|
29 |
<property name="orientation"> |
|
30 |
<enum>Qt::Horizontal</enum> |
|
31 |
</property> |
|
32 |
<property name="standardButtons"> |
|
33 |
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
|
34 |
</property> |
|
35 |
</widget> |
|
36 |
</item> |
|
37 |
<item row="1" column="1"> |
|
38 |
<layout class="QHBoxLayout" name="horizontalLayout"> |
|
39 |
<item> |
|
40 |
<widget class="QLabel" name="label"> |
|
41 |
<property name="font"> |
|
42 |
<font> |
|
43 |
<family>맑은 고딕</family> |
|
44 |
</font> |
|
45 |
</property> |
|
46 |
<property name="text"> |
|
47 |
<string>Drawing Name</string> |
|
48 |
</property> |
|
49 |
</widget> |
|
50 |
</item> |
|
51 |
<item> |
|
52 |
<widget class="QLineEdit" name="lineEditDrawingName"> |
|
53 |
<property name="font"> |
|
54 |
<font> |
|
55 |
<family>맑은 고딕</family> |
|
56 |
</font> |
|
57 |
</property> |
|
58 |
</widget> |
|
59 |
</item> |
|
60 |
</layout> |
|
61 |
</item> |
|
62 |
</layout> |
|
63 |
</widget> |
|
64 |
<resources/> |
|
65 |
<connections> |
|
66 |
<connection> |
|
67 |
<sender>buttonBox</sender> |
|
68 |
<signal>accepted()</signal> |
|
69 |
<receiver>Dialog</receiver> |
|
70 |
<slot>accept()</slot> |
|
71 |
<hints> |
|
72 |
<hint type="sourcelabel"> |
|
73 |
<x>248</x> |
|
74 |
<y>254</y> |
|
75 |
</hint> |
|
76 |
<hint type="destinationlabel"> |
|
77 |
<x>157</x> |
|
78 |
<y>274</y> |
|
79 |
</hint> |
|
80 |
</hints> |
|
81 |
</connection> |
|
82 |
<connection> |
|
83 |
<sender>buttonBox</sender> |
|
84 |
<signal>rejected()</signal> |
|
85 |
<receiver>Dialog</receiver> |
|
86 |
<slot>reject()</slot> |
|
87 |
<hints> |
|
88 |
<hint type="sourcelabel"> |
|
89 |
<x>316</x> |
|
90 |
<y>260</y> |
|
91 |
</hint> |
|
92 |
<hint type="destinationlabel"> |
|
93 |
<x>286</x> |
|
94 |
<y>274</y> |
|
95 |
</hint> |
|
96 |
</hints> |
|
97 |
</connection> |
|
98 |
</connections> |
|
99 |
</ui> |
내보내기 Unified diff