7 changed files with 344 additions and 9 deletions
-
4src/app/main.cpp
-
2src/zqui/channelmgr/qt_serial_datachannel.hpp
-
34src/zqui/mainpage/mainwindow.cpp
-
11src/zqui/mainpage/mainwindow.h
-
140src/zqui/mainpage/mainwindow.ui
-
80src/zqui/zqui.cpp
-
82src/zqui/zqui.hpp
@ -0,0 +1,80 @@ |
|||||
|
#include "zqui.hpp"
|
||||
|
|
||||
|
#include "zqui/mainpage/mainwindow.h"
|
||||
|
|
||||
|
using namespace std; |
||||
|
#define TAG "ZQUI"
|
||||
|
|
||||
|
/***********************************************************************************************************************
|
||||
|
* PreviewShow * |
||||
|
***********************************************************************************************************************/ |
||||
|
MainWindow *pmainW; |
||||
|
|
||||
|
ZQUI *ZQUI::ins() { |
||||
|
static ZQUI instance; |
||||
|
return &instance; |
||||
|
} |
||||
|
|
||||
|
void ZQUI::iShow(const char *fmt, ...) { |
||||
|
va_list args; |
||||
|
va_start(args, fmt); |
||||
|
char buf[1024] = {0}; |
||||
|
vsnprintf(buf, sizeof(buf), fmt, args); |
||||
|
va_end(args); |
||||
|
QString text(buf); |
||||
|
pmainW->iShow(text); |
||||
|
} |
||||
|
void ZQUI::iRawShow(const char *fmt, ...) { |
||||
|
va_list args; |
||||
|
va_start(args, fmt); |
||||
|
char buf[1024] = {0}; |
||||
|
vsnprintf(buf, sizeof(buf), fmt, args); |
||||
|
va_end(args); |
||||
|
QString text(buf); |
||||
|
pmainW->iShow(text); |
||||
|
} |
||||
|
void ZQUI::iClear() { pmainW->iClear(); } |
||||
|
|
||||
|
void ZQUI::reportShow(const char *fmt, ...) { |
||||
|
va_list args; |
||||
|
va_start(args, fmt); |
||||
|
char buf[1024] = {0}; |
||||
|
vsnprintf(buf, sizeof(buf), fmt, args); |
||||
|
va_end(args); |
||||
|
QString text(buf); |
||||
|
pmainW->reportShow(text); |
||||
|
} |
||||
|
void ZQUI::reportClear() { pmainW->reportClear(); } |
||||
|
|
||||
|
void ZQUI::binaryShow(const char *fmt, ...) { |
||||
|
va_list args; |
||||
|
va_start(args, fmt); |
||||
|
char buf[1024] = {0}; |
||||
|
vsnprintf(buf, sizeof(buf), fmt, args); |
||||
|
va_end(args); |
||||
|
QString text(buf); |
||||
|
pmainW->binaryShow(text); |
||||
|
} |
||||
|
void ZQUI::binaryClear() { pmainW->binaryClear(); } |
||||
|
|
||||
|
void ZQUI::initialize() { |
||||
|
qRegisterMetaType<int32_t>("int32_t"); |
||||
|
qRegisterMetaType<uint32_t>("uint32_t"); |
||||
|
qRegisterMetaType<float>("float"); |
||||
|
qRegisterMetaType<function<void()>>("function<void()>"); |
||||
|
qRegisterMetaType<QFunction>("QFunction"); |
||||
|
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); |
||||
|
|
||||
|
pmainW = new MainWindow(); |
||||
|
pmainW->show(); |
||||
|
} |
||||
|
void ZQUI::doinui(function<void()> dowhat) { |
||||
|
emit doinui_signal(QFunction([dowhat]() { |
||||
|
if (dowhat) dowhat(); |
||||
|
})); |
||||
|
} |
||||
|
void ZQUI::doinui_slot(QFunction func) { |
||||
|
if (func.get()) func.get()(); |
||||
|
} |
||||
|
|
||||
|
void ZQUI::setDeviceConnectedStatus(bool connect) { pmainW->setConnectedStatus(connect); } |
@ -0,0 +1,82 @@ |
|||||
|
#pragma once
|
||||
|
|
||||
|
#include <QMainWindow>
|
||||
|
#include <QtCore/QVariant>
|
||||
|
#include <QtWidgets/QAction>
|
||||
|
#include <QtWidgets/QApplication>
|
||||
|
#include <QtWidgets/QComboBox>
|
||||
|
#include <QtWidgets/QFormLayout>
|
||||
|
#include <QtWidgets/QGridLayout>
|
||||
|
#include <QtWidgets/QGroupBox>
|
||||
|
#include <QtWidgets/QHBoxLayout>
|
||||
|
#include <QtWidgets/QLabel>
|
||||
|
#include <QtWidgets/QMainWindow>
|
||||
|
#include <QtWidgets/QMenu>
|
||||
|
#include <QtWidgets/QMenuBar>
|
||||
|
#include <QtWidgets/QPushButton>
|
||||
|
#include <QtWidgets/QSpacerItem>
|
||||
|
#include <QtWidgets/QStatusBar>
|
||||
|
#include <QtWidgets/QTabWidget>
|
||||
|
#include <QtWidgets/QTextBrowser>
|
||||
|
#include <QtWidgets/QTextEdit>
|
||||
|
#include <QtWidgets/QVBoxLayout>
|
||||
|
#include <QtWidgets/QWidget>
|
||||
|
//
|
||||
|
|
||||
|
#include <fstream>
|
||||
|
#include <functional>
|
||||
|
#include <iostream>
|
||||
|
#include <list>
|
||||
|
#include <map>
|
||||
|
#include <memory>
|
||||
|
#include <set>
|
||||
|
#include <sstream>
|
||||
|
#include <string>
|
||||
|
#include <vector>
|
||||
|
|
||||
|
#include "base/QFunction.hpp"
|
||||
|
|
||||
|
class ZQUI : public QObject { |
||||
|
Q_OBJECT |
||||
|
public: |
||||
|
typedef std::function<void(QString)> display_fn_t; |
||||
|
typedef std::function<void()> display_clear_fn_t; |
||||
|
|
||||
|
|
||||
|
public: |
||||
|
static ZQUI *ins(); |
||||
|
|
||||
|
void initialize(); |
||||
|
|
||||
|
void doinui(std::function<void()> dowhat); |
||||
|
|
||||
|
void iShow(const char *fmt, ...); |
||||
|
void iRawShow(const char *fmt, ...); |
||||
|
void iClear(); |
||||
|
|
||||
|
void reportShow(const char *fmt, ...); |
||||
|
void reportClear(); |
||||
|
|
||||
|
void binaryShow(const char *fmt, ...); |
||||
|
void binaryClear(); |
||||
|
|
||||
|
void setDeviceConnectedStatus(bool connect); |
||||
|
|
||||
|
private slots: |
||||
|
void doinui_slot(QFunction); |
||||
|
|
||||
|
signals: |
||||
|
void doinui_signal(QFunction); |
||||
|
}; |
||||
|
|
||||
|
#define ISHOW(fmt, ...) ZQUI::ins()->iShow(fmt, ##__VA_ARGS__)
|
||||
|
#define IRSHOW(fmt, ...) ZQUI::ins()->iRawShow(fmt, ##__VA_ARGS__)
|
||||
|
#define ICLEAR() ZQUI::ins()->iClear()
|
||||
|
|
||||
|
#define RSHOW(fmt, ...) ZQUI::ins()->reportShow(fmt, ##__VA_ARGS__)
|
||||
|
#define RCLEAR() ZQUI::ins()->reportClear()
|
||||
|
|
||||
|
#define BSHOW(fmt, ...) ZQUI::ins()->binaryShow(fmt, ##__VA_ARGS__)
|
||||
|
#define BCLEAR() ZQUI::ins()->binaryClear()
|
||||
|
|
||||
|
#define DOINUI(fn) ZQUI::ins()->doinui(fn)
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue