24 : QObject(parent), _settingsName(std::move(settingsName))
29 fileAction =
new QAction(
this);
30 fileAction->setVisible(
false);
31 connect(fileAction, SIGNAL(triggered()), parent, slot);
51 QStringList files = settings.value(
_settingsName).toStringList();
52 files.removeAll(filename);
53 files.prepend(filename);
59 settings.setValue(
"recentFileList", files);
66 QStringList files = settings.value(
_settingsName).toStringList();
68 int numFiles = qMin(files.size(),
static_cast<int>(
_maxFiles));
70 for (
int i = 0; i < numFiles; ++i)
72 QString text = tr(
"&%1 %2").arg(i + 1).arg(
strippedName(files[i]));
78 for (
int i = numFiles; i <
_maxFiles; ++i)
86 return QFileInfo(fullFileName).fileName();
Definition of the RecentFiles class.
QAction * _fileActions[_maxFiles]
QString strippedName(const QString &fullFileName)
Returns the filename from a full file path.
void setCurrentFile(const QString &filename)
Should be called from the application when a file was used.
void updateRecentFileActions()
Updates the recent files list and writes it to the settings.
QMenu * menu()
Returns the created menu. Add this menu to your QMainWindow menu.
RecentFiles(QObject *parent, const char *slot, QString settingsName)