This commit is contained in:
JackLee_CN 2024-10-03 20:17:18 +08:00
parent 83e7580546
commit 92b79745ea
33 changed files with 1875 additions and 0 deletions

58
.gitignore vendored Normal file
View File

@ -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

7
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
// 使 IntelliSense
//
// 访: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": []
}

81
.vscode/settings.json vendored Normal file
View File

@ -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"
}
}

103
CMakeLists.txt Normal file
View File

@ -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)
# debugrelease
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)
#winpthreadgcc_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
)

9
main.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <QApplication>
#include "src/sui.h"
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
sui _sui;
_sui.show();
return a.exec();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
res/font/PingFang Heavy.ttf Normal file

Binary file not shown.

Binary file not shown.

BIN
res/img/btn/btn_close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
res/img/btn/btn_max.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
res/img/btn/btn_min.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
res/img/logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 KiB

BIN
res/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

BIN
res/lang/qt_help_zh_CN.qm Normal file

Binary file not shown.

419
res/qss/dark.qsst Normal file
View File

@ -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;
}

82
res/qss/dark_style.qss Normal file
View File

@ -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;
}

462
res/qss/light.qsst Normal file
View File

@ -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;
}

80
res/qss/light_style.qss Normal file
View File

@ -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;
}

17
res/txt/about.txt Normal file
View File

@ -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
作者申明:本软件仅供学习使用,软件自带的数据均属于软件开发测试使用,由于开发过程中方便测试所以开源源码部分数据写死,如不喜欢可以自行修改增删减

55
src/common.h Normal file
View File

@ -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 <iostream>
//#################QT head###############//
#include <QtGui>
#include <QPushButton>
#include <QDialog>
#include <QThread>
#include <QProcess>
#include <QWidget>
#include <QMessageBox>
#include <QFileDialog>
#include <QFileInfo>
#include <QFileIconProvider>
#include <QDateTime>
#include <QDebug>
#include <QString>
#include <QAbstractListModel>
#include <QFile>
#include <QIcon>
#include <QDir>
#include <QListView>
#include <QAction>
#include <QMenu>
#include <QPainter>
#include <QContextMenuEvent>
#include <QInputDialog>
#include <QTabWidget>
#include <QThread>
#include <QProgressBar>
#include <QDesktopServices>
#include <QApplication>
#include <QVBoxLayout>
#include <QHBoxLayout>
//###################C++ head################//
#include <stdlib.h>
#include <vector>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <iostream>
#include <fstream>
#include <zlib.h>
#include <string.h>
#include <winuser.h>
#endif // COMMON_H

123
src/sui.cpp Normal file
View File

@ -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<MSG *>(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);
}

40
src/sui.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef SUI_H
#define SUI_H
#include "common.h"
#include <QMainWindow>
#ifdef Q_OS_WIN
#include <QWindow>
#include <windowsx.h>
#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

12
src/sui_base.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef SUI_BASE_H
#define SUI_BASE_H
#include <vector>
#include <string>
typedef struct {
int set_font;
int set_style;
}sui_sets;
extern sui_sets s_sets;
#endif // SUI_BASE_H

244
src/sui_title.cpp Normal file
View File

@ -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()<<event->type();
switch ( event->type() ) //判断发生事件的类型
{
case QEvent::WindowTitleChange: //窗口标题改变事件
{
QWidget *pWidget = qobject_cast<QWidget *>(obj); //获得发生事件的窗口对象
if (pWidget)
{
//窗体标题改变,则标题栏标题也随之改变
//m_pTitleLabel->setText(pWidget->windowTitle());
return true;
}
}
break;
case QEvent::WindowIconChange: //窗口图标改变事件
{
QWidget *pWidget = qobject_cast<QWidget *>(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<QPushButton *>(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);
}

60
src/sui_title.h Normal file
View File

@ -0,0 +1,60 @@
#ifndef SUI_TITLE_H
#define SUI_TITLE_H
#include <QFrame>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QApplication>
#include <QStyleOption>
#include <QPainter>
#include <QFile>
#include <QFileInfo>
#include <QMenu>
#include <QDir>
#include <QActionGroup>
#include <QFontDatabase>
#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

1
sui.rc Normal file
View File

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "res\\img\\logo.ico"

22
suires.qrc Normal file
View File

@ -0,0 +1,22 @@
<RCC>
<qresource prefix="/">
<file>res/img/logo.png</file>
<file>res/img/logo.ico</file>
<file>res/img/btn/btn_close.png</file>
<file>res/img/btn/btn_max.png</file>
<file>res/img/btn/btn_min.png</file>
<file>res/img/btn/btn_restart_max.png</file>
<file>res/qss/dark_style.qss</file>
<file>res/qss/light_style.qss</file>
<file>res/lang/qt_help_zh_CN.qm</file>
<file>res/txt/about.txt</file>
<file>res/font/HarmonyOS_Sans_SC_Black.ttf</file>
<file>res/font/HarmonyOS_Sans_SC_Bold.ttf</file>
<file>res/font/HarmonyOS_Sans_SC_Light.ttf</file>
<file>res/font/HarmonyOS_Sans_SC_Medium.ttf</file>
<file>res/font/HarmonyOS_Sans_SC_Regular.ttf</file>
<file>res/font/HarmonyOS_Sans_SC_Thin.ttf</file>
<file>res/font/PingFang Heavy.ttf</file>
<file>res/font/PingFang Medium.ttf</file>
</qresource>
</RCC>