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 "openurlinstance.h" 25 #include "textparameterdefinition.h" 26 27 namespace ActionTools 28 { 29 class ActionPack; 30 class ActionInstance; 31 } 32 33 namespace Actions 34 { 35 class OpenURLDefinition : public ActionTools::ActionDefinition 36 { 37 Q_OBJECT 38 39 public: OpenURLDefinition(ActionTools::ActionPack * pack)40 explicit OpenURLDefinition(ActionTools::ActionPack *pack) 41 : ActionDefinition(pack) 42 { 43 auto &url = addParameter<ActionTools::TextParameterDefinition>({QStringLiteral("url"), tr("URL")}); 44 url.setTooltip(tr("The url to open")); 45 46 addException(OpenURLInstance::FailedToOpenURL, tr("Failed to open URL")); 47 } 48 name()49 QString name() const override { return QObject::tr("Open URL"); } id()50 QString id() const override { return QStringLiteral("ActionOpenURL"); } flags()51 ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } description()52 QString description() const override { return QObject::tr("Opens an URL"); } newActionInstance()53 ActionTools::ActionInstance *newActionInstance() const override { return new OpenURLInstance(this); } category()54 ActionTools::ActionCategory category() const override { return ActionTools::System; } icon()55 QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/openurl.png")); } 56 57 private: 58 Q_DISABLE_COPY(OpenURLDefinition) 59 }; 60 } 61 62