void GLShaderDev::clearProjectRecent() { QSettings settings; settings.setValue("recentProjects", QStringList()); updateRecentProjects(); }
void GLShaderDev::initializeActions() { QSettings settings; QMenu* recent; QMenu* fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(QIcon(":/document-new.png"), tr("&New..."), _newFileDialog, SLOT(exec()), QKeySequence::New); connect(_newFileDialog, SIGNAL(accepted()), this, SLOT(newFile())); fileMenu->addAction(QIcon(":/document-open.png"), tr("&Open..."), this, SLOT(openFileDialog()), QKeySequence::Open); recent = fileMenu->addMenu(QIcon(":/document-open-recent.png"), tr("Open &Recent")); for (int i = 0; i < MaxRecentFiles; ++i) (_recentFileActions[i] = recent->addAction(tr("<Empty>"), this, SLOT(openRecentFile())))->setVisible(true); (_recentFileActions[MaxRecentFiles] = recent->addSeparator())->setVisible(true); (_recentFileActions[MaxRecentFiles + 1] = recent->addAction(tr("&Clear List"), this, SLOT(clearFileRecent())))->setEnabled(false); updateRecentFiles(); fileMenu->addSeparator(); fileMenu->addAction(QIcon(":/document-save-all.png"), tr("Save Al&l"), _editor, SLOT(saveAll())); fileMenu->addAction(QIcon(":/document-save.png"), tr("&Save"), _editor, SLOT(save()), QKeySequence::Save); fileMenu->addAction(QIcon(":/document-save-as.png"), tr("Save &As..."), this, SLOT(saveFileAs()), QKeySequence::SaveAs); fileMenu->addSeparator(); fileMenu->addAction(QIcon(":/dialog-close.png"), tr("&Close"), _editor, SLOT(closeCurrentTab()), tr("Ctrl+W")); fileMenu->addAction(QIcon(":/dialog-close.png"), tr("Cl&ose All"), _editor, SLOT(closeAllTabs()), tr("Ctrl+Shift+W")); fileMenu->addSeparator(); fileMenu->addAction(QIcon(":/application-exit.png"), tr("&Quit"), this, SLOT(close()), QKeySequence::Quit); QMenu* projectMenu = menuBar()->addMenu(tr("&Project")); projectMenu->addAction(QIcon(":/project-development-new-template.png"), tr("&New Project"), this, SLOT(newProject())); projectMenu->addAction(QIcon(":/project-open.png"), tr("&Open Project..."), this, SLOT(openProjectDialog())); recent = projectMenu->addMenu(QIcon(":/document-open-recent.png"), tr("Open &Recent")); for (int i = 0; i < MaxRecentProjects; ++i) (_recentProjectActions[i] = recent->addAction(tr("<Empty>"), this, SLOT(openRecentProject())))->setVisible(true); (_recentProjectActions[MaxRecentProjects] = recent->addSeparator())->setVisible(true); (_recentProjectActions[MaxRecentProjects + 1] = recent->addAction(tr("&Clear List"), this, SLOT(clearProjectRecent())))->setEnabled(false); updateRecentProjects(); projectMenu->addSeparator(); projectMenu->addAction(QIcon(":/configure.png"), tr("Open &Configuration..."), this, SLOT(openProjectConfiguration())); projectMenu->addAction(QIcon(":/run-build.png"), tr("&Build Current"), this, SLOT(buildCurrentProject()), tr("F8")); projectMenu->addSeparator(); projectMenu->addAction(QIcon(":/project-development-close.png"), tr("&Close Project"), this, SLOT(closeProject())); menuBar()->addMenu("|")->setEnabled(false); QMenu* toolsMenu = menuBar()->addMenu(tr("&Tools")); toolsMenu->addAction(QIcon(":/preferences-other.png"), tr("&OpenGL Info..."), this, SLOT(showGLInfo())); QMenu* settingsMenu = menuBar()->addMenu(tr("&Settings")); settingsMenu->addAction(QIcon(":/preferences-other.png"), tr("&Preferences..."), this, SLOT(showPreferences())); QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(QIcon(":/glsd-icon.png"), tr("&About GLShaderDev"), this, SLOT(about())); helpMenu->addAction(QIcon(":/qt-icon.png"), tr("About &Qt"), qApp, SLOT(aboutQt())); }
void GLShaderDev::addRecentProject(const QString& filename) { QSettings settings; QStringList recentProjects = settings.value("recentProjects").toStringList(); recentProjects.removeAll(filename); recentProjects.prepend(filename); while (recentProjects.size() > MaxRecentProjects) recentProjects.removeLast(); settings.setValue("recentProjects", recentProjects); updateRecentProjects(); }
/* Open an existing project. Read the project file and load the appropriate files into the UI. */ void MainWindow::openProject(QString projectPath) { QDir projectDir(projectPath); QString projectName = projectDir.dirName(); if(!projectDir.exists()) return statusBar()->showMessage( QString("Couldn't find %1.").arg(projectName), 3500 ); QString pathname = projectName; // filename should not have spaces QFile projFile(projectDir.filePath(pathname + ".xml")); QDomDocument doc; if(doc.setContent(&projFile)) { currentProject = projectPath; currentFileDropDown->clear(); QDomNodeList allFiles = doc.elementsByTagName("files").at(0).childNodes(); for(int i = 0; i < allFiles.count(); i++) { QFileInfo fi(allFiles.at(i).toElement().text()); if(fi.fileName().isEmpty()) continue; // load the file name into the file dropdown if(projectDir.exists(fi.fileName())) { if(QDir::isAbsolutePath(fi.filePath())) currentFileDropDown->addItem(fi.fileName(), fi.filePath()); else currentFileDropDown->addItem(fi.fileName(), projectDir.filePath(fi.filePath())); // if this is the main project file, load it into the editor if(fi.baseName() == pathname) { editorLoadFile(projectDir.filePath(fi.filePath())); currentFileDropDown->setCurrentIndex(currentFileDropDown->findText(fi.fileName())); } } } setWindowTitle( projectName + "[*] - mcbuilder"); updateRecentProjects(projectPath); builder->onProjectUpdated(); projInfo->load(); buildLog->clear(); } else return statusBar()->showMessage( QString("Couldn't find main file for %1.").arg(projectName), 3500 ); }