diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-21 08:43:39 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-31 04:30:35 +0000 |
commit | ad4d25589fcd5efd4faa3074c19928d195f615bb (patch) | |
tree | 30bf2531bc9518e1e270fb7824b7064c34920ac4 /examples/widgets/mainwindows/mdi/mainwindow.h | |
parent | 57dbdcd92fdee7ae5eaafcba880739b58404ec4e (diff) |
Add recent file handling to SDI/MDI and remove the recentfiles example.
The existing recentfiles example was basically a clone of the SDI
example with a "Recent" menu added. Assuming it is better to have
it all in one place, the functionality is merged into the existing
SDI/MDI examples.
- Implement recently opened files handling using a submenu and a
QSettings array in the SDI/MDI examples.
- Remove recentfiles example.
Change-Id: Id5a1ab9fa1c2e6b9ec81309cfe74cf86f450392a
Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com>
Diffstat (limited to 'examples/widgets/mainwindows/mdi/mainwindow.h')
-rw-r--r-- | examples/widgets/mainwindows/mdi/mainwindow.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/widgets/mainwindows/mdi/mainwindow.h b/examples/widgets/mainwindows/mdi/mainwindow.h index bdc2a6a09d..3ac60282fd 100644 --- a/examples/widgets/mainwindows/mdi/mainwindow.h +++ b/examples/widgets/mainwindows/mdi/mainwindow.h @@ -68,6 +68,8 @@ private slots: void open(); void save(); void saveAs(); + void updateRecentFileActions(); + void openRecentFile(); #ifndef QT_NO_CLIPBOARD void cut(); void copy(); @@ -80,10 +82,16 @@ private slots: void switchLayoutDirection(); private: + enum { MaxRecentFiles = 5 }; + void createActions(); void createStatusBar(); void readSettings(); void writeSettings(); + bool loadFile(const QString &fileName); + static bool hasRecentFiles(); + void prependToRecentFiles(const QString &fileName); + void setRecentFilesVisible(bool visible); MdiChild *activeMdiChild() const; QMdiSubWindow *findMdiChild(const QString &fileName) const; @@ -93,6 +101,9 @@ private: QAction *newAct; QAction *saveAct; QAction *saveAsAct; + QAction *recentFileActs[MaxRecentFiles]; + QAction *recentFileSeparator; + QAction *recentFileSubMenuAct; #ifndef QT_NO_CLIPBOARD QAction *cutAct; QAction *copyAct; |