Ejemplo n.º 1
0
void pManagement::projectContents()
{
    /*
     *Todo: Hazır şablonlar sınıfı oluşturulacak.
     *Bu method hazır şablon sınıfına devredilecek.
    */
    //Ana dosya oluşuturuluyor.
    QString path = getProjectPath()+QDir::separator()+getProjectName()+
                   QDir::separator()+getMainClass();
    QFile mclass(path+".d");
    if (!mclass.open(QIODevice::WriteOnly | QIODevice::Text))
        return;
    QTextStream out(&mclass);
    out << "import std.stdio;" << endl
            << "void main(){" << endl
            << " writefln(\"Merhaba\");" << endl
            << "}" << endl;
    mclass.close();

    QFile mindex(getProjectPath()+QDir::separator()+getProjectName()+QDir::separator()+"index.did");
    if (!mindex.open(QIODevice::WriteOnly | QIODevice::Text))
        return;
    QTextStream out2(&mindex);
    out2 << "RUNCLASS=" << getMainClass() <<".d\n";
    mindex.close();
    projectsHistory(getProjectPath()+QDir::separator()+getProjectName());
}
	SPtr<EditorWidgetLayout> EditorApplication::loadWidgetLayout()
	{
		Path layoutPath = getProjectPath();
		layoutPath.append(WIDGET_LAYOUT_PATH);

		if (!FileSystem::exists(layoutPath))
			saveDefaultWidgetLayout(getProjectPath());

		if(FileSystem::exists(layoutPath))
		{
			FileDecoder fs(layoutPath);
			return std::static_pointer_cast<EditorWidgetLayout>(fs.decode());
		}

		return nullptr;
	}
	void EditorApplication::saveWidgetLayout(const SPtr<EditorWidgetLayout>& layout)
	{
		Path layoutPath = getProjectPath();
		layoutPath.append(WIDGET_LAYOUT_PATH);

		FileEncoder fs(layoutPath);
		fs.encode(layout.get());
	}
Ejemplo n.º 4
0
void pManagement::createProject()
{
    //Görsel arayüzden alacağımız proje ismi ve yoluna dizin eklenecek
    //İçerisine sınıf ve index.txt atılacak.

    QTextStream cout(stdout);


    QDir pPath(getProjectPath()+QDir::separator()+getProjectName());
    bool stats = pPath.exists();
    if(!stats)
    {
        QDir dir(getProjectPath());
        dir.mkdir(getProjectName());
        projectContents();
    }else
    {
        cout << "Dizin var" << endl;
    }
}
	void EditorApplication::saveProjectSettings()
	{
		if (mProjectSettings == nullptr || !isProjectLoaded())
			return;

		Path absoluteDataPath = getProjectPath();
		absoluteDataPath.append(PROJECT_SETTINGS_PATH);

		FileEncoder fs(absoluteDataPath);
		fs.encode(mProjectSettings.get());
	}
	void EditorApplication::saveProject()
	{
		if (!isProjectLoaded())
			return;

		Path buildDataPath = getProjectPath();
		buildDataPath.append(BUILD_DATA_PATH);

		BuildManager::instance().save(buildDataPath);
		saveWidgetLayout(EditorWidgetManager::instance().getLayout());
		saveEditorSettings();
		saveProjectSettings();

		gProjectLibrary().saveLibrary();
	}
	void EditorApplication::loadProjectSettings()
	{
		if (isProjectLoaded())
		{
			Path absoluteDataPath = getProjectPath();
			absoluteDataPath.append(PROJECT_SETTINGS_PATH);

			if (FileSystem::exists(absoluteDataPath))
			{
				FileDecoder fs(absoluteDataPath);
				mProjectSettings = std::static_pointer_cast<ProjectSettings>(fs.decode());
			}
		}

		if (mProjectSettings == nullptr)
			mProjectSettings = bs_shared_ptr_new<ProjectSettings>();
	}
	void EditorApplication::loadProject(const Path& projectPath)
	{
		unloadProject();

		mProjectPath = projectPath;
		mProjectName = projectPath.getTail();
		mIsProjectLoaded = true;

		loadProjectSettings();

		Path buildDataPath = getProjectPath();
		buildDataPath.append(BUILD_DATA_PATH);

		BuildManager::instance().load(buildDataPath);
		gProjectLibrary().loadLibrary();

		// Do this before restoring windows to ensure types are loaded
		ScriptManager::instance().reload();
		
		SPtr<EditorWidgetLayout> layout = loadWidgetLayout();
		if (layout != nullptr)
			EditorWidgetManager::instance().setLayout(layout);
	}