This commit is contained in:
copper 2022-05-25 15:31:52 +08:00
parent 9f7478dfa9
commit 522548a151
4 changed files with 52 additions and 43 deletions

View File

@ -1,4 +1,4 @@
2022-05-24 20:29:01,454 - root - INFO - lic data:2022-12-01 00:00:00 2022-05-25 15:29:52,208 - root - INFO - lic data:2022-12-01 00:00:00
2022-05-24 20:29:01,455 - root - INFO - remain_days: 190 2022-05-25 15:29:52,209 - root - INFO - remain_days: 189
2022-05-24 20:29:02,777 - root - INFO - lic data:2022-12-01 00:00:00 2022-05-25 15:29:53,515 - root - INFO - lic data:2022-12-01 00:00:00
2022-05-24 20:29:02,777 - root - INFO - remain_days: 190 2022-05-25 15:29:53,515 - root - INFO - remain_days: 189

View File

@ -191,8 +191,7 @@ class ActionManager(QtCore.QObject):
if project.is_init: if project.is_init:
project.save() project.save()
project.clear() project.clear()
project.setup(projec_create.file, projec_create.name + '.prj') project.setup(projec_create.file, projec_create.name)
project.is_init = True
project.cell_size = projec_create.cell_size project.cell_size = projec_create.cell_size
project.max_memory = projec_create.max_memory project.max_memory = projec_create.max_memory
project.save() project.save()

View File

@ -2,25 +2,26 @@ from pathlib import Path
from PyQt5.QtWidgets import QDialog, QFileDialog, QLineEdit, QPushButton, QVBoxLayout, QHBoxLayout, QLabel, QMessageBox from PyQt5.QtWidgets import QDialog, QFileDialog, QLineEdit, QPushButton, QVBoxLayout, QHBoxLayout, QLabel, QMessageBox
from PyQt5.QtGui import QIcon, QIntValidator from PyQt5.QtGui import QIcon, QIntValidator
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from rscder.utils.project import Project
from rscder.utils.setting import Settings from rscder.utils.setting import Settings
class Create(QDialog): class Create(QDialog):
def __init__(self, parent=None) -> None: def __init__(self, parent=None) -> None:
super().__init__(parent) super().__init__(parent)
self.setWindowTitle('Create Project') self.setWindowTitle(self.tr('创建项目'))
self.setWindowIcon(QIcon(":/icons/logo.png")) self.setWindowIcon(QIcon(":/icons/logo.png"))
self.file = str(Path(Settings.General().root)/'default') self.file = str(Path(Settings.General().last_path))
self.name = '未命名' self.name = '未命名'
self.max_memory = Settings.Project().max_memory self.max_memory = Settings.Project().max_memory
self.cell_size = Settings.Project().cell_size self.cell_size = Settings.Project().cell_size
file_label = QLabel('Project Dir:') file_label = QLabel('项目目录:')
file_label.setFixedWidth(100) file_label.setFixedWidth(100)
file_input = QLineEdit() file_input = QLineEdit()
file_input.setPlaceholderText('Project Dir') file_input.setPlaceholderText('项目目录')
file_input.setToolTip('Project Dir') file_input.setToolTip('项目目录')
file_input.setReadOnly(True) file_input.setReadOnly(True)
file_input.setText(self.file) file_input.setText(self.file)
self.file_input = file_input self.file_input = file_input
@ -30,11 +31,11 @@ class Create(QDialog):
file_open.clicked.connect(self.open_file) file_open.clicked.connect(self.open_file)
name_label = QLabel('Project Name:') name_label = QLabel('项目名称:')
name_label.setFixedWidth(100) name_label.setFixedWidth(100)
name_input = QLineEdit() name_input = QLineEdit()
name_input.setPlaceholderText('Project Name') name_input.setPlaceholderText('项目名称')
name_input.setToolTip('Project Name') name_input.setToolTip('项目名称')
name_input.setText(self.name) name_input.setText(self.name)
self.name_input = name_input self.name_input = name_input
@ -48,18 +49,18 @@ class Create(QDialog):
file_input_layout.addWidget(file_input) file_input_layout.addWidget(file_input)
file_input_layout.addWidget(file_open) file_input_layout.addWidget(file_open)
cell_size_label = QLabel('Cell Size:') cell_size_label = QLabel('格网大小:')
cell_size_label.setFixedWidth(100) cell_size_label.setFixedWidth(100)
cell_size_x_label = QLabel('X:') cell_size_x_label = QLabel('X:')
cell_size_y_label = QLabel('Y:') cell_size_y_label = QLabel('Y:')
cell_size_x_input = QLineEdit() cell_size_x_input = QLineEdit()
cell_size_y_input = QLineEdit() cell_size_y_input = QLineEdit()
cell_size_x_input.setPlaceholderText('Cell Size X') cell_size_x_input.setPlaceholderText('X')
cell_size_x_input.setValidator(QIntValidator()) cell_size_x_input.setValidator(QIntValidator())
cell_size_y_input.setPlaceholderText('Cell Size Y') cell_size_y_input.setPlaceholderText('Y')
cell_size_y_input.setValidator(QIntValidator()) cell_size_y_input.setValidator(QIntValidator())
cell_size_x_input.setToolTip('Cell Size X') cell_size_x_input.setToolTip('X')
cell_size_y_input.setToolTip('Cell Size Y') cell_size_y_input.setToolTip('Y')
cell_size_x_input.setText(str(self.cell_size[0])) cell_size_x_input.setText(str(self.cell_size[0]))
cell_size_y_input.setText(str(self.cell_size[1])) cell_size_y_input.setText(str(self.cell_size[1]))
@ -73,17 +74,17 @@ class Create(QDialog):
cell_input_layout.addWidget(cell_size_y_label) cell_input_layout.addWidget(cell_size_y_label)
cell_input_layout.addWidget(cell_size_y_input) cell_input_layout.addWidget(cell_size_y_input)
max_memory_label = QLabel('Max Memory (MB):') max_memory_label = QLabel('最大文件大小 (MB):')
max_memory_label.setFixedWidth(100) max_memory_label.setFixedWidth(100)
max_memory_input = QLineEdit() max_memory_input = QLineEdit()
max_memory_input.setPlaceholderText('Max Memory') max_memory_input.setPlaceholderText('最大文件大小')
max_memory_input.setToolTip('Max Memory') max_memory_input.setToolTip('最大文件大小')
max_memory_input.setText(str(self.max_memory)) max_memory_input.setText(str(self.max_memory))
max_memory_input.setValidator(QIntValidator()) max_memory_input.setValidator(QIntValidator())
self.max_memory_input = max_memory_input self.max_memory_input = max_memory_input
ok_button = QPushButton('OK') ok_button = QPushButton('确定')
cancel_button = QPushButton('Cancel') cancel_button = QPushButton('取消')
ok_button.clicked.connect(self.ok) ok_button.clicked.connect(self.ok)
cancel_button.clicked.connect(self.cancel) cancel_button.clicked.connect(self.cancel)
@ -103,9 +104,10 @@ class Create(QDialog):
def open_file(self): def open_file(self):
file = QFileDialog.getExistingDirectory(self, 'Open Directory', self.file) file = QFileDialog.getExistingDirectory(self, '选择文件夹', self.file)
if file: if file:
self.file = file self.file = file
Settings.General().last_path = self.file
self.file_input.setText(self.file) self.file_input.setText(self.file)
def ok(self): def ok(self):
@ -113,13 +115,13 @@ class Create(QDialog):
self.max_memory = self.max_memory_input.text() self.max_memory = self.max_memory_input.text()
self.cell_size = (self.cell_size_x_input.text(), self.cell_size_y_input.text()) self.cell_size = (self.cell_size_x_input.text(), self.cell_size_y_input.text())
if self.name == '': if self.name == '':
QMessageBox.warning(self, 'Warning', 'Please input project name!') QMessageBox.warning(self, 'Warning', '请选择项目目录!')
return return
if self.max_memory == '': if self.max_memory == '':
QMessageBox.warning(self, 'Warning', 'Please input max memory!') QMessageBox.warning(self, 'Warning', '请输入最大文件大小!')
return return
if self.cell_size == ('', ''): if self.cell_size == ('', ''):
QMessageBox.warning(self, 'Warning', 'Please input cell size!') QMessageBox.warning(self, 'Warning', '请输入格网大小!')
return return
self.max_memory = int(self.max_memory) self.max_memory = int(self.max_memory)
self.cell_size = (int(self.cell_size[0]), int(self.cell_size[1])) self.cell_size = (int(self.cell_size[0]), int(self.cell_size[1]))

View File

@ -89,23 +89,31 @@ class Project(QObject):
self.layer_show_update.connect(self.run_auto_save) self.layer_show_update.connect(self.run_auto_save)
def setup(self, path = None, name = None): def setup(self, path = None, name = None):
'''
if path is not None: create: path is not None and name is not None
self.root = path open: path is file and name is None
if name is None: '''
self.file = str(Path(self.root)/'default.prj') if path is not None and name is not None:
self.root = str(Path(path)/name)
self.file = str(Path(self.root)/(name + '.prj'))
elif name is None:
self.file = path
self.root = os.path.split(path)[0]
else: else:
self.file = str(Path(self.root)/name) self.message_box.error('打开或创建项目失败')
if not os.path.exists(self.root): try:
os.makedirs(self.root, exist_ok=True) if not os.path.exists(self.root):
if not os.path.exists(self.file): os.makedirs(self.root, exist_ok=True)
with open(self.file, 'w') as f: if not os.path.exists(self.file):
pass with open(self.file, 'w') as f:
else: pass
self.load() else:
self.load()
self.is_init = True self.is_init = True
self.project_init.emit(True) self.project_init.emit(True)
except:
self.message_box.error('打开或创建项目失败')
def save(self): def save(self):
data_dict = { data_dict = {