def remove_project(self):
     project_ini_path = os.path.join(self.parent_dir, 'ini', 'project.data')
     project_names = cpickle_operation.get_cpickle_data(project_ini_path)
     project_names.remove(self.sender().text())
     cpickle_operation.set_cpickle_data(project_ini_path, project_names)
     self.sender().deleteLater()
     self.update_project()
 def init_settings(self):
     project_ini_path = os.path.join(self.parent_dir, 'ini', 'project.data')
     if os.path.isfile(project_ini_path):
         project_names = cpickle_operation.get_cpickle_data(
             project_ini_path)
         if project_names:
             model = QStandardItemModel()
             for project_name in project_names:
                 item = QStandardItem(project_name)
                 model.appendRow(item)
             self.project_name_cbox.setModel(model)
             self.project_name_cbox.setCurrentIndex(
                 self.project_name_cbox.count() + 1)
 def read_setting(self):
     if self.os_type == 'windows':
         latest_project_data_path = os.path.join(os.environ['APPDATA'],
                                                 'latest_project.data')
     if self.os_type == 'linux':
         latest_project_data_path = os.path.join('/tmp',
                                                 'latest_project.data')
     if os.path.isfile(latest_project_data_path):
         value = cpickle_operation.get_cpickle_data(
             latest_project_data_path)
         if self.project_cbox.findText(value) != -1:
             self.project_cbox.setCurrentIndex(
                 self.project_cbox.findText(value))
 def update_project(self):
     self.remove_project_menu.clear()
     self.project_cbox.clear()
     project_ini_path = os.path.join(self.parent_dir, 'ini', 'project.data')
     if os.path.isfile(project_ini_path):
         project_names = cpickle_operation.get_cpickle_data(
             project_ini_path)
         if project_names:
             for project_name in project_names:
                 self.project_cbox.addItem(project_name)
                 self.project_action = QAction(project_name, self)
                 self.project_action.triggered.connect(self.remove_project)
                 self.remove_project_menu.addAction(self.project_action)
             self.project_cbox.setCurrentIndex(self.project_cbox.count() +
                                               1)
 def add_projcet(self):
     project_name = self.project_name_cbox.currentText()
     if project_name:
         ########project ini path
         project_ini_path = os.path.join(self.parent_dir, 'ini',
                                         'project.data')
         if not os.path.isfile(project_ini_path):
             f = open(os.path.join(self.parent_dir, 'ini', 'project.data'),
                      'w')
             f.close()
         project_names = cpickle_operation.get_cpickle_data(
             project_ini_path)
         if project_name not in project_names:
             project_names.append(project_name)
             cpickle_operation.set_cpickle_data(project_ini_path,
                                                project_names)
         ########project render settings data
         render_settings_data_dir = os.path.join(self.parent_dir, 'data',
                                                 'render_settings_data')
         if not os.path.isdir(render_settings_data_dir):
             os.makedirs(render_settings_data_dir)
         render_settings_data_path = os.path.join(
             render_settings_data_dir,
             str(project_name) + '_render_settings.json')
         render_settings_dict = dict()
         for i in xrange(self.atrribute_layout.count()):
             layout = self.atrribute_layout.itemAt(i).layout()
             if layout and layout.line.text():
                 render_settings_dict[layout.attr_name] = str(
                     layout.line.text())
         json_operation.set_json_data(render_settings_data_path,
                                      render_settings_dict)
     else:
         warm_tip.warm_tip('Please input a project name')
     try:
         rsw_widget.update_project()
     except:
         pass
     self.do_close()
Exemple #6
0
 def read_settings(self):
     latest_dir = self.get_latest_dir()
     if os.path.isfile(latest_dir):
         value = cpickle_operation.get_cpickle_data(latest_dir)
         self.abc_file_le.setText(value)