개정판 3a867046
issue 1351: save and restore layout of app
Change-Id: Id2abe1439413846367834d83ab627d7a0928c3b4
DTI_PID/DTI_PID/App.py | ||
---|---|---|
4 | 4 |
import os |
5 | 5 |
|
6 | 6 |
if hasattr(sys, 'frozen'): |
7 |
os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH'] |
|
8 |
|
|
7 |
os.environ['PATH'] = sys._MEIPASS + ";" + os.environ['PATH']
|
|
8 |
|
|
9 | 9 |
from PyQt5.QtCore import * |
10 | 10 |
from PyQt5.QtGui import * |
11 | 11 |
from PyQt5.QtWidgets import * |
... | ... | |
16 | 16 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) |
17 | 17 |
from AppDocData import AppDocData |
18 | 18 |
|
19 |
|
|
19 | 20 |
class App(QApplication): |
20 | 21 |
""" This is App class inherits from QApplication """ |
21 | 22 |
|
23 |
COMPANY = 'DOFTECH' |
|
22 | 24 |
NAME = 'Digital P&ID' |
23 | 25 |
|
24 | 26 |
def __init__(self, args): |
... | ... | |
41 | 43 |
self._translator = None |
42 | 44 |
configs = app_doc_data.getAppConfigs('app', 'language') |
43 | 45 |
if configs and len(configs) == 1: |
44 |
qm_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'translate', '{0}.qm'.format(configs[0].value)) |
|
46 |
qm_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'translate', |
|
47 |
'{0}.qm'.format(configs[0].value)) |
|
45 | 48 |
else: |
46 | 49 |
locale = locale.getdefaultlocale() |
47 | 50 |
qm_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'translate', '{0}.qm'.format(locale[0])) |
... | ... | |
58 | 61 |
@author humkyung |
59 | 62 |
@date 2018.04.07 |
60 | 63 |
''' |
64 |
|
|
61 | 65 |
def loadStyleSheet(self, sheetName): |
62 | 66 |
try: |
63 | 67 |
file = QFile('%s.qss' % sheetName.lower()) |
... | ... | |
97 | 101 |
|
98 | 102 |
return None |
99 | 103 |
|
104 |
|
|
100 | 105 |
''' |
101 | 106 |
@history 18.04.23 Jeongwoo Change method to execute ProjectDialog(dlg.exec_()→dlg.showDialog()) |
102 | 107 |
''' |
... | ... | |
122 | 127 |
else: |
123 | 128 |
qtmodern.styles.darkorange(app) |
124 | 129 |
""" |
125 |
if True:# == QLicenseDialog.check_license_key(): |
|
130 |
if True: # == QLicenseDialog.check_license_key():
|
|
126 | 131 |
dlg = Ui_Dialog() |
127 | 132 |
selectedProject = dlg.showDialog() |
128 | 133 |
if selectedProject is not None: |
... | ... | |
130 | 135 |
AppDocData.instance().ex = exceptionHandler |
131 | 136 |
app._mainWnd = MainWindow.instance() |
132 | 137 |
app._mainWnd.show() |
133 |
sys.exit(app.exec_()) |
|
138 |
sys.exit(app.exec_()) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
322 | 322 |
self.tableWidgetInconsistency.keyPressEvent = self.inconsistencyTableKeyPressEvent |
323 | 323 |
self.tableWidgetInconsistency.setSortingEnabled(True) |
324 | 324 |
|
325 |
self.read_settings() |
|
326 |
|
|
325 | 327 |
@property |
326 | 328 |
def title(self) -> str: |
327 | 329 |
"""return window title""" |
... | ... | |
345 | 347 |
return QWidget.eventFilter(self, source, event) |
346 | 348 |
|
347 | 349 |
def closeEvent(self, event): |
348 |
"""ask user to save drawing which is modified""" |
|
350 |
"""save geometry and state and ask user to save drawing which is modified"""
|
|
349 | 351 |
|
352 |
self.settings.setValue('geometry', self.saveGeometry()) |
|
353 |
self.settings.setValue('windowState', self.saveState()) |
|
354 |
# TODO: need to modify |
|
350 | 355 |
#self.save_drawing_if_necessary() |
351 | 356 |
AppDocData.instance().clear() |
352 | 357 |
event.accept() |
... | ... | |
449 | 454 |
|
450 | 455 |
HighlightCommand(self.graphicsView).execute(item.tag) |
451 | 456 |
|
457 |
def read_settings(self): |
|
458 |
"""read geometry and state""" |
|
459 |
from App import App |
|
460 |
|
|
461 |
try: |
|
462 |
self.settings = QSettings(App.COMPANY, App.NAME) |
|
463 |
self.restoreGeometry(self.settings.value("geometry", "")) |
|
464 |
self.restoreState(self.settings.value("windowState", "")) |
|
465 |
except Exception as ex: |
|
466 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
467 |
sys.exc_info()[-1].tb_lineno) |
|
468 |
print(message) |
|
469 |
|
|
470 |
|
|
452 | 471 |
def load_stylesheet(self, file): |
453 |
""" |
|
454 |
@brief load stylesheets |
|
455 |
@author humkyung |
|
456 |
@date 2018.10.29 |
|
457 |
""" |
|
472 |
"""load stylesheets""" |
|
458 | 473 |
|
459 | 474 |
QtWidgets.qApp.loadStyleSheet(os.path.join(os.path.dirname(os.path.realpath(__file__)), file)) |
460 | 475 |
|
내보내기 Unified diff