프로젝트

일반

사용자정보

개정판 4635932f

ID4635932f0077619a10b384fca3c2f9d03adeb4a7
상위 b9350829
하위 028d5f11

김연진이(가) 5년 이상 전에 추가함

issue #1049:옵션 창 및 기능

Change-Id: Idf30eb6f71b042cf239aaba1a380cfb0f347f4cf

차이점 보기:

HYTOS/HYTOS/OptionsDialog.py
1
# coding: utf-8
2
""" This is Configuratio dialog module """
3

  
4
import os
5
import sys
6
from PyQt5.QtCore import *
7
from PyQt5.QtGui import *
8
from PyQt5.QtWidgets import *
9
import sqlite3
10
from App import App
11
from AppDocData import AppDocData
12
from AppDocData import Config
13
from AppDocData import Color
14
import Options_UI
15

  
16
class QOptionsDialog(QDialog):
17

  
18
    def __init__(self, parent):
19
        QDialog.__init__(self, parent)
20

  
21
        self.ui = Options_UI.Ui_OptionsDialog()
22
        self.ui.setupUi(self)
23
        
24
        self.load_data()
25

  
26
        # connect signals and slots
27
        self.ui.radioButtonFixedSize.toggled.connect(self.onFixedSizeToggled)
28

  
29
    def load_data(self):
30
        docData = AppDocData.instance()
31

  
32
        configs = docData.getConfigs('Symbol Style', 'Opacity')
33
        self.ui.spinBoxSymbolOpacity.setValue(int(configs[0].value) if configs else 50)
34

  
35
        self.ui.labelFontName.setBuddy(self.ui.fontComboBox)
36
        configs = docData.getConfigs('Text Style', 'Font Name')
37
        if configs:
38
            self.ui.fontComboBox.setCurrentFont(QFont(configs[0].value, 10))
39
        configs = docData.getConfigs('Text Style', 'Font Size')
40
        if configs:
41
            size = int(configs[0].value)
42
            self.ui.radioButtonAutoSize.setChecked(True if size == -1 else False)
43
            self.ui.radioButtonFixedSize.setChecked(True if size != -1 else False)
44
            self.ui.spinBoxFontSize.setValue(size if size != -1 else 10)
45
            self.ui.spinBoxFontSize.setEnabled(self.ui.radioButtonFixedSize.isChecked())
46
        else:
47
            self.ui.radioButtonAutoSize.setChecked(True)
48
            self.ui.radioButtonFixedSize.setChecked(False)
49
            self.ui.spinBoxFontSize.setValue(10)
50
            self.ui.spinBoxFontSize.setEnabled(self.ui.radioButtonFixedSize.isChecked())
51

  
52
    def onFixedSizeToggled(self, radioButton):
53
        self.ui.spinBoxFontSize.setEnabled(self.ui.radioButtonFixedSize.isChecked())
54

  
55
    def accept(self):
56
        
57
        try:
58
            docData = AppDocData.instance()
59

  
60
            configs = []                       
61

  
62
            configs.append(Config('Symbol Style', 'Opacity', str(self.ui.spinBoxSymbolOpacity.value())))
63

  
64
            font = self.ui.fontComboBox.currentFont()
65
            configs.append(Config('Text Style', 'Font Name', font.family()))
66
            configs.append(Config('Text Style', 'Font Size', str(self.ui.spinBoxFontSize.value()) if self.ui.radioButtonFixedSize.isChecked() else '-1'))
67
            
68
            docData.saveConfigs(configs)
69

  
70
            docData.configTable = None
71
        except Exception as ex:
72
            from App import App
73
            from AppDocData import MessageType
74

  
75
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
76
            App.mainWnd().addMessage.emit(MessageType.Error, message)
77

  
78
        QDialog.accept(self)
79

  
80
    def reject(self):
81
        QDialog.reject(self)
HYTOS/HYTOS/Options_UI.py
1
# -*- coding: utf-8 -*-
2

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

  
9

  
10
from PyQt5 import QtCore, QtGui, QtWidgets
11

  
12

  
13
class Ui_OptionsDialog(object):
14
    def setupUi(self, OptionsDialog):
15
        OptionsDialog.setObjectName("OptionsDialog")
16
        OptionsDialog.resize(363, 194)
17
        font = QtGui.QFont()
18
        font.setFamily("맑은 고딕")
19
        OptionsDialog.setFont(font)
20
        icon = QtGui.QIcon()
21
        icon.addPixmap(QtGui.QPixmap(":/newPrefix/Option.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
22
        OptionsDialog.setWindowIcon(icon)
23
        self.formLayout = QtWidgets.QFormLayout(OptionsDialog)
24
        self.formLayout.setObjectName("formLayout")
25
        self.tabWidget = QtWidgets.QTabWidget(OptionsDialog)
26
        self.tabWidget.setObjectName("tabWidget")
27
        self.tab = QtWidgets.QWidget()
28
        self.tab.setObjectName("tab")
29
        self.gridLayout_3 = QtWidgets.QGridLayout(self.tab)
30
        self.gridLayout_3.setObjectName("gridLayout_3")
31
        self.groupBoxText = QtWidgets.QGroupBox(self.tab)
32
        self.groupBoxText.setTitle("")
33
        self.groupBoxText.setObjectName("groupBoxText")
34
        self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBoxText)
35
        self.gridLayout_2.setObjectName("gridLayout_2")
36
        self.verticalLayout_5 = QtWidgets.QVBoxLayout()
37
        self.verticalLayout_5.setObjectName("verticalLayout_5")
38
        self.horizontalLayout_14 = QtWidgets.QHBoxLayout()
39
        self.horizontalLayout_14.setObjectName("horizontalLayout_14")
40
        self.label_2 = QtWidgets.QLabel(self.groupBoxText)
41
        self.label_2.setObjectName("label_2")
42
        self.horizontalLayout_14.addWidget(self.label_2)
43
        self.spinBoxSymbolOpacity = QtWidgets.QSpinBox(self.groupBoxText)
44
        self.spinBoxSymbolOpacity.setProperty("value", 50)
45
        self.spinBoxSymbolOpacity.setObjectName("spinBoxSymbolOpacity")
46
        self.horizontalLayout_14.addWidget(self.spinBoxSymbolOpacity)
47
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
48
        self.horizontalLayout_14.addItem(spacerItem)
49
        self.verticalLayout_5.addLayout(self.horizontalLayout_14)
50
        self.gridLayout_2.addLayout(self.verticalLayout_5, 0, 0, 1, 1)
51
        spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
52
        self.gridLayout_2.addItem(spacerItem1, 1, 0, 1, 1)
53
        self.gridLayout_3.addWidget(self.groupBoxText, 0, 0, 1, 1)
54
        self.tabWidget.addTab(self.tab, "")
55
        self.tab_2 = QtWidgets.QWidget()
56
        self.tab_2.setObjectName("tab_2")
57
        self.gridLayout = QtWidgets.QGridLayout(self.tab_2)
58
        self.gridLayout.setObjectName("gridLayout")
59
        self.groupBoxText_2 = QtWidgets.QGroupBox(self.tab_2)
60
        self.groupBoxText_2.setTitle("")
61
        self.groupBoxText_2.setObjectName("groupBoxText_2")
62
        self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBoxText_2)
63
        self.gridLayout_4.setObjectName("gridLayout_4")
64
        self.verticalLayout_6 = QtWidgets.QVBoxLayout()
65
        self.verticalLayout_6.setObjectName("verticalLayout_6")
66
        self.horizontalLayout_16 = QtWidgets.QHBoxLayout()
67
        self.horizontalLayout_16.setObjectName("horizontalLayout_16")
68
        self.labelFontName = QtWidgets.QLabel(self.groupBoxText_2)
69
        self.labelFontName.setMinimumSize(QtCore.QSize(0, 0))
70
        self.labelFontName.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
71
        self.labelFontName.setObjectName("labelFontName")
72
        self.horizontalLayout_16.addWidget(self.labelFontName)
73
        self.fontComboBox = QtWidgets.QFontComboBox(self.groupBoxText_2)
74
        self.fontComboBox.setObjectName("fontComboBox")
75
        self.horizontalLayout_16.addWidget(self.fontComboBox)
76
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
77
        self.horizontalLayout_16.addItem(spacerItem2)
78
        self.verticalLayout_6.addLayout(self.horizontalLayout_16)
79
        self.horizontalLayout_12 = QtWidgets.QHBoxLayout()
80
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
81
        self.labelFontSize = QtWidgets.QLabel(self.groupBoxText_2)
82
        self.labelFontSize.setMinimumSize(QtCore.QSize(0, 0))
83
        self.labelFontSize.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
84
        self.labelFontSize.setObjectName("labelFontSize")
85
        self.horizontalLayout_12.addWidget(self.labelFontSize)
86
        self.radioButtonAutoSize = QtWidgets.QRadioButton(self.groupBoxText_2)
87
        self.radioButtonAutoSize.setObjectName("radioButtonAutoSize")
88
        self.horizontalLayout_12.addWidget(self.radioButtonAutoSize)
89
        self.radioButtonFixedSize = QtWidgets.QRadioButton(self.groupBoxText_2)
90
        self.radioButtonFixedSize.setMaximumSize(QtCore.QSize(50, 16777215))
91
        self.radioButtonFixedSize.setObjectName("radioButtonFixedSize")
92
        self.horizontalLayout_12.addWidget(self.radioButtonFixedSize)
93
        self.spinBoxFontSize = QtWidgets.QSpinBox(self.groupBoxText_2)
94
        self.spinBoxFontSize.setObjectName("spinBoxFontSize")
95
        self.horizontalLayout_12.addWidget(self.spinBoxFontSize)
96
        spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
97
        self.horizontalLayout_12.addItem(spacerItem3)
98
        self.verticalLayout_6.addLayout(self.horizontalLayout_12)
99
        self.gridLayout_4.addLayout(self.verticalLayout_6, 0, 0, 1, 1)
100
        spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
101
        self.gridLayout_4.addItem(spacerItem4, 1, 0, 1, 1)
102
        self.gridLayout.addWidget(self.groupBoxText_2, 0, 0, 1, 1)
103
        self.tabWidget.addTab(self.tab_2, "")
104
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.tabWidget)
105
        self.buttonBox = QtWidgets.QDialogButtonBox(OptionsDialog)
106
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
107
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
108
        self.buttonBox.setObjectName("buttonBox")
109
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.buttonBox)
110

  
111
        self.retranslateUi(OptionsDialog)
112
        self.tabWidget.setCurrentIndex(0)
113
        self.buttonBox.accepted.connect(OptionsDialog.accept)
114
        self.buttonBox.rejected.connect(OptionsDialog.reject)
115
        QtCore.QMetaObject.connectSlotsByName(OptionsDialog)
116

  
117
    def retranslateUi(self, OptionsDialog):
118
        _translate = QtCore.QCoreApplication.translate
119
        OptionsDialog.setWindowTitle(_translate("OptionsDialog", "HYTOS Options"))
120
        self.label_2.setText(_translate("OptionsDialog", "Opacity : "))
121
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("OptionsDialog", "Symbol"))
122
        self.labelFontName.setText(_translate("OptionsDialog", "Font Name : "))
123
        self.labelFontSize.setText(_translate("OptionsDialog", "Font Size : "))
124
        self.radioButtonAutoSize.setText(_translate("OptionsDialog", "Auto"))
125
        self.radioButtonFixedSize.setText(_translate("OptionsDialog", "Fixed"))
126
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("OptionsDialog", "Text"))
127
import Resource_rc
HYTOS/HYTOS/UI/Options.ui
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ui version="4.0">
3
 <class>OptionsDialog</class>
4
 <widget class="QDialog" name="OptionsDialog">
5
  <property name="geometry">
6
   <rect>
7
    <x>0</x>
8
    <y>0</y>
9
    <width>363</width>
10
    <height>194</height>
11
   </rect>
12
  </property>
13
  <property name="font">
14
   <font>
15
    <family>맑은 고딕</family>
16
   </font>
17
  </property>
18
  <property name="windowTitle">
19
   <string>HYTOS Options</string>
20
  </property>
21
  <property name="windowIcon">
22
   <iconset resource="../res/Resource.qrc">
23
    <normaloff>:/newPrefix/Option.png</normaloff>:/newPrefix/Option.png</iconset>
24
  </property>
25
  <layout class="QFormLayout" name="formLayout">
26
   <item row="0" column="0" colspan="2">
27
    <widget class="QTabWidget" name="tabWidget">
28
     <property name="currentIndex">
29
      <number>0</number>
30
     </property>
31
     <widget class="QWidget" name="tab">
32
      <attribute name="title">
33
       <string>Symbol</string>
34
      </attribute>
35
      <layout class="QGridLayout" name="gridLayout_3">
36
       <item row="0" column="0">
37
        <widget class="QGroupBox" name="groupBoxText">
38
         <property name="title">
39
          <string/>
40
         </property>
41
         <layout class="QGridLayout" name="gridLayout_2">
42
          <item row="0" column="0">
43
           <layout class="QVBoxLayout" name="verticalLayout_5">
44
            <item>
45
             <layout class="QHBoxLayout" name="horizontalLayout_14">
46
              <item>
47
               <widget class="QLabel" name="label_2">
48
                <property name="text">
49
                 <string>Opacity : </string>
50
                </property>
51
               </widget>
52
              </item>
53
              <item>
54
               <widget class="QSpinBox" name="spinBoxSymbolOpacity">
55
                <property name="value">
56
                 <number>50</number>
57
                </property>
58
               </widget>
59
              </item>
60
              <item>
61
               <spacer name="horizontalSpacer">
62
                <property name="orientation">
63
                 <enum>Qt::Horizontal</enum>
64
                </property>
65
                <property name="sizeHint" stdset="0">
66
                 <size>
67
                  <width>40</width>
68
                  <height>20</height>
69
                 </size>
70
                </property>
71
               </spacer>
72
              </item>
73
             </layout>
74
            </item>
75
           </layout>
76
          </item>
77
          <item row="1" column="0">
78
           <spacer name="verticalSpacer">
79
            <property name="orientation">
80
             <enum>Qt::Vertical</enum>
81
            </property>
82
            <property name="sizeHint" stdset="0">
83
             <size>
84
              <width>20</width>
85
              <height>40</height>
86
             </size>
87
            </property>
88
           </spacer>
89
          </item>
90
         </layout>
91
        </widget>
92
       </item>
93
      </layout>
94
     </widget>
95
     <widget class="QWidget" name="tab_2">
96
      <attribute name="title">
97
       <string>Text</string>
98
      </attribute>
99
      <layout class="QGridLayout" name="gridLayout">
100
       <item row="0" column="0">
101
        <widget class="QGroupBox" name="groupBoxText_2">
102
         <property name="title">
103
          <string/>
104
         </property>
105
         <layout class="QGridLayout" name="gridLayout_4">
106
          <item row="0" column="0">
107
           <layout class="QVBoxLayout" name="verticalLayout_6">
108
            <item>
109
             <layout class="QHBoxLayout" name="horizontalLayout_16">
110
              <item>
111
               <widget class="QLabel" name="labelFontName">
112
                <property name="minimumSize">
113
                 <size>
114
                  <width>0</width>
115
                  <height>0</height>
116
                 </size>
117
                </property>
118
                <property name="text">
119
                 <string>Font Name : </string>
120
                </property>
121
                <property name="alignment">
122
                 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
123
                </property>
124
               </widget>
125
              </item>
126
              <item>
127
               <widget class="QFontComboBox" name="fontComboBox"/>
128
              </item>
129
              <item>
130
               <spacer name="horizontalSpacer_2">
131
                <property name="orientation">
132
                 <enum>Qt::Horizontal</enum>
133
                </property>
134
                <property name="sizeHint" stdset="0">
135
                 <size>
136
                  <width>40</width>
137
                  <height>20</height>
138
                 </size>
139
                </property>
140
               </spacer>
141
              </item>
142
             </layout>
143
            </item>
144
            <item>
145
             <layout class="QHBoxLayout" name="horizontalLayout_12">
146
              <item>
147
               <widget class="QLabel" name="labelFontSize">
148
                <property name="minimumSize">
149
                 <size>
150
                  <width>0</width>
151
                  <height>0</height>
152
                 </size>
153
                </property>
154
                <property name="text">
155
                 <string>Font Size : </string>
156
                </property>
157
                <property name="alignment">
158
                 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
159
                </property>
160
               </widget>
161
              </item>
162
              <item>
163
               <widget class="QRadioButton" name="radioButtonAutoSize">
164
                <property name="text">
165
                 <string>Auto</string>
166
                </property>
167
               </widget>
168
              </item>
169
              <item>
170
               <widget class="QRadioButton" name="radioButtonFixedSize">
171
                <property name="maximumSize">
172
                 <size>
173
                  <width>50</width>
174
                  <height>16777215</height>
175
                 </size>
176
                </property>
177
                <property name="text">
178
                 <string>Fixed</string>
179
                </property>
180
               </widget>
181
              </item>
182
              <item>
183
               <widget class="QSpinBox" name="spinBoxFontSize"/>
184
              </item>
185
              <item>
186
               <spacer name="horizontalSpacer_3">
187
                <property name="orientation">
188
                 <enum>Qt::Horizontal</enum>
189
                </property>
190
                <property name="sizeHint" stdset="0">
191
                 <size>
192
                  <width>40</width>
193
                  <height>20</height>
194
                 </size>
195
                </property>
196
               </spacer>
197
              </item>
198
             </layout>
199
            </item>
200
           </layout>
201
          </item>
202
          <item row="1" column="0">
203
           <spacer name="verticalSpacer_2">
204
            <property name="orientation">
205
             <enum>Qt::Vertical</enum>
206
            </property>
207
            <property name="sizeHint" stdset="0">
208
             <size>
209
              <width>20</width>
210
              <height>40</height>
211
             </size>
212
            </property>
213
           </spacer>
214
          </item>
215
         </layout>
216
        </widget>
217
       </item>
218
      </layout>
219
     </widget>
220
    </widget>
221
   </item>
222
   <item row="1" column="1">
223
    <widget class="QDialogButtonBox" name="buttonBox">
224
     <property name="orientation">
225
      <enum>Qt::Horizontal</enum>
226
     </property>
227
     <property name="standardButtons">
228
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
229
     </property>
230
    </widget>
231
   </item>
232
  </layout>
233
 </widget>
234
 <resources>
235
  <include location="../res/Resource.qrc"/>
236
 </resources>
237
 <connections>
238
  <connection>
239
   <sender>buttonBox</sender>
240
   <signal>accepted()</signal>
241
   <receiver>OptionsDialog</receiver>
242
   <slot>accept()</slot>
243
   <hints>
244
    <hint type="sourcelabel">
245
     <x>248</x>
246
     <y>254</y>
247
    </hint>
248
    <hint type="destinationlabel">
249
     <x>157</x>
250
     <y>274</y>
251
    </hint>
252
   </hints>
253
  </connection>
254
  <connection>
255
   <sender>buttonBox</sender>
256
   <signal>rejected()</signal>
257
   <receiver>OptionsDialog</receiver>
258
   <slot>reject()</slot>
259
   <hints>
260
    <hint type="sourcelabel">
261
     <x>316</x>
262
     <y>260</y>
263
    </hint>
264
    <hint type="destinationlabel">
265
     <x>286</x>
266
     <y>274</y>
267
    </hint>
268
   </hints>
269
  </connection>
270
 </connections>
271
</ui>

내보내기 Unified diff

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