OGS
RecentFiles.h
Go to the documentation of this file.
1
14#pragma once
15
16// ** INCLUDES **
17#include <QAction>
18#include <QMenu>
19#include <QObject>
20
21class QString;
22
38class RecentFiles : public QObject
39{
40 Q_OBJECT
41
42public:
51 RecentFiles(QObject* parent, const char* slot, QString settingsName);
52 ~RecentFiles() override;
53
55 QMenu* menu();
56
57public slots:
59 void setCurrentFile(const QString& filename);
60
61private:
64
66 QString strippedName(const QString& fullFileName);
67
68 QMenu* _filesMenu;
69 QString _currentFile;
71 enum { _maxFiles = 5 };
73};
QAction * _fileActions[_maxFiles]
Definition: RecentFiles.h:72
QString strippedName(const QString &fullFileName)
Returns the filename from a full file path.
Definition: RecentFiles.cpp:84
void setCurrentFile(const QString &filename)
Should be called from the application when a file was used.
Definition: RecentFiles.cpp:46
~RecentFiles() override
Definition: RecentFiles.cpp:37
void updateRecentFileActions()
Updates the recent files list and writes it to the settings.
Definition: RecentFiles.cpp:63
QMenu * menu()
Returns the created menu. Add this menu to your QMainWindow menu.
Definition: RecentFiles.cpp:42
QString _currentFile
Definition: RecentFiles.h:69
QString _settingsName
Definition: RecentFiles.h:70
QMenu * _filesMenu
Definition: RecentFiles.h:68