Finished welcome dialog. New project dialog prototype.
This commit is contained in:
		@@ -0,0 +1,2 @@
 | 
			
		||||
from .recent_project import RecentProject
 | 
			
		||||
from .project import Project
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
class Project(object):
 | 
			
		||||
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        self.root_dir = None
 | 
			
		||||
    def __init__(self, path):
 | 
			
		||||
        self.root_dir = path
 | 
			
		||||
        
 | 
			
		||||
    def get_items(self):
 | 
			
		||||
        pass
 | 
			
		||||
							
								
								
									
										60
									
								
								model/recent_project.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								model/recent_project.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
import time
 | 
			
		||||
from typing import List
 | 
			
		||||
 | 
			
		||||
class RecentProject(object):
 | 
			
		||||
 | 
			
		||||
    DICT_FIELDS = [ 'path', 'name', 'dateAccessed', 'pinned' ]
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    Creates new instance of RecentProject.
 | 
			
		||||
 | 
			
		||||
    Args:
 | 
			
		||||
        name: name of the project
 | 
			
		||||
        path: path to the project
 | 
			
		||||
        dateAccessed: date (unix time) when project was last accessed
 | 
			
		||||
        pinned: the project is pinned by the user
 | 
			
		||||
 | 
			
		||||
    Remarks:
 | 
			
		||||
        If dateAccessed = None, it will be set to the current date and time.
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, name: str, path: str, dateAccessed : int = None, pinned : bool = False):
 | 
			
		||||
        self.name = name
 | 
			
		||||
        self.path = path
 | 
			
		||||
        self.dateAccessed = dateAccessed
 | 
			
		||||
        self.pinned = pinned
 | 
			
		||||
 | 
			
		||||
        if (self.dateAccessed is None):
 | 
			
		||||
            self.dateAccessed = int(time.time())
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    Creates new instance of RecentProject from a dictionary.
 | 
			
		||||
    If the dateAccessed and pinned fields are strings, they are parsed.
 | 
			
		||||
 | 
			
		||||
    Raises:
 | 
			
		||||
        ValueError if date cannot be parsed.
 | 
			
		||||
    """
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def fromDictionary(data : dict) -> 'RecentProject':
 | 
			
		||||
        name = data['name']
 | 
			
		||||
        path = data['path']
 | 
			
		||||
        dateAccessed = data['dateAccessed']
 | 
			
		||||
        pinned = data['pinned']
 | 
			
		||||
 | 
			
		||||
        if isinstance(dateAccessed, str):
 | 
			
		||||
            dateAccessed = int(dateAccessed)
 | 
			
		||||
 | 
			
		||||
        if isinstance(pinned, str):
 | 
			
		||||
            pinned = pinned.lower() in [ 'yes', 'y', 'true', '1', 'on' ]
 | 
			
		||||
 | 
			
		||||
        return RecentProject(name, path, dateAccessed, pinned)
 | 
			
		||||
 | 
			
		||||
    """
 | 
			
		||||
    Serialize to dictionary.
 | 
			
		||||
    """
 | 
			
		||||
    def toDictionary(self) -> dict:
 | 
			
		||||
        return {
 | 
			
		||||
            "name" : self.name,
 | 
			
		||||
            "path" : self.path,
 | 
			
		||||
            "dateAccessed" : self.dateAccessed,
 | 
			
		||||
            "pinned" : self.pinned
 | 
			
		||||
        }
 | 
			
		||||
		Reference in New Issue
	
	Block a user