ccRecentFiles.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef CCRECENTFILES_H
  2. #define CCRECENTFILES_H
  3. //##########################################################################
  4. //# #
  5. //# CLOUDCOMPARE #
  6. //# #
  7. //# This program is free software; you can redistribute it and/or modify #
  8. //# it under the terms of the GNU General Public License as published by #
  9. //# the Free Software Foundation; version 2 or later 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. //# COPYRIGHT: CloudCompare project #
  17. //# #
  18. //##########################################################################
  19. #include <QObject>
  20. #include <QSettings>
  21. class QAction;
  22. class QMenu;
  23. class QString;
  24. class QStringList;
  25. class ccRecentFiles : public QObject
  26. {
  27. Q_OBJECT
  28. public:
  29. ccRecentFiles( QWidget *parent );
  30. //! Returns a "most recently used file" menu
  31. QMenu *menu();
  32. //! Adds a file path to the recently used menu
  33. void addFilePath( const QString &filePath );
  34. private:
  35. //! Updates the contents of the menu
  36. void updateMenu();
  37. //! Opens a file based on the action that was triggered
  38. void openFileFromAction();
  39. //! Returns a list of file paths from the QSettings
  40. //! This will also remove any file from the list that does not exist
  41. QStringList listRecent();
  42. //! Contracts the path by substituting '~' for the user's home directory
  43. QString contractFilePath( const QString &filePath );
  44. //! Expands the path by substituting the user's home directory for '~'
  45. QString expandFilePath( const QString &filePath );
  46. //! The key in the QSettings where we store the file list
  47. static QString s_settingKey;
  48. QSettings m_settings;
  49. QMenu* m_menu;
  50. QAction* m_actionClearMenu;
  51. };
  52. #endif