Skip to content

Commit f1bc5f9

Browse files
committed
新增ElaKeyBinder单按键绑定器、修正ElaWindow导航模式切换问题
1 parent eba3f2c commit f1bc5f9

17 files changed

+554
-125
lines changed

README.md

+75-68
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
# ElaWidgetTools
22

33
## 简介
4-
本项目是基于QT-Widget开发的FluentUI风格的组件库,同时提供不限于组件的常用集成功能;目前Main分支支持QT5.12以上所有版本(Linux为QT5.15以上),推荐版本为QT6.4.3和QT6.6.2;
4+
5+
本项目是基于QT-Widget开发的FluentUI风格的组件库,同时提供不限于组件的常用集成功能;目前Main分支支持QT5.12以上所有版本(
6+
Linux为QT5.15以上),推荐版本为QT6.4.3和QT6.6.2;
57

68
## 重要提示
9+
710
该项目项目性质原因,暂不接受任何PR!!!使用问题或BUG请直接进群反馈,都会及时处理,感谢您的支持! 企鹅群:850243692
811

912
## 支持平台
10-
| [Windows][win-link] | [Ubuntu][ubuntu-link]
11-
|---------------|---------------|
12-
| ![win-badge] | ![ubuntu-badge] |
13+
14+
| [Windows][win-link] | [Ubuntu][ubuntu-link]
15+
|---------------------|-----------------------|
16+
| ![win-badge] | ![ubuntu-badge] |
1317

1418
[win-link]: https://github.com/Liniyous/ElaWidgetTools/actions?query=workflow%3AWindows "WindowsAction"
19+
1520
[win-badge]: https://img.shields.io/badge/Windows-Passing-61C263
1621

1722
[ubuntu-link]: https://github.com/Liniyous/ElaWidgetTools/actions?query=workflow%3AUbuntu "UbuntuAction"
18-
[ubuntu-badge]: https://img.shields.io/badge/Ubuntu-Passing-61C263
1923

24+
[ubuntu-badge]: https://img.shields.io/badge/Ubuntu-Passing-61C263
2025

2126
## 主界面预览
27+
2228
<div align=center>
2329
<img src="doc/preview/ElaWidgetTools_Light.png">
2430
</div>
@@ -28,66 +34,67 @@
2834

2935
## 支持的组件
3036

31-
|目录|说明|备注|
32-
|----|---------|----|
33-
|ElaApplication|程序初始化||
34-
|ElaAppBar|窗口顶部标题栏|支持拖动窗口,最小化、最大化、关闭窗口、调整窗口尺寸|
35-
|ElaAcrylicUrlCard|带图片的交互式亚克力卡片|支持URL跳转|
36-
|ElaBreadcrumbBar|面包屑组件|自动处理点击事件|
37-
|ElaCheckBox|勾选框||
38-
|ElaComboBox|下拉框||
39-
|ElaColorDialog|颜色选择器||
40-
|ElaCalendar|日历视图||
41-
|ElaCalendarPicker|日期选择器||
42-
|ElaMultiSelectComboBox|多选下拉框||
43-
|ElaContentDialog|带遮罩的对话框||
44-
|ElaDockWidget|停靠窗口||
45-
|ElaSpinBox|微调框||
46-
|ElaDoubleSpinBox|微调框|浮点数|
47-
|ElaDxgiManager|DXGI采集器|支持自动选择采集设备 效率远高于原生采集|
48-
|ElaEventBus|事件总线||
49-
|ElaFlowLayout|流式布局|支持动画|
50-
|ElaIcon|图标||
51-
|ElaIconButton|图标按钮||
52-
|ElaImageCard|图片卡片||
53-
|ElaInteractiveCard|带图片的交互式透明卡片||
54-
|ElaLineEdit|输入框||
55-
|ElaListView|列表视图||
56-
|ElaLog|消息日志||
57-
|ElaMenu|菜单||
58-
|ElaMenuBar|菜单栏||
59-
|ElaMessageBar|弹出式信息栏|支持八方向,锚定位置|
60-
|ElaMessageButton|弹出信息按钮||
61-
|ElaPivot|轴转导航||
62-
|ElaPlainTextEdit|文本编辑框||
63-
|ElaPushButton|按钮||
64-
|ElaPopularCard|热门卡片||
65-
|ElaProgressBar|进度条||
66-
|ElaPromotionCard|促销卡片||
67-
|ElaPromotionView|促销卡片视窗||
68-
|ElaSwitchButton|切换按钮||
69-
|ElaSuggestBox|建议搜索框||
70-
|ElaRadioButton|单选按钮||
71-
|ElaNavigationRouter|路由跳转||
72-
|ElaToggleSwitch|开关按钮||
73-
|ElaTabBar|选项卡|谷歌浏览器风格|
74-
|ElaTabWidget|选项卡页面|谷歌浏览器风格|
75-
|ElaTableView|表格视图||
76-
|ElaTreeView|树型视图||
77-
|ElaToolButton|带下拉菜单的工具按钮||
78-
|ElaToolBar|工具栏||
79-
|ElaTheme|主题管理器||
80-
|ElaReminderCard|带图片的提醒卡片||
81-
|ElaScrollbar|滚动条||
82-
|ElaScrollArea|滚动区域|可设置鼠标拖动|
83-
|ElaScrollPage|滚动页面|自带堆栈页面和面包屑导航|
84-
|ElaScrollPageArea|滚动页面区域组件||
85-
|ElaSlider|拖动条||
86-
|ElaStatusBar|状态栏||
87-
|ElaExponentialBlur|指数模糊||
88-
|ElaText|Text文本||
89-
|ElaGraphicsScene|高级场景|大量实用API|
90-
|ElaGraphicsView|高级视图|按键缩放、拖动|
91-
|ElaGraphicsItem|高级图元|大量实用API|
92-
|ElaWindow|带导航栏的无边框窗口||
93-
|ElaWidget|无边框模态窗口||
37+
| 目录 | 说明 | 备注 |
38+
|------------------------|--------------|----------------------------|
39+
| ElaApplication | 程序初始化 | |
40+
| ElaAppBar | 窗口顶部标题栏 | 支持拖动窗口,最小化、最大化、关闭窗口、调整窗口尺寸 |
41+
| ElaAcrylicUrlCard | 带图片的交互式亚克力卡片 | 支持URL跳转 |
42+
| ElaBreadcrumbBar | 面包屑组件 | 自动处理点击事件 |
43+
| ElaCheckBox | 勾选框 | |
44+
| ElaComboBox | 下拉框 | |
45+
| ElaColorDialog | 颜色选择器 | |
46+
| ElaCalendar | 日历视图 | |
47+
| ElaCalendarPicker | 日期选择器 | |
48+
| ElaMultiSelectComboBox | 多选下拉框 | |
49+
| ElaContentDialog | 带遮罩的对话框 | |
50+
| ElaDockWidget | 停靠窗口 | |
51+
| ElaSpinBox | 微调框 | |
52+
| ElaDoubleSpinBox | 微调框 | 浮点数 |
53+
| ElaDxgiManager | DXGI采集器 | 支持自动选择采集设备 效率远高于原生采集 |
54+
| ElaEventBus | 事件总线 | |
55+
| ElaFlowLayout | 流式布局 | 支持动画 |
56+
| ElaIcon | 图标 | |
57+
| ElaIconButton | 图标按钮 | |
58+
| ElaImageCard | 图片卡片 | |
59+
| ElaInteractiveCard | 带图片的交互式透明卡片 | |
60+
| ElaKeyBinder | 单按键绑定器 | |
61+
| ElaLineEdit | 输入框 | |
62+
| ElaListView | 列表视图 | |
63+
| ElaLog | 消息日志 | |
64+
| ElaMenu | 菜单 | |
65+
| ElaMenuBar | 菜单栏 | |
66+
| ElaMessageBar | 弹出式信息栏 | 支持八方向,锚定位置 |
67+
| ElaMessageButton | 弹出信息按钮 | |
68+
| ElaPivot | 轴转导航 | |
69+
| ElaPlainTextEdit | 文本编辑框 | |
70+
| ElaPushButton | 按钮 | |
71+
| ElaPopularCard | 热门卡片 | |
72+
| ElaProgressBar | 进度条 | |
73+
| ElaPromotionCard | 促销卡片 | |
74+
| ElaPromotionView | 促销卡片视窗 | |
75+
| ElaSwitchButton | 切换按钮 | |
76+
| ElaSuggestBox | 建议搜索框 | |
77+
| ElaRadioButton | 单选按钮 | |
78+
| ElaNavigationRouter | 路由跳转 | |
79+
| ElaToggleSwitch | 开关按钮 | |
80+
| ElaTabBar | 选项卡 | 谷歌浏览器风格 |
81+
| ElaTabWidget | 选项卡页面 | 谷歌浏览器风格 |
82+
| ElaTableView | 表格视图 | |
83+
| ElaTreeView | 树型视图 | |
84+
| ElaToolButton | 带下拉菜单的工具按钮 | |
85+
| ElaToolBar | 工具栏 | |
86+
| ElaTheme | 主题管理器 | |
87+
| ElaReminderCard | 带图片的提醒卡片 | |
88+
| ElaScrollbar | 滚动条 | |
89+
| ElaScrollArea | 滚动区域 | 可设置鼠标拖动 |
90+
| ElaScrollPage | 滚动页面 | 自带堆栈页面和面包屑导航 |
91+
| ElaScrollPageArea | 滚动页面区域组件 | |
92+
| ElaSlider | 拖动条 | |
93+
| ElaStatusBar | 状态栏 | |
94+
| ElaExponentialBlur | 指数模糊 | |
95+
| ElaText | Text文本 | |
96+
| ElaGraphicsScene | 高级场景 | 大量实用API |
97+
| ElaGraphicsView | 高级视图 | 按键缩放、拖动 |
98+
| ElaGraphicsItem | 高级图元 | 大量实用API |
99+
| ElaWindow | 带导航栏的无边框窗口 | |
100+
| ElaWidget | 无边框模态窗口 | |

example/ExamplePage/T_Popup.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "ElaCalendar.h"
77
#include "ElaCalendarPicker.h"
88
#include "ElaColorDialog.h"
9+
#include "ElaKeyBinder.h"
910
#include "ElaMenu.h"
1011
#include "ElaPushButton.h"
1112
#include "ElaScrollPageArea.h"
@@ -88,12 +89,22 @@ T_Popup::T_Popup(QWidget* parent)
8889
calendarPickerLayout->addWidget(_calendarPicker);
8990
calendarPickerLayout->addStretch();
9091

92+
_keyBinder = new ElaKeyBinder(this);
93+
ElaScrollPageArea* keyBinderArea = new ElaScrollPageArea(this);
94+
QHBoxLayout* keyBinderLayout = new QHBoxLayout(keyBinderArea);
95+
ElaText* keyBinderText = new ElaText("ElaKeyBinder", this);
96+
keyBinderText->setTextPixelSize(15);
97+
keyBinderLayout->addWidget(keyBinderText);
98+
keyBinderLayout->addWidget(_keyBinder);
99+
keyBinderLayout->addStretch();
100+
91101
QVBoxLayout* centerVLayout = new QVBoxLayout(centralWidget);
92102
centerVLayout->setContentsMargins(0, 0, 0, 0);
93103
centerVLayout->addWidget(toolButtonArea);
94104
centerVLayout->addWidget(colorDialogArea);
95105
centerVLayout->addWidget(calendarPickerArea);
96106
centerVLayout->addWidget(_calendar);
107+
centerVLayout->addWidget(keyBinderArea);
97108
centerVLayout->addStretch();
98109
addCentralWidget(centralWidget, true, false, 0);
99110
}

example/ExamplePage/T_Popup.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class ElaToolButton;
77
class ElaColorDialog;
88
class ElaCalendar;
99
class ElaCalendarPicker;
10+
class ElaKeyBinder;
1011
class T_Popup : public T_BasePage
1112
{
1213
Q_OBJECT
@@ -19,6 +20,7 @@ class T_Popup : public T_BasePage
1920
ElaColorDialog* _colorDialog{nullptr};
2021
ElaCalendar* _calendar{nullptr};
2122
ElaCalendarPicker* _calendarPicker{nullptr};
23+
ElaKeyBinder* _keyBinder{nullptr};
2224
};
2325

24-
#endif // T_POPUP_H
26+
#endif// T_POPUP_H

example/ExamplePage/T_UpdateWidget.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,21 @@ T_UpdateWidget::T_UpdateWidget(QWidget* parent)
1111
mainLayout->setSizeConstraint(QLayout::SetMaximumSize);
1212
mainLayout->setContentsMargins(5, 10, 5, 5);
1313
mainLayout->setSpacing(4);
14-
ElaText* updateTitle = new ElaText("2024-9-27更新", 15, this);
15-
ElaText* update1 = new ElaText("1、Mica模块重做并对全局开放", 13, this);
16-
ElaText* update2 = new ElaText("2、QT6.5.3-6.6.1无边框优化", 13, this);
17-
ElaText* update3 = new ElaText("3、ElaDockWidget支持改变大小", 13, this);
18-
ElaText* update4 = new ElaText("4、ElaTabWidget功能强化", 13, this);
19-
ElaText* update5 = new ElaText("5、Linux部分问题修正", 13, this);
14+
ElaText* updateTitle = new ElaText("2024-11-17更新", 15, this);
15+
ElaText* update1 = new ElaText("1、新增ElaKeyBinder单键位绑定组件,支持鼠标按键", 13, this);
16+
ElaText* update2 = new ElaText("2、ElaContentDialog中间按钮按下行为优化", 13, this);
17+
ElaText* update3 = new ElaText("3、ElaWindow导航模式切换相关问题修正", 13, this);
18+
ElaText* update4 = new ElaText("4、CMAKE编译配置和体验优化", 13, this);
2019
update1->setIsWrapAnywhere(true);
2120
update2->setIsWrapAnywhere(true);
2221
update3->setIsWrapAnywhere(true);
2322
update4->setIsWrapAnywhere(true);
24-
update5->setIsWrapAnywhere(true);
2523

2624
mainLayout->addWidget(updateTitle);
2725
mainLayout->addWidget(update1);
2826
mainLayout->addWidget(update2);
2927
mainLayout->addWidget(update3);
3028
mainLayout->addWidget(update4);
31-
mainLayout->addWidget(update5);
3229
mainLayout->addStretch();
3330
}
3431

example/mainwindow.cpp

+22-7
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ MainWindow::MainWindow(QWidget* parent)
5050
// 拦截默认关闭事件
5151
_closeDialog = new ElaContentDialog(this);
5252
connect(_closeDialog, &ElaContentDialog::rightButtonClicked, this, &MainWindow::closeWindow);
53-
connect(_closeDialog, &ElaContentDialog::middleButtonClicked, this, &MainWindow::showMinimized);
53+
connect(_closeDialog, &ElaContentDialog::middleButtonClicked, this, [=]() {
54+
_closeDialog->close();
55+
showMinimized();
56+
});
5457
this->setIsDefaultClosed(false);
5558
connect(this, &MainWindow::closeButtonClicked, this, [=]() {
5659
_closeDialog->exec();
@@ -267,13 +270,25 @@ void MainWindow::initContent()
267270
}
268271
});
269272
addFooterNode("Setting", _settingPage, _settingKey, 0, ElaIconType::GearComplex);
270-
connect(this, &MainWindow::userInfoCardClicked, this, [=]() { this->navigation(_homePage->property("ElaPageKey").toString()); });
273+
connect(this, &MainWindow::userInfoCardClicked, this, [=]() {
274+
this->navigation(_homePage->property("ElaPageKey").toString());
275+
});
271276
#ifdef Q_OS_WIN
272-
connect(_homePage, &T_Home::elaScreenNavigation, this, [=]() { this->navigation(_elaScreenPage->property("ElaPageKey").toString()); });
277+
connect(_homePage, &T_Home::elaScreenNavigation, this, [=]() {
278+
this->navigation(_elaScreenPage->property("ElaPageKey").toString());
279+
});
273280
#endif
274-
connect(_homePage, &T_Home::elaBaseComponentNavigation, this, [=]() { this->navigation(_baseComponentsPage->property("ElaPageKey").toString()); });
275-
connect(_homePage, &T_Home::elaSceneNavigation, this, [=]() { this->navigation(_graphicsPage->property("ElaPageKey").toString()); });
276-
connect(_homePage, &T_Home::elaIconNavigation, this, [=]() { this->navigation(_iconPage->property("ElaPageKey").toString()); });
277-
connect(_homePage, &T_Home::elaCardNavigation, this, [=]() { this->navigation(_cardPage->property("ElaPageKey").toString()); });
281+
connect(_homePage, &T_Home::elaBaseComponentNavigation, this, [=]() {
282+
this->navigation(_baseComponentsPage->property("ElaPageKey").toString());
283+
});
284+
connect(_homePage, &T_Home::elaSceneNavigation, this, [=]() {
285+
this->navigation(_graphicsPage->property("ElaPageKey").toString());
286+
});
287+
connect(_homePage, &T_Home::elaIconNavigation, this, [=]() {
288+
this->navigation(_iconPage->property("ElaPageKey").toString());
289+
});
290+
connect(_homePage, &T_Home::elaCardNavigation, this, [=]() {
291+
this->navigation(_cardPage->property("ElaPageKey").toString());
292+
});
278293
qDebug() << "已注册的事件列表" << ElaEventBus::getInstance()->getRegisteredEventsName();
279294
}

src/CMakeLists.txt

+34-29
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ set(PROJECT_SOURCES
3737

3838
if (ELAWIDGETTOOLS_BUILD_STATIC_LIB)
3939
set(LIB_TYPE "STATIC")
40-
else()
41-
set(LIB_TYPE "SHARED")
42-
endif()
43-
44-
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
45-
qt_add_library(${EXPORT_NAME} ${LIB_TYPE}
46-
${PROJECT_SOURCES}
47-
)
48-
else()
49-
add_library(${EXPORT_NAME} ${LIB_TYPE}
50-
${PROJECT_SOURCES}
51-
)
52-
endif()
40+
else ()
41+
set(LIB_TYPE "SHARED"
42+
DeveloperComponents/ElaKeyBinderContainer.cpp
43+
DeveloperComponents/ElaKeyBinderContainer.h)
44+
endif ()
45+
46+
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
47+
qt_add_library(${EXPORT_NAME} ${LIB_TYPE}
48+
${PROJECT_SOURCES}
49+
)
50+
else ()
51+
add_library(${EXPORT_NAME} ${LIB_TYPE}
52+
${PROJECT_SOURCES}
53+
)
54+
endif ()
5355

5456
FILE(GLOB EXPORT_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h
5557
${CMAKE_CURRENT_SOURCE_DIR}/include/*.qrc
@@ -61,38 +63,38 @@ target_include_directories(${EXPORT_NAME} PUBLIC
6163
$<INSTALL_INTERFACE:include>
6264
)
6365

64-
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
66+
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
6567
#遍历所有资源文件
6668
file(GLOB_RECURSE RES_PATHS *.png *.jpg *.svg *.ico *.ttf *.webp *.js)
67-
foreach(filepath ${RES_PATHS})
68-
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
69-
list(APPEND resource_files ${filename})
70-
endforeach(filepath)
69+
foreach (filepath ${RES_PATHS})
70+
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
71+
list(APPEND resource_files ${filename})
72+
endforeach (filepath)
7173
qt_add_resources(${EXPORT_NAME} "ElaWidgetTools"
7274
RESOURCES PREFIX "/"
7375
FILES
7476
${resource_files}
7577
)
76-
endif()
78+
endif ()
7779

78-
if(MINGW)
80+
if (MINGW)
7981
set_target_properties(${EXPORT_NAME} PROPERTIES PREFIX "")
80-
endif()
81-
if(MSVC)
82+
endif ()
83+
if (MSVC)
8284
set_target_properties(${EXPORT_NAME} PROPERTIES DEBUG_POSTFIX "d")
83-
endif()
85+
endif ()
8486

85-
if(WIN32)
87+
if (WIN32)
8688
target_link_libraries(${EXPORT_NAME} PUBLIC
8789
Qt${QT_VERSION_MAJOR}::Widgets
8890
D3D11
8991
DXGI
9092
)
91-
else()
92-
target_link_libraries(${EXPORT_NAME} PUBLIC
93-
Qt${QT_VERSION_MAJOR}::Widgets
94-
)
95-
endif()
93+
else ()
94+
target_link_libraries(${EXPORT_NAME} PUBLIC
95+
Qt${QT_VERSION_MAJOR}::Widgets
96+
)
97+
endif ()
9698

9799

98100
install(
@@ -104,6 +106,9 @@ install(
104106
)
105107

106108
install(FILES ${EXPORT_HEADERS} DESTINATION include)
109+
install(TARGETS ${EXPORT_NAME}
110+
RUNTIME DESTINATION ${CMAKE_BINARY_DIR}
111+
)
107112

108113
set(INCLUDE_DIRS include)
109114
set(LIBRARIES ${EXPORT_NAME})

0 commit comments

Comments
 (0)