3 Commits a456f70247 ... 071ae7e54c

Autore SHA1 Messaggio Data
  Apple 071ae7e54c V0.8.2 3 mesi fa
  Apple 683764bc5b V0.8.1 3 mesi fa
  Apple 90d9e6a674 V0.8 3 mesi fa
36 ha cambiato i file con 793 aggiunte e 836 eliminazioni
  1. 10 8
      Libraries/CURL/FindCURL.cmake
  2. BIN
      Libraries/LHHTTPAPI/.DS_Store
  3. 5 4
      Libraries/LHHTTPAPI/FindLHHTTPAPI.cmake
  4. BIN
      Libraries/LHHTTPAPI/lib/.DS_Store
  5. BIN
      Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterface.dll
  6. BIN
      Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterfaced.dll
  7. BIN
      Libraries/LHHTTPAPI/lib/macos/.DS_Store
  8. BIN
      Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.1.0.0.dylib
  9. 1 0
      Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.1.0.dylib
  10. 1 0
      Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.1.dylib
  11. 1 0
      Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.dylib
  12. BIN
      Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.1.0.0.dylib
  13. 1 0
      Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.1.0.dylib
  14. 1 0
      Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.1.dylib
  15. 1 0
      Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.dylib
  16. 2 2
      Libraries/LHHTTPAPI/src/lhhttpapi.cpp
  17. 5 3
      Libraries/LHQLog/FindLHQLog.cmake
  18. 3 26
      Libraries/LHQLog/src/LHQLogAPI.cpp
  19. 5 54
      Libraries/LHQLog/src/LHQLogAPI.h
  20. 4 3
      Libraries/qmqtt/Findqmqtt.cmake
  21. 5 3
      Libraries/sm_dll/FindSM.cmake
  22. BIN
      Libraries/spdlog/.DS_Store
  23. 20 9
      Libraries/spdlog/Findspdlog.cmake
  24. BIN
      Libraries/spdlog/macos/libspdlog.1.14.1.dylib
  25. 1 0
      Libraries/spdlog/macos/libspdlog.1.14.dylib
  26. 1 0
      Libraries/spdlog/macos/libspdlog.dylib
  27. BIN
      Libraries/spdlog/macos/libspdlogd.1.14.1.dylib
  28. 1 0
      Libraries/spdlog/macos/libspdlogd.1.14.dylib
  29. 1 0
      Libraries/spdlog/macos/libspdlogd.dylib
  30. 46 46
      common/combox/customcombobox.cpp
  31. 26 26
      common/combox/customcombobox.h
  32. 67 67
      common/combox/wordtopinyin.h
  33. 205 205
      common/warning/warning copy.ui_
  34. 112 112
      common/warning/warning.cpp
  35. 46 46
      common/warning/warning.h
  36. 222 222
      common/warning/warning.ui

+ 10 - 8
Libraries/CURL/FindCURL.cmake

@@ -48,17 +48,19 @@ endif()
 if(CURL_INCLUDE_DIR AND ( CURL_LIBRARY OR CURL_STATIC_LIBRARY) )
     set(CURL_FOUND TRUE)
     set(CURL_VERSION 7.88.1)
+
+    if(CURL_INCLUDE_DIR AND CURL_LIBRARY AND CURL_STATIC_LIBRARY)
+        message(STATUS "include : CURL_INCLUDE_DIR")
+        message(STATUS "Library : CURL_LIBRARY")
+        message(STATUS "Static Library : CURL_STATIC_LIBRARY")
+    elseif(CURL_INCLUDE_DIR AND CURL_LIBRARY)
+        message(STATUS "include : CURL_INCLUDE_DIR")
+        message(STATUS "Library : CURL_LIBRARY")
+    endif()
 else()
     set(CURL_FOUND FALSE)
 endif()
 
-if(CURL_INCLUDE_DIR AND CURL_LIBRARY AND CURL_STATIC_LIBRARY)
-    message(STATUS "include : CURL_INCLUDE_DIR")
-    message(STATUS "Library : CURL_LIBRARY")
-    message(STATUS "Static Library : CURL_STATIC_LIBRARY")
-elseif(CURL_INCLUDE_DIR AND CURL_LIBRARY)
-    message(STATUS "include : CURL_INCLUDE_DIR")
-    message(STATUS "Library : CURL_LIBRARY")
-endif()
+
 
 message(STATUS "---------------------------------")

BIN
Libraries/LHHTTPAPI/.DS_Store


+ 5 - 4
Libraries/LHHTTPAPI/FindLHHTTPAPI.cmake

@@ -64,13 +64,14 @@ if(LHHTTPAPI_INCLUDE_DIRS AND LHHTTPAPI_SOURCE_DIRS AND LHHTTPAPI_LIBRARY)
     set(LHHTTPAPI_FOUND TRUE)
     set(LHHTTPAPI_VERSION 1.0.9)
 
+    # message(STATUS "LHHTTPAPI found: LHHTTPAPI")
+    message(STATUS "LHHTTPAPI include: LHHTTPAPI_INCLUDE_DIRS")
+    message(STATUS "LHHTTPAPI source: LHHTTPAPI_SOURCE_DIRS")
+    # message(STATUS "LHHTTPAPI library: LHHTTPAPI_LIBRARY")
 else()
     set(LHHTTPAPI_FOUND FALSE)
 endif()
 
-# message(STATUS "LHHTTPAPI found: LHHTTPAPI")
-message(STATUS "LHHTTPAPI include: LHHTTPAPI_INCLUDE_DIRS")
-message(STATUS "LHHTTPAPI source: LHHTTPAPI_SOURCE_DIRS")
-# message(STATUS "LHHTTPAPI library: LHHTTPAPI_LIBRARY")
+
 
 message(STATUS "--------------------------------------------------")

BIN
Libraries/LHHTTPAPI/lib/.DS_Store


BIN
Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterface.dll


BIN
Libraries/LHHTTPAPI/lib/MinGW_64/LHSqlWebInterfaced.dll


BIN
Libraries/LHHTTPAPI/lib/macos/.DS_Store


BIN
Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.1.0.0.dylib


+ 1 - 0
Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.1.0.dylib

@@ -0,0 +1 @@
+libLHSqlWebInterfaceEX_debug.1.0.0.dylib

+ 1 - 0
Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.1.dylib

@@ -0,0 +1 @@
+libLHSqlWebInterfaceEX_debug.1.0.0.dylib

+ 1 - 0
Libraries/LHHTTPAPI/lib/macos/Debug/libLHSqlWebInterfaceEX_debug.dylib

@@ -0,0 +1 @@
+libLHSqlWebInterfaceEX_debug.1.0.0.dylib

BIN
Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.1.0.0.dylib


+ 1 - 0
Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.1.0.dylib

@@ -0,0 +1 @@
+libLHSqlWebInterfaceEX.1.0.0.dylib

+ 1 - 0
Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.1.dylib

@@ -0,0 +1 @@
+libLHSqlWebInterfaceEX.1.0.0.dylib

+ 1 - 0
Libraries/LHHTTPAPI/lib/macos/Release/libLHSqlWebInterfaceEX.dylib

@@ -0,0 +1 @@
+libLHSqlWebInterfaceEX.1.0.0.dylib

+ 2 - 2
Libraries/LHHTTPAPI/src/lhhttpapi.cpp

@@ -90,7 +90,7 @@ bool lhhttpapi::Load(QString file)
 bool lhhttpapi::Load()
 {
 #if defined(Q_OS_WIN)
-    QString libFile = QString("%1/LHSqlWebInterface.dll").arg(QCoreApplication::applicationDirPath());
+    qDebug() << "暂不支持Windows";
 #elif defined(Q_OS_LINUX)
     QString libFile = QString("%1/libLHSqlWebInterface.so").arg(QCoreApplication::applicationDirPath());
 #endif
@@ -282,7 +282,7 @@ int lhhttpapi::DBDoInterface( int nOperatorType, const QString &strParamXml, QSt
         //char buffer[LHHTTPAPI_BUFFER_SIZE] = {0};
         char *buffer = new char[LHHTTPAPI_BUFFER_SIZE]{0};
         // memset(buffer, 0, LHHTTPAPI_BUFFER_SIZE);
-        int ret = fnDBDoInterface(serid.toUtf8().data(), appType.toUtf8().data(), strToken.toUtf8().data(), nOperatorType, strParamXml.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE-1, bismulti,phttpip);
+        int ret = fnDBDoInterface(serid.toUtf8().data(), appType.toUtf8().data(), strToken.toUtf8().data(), nOperatorType, strParamXml.toUtf8().data(), buffer, LHHTTPAPI_BUFFER_SIZE,bismulti,phttpip);
         strRetXml = QString::fromUtf8(buffer);
         delete [] buffer;
         return ret;

+ 5 - 3
Libraries/LHQLog/FindLHQLog.cmake

@@ -100,13 +100,15 @@ if(LHQLog_INCLUDE_DIRS AND LHQLog_SOURCE_DIRS)
     set(LHQLog_INCLUDE_DIRS ${LHQLog_INCLUDE_DIRS} CACHE INTERNAL "LHQLog include directories")
     set(LHQLog_SOURCE_DIRS ${LHQLog_SOURCE_DIRS} CACHE INTERNAL "LHQLog source directories")
     set(LHQLog_LIBRARY ${LHQLog_LIBRARY} CACHE INTERNAL "LHQLog library")
+
+
+    message(STATUS "LHQLog include: LHQLog_INCLUDE_DIRS")
+    message(STATUS "LHQLog source: LHQLog_SOURCE_DIRS")
+    # message(STATUS "LHQLog library: LHQLog_LIBRARY")
 else()
     set(LHQLog_FOUND FALSE)
     
 endif()
 
-message(STATUS "LHQLog include: LHQLog_INCLUDE_DIRS")
-message(STATUS "LHQLog source: LHQLog_SOURCE_DIRS")
-# message(STATUS "LHQLog library: LHQLog_LIBRARY")
 
 message(STATUS "--------------------------------------------------")

+ 3 - 26
Libraries/LHQLog/src/LHQLogAPI.cpp

@@ -1,29 +1,7 @@
 #include "LHQLogAPI.h"
 #include <QTime>
-#include <QCoreApplication>
 // #include "./External/Core/MyDebugLog.h"
 
-
-/* 加载动态库 */
-void LH_LoadLib()
-{
-    QString libPath = QCoreApplication::applicationDirPath();
-#ifdef Q_OS_WINDOWS
-    libPath += "/LHQLog.dll";
-    g_apiLhQLog.Load(libPath);
-#else
-    libPath += "/libLHQLog.so";
-    g_apiLhQLog.Load(libPath);
-#endif
-
-}
-
-void LH_LoadLib(const QString& strLibPath)
-{
-    g_apiLhQLog.Load(strLibPath);
-}
-
-
 CLHQLogApi g_apiLhQLog;
 void WRITE_LOG(QString log)
 {
@@ -32,9 +10,8 @@ void WRITE_LOG(QString log)
 #ifdef QT_NO_DEBUG
     g_apiLhQLog.DoWriteLog(ELT_Log_Common, msg);
 #else
-    // log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
+    log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
     // LOG(log);
-    
 #endif
 }
 
@@ -45,7 +22,7 @@ void WRITE_ERROR(QString log)
 #ifdef QT_NO_DEBUG
     g_apiLhQLog.DoWriteLog(ELT_Log_Error, msg);
 #else
-    // log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
+    log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
     // LOG(log);
 #endif
 }
@@ -57,7 +34,7 @@ void WRITE_LOG_DEBUG(QString log)
 #ifdef QT_NO_DEBUG
     g_apiLhQLog.DoWriteLog(ELT_Log_Debug, msg);
 #else
-    // log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
+    log.insert(idx+1, QTime::currentTime().toString("hh:mm:ss.zzz"));
     // LOG(log);
 #endif
 }

+ 5 - 54
Libraries/LHQLog/src/LHQLogAPI.h

@@ -6,61 +6,13 @@
 #include <QElapsedTimer>
 #include <QDebug>
 
-/** ====================================================================================================
- * ***************************************  对外API **************************************************
- * ====================================================================================================*/
+
 
 #define DoLog(msg)      WRITE_LOG(QString("[%1:%2:%3] %4").arg(__FILE__, __FUNCTION__, QString::number(__LINE__), msg))
 #define DoError(msg)    WRITE_ERROR(QString("[%1:%2:%3] %4").arg(__FILE__, __FUNCTION__, QString::number(__LINE__), msg))
 #define DoDebug(msg)    WRITE_LOG_DEBUG(QString("[%1:%2:%3] %4").arg(__FILE__, __FUNCTION__, QString::number(__LINE__), msg))
 #define MyLog(msg)      qDebug() << "[" << __FILE__ << __FUNCTION__ << __LINE__ << QTime::currentTime().toString("hh:mm:ss.zzz") << "]" << msg
 
-/* 通过这个宏写日志可以打印到终端上 */
-
-#define LH_WRITE_LOG_DEBUG(_log_msg) \
-    do {                                                                        \
-        QString _log_file = __FILE__;                                           \
-        QString _log_str = '[' +                                                \
-        QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")        \
-         + ']' + '[' +                                                          \
-         _log_file.right(_log_file.count() - _log_file.lastIndexOf('/') -1)     \
-          + ':' +                                                               \
-          QString::number(__LINE__) + "] " + _log_msg;                          \
-         qDebug() << _log_str;                                                  \
-         WRITE_LOG_DEBUG(_log_str);                                             \
-    } while(0)
-
-#define LH_WRITE_LOG(_log_msg)       \
-    do {                                                                        \
-        QString _log_file = __FILE__;                                           \
-        QString _log_str =                                                      \
-        '[' +                                                                   \
-        QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") +      \
-        ']' + '[' +                                                             \
-        _log_file.right(_log_file.count() - _log_file.lastIndexOf('/') - 1)     \
-        + ':' +                                                                 \
-        QString::number(__LINE__) + "] " + _log_msg;                            \
-        qInfo() << _log_str;                                                    \
-        WRITE_LOG(_log_str);                                                    \
-    } while (0)
-
-#define LH_WRITE_ERROR(_log_msg)    \
-    do {                                                                        \
-        QString _log_file = __FILE__;                                           \
-        QString _log_str =                                                      \
-        '[' +                                                                   \
-        QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") +      \
-        ']' + '[' +                                                             \
-        _log_file.right(_log_file.count() - _log_file.lastIndexOf('/') - 1)     \
-        + ':' +                                                                 \
-        QString::number(__LINE__) + "] " + _log_msg;                            \
-        qWarning() << _log_str;                                                 \
-        WRITE_ERROR(_log_str);                                                  \
-    } while (0)
-
-/* 加载动态库 */
-void LH_LoadLib();
-void LH_LoadLib(const QString& strLibPath);
 
 
 #define LimitLog(interval, msg) \
@@ -75,11 +27,6 @@ void LH_LoadLib(const QString& strLibPath);
         }\
     }while(0);
 
-
-/** ====================================================================================================
- * 
- * ====================================================================================================*/
-
 enum enLogType
 {
     ELT_Log_ALL = 0,
@@ -101,6 +48,10 @@ enum enLogType
 };
 
 
+#define LH_WRITE_LOG(msg)       WRITE_LOG(msg)
+#define LH_WRITE_ERROR(msg)     WRITE_ERROR(msg)
+#define LH_WRITE_LOG_DEBUG(msg) WRITE_LOG_DEBUG(msg)
+
 extern void WRITE_LOG(QString log);
 extern void WRITE_ERROR(QString log);
 extern void WRITE_LOG_DEBUG(QString log);

+ 4 - 3
Libraries/qmqtt/Findqmqtt.cmake

@@ -82,13 +82,14 @@ endif()
 # 3. 设置查找到了变量
 if(qmqtt_INCLUDE_DIR AND qmqtt_LIBRARY)
     set(qmqtt_FOUND TRUE)
+
+    # message(STATUS "qmqtt Version : ${qmqtt_VERSION}")
+    message(STATUS "include : qmqtt_INCLUDE_DIR")
+    message(STATUS "Library : qmqtt_LIBRARY")
 else()
     set(qmqtt_FOUND FALSE)
 endif()
 
-# message(STATUS "qmqtt Version : ${qmqtt_VERSION}")
-message(STATUS "include : qmqtt_INCLUDE_DIR")
-message(STATUS "Library : qmqtt_LIBRARY")
 
 
 message(STATUS "---------------------------------")

+ 5 - 3
Libraries/sm_dll/FindSM.cmake

@@ -73,12 +73,14 @@ endif()
 if(SM_INCLUDE_DIR AND SM_SOURCE_DIR AND SM_LIB_LIBRARY)
     set(SM_FOUND TRUE)
     set(SM_VERSION "1.1.0")
+
+    message(STATUS "include : SM_INCLUDE_DIR")
+    message(STATUS "source : SM_SOURCE_DIR")
+    message(STATUS "Library : SM_LIB_LIBRARY")
 else()
     set(SM_FOUND FALSE)
 endif()
 
-message(STATUS "include : SM_INCLUDE_DIR")
-message(STATUS "source : SM_SOURCE_DIR")
-message(STATUS "Library : SM_LIB_LIBRARY")
+
 
 message(STATUS "---------------------------------")

BIN
Libraries/spdlog/.DS_Store


+ 20 - 9
Libraries/spdlog/Findspdlog.cmake

@@ -68,6 +68,15 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
         #这里需要显式的链接依赖库,或者使用target_link_options(appname PRIVATE "-Wl,--copy-dt-needed-entries")来让gcc递归搜索依赖库
         list(APPEND spdlog_STATIC_LIBRARY pthread)
     endif()
+#MacOS版本
+elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+    #MacOS版本
+    if(CMAKE_BUILD_TYPE MATCHES "Debug")
+        list(APPEND spdlog_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/macos/libspdlog.dylib)
+    else()
+        list(APPEND spdlog_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/macos/libspdlog.dylib)
+    endif()
+
 endif()
 
 #设置查找到后的变量
@@ -80,18 +89,20 @@ endif()
 if(spdlog_INCLUDE_DIR AND spdlog_LIBRARY)
     set(spdlog_FOUND TRUE)
     set(spdlog_VERSION 1.14.1)
+
+    message(STATUS "如果需要使用静态库,定义“ ENABLE_SPDLOG_STATIC_LIB ”变量")
+    if(ENABLE_SPDLOG_STATIC_LIB)
+        message(STATUS "include : spdlog_INCLUDE_DIR")
+        message(STATUS "Library : spdlog_LIBRARY")
+        message(STATUS "Static Library : spdlog_STATIC_LIBRARY")
+    else()
+        message(STATUS "include : spdlog_INCLUDE_DIR")
+        message(STATUS "Library : spdlog_LIBRARY")
+    endif()
 else()
     set(spdlog_FOUND FALSE)
 endif()
 
-message(STATUS "如果需要使用静态库,定义“ ENABLE_SPDLOG_STATIC_LIB ”变量")
-if(ENABLE_SPDLOG_STATIC_LIB)
-    message(STATUS "include : spdlog_INCLUDE_DIR")
-    message(STATUS "Library : spdlog_LIBRARY")
-    message(STATUS "Static Library : spdlog_STATIC_LIBRARY")
-else()
-    message(STATUS "include : spdlog_INCLUDE_DIR")
-    message(STATUS "Library : spdlog_LIBRARY")
-endif()
+
 
 message(STATUS "---------------------------------")

BIN
Libraries/spdlog/macos/libspdlog.1.14.1.dylib


+ 1 - 0
Libraries/spdlog/macos/libspdlog.1.14.dylib

@@ -0,0 +1 @@
+libspdlog.1.14.1.dylib

+ 1 - 0
Libraries/spdlog/macos/libspdlog.dylib

@@ -0,0 +1 @@
+libspdlog.1.14.dylib

BIN
Libraries/spdlog/macos/libspdlogd.1.14.1.dylib


+ 1 - 0
Libraries/spdlog/macos/libspdlogd.1.14.dylib

@@ -0,0 +1 @@
+libspdlogd.1.14.1.dylib

+ 1 - 0
Libraries/spdlog/macos/libspdlogd.dylib

@@ -0,0 +1 @@
+libspdlogd.1.14.dylib

+ 46 - 46
common/combox/customcombobox.cpp

@@ -1,46 +1,46 @@
-#include "customcombobox.h"
-#include <QApplication>
-#include <QGraphicsDropShadowEffect>
-#include <QListView>
-#include <QDebug>
-
-CustomComboBox::CustomComboBox(QWidget *parent)
-    : QComboBox(parent)
-{
-    
-}
-CustomComboBox::~CustomComboBox()
-{
-}
-
-/* 设置下拉框阴影 */
-void CustomComboBox::setViewShadowEffect()
-{
-    setView(new QListView());
-    if (nullptr != view() && nullptr != view()->window()) 
-    {
-        view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
-        view()->window()->setAttribute(Qt::WA_TranslucentBackground);
-
-        QGraphicsDropShadowEffect *pShadowEffect = new QGraphicsDropShadowEffect(this);
-        pShadowEffect->setBlurRadius(LISTVIEW_MARGIN);  // 模糊度
-        pShadowEffect->setColor(QColor(0, 0, 0, 90));   // 阴影的颜色
-        pShadowEffect->setOffset(0, 0);                 // 水平和垂直偏移量
-        view()->setGraphicsEffect(pShadowEffect);
-
-        QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
-    }
-}
-
-void CustomComboBox::showPopup()
-{
-    QComboBox::showPopup();
-
-    if (nullptr != view()) {
-        view()->setMinimumWidth(width() + LISTVIEW_MARGIN * 2);
-    }
-    QWidget *popup = findChild<QFrame*>();
-    if (nullptr != popup) {
-        popup->move(mapToGlobal(QPoint(-LISTVIEW_MARGIN, height() - LISTVIEW_MARGIN + 4)));
-    }
-}
+#include "customcombobox.h"
+#include <QApplication>
+#include <QGraphicsDropShadowEffect>
+#include <QListView>
+#include <QDebug>
+
+CustomComboBox::CustomComboBox(QWidget *parent)
+    : QComboBox(parent)
+{
+    
+}
+CustomComboBox::~CustomComboBox()
+{
+}
+
+/* 设置下拉框阴影 */
+void CustomComboBox::setViewShadowEffect()
+{
+    setView(new QListView());
+    if (nullptr != view() && nullptr != view()->window()) 
+    {
+        view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
+        view()->window()->setAttribute(Qt::WA_TranslucentBackground);
+
+        QGraphicsDropShadowEffect *pShadowEffect = new QGraphicsDropShadowEffect(this);
+        pShadowEffect->setBlurRadius(LISTVIEW_MARGIN);  // 模糊度
+        pShadowEffect->setColor(QColor(0, 0, 0, 90));   // 阴影的颜色
+        pShadowEffect->setOffset(0, 0);                 // 水平和垂直偏移量
+        view()->setGraphicsEffect(pShadowEffect);
+
+        QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
+    }
+}
+
+void CustomComboBox::showPopup()
+{
+    QComboBox::showPopup();
+
+    if (nullptr != view()) {
+        view()->setMinimumWidth(width() + LISTVIEW_MARGIN * 2);
+    }
+    QWidget *popup = findChild<QFrame*>();
+    if (nullptr != popup) {
+        popup->move(mapToGlobal(QPoint(-LISTVIEW_MARGIN, height() - LISTVIEW_MARGIN + 4)));
+    }
+}

+ 26 - 26
common/combox/customcombobox.h

@@ -1,26 +1,26 @@
-#ifndef CUSTOMCOMBOBOX_H
-#define CUSTOMCOMBOBOX_H
-
-#include <QComboBox>
-
-/**
- * @brief 1、使用此类绘制下拉框阴影需要在样式表中设置QAbstractItemView {margin: LISTVIEW_MARGIN;}
- *          否则阴影会被遮挡
- *        2、调用函数setViewShadowEffect()设置下拉框阴影
- */
-class CustomComboBox : public QComboBox
-{
-public:
-    explicit CustomComboBox(QWidget *parent = nullptr);
-    ~CustomComboBox();
-
-    /* 设置下拉框阴影 */
-    void setViewShadowEffect();
-
-    //重写下拉框弹出位置
-    void showPopup() override;
-private:
-    const int LISTVIEW_MARGIN = 12; // QAbstractItemView边距(阴影宽度)
-};
-
-#endif // CUSTOMCOMBOBOX_H
+#ifndef CUSTOMCOMBOBOX_H
+#define CUSTOMCOMBOBOX_H
+
+#include <QComboBox>
+
+/**
+ * @brief 1、使用此类绘制下拉框阴影需要在样式表中设置QAbstractItemView {margin: LISTVIEW_MARGIN;}
+ *          否则阴影会被遮挡
+ *        2、调用函数setViewShadowEffect()设置下拉框阴影
+ */
+class CustomComboBox : public QComboBox
+{
+public:
+    explicit CustomComboBox(QWidget *parent = nullptr);
+    ~CustomComboBox();
+
+    /* 设置下拉框阴影 */
+    void setViewShadowEffect();
+
+    //重写下拉框弹出位置
+    void showPopup() override;
+private:
+    const int LISTVIEW_MARGIN = 12; // QAbstractItemView边距(阴影宽度)
+};
+
+#endif // CUSTOMCOMBOBOX_H

+ 67 - 67
common/combox/wordtopinyin.h

@@ -1,67 +1,67 @@
-#ifndef WORDTOPINYIN_H
-#define WORDTOPINYIN_H
-#include <QTextCodec>
-
-class WordToPinyin
-{
-public:
-    static bool In( quint16 start, quint16 end, quint16 code)
-    {
-        return (code>=start && code<=end) ? true : false;
-    }
-
-    static char convert(quint16 n)
-    {
-        if (In(0xB0A1,0xB0C4,n)) return 'a';
-        if (In(0XB0C5,0XB2C0,n)) return 'b';
-        if (In(0xB2C1,0xB4ED,n)) return 'c';
-        if (In(0xB4EE,0xB6E9,n)) return 'd';
-        if (In(0xB6EA,0xB7A0,n)) return 'e';
-        if (In(0xB7A1,0xB8c0,n)) return 'f';
-        if (In(0xB8C1,0xB9FD,n)) return 'g';
-        if (In(0xB9FE,0xBBF6,n)) return 'h';
-        if (In(0xBBF7,0xBFA4,n)) return 'j';
-        if (In(0xBFA5,0xC0AA,n)) return 'k';
-        if (In(0xC0AB,0xC2E7,n)) return 'l';
-        if (In(0xC2E8,0xC4C2,n)) return 'm';
-        if (In(0xC4C3,0xC5B5,n)) return 'n';
-        if (In(0xC5B6,0xC5BD,n)) return 'o';
-        if (In(0xC5BE,0xC6D9,n)) return 'p';
-        if (In(0xC6DA,0xC8BA,n)) return 'q';
-        if (In(0xC8BB,0xC8F5,n)) return 'r';
-        if (In(0xC8F6,0xCBF9,n)) return 's';
-        if (In(0xCBFA,0xCDD9,n)) return 't';
-        if (In(0xCDDA,0xCEF3,n)) return 'w';
-        if (In(0xCEF4,0xD1B8,n)) return 'x';
-        if (In(0xD1B9,0xD4D0,n)) return 'y';
-        if (In(0xD4D1,0xD7F9,n)) return 'z';
-        return '\0';
-    }
-
-    //获取首字母
-    static QString firstPinyin(const QString &string)
-    {
-        QTextCodec *codec4gbk = QTextCodec::codecForName("GBK");    //获取qt提供的gbk的解码器
-        QByteArray buf = codec4gbk->fromUnicode( string );        //qt用的unicode,专程gbk
-        int size = buf.size();
-        quint16 *array = new quint16[size+1]{0};
-        QString alphbats;
-        for( int i = 0, j = 0; i < size; i++, j++ )
-        {
-            if( (quint8)buf[i] < 0x80 )                        //gbk的第一个字节都大于0x81,所以小于0x80的都是符号,字母,数字etc
-            {
-                alphbats.append(QString("%1").arg(buf[i]));
-                continue;
-            }
-            array[j] = (((quint8)buf[i]) << 8) + (quint8)buf[i+1];    //计算gbk编码
-            i++;
-            alphbats.append( convert( array[j] ) );            //相当于查表,用gbk编码得到首拼音字母
-        }
-        delete [] array;
-        return alphbats;
-    }
-
-};
-
-
-#endif 
+#ifndef WORDTOPINYIN_H
+#define WORDTOPINYIN_H
+#include <QTextCodec>
+
+class WordToPinyin
+{
+public:
+    static bool In( quint16 start, quint16 end, quint16 code)
+    {
+        return (code>=start && code<=end) ? true : false;
+    }
+
+    static char convert(quint16 n)
+    {
+        if (In(0xB0A1,0xB0C4,n)) return 'a';
+        if (In(0XB0C5,0XB2C0,n)) return 'b';
+        if (In(0xB2C1,0xB4ED,n)) return 'c';
+        if (In(0xB4EE,0xB6E9,n)) return 'd';
+        if (In(0xB6EA,0xB7A0,n)) return 'e';
+        if (In(0xB7A1,0xB8c0,n)) return 'f';
+        if (In(0xB8C1,0xB9FD,n)) return 'g';
+        if (In(0xB9FE,0xBBF6,n)) return 'h';
+        if (In(0xBBF7,0xBFA4,n)) return 'j';
+        if (In(0xBFA5,0xC0AA,n)) return 'k';
+        if (In(0xC0AB,0xC2E7,n)) return 'l';
+        if (In(0xC2E8,0xC4C2,n)) return 'm';
+        if (In(0xC4C3,0xC5B5,n)) return 'n';
+        if (In(0xC5B6,0xC5BD,n)) return 'o';
+        if (In(0xC5BE,0xC6D9,n)) return 'p';
+        if (In(0xC6DA,0xC8BA,n)) return 'q';
+        if (In(0xC8BB,0xC8F5,n)) return 'r';
+        if (In(0xC8F6,0xCBF9,n)) return 's';
+        if (In(0xCBFA,0xCDD9,n)) return 't';
+        if (In(0xCDDA,0xCEF3,n)) return 'w';
+        if (In(0xCEF4,0xD1B8,n)) return 'x';
+        if (In(0xD1B9,0xD4D0,n)) return 'y';
+        if (In(0xD4D1,0xD7F9,n)) return 'z';
+        return '\0';
+    }
+
+    //获取首字母
+    static QString firstPinyin(const QString &string)
+    {
+        QTextCodec *codec4gbk = QTextCodec::codecForName("GBK");    //获取qt提供的gbk的解码器
+        QByteArray buf = codec4gbk->fromUnicode( string );        //qt用的unicode,专程gbk
+        int size = buf.size();
+        quint16 *array = new quint16[size+1]{0};
+        QString alphbats;
+        for( int i = 0, j = 0; i < size; i++, j++ )
+        {
+            if( (quint8)buf[i] < 0x80 )                        //gbk的第一个字节都大于0x81,所以小于0x80的都是符号,字母,数字etc
+            {
+                alphbats.append(QString("%1").arg(buf[i]));
+                continue;
+            }
+            array[j] = (((quint8)buf[i]) << 8) + (quint8)buf[i+1];    //计算gbk编码
+            i++;
+            alphbats.append( convert( array[j] ) );            //相当于查表,用gbk编码得到首拼音字母
+        }
+        delete [] array;
+        return alphbats;
+    }
+
+};
+
+
+#endif 

+ 205 - 205
common/warning/warning copy.ui_

@@ -1,205 +1,205 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Warning</class>
- <widget class="QDialog" name="Warning">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>448</width>
-    <height>249</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Dialog</string>
-  </property>
-  <property name="styleSheet">
-   <string notr="true">QDialog#Warning
-{
-background:transparent;
-}</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <property name="spacing">
-    <number>0</number>
-   </property>
-   <property name="leftMargin">
-    <number>16</number>
-   </property>
-   <property name="topMargin">
-    <number>16</number>
-   </property>
-   <property name="rightMargin">
-    <number>16</number>
-   </property>
-   <property name="bottomMargin">
-    <number>16</number>
-   </property>
-   <item>
-    <widget class="QWidget" name="widget" native="true">
-     <property name="styleSheet">
-      <string notr="true">QWidget{
-background: #FFFFFF;
-border-radius: 8px;
-font-family: 思源黑体R;
-font-weight: 400;
-font-size: 18px;
-color: #3A3F63;
-line-height: 21px;
-text-align: left;
-font-style: normal;
-}
-
-QLabel#label_NC1
-{
-font-family: 思源黑体M;
-font-weight: bold;
-font-size: 18px;
-color: #3A3F63;
-line-height: 27px;
-text-transform: uppercase;
-}
-
-QLabel#label_line
-{
-background: #E6E9F4;
-}
-
-QLabel#label_Warn
-{
-	
-}
-
-QPushButton#pBtn_close{
-	border-image: url(:/ESM-8C_ICON/Dialog_close.png);
-}
-QPushButton#pBtn_close:hover{
-	
-	border-image: url(:/ESM-8C_ICON/Dialog_close2.png);
-}
-
-QPushButton
-{
-	background: #FFFFFF;
-	border: 1px solid #E6E9F4;
-	text-align: center;
-}
-
-
-/********* 普通方框按钮三种状态效果 *********/
-QPushButton#pBtn_cancel
-{
-    background: #FFFFFF;
-    border-radius: 16px;
-    border: 1px solid #E6E9F4;
-    color: #3A3F63;
-}
-QPushButton#pBtn_cancel:hover
-{
-    background: #FFFFFF;
-    border-radius: 16px;
-    border: 1px solid #4458FE;
-    color: #4458FE;
-}
-
-/********* 带有底色按钮三种状态效果 *********/
-QPushButton#pBtn_ok
-{
-    color:white;
-    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:1 #4F8AFF,stop:0 #4B5EFF);
-    border-radius: 16px;
-}
-
-QPushButton#pBtn_ok:hover
-{
-    color:white;
-    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:0 #5D73FF,stop:1 #6092FF);
-    border-radius: 16px;
-}
-</string>
-     </property>
-     <widget class="QLabel" name="label_NC1">
-      <property name="geometry">
-       <rect>
-        <x>32</x>
-        <y>18</y>
-        <width>90</width>
-        <height>18</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>提示</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_line">
-      <property name="geometry">
-       <rect>
-        <x>0</x>
-        <y>56</y>
-        <width>416</width>
-        <height>1</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_close">
-      <property name="geometry">
-       <rect>
-        <x>368</x>
-        <y>12</y>
-        <width>32</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_Warn">
-      <property name="geometry">
-       <rect>
-        <x>40</x>
-        <y>78</y>
-        <width>331</width>
-        <height>61</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>删除该设备,“执行计划”中与之对应的计划也会删除!</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_cancel">
-      <property name="geometry">
-       <rect>
-        <x>248</x>
-        <y>153</y>
-        <width>60</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>取消</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_ok">
-      <property name="geometry">
-       <rect>
-        <x>324</x>
-        <y>153</y>
-        <width>60</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>确定</string>
-      </property>
-     </widget>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Warning</class>
+ <widget class="QDialog" name="Warning">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>448</width>
+    <height>249</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">QDialog#Warning
+{
+background:transparent;
+}</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <property name="leftMargin">
+    <number>16</number>
+   </property>
+   <property name="topMargin">
+    <number>16</number>
+   </property>
+   <property name="rightMargin">
+    <number>16</number>
+   </property>
+   <property name="bottomMargin">
+    <number>16</number>
+   </property>
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <property name="styleSheet">
+      <string notr="true">QWidget{
+background: #FFFFFF;
+border-radius: 8px;
+font-family: 思源黑体R;
+font-weight: 400;
+font-size: 18px;
+color: #3A3F63;
+line-height: 21px;
+text-align: left;
+font-style: normal;
+}
+
+QLabel#label_NC1
+{
+font-family: 思源黑体M;
+font-weight: bold;
+font-size: 18px;
+color: #3A3F63;
+line-height: 27px;
+text-transform: uppercase;
+}
+
+QLabel#label_line
+{
+background: #E6E9F4;
+}
+
+QLabel#label_Warn
+{
+	
+}
+
+QPushButton#pBtn_close{
+	border-image: url(:/ESM-8C_ICON/Dialog_close.png);
+}
+QPushButton#pBtn_close:hover{
+	
+	border-image: url(:/ESM-8C_ICON/Dialog_close2.png);
+}
+
+QPushButton
+{
+	background: #FFFFFF;
+	border: 1px solid #E6E9F4;
+	text-align: center;
+}
+
+
+/********* 普通方框按钮三种状态效果 *********/
+QPushButton#pBtn_cancel
+{
+    background: #FFFFFF;
+    border-radius: 16px;
+    border: 1px solid #E6E9F4;
+    color: #3A3F63;
+}
+QPushButton#pBtn_cancel:hover
+{
+    background: #FFFFFF;
+    border-radius: 16px;
+    border: 1px solid #4458FE;
+    color: #4458FE;
+}
+
+/********* 带有底色按钮三种状态效果 *********/
+QPushButton#pBtn_ok
+{
+    color:white;
+    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:1 #4F8AFF,stop:0 #4B5EFF);
+    border-radius: 16px;
+}
+
+QPushButton#pBtn_ok:hover
+{
+    color:white;
+    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:0 #5D73FF,stop:1 #6092FF);
+    border-radius: 16px;
+}
+</string>
+     </property>
+     <widget class="QLabel" name="label_NC1">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>18</y>
+        <width>90</width>
+        <height>18</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>提示</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_line">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>56</y>
+        <width>416</width>
+        <height>1</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_close">
+      <property name="geometry">
+       <rect>
+        <x>368</x>
+        <y>12</y>
+        <width>32</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_Warn">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>78</y>
+        <width>331</width>
+        <height>61</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>删除该设备,“执行计划”中与之对应的计划也会删除!</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_cancel">
+      <property name="geometry">
+       <rect>
+        <x>248</x>
+        <y>153</y>
+        <width>60</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>取消</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_ok">
+      <property name="geometry">
+       <rect>
+        <x>324</x>
+        <y>153</y>
+        <width>60</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>确定</string>
+      </property>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 112 - 112
common/warning/warning.cpp

@@ -1,112 +1,112 @@
-#include "warning.h"
-#include "ui_warning.h"
-
-#include <QPainter>
-#include <QLayout>
-#include <QDebug>
-
-
-#include "spdlog/spdlog.h"
-#include "oneshadow.h"
-
-Warning::Warning(QWidget *parent) :
-    QDialog(parent),
-    ui(new Ui::Warning)
-{
-    ui->setupUi(this);
-    /* 设置无边框和背景透明 */
-    this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
-    this->setAttribute(Qt::WA_TranslucentBackground);
-
-    /* 设置文字自动换行 */
-    ui->label_Warn->setWordWrap(true);
-    /* 设置文本居中 */
-    // ui->label_Warn->setAlignment(Qt::AlignCenter);
-    ui->label_Warn->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
-    /* 加载警告图标 */
-    ui->label_warnIcon->setStyleSheet(R"(border-image: url(:/ESM-8C_ICON/Tip/Tips2x.png);)");
-
-    /* 阴影宽度是16 */
-    this->layout()->setMargin(SHADOW_W);
-    m_shadow = new OneShadow(QSize(width() - SHADOW_W*2, height() - SHADOW_W*2),SHADOW_W);
-
-    connect(ui->pBtn_close,SIGNAL(clicked()),this,SLOT(close()));
-    connect(ui->pBtn_cancel,SIGNAL(clicked()),this,SLOT(close()));
-    connect(ui->pBtn_ok,SIGNAL(clicked()),this,SLOT(do_ok()));
-}
-
-Warning::~Warning()
-{
-    delete ui;
-}
-
-void Warning::setText(const QString &text)
-{
-    /* 根据文本大小设置高度 */
-    ui->label_Warn->setText(text);
-    /* 重新设置位置 */
-    resetLabelSize();
-    moveWarnICON();
-}
-
-/* 只有一个确定按钮 */
-void Warning::setTextWithOneButton(const QString &text)
-{
-    ui->pBtn_cancel->hide();
-    // ui->pBtn_ok->move(ui->pBtn_cancel->x(),ui->pBtn_cancel->y());
-    ui->label_Warn->setText(text);
-    /* 重新设置位置 */
-    resetLabelSize();
-    moveWarnICON();
-}
-
-void Warning::paintEvent(QPaintEvent *event)
-{
-    QPainter painter(this);
-    painter.setRenderHint(QPainter::Antialiasing);
-    /* 绘制阴影 */
-    painter.drawImage(QPoint(0,0),m_shadow->image());
-}
-
-
-
-void Warning::do_ok()
-{
-    emit signal_ok();
-    m_isOk = true;
-    this->close();
-}
-
-/**
- * @brief 重新设置显示文字的区域大小,主要是设置宽度,为计算出左侧的图标位置
- *        字号是18,每个汉字的宽度、高度都是18,行高是27。
- *        文字显示区域最大宽度是306,显示17个汉字。
- *        阴影宽度是16,需要加上阴影宽度的坐标。
- * 
- */
-void Warning::resetLabelSize()
-{
-    int TextCount = ui->label_Warn->text().count();
-    int width = TextCount * 18;
-    if(width > 306)
-    {
-        width = 306;
-    }
-    // ui->label_Warn->setFixedWidth(width);
-    ui->label_Warn->resize(width, ui->label_Warn->height());
-    /* ui->widget是布局确定的大小,获取它的大小不准确 */
-    int widgetWidth = this->width();
-    int x = (widgetWidth - width) / 2;
-    // int x = (widgetWidth - width - ui->label_warnIcon->width() - 12) / 2;
-    // x = x + ui->label_warnIcon->width() + 12; /* 加上图标的宽度,和图标之间的间距 */
-    ui->label_Warn->move(x, ui->label_Warn->y());
-}
-
-
-/* 移动警告图标 */
-void Warning::moveWarnICON()
-{
-    int x = ui->label_Warn->x() - ui->label_warnIcon->width() - 12;
-    int y = ui->label_Warn->y() + ui->label_Warn->height() / 2 - ui->label_warnIcon->height() / 2;
-    ui->label_warnIcon->move(x,y);
-}
+#include "warning.h"
+#include "ui_warning.h"
+
+#include <QPainter>
+#include <QLayout>
+#include <QDebug>
+
+
+#include "spdlog/spdlog.h"
+#include "oneshadow.h"
+
+Warning::Warning(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::Warning)
+{
+    ui->setupUi(this);
+    /* 设置无边框和背景透明 */
+    this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
+    this->setAttribute(Qt::WA_TranslucentBackground);
+
+    /* 设置文字自动换行 */
+    ui->label_Warn->setWordWrap(true);
+    /* 设置文本居中 */
+    // ui->label_Warn->setAlignment(Qt::AlignCenter);
+    ui->label_Warn->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+    /* 加载警告图标 */
+    ui->label_warnIcon->setStyleSheet(R"(border-image: url(:/ESM-8C_ICON/Tip/Tips2x.png);)");
+
+    /* 阴影宽度是16 */
+    this->layout()->setMargin(SHADOW_W);
+    m_shadow = new OneShadow(QSize(width() - SHADOW_W*2, height() - SHADOW_W*2),SHADOW_W);
+
+    connect(ui->pBtn_close,SIGNAL(clicked()),this,SLOT(close()));
+    connect(ui->pBtn_cancel,SIGNAL(clicked()),this,SLOT(close()));
+    connect(ui->pBtn_ok,SIGNAL(clicked()),this,SLOT(do_ok()));
+}
+
+Warning::~Warning()
+{
+    delete ui;
+}
+
+void Warning::setText(const QString &text)
+{
+    /* 根据文本大小设置高度 */
+    ui->label_Warn->setText(text);
+    /* 重新设置位置 */
+    resetLabelSize();
+    moveWarnICON();
+}
+
+/* 只有一个确定按钮 */
+void Warning::setTextWithOneButton(const QString &text)
+{
+    ui->pBtn_cancel->hide();
+    // ui->pBtn_ok->move(ui->pBtn_cancel->x(),ui->pBtn_cancel->y());
+    ui->label_Warn->setText(text);
+    /* 重新设置位置 */
+    resetLabelSize();
+    moveWarnICON();
+}
+
+void Warning::paintEvent(QPaintEvent *event)
+{
+    QPainter painter(this);
+    painter.setRenderHint(QPainter::Antialiasing);
+    /* 绘制阴影 */
+    painter.drawImage(QPoint(0,0),m_shadow->image());
+}
+
+
+
+void Warning::do_ok()
+{
+    emit signal_ok();
+    m_isOk = true;
+    this->close();
+}
+
+/**
+ * @brief 重新设置显示文字的区域大小,主要是设置宽度,为计算出左侧的图标位置
+ *        字号是18,每个汉字的宽度、高度都是18,行高是27。
+ *        文字显示区域最大宽度是306,显示17个汉字。
+ *        阴影宽度是16,需要加上阴影宽度的坐标。
+ * 
+ */
+void Warning::resetLabelSize()
+{
+    int TextCount = ui->label_Warn->text().count();
+    int width = TextCount * 18;
+    if(width > 306)
+    {
+        width = 306;
+    }
+    // ui->label_Warn->setFixedWidth(width);
+    ui->label_Warn->resize(width, ui->label_Warn->height());
+    /* ui->widget是布局确定的大小,获取它的大小不准确 */
+    int widgetWidth = this->width();
+    int x = (widgetWidth - width) / 2;
+    // int x = (widgetWidth - width - ui->label_warnIcon->width() - 12) / 2;
+    // x = x + ui->label_warnIcon->width() + 12; /* 加上图标的宽度,和图标之间的间距 */
+    ui->label_Warn->move(x, ui->label_Warn->y());
+}
+
+
+/* 移动警告图标 */
+void Warning::moveWarnICON()
+{
+    int x = ui->label_Warn->x() - ui->label_warnIcon->width() - 12;
+    int y = ui->label_Warn->y() + ui->label_Warn->height() / 2 - ui->label_warnIcon->height() / 2;
+    ui->label_warnIcon->move(x,y);
+}

+ 46 - 46
common/warning/warning.h

@@ -1,46 +1,46 @@
-#ifndef WARNING_H
-#define WARNING_H
-
-#include <QDialog>
-
-class OneShadow;
-
-namespace Ui {
-class Warning;
-}
-
-class Warning : public QDialog
-{
-    Q_OBJECT
-
-public:
-    explicit Warning(QWidget *parent = nullptr);
-    ~Warning();
-
-    void setText(const QString& text);
-    void setTextWithOneButton(const QString& text);     /* 只有一个确定按钮 */
-    bool isOk() const { return m_isOk; }
-signals:
-    void signal_ok();
-
-protected:
-    void paintEvent(QPaintEvent *event);
-
-private slots:
-    void do_ok();
-
-private:
-    /* 重新设置显示文字的区域大小 */
-    void resetLabelSize();
-    /* 移动警告图标 */
-    void moveWarnICON();
-
-private:
-    Ui::Warning *ui;
-
-    OneShadow* m_shadow = nullptr;
-    const int SHADOW_W = 16;                /* 阴影的大小 */
-    bool m_isOk = false;
-};
-
-#endif // WARNING_H
+#ifndef WARNING_H
+#define WARNING_H
+
+#include <QDialog>
+
+class OneShadow;
+
+namespace Ui {
+class Warning;
+}
+
+class Warning : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit Warning(QWidget *parent = nullptr);
+    ~Warning();
+
+    void setText(const QString& text);
+    void setTextWithOneButton(const QString& text);     /* 只有一个确定按钮 */
+    bool isOk() const { return m_isOk; }
+signals:
+    void signal_ok();
+
+protected:
+    void paintEvent(QPaintEvent *event);
+
+private slots:
+    void do_ok();
+
+private:
+    /* 重新设置显示文字的区域大小 */
+    void resetLabelSize();
+    /* 移动警告图标 */
+    void moveWarnICON();
+
+private:
+    Ui::Warning *ui;
+
+    OneShadow* m_shadow = nullptr;
+    const int SHADOW_W = 16;                /* 阴影的大小 */
+    bool m_isOk = false;
+};
+
+#endif // WARNING_H

+ 222 - 222
common/warning/warning.ui

@@ -1,222 +1,222 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Warning</class>
- <widget class="QDialog" name="Warning">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>440</width>
-    <height>302</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Dialog</string>
-  </property>
-  <property name="styleSheet">
-   <string notr="true">QDialog#Warning
-{
-background:transparent;
-}</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <property name="spacing">
-    <number>0</number>
-   </property>
-   <property name="leftMargin">
-    <number>16</number>
-   </property>
-   <property name="topMargin">
-    <number>16</number>
-   </property>
-   <property name="rightMargin">
-    <number>16</number>
-   </property>
-   <property name="bottomMargin">
-    <number>16</number>
-   </property>
-   <item>
-    <widget class="QWidget" name="widget" native="true">
-     <property name="styleSheet">
-      <string notr="true">QWidget{
-background: #FFFFFF;
-border-radius: 8px;
-font-family: 思源黑体R;
-font-weight: 400;
-font-size: 18px;
-color: #3A3F63;
-line-height: 21px;
-text-align: left;
-font-style: normal;
-}
-
-QLabel#label_NC1
-{
-font-family: 思源黑体M;
-font-weight: bold;
-font-size: 18px;
-color: #3A3F63;
-line-height: 27px;
-text-transform: uppercase;
-}
-
-QLabel#label_line
-{
-background: #E6E9F4;
-}
-
-QLabel#label_Warn
-{
-	font-family: 思源黑体R;
-	font-weight: 400;
-	font-size: 18px;
-	color: #3A3F63;
-	line-height: 27px;
-}
-
-QPushButton#pBtn_close{
-	border-image: url(:/ESM-8C_ICON/Dialog_close.png);
-}
-QPushButton#pBtn_close:hover{
-	
-	border-image: url(:/ESM-8C_ICON/Dialog_close2.png);
-}
-
-QPushButton
-{
-	background: #FFFFFF;
-	border: 1px solid #E6E9F4;
-	text-align: center;
-}
-
-
-/********* 普通方框按钮三种状态效果 *********/
-QPushButton#pBtn_cancel
-{
-    background: #FFFFFF;
-    border-radius: 16px;
-    border: 1px solid #E6E9F4;
-    color: #3A3F63;
-}
-QPushButton#pBtn_cancel:hover
-{
-    background: #FFFFFF;
-    border-radius: 16px;
-    border: 1px solid #4458FE;
-    color: #4458FE;
-}
-
-/********* 带有底色按钮三种状态效果 *********/
-QPushButton#pBtn_ok
-{
-    color:white;
-    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:1 #4F8AFF,stop:0 #4B5EFF);
-    border-radius: 16px;
-}
-
-QPushButton#pBtn_ok:hover
-{
-    color:white;
-    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:0 #5D73FF,stop:1 #6092FF);
-    border-radius: 16px;
-}
-</string>
-     </property>
-     <widget class="QLabel" name="label_NC1">
-      <property name="geometry">
-       <rect>
-        <x>32</x>
-        <y>18</y>
-        <width>90</width>
-        <height>18</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>提示</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_line">
-      <property name="geometry">
-       <rect>
-        <x>0</x>
-        <y>56</y>
-        <width>416</width>
-        <height>1</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_close">
-      <property name="geometry">
-       <rect>
-        <x>368</x>
-        <y>12</y>
-        <width>32</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_Warn">
-      <property name="geometry">
-       <rect>
-        <x>50</x>
-        <y>78</y>
-        <width>308</width>
-        <height>120</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>删除该设备,“执行计划”中与之对应的计划也会删除!</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_cancel">
-      <property name="geometry">
-       <rect>
-        <x>248</x>
-        <y>216</y>
-        <width>60</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>取消</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_ok">
-      <property name="geometry">
-       <rect>
-        <x>324</x>
-        <y>216</y>
-        <width>60</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>确定</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_warnIcon">
-      <property name="geometry">
-       <rect>
-        <x>10</x>
-        <y>130</y>
-        <width>20</width>
-        <height>20</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Warning</class>
+ <widget class="QDialog" name="Warning">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>440</width>
+    <height>302</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true">QDialog#Warning
+{
+background:transparent;
+}</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <property name="leftMargin">
+    <number>16</number>
+   </property>
+   <property name="topMargin">
+    <number>16</number>
+   </property>
+   <property name="rightMargin">
+    <number>16</number>
+   </property>
+   <property name="bottomMargin">
+    <number>16</number>
+   </property>
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <property name="styleSheet">
+      <string notr="true">QWidget{
+background: #FFFFFF;
+border-radius: 8px;
+font-family: 思源黑体R;
+font-weight: 400;
+font-size: 18px;
+color: #3A3F63;
+line-height: 21px;
+text-align: left;
+font-style: normal;
+}
+
+QLabel#label_NC1
+{
+font-family: 思源黑体M;
+font-weight: bold;
+font-size: 18px;
+color: #3A3F63;
+line-height: 27px;
+text-transform: uppercase;
+}
+
+QLabel#label_line
+{
+background: #E6E9F4;
+}
+
+QLabel#label_Warn
+{
+	font-family: 思源黑体R;
+	font-weight: 400;
+	font-size: 18px;
+	color: #3A3F63;
+	line-height: 27px;
+}
+
+QPushButton#pBtn_close{
+	border-image: url(:/ESM-8C_ICON/Dialog_close.png);
+}
+QPushButton#pBtn_close:hover{
+	
+	border-image: url(:/ESM-8C_ICON/Dialog_close2.png);
+}
+
+QPushButton
+{
+	background: #FFFFFF;
+	border: 1px solid #E6E9F4;
+	text-align: center;
+}
+
+
+/********* 普通方框按钮三种状态效果 *********/
+QPushButton#pBtn_cancel
+{
+    background: #FFFFFF;
+    border-radius: 16px;
+    border: 1px solid #E6E9F4;
+    color: #3A3F63;
+}
+QPushButton#pBtn_cancel:hover
+{
+    background: #FFFFFF;
+    border-radius: 16px;
+    border: 1px solid #4458FE;
+    color: #4458FE;
+}
+
+/********* 带有底色按钮三种状态效果 *********/
+QPushButton#pBtn_ok
+{
+    color:white;
+    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:1 #4F8AFF,stop:0 #4B5EFF);
+    border-radius: 16px;
+}
+
+QPushButton#pBtn_ok:hover
+{
+    color:white;
+    background: qlineargradient( x0:1,x1:1,y1:0,y2:0,stop:0 #5D73FF,stop:1 #6092FF);
+    border-radius: 16px;
+}
+</string>
+     </property>
+     <widget class="QLabel" name="label_NC1">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>18</y>
+        <width>90</width>
+        <height>18</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>提示</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_line">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>56</y>
+        <width>416</width>
+        <height>1</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_close">
+      <property name="geometry">
+       <rect>
+        <x>368</x>
+        <y>12</y>
+        <width>32</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_Warn">
+      <property name="geometry">
+       <rect>
+        <x>50</x>
+        <y>78</y>
+        <width>308</width>
+        <height>120</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>删除该设备,“执行计划”中与之对应的计划也会删除!</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_cancel">
+      <property name="geometry">
+       <rect>
+        <x>248</x>
+        <y>216</y>
+        <width>60</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>取消</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_ok">
+      <property name="geometry">
+       <rect>
+        <x>324</x>
+        <y>216</y>
+        <width>60</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>确定</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_warnIcon">
+      <property name="geometry">
+       <rect>
+        <x>10</x>
+        <y>130</y>
+        <width>20</width>
+        <height>20</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>