├── services
├── simpleserialiser.cpp
├── sync.h
├── imageresource.cpp
├── simpleserialiser.h
├── p3paintchatservice.cpp
├── paintchatitems.h
├── p3paintchatservice.h
├── imageresource.h
├── paintchatitems.cpp
└── sync.cpp
├── paintchat-1.png
├── gui
├── images
│ └── colors.png
├── paintchatwindow.cpp
├── images.qrc
├── paintchatpopupchatdialog.h
├── paintwidget.h
├── paintchatwindow.h
├── paintwidget.cpp
├── paintchatpopupchatdialog.cpp
└── paintchatwindow.ui
├── interface
└── paintchatservice.h
├── README.md
├── PaintChat.pro
├── paintchatplugin.h
└── paintchatplugin.cpp
/services/simpleserialiser.cpp:
--------------------------------------------------------------------------------
1 | #include "simpleserialiser.h"
2 |
3 |
--------------------------------------------------------------------------------
/paintchat-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/Retroshare-Paintchat-Plugin/master/paintchat-1.png
--------------------------------------------------------------------------------
/services/sync.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/Retroshare-Paintchat-Plugin/master/services/sync.h
--------------------------------------------------------------------------------
/gui/images/colors.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/Retroshare-Paintchat-Plugin/master/gui/images/colors.png
--------------------------------------------------------------------------------
/gui/paintchatwindow.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/Retroshare-Paintchat-Plugin/master/gui/paintchatwindow.cpp
--------------------------------------------------------------------------------
/services/imageresource.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/Retroshare-Paintchat-Plugin/master/services/imageresource.cpp
--------------------------------------------------------------------------------
/services/simpleserialiser.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/Retroshare-Paintchat-Plugin/master/services/simpleserialiser.h
--------------------------------------------------------------------------------
/gui/images.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/colors.png
4 |
5 |
6 |
--------------------------------------------------------------------------------
/services/p3paintchatservice.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chozabu/Retroshare-Paintchat-Plugin/master/services/p3paintchatservice.cpp
--------------------------------------------------------------------------------
/gui/paintchatpopupchatdialog.h:
--------------------------------------------------------------------------------
1 | #ifndef PAINTCHATPOPUPCHATDIALOG_H
2 | #define PAINTCHATPOPUPCHATDIALOG_H
3 |
4 | #include
5 | #include "paintchatwindow.h"
6 |
7 | class PaintChatPopupChatDialog : public PopupChatDialog
8 | {
9 | Q_OBJECT
10 | public:
11 | PaintChatPopupChatDialog(QWidget *parent = NULL);
12 |
13 | private slots:
14 | void togglePaintChatWindow();
15 |
16 | protected:
17 | virtual void init(const std::string &peerId, const QString &title);
18 |
19 | private:
20 | QPushButton *paintChatWindowToggleButton;
21 | PaintChatWindow *paintChatWindow;
22 | };
23 |
24 | #endif // PAINTCHATPOPUPCHATDIALOG_H
25 |
--------------------------------------------------------------------------------
/interface/paintchatservice.h:
--------------------------------------------------------------------------------
1 | #ifndef PAINTCHATSERVICE_H
2 | #define PAINTCHATSERVICE_H
3 |
4 | #include "services/sync.h"
5 | #include "services/imageresource.h"
6 |
7 | class PaintChatService;
8 | extern PaintChatService *paintChatService;
9 |
10 | class PaintChatService{
11 | public:
12 | virtual void init(std::string id, ImageResource res)=0;
13 | // tell remote end to init
14 | virtual void sendInit(std::string id, ImageResource res)=0;
15 | virtual bool haveUpdate(std::string id)=0;
16 | virtual bool receivedInit(std::string id)=0;
17 | virtual ImageResource update(std::string id, ImageResource res)=0;
18 | };
19 |
20 | #endif // PAINTCHATSERVICE_H
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Retroshare-Paintchat-Plugin #
2 |
3 | Draw a quick sketch to explain things.
4 |
5 | 
6 |
7 | ## How to compile ##
8 |
9 | 1. Prepare Retroshare build environment [http://retroshare.sourceforge.net/wiki/index.php/Developers_Corner](http://retroshare.sourceforge.net/wiki/index.php/Developers_Corner)
10 | 2. clone this Repository into **retroshare/plugins**
11 | 3. add **Retroshare-Paintchat-Plugin** to **retroshare/plugins/plugins.pro**
12 |
13 | ## What is Retroshare? ##
14 |
15 | [Retroshare](http://retroshare.sourceforge.net) is a secure friend-2-friend social network.
--------------------------------------------------------------------------------
/gui/paintwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef PAINTWIDGET_H
2 | #define PAINTWIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | class PaintWidget : public QWidget
10 | {
11 | Q_OBJECT
12 | public:
13 | explicit PaintWidget(QWidget *parent = 0);
14 | void setImage(const QImage&);
15 | QImage getImage();
16 |
17 | void fillImage(QColor color);
18 |
19 | QColor color;
20 | uint8_t penWidth;
21 |
22 | signals:
23 | void haveUpdate();
24 |
25 | public slots:
26 |
27 | protected:
28 | virtual void mouseMoveEvent(QMouseEvent *);
29 | virtual void mouseReleaseEvent(QMouseEvent * event);
30 | virtual void paintEvent(QPaintEvent *);
31 |
32 | private:
33 | QImage image;
34 |
35 | };
36 |
37 | #endif // PAINTWIDGET_H
38 |
--------------------------------------------------------------------------------
/PaintChat.pro:
--------------------------------------------------------------------------------
1 | !include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri")
2 |
3 | CONFIG += qt uic qrc
4 |
5 | INCLUDEPATH += ../../retroshare-gui/src/temp/ui
6 |
7 | SOURCES = \
8 | paintchatplugin.cpp \
9 | gui/paintchatwindow.cpp \
10 | gui/paintchatpopupchatdialog.cpp \
11 | services/paintchatitems.cpp \
12 | services/p3paintchatservice.cpp \
13 | gui/paintwidget.cpp \
14 | services/imageresource.cpp
15 | HEADERS = \
16 | paintchatplugin.h \
17 | gui/paintchatwindow.h \
18 | gui/paintchatpopupchatdialog.h \
19 | services/paintchatitems.h \
20 | services/sync.h \
21 | services/p3paintchatservice.h \
22 | interface/paintchatservice.h \
23 | gui/paintwidget.h \
24 | services/imageresource.h
25 | FORMS = \
26 | gui/paintchatwindow.ui
27 |
28 | TARGET = PaintChat
29 |
30 | RESOURCES += \
31 | gui/images.qrc
32 |
--------------------------------------------------------------------------------
/gui/paintchatwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef PAINTCHATWINDOW_H
2 | #define PAINTCHATWINDOW_H
3 |
4 | #include
5 | #include
6 |
7 | namespace Ui {
8 | class PaintChatWindow;
9 | }
10 |
11 | class PaintChatWindow : public QMainWindow
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | explicit PaintChatWindow(QWidget *parent = 0);
17 | ~PaintChatWindow();
18 |
19 | void setPeerId(std::string peerId);
20 |
21 | private slots:
22 | void on_haveUpdate();
23 | void on_timer();
24 |
25 | void on_pushButtonBlack_clicked();
26 |
27 | void on_pushButtonWhite_clicked();
28 |
29 | void on_pushButton1px_clicked();
30 |
31 | void on_pushButton4px_clicked();
32 |
33 | void on_pushButton8px_clicked();
34 |
35 | void on_pushButtonClear_clicked();
36 |
37 | void on_pushButtonCopy_clicked();
38 |
39 | private:
40 | void updateImage();
41 | void resetPenButtons();
42 | Ui::PaintChatWindow *ui;
43 | std::string peerId;
44 |
45 | QTimer *timer;
46 | };
47 |
48 | #endif // PAINTCHATWINDOW_H
49 |
--------------------------------------------------------------------------------
/paintchatplugin.h:
--------------------------------------------------------------------------------
1 | #ifndef PAINTCHATPLUGIN_H
2 | #define PAINTCHATPLUGIN_H
3 |
4 | #include
5 | #include "services/paintchatitems.h"
6 | #include "services/p3paintchatservice.h"
7 |
8 | class PaintChatPlugin : public RsPlugin
9 | {
10 | public:
11 | PaintChatPlugin();
12 | virtual ~PaintChatPlugin();
13 |
14 | virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const ;
15 | virtual void setPlugInHandler(RsPluginHandler *pgHandler);
16 |
17 |
18 | virtual std::string getShortPluginDescription() const ;
19 | virtual std::string getPluginName() const;
20 | virtual void setInterfaces(RsPlugInInterfaces& interfaces);
21 |
22 | virtual RsPQIService *rs_pqi_service() const ;
23 | virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_PAINTCHAT_PLUGIN ; }
24 |
25 | virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const ;
26 |
27 | private:
28 | RsPluginHandler *mPlugInHandler;
29 | // keine ahnung warum mutable
30 | mutable p3PaintChatService *mService;
31 | };
32 |
33 | #endif // PAINTCHATPLUGIN_H
34 |
--------------------------------------------------------------------------------
/gui/paintwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "paintwidget.h"
2 |
3 | #include
4 | #include
5 |
6 | PaintWidget::PaintWidget(QWidget *parent) :
7 | QWidget(parent),image(500,500,QImage::Format_RGB32),color(Qt::black),penWidth(1)
8 | {
9 | image.fill(Qt::white);
10 | }
11 |
12 | void PaintWidget::setImage(const QImage &img){
13 | image=img.copy();
14 | update();
15 | }
16 |
17 | QImage PaintWidget::getImage(){
18 | return image;
19 | }
20 |
21 | void PaintWidget::fillImage(QColor color){
22 | image.fill(color);
23 | update();
24 | }
25 |
26 | void PaintWidget::mouseMoveEvent(QMouseEvent *event)
27 | {
28 | QPainter p(&image);
29 | p.setPen(color);
30 | p.setBrush(color);
31 | if(penWidth==1){
32 | p.drawPoint(event->pos());
33 | }else{
34 | p.drawEllipse(event->pos(),penWidth/2,penWidth/2);
35 | }
36 | // trigger repaint of widget
37 | update();
38 | }
39 |
40 | void PaintWidget::mouseReleaseEvent(QMouseEvent *event){
41 | std::cout<<"PaintWidgte::mouseReleseEvent()"<hide();
9 |
10 | paintChatWindowToggleButton = new QPushButton ;
11 | paintChatWindowToggleButton->setMinimumSize(QSize(28,28)) ;
12 | paintChatWindowToggleButton->setMaximumSize(QSize(28,28)) ;
13 | paintChatWindowToggleButton->setText(QString()) ;
14 | paintChatWindowToggleButton->setToolTip(tr("PaintChat"));
15 |
16 | QIcon icon ;
17 | icon.addPixmap(QPixmap(":/images/colors.png"));
18 | paintChatWindowToggleButton->setIcon(icon);
19 |
20 | connect(paintChatWindowToggleButton,SIGNAL(clicked()),this,SLOT(togglePaintChatWindow()));
21 |
22 | addChatBarWidget(paintChatWindowToggleButton);
23 | }
24 |
25 | void PaintChatPopupChatDialog::togglePaintChatWindow(){
26 | if(paintChatWindow->isHidden()){
27 | paintChatWindow->show();
28 | }else{
29 | paintChatWindow->hide();
30 | }
31 | }
32 |
33 | void PaintChatPopupChatDialog::init(const std::string &peerId, const QString &title){
34 | PopupChatDialog::init(peerId,title);
35 | paintChatWindow->setPeerId(getPeerId());
36 | }
37 |
--------------------------------------------------------------------------------
/services/paintchatitems.h:
--------------------------------------------------------------------------------
1 | #ifndef PAINTCHATITEMS_H
2 | #define PAINTCHATITEMS_H
3 |
4 | #include "serialiser/rsserviceids.h"
5 | #include "serialiser/rsserial.h"
6 | #include "serialiser/rstlvtypes.h"
7 |
8 | // --------TODO------------
9 | const uint16_t RS_SERVICE_TYPE_PAINTCHAT_PLUGIN=RS_SERVICE_TYPE_PLUGIN_ARADO_TEST_ID1;
10 |
11 |
12 | class RsPaintChatItem: public RsItem{
13 | public:
14 | RsPaintChatItem():RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PAINTCHAT_PLUGIN, 0),binData(0){
15 | setPriorityLevel(QOS_PRIORITY_DEFAULT);
16 | }
17 | virtual ~RsPaintChatItem(){}
18 | virtual void clear(){}
19 |
20 | virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
21 |
22 | uint8_t command;
23 | RsTlvBinaryData binData;
24 | };
25 |
26 | class RsPaintChatSerialiser: public RsSerialType
27 | {
28 | public:
29 | RsPaintChatSerialiser()
30 | :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PAINTCHAT_PLUGIN)
31 | {
32 | }
33 | virtual ~RsPaintChatSerialiser() {}
34 |
35 | virtual uint32_t size (RsItem *item);
36 | virtual bool serialise (RsItem *item, void *data, uint32_t *pktsize);
37 | virtual RsItem *deserialise(void *data, uint32_t *pktsize);
38 | };
39 |
40 | #endif // PAINTCHATITEMS_H
41 |
--------------------------------------------------------------------------------
/services/p3paintchatservice.h:
--------------------------------------------------------------------------------
1 | #ifndef P3PAINTCHATSERVICE_H
2 | #define P3PAINTCHATSERVICE_H
3 |
4 | #include "plugins/rspqiservice.h"
5 | #include "interface/paintchatservice.h"
6 |
7 | #include