blob: 7988a0eb45c1563d49dabd2605434850f93051d6 (
plain)
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
|
#ifndef RECENT_FILES_MANAGER_H
#define RECENT_FILES_MANAGER_H
#include <QtCore>
#include <QtWidgets>
class RecentFilesManager: public QObject
{
Q_OBJECT
public:
RecentFilesManager(QObject* parent, QMenu* recentFilesMenu);
void createRecentFileActs(const QStringList& recentFiles);
void addFile( const QString& filePath);
QString getLastUsedFilePath() const;
QStringList getFiles() const;
private:
static QString getShortFileName(const QString& filePath)
{ return QFileInfo(filePath).fileName(); }
static QString getActionFile(QAction* action);
private:
QAction* createRecentFileAction(const QString& filePath);
void updateActionTexts();
QString getShortDirPath(const QString& filePath) const;
void addRecentFileAction(const QString& filePath);
private slots:
void triggerRecentFile();
signals:
void recentFileTriggered(const QString& filePath);
void addedFile();
private:
static const int MaxRecentFiles = 10;
static const int MaxPathLength = 300;
private:
QMenu* recentFilesMenu;
};
#endif
|