You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mainclass.h 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef MAINCLASS_H
  2. #define MAINCLASS_H
  3. #include <QObject>
  4. #include <QStringList>
  5. #include <ptsocket/ptsocket.h>
  6. #include "../defs.h"
  7. #define qinfo qDebug()<<(m_colored ? "[\033[1m\033[36mInfo\033[m ]" : "[Info ]")
  8. #define qerror qDebug()<<(m_colored ? "[\033[1m\033[31mError\033[m]" : "[Error]")
  9. #define qok qDebug()<<(m_colored ? "[ \033[1m\033[32mOK\033[m ]" : "[ OK ]")
  10. class MainClass : public QObject
  11. {
  12. Q_OBJECT
  13. public:
  14. explicit MainClass(QObject *parent = 0);
  15. public slots:
  16. void send(QString cmd, bool print);
  17. void setCloseOnNextQuery(bool m);
  18. void setShowOnlyResponse(bool m);
  19. void setColored(bool m);
  20. void addCommands(QStringList cmds);
  21. void connectToDaemon();
  22. private slots:
  23. void stateChanged(PTSocket::State s);
  24. void packetReceived(int type, QByteArray data);
  25. void readStdin();
  26. void mayDisconnect();
  27. private:
  28. PTSocket* m_sock;
  29. bool m_closeOnNextQuery;
  30. QStringList m_cmds;
  31. bool m_showOnlyResponse;
  32. bool m_colored;
  33. bool m_lastQueryResult;
  34. int m_responsesCount;
  35. };
  36. #endif // MAINCLASS_H