diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a9f93d --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# These are some examples of commonly ignored file patterns. +# You should customize this list as applicable to your project. +# Learn more about .gitignore: +# https://www.atlassian.com/git/tutorials/saving-changes/gitignore + +# Node artifact files +node_modules/ +dist/ +/build +build/ +release/ +/release + +# Compiled Java class files +*.class + +# Compiled Python bytecode +*.py[cod] + +# Log files +*.log + +# Package files +*.jar + +# Maven +target/ +dist/ + +# JetBrains IDE +.idea/ + +# Unit test reports +TEST*.xml + +# Generated by MacOS +.DS_Store + +# Generated by Windows +Thumbs.db + +# Applications +*.app +*.war + +# Large media files +*.mp4 +*.tiff +*.avi +*.flv +*.mov +*.wmv + +#屏蔽zvo测试数据 +*.exe +*.torrent +*.m3u8 + diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ba18e48 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,7 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3e28bff --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,81 @@ +{ + "files.associations": { + "qvboxlayout": "cpp", + "iostream": "cpp", + "qwindow": "cpp", + "*.rh": "cpp", + "qmainwindow": "cpp", + "qpainter": "cpp", + "qmouseevent": "cpp", + "qpainterpath": "cpp", + "new": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "source_location": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "format": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "semaphore": "cpp", + "shared_mutex": "cpp", + "span": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stdfloat": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "text_encoding": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "typeinfo": "cpp", + "variant": "cpp" + } +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..be5ab3c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,103 @@ +#cmake最低版本 +cmake_minimum_required(VERSION 3.16) + +#项目版本 +project(SUI VERSION 1.0 LANGUAGES CXX) + +#设置moc ui rcc编译开关 +SET(CMAKE_AUTOMOC ON) +SET(CMAKE_AUTOUIC ON) +SET(CMAKE_AUTORCC ON) + +#设置C++版本 +set(CMAKE_CXX_STANDARD 17) + +#包含所有.h文件 +SET(CMAKE_INCLUDE_CURRENT_DIR ON) + +#release编译下依然输出符号和行号 +#ADD_DEFINITIONS(-DQT_MESSAGELOGCONTEXT) + +#编译类型 debug和release输出路径 +set(CMAKE_VERBOSE_MAKEFILE ON) +SET(CMAKE_CXX_FLAGS"-Wall -Wextra") +SET(CMAKE_CXX_FLAGS_RELEASE"-O3 -s") +set(CMAKE_BUILD_TYPE "Release") + +message(STATUS "----------编译模式 START-------------") +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "[CMAKE_BUILD_TYPE]当前值[Debug]") + SET(CMAKE_BUILD_TYPE "Debug") + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/build/debug) +else() + message(STATUS "[CMAKE_BUILD_TYPE]当前值[Release]") + SET(CMAKE_BUILD_TYPE "Release") + SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/release) +endif() +message(STATUS "----------编译模式 END---------------") + +#设置QT .cmake文件路径 +SET(QT_DIR "D:/Dev/Qt/6.3.2/mingw1120_static_x64_base/lib/cmake") +SET(MSYS2 "D:/Dev/msys64/mingw64") + +list(APPEND CMAKE_PREFIX_PATH ${QT_DIR} ${MSYS2}) + +#查找QT模块 +find_package(Qt6 REQUIRED Core Gui Widgets Network) + +#输出路径 +message(STATUS "----------基础路径输出 START-------------") +message(STATUS "QT_DIR_PATH=${QT_DIR}") +message(STATUS "MSYS2_DIR_PATH=${MSYS2}") +message(STATUS "----------基础路径输出 END---------------") + + +FILE(GLOB src "${PROJECT_SOURCE_DIR}/src/*.cpp" "${PROJECT_SOURCE_DIR}/src/*.h") + +set(PROJECT_SOURCES + main.cpp + ${src} +) + +#资源文件 +qt6_add_resources(RCFILES suires.qrc) +#WIN32 +add_executable(${PROJECT_NAME} WIN32 ${PROJECT_SOURCES} ${RCFILES} sui.rc) +#增加winpthread和gcc_s静态库 +SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wl,-Bstatic -lwinpthread -Wl,-Bstatic -lz -Wl,-Bstatic -lgcc_s") +#安全编译 +#关闭RPATH特性 +SET(CMAKE_SKIP_RPATH TRUE) +#开启栈保护 +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong") +#开启GOT表保护 +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro,-z,now") +SET(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -Wl,-z,relro,-z,now") +#开启栈不可执行 +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,noexecstack") +SET(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -Wl,-z,noexecstack") +#开启地址无关 +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic") +#随机化 +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pie") +SET(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -pie") +#隐藏暴露的符号 +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fvisibility=hidden") +SET(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -fvisibility=hidden") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fvisibility-inlines-hidden") +SET(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -fvisibility-inlines-hidden") +#删除调试符号 +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s") +SET(CMAKE_EXECUTABLE_LINKER_FLAGS "${CMAKE_EXECUTABLE_LINKER_FLAGS} -s") +#开启整数溢出检查 +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -ftrapv") +#开启栈检查 +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -fstack-check") + +#忽略多重定引用 +target_link_options(${PROJECT_NAME} PUBLIC -Wl,--allow-multiple-definition) + +target_link_libraries( + ${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network +) \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..9d3d320 --- /dev/null +++ b/main.cpp @@ -0,0 +1,9 @@ +#include +#include "src/sui.h" +int main(int argc, char* argv[]) +{ + QApplication a(argc, argv); + sui _sui; + _sui.show(); + return a.exec(); +} \ No newline at end of file diff --git a/res/font/HarmonyOS_Sans_SC_Black.ttf b/res/font/HarmonyOS_Sans_SC_Black.ttf new file mode 100644 index 0000000..824b3d4 Binary files /dev/null and b/res/font/HarmonyOS_Sans_SC_Black.ttf differ diff --git a/res/font/HarmonyOS_Sans_SC_Bold.ttf b/res/font/HarmonyOS_Sans_SC_Bold.ttf new file mode 100644 index 0000000..5c925d1 Binary files /dev/null and b/res/font/HarmonyOS_Sans_SC_Bold.ttf differ diff --git a/res/font/HarmonyOS_Sans_SC_Light.ttf b/res/font/HarmonyOS_Sans_SC_Light.ttf new file mode 100644 index 0000000..8cfbc9d Binary files /dev/null and b/res/font/HarmonyOS_Sans_SC_Light.ttf differ diff --git a/res/font/HarmonyOS_Sans_SC_Medium.ttf b/res/font/HarmonyOS_Sans_SC_Medium.ttf new file mode 100644 index 0000000..350f6a0 Binary files /dev/null and b/res/font/HarmonyOS_Sans_SC_Medium.ttf differ diff --git a/res/font/HarmonyOS_Sans_SC_Regular.ttf b/res/font/HarmonyOS_Sans_SC_Regular.ttf new file mode 100644 index 0000000..aff150a Binary files /dev/null and b/res/font/HarmonyOS_Sans_SC_Regular.ttf differ diff --git a/res/font/HarmonyOS_Sans_SC_Thin.ttf b/res/font/HarmonyOS_Sans_SC_Thin.ttf new file mode 100644 index 0000000..6a58b15 Binary files /dev/null and b/res/font/HarmonyOS_Sans_SC_Thin.ttf differ diff --git a/res/font/PingFang Heavy.ttf b/res/font/PingFang Heavy.ttf new file mode 100644 index 0000000..f4cf788 Binary files /dev/null and b/res/font/PingFang Heavy.ttf differ diff --git a/res/font/PingFang Medium.ttf b/res/font/PingFang Medium.ttf new file mode 100644 index 0000000..982661b Binary files /dev/null and b/res/font/PingFang Medium.ttf differ diff --git a/res/img/btn/btn_close.png b/res/img/btn/btn_close.png new file mode 100644 index 0000000..eab5488 Binary files /dev/null and b/res/img/btn/btn_close.png differ diff --git a/res/img/btn/btn_max.png b/res/img/btn/btn_max.png new file mode 100644 index 0000000..65a65e7 Binary files /dev/null and b/res/img/btn/btn_max.png differ diff --git a/res/img/btn/btn_min.png b/res/img/btn/btn_min.png new file mode 100644 index 0000000..a7d4567 Binary files /dev/null and b/res/img/btn/btn_min.png differ diff --git a/res/img/btn/btn_restart_max.png b/res/img/btn/btn_restart_max.png new file mode 100644 index 0000000..9faea77 Binary files /dev/null and b/res/img/btn/btn_restart_max.png differ diff --git a/res/img/logo.ico b/res/img/logo.ico new file mode 100644 index 0000000..5607e9c Binary files /dev/null and b/res/img/logo.ico differ diff --git a/res/img/logo.png b/res/img/logo.png new file mode 100644 index 0000000..703806e Binary files /dev/null and b/res/img/logo.png differ diff --git a/res/lang/qt_help_zh_CN.qm b/res/lang/qt_help_zh_CN.qm new file mode 100644 index 0000000..2eb396f Binary files /dev/null and b/res/lang/qt_help_zh_CN.qm differ diff --git a/res/qss/dark.qsst b/res/qss/dark.qsst new file mode 100644 index 0000000..04ee312 --- /dev/null +++ b/res/qss/dark.qsst @@ -0,0 +1,419 @@ +/*ZvoɫʽQSSļ*/ +$Button_Hover_BackGround_Color = ; +$m_QWidget_BackGround_Color = #1b1b1b; + +/*ɫ#ff9000*/ +$m_QWidget_Font_Color = #F0F0F0F0; + +QWidget{ + background-color: $m_QWidget_BackGround_Color; + color:$m_QWidget_Font_Color; + font:10pt; +} + +QPushButton#icoButton{ + image:url(:/res/img/zvo.png); + border:none; +} + +QPushButton#t_backButton{ + image:url(:/res/img/dark/exit.png); + border:none; +} +/*бؼʽ*/ +QPushButton#searchButton{ + image:url(:/res/img/dark/search.png); + border:none; + width:15px; + height:15px; +} +QPushButton:hover{ +padding-left:1px; +padding-top:1px; +} +/*ť-Pressed*/ +QPushButton:pressed{ + padding-left:2px; + padding-top:2px; +} + +QMenu { + background-color : rgb(253,253,254); + border-radius:15px; +} +QMenu::item { + font-size:10pt; + color: rgb(0,0,0); + background-color:rgb(253,253,254); + padding: 8px 25px 6px 10px; + margin: 1px 1px; +} +QMenu::item:selected { + background-color : rgb(236,236,237); +} +QMenu::icon:checked { + background: rgb(253,253,254); + position: absolute; + top: 1px; + right: 1px; + bottom: 1px; + left: 1px; +} +QMenu::icon:checked:selected { + background-color : rgb(236,236,237); + background-image: url(:/space_selected.png); +} +QMenu::separator { + height: 2px; + background: rgb(235,235,236); + margin-left: 10px; + margin-right: 10px; +} + +QPushButton#searchButton,#t_backButton:hover{ +padding-left:1px; +padding-top:1px; +} +QPushButton#searchButton,#t_backButton:pressed{ +padding-left:2px; +padding-top:2px; +} + +QLineEdit#search_QLineEdit{ +background: $m_QWidget_BackGround_Color; +color:$m_QWidget_Font_Color; +border: 1px solid gray; +border-radius: 2px; +padding: 0 8px; +selection-background-color: darkgray; +} +/*QComboBoxʽ*/ +QComboBox { + height: 25px; + border-radius: 4px; + border: 1px solid rgb(100, 100, 100); + background: rgb(72, 72, 73); +} +QComboBox:enabled { + color:$m_QWidget_Font_Color; +} +QComboBox:!enabled { + color: rgb(155, 155, 155); +} +QComboBox:enabled:hover, QComboBox:enabled:focus { + color: rgb(230, 230, 230); + background: rgb(68, 69, 73); +} +QComboBox::drop-down { + width: 20px; + border: none; + background: transparent; +} +QComboBox::drop-down:hover { + background: rgba(255, 255, 255, 30); +} + +QComboBox::down-arrow:on { + top: 1px; +} +QComboBox QAbstractItemView { + border: 1px solid rgb(100, 100, 100); + background: rgb(68, 69, 73); + outline: none; +} +QComboBox QAbstractItemView::item { + height: 25px; + color: rgb(175, 175, 175); +} +QComboBox QAbstractItemView::item:selected { + background: rgba(255, 255, 255, 40); + color: rgb(230, 230, 230); +} + +/*QTabWidgetʽ*/ +QTabWidget{ +background-color:transparent; +} + +QTabWidget::pane{ +border:2px; +} + +QTabWidget::tab-bar{ +border:2px; +alignment:left; +} + +QTabBar::tab{ +border: 1px solid gray; +border-radius: 5px; +border:2px; +background:$m_QWidget_BackGround_Color; +color:$m_QWidget_Font_Color; +min-width:20ex; +min-height:6ex; +} + +QTabBar::tab:hover{ +background:#006161; +color:$m_QWidget_Font_Color = #F0F0F0F0; +} + +QTabBar::tab:selected{ +border-color: black; +background:#9fa493; +color:$m_QWidget_Font_Color; +} + +/*QTableViewʽ*/ +QTableView +{ +background: rgb(55,55,55); +} + +QTableView{ +selection-background-color:rgb(255,0,0); +background-color:rgb(50,50,50); +border:1px solid rgb(70,70,70); +color:rgb(200,200,200) +} + +QTableView::item +{ +background-color:$m_QWidget_BackGround_Color; +border:1px solid rgb(65,65,65); +color:$m_QWidget_Font_Color; +} +QTableView::item:hover +{ +background-color: rgb(30,30,30); +color:rgb(31,163,246); +} +QTableView::item::selected +{ +background-color: rgb(30,30,30); +color:rgb(31,163,246); +} +QHeaderView::section{ +background-color:rgb(90,90,90); +color:rgb(200,200,200); +border:1px solid rgb(60,60,60); +border-bottom:1px solid rgb(70,70,70); +} +QHeaderView::section:hover +{ +background-color:rgb(80,80,80); +} +/*ʽ*/ +QScrollBar:vertical{ +border: none; +background-color:$m_QWidget_BackGround_Color; +width:10px; +} +QScrollBar::handle:vertical{ +background:#9fa480; +border-radius:4px; +} +QScrollBar::handle:vertical:hover{ +background:#9fa493; +} +QScrollBar::add-line:vertical{ +border: none; +height: 0px; +} +QScrollBar::sub-line:vertical{ +border: none; +height: 0px; +} +QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical +{ +background:$m_QWidget_BackGround_Color; +border-radius:3px; +} +/*Ž*/ +QSlider::groove:horizontal { +border: 0px solid #bbb; +} + +QSlider::sub-page:horizontal { +background: rgb(235,97,0); +border-radius: 0px; +margin-top:8px; +margin-bottom:8px; +} + +QSlider::add-page:horizontal { +background: rgb(255,255, 255); +border: 0px solid #777; +border-radius: 2px; +margin-top:8px; +margin-bottom:8px; +} + +QSlider::handle:horizontal { +background: rgb(255,153,102); +border: 1px solid rgb(255,153,102); +width: 14px; +height:10px; +border-radius: 7px; +margin-top:2px; +margin-bottom:2px; + +} + +QSlider::handle:horizontal:hover { +background: rgb(255,128,6); +border: 1px solid rgba(102,102,102,102); +border-radius: 7px; +} + +QSlider::sub-page:horizontal:disabled { +background: #bbb; +border-color: #999; +} + +QSlider::add-page:horizontal:disabled { +background: #eee; +border-color: #999; +} + +QSlider::handle:horizontal:disabled { +background: #eee; +border: 1px solid #aaa; +border-radius: 4px; +} + + +/*------------------ʽ С ر---------------------*/ +/*ֵ*/ +$titleBar_QWidget_BackGround_Color = #ffffff; /**/ +QWidget#mediaTitle{ + background-color: $titleBar_QWidget_BackGround_Color; + margin-top:1px; + margin-right:1px; + margin-bottom:1px; + margin-left:1px; +} +QPushButton#minimizeButton{ + image:url(":/res/img/btn/btn_min.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#maximizeButton{ + image:url(":/res/img/btn/btn_max.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#closeButton{ + image:url(":/res/img/btn/btn_close.png"); + border:none; + width:20px; + height:20px; +} +/*----------------------ƶť---------------------------*/ +QPushButton#minimizeButton:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#maximizeButton:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#closeButton:hover{ + padding-left:1px; + padding-top:1px; +} +/*----------------------갴µť---------------------------*/ +QPushButton#minimizeButton:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#maximizeButton:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#closeButton:pressed{ + padding-left:1px; + padding-top:1px; +} +/*------------------ʽ---------------------*/ +/*ֵ*/ +$m_MediaPlayer_Slider_QWidget_Color = #c7fdff; +$b_max_size = 25px; +QWidget#m_MediaPlayerSliderQWidget{ + background-color: $m_QWidget_BackGround_Color; +} +QWidget#m_videoWidget{ + background-color:$m_QWidget_BackGround_Color; + background-image:url(:/res/img/zvo.png); + background-position:center; + background-repeat:no-repeat; +} +/*ť-Ĭ*/ +QPushButton#m_btnvolume{ + image:url(":/res/img/dark/volume_open.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnPlay{ + image:url(":/res/img/dark/play.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnClose{ + image:url(":/res/img/dark/close.png"); + border:none; + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnStop{ + image:url(":/res/img/dark/stop.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnPrev{ + image:url(":/res/img/dark/prev.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnNext{ + image:url(":/res/img/dark/next.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnEq{ + image:url(":/res/img/dark/equalizer.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnSet{ + image:url(":/res/img/dark/setting.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnMenuOpt{ + image:url(":/res/img/dark/menu.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnDown{ + image:url(":/res/img/dark/download.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +/*ť-Hover*/ +QPushButton#m_btnvolume:hover{ +background: $Button_Hover_BackGround_Color; +} diff --git a/res/qss/dark_style.qss b/res/qss/dark_style.qss new file mode 100644 index 0000000..f468e26 --- /dev/null +++ b/res/qss/dark_style.qss @@ -0,0 +1,82 @@ +QWidget{ + background-color: #1b1b1b; + color:#F0F0F0F0; + font:10pt; +} + +QWidget#m_widget{ + border-radius:10px; +} + +QPushButton{ + margin-right:3px; + margin-bottom:0px; + border-radius:8px; + font-family: "Microsoft YaHei"; + font-weight: bold; + font: bold 12px; +} + +QPushButton#ico_button{ + image:url(:/res/img/logo.png); + border:none; +} + +QPushButton:hover{ +padding-left:1px; +padding-top:1px; +} +/*------------------ʽ С ر---------------------*/ +/*ֵ*/ +/**/ +QWidget#sui_title{ + background-color: #ffffff; + margin-top:1px; + margin-right:1px; + margin-bottom:1px; + margin-left:1px; +} +QPushButton#min_button{ + image:url(":/res/img/btn/btn_min.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#max_button{ + image:url(":/res/img/btn/btn_max.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#close_button{ + image:url(":/res/img/btn/btn_close.png"); + border:none; + width:20px; + height:20px; +} + +QPushButton#min_button:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#max_button:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#close_button:hover{ + padding-left:1px; + padding-top:1px; +} + +QPushButton#min_button:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#max_button:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#close_button:pressed{ + padding-left:1px; + padding-top:1px; +} diff --git a/res/qss/light.qsst b/res/qss/light.qsst new file mode 100644 index 0000000..3b65ea9 --- /dev/null +++ b/res/qss/light.qsst @@ -0,0 +1,462 @@ +/*ZvoɫʽQSSļ*/ +$Button_Hover_BackGround_Color = #ffffff; +$m_QWidget_BackGround_Color = #F3F3F3; +$m_QWidget_Font_Color = #2F4F4F; + +QWidget{ + background-color: $m_QWidget_BackGround_Color; + color:$m_QWidget_Font_Color; +} +QWidget#m_QWidget{ + border-radius:10px; +} + +QToolButton{ + margin-right:3px; + margin-bottom:0px; + border-radius:8px; + font-family: "Microsoft YaHei"; + font-weight: bold; + font: bold 12px; +} +QPushButton{ + margin-right:3px; + margin-bottom:0px; + border-radius:8px; + font-family: "Microsoft YaHei"; + font-weight: bold; + font: bold 12px; +} + +QPushButton#icoButton{ + image:url(:/res/img/zvo.png); + border:none; +} + +QPushButton#t_backButton{ + image:url(:/res/img/light/exit.png); + border:none; +} +/*бؼʽ*/ +QPushButton#searchButton{ + image:url(:/res/img/light/search.png); + border:none; + width:15px; + height:15px; +} +QPushButton:hover{ +padding-left:1px; +padding-top:1px; +} +/*ť-Pressed*/ +QPushButton:pressed{ + padding-left:2px; + padding-top:2px; +} + +QMenu { + background-color : rgb(253,253,254); + border-radius:15px; +} +QMenu::item { + font-size:10pt; + color: rgb(0,0,0); + background-color:rgb(253,253,254); + padding: 8px 25px 6px 10px; + margin: 1px 1px; +} +QMenu::item:selected { + background-color : rgb(236,236,237); +} +QMenu::icon:checked { + background: rgb(253,253,254); + position: absolute; + top: 1px; + right: 1px; + bottom: 1px; + left: 1px; +} +QMenu::icon:checked:selected { + background-color : rgb(236,236,237); + background-image: url(:/space_selected.png); +} +QMenu::separator { + height: 2px; + background: rgb(235,235,236); + margin-left: 10px; + margin-right: 10px; +} + +QPushButton#searchButton,#t_backButton:hover{ +padding-left:1px; +padding-top:1px; +} +QPushButton#searchButton,#t_backButton:pressed{ +padding-left:2px; +padding-top:2px; +} + +QLineEdit#search_QLineEdit{ +background: $m_QWidget_BackGround_Color; +color:$m_QWidget_Font_Color; +border: 1px solid gray; +border-radius: 2px; +padding: 0 8px; +selection-background-color: darkgray; +} + +/*QComboBoxʽ*/ +QComboBox { + height: 25px; + border-radius: 4px; + border: 1px solid rgb(100, 100, 100); + background: #f3f3f3; +} +QComboBox:enabled { + color:#2f4f4f; +} +QComboBox:!enabled { + color: rgb(155, 155, 155); +} + +QComboBox::drop-down { + width: 20px; + border: none; +} +QComboBox::drop-down:hover { + color:$Button_Hover_BackGround_Color; +} + +QComboBox::down-arrow:on { + top: 1px; +} +QComboBox QAbstractItemView { + border: 1px solid rgb(100, 100, 100); + background: #f3f3f3; + outline: none; +} +QComboBox QAbstractItemView::item { + height: 25px; + color: $m_QWidget_Font_Color; +} +QComboBox QAbstractItemView::item:selected { + color:$Button_Hover_BackGround_Color; + background:rgb(0,120,215); +} +QComboBox QAbstractItemView::item:hover { + color:$Button_Hover_BackGround_Color; + background:rgb(0,120,215); +} +/*QTabWidgetʽ*/ +QTabWidget{ +background-color:transparent; +} + +QTabWidget::pane{ +border:0px; +} + +QTabWidget::tab-bar{ +alignment: center; +border:1px rgb(255,255,255); +} +/*ͨQTabBarʽ*/ +QTabBar::tab{ +/*border: 1px solid gray;*/ +border-radius: 3px; +color:$m_QWidget_Font_Color; +min-width:25ex; +min-height:8ex; +} + +QTabBar::tab:hover{ +background:rgb(0,120,215); +color:$Button_Hover_BackGround_Color; +} + +QTabBar::tab:selected{ +border-color: $m_QWidget_BackGround_Color; +background:rgb(0,120,215); +color:$Button_Hover_BackGround_Color; +} + +/*QTabBarʽ*/ +QTabBar#MediaTitleBar::tab{ +border-bottom: 0px; +border-radius: 3px; +color:$m_QWidget_Font_Color; +min-width:50ex; +height: 40px; +} + +QTabBar#MediaTitleBar::tab:hover{ +background:rgb(214,214,214); +color:$m_QWidget_Font_Color; +} + +QTabBar#MediaTitleBar::tab:selected{ +border-color: $m_QWidget_BackGround_Color; +background:rgb(214,214,214); +color:$m_QWidget_Font_Color; +} + +QTabBar#MediaTitleBar::close-button{ + min-width:30px; + min-height:30px; + subcontrol-origin: padding; + subcontrol-position: bottom right; + border-image: url(:/res/img/light/close_little.png); +} +QTabBar#MediaTitleBar::close-button:hover{ + background: rgb(192,192,192); +} + +/*QTableViewʽ*/ +QTableView{ +selection-background-color:rgb(255,0,0); +background:$m_QWidget_BackGround_Color; +border:1px rgb(255,255,255); +color:rgb(200,200,200) +} + +QTableView::item +{ +background-color:$m_QWidget_BackGround_Color; +border:1px solid #2f4f4f; +color:$m_QWidget_Font_Color; +} +QTableView::item:hover +{ +color:$Button_Hover_BackGround_Color; +background:rgb(0,120,215); +} +QTableView::item::selected +{ +color:$Button_Hover_BackGround_Color; +background:rgb(0,120,215); +outline:0px; +} +QHeaderView::section{ +color:#2f4f4f; +background:#f3f3f3; +border:1px solid #2f4f4f; +border-bottom:1px solid #f3f3f3; +} +QHeaderView::section:hover +{ +color:$Button_Hover_BackGround_Color; +background:rgb(0,120,215); +} +/*ʽ*/ +QScrollBar:vertical{ +border: none; +background-color:$m_QWidget_BackGround_Color; +width:10px; +} +QScrollBar::handle:vertical{ +background:rgb(0,120,215); +border-radius:4px; +} +QScrollBar::handle:vertical:hover{ +background:rgb(0,120,215); +} +QScrollBar::handle:vertical{ +background:rgb(0,120,215); +border-radius:4px; +} +QScrollBar::handle:vertical:hover{ +background:rgb(0,120,255);; +} + +QScrollBar::add-page:vertical,QScrollBar::sub-page:vertical +{ +background:$m_QWidget_BackGround_Color; +border-radius:3px; +} +/*Ž*/ +QSlider::groove:horizontal { +border: 0px solid #bbb; +} + +QSlider::sub-page:horizontal { +background: rgb(235,97,0); +border-radius: 3px; +margin-top:8px; +margin-bottom:8px; +} + +QSlider::add-page:horizontal { +background: rgb(255,255, 255); +border: 0px solid #777; +border-radius: 2px; +margin-top:8px; +margin-bottom:8px; +} + +QSlider::handle:horizontal { +background: rgb(255,153,102); +border: 1px solid rgb(255,153,102); +width: 14px; +height:10px; +border-radius: 8px; +margin-top:3px; +margin-bottom:3px; + +} + +QSlider::handle:horizontal:hover { +background: rgb(255,128,6); +border: 1px solid rgba(102,102,102,102); +border-radius: 7px; +} + +QSlider::sub-page:horizontal:disabled { +background: #bbb; +border-color: #999; +} + +QSlider::add-page:horizontal:disabled { +background: #eee; +border-color: #999; +} + +QSlider::handle:horizontal:disabled { +background: #eee; +border: 1px solid #aaa; +border-radius: 4px; +} + + +/*------------------ʽ С ر---------------------*/ +/*ֵ*/ +$titleBar_QWidget_BackGround_Color = #ffffff; /**/ +QWidget#mediaTitle{ + background-color: $titleBar_QWidget_BackGround_Color; + margin-top:1px; + margin-right:1px; + margin-bottom:1px; + margin-left:1px; +} +QPushButton#minimizeButton{ + image:url(":/res/img/btn/btn_min.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#maximizeButton{ + image:url(":/res/img/btn/btn_max.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#closeButton{ + image:url(":/res/img/btn/btn_close.png"); + border:none; + width:20px; + height:20px; +} +/*----------------------ƶť---------------------------*/ +QPushButton#minimizeButton:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#maximizeButton:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#closeButton:hover{ + padding-left:1px; + padding-top:1px; +} +/*----------------------갴µť---------------------------*/ +QPushButton#minimizeButton:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#maximizeButton:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#closeButton:pressed{ + padding-left:1px; + padding-top:1px; +} +/*------------------ʽ---------------------*/ +/*ֵ*/ +$m_MediaPlayer_Slider_QWidget_Color = #c7fdff; +$b_max_size = 25px; +QWidget#m_MediaPlayerSliderQWidget{ + background-color: $m_QWidget_BackGround_Color; +} +QWidget#m_videoWidget{ + background-color:$m_QWidget_BackGround_Color; + background-image:url(:/res/img/zvo.png); + background-position:center; + background-repeat:no-repeat; +} +/*ť-Ĭ*/ +QPushButton#m_btnvolume{ + image:url(":/res/img/light/volume_open.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnPlay{ + image:url(":/res/img/light/play.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnClose{ + image:url(":/res/img/light/close.png"); + border:none; + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnStop{ + image:url(":/res/img/light/stop.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnPrev{ + image:url(":/res/img/light/prev.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnNext{ + image:url(":/res/img/light/next.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnEq{ + image:url(":/res/img/light/equalizer.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnSet{ + image:url(":/res/img/light/setting.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnMenuOpt{ + image:url(":/res/img/light/menu.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +QPushButton#m_btnDown{ + image:url(":/res/img/light/download.png"); + border:none; + max-width:$b_max_size; + max-height:$b_max_size; +} +/*ť-Hover*/ +QPushButton#m_btnvolume:hover{ +background: $Button_Hover_BackGround_Color; +} diff --git a/res/qss/light_style.qss b/res/qss/light_style.qss new file mode 100644 index 0000000..cc16d02 --- /dev/null +++ b/res/qss/light_style.qss @@ -0,0 +1,80 @@ +QWidget{ + background-color: #F3F3F3; + color:#2F4F4F; +} +QWidget#m_widget{ + border-radius:10px; +} + +QPushButton{ + margin-right:3px; + margin-bottom:0px; + border-radius:8px; + font-family: "Microsoft YaHei"; + font-weight: bold; + font: bold 12px; +} + +QPushButton#ico_button{ + image:url(:/res/img/logo.png); + border:none; +} + +QPushButton:hover{ +padding-left:1px; +padding-top:1px; +} +/*------------------ʽ С ر---------------------*/ +/*ֵ*/ +/**/ +QWidget#sui_title{ + background-color: #ffffff; + margin-top:1px; + margin-right:1px; + margin-bottom:1px; + margin-left:1px; +} +QPushButton#min_button{ + image:url(":/res/img/btn/btn_min.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#max_button{ + image:url(":/res/img/btn/btn_max.png"); + border:none; + width:20px; + height:20px; +} +QPushButton#close_button{ + image:url(":/res/img/btn/btn_close.png"); + border:none; + width:20px; + height:20px; +} + +QPushButton#min_button:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#max_button:hover{ + padding-left:1px; + padding-top:1px; +} +QPushButton#close_button:hover{ + padding-left:1px; + padding-top:1px; +} + +QPushButton#min_button:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#max_button:pressed{ + padding-left:2px; + padding-top:2px; +} +QPushButton#close_button:pressed{ + padding-left:1px; + padding-top:1px; +} \ No newline at end of file diff --git a/res/txt/about.txt b/res/txt/about.txt new file mode 100644 index 0000000..aad48a2 --- /dev/null +++ b/res/txt/about.txt @@ -0,0 +1,17 @@ + 关于本软件 +软件名:Zvo(Zero Vague Oder) +一款集成视频播放,摄像头播放,P2P下载的软件 +开发者 能力一般 水平有限 代码拉胯 +编译环境: +QT static build +curl +qbittorrent +aria2 +libvlc +libgit2 +libtorrent +作者:JackLee_CN +联系Mail:809262979@qq.com +开原地址:https://jihulab.com/vk/zvo.git + +作者申明:本软件仅供学习使用,软件自带的数据均属于软件开发测试使用,由于开发过程中方便测试所以开源源码部分数据写死,如不喜欢可以自行修改增删减 diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..51183e0 --- /dev/null +++ b/src/common.h @@ -0,0 +1,55 @@ +#ifndef COMMON_H +#define COMMON_H +#define UNUSED(x) (void)(x) +#define GIT_UNUSED(x) ((void)(x)) +#define FILE_PATH_LEN 128 +#define toStr(name) (#name) +#ifdef __unix +#define fopen_s(pFile,filename,mode) ((*(pFile))=fopen((filename), (mode)))==NULL +#endif + +#include +//#################QT head###############// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//###################C++ head################// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // COMMON_H diff --git a/src/sui.cpp b/src/sui.cpp new file mode 100644 index 0000000..3df268f --- /dev/null +++ b/src/sui.cpp @@ -0,0 +1,123 @@ +#include "sui.h" +sui::sui(QWidget *parent) + : QWidget(parent), + m_widget(new QWidget), + m_layout(new QVBoxLayout), + m_press(false), + m_border_width(5) +{ + init_layout(); +} +sui::~sui() +{ +} +void sui::init_layout() +{ + m_title=new sui_title(this); + m_main_qwidget=new QWidget(m_title); + setObjectName(tr("m_widget")); + m_layout->addWidget(m_title); + m_title->setMouseTracking(true); + m_layout->addWidget(m_main_qwidget); + m_layout->setContentsMargins(5, 5, 5, 5); + m_layout->setSpacing(0); + setWindowFlags(Qt::FramelessWindowHint); + setAttribute(Qt::WA_TranslucentBackground); + setMouseTracking(true); + setBaseSize(1000, 600); + resize(1000, 600); + setLayout(m_layout); +} + +void sui::showEvent(QShowEvent *event) +{ + this->setAttribute(Qt::WA_Mapped); + QWidget::showEvent(event); +} + +void sui::paintEvent(QPaintEvent *event) +{ + QStyleOption opt; + opt.initFrom(this); + QPainter painter(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + painter.setRenderHint(QPainter::Antialiasing); + painter.drawRoundedRect(this->rect(), 10, 10); + QWidget::paintEvent(event); +} + +void sui::mousePressEvent(QMouseEvent *event) +{ + if ((event->button() == Qt::LeftButton)) + { + m_press = true; + m_point = (event->globalPosition() - this->pos()).toPoint(); + event->accept(); + } +} + +void sui::mouseMoveEvent(QMouseEvent *event) +{ + if (m_press) + { + move(event->globalPosition().toPoint() - m_point); + event->accept(); + } +} + +void sui::mouseReleaseEvent(QMouseEvent *event) +{ + Q_UNUSED(event) + m_press = false; +} + +bool sui::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +{ + Q_UNUSED(eventType) + + MSG *param = static_cast(message); + + switch (param->message) + { + case WM_NCHITTEST: + { + int nX = GET_X_LPARAM(param->lParam) - this->geometry().x(); + int nY = GET_Y_LPARAM(param->lParam) - this->geometry().y(); + + // 如果鼠标位于子控件上,则不进行处理 + if (childAt(nX, nY) != nullptr) + return QWidget::nativeEvent(eventType, message, result); + + *result = HTCAPTION; + + // 鼠标区域位于窗体边框,进行缩放 + if ((nX > 0) && (nX < m_border_width)) + *result = HTLEFT; + + if ((nX > this->width() - m_border_width) && (nX < this->width())) + *result = HTRIGHT; + + if ((nY > 0) && (nY < m_border_width)) + *result = HTTOP; + + if ((nY > this->height() - m_border_width) && (nY < this->height())) + *result = HTBOTTOM; + + if ((nX > 0) && (nX < m_border_width) && (nY > 0) && (nY < m_border_width)) + *result = HTTOPLEFT; + + if ((nX > this->width() - m_border_width) && (nX < this->width()) && (nY > 0) && (nY < m_border_width)) + *result = HTTOPRIGHT; + + if ((nX > 0) && (nX < m_border_width) && (nY > this->height() - m_border_width) && (nY < this->height())) + *result = HTBOTTOMLEFT; + + if ((nX > this->width() - m_border_width) && (nX < this->width()) && (nY > this->height() - m_border_width) && (nY < this->height())) + *result = HTBOTTOMRIGHT; + + return true; + } + } + + return QWidget::nativeEvent(eventType, message, result); +} diff --git a/src/sui.h b/src/sui.h new file mode 100644 index 0000000..efb9cb7 --- /dev/null +++ b/src/sui.h @@ -0,0 +1,40 @@ +#ifndef SUI_H +#define SUI_H + +#include "common.h" +#include +#ifdef Q_OS_WIN +#include +#include +#pragma execution_character_set("utf-8") +#endif + +#include "sui_title.h" + +class sui : public QWidget +{ + Q_OBJECT +public: + explicit sui(QWidget *parent = 0); + ~sui(); + +private: + void init_layout(); + +private: + QVBoxLayout *m_layout; + QWidget *m_widget; + QPoint m_point; + bool m_press; + int m_border_width; + sui_title* m_title; + QWidget* m_main_qwidget; +protected: + void paintEvent(QPaintEvent *event); + void showEvent(QShowEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); +}; +#endif // SUI_H \ No newline at end of file diff --git a/src/sui_base.h b/src/sui_base.h new file mode 100644 index 0000000..aae7c00 --- /dev/null +++ b/src/sui_base.h @@ -0,0 +1,12 @@ +#ifndef SUI_BASE_H +#define SUI_BASE_H + +#include +#include +typedef struct { + int set_font; + int set_style; +}sui_sets; + +extern sui_sets s_sets; +#endif // SUI_BASE_H \ No newline at end of file diff --git a/src/sui_title.cpp b/src/sui_title.cpp new file mode 100644 index 0000000..e09506c --- /dev/null +++ b/src/sui_title.cpp @@ -0,0 +1,244 @@ +#include "sui_title.h" +sui_title::sui_title(QWidget *parent) + : QWidget (parent), + m_menu(nullptr), + s_menu(nullptr), + f_menu(nullptr) +{ + m_parent=parent; + //给成员变量申请内存 + m_icon_button = new QPushButton(/*this*/); + m_min_button = new QPushButton(this); + m_max_button = new QPushButton(this); + m_close_button = new QPushButton(this); + //初始化图标Label + m_icon_button->setFixedSize(35,35); + m_icon_button->setAutoFillBackground(true); + m_icon_button->setFlat(true); + + //设置按钮的固定大小、图片、取消边框 + m_min_button->setIconSize(QSize(25,25)); + m_min_button->setAutoFillBackground(true); + m_min_button->setFlat(true); + //-- + m_max_button->setIconSize(QSize(25,25)); + m_max_button->setAutoFillBackground(true); + m_max_button->setFlat(true); + //-- + m_close_button->setIconSize(QSize(25,25)); + m_close_button->setAutoFillBackground(true); + m_close_button->setFlat(true); + + //设置窗口部件的名称 + setObjectName(tr("sui_title")); + m_icon_button->setObjectName(tr("ico_button")); + m_min_button->setObjectName(tr("min_button")); + m_max_button->setObjectName(tr("max_button")); + m_close_button->setObjectName(tr("close_button")); + //给按钮设置静态tooltip,当鼠标移上去时显示tooltip + m_min_button->setToolTip(tr("最小化")); + m_max_button->setToolTip(tr("最大化")); + m_close_button->setToolTip(tr("关闭")); + //标题栏布局 + m_layout = new QHBoxLayout(this); + m_layout->setAlignment(Qt::AlignCenter); + m_layout->addWidget(m_icon_button); + m_layout->addItem(sparcer_item); + m_layout->addWidget(m_min_button); + m_layout->addWidget(m_max_button); + m_layout->addWidget(m_close_button); + m_layout->setSpacing(5); + m_layout->setContentsMargins(0, 0, 0, 0); + setFixedHeight(40); + setLayout(m_layout); + s_sets.set_font=0; + s_sets.set_style=1; + QDir *fontDir = new QDir(tr(":/res/font/")); + font_table = fontDir->entryList(QDir::Files); + QDir *styleDir = new QDir(tr(":/res/qss/")); + style_table = styleDir->entryList(QDir::Files); + slots_set_style_change(); + slots_set_font_change(); + connect_slots(); +} +sui_title::~sui_title() +{ +} +void sui_title::connect_slots(){ + //连接三个按钮的信号槽3 + connect(m_icon_button, SIGNAL(clicked(bool)), this, SLOT(slots_ico_menu())); + connect(m_min_button, SIGNAL(clicked(bool)), this, SLOT(on_clicked())); + connect(m_max_button, SIGNAL(clicked(bool)), this, SLOT(on_clicked())); + connect(m_close_button, SIGNAL(clicked(bool)), this, SLOT(on_clicked())); +} +void sui_title::slots_ico_menu() +{ + m_menu = new QMenu(); + //外观 + if(!s_menu){ + QActionGroup* s_QGroup = new QActionGroup(this); + s_menu = new QMenu(tr("外观设置")); + for(int i=0;i<=style_table.count()-1;i++){ + QString sName=QFileInfo(style_table[i]).baseName(); + QAction* s_Action=new QAction(sName,s_QGroup); + s_Action->setObjectName(QString::number(i)); + s_Action->setCheckable(true); + if(i==s_sets.set_style){ + s_Action->setChecked(true); + } + connect(s_Action,SIGNAL(triggered (bool)),this,SLOT(slots_set_style_change())); + s_menu->addAction(s_Action); + } + } + //字体 + if(!f_menu){ + QActionGroup* f_QGroup = new QActionGroup(this); + f_menu = new QMenu(tr("字体设置")); + for(int i=0;i<=font_table.count()-1;i++){ + QAction* f_Action=new QAction(font_table[i],f_QGroup); + f_Action->setObjectName(QString::number(i)); + f_Action->setCheckable(true); + if(i==s_sets.set_font){ + f_Action->setChecked(true); + } + connect(f_Action,SIGNAL(triggered (bool)),this,SLOT(slots_set_font_change())); + f_menu->addAction(f_Action); + } + } + m_menu->addMenu(s_menu); + m_menu->addMenu(f_menu); + m_menu->exec(QCursor::pos()); + delete m_menu; + m_menu=nullptr; +} +void sui_title::slots_set_style_change() +{ + if(sender()!=nullptr){ + s_sets.set_style=sender()->objectName().toInt(); + } + change_style(s_sets.set_style); +} +void sui_title::slots_set_font_change() +{ + if(sender()!=nullptr){ + s_sets.set_font=sender()->objectName().toInt(); + } + QString font=tr(":/res/font/")+font_table[s_sets.set_font]; + int fontId = QFontDatabase::addApplicationFont(font); + QStringList fontIDs = QFontDatabase::applicationFontFamilies(fontId); + if (!fontIDs.isEmpty()) { + QFont font(fontIDs.first()); + font.setPointSize(10); + QApplication::setFont(font); + } + else { + qDebug()<<"Failed to load font."; + } + change_style(s_sets.set_style); +} +void sui_title::change_style(int index){ + QString style=tr(":/res/qss/")+style_table[index]; + QFile qss(style); + if (qss.open(QFile::ReadOnly)) + { + QString styleSheet = this->styleSheet(); + styleSheet += QLatin1String(qss.readAll()); + m_parent->setStyleSheet(styleSheet); + } + qss.close(); + m_parent->update(); +} + +//双击标题栏进行界面的最大化/还原 +void sui_title::mouse_double_click_event(QMouseEvent *event) +{ + Q_UNUSED(event); //没有实质性的作用,只是用来允许event可以不使用,用来避免编译器警告 + emit m_max_button->clicked(); +} +//使用事件过滤器监听标题栏所在的窗体,所以当窗体标题、图标等信息发生改变时,标题栏也应该随之改变 +bool sui_title::event_filter(QObject *obj, QEvent *event) +{ + qDebug()<type(); + switch ( event->type() ) //判断发生事件的类型 + { + case QEvent::WindowTitleChange: //窗口标题改变事件 + { + QWidget *pWidget = qobject_cast(obj); //获得发生事件的窗口对象 + if (pWidget) + { + //窗体标题改变,则标题栏标题也随之改变 + //m_pTitleLabel->setText(pWidget->windowTitle()); + return true; + } + } + break; + case QEvent::WindowIconChange: //窗口图标改变事件 + { + QWidget *pWidget = qobject_cast(obj); + if (pWidget) + { + //窗体图标改变,则标题栏图标也随之改变 + QIcon icon = pWidget->windowIcon(); + //m_pIconLabel->setPixmap(icon.pixmap(m_pIconLabel->size())); + return true; + } + } + break; + case QEvent::Resize: + up_maximize(); //最大化/还原 + return true; + default: + return QWidget::eventFilter(obj, event); + } + return QWidget::eventFilter(obj, event); +} +//进行最小化、最大化/还原、关闭操作 +void sui_title::on_clicked() +{ + //QObject::Sender()返回发送信号的对象的指针,返回类型为QObject * + QPushButton *pButton = qobject_cast(sender()); + QWidget *pWindow = this->window(); //获得标题栏所在的窗口 + if (pWindow->isWindow()) + { + //判断发送信号的对象使哪个按钮 + if (pButton == m_min_button) + { + pWindow->showMinimized(); //窗口最小化显示 + } + else if (pButton == m_max_button) + { + pWindow->isFullScreen() ? pWindow->showNormal() : pWindow->showFullScreen(); + } + else if (pButton == m_close_button) + { + QApplication::quit(); + } + } +} +//最大化/还原 +void sui_title::up_maximize() +{ + QWidget *pWindow = this->window(); //获得标题栏所在的窗口 + if (pWindow->isWindow()) + { + bool bMaximize = pWindow->isFullScreen(); //判断窗口是不是最大化状态,是则返回true,否则返回false + if (bMaximize) + { + //目前窗口是最大化状态,则最大化/还原的toolTip设置为"Restore" + m_max_button->setToolTip(tr("Restore")); + //设置按钮的属性名为"maximizeProperty" + m_max_button->setProperty("maximizeProperty", tr("restore")); + } + else + { + //目前窗口是还原状态,则最大化/还原的toolTip设置为"Maximize" + m_max_button->setToolTip(tr("Maximize")); + //设置按钮的属性名为"maximizeProperty" + m_max_button->setProperty("maximizeProperty", tr("maximize")); + } + m_max_button->setStyle(QApplication::style()); + } +} +void sui_title::set_title_txt(QString str){ + //m_pTitleLabel->setText(str); +} \ No newline at end of file diff --git a/src/sui_title.h b/src/sui_title.h new file mode 100644 index 0000000..c9cb91c --- /dev/null +++ b/src/sui_title.h @@ -0,0 +1,60 @@ +#ifndef SUI_TITLE_H +#define SUI_TITLE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sui_base.h" + +sui_sets s_sets; +class sui_title: public QWidget +{ + Q_OBJECT +public: + explicit sui_title(QWidget *parent = nullptr); + ~sui_title(); + void set_title_txt(QString str); +protected: + //双击标题栏进行界面的最大化/还原 + void mouse_double_click_event(QMouseEvent *event); + //设置界面标题与图标 + bool event_filter(QObject *obj, QEvent *event); +private slots: + //进行最小化、最大化/还原、关闭操作 + void on_clicked(); +private: + //最大化/还原 + void up_maximize(); + void change_style(int); + void connect_slots(); +private: + QWidget *m_parent; + QHBoxLayout *m_layout; + QPushButton *m_icon_button; //标题栏图标 + QLabel *m_title_label; //标题栏标题 + QPushButton *m_min_button; //最小化按钮 + QPushButton *m_max_button; //最大化/还原按钮 + QPushButton *m_close_button; //关闭按钮 + QSpacerItem *sparcer_item = new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Fixed); + QMenu *m_menu; + QMenu* s_menu; + QMenu* f_menu; + QStringList style_table; + QStringList font_table; +public slots: + void slots_ico_menu(); + void slots_set_style_change(); + void slots_set_font_change(); +}; +#endif \ No newline at end of file diff --git a/sui.rc b/sui.rc new file mode 100644 index 0000000..fd58c4b --- /dev/null +++ b/sui.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "res\\img\\logo.ico" \ No newline at end of file diff --git a/suires.qrc b/suires.qrc new file mode 100644 index 0000000..a3f32ec --- /dev/null +++ b/suires.qrc @@ -0,0 +1,22 @@ + + + res/img/logo.png + res/img/logo.ico + res/img/btn/btn_close.png + res/img/btn/btn_max.png + res/img/btn/btn_min.png + res/img/btn/btn_restart_max.png + res/qss/dark_style.qss + res/qss/light_style.qss + res/lang/qt_help_zh_CN.qm + res/txt/about.txt + res/font/HarmonyOS_Sans_SC_Black.ttf + res/font/HarmonyOS_Sans_SC_Bold.ttf + res/font/HarmonyOS_Sans_SC_Light.ttf + res/font/HarmonyOS_Sans_SC_Medium.ttf + res/font/HarmonyOS_Sans_SC_Regular.ttf + res/font/HarmonyOS_Sans_SC_Thin.ttf + res/font/PingFang Heavy.ttf + res/font/PingFang Medium.ttf + +