File indexing completed on 2024-05-12 04:55:02
0001 /** 0002 * \file recentfilesmenu.h 0003 * Menu to open recent files. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 15-Aug-2010 0008 * 0009 * Copyright (C) 2010-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QStringList> 0030 #include <QMenu> 0031 0032 class ISettings; 0033 0034 /** 0035 * Menu to open recent files. 0036 */ 0037 class RecentFilesMenu : public QMenu { 0038 Q_OBJECT 0039 public: 0040 /** 0041 * Constructor. 0042 * 0043 * @param parent parent widget 0044 */ 0045 explicit RecentFilesMenu(QWidget* parent); 0046 0047 /** 0048 * Destructor. 0049 */ 0050 ~RecentFilesMenu() override = default; 0051 0052 /** 0053 * Add directory to list of recent files. 0054 * 0055 * @param dir path to directory 0056 */ 0057 void addDirectory(const QString& dir); 0058 0059 /** 0060 * Saves the current recent files entries to a given configuration. 0061 * 0062 * @param config configuration settings 0063 */ 0064 void saveEntries(ISettings* config); 0065 0066 /** 0067 * Loads the recent files entries from a given configuration. 0068 * 0069 * @param config configuration settings 0070 */ 0071 void loadEntries(ISettings* config); 0072 0073 signals: 0074 /** 0075 * Emitted when a recent file has to be loaded. 0076 * Parameter: path to file or directory 0077 */ 0078 void loadFile(const QString&); 0079 0080 private slots: 0081 /** 0082 * Emit a load file signal when a recent file has to be loaded. 0083 */ 0084 void openRecentFile(); 0085 0086 /** 0087 * Clear the list of recent files. 0088 */ 0089 void clearList(); 0090 0091 private: 0092 /** 0093 * Update the recent file actions. 0094 */ 0095 void updateRecentFileActions(); 0096 0097 QStringList m_files; 0098 };