From 07d3684eed7621b4209a163de7c53eef629d0017 Mon Sep 17 00:00:00 2001 From: XMuli Date: Thu, 20 Oct 2022 16:23:15 +0800 Subject: [PATCH] feat: QToolButtonAutoRaiseEx --- .../CMakeAutoRaise/.gitignore | 73 +++++++++++++++++++ .../CMakeAutoRaise/CMakeLists.txt | 65 +++++++++++++++++ .../CMakeAutoRaise/icons/normal/arrow.svg | 1 + .../CMakeAutoRaise/icons/normal/copy.svg | 1 + .../CMakeAutoRaise/icons/normal/download.svg | 1 + .../CMakeAutoRaise/icons/normal/ellipse.svg | 1 + .../CMakeAutoRaise/icons/normal/exit.svg | 1 + .../icons/normal/fill-ellipse.svg | 1 + .../CMakeAutoRaise/icons/normal/fill-rect.svg | 1 + .../CMakeAutoRaise/icons/normal/gif.svg | 1 + .../CMakeAutoRaise/icons/normal/line.svg | 1 + .../CMakeAutoRaise/icons/normal/mosaic.svg | 1 + .../CMakeAutoRaise/icons/normal/pen.svg | 1 + .../CMakeAutoRaise/icons/normal/recover.svg | 1 + .../CMakeAutoRaise/icons/normal/rectangle.svg | 1 + .../CMakeAutoRaise/icons/normal/revoke.svg | 1 + .../CMakeAutoRaise/icons/normal/right.svg | 1 + .../icons/normal/screenshot.svg | 1 + .../CMakeAutoRaise/icons/normal/text.svg | 1 + .../CMakeAutoRaise/icons/normal/update.svg | 1 + .../CMakeAutoRaise/icons/tool/arrow.svg | 8 ++ .../CMakeAutoRaise/icons/tool/cancel.svg | 9 +++ .../CMakeAutoRaise/icons/tool/ellipse.svg | 8 ++ .../CMakeAutoRaise/icons/tool/finish.svg | 8 ++ .../CMakeAutoRaise/icons/tool/gif.svg | 8 ++ .../CMakeAutoRaise/icons/tool/mosaic.svg | 8 ++ .../CMakeAutoRaise/icons/tool/pen.svg | 10 +++ .../CMakeAutoRaise/icons/tool/pin.svg | 1 + .../CMakeAutoRaise/icons/tool/rectangle.svg | 8 ++ .../CMakeAutoRaise/icons/tool/renewal.svg | 11 +++ .../CMakeAutoRaise/icons/tool/revocation.svg | 11 +++ .../CMakeAutoRaise/icons/tool/save.svg | 12 +++ .../icons/tool/serialnumber.svg | 8 ++ .../CMakeAutoRaise/icons/tool/smooth.svg | 8 ++ .../CMakeAutoRaise/icons/tool/text.svg | 8 ++ .../CMakeAutoRaise/main.cpp | 28 +++++++ .../CMakeAutoRaise/resources.qrc | 37 ++++++++++ .../CMakeAutoRaise/testbtstyle.cpp | 62 ++++++++++++++++ .../CMakeAutoRaise/testbtstyle.h | 23 ++++++ .../CMakeAutoRaise/widget.cpp | 11 +++ .../CMakeAutoRaise/widget.h | 14 ++++ .../QMakeAutoRaise/.gitignore | 73 +++++++++++++++++++ .../QMakeAutoRaise/QMakeAutoRaise.pro | 26 +++++++ .../QMakeAutoRaise/icons/normal/arrow.svg | 1 + .../QMakeAutoRaise/icons/normal/copy.svg | 1 + .../QMakeAutoRaise/icons/normal/download.svg | 1 + .../QMakeAutoRaise/icons/normal/ellipse.svg | 1 + .../QMakeAutoRaise/icons/normal/exit.svg | 1 + .../icons/normal/fill-ellipse.svg | 1 + .../QMakeAutoRaise/icons/normal/fill-rect.svg | 1 + .../QMakeAutoRaise/icons/normal/gif.svg | 1 + .../QMakeAutoRaise/icons/normal/line.svg | 1 + .../QMakeAutoRaise/icons/normal/mosaic.svg | 1 + .../QMakeAutoRaise/icons/normal/pen.svg | 1 + .../QMakeAutoRaise/icons/normal/recover.svg | 1 + .../QMakeAutoRaise/icons/normal/rectangle.svg | 1 + .../QMakeAutoRaise/icons/normal/revoke.svg | 1 + .../QMakeAutoRaise/icons/normal/right.svg | 1 + .../icons/normal/screenshot.svg | 1 + .../QMakeAutoRaise/icons/normal/text.svg | 1 + .../QMakeAutoRaise/icons/normal/update.svg | 1 + .../QMakeAutoRaise/icons/tool/arrow.svg | 8 ++ .../QMakeAutoRaise/icons/tool/cancel.svg | 9 +++ .../QMakeAutoRaise/icons/tool/ellipse.svg | 8 ++ .../QMakeAutoRaise/icons/tool/finish.svg | 8 ++ .../QMakeAutoRaise/icons/tool/gif.svg | 8 ++ .../QMakeAutoRaise/icons/tool/mosaic.svg | 8 ++ .../QMakeAutoRaise/icons/tool/pen.svg | 10 +++ .../QMakeAutoRaise/icons/tool/pin.svg | 1 + .../QMakeAutoRaise/icons/tool/rectangle.svg | 8 ++ .../QMakeAutoRaise/icons/tool/renewal.svg | 11 +++ .../QMakeAutoRaise/icons/tool/revocation.svg | 11 +++ .../QMakeAutoRaise/icons/tool/save.svg | 12 +++ .../icons/tool/serialnumber.svg | 8 ++ .../QMakeAutoRaise/icons/tool/smooth.svg | 8 ++ .../QMakeAutoRaise/icons/tool/text.svg | 8 ++ .../QMakeAutoRaise/main.cpp | 16 ++++ .../QMakeAutoRaise/resources.qrc | 37 ++++++++++ .../QMakeAutoRaise/testbtstyle.cpp | 60 +++++++++++++++ .../QMakeAutoRaise/testbtstyle.h | 23 ++++++ .../QMakeAutoRaise/widget.cpp | 11 +++ .../QMakeAutoRaise/widget.h | 14 ++++ 82 files changed, 861 insertions(+) create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/.gitignore create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/CMakeLists.txt create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/arrow.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/copy.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/download.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/ellipse.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/exit.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-ellipse.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-rect.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/gif.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/line.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/mosaic.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/pen.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/recover.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/rectangle.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/revoke.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/right.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/screenshot.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/text.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/update.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/arrow.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/cancel.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/ellipse.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/finish.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/gif.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/mosaic.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pen.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pin.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/rectangle.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/renewal.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/revocation.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/save.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/serialnumber.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/smooth.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/text.svg create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/main.cpp create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/resources.qrc create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.cpp create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.h create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.cpp create mode 100644 QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.h create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/.gitignore create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/QMakeAutoRaise.pro create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/arrow.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/copy.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/download.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/ellipse.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/exit.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-ellipse.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-rect.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/gif.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/line.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/mosaic.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/pen.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/recover.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/rectangle.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/revoke.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/right.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/screenshot.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/text.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/update.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/arrow.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/cancel.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/ellipse.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/finish.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/gif.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/mosaic.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pen.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pin.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/rectangle.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/renewal.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/revocation.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/save.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/serialnumber.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/smooth.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/text.svg create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/main.cpp create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/resources.qrc create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.cpp create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.h create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.cpp create mode 100644 QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.h diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/.gitignore b/QToolButtonAutoRaiseEx/CMakeAutoRaise/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/CMakeLists.txt b/QToolButtonAutoRaiseEx/CMakeAutoRaise/CMakeLists.txt new file mode 100644 index 0000000..0cc5f5a --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/CMakeLists.txt @@ -0,0 +1,65 @@ +cmake_minimum_required(VERSION 3.5) + +project(CMakeAutoRaise VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) + +set(PROJECT_SOURCES + main.cpp + widget.cpp + widget.h + resources.qrc + testbtstyle.h + testbtstyle.cpp +) + +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(CMakeAutoRaise + MANUAL_FINALIZATION + ${PROJECT_SOURCES} + ) +# Define target properties for Android with Qt 6 as: +# set_property(TARGET CMakeAutoRaise 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(CMakeAutoRaise 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(CMakeAutoRaise + ${PROJECT_SOURCES} + ) + endif() +endif() + +target_link_libraries(CMakeAutoRaise PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) + +set_target_properties(CMakeAutoRaise PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE TRUE + WIN32_EXECUTABLE TRUE +) + +install(TARGETS CMakeAutoRaise + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(CMakeAutoRaise) +endif() diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/arrow.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/arrow.svg new file mode 100644 index 0000000..470baef --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/copy.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/copy.svg new file mode 100644 index 0000000..b71c472 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/copy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/download.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/download.svg new file mode 100644 index 0000000..e9333ee --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/download.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/ellipse.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/ellipse.svg new file mode 100644 index 0000000..68f7d2a --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/ellipse.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/exit.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/exit.svg new file mode 100644 index 0000000..ce0ac4e --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/exit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-ellipse.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-ellipse.svg new file mode 100644 index 0000000..3445697 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-ellipse.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-rect.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-rect.svg new file mode 100644 index 0000000..6f511dc --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/fill-rect.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/gif.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/gif.svg new file mode 100644 index 0000000..2099da9 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/gif.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/line.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/line.svg new file mode 100644 index 0000000..adb34e5 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/line.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/mosaic.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/mosaic.svg new file mode 100644 index 0000000..812a3bc --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/mosaic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/pen.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/pen.svg new file mode 100644 index 0000000..7737451 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/pen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/recover.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/recover.svg new file mode 100644 index 0000000..a8104c5 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/recover.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/rectangle.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/rectangle.svg new file mode 100644 index 0000000..214cadd --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/rectangle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/revoke.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/revoke.svg new file mode 100644 index 0000000..c90aad0 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/revoke.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/right.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/right.svg new file mode 100644 index 0000000..adf763b --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/screenshot.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/screenshot.svg new file mode 100644 index 0000000..fd42674 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/screenshot.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/text.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/text.svg new file mode 100644 index 0000000..17a2dc9 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/text.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/update.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/update.svg new file mode 100644 index 0000000..b936f15 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal/update.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/arrow.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/arrow.svg new file mode 100644 index 0000000..ef4db13 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/arrow.svg @@ -0,0 +1,8 @@ + + + 箭头 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/cancel.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/cancel.svg new file mode 100644 index 0000000..095c02f --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/cancel.svg @@ -0,0 +1,9 @@ + + + 取消 + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/ellipse.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/ellipse.svg new file mode 100644 index 0000000..8da9bed --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/ellipse.svg @@ -0,0 +1,8 @@ + + + 圆形 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/finish.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/finish.svg new file mode 100644 index 0000000..da0212e --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/finish.svg @@ -0,0 +1,8 @@ + + + 确定 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/gif.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/gif.svg new file mode 100644 index 0000000..6d1d0fc --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/gif.svg @@ -0,0 +1,8 @@ + + + 录屏 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/mosaic.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/mosaic.svg new file mode 100644 index 0000000..ed5d65c --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/mosaic.svg @@ -0,0 +1,8 @@ + + + 马赛克 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pen.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pen.svg new file mode 100644 index 0000000..9db63b5 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pen.svg @@ -0,0 +1,10 @@ + + + 画笔 + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pin.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pin.svg new file mode 100644 index 0000000..39acebf --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/pin.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/rectangle.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/rectangle.svg new file mode 100644 index 0000000..63d7c30 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/rectangle.svg @@ -0,0 +1,8 @@ + + + 矩形 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/renewal.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/renewal.svg new file mode 100644 index 0000000..052543b --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/renewal.svg @@ -0,0 +1,11 @@ + + + 恢复 + + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/revocation.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/revocation.svg new file mode 100644 index 0000000..27ec283 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/revocation.svg @@ -0,0 +1,11 @@ + + + 撤回 + + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/save.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/save.svg new file mode 100644 index 0000000..76a522d --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/save.svg @@ -0,0 +1,12 @@ + + + 保存 + + + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/serialnumber.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/serialnumber.svg new file mode 100644 index 0000000..f9a920f --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/serialnumber.svg @@ -0,0 +1,8 @@ + + + 标注 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/smooth.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/smooth.svg new file mode 100644 index 0000000..a48ef88 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/smooth.svg @@ -0,0 +1,8 @@ + + + 模糊 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/text.svg b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/text.svg new file mode 100644 index 0000000..d6d404d --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool/text.svg @@ -0,0 +1,8 @@ + + + 文字 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/main.cpp b/QToolButtonAutoRaiseEx/CMakeAutoRaise/main.cpp new file mode 100644 index 0000000..f4dec0f --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/main.cpp @@ -0,0 +1,28 @@ +#include "testbtstyle.h" +#include "widget.h" + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + qApp->setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication a(argc, argv); +// Widget w; +// w.show(); + + QStringList listStyle = QStyleFactory::keys(); + foreach(QString val, listStyle) + qDebug()<setWindowTitle("MacOS 12.6 + Qt 5.15.2 + Style: Windows"); + t->show(); + + return a.exec(); +} + + diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/resources.qrc b/QToolButtonAutoRaiseEx/CMakeAutoRaise/resources.qrc new file mode 100644 index 0000000..8d7422f --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/resources.qrc @@ -0,0 +1,37 @@ + + + icons/normal/arrow.svg + icons/normal/copy.svg + icons/normal/download.svg + icons/normal/ellipse.svg + icons/normal/exit.svg + icons/normal/fill-ellipse.svg + icons/normal/fill-rect.svg + icons/normal/gif.svg + icons/normal/line.svg + icons/normal/mosaic.svg + icons/normal/pen.svg + icons/normal/recover.svg + icons/normal/rectangle.svg + icons/normal/revoke.svg + icons/normal/right.svg + icons/normal/screenshot.svg + icons/normal/text.svg + icons/normal/update.svg + icons/tool/arrow.svg + icons/tool/cancel.svg + icons/tool/ellipse.svg + icons/tool/finish.svg + icons/tool/gif.svg + icons/tool/mosaic.svg + icons/tool/pen.svg + icons/tool/pin.svg + icons/tool/rectangle.svg + icons/tool/renewal.svg + icons/tool/revocation.svg + icons/tool/save.svg + icons/tool/serialnumber.svg + icons/tool/smooth.svg + icons/tool/text.svg + + diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.cpp b/QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.cpp new file mode 100644 index 0000000..736d853 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.cpp @@ -0,0 +1,62 @@ +#include "testbtstyle.h" +#include "QtGui/qpainter.h" +#include +#include +#include +#include + +TestBTStyle::TestBTStyle(QWidget *parent) +{ + + QString filePath = "/Users/winks/Desktop/projects/QtExamples/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/normal"; +// QString filePath = "/Users/winks/Desktop/projects/QtExamples/QToolButtonAutoRaiseEx/CMakeAutoRaise/icons/tool"; + QDir *dir=new QDir(filePath); + QStringList filter; + QList *fileInfo=new QList(dir->entryInfoList(filter)); +// for(int i = 0;icount(); i++) +// { +// qDebug()<at(i).filePath(); +// qDebug()<at(i).fileName(); +// } + + + auto layout = new QHBoxLayout(this); + QStringList listName; + for(int i = 0;icount(); i++) + { + if (fileInfo->at(i).fileName() == "." || fileInfo->at(i).fileName() == "..") + continue; + + listName << fileInfo->at(i).fileName(); + } + + for (const auto &it : listName){ + auto tb = new QToolButton(); + tb->setObjectName(it); + tb->setToolButtonStyle(Qt::ToolButtonIconOnly); + tb->setAutoRaise(true); + tb->setIcon(QIcon(":/icons/normal/" + it)); +// tb->setIcon(QIcon(":/icons/tool/" + it)); + tb->setIconSize(QSize(14, 14) * 2); + tb->setContentsMargins(0, 0, 0, 0); + tb->setFixedSize(QSize(14, 14) * 2); + tb->setToolTip(it); + tb->setChecked(false); + tb->setCheckable(true); + + layout->addWidget(tb); + } + +} + +void TestBTStyle::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + QPainter pa(this); + pa.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + pa.setPen(Qt::NoPen); + pa.setBrush(QColor(255, 255, 255, 0.7 * 255)); + + const int round = 4; + pa.drawRoundedRect(contentsRect().adjusted(1, 1, -1, -1), round, round); +} diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.h b/QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.h new file mode 100644 index 0000000..58a8c33 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/testbtstyle.h @@ -0,0 +1,23 @@ +#ifndef TESTBTSTYLE_H +#define TESTBTSTYLE_H + +#include +#include +#include +#include + +class TestBTStyle : public QWidget +{ + Q_OBJECT +public: + TestBTStyle(QWidget *parent = nullptr); + +protected: + void paintEvent(QPaintEvent *event) override; + +private: + QVector m_vItem; + std::vector> m_vTbName; +}; + +#endif // TESTBTSTYLE_H diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.cpp b/QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.cpp new file mode 100644 index 0000000..7350ff4 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.cpp @@ -0,0 +1,11 @@ +#include "widget.h" + +Widget::Widget(QWidget *parent) + : QWidget(parent) +{ +} + +Widget::~Widget() +{ +} + diff --git a/QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.h b/QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.h new file mode 100644 index 0000000..47b6270 --- /dev/null +++ b/QToolButtonAutoRaiseEx/CMakeAutoRaise/widget.h @@ -0,0 +1,14 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget *parent = nullptr); + ~Widget(); +}; +#endif // WIDGET_H diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/.gitignore b/QToolButtonAutoRaiseEx/QMakeAutoRaise/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/QMakeAutoRaise.pro b/QToolButtonAutoRaiseEx/QMakeAutoRaise/QMakeAutoRaise.pro new file mode 100644 index 0000000..4e55114 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/QMakeAutoRaise.pro @@ -0,0 +1,26 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp \ + widget.cpp \ + testbtstyle.cpp + +HEADERS += \ + widget.h \ + testbtstyle.h + +RESOURCES += resources.qrc \ + resources.qrc + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/arrow.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/arrow.svg new file mode 100644 index 0000000..470baef --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/copy.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/copy.svg new file mode 100644 index 0000000..b71c472 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/copy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/download.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/download.svg new file mode 100644 index 0000000..e9333ee --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/download.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/ellipse.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/ellipse.svg new file mode 100644 index 0000000..68f7d2a --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/ellipse.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/exit.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/exit.svg new file mode 100644 index 0000000..ce0ac4e --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/exit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-ellipse.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-ellipse.svg new file mode 100644 index 0000000..3445697 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-ellipse.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-rect.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-rect.svg new file mode 100644 index 0000000..6f511dc --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/fill-rect.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/gif.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/gif.svg new file mode 100644 index 0000000..2099da9 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/gif.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/line.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/line.svg new file mode 100644 index 0000000..adb34e5 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/line.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/mosaic.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/mosaic.svg new file mode 100644 index 0000000..812a3bc --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/mosaic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/pen.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/pen.svg new file mode 100644 index 0000000..7737451 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/pen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/recover.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/recover.svg new file mode 100644 index 0000000..a8104c5 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/recover.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/rectangle.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/rectangle.svg new file mode 100644 index 0000000..214cadd --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/rectangle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/revoke.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/revoke.svg new file mode 100644 index 0000000..c90aad0 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/revoke.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/right.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/right.svg new file mode 100644 index 0000000..adf763b --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/screenshot.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/screenshot.svg new file mode 100644 index 0000000..fd42674 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/screenshot.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/text.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/text.svg new file mode 100644 index 0000000..17a2dc9 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/text.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/update.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/update.svg new file mode 100644 index 0000000..b936f15 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal/update.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/arrow.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/arrow.svg new file mode 100644 index 0000000..ef4db13 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/arrow.svg @@ -0,0 +1,8 @@ + + + 箭头 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/cancel.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/cancel.svg new file mode 100644 index 0000000..095c02f --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/cancel.svg @@ -0,0 +1,9 @@ + + + 取消 + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/ellipse.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/ellipse.svg new file mode 100644 index 0000000..8da9bed --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/ellipse.svg @@ -0,0 +1,8 @@ + + + 圆形 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/finish.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/finish.svg new file mode 100644 index 0000000..da0212e --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/finish.svg @@ -0,0 +1,8 @@ + + + 确定 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/gif.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/gif.svg new file mode 100644 index 0000000..6d1d0fc --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/gif.svg @@ -0,0 +1,8 @@ + + + 录屏 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/mosaic.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/mosaic.svg new file mode 100644 index 0000000..ed5d65c --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/mosaic.svg @@ -0,0 +1,8 @@ + + + 马赛克 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pen.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pen.svg new file mode 100644 index 0000000..9db63b5 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pen.svg @@ -0,0 +1,10 @@ + + + 画笔 + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pin.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pin.svg new file mode 100644 index 0000000..39acebf --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/pin.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/rectangle.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/rectangle.svg new file mode 100644 index 0000000..63d7c30 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/rectangle.svg @@ -0,0 +1,8 @@ + + + 矩形 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/renewal.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/renewal.svg new file mode 100644 index 0000000..052543b --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/renewal.svg @@ -0,0 +1,11 @@ + + + 恢复 + + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/revocation.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/revocation.svg new file mode 100644 index 0000000..27ec283 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/revocation.svg @@ -0,0 +1,11 @@ + + + 撤回 + + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/save.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/save.svg new file mode 100644 index 0000000..76a522d --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/save.svg @@ -0,0 +1,12 @@ + + + 保存 + + + + + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/serialnumber.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/serialnumber.svg new file mode 100644 index 0000000..f9a920f --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/serialnumber.svg @@ -0,0 +1,8 @@ + + + 标注 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/smooth.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/smooth.svg new file mode 100644 index 0000000..a48ef88 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/smooth.svg @@ -0,0 +1,8 @@ + + + 模糊 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/text.svg b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/text.svg new file mode 100644 index 0000000..d6d404d --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool/text.svg @@ -0,0 +1,8 @@ + + + 文字 + + + + + \ No newline at end of file diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/main.cpp b/QToolButtonAutoRaiseEx/QMakeAutoRaise/main.cpp new file mode 100644 index 0000000..6198f11 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/main.cpp @@ -0,0 +1,16 @@ +#include "testbtstyle.h" +#include "widget.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); +// Widget w; +// w.show(); + + auto t = new TestBTStyle(); + t->show(); + + return a.exec(); +} diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/resources.qrc b/QToolButtonAutoRaiseEx/QMakeAutoRaise/resources.qrc new file mode 100644 index 0000000..8d7422f --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/resources.qrc @@ -0,0 +1,37 @@ + + + icons/normal/arrow.svg + icons/normal/copy.svg + icons/normal/download.svg + icons/normal/ellipse.svg + icons/normal/exit.svg + icons/normal/fill-ellipse.svg + icons/normal/fill-rect.svg + icons/normal/gif.svg + icons/normal/line.svg + icons/normal/mosaic.svg + icons/normal/pen.svg + icons/normal/recover.svg + icons/normal/rectangle.svg + icons/normal/revoke.svg + icons/normal/right.svg + icons/normal/screenshot.svg + icons/normal/text.svg + icons/normal/update.svg + icons/tool/arrow.svg + icons/tool/cancel.svg + icons/tool/ellipse.svg + icons/tool/finish.svg + icons/tool/gif.svg + icons/tool/mosaic.svg + icons/tool/pen.svg + icons/tool/pin.svg + icons/tool/rectangle.svg + icons/tool/renewal.svg + icons/tool/revocation.svg + icons/tool/save.svg + icons/tool/serialnumber.svg + icons/tool/smooth.svg + icons/tool/text.svg + + diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.cpp b/QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.cpp new file mode 100644 index 0000000..df87a29 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.cpp @@ -0,0 +1,60 @@ +#include "testbtstyle.h" +#include "QtGui/qpainter.h" +#include +#include +#include +#include + +TestBTStyle::TestBTStyle(QWidget *parent) +{ + QString filePath = "/Users/winks/Desktop/projects/QtExamples/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/normal"; +// QString filePath = "/Users/winks/Desktop/projects/QtExamples/QToolButtonAutoRaiseEx/QMakeAutoRaise/icons/tool"; + QDir *dir=new QDir(filePath); + QStringList filter; + QList *fileInfo=new QList(dir->entryInfoList(filter)); +// for(int i = 0;icount(); i++) +// { +// qDebug()<at(i).filePath(); +// qDebug()<at(i).fileName(); +// } + + + auto layout = new QHBoxLayout(this); + QStringList listName; + for(int i = 0;icount(); i++) + { + if (fileInfo->at(i).fileName() == "." || fileInfo->at(i).fileName() == "..") + continue; + + listName << fileInfo->at(i).fileName(); + } + + for (const auto &it : listName){ + auto tb = new QToolButton(); + tb->setObjectName(it); + tb->setToolButtonStyle(Qt::ToolButtonIconOnly); + tb->setAutoRaise(true); + tb->setIcon(QIcon(":/icons/normal/" + it)); + tb->setIconSize(QSize(14, 14) * 2); + tb->setContentsMargins(0, 0, 0, 0); + tb->setFixedSize(QSize(14, 14) * 2); + tb->setToolTip(it); + tb->setChecked(false); + tb->setCheckable(true); + + layout->addWidget(tb); + } + +} + +void TestBTStyle::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event) + QPainter pa(this); + pa.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + pa.setPen(Qt::NoPen); + pa.setBrush(QColor(255, 255, 255, 0.7 * 255)); + + const int round = 4; + pa.drawRoundedRect(contentsRect().adjusted(1, 1, -1, -1), round, round); +} diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.h b/QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.h new file mode 100644 index 0000000..58a8c33 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/testbtstyle.h @@ -0,0 +1,23 @@ +#ifndef TESTBTSTYLE_H +#define TESTBTSTYLE_H + +#include +#include +#include +#include + +class TestBTStyle : public QWidget +{ + Q_OBJECT +public: + TestBTStyle(QWidget *parent = nullptr); + +protected: + void paintEvent(QPaintEvent *event) override; + +private: + QVector m_vItem; + std::vector> m_vTbName; +}; + +#endif // TESTBTSTYLE_H diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.cpp b/QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.cpp new file mode 100644 index 0000000..7350ff4 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.cpp @@ -0,0 +1,11 @@ +#include "widget.h" + +Widget::Widget(QWidget *parent) + : QWidget(parent) +{ +} + +Widget::~Widget() +{ +} + diff --git a/QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.h b/QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.h new file mode 100644 index 0000000..47b6270 --- /dev/null +++ b/QToolButtonAutoRaiseEx/QMakeAutoRaise/widget.h @@ -0,0 +1,14 @@ +#ifndef WIDGET_H +#define WIDGET_H + +#include + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget *parent = nullptr); + ~Widget(); +}; +#endif // WIDGET_H