Qt Utilities  6.4.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
recentmenumanager.h
Go to the documentation of this file.
1 #ifndef MISC_UTILS_RECENTMENUMANAGER_H
2 #define MISC_UTILS_RECENTMENUMANAGER_H
3 
4 #include "../global.h"
5 
6 #include <QObject>
7 
8 QT_FORWARD_DECLARE_CLASS(QMenu)
9 QT_FORWARD_DECLARE_CLASS(QAction)
10 
11 namespace QtUtilities {
12 
13 class QT_UTILITIES_EXPORT RecentMenuManager : public QObject {
14  Q_OBJECT
15 
16 public:
17  RecentMenuManager(QMenu *menu, QObject *parent = nullptr);
18 
19 public Q_SLOTS:
20  void restore(const QStringList &savedEntries);
21  QStringList save();
22  void addEntry(const QString &path);
23  void clearEntries();
24 
25 Q_SIGNALS:
26  void fileSelected(const QString &path);
27 
28 private Q_SLOTS:
29  void handleActionTriggered();
30 
31 private:
32  QMenu *m_menu;
33  QAction *m_sep;
34  QAction *m_clearAction;
35 };
36 } // namespace QtUtilities
37 
38 #endif // MISC_UTILS_RECENTMENUMANAGER_H
The RecentMenuManager class manages the entries for a "recently opened files" menu.
void fileSelected(const QString &path)
Emitted after the user selected a file.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.