void MainWindow::setCurrentFile(const QString& filename) { setWindowModified(false); if(filename.isEmpty()) { setWindowFilePath("untitled.chr"); } else { setWindowFilePath(filename); QSettings settings; QStringList recentFiles(settings.value("recentFiles").toStringList()); recentFiles.removeAll(filename); recentFiles.prepend(filename); while(recentFiles.size() > MaxRecentCount) { recentFiles.removeLast(); } settings.setValue("recentFiles", recentFiles); updateRecentFiles(); } currentFile = filename; }
void MainWindow::createActions() { // file menu actions openModelAct = new QAction(QIcon("../images/open.png"), tr("&Open Model"), this); openModelAct->setShortcut(QKeySequence::New); openModelAct->setStatusTip(tr("open a mesh model")); connect(openModelAct, SIGNAL(triggered()), this, SLOT(openModel())); openTextureFileAct = new QAction(QIcon("../images/open.png"), tr("&Open Texture Image"), this); connect(openTextureFileAct, SIGNAL(triggered()), this, SLOT(openTextureImage())); openQuadFileAct = new QAction(QIcon("../images/open.png"), tr("&Open Quad File"), this); connect(openQuadFileAct, SIGNAL(triggered()), this, SLOT(openQuadFile())); saveModelAct = new QAction(QIcon("../images/save.png"), tr("&Save Model"), this); saveModelAct->setShortcut(QKeySequence::Save); saveModelAct->setStatusTip(tr("save this mesh model")); connect(saveModelAct, SIGNAL(triggered()), this, SLOT(saveModel())); saveAsBmpAct = new QAction(tr("Save as BMP"), this); connect(saveAsBmpAct, SIGNAL(triggered()), this, SLOT(saveAsBmp())); recentFileAct = new QAction(tr("Recent Files"), this); connect(recentFileAct, SIGNAL(triggered()), this, SLOT(recentFiles())); exitAct = new QAction(tr("E&xit"), this); exitAct->setShortcuts(QKeySequence::Quit); exitAct->setStatusTip(tr("Exit the application")); connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); // toolbar menu actions toolBarAct = new QAction(tr("ToolBar"), this); connect(toolBarAct, SIGNAL(triggered()), this, SLOT(toobBar())); stateBarAct = new QAction(tr("StateBar"), this); connect(stateBarAct, SIGNAL(triggered()), this, SLOT(stateBar())); // quad menu actions // help menu actions aboutAct = new QAction(tr("About"), this); connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); // mouse actions mouseSpinAct = new QAction(QIcon("../images/rotate-left.png"), tr("Spin"), this); connect(mouseSpinAct, SIGNAL(triggered()), this, SLOT(mouseSpin())); mouseMoveAct = new QAction(QIcon("../images/move.png"), tr("Move"), this); connect(mouseMoveAct, SIGNAL(triggered()), this, SLOT(mouseMove())); mouseZoomAct = new QAction(QIcon("../images/zoom.png"), tr("Zoom"), this); connect(mouseZoomAct, SIGNAL(triggered()), this, SLOT(mouseZoom())); }