def __init__(self, parent=None): super(Home, self).__init__(parent) settings_folder = os.path.join(os.path.expanduser("~"), ".config", "DICE") if not os.path.exists(settings_folder): os.makedirs(settings_folder) self.__recent_projects = JsonList( os.path.join(settings_folder, "recent_projects.json")) self.__max_recent_projects = 10 # TODO: get this value from settings
def get_model_data(self, path=None, *args): """ Returns the model as stored in the DB. The DB could be stored in the users config folder, the app installation folder or the global DICE db folder. The path is then searched in this order in all these folders. :param path: :param args: :return: """ if path is None: return [] file_path, dict_path = self.split_path(path) file_name = os.path.join(self.module_path(), "db", file_path) + ".json" # TODO: merge lists if local and global files exist if not os.path.exists(file_name): file_name = os.path.join(self.dice.application_dir, "db", file_path) + ".json" if not os.path.exists(file_name): return [] if dict_path: jl = JsonOrderedDict(file_name) return self.get_value_by_path(jl, dict_path) else: jl = JsonList(file_name) return jl
def __load_next_core_app(self): if self.__app_candidates is None: core_apps_json = os.path.join(self.application_dir, "core_apps", "core_apps.json") self.__app_candidates = JsonList(core_apps_json) if self.__current_loading_core_app_index == len(self.__app_candidates): return core_app_name = self.__app_candidates[ self.__current_loading_core_app_index] qDebug("load " + core_app_name) self.__current_loading_core_app_index += 1 core_app = self.__create_core_app(core_app_name) if core_app is not None: core_app.load() core_app.completed.connect(self.__continue_loading_apps) self.core_app_loaded.emit(core_app) # set really special core apps if core_app.name == "Home": self.home = core_app elif core_app.name == "Desk": self.desk = core_app elif core_app.name == "Settings": self.settings = core_app else: raise Exception("Could not load " + core_app_name)
class Home(CoreApp): def __init__(self, parent=None): super(Home, self).__init__(parent) settings_folder = os.path.join(os.path.expanduser("~"), ".config", "DICE") if not os.path.exists(settings_folder): os.makedirs(settings_folder) self.__recent_projects = JsonList( os.path.join(settings_folder, "recent_projects.json")) self.__max_recent_projects = 10 # TODO: get this value from settings recent_projects_changed = pyqtSignal(name="recentProjectsChanged") @property def recent_projects(self): return self.__recent_projects.to_simple_list() recentProjects = pyqtProperty("QVariantList", fget=recent_projects.fget, notify=recent_projects_changed) def add_recent_project(self, project_name, location): recent_locations = [ recent_project['location'] for recent_project in self.__recent_projects ] recent_project = {'projectName': project_name, 'location': location} if location not in recent_locations: self.__recent_projects.insert(0, recent_project) while len(self.__recent_projects) > self.__max_recent_projects: self.__recent_projects.pop() self.recent_projects_changed.emit() else: # add the project on top of the list index = self.__recent_projects.index(recent_project) if index != 0: self.__recent_projects.pop(index) self.__recent_projects.insert(0, recent_project) self.recent_projects_changed.emit() @pyqtSlot(name="closeProject") def close_project(self): self.dice.project.close() self.dice.desk.clear_workspace()
def __init__(self, parent=None): super(Home, self).__init__(parent) settings_folder = os.path.join(os.path.expanduser("~"), ".config", "DICE") if not os.path.exists(settings_folder): os.makedirs(settings_folder) self.__recent_projects = JsonList(os.path.join(settings_folder, "recent_projects.json")) self.__max_recent_projects = 10 # TODO: get this value from settings
class Home(CoreApp): def __init__(self, parent=None): super(Home, self).__init__(parent) settings_folder = os.path.join(os.path.expanduser("~"), ".config", "DICE") if not os.path.exists(settings_folder): os.makedirs(settings_folder) self.__recent_projects = JsonList(os.path.join(settings_folder, "recent_projects.json")) self.__max_recent_projects = 10 # TODO: get this value from settings recent_projects_changed = pyqtSignal(name="recentProjectsChanged") @property def recent_projects(self): return self.__recent_projects.to_simple_list() recentProjects = pyqtProperty("QVariantList", fget=recent_projects.fget, notify=recent_projects_changed) def add_recent_project(self, project_name, location): recent_locations = [recent_project['location'] for recent_project in self.__recent_projects] recent_project = {'projectName': project_name, 'location': location} if location not in recent_locations: self.__recent_projects.insert(0, recent_project) while len(self.__recent_projects) > self.__max_recent_projects: self.__recent_projects.pop() self.recent_projects_changed.emit() else: # add the project on top of the list index = self.__recent_projects.index(recent_project) if index != 0: self.__recent_projects.pop(index) self.__recent_projects.insert(0, recent_project) self.recent_projects_changed.emit() @pyqtSlot(name="closeProject") def close_project(self): self.dice.project.close() self.dice.desk.clear_workspace()