From e943272e3c0bf1375ceee4f16c05f5a5974f9782 Mon Sep 17 00:00:00 2001 From: Irony <892768447@qq.com> Date: Sat, 27 Apr 2024 23:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test(Wrapper):=20Wrapper=20for?= =?UTF-8?q?=20sip=20and=20shiboken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 760 ++++++++++++++++++ Test/WigglyWidget/CMakeLists.txt | 8 + .../LibWigglyWidget/CMakeLists.txt | 36 + .../LibWigglyWidget/WigglyWidget_global.h | 12 + .../LibWigglyWidget/wigglywidget.cpp | 50 ++ .../LibWigglyWidget/wigglywidget.h | 28 + Test/WigglyWidget/PyQtWrapper/CMakeLists.txt | 3 + .../WigglyWidget/PySideWrapper/CMakeLists.txt | 11 + .../PySideWrapper/TestWigglyWidget.py | 41 + Test/WigglyWidget/PySideWrapper/bindings.h | 4 + .../PySideWrapper/bindings.txt.in | 13 + Test/WigglyWidget/PySideWrapper/bindings.xml | 5 + Test/WigglyWidget/PySideWrapper/generated.bat | 0 Test/WigglyWidget/PySideWrapper/generated.sh | 0 .../PySideWrapper/requirements.txt | 9 + .../TestWigglyWidget/CMakeLists.txt | 61 ++ Test/WigglyWidget/TestWigglyWidget/main.cpp | 11 + 17 files changed, 1052 insertions(+) create mode 100644 Test/WigglyWidget/CMakeLists.txt create mode 100644 Test/WigglyWidget/LibWigglyWidget/CMakeLists.txt create mode 100644 Test/WigglyWidget/LibWigglyWidget/WigglyWidget_global.h create mode 100644 Test/WigglyWidget/LibWigglyWidget/wigglywidget.cpp create mode 100644 Test/WigglyWidget/LibWigglyWidget/wigglywidget.h create mode 100644 Test/WigglyWidget/PyQtWrapper/CMakeLists.txt create mode 100644 Test/WigglyWidget/PySideWrapper/CMakeLists.txt create mode 100644 Test/WigglyWidget/PySideWrapper/TestWigglyWidget.py create mode 100644 Test/WigglyWidget/PySideWrapper/bindings.h create mode 100644 Test/WigglyWidget/PySideWrapper/bindings.txt.in create mode 100644 Test/WigglyWidget/PySideWrapper/bindings.xml create mode 100644 Test/WigglyWidget/PySideWrapper/generated.bat create mode 100644 Test/WigglyWidget/PySideWrapper/generated.sh create mode 100644 Test/WigglyWidget/PySideWrapper/requirements.txt create mode 100644 Test/WigglyWidget/TestWigglyWidget/CMakeLists.txt create mode 100644 Test/WigglyWidget/TestWigglyWidget/main.cpp diff --git a/.gitignore b/.gitignore index 9f409db..812f985 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,763 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python,qt,qtcreator,visualstudiocode,visualstudio,macos,linux,windows,cmake +# Edit at https://www.toptal.com/developers/gitignore?templates=python,qt,qtcreator,visualstudiocode,visualstudio,macos,linux,windows,cmake + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +### Qt ### +# C++ objects and libs +*.slo +*.lo +*.o +*.a +*.la +*.lai +*.so.* +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +*.qmlc +*.jsc +Makefile* +*build-* +*.qm +*.prl + +# Qt unit tests +target_wrapper.* + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* + +# QtCreator 4.8< compilation database + +# QtCreator local machine specific files for imported projects +*creator.user* + +*_qmlcache.qrc + +### QtCreator ### +# gitignore for Qt Creator like IDE for pure C/C++ project without Qt +# +# Reference: http://doc.qt.io/qtcreator/creator-project-generic.html + + + +# Qt Creator autogenerated files + + +# A listing of all the files included in the project +*.files + +# Include directories +*.includes + +# Project configuration settings like predefined Macros +*.config + +# Qt Creator settings +*.creator + +# User project settings +*.creator.user* + +# Qt Creator backups + +# Flags for Clang Code Model +*.cxxflags +*.cflags + + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +*.code-workspace + +# Local History for Visual Studio Code + +# Windows Installer files from build outputs + +# JetBrains Rider +*.sln.iml + +### VisualStudio Patch ### +# Additional files built by Visual Studio + +# End of https://www.toptal.com/developers/gitignore/api/python,qt,qtcreator,visualstudiocode,visualstudio,macos,linux,windows,cmake + # Byte-compiled / optimized / DLL files __pycache__/ *.py[co] diff --git a/Test/WigglyWidget/CMakeLists.txt b/Test/WigglyWidget/CMakeLists.txt new file mode 100644 index 0000000..41beb60 --- /dev/null +++ b/Test/WigglyWidget/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.14) + +project(WigglyWidget LANGUAGES CXX) + +add_subdirectory(LibWigglyWidget) +add_subdirectory(TestWigglyWidget) +add_subdirectory(PyQtWrapper) +add_subdirectory(PySideWrapper) diff --git a/Test/WigglyWidget/LibWigglyWidget/CMakeLists.txt b/Test/WigglyWidget/LibWigglyWidget/CMakeLists.txt new file mode 100644 index 0000000..f987465 --- /dev/null +++ b/Test/WigglyWidget/LibWigglyWidget/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.14) + +project(LibWigglyWidget LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# 配置安装目录 +set(CMAKE_INSTALL_DIR "${CMAKE_SOURCE_DIR}/dist") + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) + +add_library(LibWigglyWidget SHARED WigglyWidget_global.h wigglywidget.cpp + wigglywidget.h) + +target_link_libraries(LibWigglyWidget PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) + +target_compile_definitions(LibWigglyWidget PRIVATE LIBWIGGLYWIDGET_LIBRARY) + +# 配置生成的文件安装目录 +install( + TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION "${CMAKE_INSTALL_DIR}/bin" + LIBRARY DESTINATION "${CMAKE_INSTALL_DIR}/lib" + ARCHIVE DESTINATION "${CMAKE_INSTALL_DIR}/lib") + +install(FILES wigglywidget.h DESTINATION "${CMAKE_INSTALL_DIR}/include") + +message( + NOTICE + "****${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS}" +) diff --git a/Test/WigglyWidget/LibWigglyWidget/WigglyWidget_global.h b/Test/WigglyWidget/LibWigglyWidget/WigglyWidget_global.h new file mode 100644 index 0000000..f82001e --- /dev/null +++ b/Test/WigglyWidget/LibWigglyWidget/WigglyWidget_global.h @@ -0,0 +1,12 @@ +#ifndef WIGGLYWIDGET_GLOBAL_H +#define WIGGLYWIDGET_GLOBAL_H + +#include + +#if defined(WIGGLYWIDGET_LIBRARY) +#define WIGGLYWIDGET_EXPORT Q_DECL_EXPORT +#else +#define WIGGLYWIDGET_EXPORT Q_DECL_IMPORT +#endif + +#endif // WIGGLYWIDGET_GLOBAL_H diff --git a/Test/WigglyWidget/LibWigglyWidget/wigglywidget.cpp b/Test/WigglyWidget/LibWigglyWidget/wigglywidget.cpp new file mode 100644 index 0000000..0433fc1 --- /dev/null +++ b/Test/WigglyWidget/LibWigglyWidget/wigglywidget.cpp @@ -0,0 +1,50 @@ +#include "wigglywidget.h" + +#include +#include +#include + +WigglyWidget::WigglyWidget(QWidget *parent) : QWidget(parent), step(0) { + setBackgroundRole(QPalette::Midlight); + setAutoFillBackground(true); + + QFont newFont = font(); + newFont.setPointSize(newFont.pointSize() + 20); + setFont(newFont); + + timer.start(60, this); +} + +void WigglyWidget::setText(const QString &newText) { text = newText; } + +void WigglyWidget::paintEvent(QPaintEvent * /* event */) + +{ + static constexpr int sineTable[16] = {0, 38, 71, 92, 100, 92, 71, 38, + 0, -38, -71, -92, -100, -92, -71, -38}; + + QFontMetrics metrics(font()); + int x = (width() - metrics.horizontalAdvance(text)) / 2; + int y = (height() + metrics.ascent() - metrics.descent()) / 2; + QColor color; + + QPainter painter(this); + + for (int i = 0; i < text.size(); ++i) { + int index = (step + i) % 16; + color.setHsv((15 - index) * 16, 255, 191); + painter.setPen(color); + painter.drawText(x, y - ((sineTable[index] * metrics.height()) / 400), + QString(text[i])); + x += metrics.horizontalAdvance(text[i]); + } +} + +void WigglyWidget::timerEvent(QTimerEvent *event) { + if (event->timerId() == timer.timerId()) { + ++step; + update(); + } else { + QWidget::timerEvent(event); + } +} diff --git a/Test/WigglyWidget/LibWigglyWidget/wigglywidget.h b/Test/WigglyWidget/LibWigglyWidget/wigglywidget.h new file mode 100644 index 0000000..b1eff02 --- /dev/null +++ b/Test/WigglyWidget/LibWigglyWidget/wigglywidget.h @@ -0,0 +1,28 @@ +#ifndef WIGGLYWIDGET_H +#define WIGGLYWIDGET_H + +#include +#include + +#include "WigglyWidget_global.h" + +class WIGGLYWIDGET_EXPORT WigglyWidget : public QWidget { + Q_OBJECT + + public: + WigglyWidget(QWidget *parent = nullptr); + + public slots: + void setText(const QString &newText); + + protected: + virtual void paintEvent(QPaintEvent *event) override; + virtual void timerEvent(QTimerEvent *event) override; + + private: + QBasicTimer timer; + QString text; + int step; +}; + +#endif // WIGGLYWIDGET_H diff --git a/Test/WigglyWidget/PyQtWrapper/CMakeLists.txt b/Test/WigglyWidget/PyQtWrapper/CMakeLists.txt new file mode 100644 index 0000000..8218c32 --- /dev/null +++ b/Test/WigglyWidget/PyQtWrapper/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) + +project(PyQtWrapper) diff --git a/Test/WigglyWidget/PySideWrapper/CMakeLists.txt b/Test/WigglyWidget/PySideWrapper/CMakeLists.txt new file mode 100644 index 0000000..73d64eb --- /dev/null +++ b/Test/WigglyWidget/PySideWrapper/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.14) + +project(PySideWrapper) + +set(BINDINGS_HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/bindings.h") +set(BINDINGS_TYPESYSTEM_FILE "${CMAKE_CURRENT_SOURCE_DIR}/bindings.xml") +set(BINDINGS_OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dist") +set(BINDINGS_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../dist/include/") + +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/bindings.txt.in" + "${CMAKE_CURRENT_SOURCE_DIR}/bindings.txt") diff --git a/Test/WigglyWidget/PySideWrapper/TestWigglyWidget.py b/Test/WigglyWidget/PySideWrapper/TestWigglyWidget.py new file mode 100644 index 0000000..fec5200 --- /dev/null +++ b/Test/WigglyWidget/PySideWrapper/TestWigglyWidget.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Created on 2024/04/26 +@author: Irony +@site: https://pyqt.site | https://github.com/PyQt5 +@email: 892768447@qq.com +@file: TestWigglyWidget.py +@description: +""" + +import os +import sys + + +from PySide2.QtWidgets import QApplication, QLineEdit, QVBoxLayout, QWidget +from PySide2.WigglyWidget import WigglyWidget + +class TestWigglyWidget(QWidget): + def __init__(self, *args, **kwargs): + super(TestWigglyWidget, self).__init__(*args, **kwargs) + self._layout = QVBoxLayout(self) + self._lineEdit = QLineEdit(self) + self._wigglyWidget = WigglyWidget(self) + self._layout.addWidget(self._lineEdit) + self._layout.addWidget(self._wigglyWidget) + + self._lineEdit.textChanged.connect(self._wigglyWidget.setText) + self._lineEdit.setText("pyqt.site") + + +if __name__ == "__main__": + import cgitb + import sys + + cgitb.enable(format="text") + app = QApplication(sys.argv) + w = TestWigglyWidget() + w.show() + sys.exit(app.exec_()) diff --git a/Test/WigglyWidget/PySideWrapper/bindings.h b/Test/WigglyWidget/PySideWrapper/bindings.h new file mode 100644 index 0000000..0634a4b --- /dev/null +++ b/Test/WigglyWidget/PySideWrapper/bindings.h @@ -0,0 +1,4 @@ +#ifndef BINDINGS_H +#define BINDINGS_H +#include "wigglywidget.h" +#endif // BINDINGS_H diff --git a/Test/WigglyWidget/PySideWrapper/bindings.txt.in b/Test/WigglyWidget/PySideWrapper/bindings.txt.in new file mode 100644 index 0000000..d1bb8a4 --- /dev/null +++ b/Test/WigglyWidget/PySideWrapper/bindings.txt.in @@ -0,0 +1,13 @@ +[generator-project] +generator-set = shiboken +header-file = ${BINDINGS_HEADER_FILE} +typesystem-file = ${BINDINGS_TYPESYSTEM_FILE} +output-directory = ${BINDINGS_OUTPUT_DIR} +include-path = ${BINDINGS_INCLUDE_PATH} +framework-include-paths = +typesystem-paths = ${BINDINGS_TYPESYSTEM_PATH} + +enable-parent-ctor-heuristic +enable-pyside-extensions +enable-return-value-heuristic +use-isnull-as-nb_nonzero diff --git a/Test/WigglyWidget/PySideWrapper/bindings.xml b/Test/WigglyWidget/PySideWrapper/bindings.xml new file mode 100644 index 0000000..c3a3129 --- /dev/null +++ b/Test/WigglyWidget/PySideWrapper/bindings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Test/WigglyWidget/PySideWrapper/generated.bat b/Test/WigglyWidget/PySideWrapper/generated.bat new file mode 100644 index 0000000..e69de29 diff --git a/Test/WigglyWidget/PySideWrapper/generated.sh b/Test/WigglyWidget/PySideWrapper/generated.sh new file mode 100644 index 0000000..e69de29 diff --git a/Test/WigglyWidget/PySideWrapper/requirements.txt b/Test/WigglyWidget/PySideWrapper/requirements.txt new file mode 100644 index 0000000..d3ee81f --- /dev/null +++ b/Test/WigglyWidget/PySideWrapper/requirements.txt @@ -0,0 +1,9 @@ +PySide2 + +https://download.qt.io/official_releases/QtForPython/shiboken2-generator/shiboken2_generator-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-none-win_amd64.whl; platform_machine == "x86_64" and platform_system == "Windows" + +https://download.qt.io/official_releases/QtForPython/shiboken2-generator/shiboken2_generator-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-none-win32.whl; platform_machine == "i686" and platform_system == "Windows" + +https://download.qt.io/official_releases/QtForPython/shiboken2-generator/shiboken2_generator-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-manylinux1_x86_64.whl; platform_machine == "x86_64" and platform_system == "Linux" + +https://download.qt.io/official_releases/QtForPython/shiboken2-generator/shiboken2_generator-5.15.2.1-5.15.2-cp35.cp36.cp37.cp38.cp39.cp310-abi3-macosx_10_13_intel.whl; platform_machine == "x86_64" and platform_system == "Darwin" diff --git a/Test/WigglyWidget/TestWigglyWidget/CMakeLists.txt b/Test/WigglyWidget/TestWigglyWidget/CMakeLists.txt new file mode 100644 index 0000000..9ab36f9 --- /dev/null +++ b/Test/WigglyWidget/TestWigglyWidget/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required(VERSION 3.5) + +project( + TestWigglyWidget + VERSION 0.1 + LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# 配置安装目录 +set(CMAKE_INSTALL_DIR "${CMAKE_SOURCE_DIR}/dist") + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) + +include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../LibWigglyWidget") + +set(PROJECT_SOURCES main.cpp) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(${PROJECT_NAME} MANUAL_FINALIZATION ${PROJECT_SOURCES}) + # Define target properties for Android with Qt 6 as: set_property(TARGET + # TestWigglyWidget APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR + # ${CMAKE_CURRENT_SOURCE_DIR}/android) For more information, see + # https://doc.qt.io/qt-6/qt-add-executable.html#target-creation +else() + if(ANDROID) + add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCES}) + # Define properties for Android with Qt 5 after find_package() calls as: + # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") + else() + add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) + endif() +endif() + +target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets + LibWigglyWidget) + +# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. If +# you are developing for iOS or macOS you should consider setting an explicit, +# fixed bundle identifier manually though. +if(${QT_VERSION} VERSION_LESS 6.1.0) + set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER + com.example.TestWigglyWidget) +endif() +set_target_properties( + ${PROJECT_NAME} + PROPERTIES ${BUNDLE_ID_OPTION} MACOSX_BUNDLE_BUNDLE_VERSION + ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING + ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE + TRUE WIN32_EXECUTABLE + TRUE) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(${PROJECT_NAME}) +endif() diff --git a/Test/WigglyWidget/TestWigglyWidget/main.cpp b/Test/WigglyWidget/TestWigglyWidget/main.cpp new file mode 100644 index 0000000..a74498e --- /dev/null +++ b/Test/WigglyWidget/TestWigglyWidget/main.cpp @@ -0,0 +1,11 @@ +#include + +#include "wigglywidget.h" + +int main(int argc, char *argv[]) { + QApplication a(argc, argv); + WigglyWidget w; + w.setText("pyqt.site"); + w.show(); + return a.exec(); +}