forked from ic005k/OCAuxiliaryTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recentfiles.h
62 lines (47 loc) · 1.61 KB
/
recentfiles.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef RECENTFILES_H
#define RECENTFILES_H
#include <QMainWindow>
#include <QObject>
#include <QSettings>
#include <QStringList>
class QMenu;
class QAction;
#define recentFileCount "recentFiles/numOfRecentFiles"
#define recentFileListId "recentFiles/fileList"
/**
* @brief The RecentFiles class manages a list of recently accessed files.
*
* It handles user-settable number of most recently accessed files, provides
* a sub-menu that allows the user to select recently used files for opening.
*/
class RecentFiles : public QObject {
Q_OBJECT
public:
explicit RecentFiles(
QMainWindow* parent = NULL); /* Parent mainwindow, just for proper
heirarchy, not actually used outside QObject constr */
~RecentFiles();
void attachToMenuAfterItem(QMenu* menu, QString text, const char* slotName);
QStringList getRecentFiles() const;
void setMostRecentFile(const QString fileName);
QString strippedName(const QString& fullFileName);
void setMenuEnabled(bool tf);
int numberOfRecentFilesToSave();
static const int MaxRecentFiles = 21; ///< Max number of names we keep.
void clearHistory();
public slots:
/// The application can set the number of recent files retained/reported here
void setNumOfRecentFiles(int n);
signals:
void openFile(QString fileName);
void newMaxFilesShown(int);
private slots:
void openRecentFile();
private:
void purgeMissingFilesFromList(QStringList& recentFileList);
void updateRecentFiles(QSettings& settings);
QMenu* m_recentMenu;
QAction* m_recentMenuTriggeredAction;
QAction* m_recentFileActions[MaxRecentFiles];
};
#endif // RECENTFILES_H