tahoma2d/toonz/sources/include/tmsgcore.h

74 lines
1.4 KiB
C
Raw Normal View History

2016-03-19 06:57:51 +13:00
#pragma once
2016-03-27 13:30:32 +13:00
#include <QObject>
2016-03-19 06:57:51 +13:00
#include <set>
#include "tcommon.h"
#undef DVAPI
#undef DVVAR
#ifdef TSYSTEM_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
class QLocalServer;
class QLocalSocket;
class QTcpServer;
class QTcpSocket;
#undef ERROR
2016-06-15 18:43:10 +12:00
namespace DVGui {
2016-03-19 06:57:51 +13:00
enum MsgType {
2016-06-15 18:43:10 +12:00
INFORMATION,
WARNING, // this one opens a popup only if tmsg not visible
CRITICAL, // this one opens always a popup
QUESTION
2016-03-19 06:57:51 +13:00
};
void DVAPI MsgBox(MsgType type, const QString &text);
void DVAPI error(const QString &msg);
void DVAPI warning(const QString &msg);
void DVAPI info(const QString &msg);
};
class DVAPI TMsgCore final : public QObject {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QTcpServer *m_tcpServer;
QTcpSocket *m_clientSocket;
std::set<QTcpSocket *> m_sockets;
void readFromSocket(QTcpSocket *socket);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
TMsgCore();
~TMsgCore();
static TMsgCore *instance();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// client side
// 'send' returns false if the tmessage is not active in the application
// (typically, in console applications such as tcomposer)
2016-06-15 18:43:10 +12:00
bool send(DVGui::MsgType type, const QString &message);
void connectTo(const QString &address = "");
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// server side
bool openConnection();
QString getConnectionName();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
Q_SIGNALS:
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void sendMessage(int type, const QString &message);
2016-03-19 06:57:51 +13:00
public Q_SLOTS:
2016-06-15 18:43:10 +12:00
void OnNewConnection();
void OnReadyRead();
void OnDisconnected();
2016-03-19 06:57:51 +13:00
};