15 const int VuoRecentFileMenu::maxRecentFileCount = 10;
23 setTitle(QApplication::translate(
"VuoEditorWindow",
"Open Recent"));
24 updateRecentFileActions();
32 recentFiles.removeAll(filePath);
33 recentFiles.prepend(filePath);
35 while (recentFiles.size() > maxRecentFileCount)
36 recentFiles.removeLast();
38 updateRecentFileActions();
47 QStringList currentlyExistingRecentFiles = QStringList(recentFiles);
48 bool foundMissingFile =
false;
52 foreach (QString recentFile, currentlyExistingRecentFiles)
56 bool currentFileMissing =
false;
62 if (!isExampleComposition)
64 fileName = QFileInfo(recentFile).fileName();
67 currentFileMissing =
true;
68 foundMissingFile =
true;
72 if (!currentFileMissing)
73 recentFiles.append(recentFile);
77 updateRecentFileActions();
84 void VuoRecentFileMenu::updateRecentFileActions()
87 int currentNumRecentFiles = recentFiles.size();
88 setEnabled(currentNumRecentFiles > 0);
91 for (
int i = 0; i < currentNumRecentFiles; ++i)
93 QAction *recentFileAction =
new QAction(
this);
94 QString fileName, fileURL;
96 QUrl url(recentFiles[i]);
102 fileURL = QFileInfo(recentFiles[i]).filePath();
108 fileName = QFileInfo(recentFiles[i]).fileName();
109 fileURL = QString(
"file://").append(QFileInfo(recentFiles[i]).filePath());
112 recentFileAction->setText(fileName);
113 recentFileAction->setData(fileURL);
114 recentFileAction->setIcon(QIcon(
":/Icons/vuo-composition.png"));
116 recentFileAction->setShortcut(QKeySequence(
"Ctrl+Shift+O"));
117 connect(recentFileAction, &QAction::triggered,
this, &VuoRecentFileMenu::recentFileActionTriggered);
118 addAction(recentFileAction);
122 if (currentNumRecentFiles > 0)
125 QAction *clearRecentFileListAction =
new QAction(
this);
126 clearRecentFileListAction->setText(QApplication::translate(
"VuoEditorWindow",
"Clear Menu"));
128 addAction(clearRecentFileListAction);
135 void VuoRecentFileMenu::recentFileActionTriggered()
137 QAction *sender = (QAction *)QObject::sender();
146 if (recentFiles.size())
148 QUrl url(recentFiles[0]);
149 QString formattedURL;
153 formattedURL = QFileInfo(recentFiles[0]).filePath();
157 formattedURL = QString(
"file://").append(QFileInfo(recentFiles[0]).filePath());
169 updateRecentFileActions();
186 this->recentFiles = recentFiles;
187 updateRecentFileActions();