void TupMainWindow::updateOpenRecentMenu(QMenu *menu, QStringList recents) { int i = 0; QAction *action[recents.length()]; menu->clear(); m_recentProjects.clear(); foreach (QString recent, recents) { // if (!recent.isEmpty() && m_recentProjects.indexOf(recent) == -1) { if (!recent.isEmpty()) { m_recentProjects << recent; action[i] = new QAction(QPixmap(THEME_DIR + "icons/recent_files.png"), recent, this); action[i]->setIconVisibleInMenu(true); menu->addAction(action[i]); connect(action[i], SIGNAL(triggered()), this, SLOT(openRecentProject())); i++; } else { m_recentProjectsMenu->setEnabled(false); return; } } if (i>0 && !m_recentProjectsMenu->isEnabled()) m_recentProjectsMenu->setEnabled(true); }
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())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); QSettings settings; libraryWidget_ = new LibraryWidget; setCentralWidget(libraryWidget_); { outputDock_ = new QDockWidget(tr("Output"), this); outputDock_->setObjectName("output"); outputWidget_ = new QTextEditEx(outputDock_); connect(outputWidget_, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(outputMouseDoubleClick(QMouseEvent*))); outputWidget_->setReadOnly(true); outputDock_->setWidget(outputWidget_); addDockWidget(Qt::BottomDockWidgetArea, outputDock_); } ui.actionStart_Player->setIcon(IconLibrary::instance().icon("gamepad")); connect(ui.actionStart_Player, SIGNAL(triggered()), this, SLOT(startPlayer())); ui.actionStart->setIcon(IconLibrary::instance().icon("start")); ui.actionStart->setEnabled(false); connect(ui.actionStart, SIGNAL(triggered()), this, SLOT(start())); ui.actionStop->setIcon(IconLibrary::instance().icon("stop")); ui.actionStop->setEnabled(false); connect(ui.actionStop, SIGNAL(triggered()), this, SLOT(stop())); connect(ui.actionNew_Project, SIGNAL(triggered()), this, SLOT(newProject())); connect(ui.actionClose_Project, SIGNAL(triggered()), this, SLOT(closeProject())); connect(ui.actionSave_Project, SIGNAL(triggered()), this, SLOT(saveProject())); connect(ui.actionOpen_Project, SIGNAL(triggered()), this, SLOT(openProject())); connect(ui.actionExport_Project, SIGNAL(triggered()), this, SLOT(exportProject())); connect(ui.actionProject1, SIGNAL(triggered()), this, SLOT(openRecentProject())); connect(ui.actionProject2, SIGNAL(triggered()), this, SLOT(openRecentProject())); connect(ui.actionProject3, SIGNAL(triggered()), this, SLOT(openRecentProject())); connect(ui.actionProject4, SIGNAL(triggered()), this, SLOT(openRecentProject())); connect(ui.actionProject5, SIGNAL(triggered()), this, SLOT(openRecentProject())); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.actionPlayer_Settings, SIGNAL(triggered()), this, SLOT(playerSettings())); connect(ui.actionFile_Associations, SIGNAL(triggered()), this, SLOT(fileAssociations())); connect(libraryWidget_, SIGNAL(openRequest(const QString&, const QString&)), this, SLOT(onOpenRequest(const QString&, const QString&))); QString playerip = settings.value("player ip", QString("127.0.0.1")).toString(); client_ = new GiderosNetworkClient(playerip, 15000); connect(client_, SIGNAL(connected()), this, SLOT(connected())); connect(client_, SIGNAL(disconnected()), this, SLOT(disconnected())); connect(client_, SIGNAL(dataReceived(const QByteArray&)), this, SLOT(dataReceived(const QByteArray&))); connect(client_, SIGNAL(ackReceived(unsigned int)), this, SLOT(ackReceived(unsigned int))); updateUI(); setWindowTitle(tr("Gideros")); updateRecentProjectActions(); QTimer* timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(onTimer())); timer->start(1); isTransferring_ = false; QList<QVariant> v = settings.value("fileAssociations", QList<QVariant>()).toList(); for (int i = 0; i < v.size(); ++i) fileAssociations_.push_back(v[i].toStringList()); localServer_.listen("GiderosProjectManager"); connect(&localServer_, SIGNAL(newConnection()), this, SLOT(onLocalServerNewConnection())); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("windowState").toByteArray()); }