From 34988cc2406893940becfdee2ec290dadd9967f0 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 10 Aug 2015 14:08:33 +0200 Subject: [PATCH] Templates and script for making new plugins. --- new.sh | 21 +++++++++++++++ templates/dockplugin.cpp | 41 +++++++++++++++++++++++++++++ templates/dockplugin.h | 56 ++++++++++++++++++++++++++++++++++++++++ templates/dockplugin.ui | 36 ++++++++++++++++++++++++++ templates/plugin.cpp | 37 ++++++++++++++++++++++++++ templates/plugin.h | 46 +++++++++++++++++++++++++++++++++ 6 files changed, 237 insertions(+) create mode 100755 new.sh create mode 100644 templates/dockplugin.cpp create mode 100644 templates/dockplugin.h create mode 100644 templates/dockplugin.ui create mode 100644 templates/plugin.cpp create mode 100644 templates/plugin.h diff --git a/new.sh b/new.sh new file mode 100755 index 000000000..37f9d431d --- /dev/null +++ b/new.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +type="$1" +path="$2" +name="$3" + +if ! [[ -n $type ]] || ! [[ -n $path ]] || ! [[ -n $name ]]; then + echo "Usage new.sh " + echo "e.g. new.sh plugin alethzero MyPlugin" + exit +fi + +cd templates +for i in $type.*; do + n="../$path/${i/$type/$name}" + cp "$i" "$n" + perl -i -p -e "s/\\\$NAME/$name/gc" "$n" +done + + + diff --git a/templates/dockplugin.cpp b/templates/dockplugin.cpp new file mode 100644 index 000000000..479896f54 --- /dev/null +++ b/templates/dockplugin.cpp @@ -0,0 +1,41 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#include "$NAME.h" +#include +#include +#include "ui_$NAME.h" +using namespace std; +using namespace dev; +using namespace az; +using namespace eth; + +$NAME::$NAME(MainFace* _m): + Plugin(_m, "$NAME"), + m_ui(new Ui::$NAME) +{ + dock(Qt::RightDockWidgetArea, "$NAME")->setWidget(new QWidget()); + m_ui->setupUi(dock()->widget()); +} + +$NAME::~$NAME() +{ +} diff --git a/templates/dockplugin.h b/templates/dockplugin.h new file mode 100644 index 000000000..e47181436 --- /dev/null +++ b/templates/dockplugin.h @@ -0,0 +1,56 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#pragma once + +#include +#include +#include "MainFace.h" + +namespace Ui +{ +class $NAME; +} + +namespace dev +{ +namespace az +{ + +class $NAME: public QObject, public Plugin +{ + Q_OBJECT + +public: + AllAccounts(MainFace* _m); + ~AllAccounts(); + +private: + void onAllChange() override {} + void readSettings(QSettings const&) override {} + void writeSettings(QSettings&) override {} + +private: + Ui::$NAME* m_ui; +}; + +} +} diff --git a/templates/dockplugin.ui b/templates/dockplugin.ui new file mode 100644 index 000000000..5da527cbd --- /dev/null +++ b/templates/dockplugin.ui @@ -0,0 +1,36 @@ + + + $NAME + + + + 0 + 0 + 405 + 300 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + diff --git a/templates/plugin.cpp b/templates/plugin.cpp new file mode 100644 index 000000000..7c072aa2e --- /dev/null +++ b/templates/plugin.cpp @@ -0,0 +1,37 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#include "$NAME.h" +#include +#include +using namespace std; +using namespace dev; +using namespace az; +using namespace eth; + +$NAME::$NAME(MainFace* _m): + Plugin(_m, "$NAME") +{ +} + +$NAME::~$NAME() +{ +} diff --git a/templates/plugin.h b/templates/plugin.h new file mode 100644 index 000000000..ee360417c --- /dev/null +++ b/templates/plugin.h @@ -0,0 +1,46 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file $NAME.h + * @author Gav Wood + * @date 2015 + */ + +#pragma once + +#include "MainFace.h" + +namespace dev +{ +namespace az +{ + +class $NAME: public QObject, public Plugin +{ + Q_OBJECT + +public: + $NAME(MainFace* _m); + ~$NAME(); + +private: + void onAllChange() override {} + void readSettings(QSettings const&) override {} + void writeSettings(QSettings&) override {} +}; + +} +}