Browse Source

Templates and script for making new plugins.

cl-refactor
Gav Wood 10 years ago
parent
commit
34988cc240
  1. 21
      new.sh
  2. 41
      templates/dockplugin.cpp
  3. 56
      templates/dockplugin.h
  4. 36
      templates/dockplugin.ui
  5. 37
      templates/plugin.cpp
  6. 46
      templates/plugin.h

21
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 <type> <path> <name>"
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

41
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 <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#include "$NAME.h"
#include <libdevcore/Log.h>
#include <libethereum/Client.h>
#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()
{
}

56
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 <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#pragma once
#include <QListWidget>
#include <QPlainTextEdit>
#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;
};
}
}

36
templates/dockplugin.ui

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>$NAME</class>
<widget class="QWidget" name="NAME">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>405</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
<resources/>
<connections/>
</ui>

37
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 <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @date 2015
*/
#include "$NAME.h"
#include <libdevcore/Log.h>
#include <libethereum/Client.h>
using namespace std;
using namespace dev;
using namespace az;
using namespace eth;
$NAME::$NAME(MainFace* _m):
Plugin(_m, "$NAME")
{
}
$NAME::~$NAME()
{
}

46
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 <http://www.gnu.org/licenses/>.
*/
/** @file $NAME.h
* @author Gav Wood <i@gavwood.com>
* @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 {}
};
}
}
Loading…
Cancel
Save