1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #include "lhtransmitterswitchapi.h"
- #include <QLibrary>
- #include <QApplication>
- #include <QDebug>
- LHTransmitterSwitchAPI::LHTransmitterSwitchAPI()
- {
- }
- LHTransmitterSwitchAPI::~LHTransmitterSwitchAPI()
- {
- }
- /* 加载动态库 */
- bool LHTransmitterSwitchAPI::loadLibrary()
- {
- #ifdef Q_OS_WIN
- QString libPath = QApplication::applicationDirPath() + "/libLHTransmitterSwitch.dll";
- #elif defined(Q_OS_LINUX)
- QString libPath = QApplication::applicationDirPath() + "/libLHTransmitterSwitch.so";
- #endif
- QLibrary lib(libPath);
- if(!lib.load())
- {
- qDebug() << "load 《LHTransmitterSwitch》 library failed, path: " << libPath;
- return false;
- }
- m_pInit = (pInit)lib.resolve("DoInit");
- m_pCreateWindow = (pCreateWindow)lib.resolve("DoCreateWindow");
- m_pShowWindow = (pShowWindow)lib.resolve("DoShowWindow");
- m_pGetExecPlanFromEQM = (pGetExecPlanFromEQM)lib.resolve("DoGetExecPlanFromEQM");
- m_pSaveExecPlanToEQM = (pSaveExecPlanToEQM)lib.resolve("DoSaveExecPlanToEQM");
- m_pRelease = (pRelease)lib.resolve("DoRelease");
- if(m_pInit == nullptr || m_pCreateWindow == nullptr || m_pShowWindow == nullptr ||
- m_pGetExecPlanFromEQM == nullptr || m_pSaveExecPlanToEQM == nullptr || m_pRelease == nullptr)
- {
- return false;
- }
- return true;
- }
- int LHTransmitterSwitchAPI::DoInit(const InitData* pData)
- {
- if(pData == nullptr)
- {
- return -1;
- }
- return m_pInit(pData);
- }
- int LHTransmitterSwitchAPI::DoCreateWindow(int skintype, QWidget* parent)
- {
- if(parent == nullptr)
- {
- return -1;
- }
- return m_pCreateWindow(skintype, parent);
- }
- int LHTransmitterSwitchAPI::DoShowWindow(int skintype, bool showWindow)
- {
- return m_pShowWindow(skintype, showWindow);
- }
- int LHTransmitterSwitchAPI::DoGetExecPlanFromEQM()
- {
- return m_pGetExecPlanFromEQM();
- }
- int LHTransmitterSwitchAPI::DoSaveExecPlanToEQM()
- {
- return m_pSaveExecPlanToEQM();
- }
- int LHTransmitterSwitchAPI::DoRelease()
- {
- return m_pRelease();
- }
|