Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
recentfilemenu.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2017 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 
19 #ifndef RECENTFILEMENU_H
20 #define RECENTFILEMENU_H
21 
22 #include <map>
23 #include <QMenu>
24 #include <QStringList>
25 #include "pencildef.h"
26 
27 class QAction;
28 class ListItemModel;
29 
30 class RecentFileMenu : public QMenu
31 {
32  Q_OBJECT
33 
34  Q_PROPERTY ( QStringList recentFiles
35  READ getRecentFiles
36  WRITE setRecentFiles )
37 public:
38  explicit RecentFileMenu(QString title = tr("Open Recent"), QWidget *parent = 0);
39  ~RecentFileMenu();
40 
41  static const int MAX_RECENT_FILES = 10;
42 
43  QStringList getRecentFiles() { return mRecentFiles; }
44  void setRecentFiles(QStringList filenames);
45 
46  void addRecentFile(QString filename);
47  void removeRecentFile(QString filename);
48 
49  bool loadFromDisk();
50  bool saveToDisk();
51 
52 signals:
53  void loadRecentFile(QString filename);
54 
55 public slots:
56  void clear();
57 
58 protected slots:
59  void onRecentFileTriggered();
60 
61 private:
62  QStringList mRecentFiles;
63  std::map<QString, QAction*> mRecentActions;
64  QAction* mClearAction = nullptr;
65  QAction* mClearSeparator = nullptr;
66 };
67 
68 #endif // RECENTFILEMENU_H