1 /* 2 * commandmanager.h 3 * Copyright 2017, Ketan Gupta <ketan19972010@gmail.com> 4 * Copyright 2018-2020, Thorbjørn Lindeijer <bjorn@lindeijer.nl> 5 * 6 * This file is part of Tiled. 7 * 8 * This program is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License as published by the Free 10 * Software Foundation; either version 2 of the License, or (at your option) 11 * any later version. 12 * 13 * This program is distributed in the hope that it will be useful, but WITHOUT 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 16 * more details. 17 * 18 * You should have received a copy of the GNU General Public License along with 19 * this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #pragma once 23 24 #include "command.h" 25 26 #include <QObject> 27 #include <QVector> 28 29 class QAction; 30 class QMenu; 31 32 namespace Tiled { 33 34 class CommandDataModel; 35 36 class CommandManager : public QObject 37 { 38 Q_OBJECT 39 40 CommandManager(); 41 ~CommandManager() override; 42 43 public: 44 static CommandManager *instance(); 45 46 bool executeDefaultCommand() const; 47 48 const QVector<Command> &globalCommands() const; 49 const QVector<Command> &projectCommands() const; 50 QVector<Command> allCommands() const; 51 52 void registerMenu(QMenu *menu); 53 54 void retranslateUi(); 55 56 public slots: 57 void showDialog(); 58 59 private: 60 Q_DISABLE_COPY(CommandManager) 61 62 void commit(); 63 64 void updateActions(); 65 66 CommandDataModel *mModel; 67 QVector<Command> mCommands; 68 QList<QMenu*> mMenus; 69 QList<QAction*> mActions; 70 QAction *mEditCommandsAction = nullptr; 71 }; 72 73 allCommands()74inline QVector<Command> CommandManager::allCommands() const 75 { 76 return globalCommands() + projectCommands(); 77 } 78 79 } // namespace Tiled 80