1 /* 2 Actiona 3 Copyright (C) 2005 Jonathan Mercier-Ganady 4 5 Actiona is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 Actiona is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 Contact : jmgr@jmgr.info 19 */ 20 21 #pragma once 22 23 #include "actiondefinition.h" 24 #include "consoleinstance.h" 25 #include "textparameterdefinition.h" 26 #include "listparameterdefinition.h" 27 28 namespace ActionTools 29 { 30 class ActionPack; 31 class ActionInstance; 32 } 33 34 namespace Actions 35 { 36 class ConsoleDefinition : public ActionTools::ActionDefinition 37 { 38 Q_OBJECT 39 40 public: ConsoleDefinition(ActionTools::ActionPack * pack)41 explicit ConsoleDefinition(ActionTools::ActionPack *pack) 42 : ActionDefinition(pack) 43 { 44 translateItems("ConsoleInstance::outputs", ConsoleInstance::outputs); 45 46 auto &text = addParameter<ActionTools::TextParameterDefinition>({QStringLiteral("text"), tr("Text")}); 47 text.setTooltip(tr("The text to write")); 48 49 auto &output = addParameter<ActionTools::ListParameterDefinition>({QStringLiteral("output"), tr("Output")}); 50 output.setTooltip(tr("The console output")); 51 output.setItems(ConsoleInstance::outputs); 52 output.setDefaultValue(ConsoleInstance::outputs.second.at(ConsoleInstance::Information)); 53 } 54 name()55 QString name() const override { return QObject::tr("Console"); } id()56 QString id() const override { return QStringLiteral("ActionConsole"); } flags()57 ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } description()58 QString description() const override { return QObject::tr("Write an entry in the console"); } newActionInstance()59 ActionTools::ActionInstance *newActionInstance() const override { return new ConsoleInstance(this); } category()60 ActionTools::ActionCategory category() const override { return ActionTools::Internal; } icon()61 QPixmap icon() const override { return QPixmap(QStringLiteral(":/actions/icons/console.png")); } 62 63 private: 64 Q_DISABLE_COPY(ConsoleDefinition) 65 }; 66 } 67 68