From 595ee7f98e42bc4133b5d8d92f72eb9e7e793c27 Mon Sep 17 00:00:00 2001 From: amass <168062547@qq.com> Date: Sun, 13 Aug 2023 15:05:35 +0800 Subject: [PATCH] Add library 'QtComponets'. --- CMakeLists.txt | 1 + HttpProxy/TemplateSegmentRule.h | 1 + QtComponets/CMakeLists.txt | 15 +++++++++++ QtComponets/QClassStdStream.cpp | 47 +++++++++++++++++++++++++++++++++ QtComponets/QClassStdStream.h | 25 ++++++++++++++++++ resource/deploy.sh | 34 ++++++++++++++++++++++-- 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 QtComponets/CMakeLists.txt create mode 100644 QtComponets/QClassStdStream.cpp create mode 100644 QtComponets/QClassStdStream.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 94a3430..7f96d4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,4 +11,5 @@ set(ZeroMQ_LIBRARIES zmq) add_subdirectory(AsioZeroMQ) add_subdirectory(Encrypt) add_subdirectory(HttpProxy) +add_subdirectory(QtComponets) add_subdirectory(Universal) \ No newline at end of file diff --git a/HttpProxy/TemplateSegmentRule.h b/HttpProxy/TemplateSegmentRule.h index 98d78b3..ea733c3 100644 --- a/HttpProxy/TemplateSegmentRule.h +++ b/HttpProxy/TemplateSegmentRule.h @@ -7,6 +7,7 @@ #include #include #include +#include class TemplateSegment { friend class TemplateSegmentRule; diff --git a/QtComponets/CMakeLists.txt b/QtComponets/CMakeLists.txt new file mode 100644 index 0000000..adda7ca --- /dev/null +++ b/QtComponets/CMakeLists.txt @@ -0,0 +1,15 @@ +find_package(Qt6 COMPONENTS Gui REQUIRED) + +set(CMAKE_AUTOMOC ON) + +add_library(QtComponets + QClassStdStream.h QClassStdStream.cpp +) + +target_include_directories(QtComponets + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries(QtComponets + PUBLIC Qt6::Gui +) \ No newline at end of file diff --git a/QtComponets/QClassStdStream.cpp b/QtComponets/QClassStdStream.cpp new file mode 100644 index 0000000..d2e9bbb --- /dev/null +++ b/QtComponets/QClassStdStream.cpp @@ -0,0 +1,47 @@ +#include "QClassStdStream.h" + +namespace std { +std::ostream &operator<<(std::ostream &stream, const QSize &element) { + stream << "QSize(" << element.width() << "," << element.height() << ")"; + return stream; +} + +std::ostream &operator<<(std::ostream &stream, const QPoint &element) { + stream << "QPoint(" << element.x() << "," << element.y() << ")"; + return stream; +} + +std::ostream &operator<<(std::ostream &stream, const QPointF &element) { + stream << "QPointF(" << element.x() << "," << element.y() << ")"; + return stream; +} + +std::ostream &operator<<(std::ostream &stream, const QString &element) { + stream << element.toStdString(); + return stream; +} + +std::ostream &operator<<(std::ostream &stream, const QStringList &element) { + stream << "["; + for (auto &str : element) { + stream << str << ", "; + } + stream << "]"; + return stream; +} + +std::ostream &operator<<(std::ostream &stream, const QImage::Format &element) { + switch (element) { + case QImage::Format_RGB32: + stream << "Format_RGB32"; + break; + case QImage::Format_RGBA8888: + stream << "Format_RGBA8888"; + break; + default: + stream << "unknown format: " << (int)element; + break; + } + return stream; +} +} // namespace std diff --git a/QtComponets/QClassStdStream.h b/QtComponets/QClassStdStream.h new file mode 100644 index 0000000..da60eb8 --- /dev/null +++ b/QtComponets/QClassStdStream.h @@ -0,0 +1,25 @@ +#ifndef QCLASSSTDSTREAM_H +#define QCLASSSTDSTREAM_H + +#include +#include +#include +#include + +namespace std { + +inline std::ostream &operator<<(std::ostream &stream, const QVector3D &element) { + stream << "(" << element.x() << "," << element.y() << "," << element.z() << ")"; + return stream; +} + +std::ostream &operator<<(std::ostream &stream, const QString &element); +std::ostream &operator<<(std::ostream &stream, const QStringList &element); + +std::ostream &operator<<(std::ostream &stream, const QPoint &element); +std::ostream &operator<<(std::ostream &stream, const QPointF &element); +std::ostream &operator<<(std::ostream &stream, const QSize &element); +std::ostream &operator<<(std::ostream &stream, const QImage::Format &element); +} // namespace std + +#endif // QCLASSSTDSTREAM_H diff --git a/resource/deploy.sh b/resource/deploy.sh index 1c511ea..c6b4339 100644 --- a/resource/deploy.sh +++ b/resource/deploy.sh @@ -9,6 +9,35 @@ else fi echo "build directory: $build_path" +if [ -d "/opt/Qt/6.5.2/gcc_64" ]; then + qt_prefix_path="/opt/Qt/6.5.2/gcc_64" + cmake_qt_parameters="-DCMAKE_PREFIX_PATH=${qt_prefix_path} \ + -DQT_QMAKE_EXECUTABLE=${qt_prefix_path}/bin/qmake \ + -DQT_DIR=${qt_prefix_path}/lib/cmake/Qt6 \ + -DQt6_DIR=${qt_prefix_path}/lib/cmake/Qt6 \ + -DQt6Core_DIR=${qt_prefix_path}/lib/cmake/Qt6Core \ + -DQt6Gui_DIR=${qt_prefix_path}/lib/cmake/Qt6Gui \ + -DQt6Qml_DIR=${qt_prefix_path}/lib/cmake/Qt6Qml \ + -DQt6Widgets_DIR=${qt_prefix_path}/lib/cmake/Qt6Widgets \ + -DQt6Quick_DIR=${qt_prefix_path}/lib/cmake/Qt6Quick \ + -DQt6Svg_DIR=${qt_prefix_path}/lib/cmake/Qt6Svg " +elif [ -d "/opt/Qt/5.15.2/gcc_64" ]; then + qt_prefix_path="/opt/Qt/5.15.2/gcc_64" + cmake_qt_parameters="-DCMAKE_PREFIX_PATH=${qt_prefix_path} \ + -DQT_QMAKE_EXECUTABLE=${qt_prefix_path}/bin/qmake \ + -DQT_DIR=${qt_prefix_path}/lib/cmake/Qt5 \ + -DQt5_DIR=${qt_prefix_path}/lib/cmake/Qt5 \ + -DQt5Core_DIR=${qt_prefix_path}/lib/cmake/Qt5Core \ + -DQt5Gui_DIR=${qt_prefix_path}/lib/cmake/Qt5Gui \ + -DQt5Qml_DIR=${qt_prefix_path}/lib/cmake/Qt5Qml \ + -DQt5Widgets_DIR=${qt_prefix_path}/lib/cmake/Qt5Widgets \ + -DQt5Quick_DIR=${qt_prefix_path}/lib/cmake/Qt5Quick \ + -DQt5Svg_DIR=${qt_prefix_path}/lib/cmake/Qt5Svg " +else + cmake_qt_parameters="" + echo "please install qt6.5.2 or qt5.15.2 ..." +fi + function cmake_scan() { if [ ! -d ${build_path} ]; then mkdir ${build_path} @@ -18,8 +47,9 @@ function cmake_scan() { -S ${base_path} \ -B ${build_path} \ -DCMAKE_BUILD_TYPE=Debug \ - -DBOOST_ROOT=${libraries_root}/boost_1_82_0 \ - -DZeroMQ_ROOT=${libraries_root}/zeromq-4.3.4_debug + -DBOOST_ROOT=${libraries_root}/boost_1_83_0 \ + -DZeroMQ_ROOT=${libraries_root}/zeromq-4.3.4_debug \ + ${cmake_qt_parameters} } function build() {