mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-02 16:15:28 +08:00
Compare commits
13 Commits
4997b991db
...
1.7.6
Author | SHA1 | Date | |
---|---|---|---|
ef65183320 | |||
2e379fcd7e | |||
0a8732c91b | |||
b98c5d327a | |||
7163c739c2 | |||
5cfd9824a8 | |||
a27554bfb2 | |||
7a67ccc1e1 | |||
39f58278ff | |||
354f7f2e3e | |||
876b230141 | |||
2367c6978a | |||
6b941697b0 |
@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake/)
|
|||||||
include(GetGitRevisionDescription)
|
include(GetGitRevisionDescription)
|
||||||
|
|
||||||
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
||||||
set(FLUENTUI_BUILD_STATIC_LIB OFF)
|
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
||||||
|
@ -34,6 +34,38 @@ providing powerful tools and support for this project.
|
|||||||
For more information about the Qt project,
|
For more information about the Qt project,
|
||||||
please visit the official Qt website (https://www.qt.io/).
|
please visit the official Qt website (https://www.qt.io/).
|
||||||
|
|
||||||
|
|
||||||
|
************************************************************************************
|
||||||
|
QHotkey
|
||||||
|
|
||||||
|
Copyright (c) 2016, Felix Barz
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of QHotkey nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
************************************************************************************
|
************************************************************************************
|
||||||
framelesshelper
|
framelesshelper
|
||||||
|
|
||||||
|
@ -209,6 +209,7 @@
|
|||||||
<file>qml/window/FluentInitializrWindow.qml</file>
|
<file>qml/window/FluentInitializrWindow.qml</file>
|
||||||
<file>qml/page/T_OpenGL.qml</file>
|
<file>qml/page/T_OpenGL.qml</file>
|
||||||
<file>qml/page/T_Icons.qml</file>
|
<file>qml/page/T_Icons.qml</file>
|
||||||
|
<file>qml/window/HotkeyWindow.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/"/>
|
<qresource prefix="/"/>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -1,6 +1,54 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE TS>
|
<!DOCTYPE TS>
|
||||||
<TS version="2.1" language="en_US">
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>App</name>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="61"/>
|
||||||
|
<source>Quit</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="68"/>
|
||||||
|
<source>Test1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="75"/>
|
||||||
|
<source>Test2</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="82"/>
|
||||||
|
<source>Test3</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="89"/>
|
||||||
|
<source>Test4</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="96"/>
|
||||||
|
<source>Test5</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="103"/>
|
||||||
|
<source>Test6</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="110"/>
|
||||||
|
<source>Test7</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="117"/>
|
||||||
|
<source>Test8</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>CodeExpander</name>
|
<name>CodeExpander</name>
|
||||||
<message>
|
<message>
|
||||||
@ -71,6 +119,14 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>HotkeyWindow</name>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/window/HotkeyWindow.qml" line="11"/>
|
||||||
|
<source>Hotkey</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>HotloadWindow</name>
|
<name>HotloadWindow</name>
|
||||||
<message>
|
<message>
|
||||||
@ -1987,108 +2043,108 @@ Some contents...</source>
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="73"/>
|
<location filename="qml/page/T_TableView.qml" line="72"/>
|
||||||
<source>Modify the column name</source>
|
<source>Modify the column name</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="74"/>
|
<location filename="qml/page/T_TableView.qml" line="73"/>
|
||||||
<source>Cancel</source>
|
<source>Cancel</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="92"/>
|
<location filename="qml/page/T_TableView.qml" line="91"/>
|
||||||
<source>OK</source>
|
<source>OK</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="134"/>
|
<location filename="qml/page/T_TableView.qml" line="133"/>
|
||||||
<source>Search</source>
|
<source>Search</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="177"/>
|
<location filename="qml/page/T_TableView.qml" line="176"/>
|
||||||
<location filename="qml/page/T_TableView.qml" line="509"/>
|
<location filename="qml/page/T_TableView.qml" line="508"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="211"/>
|
<location filename="qml/page/T_TableView.qml" line="210"/>
|
||||||
<source>Delete</source>
|
<source>Delete</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="218"/>
|
<location filename="qml/page/T_TableView.qml" line="217"/>
|
||||||
<source>Edit</source>
|
<source>Edit</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="237"/>
|
<location filename="qml/page/T_TableView.qml" line="236"/>
|
||||||
<source>Select All</source>
|
<source>Select All</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="365"/>
|
<location filename="qml/page/T_TableView.qml" line="364"/>
|
||||||
<source>Age</source>
|
<source>Age</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="440"/>
|
<location filename="qml/page/T_TableView.qml" line="439"/>
|
||||||
<source>Clear All</source>
|
<source>Clear All</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="447"/>
|
<location filename="qml/page/T_TableView.qml" line="446"/>
|
||||||
<source>Delete Selection</source>
|
<source>Delete Selection</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="470"/>
|
<location filename="qml/page/T_TableView.qml" line="469"/>
|
||||||
<source>Add a row of Data</source>
|
<source>Add a row of Data</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="476"/>
|
<location filename="qml/page/T_TableView.qml" line="475"/>
|
||||||
<source>Insert a Row</source>
|
<source>Insert a Row</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="483"/>
|
<location filename="qml/page/T_TableView.qml" line="482"/>
|
||||||
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="514"/>
|
<location filename="qml/page/T_TableView.qml" line="513"/>
|
||||||
<source>Avatar</source>
|
<source>Avatar</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="528"/>
|
<location filename="qml/page/T_TableView.qml" line="527"/>
|
||||||
<source>Address</source>
|
<source>Address</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="536"/>
|
<location filename="qml/page/T_TableView.qml" line="535"/>
|
||||||
<source>Nickname</source>
|
<source>Nickname</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="543"/>
|
<location filename="qml/page/T_TableView.qml" line="542"/>
|
||||||
<source>Long String</source>
|
<source>Long String</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="551"/>
|
<location filename="qml/page/T_TableView.qml" line="550"/>
|
||||||
<source>Options</source>
|
<source>Options</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="569"/>
|
<location filename="qml/page/T_TableView.qml" line="568"/>
|
||||||
<source><Previous</source>
|
<source><Previous</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="570"/>
|
<location filename="qml/page/T_TableView.qml" line="569"/>
|
||||||
<source>Next></source>
|
<source>Next></source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -1,6 +1,54 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE TS>
|
<!DOCTYPE TS>
|
||||||
<TS version="2.1" language="zh_CN">
|
<TS version="2.1" language="zh_CN">
|
||||||
|
<context>
|
||||||
|
<name>App</name>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="61"/>
|
||||||
|
<source>Quit</source>
|
||||||
|
<translation type="unfinished">退出</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="68"/>
|
||||||
|
<source>Test1</source>
|
||||||
|
<translation type="unfinished">测试1</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="75"/>
|
||||||
|
<source>Test2</source>
|
||||||
|
<translation type="unfinished">测试2</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="82"/>
|
||||||
|
<source>Test3</source>
|
||||||
|
<translation type="unfinished">测试3</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="89"/>
|
||||||
|
<source>Test4</source>
|
||||||
|
<translation type="unfinished">测试4</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="96"/>
|
||||||
|
<source>Test5</source>
|
||||||
|
<translation type="unfinished">测试5</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="103"/>
|
||||||
|
<source>Test6</source>
|
||||||
|
<translation type="unfinished">测试6</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="110"/>
|
||||||
|
<source>Test7</source>
|
||||||
|
<translation type="unfinished">测试7</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/App.qml" line="117"/>
|
||||||
|
<source>Test8</source>
|
||||||
|
<translation type="unfinished">测试8</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>CodeExpander</name>
|
<name>CodeExpander</name>
|
||||||
<message>
|
<message>
|
||||||
@ -71,6 +119,14 @@
|
|||||||
<translation type="unfinished">创建</translation>
|
<translation type="unfinished">创建</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>HotkeyWindow</name>
|
||||||
|
<message>
|
||||||
|
<location filename="qml/window/HotkeyWindow.qml" line="11"/>
|
||||||
|
<source>Hotkey</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>HotloadWindow</name>
|
<name>HotloadWindow</name>
|
||||||
<message>
|
<message>
|
||||||
@ -2043,6 +2099,10 @@ Some contents...</source>
|
|||||||
<source>ShortcutPicker</source>
|
<source>ShortcutPicker</source>
|
||||||
<translation type="unfinished">快捷键选择器</translation>
|
<translation type="unfinished">快捷键选择器</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Quit</source>
|
||||||
|
<translation type="obsolete">退出</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Activate the Shortcut</source>
|
<source>Activate the Shortcut</source>
|
||||||
<translation type="obsolete">激活快捷键</translation>
|
<translation type="obsolete">激活快捷键</translation>
|
||||||
@ -2133,108 +2193,108 @@ Some contents...</source>
|
|||||||
<translation type="unfinished">表格</translation>
|
<translation type="unfinished">表格</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="73"/>
|
<location filename="qml/page/T_TableView.qml" line="72"/>
|
||||||
<source>Modify the column name</source>
|
<source>Modify the column name</source>
|
||||||
<translation type="unfinished">修改列名</translation>
|
<translation type="unfinished">修改列名</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="74"/>
|
<location filename="qml/page/T_TableView.qml" line="73"/>
|
||||||
<source>Cancel</source>
|
<source>Cancel</source>
|
||||||
<translation type="unfinished">取消</translation>
|
<translation type="unfinished">取消</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="92"/>
|
<location filename="qml/page/T_TableView.qml" line="91"/>
|
||||||
<source>OK</source>
|
<source>OK</source>
|
||||||
<translation type="unfinished">确定</translation>
|
<translation type="unfinished">确定</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="134"/>
|
<location filename="qml/page/T_TableView.qml" line="133"/>
|
||||||
<source>Search</source>
|
<source>Search</source>
|
||||||
<translation type="unfinished">搜索</translation>
|
<translation type="unfinished">搜索</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="177"/>
|
<location filename="qml/page/T_TableView.qml" line="176"/>
|
||||||
<location filename="qml/page/T_TableView.qml" line="509"/>
|
<location filename="qml/page/T_TableView.qml" line="508"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation type="unfinished">名称</translation>
|
<translation type="unfinished">名称</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="211"/>
|
<location filename="qml/page/T_TableView.qml" line="210"/>
|
||||||
<source>Delete</source>
|
<source>Delete</source>
|
||||||
<translation type="unfinished">删除</translation>
|
<translation type="unfinished">删除</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="218"/>
|
<location filename="qml/page/T_TableView.qml" line="217"/>
|
||||||
<source>Edit</source>
|
<source>Edit</source>
|
||||||
<translation type="unfinished">编辑</translation>
|
<translation type="unfinished">编辑</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="237"/>
|
<location filename="qml/page/T_TableView.qml" line="236"/>
|
||||||
<source>Select All</source>
|
<source>Select All</source>
|
||||||
<translation type="unfinished">全选</translation>
|
<translation type="unfinished">全选</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="365"/>
|
<location filename="qml/page/T_TableView.qml" line="364"/>
|
||||||
<source>Age</source>
|
<source>Age</source>
|
||||||
<translation type="unfinished">年龄</translation>
|
<translation type="unfinished">年龄</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="440"/>
|
<location filename="qml/page/T_TableView.qml" line="439"/>
|
||||||
<source>Clear All</source>
|
<source>Clear All</source>
|
||||||
<translation type="unfinished">清除所有</translation>
|
<translation type="unfinished">清除所有</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="476"/>
|
<location filename="qml/page/T_TableView.qml" line="475"/>
|
||||||
<source>Insert a Row</source>
|
<source>Insert a Row</source>
|
||||||
<translation type="unfinished">插入一行</translation>
|
<translation type="unfinished">插入一行</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="483"/>
|
<location filename="qml/page/T_TableView.qml" line="482"/>
|
||||||
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
<source>Focus not acquired: Please click any item in the form as the target for insertion!</source>
|
||||||
<translation type="unfinished">焦点未获取:请点击表格中的任意一项,作为插入的靶点!</translation>
|
<translation type="unfinished">焦点未获取:请点击表格中的任意一项,作为插入的靶点!</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="514"/>
|
<location filename="qml/page/T_TableView.qml" line="513"/>
|
||||||
<source>Avatar</source>
|
<source>Avatar</source>
|
||||||
<translation type="unfinished">头像</translation>
|
<translation type="unfinished">头像</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="528"/>
|
<location filename="qml/page/T_TableView.qml" line="527"/>
|
||||||
<source>Address</source>
|
<source>Address</source>
|
||||||
<translation type="unfinished">地址</translation>
|
<translation type="unfinished">地址</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="536"/>
|
<location filename="qml/page/T_TableView.qml" line="535"/>
|
||||||
<source>Nickname</source>
|
<source>Nickname</source>
|
||||||
<translation type="unfinished">昵称</translation>
|
<translation type="unfinished">昵称</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="543"/>
|
<location filename="qml/page/T_TableView.qml" line="542"/>
|
||||||
<source>Long String</source>
|
<source>Long String</source>
|
||||||
<translation type="unfinished">长字符串</translation>
|
<translation type="unfinished">长字符串</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="551"/>
|
<location filename="qml/page/T_TableView.qml" line="550"/>
|
||||||
<source>Options</source>
|
<source>Options</source>
|
||||||
<translation type="unfinished">操作</translation>
|
<translation type="unfinished">操作</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="569"/>
|
<location filename="qml/page/T_TableView.qml" line="568"/>
|
||||||
<source><Previous</source>
|
<source><Previous</source>
|
||||||
<translation type="unfinished"><上一页</translation>
|
<translation type="unfinished"><上一页</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="570"/>
|
<location filename="qml/page/T_TableView.qml" line="569"/>
|
||||||
<source>Next></source>
|
<source>Next></source>
|
||||||
<translation type="unfinished">下一页></translation>
|
<translation type="unfinished">下一页></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="447"/>
|
<location filename="qml/page/T_TableView.qml" line="446"/>
|
||||||
<source>Delete Selection</source>
|
<source>Delete Selection</source>
|
||||||
<translation type="unfinished">删除选中</translation>
|
<translation type="unfinished">删除选中</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/page/T_TableView.qml" line="470"/>
|
<location filename="qml/page/T_TableView.qml" line="469"/>
|
||||||
<source>Add a row of Data</source>
|
<source>Add a row of Data</source>
|
||||||
<translation type="unfinished">添加一行数据</translation>
|
<translation type="unfinished">添加一行数据</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -43,7 +43,8 @@ FluLauncher {
|
|||||||
"/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml",
|
"/singleTaskWindow":"qrc:/example/qml/window/SingleTaskWindow.qml",
|
||||||
"/standardWindow":"qrc:/example/qml/window/StandardWindow.qml",
|
"/standardWindow":"qrc:/example/qml/window/StandardWindow.qml",
|
||||||
"/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml",
|
"/singleInstanceWindow":"qrc:/example/qml/window/SingleInstanceWindow.qml",
|
||||||
"/pageWindow":"qrc:/example/qml/window/PageWindow.qml"
|
"/pageWindow":"qrc:/example/qml/window/PageWindow.qml",
|
||||||
|
"/hotkey":"qrc:/example/qml/window/HotkeyWindow.qml"
|
||||||
}
|
}
|
||||||
var args = Qt.application.arguments
|
var args = Qt.application.arguments
|
||||||
if(args.length>=2 && args[1].startsWith("-crashed=")){
|
if(args.length>=2 && args[1].startsWith("-crashed=")){
|
||||||
@ -52,4 +53,73 @@ FluLauncher {
|
|||||||
FluRouter.navigate("/")
|
FluRouter.navigate("/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property alias hotkeys: object_hotkey
|
||||||
|
FluObject{
|
||||||
|
id: object_hotkey
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Quit")
|
||||||
|
sequence: "Ctrl+Alt+Q"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.exit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test1")
|
||||||
|
sequence: "Alt+A"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test2")
|
||||||
|
sequence: "Alt+B"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test3")
|
||||||
|
sequence: "Alt+C"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test4")
|
||||||
|
sequence: "Alt+D"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test5")
|
||||||
|
sequence: "Alt+E"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test6")
|
||||||
|
sequence: "Alt+F"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test7")
|
||||||
|
sequence: "Alt+G"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluHotkey{
|
||||||
|
name: qsTr("Test8")
|
||||||
|
sequence: "Alt+H"
|
||||||
|
onActivated: {
|
||||||
|
FluRouter.navigate("/hotkey",{sequence:sequence})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,26 @@ FluScrollablePage{
|
|||||||
|
|
||||||
FluFrame{
|
FluFrame{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 100
|
Layout.preferredHeight: childrenRect.height
|
||||||
padding: 10
|
ColumnLayout{
|
||||||
FluShortcutPicker{
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
Item{
|
||||||
|
Layout.preferredHeight: 15
|
||||||
|
}
|
||||||
|
Repeater{
|
||||||
|
model: FluApp.launcher.hotkeys.children
|
||||||
|
delegate: FluShortcutPicker{
|
||||||
|
text: model.name
|
||||||
|
syncHotkey: FluApp.launcher.hotkeys.children[index]
|
||||||
|
Layout.leftMargin: 15
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item{
|
||||||
|
Layout.preferredHeight: 15
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -6
|
Layout.topMargin: -6
|
||||||
@ -26,5 +40,3 @@ FluScrollablePage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ FluContentPage{
|
|||||||
title: qsTr("TableView")
|
title: qsTr("TableView")
|
||||||
signal checkBoxChanged
|
signal checkBoxChanged
|
||||||
|
|
||||||
property var dataSource : []
|
|
||||||
property int sortType: 0
|
property int sortType: 0
|
||||||
property bool selectedAll: true
|
property bool selectedAll: true
|
||||||
property string nameKeyword: ""
|
property string nameKeyword: ""
|
||||||
@ -621,7 +620,6 @@ FluContentPage{
|
|||||||
for(var i=0;i<count;i++){
|
for(var i=0;i<count;i++){
|
||||||
dataSource.push(genTestObject())
|
dataSource.push(genTestObject())
|
||||||
}
|
}
|
||||||
root.dataSource = dataSource
|
table_view.dataSource = dataSource
|
||||||
table_view.dataSource = root.dataSource
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
example/qml/window/HotkeyWindow.qml
Normal file
26
example/qml/window/HotkeyWindow.qml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
import FluentUI 1.0
|
||||||
|
import "../component"
|
||||||
|
|
||||||
|
FluWindow {
|
||||||
|
|
||||||
|
id: window
|
||||||
|
property string sequence: ""
|
||||||
|
title: qsTr("Hotkey")
|
||||||
|
width: 250
|
||||||
|
height: 250
|
||||||
|
fixSize: true
|
||||||
|
launchMode: FluWindowType.SingleInstance
|
||||||
|
onInitArgument:
|
||||||
|
(argument)=>{
|
||||||
|
window.sequence = argument.sequence
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color: FluTheme.primaryColor
|
||||||
|
font: FluTextStyle.Title
|
||||||
|
text: window.sequence
|
||||||
|
}
|
||||||
|
}
|
@ -14,9 +14,9 @@ FluWindow {
|
|||||||
id:window
|
id:window
|
||||||
title: "FluentUI"
|
title: "FluentUI"
|
||||||
width: 1000
|
width: 1000
|
||||||
height: 680
|
height: 668
|
||||||
minimumWidth: 800
|
minimumWidth: 668
|
||||||
minimumHeight: 200
|
minimumHeight: 320
|
||||||
launchMode: FluWindowType.SingleTask
|
launchMode: FluWindowType.SingleTask
|
||||||
fitsAppBarWindows: true
|
fitsAppBarWindows: true
|
||||||
appBar: FluAppBar {
|
appBar: FluAppBar {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QOpenGLFramebufferObjectFormat>
|
#include <QOpenGLFramebufferObjectFormat>
|
||||||
#include <QOpenGLShaderProgram>
|
#include <QOpenGLShaderProgram>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
class FBORenderer : public QQuickFramebufferObject::Renderer, protected QOpenGLFunctions {
|
class FBORenderer : public QQuickFramebufferObject::Renderer, protected QOpenGLFunctions {
|
||||||
public:
|
public:
|
||||||
@ -47,6 +48,7 @@ QOpenGLFramebufferObject *FBORenderer::createFramebufferObject(const QSize &size
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FBORenderer::render() {
|
void FBORenderer::render() {
|
||||||
|
auto pixelRatio = item->window()->devicePixelRatio();
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@ -61,7 +63,7 @@ void FBORenderer::render() {
|
|||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
program.setAttributeArray(0, GL_FLOAT, values, 2);
|
program.setAttributeArray(0, GL_FLOAT, values, 2);
|
||||||
program.setUniformValue("t", (float) item->t());
|
program.setUniformValue("t", (float) item->t());
|
||||||
glViewport(0, 0, qRound(item->width()), qRound(item->height()));
|
glViewport(0, 0, qRound(item->width()*pixelRatio), qRound(item->height()*pixelRatio));
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
@ -11,6 +11,13 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.cmake/)
|
|||||||
#配置通用编译
|
#配置通用编译
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
if (QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||||
|
qt_standard_project_setup()
|
||||||
|
else ()
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
#设置版本号
|
#设置版本号
|
||||||
add_definitions(-DFLUENTUI_VERSION=1,7,5,0)
|
add_definitions(-DFLUENTUI_VERSION=1,7,5,0)
|
||||||
@ -35,14 +42,6 @@ if (NOT FLUENTUI_QML_PLUGIN_DIRECTORY)
|
|||||||
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/FluentUI)
|
set(FLUENTUI_QML_PLUGIN_DIRECTORY ${QT_SDK_DIR}/qml/FluentUI)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
|
||||||
qt_standard_project_setup()
|
|
||||||
else ()
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_AUTORCC ON)
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
#国际化
|
#国际化
|
||||||
find_program(QT_LUPDATE NAMES lupdate)
|
find_program(QT_LUPDATE NAMES lupdate)
|
||||||
find_program(QT_LRELEASE NAMES lrelease)
|
find_program(QT_LRELEASE NAMES lrelease)
|
||||||
@ -62,9 +61,28 @@ file(COPY ${QM_FILE_PATHS} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/Qt${QT_VERSI
|
|||||||
file(GLOB_RECURSE CPP_FILES *.cpp *.h *.cxx)
|
file(GLOB_RECURSE CPP_FILES *.cpp *.h *.cxx)
|
||||||
foreach (filepath ${CPP_FILES})
|
foreach (filepath ${CPP_FILES})
|
||||||
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" filename ${filepath})
|
||||||
|
message(${filename})
|
||||||
list(APPEND sources_files ${filename})
|
list(APPEND sources_files ${filename})
|
||||||
endforeach (filepath)
|
endforeach (filepath)
|
||||||
|
|
||||||
|
list(REMOVE_ITEM sources_files qhotkey/qhotkey_mac.cpp qhotkey/qhotkey_win.cpp qhotkey/qhotkey_x11.cpp)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
list(APPEND sources_files qhotkey/qhotkey_win.cpp)
|
||||||
|
elseif (APPLE)
|
||||||
|
list(APPEND sources_files qhotkey/qhotkey_mac.cpp)
|
||||||
|
elseif (UNIX)
|
||||||
|
list(APPEND sources_files qhotkey/qhotkey_x11.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(FLUENTUI_VERSION_RC_PATH ${CMAKE_CURRENT_BINARY_DIR}/version_${PROJECT_NAME}.rc)
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/.cmake/version_dll.rc.in
|
||||||
|
${FLUENTUI_VERSION_RC_PATH}
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (QT_VERSION VERSION_GREATER_EQUAL "6.2")
|
if (QT_VERSION VERSION_GREATER_EQUAL "6.2")
|
||||||
#删除fluentuiplugin.cpp与fluentuiplugin.h,这些只要Qt5使用,Qt6不需要
|
#删除fluentuiplugin.cpp与fluentuiplugin.h,这些只要Qt5使用,Qt6不需要
|
||||||
list(REMOVE_ITEM sources_files fluentuiplugin.h fluentuiplugin.cpp)
|
list(REMOVE_ITEM sources_files fluentuiplugin.h fluentuiplugin.cpp)
|
||||||
@ -179,6 +197,24 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
|
|||||||
Qt${QT_VERSION_MAJOR}::Quick
|
Qt${QT_VERSION_MAJOR}::Quick
|
||||||
Qt${QT_VERSION_MAJOR}::Qml
|
Qt${QT_VERSION_MAJOR}::Qml
|
||||||
)
|
)
|
||||||
|
if(APPLE)
|
||||||
|
find_library(CARBON_LIBRARY Carbon)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${CARBON_LIBRARY})
|
||||||
|
elseif(WIN32)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE user32)
|
||||||
|
elseif(UNIX)
|
||||||
|
if(QT_VERSION_MAJOR STREQUAL "6")
|
||||||
|
if(QT_VERSION VERSION_LESS "6.2.0")
|
||||||
|
message(FATAL_ERROR "Qt 6.2.0 or greater is required when using Qt6")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(QT_VERSION_MAJOR LESS "6")
|
||||||
|
find_package(Qt5 REQUIRED COMPONENTS X11Extras)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::X11Extras)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE X11)
|
||||||
|
endif()
|
||||||
|
|
||||||
if ((${QT_VERSION_MAJOR} LESS_EQUAL 6) AND (CMAKE_BUILD_TYPE MATCHES "Release"))
|
if ((${QT_VERSION_MAJOR} LESS_EQUAL 6) AND (CMAKE_BUILD_TYPE MATCHES "Release"))
|
||||||
find_program(QML_PLUGIN_DUMP NAMES qmlplugindump)
|
find_program(QML_PLUGIN_DUMP NAMES qmlplugindump)
|
||||||
|
@ -16,9 +16,10 @@ FluApp::FluApp(QObject *parent) : QObject{parent} {
|
|||||||
|
|
||||||
FluApp::~FluApp() = default;
|
FluApp::~FluApp() = default;
|
||||||
|
|
||||||
void FluApp::init(QObject *target, QLocale locale) {
|
void FluApp::init(QObject *launcher, QLocale locale) {
|
||||||
|
this->launcher(launcher);
|
||||||
_locale = std::move(locale);
|
_locale = std::move(locale);
|
||||||
_engine = qmlEngine(target);
|
_engine = qmlEngine(launcher);
|
||||||
_translator = new QTranslator(this);
|
_translator = new QTranslator(this);
|
||||||
QGuiApplication::installTranslator(_translator);
|
QGuiApplication::installTranslator(_translator);
|
||||||
const QStringList uiLanguages = _locale.uiLanguages();
|
const QStringList uiLanguages = _locale.uiLanguages();
|
||||||
@ -33,7 +34,7 @@ void FluApp::init(QObject *target, QLocale locale) {
|
|||||||
|
|
||||||
[[maybe_unused]] QJsonArray FluApp::iconData(const QString &keyword) {
|
[[maybe_unused]] QJsonArray FluApp::iconData(const QString &keyword) {
|
||||||
QJsonArray arr;
|
QJsonArray arr;
|
||||||
QMetaEnum enumType = Fluent_Icons::staticMetaObject.enumerator(Fluent_Icons::staticMetaObject.indexOfEnumerator("Fluent_IconType"));
|
QMetaEnum enumType = FluentIcons::staticMetaObject.enumerator(FluentIcons::staticMetaObject.indexOfEnumerator("Type"));
|
||||||
for (int i = 0; i <= enumType.keyCount() - 1; ++i) {
|
for (int i = 0; i <= enumType.keyCount() - 1; ++i) {
|
||||||
QString name = enumType.key(i);
|
QString name = enumType.key(i);
|
||||||
int icon = enumType.value(i);
|
int icon = enumType.value(i);
|
||||||
|
@ -21,6 +21,7 @@ Q_OBJECT
|
|||||||
Q_PROPERTY_AUTO(bool, useSystemAppBar)
|
Q_PROPERTY_AUTO(bool, useSystemAppBar)
|
||||||
Q_PROPERTY_AUTO(QString, windowIcon)
|
Q_PROPERTY_AUTO(QString, windowIcon)
|
||||||
Q_PROPERTY_AUTO(QLocale, locale)
|
Q_PROPERTY_AUTO(QLocale, locale)
|
||||||
|
Q_PROPERTY_AUTO_P(QObject*,launcher)
|
||||||
QML_NAMED_ELEMENT(FluApp)
|
QML_NAMED_ELEMENT(FluApp)
|
||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ SINGLETON(FluApp)
|
|||||||
|
|
||||||
static FluApp *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
static FluApp *create(QQmlEngine *, QJSEngine *) { return getInstance(); }
|
||||||
|
|
||||||
Q_INVOKABLE void init(QObject *target, QLocale locale = QLocale::system());
|
Q_INVOKABLE void init(QObject *launcher, QLocale locale = QLocale::system());
|
||||||
|
|
||||||
[[maybe_unused]] Q_INVOKABLE static QJsonArray iconData(const QString &keyword = "");
|
[[maybe_unused]] Q_INVOKABLE static QJsonArray iconData(const QString &keyword = "");
|
||||||
|
|
||||||
|
@ -131,10 +131,14 @@ void FluFrameless::componentComplete() {
|
|||||||
setShadow(hwnd);
|
setShadow(hwnd);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
h = qRound(h + _appbar->height());
|
auto appBarHeight = _appbar->height();
|
||||||
|
h = qRound(h + appBarHeight);
|
||||||
if (_fixSize) {
|
if (_fixSize) {
|
||||||
window()->setMaximumSize(QSize(w, h));
|
window()->setMaximumSize(QSize(w, h));
|
||||||
window()->setMinimumSize(QSize(w, h));
|
window()->setMinimumSize(QSize(w, h));
|
||||||
|
} else {
|
||||||
|
window()->setMinimumHeight(window()->minimumHeight() + appBarHeight);
|
||||||
|
window()->setMaximumHeight(window()->maximumHeight() + appBarHeight);
|
||||||
}
|
}
|
||||||
window()->resize(QSize(w, h));
|
window()->resize(QSize(w, h));
|
||||||
connect(this, &FluFrameless::topmostChanged, this, [this] {
|
connect(this, &FluFrameless::topmostChanged, this, [this] {
|
||||||
@ -188,8 +192,8 @@ void FluFrameless::componentComplete() {
|
|||||||
bool isMaximum = ::IsZoomed(hwnd);
|
bool isMaximum = ::IsZoomed(hwnd);
|
||||||
if (isMaximum) {
|
if (isMaximum) {
|
||||||
auto geometry = window()->screen()->geometry();
|
auto geometry = window()->screen()->geometry();
|
||||||
auto offsetX = qAbs(geometry.left()-originalLeft);
|
auto offsetX = qAbs(geometry.left() - originalLeft);
|
||||||
auto offsetY = qAbs(geometry.top()-originalTop);
|
auto offsetY = qAbs(geometry.top() - originalTop);
|
||||||
clientRect->top = originalTop + offsetY;
|
clientRect->top = originalTop + offsetY;
|
||||||
clientRect->bottom = originalBottom - offsetY;
|
clientRect->bottom = originalBottom - offsetY;
|
||||||
clientRect->left = originalLeft + offsetX;
|
clientRect->left = originalLeft + offsetX;
|
||||||
@ -269,16 +273,8 @@ void FluFrameless::componentComplete() {
|
|||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
} else if (uMsg == WM_NCACTIVATE) {
|
} else if (uMsg == WM_NCACTIVATE) {
|
||||||
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
|
||||||
*result = TRUE;
|
*result = TRUE;
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
if (isCompositionEnabled()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*result = TRUE;
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
} else if (uMsg == WM_GETMINMAXINFO) {
|
} else if (uMsg == WM_GETMINMAXINFO) {
|
||||||
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
#if (QT_VERSION == QT_VERSION_CHECK(6, 5, 3) || QT_VERSION == QT_VERSION_CHECK(6, 6, 0))
|
||||||
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
|
||||||
@ -375,7 +371,7 @@ void FluFrameless::_showSystemMenu(QPoint point) {
|
|||||||
}
|
}
|
||||||
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(),
|
const int result = ::TrackPopupMenu(hMenu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), nativePos.x(),
|
||||||
nativePos.y(), 0, hwnd, nullptr);
|
nativePos.y(), 0, hwnd, nullptr);
|
||||||
if (result != FALSE) {
|
if (result) {
|
||||||
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
::PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -402,13 +398,13 @@ bool FluFrameless::_hitMaximizeButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FluFrameless::_setMaximizePressed(bool val) {
|
void FluFrameless::_setMaximizePressed(bool val) {
|
||||||
if(_maximizeButton){
|
if (_maximizeButton) {
|
||||||
_maximizeButton->setProperty("down", val);
|
_maximizeButton->setProperty("down", val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluFrameless::_setMaximizeHovered(bool val) {
|
void FluFrameless::_setMaximizeHovered(bool val) {
|
||||||
if(_maximizeButton){
|
if (_maximizeButton) {
|
||||||
_maximizeButton->setProperty("hover", val);
|
_maximizeButton->setProperty("hover", val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
src/FluHotkey.cpp
Normal file
32
src/FluHotkey.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "FluHotkey.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "QGuiApplication"
|
||||||
|
|
||||||
|
FluHotkey::FluHotkey(QObject *parent)
|
||||||
|
: QObject{parent}
|
||||||
|
{
|
||||||
|
_sequence = "";
|
||||||
|
_isRegistered = false;
|
||||||
|
connect(this,&FluHotkey::sequenceChanged,this,[=]{
|
||||||
|
if(_hotkey){
|
||||||
|
delete _hotkey;
|
||||||
|
_hotkey = nullptr;
|
||||||
|
}
|
||||||
|
_hotkey = new QHotkey(QKeySequence(_sequence), true, qApp);
|
||||||
|
this->isRegistered(_hotkey->isRegistered());
|
||||||
|
QObject::connect(_hotkey, &QHotkey::activated, qApp, [=](){
|
||||||
|
Q_EMIT this->activated();
|
||||||
|
});
|
||||||
|
QObject::connect(_hotkey, &QHotkey::registeredChanged, qApp, [=](){
|
||||||
|
this->isRegistered(_hotkey->isRegistered());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
FluHotkey::~FluHotkey(){
|
||||||
|
if(_hotkey){
|
||||||
|
delete _hotkey;
|
||||||
|
_hotkey = nullptr;
|
||||||
|
}
|
||||||
|
}
|
24
src/FluHotkey.h
Normal file
24
src/FluHotkey.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef FLUHOTKEY_H
|
||||||
|
#define FLUHOTKEY_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include "qhotkey/qhotkey.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
class FluHotkey : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY_AUTO(QString,sequence)
|
||||||
|
Q_PROPERTY_AUTO(QString,name)
|
||||||
|
Q_PROPERTY_READONLY_AUTO(bool,isRegistered)
|
||||||
|
QML_NAMED_ELEMENT(FluHotkey)
|
||||||
|
public:
|
||||||
|
explicit FluHotkey(QObject *parent = nullptr);
|
||||||
|
~FluHotkey();
|
||||||
|
Q_SIGNAL void activated();
|
||||||
|
private:
|
||||||
|
QHotkey* _hotkey = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FLUHOTKEY_H
|
@ -31,16 +31,6 @@ QHash<int, QByteArray> FluTableModel::roleNames() const {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FluTableModel::parent(const QModelIndex &child) const {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex FluTableModel::index(int row, int column, const QModelIndex &parent) const {
|
|
||||||
if (!hasIndex(row, column, parent) || parent.isValid())
|
|
||||||
return {};
|
|
||||||
return createIndex(row, column);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FluTableModel::clear() {
|
void FluTableModel::clear() {
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
this->_rows.clear();
|
this->_rows.clear();
|
||||||
|
@ -28,10 +28,6 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
[[nodiscard]] QModelIndex parent(const QModelIndex &child) const override;
|
|
||||||
|
|
||||||
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
|
||||||
|
|
||||||
Q_INVOKABLE void clear();
|
Q_INVOKABLE void clear();
|
||||||
|
|
||||||
Q_INVOKABLE QVariant getRow(int rowIndex);
|
Q_INVOKABLE QVariant getRow(int rowIndex);
|
||||||
|
@ -9,16 +9,6 @@ FluTreeModel::FluTreeModel(QObject *parent) : QAbstractTableModel{parent} {
|
|||||||
_dataSourceSize = 0;
|
_dataSourceSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex FluTreeModel::parent(const QModelIndex &child) const {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex FluTreeModel::index(int row, int column, const QModelIndex &parent) const {
|
|
||||||
if (!hasIndex(row, column, parent) || parent.isValid())
|
|
||||||
return {};
|
|
||||||
return createIndex(row, column);
|
|
||||||
}
|
|
||||||
|
|
||||||
int FluTreeModel::rowCount(const QModelIndex &parent) const {
|
int FluTreeModel::rowCount(const QModelIndex &parent) const {
|
||||||
return _rows.count();
|
return _rows.count();
|
||||||
}
|
}
|
||||||
|
@ -107,10 +107,6 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
[[nodiscard]] QModelIndex parent(const QModelIndex &child) const override;
|
|
||||||
|
|
||||||
[[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
|
||||||
|
|
||||||
Q_INVOKABLE void removeRows(int row, int count);
|
Q_INVOKABLE void removeRows(int row, int count);
|
||||||
|
|
||||||
Q_INVOKABLE void insertRows(int row, const QList<FluTreeNode *> &data);
|
Q_INVOKABLE void insertRows(int row, const QList<FluTreeNode *> &data);
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
namespace Fluent_Icons {
|
namespace FluentIcons {
|
||||||
Q_NAMESPACE
|
Q_NAMESPACE
|
||||||
enum class Fluent_IconType {
|
enum class Type {
|
||||||
GlobalNavButton = 0xe700,
|
GlobalNavButton = 0xe700,
|
||||||
Wifi = 0xe701,
|
Wifi = 0xe701,
|
||||||
Bluetooth = 0xe702,
|
Bluetooth = 0xe702,
|
||||||
@ -1411,7 +1411,7 @@ namespace Fluent_Icons {
|
|||||||
ClickedOutLoudSolidBold = 0xf8b3
|
ClickedOutLoudSolidBold = 0xf8b3
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ENUM_NS(Fluent_IconType)
|
Q_ENUM_NS(Type)
|
||||||
|
|
||||||
QML_NAMED_ELEMENT(FluentIcons)
|
QML_NAMED_ELEMENT(FluentIcons)
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "FluTableSortProxyModel.h"
|
#include "FluTableSortProxyModel.h"
|
||||||
#include "FluFrameless.h"
|
#include "FluFrameless.h"
|
||||||
#include "FluTableModel.h"
|
#include "FluTableModel.h"
|
||||||
|
#include "FluHotkey.h"
|
||||||
|
|
||||||
void FluentUI::registerTypes(QQmlEngine *engine) {
|
void FluentUI::registerTypes(QQmlEngine *engine) {
|
||||||
initializeEngine(engine, _uri);
|
initializeEngine(engine, _uri);
|
||||||
@ -36,6 +37,7 @@ void FluentUI::registerTypes(const char *uri) const {
|
|||||||
qmlRegisterType<FluTableModel>(uri, major, minor, "FluTableModel");
|
qmlRegisterType<FluTableModel>(uri, major, minor, "FluTableModel");
|
||||||
qmlRegisterType<FluRectangle>(uri, major, minor, "FluRectangle");
|
qmlRegisterType<FluRectangle>(uri, major, minor, "FluRectangle");
|
||||||
qmlRegisterType<FluFrameless>(uri, major, minor, "FluFrameless");
|
qmlRegisterType<FluFrameless>(uri, major, minor, "FluFrameless");
|
||||||
|
qmlRegisterType<FluHotkey>(uri, major, minor, "FluHotkey");
|
||||||
qmlRegisterType<FluTableSortProxyModel>(uri, major, minor, "FluTableSortProxyModel");
|
qmlRegisterType<FluTableSortProxyModel>(uri, major, minor, "FluTableSortProxyModel");
|
||||||
|
|
||||||
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAcrylic.qml"), uri, major, minor, "FluAcrylic");
|
qmlRegisterType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluAcrylic.qml"), uri, major, minor, "FluAcrylic");
|
||||||
@ -134,7 +136,7 @@ void FluentUI::registerTypes(const char *uri) const {
|
|||||||
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRouter.qml"), uri, major, minor, "FluRouter");
|
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluRouter.qml"), uri, major, minor, "FluRouter");
|
||||||
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluEventBus.qml"), uri, major, minor, "FluEventBus");
|
qmlRegisterSingletonType(QUrl("qrc:/qt/qml/FluentUI/Controls/FluEventBus.qml"), uri, major, minor, "FluEventBus");
|
||||||
|
|
||||||
qmlRegisterUncreatableMetaObject(Fluent_Icons::staticMetaObject, uri, major, minor, "FluentIcons", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluentIcons::staticMetaObject, uri, major, minor, "FluentIcons", "Access to enums & flags only");
|
||||||
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri, major, minor, "FluThemeType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluThemeType::staticMetaObject, uri, major, minor, "FluThemeType", "Access to enums & flags only");
|
||||||
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri, major, minor, "FluPageType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluPageType::staticMetaObject, uri, major, minor, "FluPageType", "Access to enums & flags only");
|
||||||
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri, major, minor, "FluWindowType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluWindowType::staticMetaObject, uri, major, minor, "FluWindowType", "Access to enums & flags only");
|
||||||
@ -148,20 +150,35 @@ void FluentUI::registerTypes(const char *uri) const {
|
|||||||
qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri, major, minor, "FluTimelineType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluTimelineType::staticMetaObject, uri, major, minor, "FluTimelineType", "Access to enums & flags only");
|
||||||
qmlRegisterUncreatableMetaObject(FluSheetType::staticMetaObject, uri, major, minor, "FluSheetType", "Access to enums & flags only");
|
qmlRegisterUncreatableMetaObject(FluSheetType::staticMetaObject, uri, major, minor, "FluSheetType", "Access to enums & flags only");
|
||||||
|
|
||||||
|
qmlRegisterSingletonType(uri, major, minor, "FluApp", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue {
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
return scriptEngine->newQObject(FluApp::getInstance());
|
||||||
|
});
|
||||||
|
qmlRegisterSingletonType(uri, major, minor, "FluColors", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue {
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
return scriptEngine->newQObject(FluColors::getInstance());
|
||||||
|
});
|
||||||
|
qmlRegisterSingletonType(uri, major, minor, "FluTheme", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue {
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
return scriptEngine->newQObject(FluTheme::getInstance());
|
||||||
|
});
|
||||||
|
qmlRegisterSingletonType(uri, major, minor, "FluTools", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue {
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
return scriptEngine->newQObject(FluTools::getInstance());
|
||||||
|
});
|
||||||
|
qmlRegisterSingletonType(uri, major, minor, "FluTextStyle", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QJSValue {
|
||||||
|
Q_UNUSED(engine)
|
||||||
|
return scriptEngine->newQObject(FluTextStyle::getInstance());
|
||||||
|
});
|
||||||
// qmlRegisterSingletonInstance(uri, major, minor, "FluApp", FluApp::getInstance());
|
// qmlRegisterSingletonInstance(uri, major, minor, "FluApp", FluApp::getInstance());
|
||||||
// qmlRegisterSingletonInstance(uri, major, minor, "FluColors", FluColors::getInstance());
|
// qmlRegisterSingletonInstance(uri, major, minor, "FluColors", FluColors::getInstance());
|
||||||
// qmlRegisterSingletonInstance(uri, major, minor, "FluTheme", FluTheme::getInstance());
|
// qmlRegisterSingletonInstance(uri, major, minor, "FluTheme", FluTheme::getInstance());
|
||||||
// qmlRegisterSingletonInstance(uri, major, minor, "FluTools", FluTools::getInstance());
|
// qmlRegisterSingletonInstance(uri, major, minor, "FluTools", FluTools::getInstance());
|
||||||
// qmlRegisterSingletonInstance(uri, major, minor, "FluTextStyle", FluTextStyle::getInstance());
|
// qmlRegisterSingletonInstance(uri, major, minor, "FluTextStyle", FluTextStyle::getInstance());
|
||||||
|
|
||||||
qmlRegisterModule(uri, major, minor);
|
qmlRegisterModule(uri, major, minor);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluentUI::initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri) {
|
void FluentUI::initializeEngine(QQmlEngine *engine, [[maybe_unused]] const char *uri) {
|
||||||
engine->rootContext()->setContextProperty("FluApp", FluApp::getInstance());
|
Q_UNUSED(engine)
|
||||||
engine->rootContext()->setContextProperty("FluColors", FluColors::getInstance());
|
|
||||||
engine->rootContext()->setContextProperty("FluTheme", FluTheme::getInstance());
|
|
||||||
engine->rootContext()->setContextProperty("FluTools", FluTools::getInstance());
|
|
||||||
engine->rootContext()->setContextProperty("FluTextStyle", FluTextStyle::getInstance());
|
|
||||||
}
|
}
|
||||||
|
@ -3,45 +3,40 @@ import QtQuick.Controls 2.15
|
|||||||
import FluentUI 1.0
|
import FluentUI 1.0
|
||||||
|
|
||||||
FluObject {
|
FluObject {
|
||||||
property var root;
|
property var root
|
||||||
property int layoutY: 75
|
property int layoutY: 75
|
||||||
id:control
|
id:control
|
||||||
FluObject{
|
FluObject{
|
||||||
id:mcontrol
|
id:mcontrol
|
||||||
property string const_success: "success";
|
property string const_success: "success"
|
||||||
property string const_info: "info";
|
property string const_info: "info"
|
||||||
property string const_warning: "warning";
|
property string const_warning: "warning"
|
||||||
property string const_error: "error";
|
property string const_error: "error"
|
||||||
property int maxWidth: 300;
|
property int maxWidth: 300
|
||||||
property var screenLayout: null;
|
property var screenLayout: null
|
||||||
function create(type,text,duration,moremsg){
|
function create(type,text,duration,moremsg){
|
||||||
if(screenLayout){
|
if(screenLayout){
|
||||||
var last = screenLayout.getLastloader();
|
var last = screenLayout.getLastloader()
|
||||||
if(last.type === type && last.text === text && moremsg === last.moremsg){
|
if(last.type === type && last.text === text && moremsg === last.moremsg){
|
||||||
last.duration = duration
|
last.duration = duration
|
||||||
if (duration > 0) last.restart();
|
if (duration > 0) last.restart()
|
||||||
return last;
|
return last
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
initScreenLayout();
|
initScreenLayout()
|
||||||
return contentComponent.createObject(screenLayout,{
|
return contentComponent.createObject(screenLayout,{type:type,text:text,duration:duration,moremsg:moremsg,})
|
||||||
type:type,
|
|
||||||
text:text,
|
|
||||||
duration:duration,
|
|
||||||
moremsg:moremsg,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function createCustom(itemcomponent,duration){
|
function createCustom(itemcomponent,duration){
|
||||||
initScreenLayout();
|
initScreenLayout()
|
||||||
if(itemcomponent){
|
if(itemcomponent){
|
||||||
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
|
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function initScreenLayout(){
|
function initScreenLayout(){
|
||||||
if(screenLayout == null){
|
if(screenLayout == null){
|
||||||
screenLayout = screenlayoutComponent.createObject(root);
|
screenLayout = screenlayoutComponent.createObject(root)
|
||||||
screenLayout.y = control.layoutY;
|
screenLayout.y = control.layoutY
|
||||||
screenLayout.z = 100000;
|
screenLayout.z = 100000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
@ -58,44 +53,44 @@ FluObject {
|
|||||||
duration: FluTheme.animationEnabled ? 333 : 0
|
duration: FluTheme.animationEnabled ? 333 : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onChildrenChanged: if(children.length === 0) destroy();
|
onChildrenChanged: if(children.length === 0) destroy()
|
||||||
function getLastloader(){
|
function getLastloader(){
|
||||||
if(children.length > 0){
|
if(children.length > 0){
|
||||||
return children[children.length - 1];
|
return children[children.length - 1]
|
||||||
}
|
}
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
id:contentComponent
|
id:contentComponent
|
||||||
Item{
|
Item{
|
||||||
id:content;
|
id:content
|
||||||
property int duration: 1500
|
property int duration: 1500
|
||||||
property var itemcomponent
|
property var itemcomponent
|
||||||
property string type
|
property string type
|
||||||
property string text
|
property string text
|
||||||
property string moremsg
|
property string moremsg
|
||||||
width: parent.width;
|
width: parent.width
|
||||||
height: loader.height;
|
height: loader.height
|
||||||
function close(){
|
function close(){
|
||||||
content.destroy();
|
content.destroy()
|
||||||
}
|
}
|
||||||
function restart(){
|
function restart(){
|
||||||
delayTimer.restart();
|
delayTimer.restart()
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
id:delayTimer
|
id:delayTimer
|
||||||
interval: duration;
|
interval: duration
|
||||||
running: duration > 0;
|
running: duration > 0
|
||||||
repeat: duration > 0
|
repeat: duration > 0
|
||||||
onTriggered: content.close();
|
onTriggered: content.close()
|
||||||
}
|
}
|
||||||
FluLoader{
|
FluLoader{
|
||||||
id:loader;
|
id:loader
|
||||||
x:(parent.width - width) / 2;
|
x:(parent.width - width) / 2
|
||||||
property var _super: content;
|
property var _super: content
|
||||||
scale: item ? 1 : 0;
|
scale: item ? 1 : 0
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
enabled: FluTheme.animationEnabled
|
enabled: FluTheme.animationEnabled
|
||||||
@ -104,30 +99,30 @@ FluObject {
|
|||||||
duration: 167
|
duration: 167
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceComponent:itemcomponent ? itemcomponent : mcontrol.fluent_sytle;
|
sourceComponent:itemcomponent ? itemcomponent : mcontrol.fluent_sytle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property Component fluent_sytle: Rectangle{
|
property Component fluent_sytle: Rectangle{
|
||||||
width: rowlayout.width + (btn_close.visible ? 30 : 48);
|
width: rowlayout.width + (btn_close.visible ? 30 : 48)
|
||||||
height: rowlayout.height + 20;
|
height: rowlayout.height + 20
|
||||||
color: {
|
color: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return Qt.rgba(57/255,61/255,27/255,1);
|
case mcontrol.const_success: return Qt.rgba(57/255,61/255,27/255,1)
|
||||||
case mcontrol.const_warning: return Qt.rgba(67/255,53/255,25/255,1);
|
case mcontrol.const_warning: return Qt.rgba(67/255,53/255,25/255,1)
|
||||||
case mcontrol.const_info: return Qt.rgba(39/255,39/255,39/255,1);
|
case mcontrol.const_info: return Qt.rgba(39/255,39/255,39/255,1)
|
||||||
case mcontrol.const_error: return Qt.rgba(68/255,39/255,38/255,1);
|
case mcontrol.const_error: return Qt.rgba(68/255,39/255,38/255,1)
|
||||||
}
|
}
|
||||||
return Qt.rgba(255,255,255,1)
|
return Qt.rgba(1,1,1,1)
|
||||||
}else{
|
}else{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return "#dff6dd";
|
case mcontrol.const_success: return Qt.rgba(223/255,246/255,221/255,1)
|
||||||
case mcontrol.const_warning: return "#fff4ce";
|
case mcontrol.const_warning: return Qt.rgba(255/255,244/255,206/255,1)
|
||||||
case mcontrol.const_info: return "#f4f4f4";
|
case mcontrol.const_info: return Qt.rgba(244/255,244/255,244/255,1)
|
||||||
case mcontrol.const_error: return "#fde7e9";
|
case mcontrol.const_error: return Qt.rgba(253/255,231/255,233/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluShadow{
|
FluShadow{
|
||||||
@ -138,34 +133,34 @@ FluObject {
|
|||||||
border.color: {
|
border.color: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return Qt.rgba(56/255,61/255,27/255,1);
|
case mcontrol.const_success: return Qt.rgba(56/255,61/255,27/255,1)
|
||||||
case mcontrol.const_warning: return Qt.rgba(66/255,53/255,25/255,1);
|
case mcontrol.const_warning: return Qt.rgba(66/255,53/255,25/255,1)
|
||||||
case mcontrol.const_info: return Qt.rgba(38/255,39/255,39/255,1);
|
case mcontrol.const_info: return Qt.rgba(38/255,39/255,39/255,1)
|
||||||
case mcontrol.const_error: return Qt.rgba(67/255,39/255,38/255,1);
|
case mcontrol.const_error: return Qt.rgba(67/255,39/255,38/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}else{
|
}else{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return "#d2e8d0";
|
case mcontrol.const_success: return Qt.rgba(210/255,232/255,208/255,1)
|
||||||
case mcontrol.const_warning: return "#f0e6c2";
|
case mcontrol.const_warning: return Qt.rgba(240/255,230/255,194/255,1)
|
||||||
case mcontrol.const_info: return "#e6e6e6";
|
case mcontrol.const_info: return Qt.rgba(230/255,230/255,230/255,1)
|
||||||
case mcontrol.const_error: return "#eed9db";
|
case mcontrol.const_error: return Qt.rgba(238/255,217/255,219/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row{
|
Row{
|
||||||
id:rowlayout
|
id:rowlayout
|
||||||
x:20;
|
x:20
|
||||||
y:(parent.height - height) / 2;
|
y:(parent.height - height) / 2
|
||||||
spacing: 10
|
spacing: 10
|
||||||
FluIcon{
|
FluIcon{
|
||||||
iconSource:{
|
iconSource:{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return FluentIcons.CompletedSolid;
|
case mcontrol.const_success: return FluentIcons.CompletedSolid
|
||||||
case mcontrol.const_warning: return FluentIcons.InfoSolid;
|
case mcontrol.const_warning: return FluentIcons.InfoSolid
|
||||||
case mcontrol.const_info: return FluentIcons.InfoSolid;
|
case mcontrol.const_info: return FluentIcons.InfoSolid
|
||||||
case mcontrol.const_error: return FluentIcons.StatusErrorFull;
|
case mcontrol.const_error: return FluentIcons.StatusErrorFull
|
||||||
}FluentIcons.StatusErrorFull
|
}FluentIcons.StatusErrorFull
|
||||||
return FluentIcons.FA_info_circle
|
return FluentIcons.FA_info_circle
|
||||||
}
|
}
|
||||||
@ -173,20 +168,20 @@ FluObject {
|
|||||||
iconColor: {
|
iconColor: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return Qt.rgba(108/255,203/255,95/255,1);
|
case mcontrol.const_success: return Qt.rgba(108/255,203/255,95/255,1)
|
||||||
case mcontrol.const_warning: return Qt.rgba(252/255,225/255,0/255,1);
|
case mcontrol.const_warning: return Qt.rgba(252/255,225/255,0/255,1)
|
||||||
case mcontrol.const_info: return FluTheme.primaryColor;
|
case mcontrol.const_info: return FluTheme.primaryColor
|
||||||
case mcontrol.const_error: return Qt.rgba(255/255,153/255,164/255,1);
|
case mcontrol.const_error: return Qt.rgba(255/255,153/255,164/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}else{
|
}else{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return "#0f7b0f";
|
case mcontrol.const_success: return Qt.rgba(15/255,123/255,15/255,1)
|
||||||
case mcontrol.const_warning: return "#9d5d00";
|
case mcontrol.const_warning: return Qt.rgba(157/255,93/255,0/255,1)
|
||||||
case mcontrol.const_info: return "#0066b4";
|
case mcontrol.const_info: return Qt.rgba(0/255,102/255,180/255,1)
|
||||||
case mcontrol.const_error: return "#c42b1c";
|
case mcontrol.const_error: return Qt.rgba(196/255,43/255,28/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,46 +206,32 @@ FluObject {
|
|||||||
id:btn_close
|
id:btn_close
|
||||||
iconSource: FluentIcons.ChromeClose
|
iconSource: FluentIcons.ChromeClose
|
||||||
iconSize: 10
|
iconSize: 10
|
||||||
y:5
|
verticalPadding: 0
|
||||||
|
horizontalPadding: 0
|
||||||
|
width: 30
|
||||||
|
height: 20
|
||||||
visible: _super.duration<=0
|
visible: _super.duration<=0
|
||||||
iconColor: {
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
if(FluTheme.dark){
|
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
|
||||||
switch(_super.type){
|
|
||||||
case mcontrol.const_success: return Qt.rgba(108/255,203/255,95/255,1);
|
|
||||||
case mcontrol.const_warning: return Qt.rgba(252/255,225/255,0/255,1);
|
|
||||||
case mcontrol.const_info: return FluTheme.primaryColor;
|
|
||||||
case mcontrol.const_error: return Qt.rgba(255/255,153/255,164/255,1);
|
|
||||||
}
|
|
||||||
return "#FFFFFF"
|
|
||||||
}else{
|
|
||||||
switch(_super.type){
|
|
||||||
case mcontrol.const_success: return "#0f7b0f";
|
|
||||||
case mcontrol.const_warning: return "#9d5d00";
|
|
||||||
case mcontrol.const_info: return "#0066b4";
|
|
||||||
case mcontrol.const_error: return "#c42b1c";
|
|
||||||
}
|
|
||||||
return "#FFFFFF"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onClicked: _super.close()
|
onClicked: _super.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function showSuccess(text,duration=1000,moremsg){
|
function showSuccess(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showInfo(text,duration=1000,moremsg){
|
function showInfo(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showWarning(text,duration=1000,moremsg){
|
function showWarning(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showError(text,duration=1000,moremsg){
|
function showError(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showCustom(itemcomponent,duration=1000){
|
function showCustom(itemcomponent,duration=1000){
|
||||||
return mcontrol.createCustom(itemcomponent,duration);
|
return mcontrol.createCustom(itemcomponent,duration)
|
||||||
}
|
}
|
||||||
function clearAllInfo(){
|
function clearAllInfo(){
|
||||||
if(mcontrol.screenLayout != null) {
|
if(mcontrol.screenLayout != null) {
|
||||||
|
@ -39,7 +39,7 @@ T.Menu {
|
|||||||
: false
|
: false
|
||||||
clip: true
|
clip: true
|
||||||
currentIndex: control.currentIndex
|
currentIndex: control.currentIndex
|
||||||
ScrollIndicator.vertical: ScrollIndicator {}
|
ScrollBar.vertical: FluScrollBar{}
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: 150
|
implicitWidth: 150
|
||||||
|
@ -1120,7 +1120,8 @@ Item {
|
|||||||
}
|
}
|
||||||
padding: 0
|
padding: 0
|
||||||
focus: true
|
focus: true
|
||||||
contentItem: Item{
|
contentItem: FluClip{
|
||||||
|
radius: [5,5,5,5]
|
||||||
ListView{
|
ListView{
|
||||||
id:list_view
|
id:list_view
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -1145,7 +1146,6 @@ Item {
|
|||||||
visible: item_button.activeFocus
|
visible: item_button.activeFocus
|
||||||
radius:4
|
radius:4
|
||||||
}
|
}
|
||||||
|
|
||||||
FluLoader{
|
FluLoader{
|
||||||
id:item_dot_loader
|
id:item_dot_loader
|
||||||
anchors{
|
anchors{
|
||||||
@ -1160,7 +1160,6 @@ Item {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
contentItem: FluText{
|
contentItem: FluText{
|
||||||
text:modelData.title
|
text:modelData.title
|
||||||
@ -1187,13 +1186,13 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
background: FluRectangle{
|
background: Rectangle{
|
||||||
implicitWidth: 180
|
implicitWidth: 180
|
||||||
radius: [4,4,4,4]
|
color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(252/255,252/255,252/255,1)
|
||||||
FluShadow{
|
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
|
||||||
radius: 4
|
border.width: 1
|
||||||
}
|
radius: 5
|
||||||
color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
|
FluShadow{}
|
||||||
}
|
}
|
||||||
function showPopup(pos,height,model){
|
function showPopup(pos,height,model){
|
||||||
background.implicitHeight = height
|
background.implicitHeight = height
|
||||||
|
@ -10,19 +10,19 @@ QtObject {
|
|||||||
windows.push(window)
|
windows.push(window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function removeWindow(window) {
|
function removeWindow(win) {
|
||||||
if(!window.transientParent){
|
if(!win.transientParent){
|
||||||
var index = windows.indexOf(window)
|
var index = windows.indexOf(win)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
windows.splice(index, 1)
|
windows.splice(index, 1)
|
||||||
FluTools.deleteLater(window)
|
win.deleteLater()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function exit(retCode){
|
function exit(retCode){
|
||||||
for(var i =0 ;i< windows.length; i++){
|
for(var i =0 ;i< windows.length; i++){
|
||||||
var item = windows[i]
|
var win = windows[i]
|
||||||
FluTools.deleteLater(item)
|
win.deleteLater()
|
||||||
}
|
}
|
||||||
windows = []
|
windows = []
|
||||||
Qt.exit(retCode)
|
Qt.exit(retCode)
|
||||||
|
@ -10,7 +10,30 @@ FluIconButton {
|
|||||||
property string positiveText: qsTr("Save")
|
property string positiveText: qsTr("Save")
|
||||||
property string neutralText: qsTr("Cancel")
|
property string neutralText: qsTr("Cancel")
|
||||||
property string negativeText: qsTr("Reset")
|
property string negativeText: qsTr("Reset")
|
||||||
|
property bool registered: true
|
||||||
|
property color errorColor: Qt.rgba(250/255,85/255,85/255,1)
|
||||||
|
property FluHotkey syncHotkey: undefined
|
||||||
signal accepted()
|
signal accepted()
|
||||||
|
padding: 0
|
||||||
|
verticalPadding: 0
|
||||||
|
horizontalPadding: 0
|
||||||
|
onSyncHotkeyChanged: {
|
||||||
|
current = syncHotkey.sequence.split("+")
|
||||||
|
control.registered = syncHotkey.isRegistered
|
||||||
|
control.registered = Qt.binding(function(){
|
||||||
|
return syncHotkey.isRegistered
|
||||||
|
})
|
||||||
|
}
|
||||||
|
text: ""
|
||||||
|
color: {
|
||||||
|
if(!enabled){
|
||||||
|
return disableColor
|
||||||
|
}
|
||||||
|
if(pressed){
|
||||||
|
return pressedColor
|
||||||
|
}
|
||||||
|
return hovered ? hoverColor : normalColor
|
||||||
|
}
|
||||||
QtObject{
|
QtObject{
|
||||||
id: d
|
id: d
|
||||||
function keyToString(key_code,shift = true)
|
function keyToString(key_code,shift = true)
|
||||||
@ -112,15 +135,80 @@ FluIconButton {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
background: Rectangle{
|
background: Item{
|
||||||
border.color: FluTheme.dark ? "#505050" : "#DFDFDF"
|
|
||||||
border.width: 1
|
|
||||||
implicitHeight: 42
|
implicitHeight: 42
|
||||||
implicitWidth: layout_row.width+28
|
implicitWidth: 42
|
||||||
radius: control.radius
|
}
|
||||||
color:control.color
|
contentItem: Item{
|
||||||
FluFocusRectangle{
|
implicitWidth: childrenRect.width
|
||||||
visible: control.activeFocus
|
implicitHeight: layout_row.height
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
id: text_title
|
||||||
|
text: control.text
|
||||||
|
visible: control.text !== ""
|
||||||
|
rightPadding: 8
|
||||||
|
anchors{
|
||||||
|
verticalCenter: layout_rect.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: layout_rect
|
||||||
|
border.color: FluTheme.dark ? "#505050" : "#DFDFDF"
|
||||||
|
border.width: 1
|
||||||
|
radius: control.radius
|
||||||
|
color: control.color
|
||||||
|
height: control.height
|
||||||
|
width: layout_row.width
|
||||||
|
anchors{
|
||||||
|
left: text_title.right
|
||||||
|
}
|
||||||
|
FluFocusRectangle{
|
||||||
|
visible: control.activeFocus
|
||||||
|
}
|
||||||
|
Row{
|
||||||
|
id:layout_row
|
||||||
|
spacing: 5
|
||||||
|
anchors.centerIn: parent
|
||||||
|
Item{
|
||||||
|
width: 8
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
Repeater{
|
||||||
|
model: control.current
|
||||||
|
delegate: Loader{
|
||||||
|
property var keyText: modelData
|
||||||
|
sourceComponent: com_item_key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item{
|
||||||
|
width: 3
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
FluIcon{
|
||||||
|
iconSource: FluentIcons.EditMirrored
|
||||||
|
iconSize: 13
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item{
|
||||||
|
width: 8
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
id: text_error
|
||||||
|
text: qsTr("Conflict")
|
||||||
|
color: control.errorColor
|
||||||
|
visible: !control.registered
|
||||||
|
anchors{
|
||||||
|
verticalCenter: layout_rect.verticalCenter
|
||||||
|
left: layout_rect.right
|
||||||
|
leftMargin: 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
@ -139,29 +227,6 @@ FluIconButton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row{
|
|
||||||
id:layout_row
|
|
||||||
spacing: 5
|
|
||||||
anchors.centerIn: parent
|
|
||||||
Repeater{
|
|
||||||
model: control.current
|
|
||||||
delegate: Loader{
|
|
||||||
property var keyText: modelData
|
|
||||||
sourceComponent: com_item_key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Item{
|
|
||||||
width: 3
|
|
||||||
height: 1
|
|
||||||
}
|
|
||||||
FluIcon{
|
|
||||||
iconSource: FluentIcons.EditMirrored
|
|
||||||
iconSize: 13
|
|
||||||
anchors{
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FluContentDialog{
|
FluContentDialog{
|
||||||
id:content_dialog
|
id:content_dialog
|
||||||
property var keysModel: []
|
property var keysModel: []
|
||||||
@ -179,6 +244,9 @@ FluIconButton {
|
|||||||
onPositiveClicked: {
|
onPositiveClicked: {
|
||||||
control.current = content_dialog.keysModel
|
control.current = content_dialog.keysModel
|
||||||
control.accepted()
|
control.accepted()
|
||||||
|
if(control.syncHotkey){
|
||||||
|
control.syncHotkey.sequence = control.current.join("+")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onNegativeClickListener: function(){
|
onNegativeClickListener: function(){
|
||||||
content_dialog.keysModel = control.current
|
content_dialog.keysModel = control.current
|
||||||
|
@ -225,22 +225,21 @@ Rectangle {
|
|||||||
id:com_table_delegate
|
id:com_table_delegate
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:item_table_mouse
|
id:item_table_mouse
|
||||||
implicitWidth: TableView.view.width
|
|
||||||
property var _model: model
|
property var _model: model
|
||||||
property bool isMainTable: TableView.view == table_view
|
property bool isMainTable: TableView.view == table_view
|
||||||
property var currentTableView: TableView.view
|
property var currentTableView: TableView.view
|
||||||
visible: {
|
property bool isHide: {
|
||||||
if(isMainTable && columnModel.frozen){
|
if(isMainTable && columnModel.frozen){
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
if(!isMainTable){
|
if(!isMainTable){
|
||||||
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
property bool isRowSelected: {
|
property bool isRowSelected: {
|
||||||
if(rowModel === null)
|
if(!rowModel)
|
||||||
return false
|
return false
|
||||||
if(d.current){
|
if(d.current){
|
||||||
return rowModel._key === d.current._key
|
return rowModel._key === d.current._key
|
||||||
@ -248,11 +247,15 @@ Rectangle {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
property bool editVisible: {
|
property bool editVisible: {
|
||||||
|
if(!rowModel)
|
||||||
|
return false
|
||||||
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
implicitWidth: isHide ? Number.MIN_VALUE : TableView.view.width
|
||||||
|
visible: !isHide
|
||||||
TableView.onPooled: {
|
TableView.onPooled: {
|
||||||
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
||||||
control.closeEditor()
|
control.closeEditor()
|
||||||
@ -441,6 +444,11 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onWidthChanged:{
|
||||||
|
table_view.forceLayout()
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:layout_mouse_table
|
id:layout_mouse_table
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
@ -475,7 +483,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id:com_column_header_delegate
|
id: com_column_header_delegate
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id: column_item_control
|
id: column_item_control
|
||||||
property var currentTableView : TableView.view
|
property var currentTableView : TableView.view
|
||||||
@ -490,17 +498,31 @@ Rectangle {
|
|||||||
return control.columnSource.findIndex(isDataIndex)
|
return control.columnSource.findIndex(isDataIndex)
|
||||||
}
|
}
|
||||||
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
|
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
|
||||||
|
readonly property bool isHide: {
|
||||||
|
if(isHeaderHorizontal){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if(!isHeaderHorizontal){
|
||||||
|
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
visible: !isHide
|
||||||
implicitWidth: {
|
implicitWidth: {
|
||||||
|
if(isHide){
|
||||||
|
return Number.MIN_VALUE
|
||||||
|
}
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
|
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
|
||||||
}
|
}
|
||||||
return TableView.view.width
|
return Math.max(TableView.view.width,Number.MIN_VALUE)
|
||||||
}
|
}
|
||||||
implicitHeight: {
|
implicitHeight: {
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
|
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
|
||||||
}
|
}
|
||||||
return TableView.view.height
|
return Math.max(TableView.view.height,Number.MIN_VALUE)
|
||||||
}
|
}
|
||||||
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
||||||
Rectangle{
|
Rectangle{
|
||||||
@ -616,7 +638,6 @@ Rectangle {
|
|||||||
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
||||||
table_view.forceLayout()
|
table_view.forceLayout()
|
||||||
header_horizontal.forceLayout()
|
header_horizontal.forceLayout()
|
||||||
// column_item_control.currentTableView.forceLayout()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -870,12 +891,32 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
}
|
}
|
||||||
|
TableView{
|
||||||
|
property string dataIndex: columnModel.dataIndex
|
||||||
|
id: item_table_frozen
|
||||||
|
interactive: false
|
||||||
|
clip: true
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
contentWidth: width
|
||||||
|
height: table_view.height
|
||||||
|
y: header_horizontal.height
|
||||||
|
boundsBehavior: TableView.StopAtBounds
|
||||||
|
model: table_view.model
|
||||||
|
delegate: table_view.delegate
|
||||||
|
syncDirection: Qt.Vertical
|
||||||
|
syncView: table_view
|
||||||
|
}
|
||||||
TableView {
|
TableView {
|
||||||
|
property string dataIndex: columnModel.dataIndex
|
||||||
id:item_table_frozen_header
|
id:item_table_frozen_header
|
||||||
model: header_column_model
|
model: header_column_model
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
clip: true
|
|
||||||
interactive: false
|
interactive: false
|
||||||
|
clip: true
|
||||||
|
contentWidth: width
|
||||||
anchors{
|
anchors{
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
@ -883,24 +924,14 @@ Rectangle {
|
|||||||
bottom: item_table_frozen.top
|
bottom: item_table_frozen.top
|
||||||
}
|
}
|
||||||
delegate: com_column_header_delegate
|
delegate: com_column_header_delegate
|
||||||
}
|
|
||||||
TableView{
|
|
||||||
property string dataIndex: columnModel.dataIndex
|
|
||||||
id: item_table_frozen
|
|
||||||
clip: true
|
|
||||||
interactive: false
|
|
||||||
anchors{
|
|
||||||
fill: parent
|
|
||||||
topMargin: header_horizontal.height
|
|
||||||
}
|
|
||||||
boundsBehavior: TableView.StopAtBounds
|
|
||||||
model: table_sort_model
|
|
||||||
delegate: com_table_delegate
|
|
||||||
syncDirection: Qt.Vertical
|
|
||||||
syncView: table_view
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
item_table_frozen_header.contentX = columnModel.width * _index
|
item_table_frozen_header.forceLayout()
|
||||||
item_table_frozen.contentX = columnModel.width * _index
|
}
|
||||||
|
}
|
||||||
|
Connections{
|
||||||
|
target: table_view
|
||||||
|
function onWidthChanged() {
|
||||||
|
item_table_frozen_header.forceLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -914,6 +945,12 @@ Rectangle {
|
|||||||
id: item_layout_frozen
|
id: item_layout_frozen
|
||||||
readonly property int _index : model.index
|
readonly property int _index : model.index
|
||||||
readonly property var columnModel : control.columnSource[_index]
|
readonly property var columnModel : control.columnSource[_index]
|
||||||
|
readonly property bool isHide:{
|
||||||
|
if(columnModel.frozen){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
Connections{
|
Connections{
|
||||||
target: d
|
target: d
|
||||||
function onTableItemLayout(column){
|
function onTableItemLayout(column){
|
||||||
@ -932,17 +969,17 @@ Rectangle {
|
|||||||
width = table_view.columnWidthProvider(_index)
|
width = table_view.columnWidthProvider(_index)
|
||||||
x = Qt.binding(function(){
|
x = Qt.binding(function(){
|
||||||
var minX = 0
|
var minX = 0
|
||||||
var maxX = table_view.width-item_layout_frozen.width
|
var maxX = table_view.width-width
|
||||||
for(var i=0;i<_index;i++){
|
for(var i=0;i<_index;i++){
|
||||||
var item = control.columnSource[i]
|
var item = control.columnSource[i]
|
||||||
if(item.frozen){
|
if(item.frozen){
|
||||||
minX = minX + item.width
|
minX = minX + table_view.columnWidthProvider(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=_index+1;i<control.columnSource.length;i++){
|
for(i=_index+1;i<control.columnSource.length;i++){
|
||||||
item = control.columnSource[i]
|
item = control.columnSource[i]
|
||||||
if(item.frozen){
|
if(item.frozen){
|
||||||
maxX = maxX- item.width
|
maxX = maxX - table_view.columnWidthProvider(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
|
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
|
||||||
@ -952,23 +989,8 @@ Rectangle {
|
|||||||
updateLayout()
|
updateLayout()
|
||||||
}
|
}
|
||||||
height: control.height
|
height: control.height
|
||||||
visible: {
|
visible: !item_layout_frozen.isHide
|
||||||
if(modelData.frozen){
|
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_frozen
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
sourceComponent: visible ? com_table_frozen : undefined
|
|
||||||
onStatusChanged: {
|
|
||||||
if(status === Loader.Ready){
|
|
||||||
sourceComponent = Qt.binding(function(){
|
|
||||||
if(modelData.frozen){
|
|
||||||
return com_table_frozen
|
|
||||||
}
|
|
||||||
return undefined
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,4 +353,7 @@ Window {
|
|||||||
function setHitTestVisible(val){
|
function setHitTestVisible(val){
|
||||||
frameless.setHitTestVisible(val)
|
frameless.setHitTestVisible(val)
|
||||||
}
|
}
|
||||||
|
function deleteLater(){
|
||||||
|
FluTools.deleteLater(window)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,14 +31,15 @@ Module {
|
|||||||
Property { name: "useSystemAppBar"; type: "bool" }
|
Property { name: "useSystemAppBar"; type: "bool" }
|
||||||
Property { name: "windowIcon"; type: "string" }
|
Property { name: "windowIcon"; type: "string" }
|
||||||
Property { name: "locale"; type: "QLocale" }
|
Property { name: "locale"; type: "QLocale" }
|
||||||
|
Property { name: "launcher"; type: "QObject"; isPointer: true }
|
||||||
Method {
|
Method {
|
||||||
name: "init"
|
name: "init"
|
||||||
Parameter { name: "target"; type: "QObject"; isPointer: true }
|
Parameter { name: "launcher"; type: "QObject"; isPointer: true }
|
||||||
Parameter { name: "locale"; type: "QLocale" }
|
Parameter { name: "locale"; type: "QLocale" }
|
||||||
}
|
}
|
||||||
Method {
|
Method {
|
||||||
name: "init"
|
name: "init"
|
||||||
Parameter { name: "target"; type: "QObject"; isPointer: true }
|
Parameter { name: "launcher"; type: "QObject"; isPointer: true }
|
||||||
}
|
}
|
||||||
Method {
|
Method {
|
||||||
name: "iconData"
|
name: "iconData"
|
||||||
@ -159,6 +160,16 @@ Module {
|
|||||||
}
|
}
|
||||||
Method { name: "onDestruction" }
|
Method { name: "onDestruction" }
|
||||||
}
|
}
|
||||||
|
Component {
|
||||||
|
name: "FluHotkey"
|
||||||
|
prototype: "QObject"
|
||||||
|
exports: ["FluentUI/FluHotkey 1.0"]
|
||||||
|
exportMetaObjectRevisions: [0]
|
||||||
|
Property { name: "sequence"; type: "string" }
|
||||||
|
Property { name: "name"; type: "string" }
|
||||||
|
Property { name: "isRegistered"; type: "bool"; isReadonly: true }
|
||||||
|
Signal { name: "activated" }
|
||||||
|
}
|
||||||
Component {
|
Component {
|
||||||
name: "FluNavigationViewType"
|
name: "FluNavigationViewType"
|
||||||
exports: ["FluentUI/FluNavigationViewType 1.0"]
|
exports: ["FluentUI/FluNavigationViewType 1.0"]
|
||||||
@ -273,7 +284,6 @@ Module {
|
|||||||
prototype: "QAbstractTableModel"
|
prototype: "QAbstractTableModel"
|
||||||
exports: ["FluentUI/FluTableModel 1.0"]
|
exports: ["FluentUI/FluTableModel 1.0"]
|
||||||
exportMetaObjectRevisions: [0]
|
exportMetaObjectRevisions: [0]
|
||||||
Property { name: "dataSourceSize"; type: "int" }
|
|
||||||
Property { name: "columnSource"; type: "QList<QVariantMap>" }
|
Property { name: "columnSource"; type: "QList<QVariantMap>" }
|
||||||
Property { name: "rows"; type: "QList<QVariantMap>" }
|
Property { name: "rows"; type: "QList<QVariantMap>" }
|
||||||
Property { name: "rowCount"; type: "int"; isReadonly: true }
|
Property { name: "rowCount"; type: "int"; isReadonly: true }
|
||||||
@ -2497,37 +2507,37 @@ Module {
|
|||||||
Property { name: "darkClickListener"; type: "QVariant" }
|
Property { name: "darkClickListener"; type: "QVariant" }
|
||||||
Property {
|
Property {
|
||||||
name: "buttonStayTop"
|
name: "buttonStayTop"
|
||||||
type: "FluIconButton_QMLTYPE_20"
|
type: "FluIconButton_QMLTYPE_18"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
Property {
|
Property {
|
||||||
name: "buttonMinimize"
|
name: "buttonMinimize"
|
||||||
type: "FluIconButton_QMLTYPE_20"
|
type: "FluIconButton_QMLTYPE_18"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
Property {
|
Property {
|
||||||
name: "buttonMaximize"
|
name: "buttonMaximize"
|
||||||
type: "FluIconButton_QMLTYPE_20"
|
type: "FluIconButton_QMLTYPE_18"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
Property {
|
Property {
|
||||||
name: "buttonClose"
|
name: "buttonClose"
|
||||||
type: "FluIconButton_QMLTYPE_20"
|
type: "FluIconButton_QMLTYPE_18"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
Property {
|
Property {
|
||||||
name: "buttonDark"
|
name: "buttonDark"
|
||||||
type: "FluIconButton_QMLTYPE_20"
|
type: "FluIconButton_QMLTYPE_18"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
Property {
|
Property {
|
||||||
name: "layoutMacosButtons"
|
name: "layoutMacosButtons"
|
||||||
type: "FluLoader_QMLTYPE_13"
|
type: "FluLoader_QMLTYPE_16"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
@ -3100,6 +3110,7 @@ Module {
|
|||||||
Parameter { name: "itemcomponent"; type: "QVariant" }
|
Parameter { name: "itemcomponent"; type: "QVariant" }
|
||||||
Parameter { name: "duration"; type: "QVariant" }
|
Parameter { name: "duration"; type: "QVariant" }
|
||||||
}
|
}
|
||||||
|
Method { name: "clearAllInfo"; type: "QVariant" }
|
||||||
Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
|
Property { name: "children"; type: "QObject"; isList: true; isReadonly: true }
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
@ -3219,15 +3230,15 @@ Module {
|
|||||||
defaultProperty: "data"
|
defaultProperty: "data"
|
||||||
Property { name: "logo"; type: "QUrl" }
|
Property { name: "logo"; type: "QUrl" }
|
||||||
Property { name: "title"; type: "string" }
|
Property { name: "title"; type: "string" }
|
||||||
Property { name: "items"; type: "FluObject_QMLTYPE_173"; isPointer: true }
|
Property { name: "items"; type: "FluObject_QMLTYPE_164"; isPointer: true }
|
||||||
Property { name: "footerItems"; type: "FluObject_QMLTYPE_173"; isPointer: true }
|
Property { name: "footerItems"; type: "FluObject_QMLTYPE_164"; isPointer: true }
|
||||||
Property { name: "displayMode"; type: "int" }
|
Property { name: "displayMode"; type: "int" }
|
||||||
Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true }
|
Property { name: "autoSuggestBox"; type: "QQmlComponent"; isPointer: true }
|
||||||
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
|
Property { name: "actionItem"; type: "QQmlComponent"; isPointer: true }
|
||||||
Property { name: "topPadding"; type: "int" }
|
Property { name: "topPadding"; type: "int" }
|
||||||
Property { name: "pageMode"; type: "int" }
|
Property { name: "pageMode"; type: "int" }
|
||||||
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true }
|
Property { name: "navItemRightMenu"; type: "FluMenu_QMLTYPE_36"; isPointer: true }
|
||||||
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_49"; isPointer: true }
|
Property { name: "navItemExpanderRightMenu"; type: "FluMenu_QMLTYPE_36"; isPointer: true }
|
||||||
Property { name: "navCompactWidth"; type: "int" }
|
Property { name: "navCompactWidth"; type: "int" }
|
||||||
Property { name: "navTopMargin"; type: "int" }
|
Property { name: "navTopMargin"; type: "int" }
|
||||||
Property { name: "cellHeight"; type: "int" }
|
Property { name: "cellHeight"; type: "int" }
|
||||||
@ -3235,13 +3246,13 @@ Module {
|
|||||||
Property { name: "hideNavAppBar"; type: "bool" }
|
Property { name: "hideNavAppBar"; type: "bool" }
|
||||||
Property {
|
Property {
|
||||||
name: "buttonMenu"
|
name: "buttonMenu"
|
||||||
type: "FluIconButton_QMLTYPE_20"
|
type: "FluIconButton_QMLTYPE_18"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
Property {
|
Property {
|
||||||
name: "buttonBack"
|
name: "buttonBack"
|
||||||
type: "FluIconButton_QMLTYPE_20"
|
type: "FluIconButton_QMLTYPE_18"
|
||||||
isReadonly: true
|
isReadonly: true
|
||||||
isPointer: true
|
isPointer: true
|
||||||
}
|
}
|
||||||
@ -3539,6 +3550,8 @@ Module {
|
|||||||
Property { name: "currentIndex"; type: "int" }
|
Property { name: "currentIndex"; type: "int" }
|
||||||
Property { name: "spacing"; type: "int" }
|
Property { name: "spacing"; type: "int" }
|
||||||
Property { name: "orientation"; type: "int" }
|
Property { name: "orientation"; type: "int" }
|
||||||
|
Property { name: "disabled"; type: "bool" }
|
||||||
|
Property { name: "manuallyDisabled"; type: "bool" }
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
prototype: "QQuickRangeSlider"
|
prototype: "QQuickRangeSlider"
|
||||||
@ -3693,6 +3706,9 @@ Module {
|
|||||||
Property { name: "positiveText"; type: "string" }
|
Property { name: "positiveText"; type: "string" }
|
||||||
Property { name: "neutralText"; type: "string" }
|
Property { name: "neutralText"; type: "string" }
|
||||||
Property { name: "negativeText"; type: "string" }
|
Property { name: "negativeText"; type: "string" }
|
||||||
|
Property { name: "registered"; type: "bool" }
|
||||||
|
Property { name: "errorColor"; type: "QColor" }
|
||||||
|
Property { name: "syncHotkey"; type: "FluHotkey"; isPointer: true }
|
||||||
Signal { name: "accepted" }
|
Signal { name: "accepted" }
|
||||||
Property { name: "iconSize"; type: "int" }
|
Property { name: "iconSize"; type: "int" }
|
||||||
Property { name: "iconSource"; type: "int" }
|
Property { name: "iconSource"; type: "int" }
|
||||||
@ -3826,9 +3842,12 @@ Module {
|
|||||||
Property { name: "verticalHeaderVisible"; type: "bool" }
|
Property { name: "verticalHeaderVisible"; type: "bool" }
|
||||||
Property { name: "selectedBorderColor"; type: "QColor" }
|
Property { name: "selectedBorderColor"; type: "QColor" }
|
||||||
Property { name: "selectedColor"; type: "QColor" }
|
Property { name: "selectedColor"; type: "QColor" }
|
||||||
|
Property { name: "columnWidthProvider"; type: "QVariant" }
|
||||||
|
Property { name: "rowHeightProvider"; type: "QVariant" }
|
||||||
Property { name: "rows"; type: "int"; isReadonly: true }
|
Property { name: "rows"; type: "int"; isReadonly: true }
|
||||||
Property { name: "columns"; type: "int"; isReadonly: true }
|
Property { name: "columns"; type: "int"; isReadonly: true }
|
||||||
Property { name: "current"; type: "QVariant"; isReadonly: true }
|
Property { name: "current"; type: "QVariant"; isReadonly: true }
|
||||||
|
Property { name: "view"; type: "QQuickTableView"; isReadonly: true; isPointer: true }
|
||||||
Method { name: "closeEditor"; type: "QVariant" }
|
Method { name: "closeEditor"; type: "QVariant" }
|
||||||
Method { name: "resetPosition"; type: "QVariant" }
|
Method { name: "resetPosition"; type: "QVariant" }
|
||||||
Method {
|
Method {
|
||||||
@ -4081,6 +4100,7 @@ Module {
|
|||||||
Property { name: "selectedBorderColor"; type: "QColor" }
|
Property { name: "selectedBorderColor"; type: "QColor" }
|
||||||
Property { name: "selectedColor"; type: "QColor" }
|
Property { name: "selectedColor"; type: "QColor" }
|
||||||
Property { name: "current"; type: "QVariant"; isReadonly: true }
|
Property { name: "current"; type: "QVariant"; isReadonly: true }
|
||||||
|
Property { name: "view"; type: "QQuickTableView"; isReadonly: true; isPointer: true }
|
||||||
Method { name: "count"; type: "QVariant" }
|
Method { name: "count"; type: "QVariant" }
|
||||||
Method { name: "visibleCount"; type: "QVariant" }
|
Method { name: "visibleCount"; type: "QVariant" }
|
||||||
Method {
|
Method {
|
||||||
@ -4172,6 +4192,7 @@ Module {
|
|||||||
Parameter { name: "duration"; type: "QVariant" }
|
Parameter { name: "duration"; type: "QVariant" }
|
||||||
Parameter { name: "moremsg"; type: "QVariant" }
|
Parameter { name: "moremsg"; type: "QVariant" }
|
||||||
}
|
}
|
||||||
|
Method { name: "clearAllInfo"; type: "QVariant" }
|
||||||
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
|
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
|
||||||
Method { name: "fixWindowSize"; type: "QVariant" }
|
Method { name: "fixWindowSize"; type: "QVariant" }
|
||||||
Method {
|
Method {
|
||||||
@ -4274,6 +4295,7 @@ Module {
|
|||||||
Parameter { name: "duration"; type: "QVariant" }
|
Parameter { name: "duration"; type: "QVariant" }
|
||||||
Parameter { name: "moremsg"; type: "QVariant" }
|
Parameter { name: "moremsg"; type: "QVariant" }
|
||||||
}
|
}
|
||||||
|
Method { name: "clearAllInfo"; type: "QVariant" }
|
||||||
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
|
Method { name: "moveWindowToDesktopCenter"; type: "QVariant" }
|
||||||
Method { name: "fixWindowSize"; type: "QVariant" }
|
Method { name: "fixWindowSize"; type: "QVariant" }
|
||||||
Method {
|
Method {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Controls.Basic
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Window
|
import QtQuick.Window
|
||||||
import FluentUI
|
import FluentUI
|
||||||
|
@ -1,47 +1,42 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls
|
||||||
import FluentUI 1.0
|
import FluentUI
|
||||||
|
|
||||||
FluObject {
|
FluObject {
|
||||||
property var root;
|
property var root
|
||||||
property int layoutY: 75
|
property int layoutY: 75
|
||||||
id:control
|
id:control
|
||||||
FluObject{
|
FluObject{
|
||||||
id:mcontrol
|
id:mcontrol
|
||||||
property string const_success: "success";
|
property string const_success: "success"
|
||||||
property string const_info: "info";
|
property string const_info: "info"
|
||||||
property string const_warning: "warning";
|
property string const_warning: "warning"
|
||||||
property string const_error: "error";
|
property string const_error: "error"
|
||||||
property int maxWidth: 300;
|
property int maxWidth: 300
|
||||||
property var screenLayout: null;
|
property var screenLayout: null
|
||||||
function create(type,text,duration,moremsg){
|
function create(type,text,duration,moremsg){
|
||||||
if(screenLayout){
|
if(screenLayout){
|
||||||
var last = screenLayout.getLastloader();
|
var last = screenLayout.getLastloader()
|
||||||
if(last.type === type && last.text === text && moremsg === last.moremsg){
|
if(last.type === type && last.text === text && moremsg === last.moremsg){
|
||||||
last.duration = duration
|
last.duration = duration
|
||||||
if (duration > 0) last.restart();
|
if (duration > 0) last.restart()
|
||||||
return last;
|
return last
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
initScreenLayout();
|
initScreenLayout()
|
||||||
return contentComponent.createObject(screenLayout,{
|
return contentComponent.createObject(screenLayout,{type:type,text:text,duration:duration,moremsg:moremsg,})
|
||||||
type:type,
|
|
||||||
text:text,
|
|
||||||
duration:duration,
|
|
||||||
moremsg:moremsg,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
function createCustom(itemcomponent,duration){
|
function createCustom(itemcomponent,duration){
|
||||||
initScreenLayout();
|
initScreenLayout()
|
||||||
if(itemcomponent){
|
if(itemcomponent){
|
||||||
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
|
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function initScreenLayout(){
|
function initScreenLayout(){
|
||||||
if(screenLayout == null){
|
if(screenLayout == null){
|
||||||
screenLayout = screenlayoutComponent.createObject(root);
|
screenLayout = screenlayoutComponent.createObject(root)
|
||||||
screenLayout.y = control.layoutY;
|
screenLayout.y = control.layoutY
|
||||||
screenLayout.z = 100000;
|
screenLayout.z = 100000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
@ -58,44 +53,44 @@ FluObject {
|
|||||||
duration: FluTheme.animationEnabled ? 333 : 0
|
duration: FluTheme.animationEnabled ? 333 : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onChildrenChanged: if(children.length === 0) destroy();
|
onChildrenChanged: if(children.length === 0) destroy()
|
||||||
function getLastloader(){
|
function getLastloader(){
|
||||||
if(children.length > 0){
|
if(children.length > 0){
|
||||||
return children[children.length - 1];
|
return children[children.length - 1]
|
||||||
}
|
}
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
id:contentComponent
|
id:contentComponent
|
||||||
Item{
|
Item{
|
||||||
id:content;
|
id:content
|
||||||
property int duration: 1500
|
property int duration: 1500
|
||||||
property var itemcomponent
|
property var itemcomponent
|
||||||
property string type
|
property string type
|
||||||
property string text
|
property string text
|
||||||
property string moremsg
|
property string moremsg
|
||||||
width: parent.width;
|
width: parent.width
|
||||||
height: loader.height;
|
height: loader.height
|
||||||
function close(){
|
function close(){
|
||||||
content.destroy();
|
content.destroy()
|
||||||
}
|
}
|
||||||
function restart(){
|
function restart(){
|
||||||
delayTimer.restart();
|
delayTimer.restart()
|
||||||
}
|
}
|
||||||
Timer {
|
Timer {
|
||||||
id:delayTimer
|
id:delayTimer
|
||||||
interval: duration;
|
interval: duration
|
||||||
running: duration > 0;
|
running: duration > 0
|
||||||
repeat: duration > 0
|
repeat: duration > 0
|
||||||
onTriggered: content.close();
|
onTriggered: content.close()
|
||||||
}
|
}
|
||||||
FluLoader{
|
FluLoader{
|
||||||
id:loader;
|
id:loader
|
||||||
x:(parent.width - width) / 2;
|
x:(parent.width - width) / 2
|
||||||
property var _super: content;
|
property var _super: content
|
||||||
scale: item ? 1 : 0;
|
scale: item ? 1 : 0
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
enabled: FluTheme.animationEnabled
|
enabled: FluTheme.animationEnabled
|
||||||
@ -104,30 +99,30 @@ FluObject {
|
|||||||
duration: 167
|
duration: 167
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceComponent:itemcomponent ? itemcomponent : mcontrol.fluent_sytle;
|
sourceComponent:itemcomponent ? itemcomponent : mcontrol.fluent_sytle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
property Component fluent_sytle: Rectangle{
|
property Component fluent_sytle: Rectangle{
|
||||||
width: rowlayout.width + (btn_close.visible ? 30 : 48);
|
width: rowlayout.width + (btn_close.visible ? 30 : 48)
|
||||||
height: rowlayout.height + 20;
|
height: rowlayout.height + 20
|
||||||
color: {
|
color: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return Qt.rgba(57/255,61/255,27/255,1);
|
case mcontrol.const_success: return Qt.rgba(57/255,61/255,27/255,1)
|
||||||
case mcontrol.const_warning: return Qt.rgba(67/255,53/255,25/255,1);
|
case mcontrol.const_warning: return Qt.rgba(67/255,53/255,25/255,1)
|
||||||
case mcontrol.const_info: return Qt.rgba(39/255,39/255,39/255,1);
|
case mcontrol.const_info: return Qt.rgba(39/255,39/255,39/255,1)
|
||||||
case mcontrol.const_error: return Qt.rgba(68/255,39/255,38/255,1);
|
case mcontrol.const_error: return Qt.rgba(68/255,39/255,38/255,1)
|
||||||
}
|
}
|
||||||
return Qt.rgba(255,255,255,1)
|
return Qt.rgba(1,1,1,1)
|
||||||
}else{
|
}else{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return "#dff6dd";
|
case mcontrol.const_success: return Qt.rgba(223/255,246/255,221/255,1)
|
||||||
case mcontrol.const_warning: return "#fff4ce";
|
case mcontrol.const_warning: return Qt.rgba(255/255,244/255,206/255,1)
|
||||||
case mcontrol.const_info: return "#f4f4f4";
|
case mcontrol.const_info: return Qt.rgba(244/255,244/255,244/255,1)
|
||||||
case mcontrol.const_error: return "#fde7e9";
|
case mcontrol.const_error: return Qt.rgba(253/255,231/255,233/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluShadow{
|
FluShadow{
|
||||||
@ -138,34 +133,34 @@ FluObject {
|
|||||||
border.color: {
|
border.color: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return Qt.rgba(56/255,61/255,27/255,1);
|
case mcontrol.const_success: return Qt.rgba(56/255,61/255,27/255,1)
|
||||||
case mcontrol.const_warning: return Qt.rgba(66/255,53/255,25/255,1);
|
case mcontrol.const_warning: return Qt.rgba(66/255,53/255,25/255,1)
|
||||||
case mcontrol.const_info: return Qt.rgba(38/255,39/255,39/255,1);
|
case mcontrol.const_info: return Qt.rgba(38/255,39/255,39/255,1)
|
||||||
case mcontrol.const_error: return Qt.rgba(67/255,39/255,38/255,1);
|
case mcontrol.const_error: return Qt.rgba(67/255,39/255,38/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}else{
|
}else{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return "#d2e8d0";
|
case mcontrol.const_success: return Qt.rgba(210/255,232/255,208/255,1)
|
||||||
case mcontrol.const_warning: return "#f0e6c2";
|
case mcontrol.const_warning: return Qt.rgba(240/255,230/255,194/255,1)
|
||||||
case mcontrol.const_info: return "#e6e6e6";
|
case mcontrol.const_info: return Qt.rgba(230/255,230/255,230/255,1)
|
||||||
case mcontrol.const_error: return "#eed9db";
|
case mcontrol.const_error: return Qt.rgba(238/255,217/255,219/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row{
|
Row{
|
||||||
id:rowlayout
|
id:rowlayout
|
||||||
x:20;
|
x:20
|
||||||
y:(parent.height - height) / 2;
|
y:(parent.height - height) / 2
|
||||||
spacing: 10
|
spacing: 10
|
||||||
FluIcon{
|
FluIcon{
|
||||||
iconSource:{
|
iconSource:{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return FluentIcons.CompletedSolid;
|
case mcontrol.const_success: return FluentIcons.CompletedSolid
|
||||||
case mcontrol.const_warning: return FluentIcons.InfoSolid;
|
case mcontrol.const_warning: return FluentIcons.InfoSolid
|
||||||
case mcontrol.const_info: return FluentIcons.InfoSolid;
|
case mcontrol.const_info: return FluentIcons.InfoSolid
|
||||||
case mcontrol.const_error: return FluentIcons.StatusErrorFull;
|
case mcontrol.const_error: return FluentIcons.StatusErrorFull
|
||||||
}FluentIcons.StatusErrorFull
|
}FluentIcons.StatusErrorFull
|
||||||
return FluentIcons.FA_info_circle
|
return FluentIcons.FA_info_circle
|
||||||
}
|
}
|
||||||
@ -173,20 +168,20 @@ FluObject {
|
|||||||
iconColor: {
|
iconColor: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return Qt.rgba(108/255,203/255,95/255,1);
|
case mcontrol.const_success: return Qt.rgba(108/255,203/255,95/255,1)
|
||||||
case mcontrol.const_warning: return Qt.rgba(252/255,225/255,0/255,1);
|
case mcontrol.const_warning: return Qt.rgba(252/255,225/255,0/255,1)
|
||||||
case mcontrol.const_info: return FluTheme.primaryColor;
|
case mcontrol.const_info: return FluTheme.primaryColor
|
||||||
case mcontrol.const_error: return Qt.rgba(255/255,153/255,164/255,1);
|
case mcontrol.const_error: return Qt.rgba(255/255,153/255,164/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}else{
|
}else{
|
||||||
switch(_super.type){
|
switch(_super.type){
|
||||||
case mcontrol.const_success: return "#0f7b0f";
|
case mcontrol.const_success: return Qt.rgba(15/255,123/255,15/255,1)
|
||||||
case mcontrol.const_warning: return "#9d5d00";
|
case mcontrol.const_warning: return Qt.rgba(157/255,93/255,0/255,1)
|
||||||
case mcontrol.const_info: return "#0066b4";
|
case mcontrol.const_info: return Qt.rgba(0/255,102/255,180/255,1)
|
||||||
case mcontrol.const_error: return "#c42b1c";
|
case mcontrol.const_error: return Qt.rgba(196/255,43/255,28/255,1)
|
||||||
}
|
}
|
||||||
return "#FFFFFF"
|
return Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,46 +206,32 @@ FluObject {
|
|||||||
id:btn_close
|
id:btn_close
|
||||||
iconSource: FluentIcons.ChromeClose
|
iconSource: FluentIcons.ChromeClose
|
||||||
iconSize: 10
|
iconSize: 10
|
||||||
y:5
|
verticalPadding: 0
|
||||||
|
horizontalPadding: 0
|
||||||
|
width: 30
|
||||||
|
height: 20
|
||||||
visible: _super.duration<=0
|
visible: _super.duration<=0
|
||||||
iconColor: {
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
if(FluTheme.dark){
|
iconColor: FluTheme.dark ? Qt.rgba(222/255,222/255,222/255,1) : Qt.rgba(97/255,97/255,97/255,1)
|
||||||
switch(_super.type){
|
|
||||||
case mcontrol.const_success: return Qt.rgba(108/255,203/255,95/255,1);
|
|
||||||
case mcontrol.const_warning: return Qt.rgba(252/255,225/255,0/255,1);
|
|
||||||
case mcontrol.const_info: return FluTheme.primaryColor;
|
|
||||||
case mcontrol.const_error: return Qt.rgba(255/255,153/255,164/255,1);
|
|
||||||
}
|
|
||||||
return "#FFFFFF"
|
|
||||||
}else{
|
|
||||||
switch(_super.type){
|
|
||||||
case mcontrol.const_success: return "#0f7b0f";
|
|
||||||
case mcontrol.const_warning: return "#9d5d00";
|
|
||||||
case mcontrol.const_info: return "#0066b4";
|
|
||||||
case mcontrol.const_error: return "#c42b1c";
|
|
||||||
}
|
|
||||||
return "#FFFFFF"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
onClicked: _super.close()
|
onClicked: _super.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function showSuccess(text,duration=1000,moremsg){
|
function showSuccess(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showInfo(text,duration=1000,moremsg){
|
function showInfo(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showWarning(text,duration=1000,moremsg){
|
function showWarning(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showError(text,duration=1000,moremsg){
|
function showError(text,duration=1000,moremsg){
|
||||||
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
|
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "")
|
||||||
}
|
}
|
||||||
function showCustom(itemcomponent,duration=1000){
|
function showCustom(itemcomponent,duration=1000){
|
||||||
return mcontrol.createCustom(itemcomponent,duration);
|
return mcontrol.createCustom(itemcomponent,duration)
|
||||||
}
|
}
|
||||||
function clearAllInfo(){
|
function clearAllInfo(){
|
||||||
if(mcontrol.screenLayout != null) {
|
if(mcontrol.screenLayout != null) {
|
||||||
|
@ -39,7 +39,7 @@ T.Menu {
|
|||||||
: false
|
: false
|
||||||
clip: true
|
clip: true
|
||||||
currentIndex: control.currentIndex
|
currentIndex: control.currentIndex
|
||||||
ScrollIndicator.vertical: ScrollIndicator {}
|
ScrollBar.vertical: FluScrollBar{}
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: 150
|
implicitWidth: 150
|
||||||
|
@ -1121,7 +1121,8 @@ Item {
|
|||||||
}
|
}
|
||||||
padding: 0
|
padding: 0
|
||||||
focus: true
|
focus: true
|
||||||
contentItem: Item{
|
contentItem: FluClip{
|
||||||
|
radius: [5,5,5,5]
|
||||||
ListView{
|
ListView{
|
||||||
id:list_view
|
id:list_view
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -1146,7 +1147,6 @@ Item {
|
|||||||
visible: item_button.activeFocus
|
visible: item_button.activeFocus
|
||||||
radius:4
|
radius:4
|
||||||
}
|
}
|
||||||
|
|
||||||
FluLoader{
|
FluLoader{
|
||||||
id:item_dot_loader
|
id:item_dot_loader
|
||||||
anchors{
|
anchors{
|
||||||
@ -1161,7 +1161,6 @@ Item {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
contentItem: FluText{
|
contentItem: FluText{
|
||||||
text:modelData.title
|
text:modelData.title
|
||||||
@ -1188,13 +1187,13 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
background: FluRectangle{
|
background: Rectangle{
|
||||||
implicitWidth: 180
|
implicitWidth: 180
|
||||||
radius: [4,4,4,4]
|
color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(252/255,252/255,252/255,1)
|
||||||
FluShadow{
|
border.color: FluTheme.dark ? Qt.rgba(26/255,26/255,26/255,1) : Qt.rgba(191/255,191/255,191/255,1)
|
||||||
radius: 4
|
border.width: 1
|
||||||
}
|
radius: 5
|
||||||
color: FluTheme.dark ? Qt.rgba(51/255,48/255,48/255,1) : Qt.rgba(248/255,250/255,253/255,1)
|
FluShadow{}
|
||||||
}
|
}
|
||||||
function showPopup(pos,height,model){
|
function showPopup(pos,height,model){
|
||||||
background.implicitHeight = height
|
background.implicitHeight = height
|
||||||
|
@ -11,19 +11,19 @@ QtObject {
|
|||||||
windows.push(window)
|
windows.push(window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function removeWindow(window) {
|
function removeWindow(win) {
|
||||||
if(!window.transientParent){
|
if(!win.transientParent){
|
||||||
var index = windows.indexOf(window)
|
var index = windows.indexOf(win)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
windows.splice(index, 1)
|
windows.splice(index, 1)
|
||||||
FluTools.deleteLater(window)
|
win.deleteLater()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function exit(retCode){
|
function exit(retCode){
|
||||||
for(var i =0 ;i< windows.length; i++){
|
for(var i =0 ;i< windows.length; i++){
|
||||||
var item = windows[i]
|
var win = windows[i]
|
||||||
FluTools.deleteLater(item)
|
win.deleteLater()
|
||||||
}
|
}
|
||||||
windows = []
|
windows = []
|
||||||
Qt.exit(retCode)
|
Qt.exit(retCode)
|
||||||
@ -56,9 +56,7 @@ QtObject {
|
|||||||
var launchMode = win.launchMode
|
var launchMode = win.launchMode
|
||||||
if(launchMode === 1){
|
if(launchMode === 1){
|
||||||
win.argument = argument
|
win.argument = argument
|
||||||
if(!win.visible){
|
win.show()
|
||||||
win.visible = true
|
|
||||||
}
|
|
||||||
win.raise()
|
win.raise()
|
||||||
win.requestActivate()
|
win.requestActivate()
|
||||||
return
|
return
|
||||||
|
@ -10,7 +10,30 @@ FluIconButton {
|
|||||||
property string positiveText: qsTr("Save")
|
property string positiveText: qsTr("Save")
|
||||||
property string neutralText: qsTr("Cancel")
|
property string neutralText: qsTr("Cancel")
|
||||||
property string negativeText: qsTr("Reset")
|
property string negativeText: qsTr("Reset")
|
||||||
|
property bool registered: true
|
||||||
|
property color errorColor: Qt.rgba(250/255,85/255,85/255,1)
|
||||||
|
property FluHotkey syncHotkey: undefined
|
||||||
signal accepted()
|
signal accepted()
|
||||||
|
padding: 0
|
||||||
|
verticalPadding: 0
|
||||||
|
horizontalPadding: 0
|
||||||
|
onSyncHotkeyChanged: {
|
||||||
|
current = syncHotkey.sequence.split("+")
|
||||||
|
control.registered = syncHotkey.isRegistered
|
||||||
|
control.registered = Qt.binding(function(){
|
||||||
|
return syncHotkey.isRegistered
|
||||||
|
})
|
||||||
|
}
|
||||||
|
text: ""
|
||||||
|
color: {
|
||||||
|
if(!enabled){
|
||||||
|
return disableColor
|
||||||
|
}
|
||||||
|
if(pressed){
|
||||||
|
return pressedColor
|
||||||
|
}
|
||||||
|
return hovered ? hoverColor : normalColor
|
||||||
|
}
|
||||||
QtObject{
|
QtObject{
|
||||||
id: d
|
id: d
|
||||||
function keyToString(key_code,shift = true)
|
function keyToString(key_code,shift = true)
|
||||||
@ -112,15 +135,80 @@ FluIconButton {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
background: Rectangle{
|
background: Item{
|
||||||
border.color: FluTheme.dark ? "#505050" : "#DFDFDF"
|
|
||||||
border.width: 1
|
|
||||||
implicitHeight: 42
|
implicitHeight: 42
|
||||||
implicitWidth: layout_row.width+28
|
implicitWidth: 42
|
||||||
radius: control.radius
|
}
|
||||||
color:control.color
|
contentItem: Item{
|
||||||
FluFocusRectangle{
|
implicitWidth: childrenRect.width
|
||||||
visible: control.activeFocus
|
implicitHeight: layout_row.height
|
||||||
|
|
||||||
|
FluText{
|
||||||
|
id: text_title
|
||||||
|
text: control.text
|
||||||
|
visible: control.text !== ""
|
||||||
|
rightPadding: 8
|
||||||
|
anchors{
|
||||||
|
verticalCenter: layout_rect.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle{
|
||||||
|
id: layout_rect
|
||||||
|
border.color: FluTheme.dark ? "#505050" : "#DFDFDF"
|
||||||
|
border.width: 1
|
||||||
|
radius: control.radius
|
||||||
|
color: control.color
|
||||||
|
height: control.height
|
||||||
|
width: layout_row.width
|
||||||
|
anchors{
|
||||||
|
left: text_title.right
|
||||||
|
}
|
||||||
|
FluFocusRectangle{
|
||||||
|
visible: control.activeFocus
|
||||||
|
}
|
||||||
|
Row{
|
||||||
|
id:layout_row
|
||||||
|
spacing: 5
|
||||||
|
anchors.centerIn: parent
|
||||||
|
Item{
|
||||||
|
width: 8
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
Repeater{
|
||||||
|
model: control.current
|
||||||
|
delegate: Loader{
|
||||||
|
property var keyText: modelData
|
||||||
|
sourceComponent: com_item_key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item{
|
||||||
|
width: 3
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
FluIcon{
|
||||||
|
iconSource: FluentIcons.EditMirrored
|
||||||
|
iconSize: 13
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item{
|
||||||
|
width: 8
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
id: text_error
|
||||||
|
text: qsTr("Conflict")
|
||||||
|
color: control.errorColor
|
||||||
|
visible: !control.registered
|
||||||
|
anchors{
|
||||||
|
verticalCenter: layout_rect.verticalCenter
|
||||||
|
left: layout_rect.right
|
||||||
|
leftMargin: 4
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
@ -139,29 +227,6 @@ FluIconButton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row{
|
|
||||||
id:layout_row
|
|
||||||
spacing: 5
|
|
||||||
anchors.centerIn: parent
|
|
||||||
Repeater{
|
|
||||||
model: control.current
|
|
||||||
delegate: Loader{
|
|
||||||
property var keyText: modelData
|
|
||||||
sourceComponent: com_item_key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Item{
|
|
||||||
width: 3
|
|
||||||
height: 1
|
|
||||||
}
|
|
||||||
FluIcon{
|
|
||||||
iconSource: FluentIcons.EditMirrored
|
|
||||||
iconSize: 13
|
|
||||||
anchors{
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FluContentDialog{
|
FluContentDialog{
|
||||||
id:content_dialog
|
id:content_dialog
|
||||||
property var keysModel: []
|
property var keysModel: []
|
||||||
@ -179,6 +244,9 @@ FluIconButton {
|
|||||||
onPositiveClicked: {
|
onPositiveClicked: {
|
||||||
control.current = content_dialog.keysModel
|
control.current = content_dialog.keysModel
|
||||||
control.accepted()
|
control.accepted()
|
||||||
|
if(control.syncHotkey){
|
||||||
|
control.syncHotkey.sequence = control.current.join("+")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onNegativeClickListener: function(){
|
onNegativeClickListener: function(){
|
||||||
content_dialog.keysModel = control.current
|
content_dialog.keysModel = control.current
|
||||||
|
@ -225,22 +225,21 @@ Rectangle {
|
|||||||
id:com_table_delegate
|
id:com_table_delegate
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:item_table_mouse
|
id:item_table_mouse
|
||||||
implicitWidth: TableView.view.width
|
|
||||||
property var _model: model
|
property var _model: model
|
||||||
property bool isMainTable: TableView.view == table_view
|
property bool isMainTable: TableView.view == table_view
|
||||||
property var currentTableView: TableView.view
|
property var currentTableView: TableView.view
|
||||||
visible: {
|
property bool isHide: {
|
||||||
if(isMainTable && columnModel.frozen){
|
if(isMainTable && columnModel.frozen){
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
if(!isMainTable){
|
if(!isMainTable){
|
||||||
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
property bool isRowSelected: {
|
property bool isRowSelected: {
|
||||||
if(rowModel === null)
|
if(!rowModel)
|
||||||
return false
|
return false
|
||||||
if(d.current){
|
if(d.current){
|
||||||
return rowModel._key === d.current._key
|
return rowModel._key === d.current._key
|
||||||
@ -248,11 +247,15 @@ Rectangle {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
property bool editVisible: {
|
property bool editVisible: {
|
||||||
|
if(!rowModel)
|
||||||
|
return false
|
||||||
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition._key === rowModel._key && d.editPosition.column === column){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
implicitWidth: isHide ? Number.MIN_VALUE : TableView.view.width
|
||||||
|
visible: !isHide
|
||||||
TableView.onPooled: {
|
TableView.onPooled: {
|
||||||
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
if(d.editPosition && d.editPosition.row === row && d.editPosition.column === column){
|
||||||
control.closeEditor()
|
control.closeEditor()
|
||||||
@ -441,6 +444,11 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onWidthChanged:{
|
||||||
|
table_view.forceLayout()
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea{
|
MouseArea{
|
||||||
id:layout_mouse_table
|
id:layout_mouse_table
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
@ -475,7 +483,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component{
|
Component{
|
||||||
id:com_column_header_delegate
|
id: com_column_header_delegate
|
||||||
Rectangle{
|
Rectangle{
|
||||||
id: column_item_control
|
id: column_item_control
|
||||||
property var currentTableView : TableView.view
|
property var currentTableView : TableView.view
|
||||||
@ -490,17 +498,31 @@ Rectangle {
|
|||||||
return control.columnSource.findIndex(isDataIndex)
|
return control.columnSource.findIndex(isDataIndex)
|
||||||
}
|
}
|
||||||
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
|
readonly property bool isHeaderHorizontal: TableView.view == header_horizontal
|
||||||
|
readonly property bool isHide: {
|
||||||
|
if(isHeaderHorizontal){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if(!isHeaderHorizontal){
|
||||||
|
if(currentTableView.dataIndex !== columnModel.dataIndex)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
visible: !isHide
|
||||||
implicitWidth: {
|
implicitWidth: {
|
||||||
|
if(isHide){
|
||||||
|
return Number.MIN_VALUE
|
||||||
|
}
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
|
return (item_column_loader.item && item_column_loader.item.implicitWidth) + (cellPadding * 2)
|
||||||
}
|
}
|
||||||
return TableView.view.width
|
return Math.max(TableView.view.width,Number.MIN_VALUE)
|
||||||
}
|
}
|
||||||
implicitHeight: {
|
implicitHeight: {
|
||||||
if(column_item_control.isHeaderHorizontal){
|
if(column_item_control.isHeaderHorizontal){
|
||||||
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
|
return Math.max(36, (item_column_loader.item&&item_column_loader.item.implicitHeight) + (cellPadding * 2))
|
||||||
}
|
}
|
||||||
return TableView.view.height
|
return Math.max(TableView.view.height,Number.MIN_VALUE)
|
||||||
}
|
}
|
||||||
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
color: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
|
||||||
Rectangle{
|
Rectangle{
|
||||||
@ -616,7 +638,6 @@ Rectangle {
|
|||||||
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
columnModel.width = Math.min(Math.max(minimumWidth, w + delta.x),maximumWidth)
|
||||||
table_view.forceLayout()
|
table_view.forceLayout()
|
||||||
header_horizontal.forceLayout()
|
header_horizontal.forceLayout()
|
||||||
// column_item_control.currentTableView.forceLayout()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -870,12 +891,32 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
}
|
}
|
||||||
|
TableView{
|
||||||
|
property string dataIndex: columnModel.dataIndex
|
||||||
|
id: item_table_frozen
|
||||||
|
interactive: false
|
||||||
|
clip: true
|
||||||
|
anchors{
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
contentWidth: width
|
||||||
|
height: table_view.height
|
||||||
|
y: header_horizontal.height
|
||||||
|
boundsBehavior: TableView.StopAtBounds
|
||||||
|
model: table_view.model
|
||||||
|
delegate: table_view.delegate
|
||||||
|
syncDirection: Qt.Vertical
|
||||||
|
syncView: table_view
|
||||||
|
}
|
||||||
TableView {
|
TableView {
|
||||||
|
property string dataIndex: columnModel.dataIndex
|
||||||
id:item_table_frozen_header
|
id:item_table_frozen_header
|
||||||
model: header_column_model
|
model: header_column_model
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
clip: true
|
|
||||||
interactive: false
|
interactive: false
|
||||||
|
clip: true
|
||||||
|
contentWidth: width
|
||||||
anchors{
|
anchors{
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
@ -883,24 +924,14 @@ Rectangle {
|
|||||||
bottom: item_table_frozen.top
|
bottom: item_table_frozen.top
|
||||||
}
|
}
|
||||||
delegate: com_column_header_delegate
|
delegate: com_column_header_delegate
|
||||||
}
|
|
||||||
TableView{
|
|
||||||
property string dataIndex: columnModel.dataIndex
|
|
||||||
id: item_table_frozen
|
|
||||||
clip: true
|
|
||||||
interactive: false
|
|
||||||
anchors{
|
|
||||||
fill: parent
|
|
||||||
topMargin: header_horizontal.height
|
|
||||||
}
|
|
||||||
boundsBehavior: TableView.StopAtBounds
|
|
||||||
model: table_sort_model
|
|
||||||
delegate: com_table_delegate
|
|
||||||
syncDirection: Qt.Vertical
|
|
||||||
syncView: table_view
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
item_table_frozen_header.contentX = columnModel.width * _index
|
item_table_frozen_header.forceLayout()
|
||||||
item_table_frozen.contentX = columnModel.width * _index
|
}
|
||||||
|
}
|
||||||
|
Connections{
|
||||||
|
target: table_view
|
||||||
|
function onWidthChanged() {
|
||||||
|
item_table_frozen_header.forceLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -914,6 +945,12 @@ Rectangle {
|
|||||||
id: item_layout_frozen
|
id: item_layout_frozen
|
||||||
readonly property int _index : model.index
|
readonly property int _index : model.index
|
||||||
readonly property var columnModel : control.columnSource[_index]
|
readonly property var columnModel : control.columnSource[_index]
|
||||||
|
readonly property bool isHide:{
|
||||||
|
if(columnModel.frozen){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
Connections{
|
Connections{
|
||||||
target: d
|
target: d
|
||||||
function onTableItemLayout(column){
|
function onTableItemLayout(column){
|
||||||
@ -932,17 +969,17 @@ Rectangle {
|
|||||||
width = table_view.columnWidthProvider(_index)
|
width = table_view.columnWidthProvider(_index)
|
||||||
x = Qt.binding(function(){
|
x = Qt.binding(function(){
|
||||||
var minX = 0
|
var minX = 0
|
||||||
var maxX = table_view.width-item_layout_frozen.width
|
var maxX = table_view.width-width
|
||||||
for(var i=0;i<_index;i++){
|
for(var i=0;i<_index;i++){
|
||||||
var item = control.columnSource[i]
|
var item = control.columnSource[i]
|
||||||
if(item.frozen){
|
if(item.frozen){
|
||||||
minX = minX + item.width
|
minX = minX + table_view.columnWidthProvider(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(i=_index+1;i<control.columnSource.length;i++){
|
for(i=_index+1;i<control.columnSource.length;i++){
|
||||||
item = control.columnSource[i]
|
item = control.columnSource[i]
|
||||||
if(item.frozen){
|
if(item.frozen){
|
||||||
maxX = maxX- item.width
|
maxX = maxX - table_view.columnWidthProvider(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
|
return Math.min(Math.max(columnModel.x - table_view.contentX,minX),maxX)}
|
||||||
@ -952,23 +989,8 @@ Rectangle {
|
|||||||
updateLayout()
|
updateLayout()
|
||||||
}
|
}
|
||||||
height: control.height
|
height: control.height
|
||||||
visible: {
|
visible: !item_layout_frozen.isHide
|
||||||
if(modelData.frozen){
|
sourceComponent: item_layout_frozen.isHide ? undefined : com_table_frozen
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
sourceComponent: visible ? com_table_frozen : undefined
|
|
||||||
onStatusChanged: {
|
|
||||||
if(status === Loader.Ready){
|
|
||||||
sourceComponent = Qt.binding(function(){
|
|
||||||
if(modelData.frozen){
|
|
||||||
return com_table_frozen
|
|
||||||
}
|
|
||||||
return undefined
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,9 +324,6 @@ Window {
|
|||||||
window.minimumHeight = window.height
|
window.minimumHeight = window.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function registerForWindowResult(path){
|
|
||||||
return FluApp.createWindowRegister(window,path)
|
|
||||||
}
|
|
||||||
function setResult(data){
|
function setResult(data){
|
||||||
if(_windowRegister){
|
if(_windowRegister){
|
||||||
_windowRegister.setResult(data)
|
_windowRegister.setResult(data)
|
||||||
@ -352,4 +349,7 @@ Window {
|
|||||||
function setHitTestVisible(val){
|
function setHitTestVisible(val){
|
||||||
frameless.setHitTestVisible(val)
|
frameless.setHitTestVisible(val)
|
||||||
}
|
}
|
||||||
|
function deleteLater(){
|
||||||
|
FluTools.deleteLater(window)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,49 +74,49 @@
|
|||||||
<name>FluColorPicker</name>
|
<name>FluColorPicker</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="16"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="16"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="16"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
||||||
<source>Cancel</source>
|
<source>Cancel</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
||||||
<source>OK</source>
|
<source>OK</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
||||||
<source>Color Picker</source>
|
<source>Color Picker</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
||||||
<source>Edit Color</source>
|
<source>Edit Color</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
||||||
<source>Red</source>
|
<source>Red</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
||||||
<source>Green</source>
|
<source>Green</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
||||||
<source>Blue</source>
|
<source>Blue</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="24"/>
|
||||||
<source>Opacity</source>
|
<source>Opacity</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -187,14 +187,14 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>FluPagination</name>
|
<name>FluPagination</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="8"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="10"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="8"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="9"/>
|
||||||
<source><Previous</source>
|
<source><Previous</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="9"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="11"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="9"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="10"/>
|
||||||
<source>Next></source>
|
<source>Next></source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -231,6 +231,11 @@
|
|||||||
<source>Reset</source>
|
<source>Reset</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="Qt6/imports/FluentUI/Controls/FluShortcutPicker.qml" line="205"/>
|
||||||
|
<source>Conflict</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>FluStatusLayout</name>
|
<name>FluStatusLayout</name>
|
||||||
@ -349,10 +354,23 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>FluWindow</name>
|
<name>FluWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="335"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="347"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="334"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="346"/>
|
||||||
<source>Loading...</source>
|
<source>Loading...</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>QHotkey</name>
|
||||||
|
<message>
|
||||||
|
<location filename="qhotkey/qhotkey.cpp" line="294"/>
|
||||||
|
<source>Failed to register %1. Error: %2</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qhotkey/qhotkey.cpp" line="314"/>
|
||||||
|
<source>Failed to unregister %1. Error: %2</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
@ -74,49 +74,49 @@
|
|||||||
<name>FluColorPicker</name>
|
<name>FluColorPicker</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="16"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="16"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="16"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
||||||
<source>Cancel</source>
|
<source>Cancel</source>
|
||||||
<translation type="unfinished">取消</translation>
|
<translation type="unfinished">取消</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="17"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
||||||
<source>OK</source>
|
<source>OK</source>
|
||||||
<translation type="unfinished">确定</translation>
|
<translation type="unfinished">确定</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="18"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
||||||
<source>Color Picker</source>
|
<source>Color Picker</source>
|
||||||
<translation type="unfinished">颜色选择器</translation>
|
<translation type="unfinished">颜色选择器</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="19"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
||||||
<source>Edit Color</source>
|
<source>Edit Color</source>
|
||||||
<translation type="unfinished">编辑颜色</translation>
|
<translation type="unfinished">编辑颜色</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="20"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
||||||
<source>Red</source>
|
<source>Red</source>
|
||||||
<translation type="unfinished">红色</translation>
|
<translation type="unfinished">红色</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="21"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
||||||
<source>Green</source>
|
<source>Green</source>
|
||||||
<translation type="unfinished">绿色</translation>
|
<translation type="unfinished">绿色</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="22"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
||||||
<source>Blue</source>
|
<source>Blue</source>
|
||||||
<translation type="unfinished">蓝色</translation>
|
<translation type="unfinished">蓝色</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="23"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluColorPicker.qml" line="24"/>
|
||||||
<source>Opacity</source>
|
<source>Opacity</source>
|
||||||
<translation type="unfinished">透明度</translation>
|
<translation type="unfinished">透明度</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -187,14 +187,14 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>FluPagination</name>
|
<name>FluPagination</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="8"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="10"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="8"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="9"/>
|
||||||
<source><Previous</source>
|
<source><Previous</source>
|
||||||
<translation type="unfinished"><上一页</translation>
|
<translation type="unfinished"><上一页</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="9"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluPagination.qml" line="11"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="9"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluPagination.qml" line="10"/>
|
||||||
<source>Next></source>
|
<source>Next></source>
|
||||||
<translation type="unfinished">下一页></translation>
|
<translation type="unfinished">下一页></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -231,6 +231,11 @@
|
|||||||
<source>Reset</source>
|
<source>Reset</source>
|
||||||
<translation type="unfinished">重置</translation>
|
<translation type="unfinished">重置</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="Qt6/imports/FluentUI/Controls/FluShortcutPicker.qml" line="205"/>
|
||||||
|
<source>Conflict</source>
|
||||||
|
<translation type="unfinished">冲突</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>FluStatusLayout</name>
|
<name>FluStatusLayout</name>
|
||||||
@ -349,10 +354,23 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>FluWindow</name>
|
<name>FluWindow</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="335"/>
|
<location filename="Qt5/imports/FluentUI/Controls/FluWindow.qml" line="347"/>
|
||||||
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="334"/>
|
<location filename="Qt6/imports/FluentUI/Controls/FluWindow.qml" line="346"/>
|
||||||
<source>Loading...</source>
|
<source>Loading...</source>
|
||||||
<translation type="unfinished">加载中...</translation>
|
<translation type="unfinished">加载中...</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>QHotkey</name>
|
||||||
|
<message>
|
||||||
|
<location filename="qhotkey/qhotkey.cpp" line="294"/>
|
||||||
|
<source>Failed to register %1. Error: %2</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="qhotkey/qhotkey.cpp" line="314"/>
|
||||||
|
<source>Failed to unregister %1. Error: %2</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
377
src/qhotkey/qhotkey.cpp
Normal file
377
src/qhotkey/qhotkey.cpp
Normal file
@ -0,0 +1,377 @@
|
|||||||
|
#include "qhotkey.h"
|
||||||
|
#include "qhotkey_p.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QAbstractEventDispatcher>
|
||||||
|
#include <QMetaMethod>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(logQHotkey, "QHotkey")
|
||||||
|
|
||||||
|
void QHotkey::addGlobalMapping(const QKeySequence &shortcut, QHotkey::NativeShortcut nativeShortcut)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
const int key = shortcut[0].toCombined();
|
||||||
|
#else
|
||||||
|
const int key = shortcut[0];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(QHotkeyPrivate::instance(), "addMappingInvoked", Qt::QueuedConnection,
|
||||||
|
Q_ARG(Qt::Key, Qt::Key(key & ~Qt::KeyboardModifierMask)),
|
||||||
|
Q_ARG(Qt::KeyboardModifiers, Qt::KeyboardModifiers(key & Qt::KeyboardModifierMask)),
|
||||||
|
Q_ARG(QHotkey::NativeShortcut, nativeShortcut));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::isPlatformSupported()
|
||||||
|
{
|
||||||
|
return QHotkeyPrivate::isPlatformSupported();
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkey::QHotkey(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
_keyCode(Qt::Key_unknown),
|
||||||
|
_modifiers(Qt::NoModifier),
|
||||||
|
_registered(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QHotkey::QHotkey(const QKeySequence &shortcut, bool autoRegister, QObject *parent) :
|
||||||
|
QHotkey(parent)
|
||||||
|
{
|
||||||
|
setShortcut(shortcut, autoRegister);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkey::QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister, QObject *parent) :
|
||||||
|
QHotkey(parent)
|
||||||
|
{
|
||||||
|
setShortcut(keyCode, modifiers, autoRegister);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkey::QHotkey(QHotkey::NativeShortcut shortcut, bool autoRegister, QObject *parent) :
|
||||||
|
QHotkey(parent)
|
||||||
|
{
|
||||||
|
setNativeShortcut(shortcut, autoRegister);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkey::~QHotkey()
|
||||||
|
{
|
||||||
|
if(_registered)
|
||||||
|
QHotkeyPrivate::instance()->removeShortcut(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QKeySequence QHotkey::shortcut() const
|
||||||
|
{
|
||||||
|
if(_keyCode == Qt::Key_unknown)
|
||||||
|
return QKeySequence();
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
return QKeySequence((_keyCode | _modifiers).toCombined());
|
||||||
|
#else
|
||||||
|
return QKeySequence(static_cast<int>(_keyCode | _modifiers));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::Key QHotkey::keyCode() const
|
||||||
|
{
|
||||||
|
return _keyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::KeyboardModifiers QHotkey::modifiers() const
|
||||||
|
{
|
||||||
|
return _modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkey::NativeShortcut QHotkey::currentNativeShortcut() const
|
||||||
|
{
|
||||||
|
return _nativeShortcut;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::isRegistered() const
|
||||||
|
{
|
||||||
|
return _registered;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::setShortcut(const QKeySequence &shortcut, bool autoRegister)
|
||||||
|
{
|
||||||
|
if(shortcut.isEmpty())
|
||||||
|
return resetShortcut();
|
||||||
|
if(shortcut.count() > 1) {
|
||||||
|
qCWarning(logQHotkey, "Keysequences with multiple shortcuts are not allowed! "
|
||||||
|
"Only the first shortcut will be used!");
|
||||||
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
const int key = shortcut[0].toCombined();
|
||||||
|
#else
|
||||||
|
const int key = shortcut[0];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return setShortcut(Qt::Key(key & ~Qt::KeyboardModifierMask),
|
||||||
|
Qt::KeyboardModifiers(key & Qt::KeyboardModifierMask),
|
||||||
|
autoRegister);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister)
|
||||||
|
{
|
||||||
|
if(_registered) {
|
||||||
|
if(autoRegister) {
|
||||||
|
if(!QHotkeyPrivate::instance()->removeShortcut(this))
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(keyCode == Qt::Key_unknown) {
|
||||||
|
_keyCode = Qt::Key_unknown;
|
||||||
|
_modifiers = Qt::NoModifier;
|
||||||
|
_nativeShortcut = NativeShortcut();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_keyCode = keyCode;
|
||||||
|
_modifiers = modifiers;
|
||||||
|
_nativeShortcut = QHotkeyPrivate::instance()->nativeShortcut(keyCode, modifiers);
|
||||||
|
if(_nativeShortcut.isValid()) {
|
||||||
|
if(autoRegister)
|
||||||
|
return QHotkeyPrivate::instance()->addShortcut(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCWarning(logQHotkey) << "Unable to map shortcut to native keys. Key:" << keyCode << "Modifiers:" << modifiers;
|
||||||
|
_keyCode = Qt::Key_unknown;
|
||||||
|
_modifiers = Qt::NoModifier;
|
||||||
|
_nativeShortcut = NativeShortcut();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::resetShortcut()
|
||||||
|
{
|
||||||
|
if(_registered &&
|
||||||
|
!QHotkeyPrivate::instance()->removeShortcut(this)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_keyCode = Qt::Key_unknown;
|
||||||
|
_modifiers = Qt::NoModifier;
|
||||||
|
_nativeShortcut = NativeShortcut();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::setNativeShortcut(QHotkey::NativeShortcut nativeShortcut, bool autoRegister)
|
||||||
|
{
|
||||||
|
if(_registered) {
|
||||||
|
if(autoRegister) {
|
||||||
|
if(!QHotkeyPrivate::instance()->removeShortcut(this))
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nativeShortcut.isValid()) {
|
||||||
|
_keyCode = Qt::Key_unknown;
|
||||||
|
_modifiers = Qt::NoModifier;
|
||||||
|
_nativeShortcut = nativeShortcut;
|
||||||
|
if(autoRegister)
|
||||||
|
return QHotkeyPrivate::instance()->addShortcut(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_keyCode = Qt::Key_unknown;
|
||||||
|
_modifiers = Qt::NoModifier;
|
||||||
|
_nativeShortcut = NativeShortcut();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::setRegistered(bool registered)
|
||||||
|
{
|
||||||
|
if(_registered && !registered)
|
||||||
|
return QHotkeyPrivate::instance()->removeShortcut(this);
|
||||||
|
if(!_registered && registered) {
|
||||||
|
if(!_nativeShortcut.isValid())
|
||||||
|
return false;
|
||||||
|
return QHotkeyPrivate::instance()->addShortcut(this);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ---------- QHotkeyPrivate implementation ----------
|
||||||
|
|
||||||
|
QHotkeyPrivate::QHotkeyPrivate()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(qApp, Q_FUNC_INFO, "QHotkey requires QCoreApplication to be instantiated");
|
||||||
|
qApp->eventDispatcher()->installNativeEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkeyPrivate::~QHotkeyPrivate()
|
||||||
|
{
|
||||||
|
if(!shortcuts.isEmpty())
|
||||||
|
qCWarning(logQHotkey) << "QHotkeyPrivate destroyed with registered shortcuts!";
|
||||||
|
if(qApp && qApp->eventDispatcher())
|
||||||
|
qApp->eventDispatcher()->removeNativeEventFilter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
|
||||||
|
{
|
||||||
|
Qt::ConnectionType conType = (QThread::currentThread() == thread() ?
|
||||||
|
Qt::DirectConnection :
|
||||||
|
Qt::BlockingQueuedConnection);
|
||||||
|
QHotkey::NativeShortcut res;
|
||||||
|
if(!QMetaObject::invokeMethod(this, "nativeShortcutInvoked", conType,
|
||||||
|
Q_RETURN_ARG(QHotkey::NativeShortcut, res),
|
||||||
|
Q_ARG(Qt::Key, keycode),
|
||||||
|
Q_ARG(Qt::KeyboardModifiers, modifiers))) {
|
||||||
|
return QHotkey::NativeShortcut();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::addShortcut(QHotkey *hotkey)
|
||||||
|
{
|
||||||
|
if(hotkey->_registered)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Qt::ConnectionType conType = (QThread::currentThread() == thread() ?
|
||||||
|
Qt::DirectConnection :
|
||||||
|
Qt::BlockingQueuedConnection);
|
||||||
|
bool res = false;
|
||||||
|
if(!QMetaObject::invokeMethod(this, "addShortcutInvoked", conType,
|
||||||
|
Q_RETURN_ARG(bool, res),
|
||||||
|
Q_ARG(QHotkey*, hotkey))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
emit hotkey->registeredChanged(true);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::removeShortcut(QHotkey *hotkey)
|
||||||
|
{
|
||||||
|
if(!hotkey->_registered)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Qt::ConnectionType conType = (QThread::currentThread() == thread() ?
|
||||||
|
Qt::DirectConnection :
|
||||||
|
Qt::BlockingQueuedConnection);
|
||||||
|
bool res = false;
|
||||||
|
if(!QMetaObject::invokeMethod(this, "removeShortcutInvoked", conType,
|
||||||
|
Q_RETURN_ARG(bool, res),
|
||||||
|
Q_ARG(QHotkey*, hotkey))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
emit hotkey->registeredChanged(false);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHotkeyPrivate::activateShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
QMetaMethod signal = QMetaMethod::fromSignal(&QHotkey::activated);
|
||||||
|
for(QHotkey *hkey : shortcuts.values(shortcut))
|
||||||
|
signal.invoke(hkey, Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHotkeyPrivate::releaseShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
QMetaMethod signal = QMetaMethod::fromSignal(&QHotkey::released);
|
||||||
|
for(QHotkey *hkey : shortcuts.values(shortcut))
|
||||||
|
signal.invoke(hkey, Qt::QueuedConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHotkeyPrivate::addMappingInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers, QHotkey::NativeShortcut nativeShortcut)
|
||||||
|
{
|
||||||
|
mapping.insert({keycode, modifiers}, nativeShortcut);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::addShortcutInvoked(QHotkey *hotkey)
|
||||||
|
{
|
||||||
|
QHotkey::NativeShortcut shortcut = hotkey->_nativeShortcut;
|
||||||
|
|
||||||
|
if(!shortcuts.contains(shortcut)) {
|
||||||
|
if(!registerShortcut(shortcut)) {
|
||||||
|
qCWarning(logQHotkey) << QHotkey::tr("Failed to register %1. Error: %2").arg(hotkey->shortcut().toString(), error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shortcuts.insert(shortcut, hotkey);
|
||||||
|
hotkey->_registered = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::removeShortcutInvoked(QHotkey *hotkey)
|
||||||
|
{
|
||||||
|
QHotkey::NativeShortcut shortcut = hotkey->_nativeShortcut;
|
||||||
|
|
||||||
|
if(shortcuts.remove(shortcut, hotkey) == 0)
|
||||||
|
return false;
|
||||||
|
hotkey->_registered = false;
|
||||||
|
emit hotkey->registeredChanged(true);
|
||||||
|
if(shortcuts.count(shortcut) == 0) {
|
||||||
|
if (!unregisterShortcut(shortcut)) {
|
||||||
|
qCWarning(logQHotkey) << QHotkey::tr("Failed to unregister %1. Error: %2").arg(hotkey->shortcut().toString(), error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkey::NativeShortcut QHotkeyPrivate::nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers)
|
||||||
|
{
|
||||||
|
if(mapping.contains({keycode, modifiers}))
|
||||||
|
return mapping.value({keycode, modifiers});
|
||||||
|
|
||||||
|
bool ok1 = false;
|
||||||
|
auto k = nativeKeycode(keycode, ok1);
|
||||||
|
bool ok2 = false;
|
||||||
|
auto m = nativeModifiers(modifiers, ok2);
|
||||||
|
if(ok1 && ok2)
|
||||||
|
return {k, m};
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QHotkey::NativeShortcut::NativeShortcut() :
|
||||||
|
key(),
|
||||||
|
modifier(),
|
||||||
|
valid(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QHotkey::NativeShortcut::NativeShortcut(quint32 key, quint32 modifier) :
|
||||||
|
key(key),
|
||||||
|
modifier(modifier),
|
||||||
|
valid(true)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool QHotkey::NativeShortcut::isValid() const
|
||||||
|
{
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::NativeShortcut::operator ==(QHotkey::NativeShortcut other) const
|
||||||
|
{
|
||||||
|
return (key == other.key) &&
|
||||||
|
(modifier == other.modifier) &&
|
||||||
|
valid == other.valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkey::NativeShortcut::operator !=(QHotkey::NativeShortcut other) const
|
||||||
|
{
|
||||||
|
return (key != other.key) ||
|
||||||
|
(modifier != other.modifier) ||
|
||||||
|
valid != other.valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
QHOTKEY_HASH_SEED qHash(QHotkey::NativeShortcut key)
|
||||||
|
{
|
||||||
|
return qHash(key.key) ^ qHash(key.modifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHOTKEY_HASH_SEED qHash(QHotkey::NativeShortcut key, QHOTKEY_HASH_SEED seed)
|
||||||
|
{
|
||||||
|
return qHash(key.key, seed) ^ qHash(key.modifier, seed);
|
||||||
|
}
|
130
src/qhotkey/qhotkey.h
Normal file
130
src/qhotkey/qhotkey.h
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
#ifndef QHOTKEY_H
|
||||||
|
#define QHOTKEY_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QKeySequence>
|
||||||
|
#include <QPair>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#ifdef QHOTKEY_SHARED
|
||||||
|
# ifdef QHOTKEY_LIBRARY
|
||||||
|
# define QHOTKEY_EXPORT Q_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define QHOTKEY_EXPORT Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define QHOTKEY_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
#define QHOTKEY_HASH_SEED size_t
|
||||||
|
#else
|
||||||
|
#define QHOTKEY_HASH_SEED uint
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//! A class to define global, systemwide Hotkeys
|
||||||
|
class QHOTKEY_EXPORT QHotkey : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
//! @private
|
||||||
|
friend class QHotkeyPrivate;
|
||||||
|
|
||||||
|
//! Specifies whether this hotkey is currently registered or not
|
||||||
|
Q_PROPERTY(bool registered READ isRegistered WRITE setRegistered NOTIFY registeredChanged)
|
||||||
|
//! Holds the shortcut this hotkey will be triggered on
|
||||||
|
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut RESET resetShortcut)
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Defines shortcut with native keycodes
|
||||||
|
class QHOTKEY_EXPORT NativeShortcut {
|
||||||
|
public:
|
||||||
|
//! The native keycode
|
||||||
|
quint32 key;
|
||||||
|
//! The native modifiers
|
||||||
|
quint32 modifier;
|
||||||
|
|
||||||
|
//! Creates an invalid native shortcut
|
||||||
|
NativeShortcut();
|
||||||
|
//! Creates a valid native shortcut, with the given key and modifiers
|
||||||
|
NativeShortcut(quint32 key, quint32 modifier = 0);
|
||||||
|
|
||||||
|
//! Checks, whether this shortcut is valid or not
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
//! Equality operator
|
||||||
|
bool operator ==(NativeShortcut other) const;
|
||||||
|
//! Inequality operator
|
||||||
|
bool operator !=(NativeShortcut other) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool valid;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Adds a global mapping of a key sequence to a replacement native shortcut
|
||||||
|
static void addGlobalMapping(const QKeySequence &shortcut, NativeShortcut nativeShortcut);
|
||||||
|
|
||||||
|
//! Checks if global shortcuts are supported by the current platform
|
||||||
|
static bool isPlatformSupported();
|
||||||
|
|
||||||
|
//! Default Constructor
|
||||||
|
explicit QHotkey(QObject *parent = nullptr);
|
||||||
|
//! Constructs a hotkey with a shortcut and optionally registers it
|
||||||
|
explicit QHotkey(const QKeySequence &shortcut, bool autoRegister = false, QObject *parent = nullptr);
|
||||||
|
//! Constructs a hotkey with a key and modifiers and optionally registers it
|
||||||
|
explicit QHotkey(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false, QObject *parent = nullptr);
|
||||||
|
//! Constructs a hotkey from a native shortcut and optionally registers it
|
||||||
|
explicit QHotkey(NativeShortcut shortcut, bool autoRegister = false, QObject *parent = nullptr);
|
||||||
|
~QHotkey() override;
|
||||||
|
|
||||||
|
//! @readAcFn{QHotkey::registered}
|
||||||
|
bool isRegistered() const;
|
||||||
|
//! @readAcFn{QHotkey::shortcut}
|
||||||
|
QKeySequence shortcut() const;
|
||||||
|
//! @readAcFn{QHotkey::shortcut} - the key only
|
||||||
|
Qt::Key keyCode() const;
|
||||||
|
//! @readAcFn{QHotkey::shortcut} - the modifiers only
|
||||||
|
Qt::KeyboardModifiers modifiers() const;
|
||||||
|
|
||||||
|
//! Get the current native shortcut
|
||||||
|
NativeShortcut currentNativeShortcut() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//! @writeAcFn{QHotkey::registered}
|
||||||
|
bool setRegistered(bool registered);
|
||||||
|
|
||||||
|
//! @writeAcFn{QHotkey::shortcut}
|
||||||
|
bool setShortcut(const QKeySequence &shortcut, bool autoRegister = false);
|
||||||
|
//! @writeAcFn{QHotkey::shortcut}
|
||||||
|
bool setShortcut(Qt::Key keyCode, Qt::KeyboardModifiers modifiers, bool autoRegister = false);
|
||||||
|
//! @resetAcFn{QHotkey::shortcut}
|
||||||
|
bool resetShortcut();
|
||||||
|
|
||||||
|
//! Set this hotkey to a native shortcut
|
||||||
|
bool setNativeShortcut(QHotkey::NativeShortcut nativeShortcut, bool autoRegister = false);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
//! Will be emitted if the shortcut is pressed
|
||||||
|
void activated(QPrivateSignal);
|
||||||
|
|
||||||
|
//! Will be emitted if the shortcut press is released
|
||||||
|
void released(QPrivateSignal);
|
||||||
|
|
||||||
|
//! @notifyAcFn{QHotkey::registered}
|
||||||
|
void registeredChanged(bool registered);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Qt::Key _keyCode;
|
||||||
|
Qt::KeyboardModifiers _modifiers;
|
||||||
|
|
||||||
|
NativeShortcut _nativeShortcut;
|
||||||
|
bool _registered;
|
||||||
|
};
|
||||||
|
|
||||||
|
QHOTKEY_HASH_SEED QHOTKEY_EXPORT qHash(QHotkey::NativeShortcut key);
|
||||||
|
QHOTKEY_HASH_SEED QHOTKEY_EXPORT qHash(QHotkey::NativeShortcut key, QHOTKEY_HASH_SEED seed);
|
||||||
|
|
||||||
|
QHOTKEY_EXPORT Q_DECLARE_LOGGING_CATEGORY(logQHotkey)
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(QHotkey::NativeShortcut)
|
||||||
|
|
||||||
|
#endif // QHOTKEY_H
|
291
src/qhotkey/qhotkey_mac.cpp
Normal file
291
src/qhotkey/qhotkey_mac.cpp
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
#include "qhotkey.h"
|
||||||
|
#include "qhotkey_p.h"
|
||||||
|
#include <Carbon/Carbon.h>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
class QHotkeyPrivateMac : public QHotkeyPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// QAbstractNativeEventFilter interface
|
||||||
|
bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override;
|
||||||
|
|
||||||
|
static OSStatus hotkeyPressEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
|
||||||
|
static OSStatus hotkeyReleaseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// QHotkeyPrivate interface
|
||||||
|
quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
|
||||||
|
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
|
||||||
|
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||||
|
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool isHotkeyHandlerRegistered;
|
||||||
|
static QHash<QHotkey::NativeShortcut, EventHotKeyRef> hotkeyRefs;
|
||||||
|
};
|
||||||
|
NATIVE_INSTANCE(QHotkeyPrivateMac)
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::isPlatformSupported()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateMac::isHotkeyHandlerRegistered = false;
|
||||||
|
QHash<QHotkey::NativeShortcut, EventHotKeyRef> QHotkeyPrivateMac::hotkeyRefs;
|
||||||
|
|
||||||
|
bool QHotkeyPrivateMac::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result)
|
||||||
|
{
|
||||||
|
Q_UNUSED(eventType)
|
||||||
|
Q_UNUSED(message)
|
||||||
|
Q_UNUSED(result)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QHotkeyPrivateMac::nativeKeycode(Qt::Key keycode, bool &ok)
|
||||||
|
{
|
||||||
|
// Constants found in NSEvent.h from AppKit.framework
|
||||||
|
ok = true;
|
||||||
|
switch (keycode) {
|
||||||
|
case Qt::Key_Return:
|
||||||
|
return kVK_Return;
|
||||||
|
case Qt::Key_Enter:
|
||||||
|
return kVK_ANSI_KeypadEnter;
|
||||||
|
case Qt::Key_Tab:
|
||||||
|
return kVK_Tab;
|
||||||
|
case Qt::Key_Space:
|
||||||
|
return kVK_Space;
|
||||||
|
case Qt::Key_Backspace:
|
||||||
|
return kVK_Delete;
|
||||||
|
case Qt::Key_Escape:
|
||||||
|
return kVK_Escape;
|
||||||
|
case Qt::Key_CapsLock:
|
||||||
|
return kVK_CapsLock;
|
||||||
|
case Qt::Key_Option:
|
||||||
|
return kVK_Option;
|
||||||
|
case Qt::Key_F17:
|
||||||
|
return kVK_F17;
|
||||||
|
case Qt::Key_VolumeUp:
|
||||||
|
return kVK_VolumeUp;
|
||||||
|
case Qt::Key_VolumeDown:
|
||||||
|
return kVK_VolumeDown;
|
||||||
|
case Qt::Key_F18:
|
||||||
|
return kVK_F18;
|
||||||
|
case Qt::Key_F19:
|
||||||
|
return kVK_F19;
|
||||||
|
case Qt::Key_F20:
|
||||||
|
return kVK_F20;
|
||||||
|
case Qt::Key_F5:
|
||||||
|
return kVK_F5;
|
||||||
|
case Qt::Key_F6:
|
||||||
|
return kVK_F6;
|
||||||
|
case Qt::Key_F7:
|
||||||
|
return kVK_F7;
|
||||||
|
case Qt::Key_F3:
|
||||||
|
return kVK_F3;
|
||||||
|
case Qt::Key_F8:
|
||||||
|
return kVK_F8;
|
||||||
|
case Qt::Key_F9:
|
||||||
|
return kVK_F9;
|
||||||
|
case Qt::Key_F11:
|
||||||
|
return kVK_F11;
|
||||||
|
case Qt::Key_F13:
|
||||||
|
return kVK_F13;
|
||||||
|
case Qt::Key_F16:
|
||||||
|
return kVK_F16;
|
||||||
|
case Qt::Key_F14:
|
||||||
|
return kVK_F14;
|
||||||
|
case Qt::Key_F10:
|
||||||
|
return kVK_F10;
|
||||||
|
case Qt::Key_F12:
|
||||||
|
return kVK_F12;
|
||||||
|
case Qt::Key_F15:
|
||||||
|
return kVK_F15;
|
||||||
|
case Qt::Key_Help:
|
||||||
|
return kVK_Help;
|
||||||
|
case Qt::Key_Home:
|
||||||
|
return kVK_Home;
|
||||||
|
case Qt::Key_PageUp:
|
||||||
|
return kVK_PageUp;
|
||||||
|
case Qt::Key_Delete:
|
||||||
|
return kVK_ForwardDelete;
|
||||||
|
case Qt::Key_F4:
|
||||||
|
return kVK_F4;
|
||||||
|
case Qt::Key_End:
|
||||||
|
return kVK_End;
|
||||||
|
case Qt::Key_F2:
|
||||||
|
return kVK_F2;
|
||||||
|
case Qt::Key_PageDown:
|
||||||
|
return kVK_PageDown;
|
||||||
|
case Qt::Key_F1:
|
||||||
|
return kVK_F1;
|
||||||
|
case Qt::Key_Left:
|
||||||
|
return kVK_LeftArrow;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
return kVK_RightArrow;
|
||||||
|
case Qt::Key_Down:
|
||||||
|
return kVK_DownArrow;
|
||||||
|
case Qt::Key_Up:
|
||||||
|
return kVK_UpArrow;
|
||||||
|
default:
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
UTF16Char ch = keycode;
|
||||||
|
|
||||||
|
CFDataRef currentLayoutData;
|
||||||
|
TISInputSourceRef currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource();
|
||||||
|
|
||||||
|
if (currentKeyboard == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
|
||||||
|
CFRelease(currentKeyboard);
|
||||||
|
if (currentLayoutData == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData);
|
||||||
|
UCKeyboardTypeHeader* table = header->keyboardTypeList;
|
||||||
|
|
||||||
|
uint8_t *data = (uint8_t*)header;
|
||||||
|
for (quint32 i=0; i < header->keyboardTypeCount; i++) {
|
||||||
|
UCKeyStateRecordsIndex* stateRec = 0;
|
||||||
|
if (table[i].keyStateRecordsIndexOffset != 0) {
|
||||||
|
stateRec = reinterpret_cast<UCKeyStateRecordsIndex*>(data + table[i].keyStateRecordsIndexOffset);
|
||||||
|
if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
UCKeyToCharTableIndex* charTable = reinterpret_cast<UCKeyToCharTableIndex*>(data + table[i].keyToCharTableIndexOffset);
|
||||||
|
if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue;
|
||||||
|
|
||||||
|
for (quint32 j=0; j < charTable->keyToCharTableCount; j++) {
|
||||||
|
UCKeyOutput* keyToChar = reinterpret_cast<UCKeyOutput*>(data + charTable->keyToCharTableOffsets[j]);
|
||||||
|
for (quint32 k=0; k < charTable->keyToCharTableSize; k++) {
|
||||||
|
if (keyToChar[k] & kUCKeyOutputTestForIndexMask) {
|
||||||
|
long idx = keyToChar[k] & kUCKeyOutputGetIndexMask;
|
||||||
|
if (stateRec && idx < stateRec->keyStateRecordCount) {
|
||||||
|
UCKeyStateRecord* rec = reinterpret_cast<UCKeyStateRecord*>(data + stateRec->keyStateRecordOffsets[idx]);
|
||||||
|
if (rec->stateZeroCharData == ch) {
|
||||||
|
ok = true;
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) {
|
||||||
|
if (keyToChar[k] == ch) {
|
||||||
|
ok = true;
|
||||||
|
return k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QHotkeyPrivateMac::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
|
||||||
|
{
|
||||||
|
quint32 nMods = 0;
|
||||||
|
if (modifiers & Qt::ShiftModifier)
|
||||||
|
nMods |= shiftKey;
|
||||||
|
if (modifiers & Qt::ControlModifier)
|
||||||
|
nMods |= cmdKey;
|
||||||
|
if (modifiers & Qt::AltModifier)
|
||||||
|
nMods |= optionKey;
|
||||||
|
if (modifiers & Qt::MetaModifier)
|
||||||
|
nMods |= controlKey;
|
||||||
|
if (modifiers & Qt::KeypadModifier)
|
||||||
|
nMods |= kEventKeyModifierNumLockMask;
|
||||||
|
ok = true;
|
||||||
|
return nMods;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateMac::registerShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
if (!this->isHotkeyHandlerRegistered)
|
||||||
|
{
|
||||||
|
EventTypeSpec pressEventSpec;
|
||||||
|
pressEventSpec.eventClass = kEventClassKeyboard;
|
||||||
|
pressEventSpec.eventKind = kEventHotKeyPressed;
|
||||||
|
InstallApplicationEventHandler(&QHotkeyPrivateMac::hotkeyPressEventHandler, 1, &pressEventSpec, NULL, NULL);
|
||||||
|
|
||||||
|
EventTypeSpec releaseEventSpec;
|
||||||
|
releaseEventSpec.eventClass = kEventClassKeyboard;
|
||||||
|
releaseEventSpec.eventKind = kEventHotKeyReleased;
|
||||||
|
InstallApplicationEventHandler(&QHotkeyPrivateMac::hotkeyReleaseEventHandler, 1, &releaseEventSpec, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
EventHotKeyID hkeyID;
|
||||||
|
hkeyID.signature = shortcut.key;
|
||||||
|
hkeyID.id = shortcut.modifier;
|
||||||
|
|
||||||
|
EventHotKeyRef eventRef = 0;
|
||||||
|
OSStatus status = RegisterEventHotKey(shortcut.key,
|
||||||
|
shortcut.modifier,
|
||||||
|
hkeyID,
|
||||||
|
GetApplicationEventTarget(),
|
||||||
|
0,
|
||||||
|
&eventRef);
|
||||||
|
if (status != noErr) {
|
||||||
|
error = QString::number(status);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this->hotkeyRefs.insert(shortcut, eventRef);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateMac::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
EventHotKeyRef eventRef = QHotkeyPrivateMac::hotkeyRefs.value(shortcut);
|
||||||
|
OSStatus status = UnregisterEventHotKey(eventRef);
|
||||||
|
if (status != noErr) {
|
||||||
|
error = QString::number(status);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this->hotkeyRefs.remove(shortcut);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OSStatus QHotkeyPrivateMac::hotkeyPressEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
||||||
|
{
|
||||||
|
Q_UNUSED(nextHandler);
|
||||||
|
Q_UNUSED(data);
|
||||||
|
|
||||||
|
if (GetEventClass(event) == kEventClassKeyboard &&
|
||||||
|
GetEventKind(event) == kEventHotKeyPressed) {
|
||||||
|
EventHotKeyID hkeyID;
|
||||||
|
GetEventParameter(event,
|
||||||
|
kEventParamDirectObject,
|
||||||
|
typeEventHotKeyID,
|
||||||
|
NULL,
|
||||||
|
sizeof(EventHotKeyID),
|
||||||
|
NULL,
|
||||||
|
&hkeyID);
|
||||||
|
hotkeyPrivate->activateShortcut({hkeyID.signature, hkeyID.id});
|
||||||
|
}
|
||||||
|
|
||||||
|
return noErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
OSStatus QHotkeyPrivateMac::hotkeyReleaseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* data)
|
||||||
|
{
|
||||||
|
Q_UNUSED(nextHandler);
|
||||||
|
Q_UNUSED(data);
|
||||||
|
|
||||||
|
if (GetEventClass(event) == kEventClassKeyboard &&
|
||||||
|
GetEventKind(event) == kEventHotKeyReleased) {
|
||||||
|
EventHotKeyID hkeyID;
|
||||||
|
GetEventParameter(event,
|
||||||
|
kEventParamDirectObject,
|
||||||
|
typeEventHotKeyID,
|
||||||
|
NULL,
|
||||||
|
sizeof(EventHotKeyID),
|
||||||
|
NULL,
|
||||||
|
&hkeyID);
|
||||||
|
hotkeyPrivate->releaseShortcut({hkeyID.signature, hkeyID.id});
|
||||||
|
}
|
||||||
|
|
||||||
|
return noErr;
|
||||||
|
}
|
62
src/qhotkey/qhotkey_p.h
Normal file
62
src/qhotkey/qhotkey_p.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#ifndef QHOTKEY_P_H
|
||||||
|
#define QHOTKEY_P_H
|
||||||
|
|
||||||
|
#include "qhotkey.h"
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
|
#include <QMultiHash>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QGlobalStatic>
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
#define _NATIVE_EVENT_RESULT qintptr
|
||||||
|
#else
|
||||||
|
#define _NATIVE_EVENT_RESULT long
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class QHOTKEY_EXPORT QHotkeyPrivate : public QObject, public QAbstractNativeEventFilter
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QHotkeyPrivate();//singleton!!!
|
||||||
|
~QHotkeyPrivate();
|
||||||
|
|
||||||
|
static QHotkeyPrivate *instance();
|
||||||
|
static bool isPlatformSupported();
|
||||||
|
|
||||||
|
QHotkey::NativeShortcut nativeShortcut(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
||||||
|
|
||||||
|
bool addShortcut(QHotkey *hotkey);
|
||||||
|
bool removeShortcut(QHotkey *hotkey);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void activateShortcut(QHotkey::NativeShortcut shortcut);
|
||||||
|
void releaseShortcut(QHotkey::NativeShortcut shortcut);
|
||||||
|
|
||||||
|
virtual quint32 nativeKeycode(Qt::Key keycode, bool &ok) = 0;//platform implement
|
||||||
|
virtual quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) = 0;//platform implement
|
||||||
|
|
||||||
|
virtual bool registerShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement
|
||||||
|
virtual bool unregisterShortcut(QHotkey::NativeShortcut shortcut) = 0;//platform implement
|
||||||
|
|
||||||
|
QString error;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHash<QPair<Qt::Key, Qt::KeyboardModifiers>, QHotkey::NativeShortcut> mapping;
|
||||||
|
QMultiHash<QHotkey::NativeShortcut, QHotkey*> shortcuts;
|
||||||
|
|
||||||
|
Q_INVOKABLE void addMappingInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers, QHotkey::NativeShortcut nativeShortcut);
|
||||||
|
Q_INVOKABLE bool addShortcutInvoked(QHotkey *hotkey);
|
||||||
|
Q_INVOKABLE bool removeShortcutInvoked(QHotkey *hotkey);
|
||||||
|
Q_INVOKABLE QHotkey::NativeShortcut nativeShortcutInvoked(Qt::Key keycode, Qt::KeyboardModifiers modifiers);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NATIVE_INSTANCE(ClassName) \
|
||||||
|
Q_GLOBAL_STATIC(ClassName, hotkeyPrivate) \
|
||||||
|
\
|
||||||
|
QHotkeyPrivate *QHotkeyPrivate::instance()\
|
||||||
|
{\
|
||||||
|
return hotkeyPrivate;\
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QHOTKEY_P_H
|
309
src/qhotkey/qhotkey_win.cpp
Normal file
309
src/qhotkey/qhotkey_win.cpp
Normal file
@ -0,0 +1,309 @@
|
|||||||
|
#include "qhotkey.h"
|
||||||
|
#include "qhotkey_p.h"
|
||||||
|
#include <qt_windows.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QList>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#define HKEY_ID(nativeShortcut) (((nativeShortcut.key ^ (nativeShortcut.modifier << 8)) & 0x0FFF) | 0x7000)
|
||||||
|
|
||||||
|
#if !defined(MOD_NOREPEAT)
|
||||||
|
#define MOD_NOREPEAT 0x4000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class QHotkeyPrivateWin : public QHotkeyPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QHotkeyPrivateWin();
|
||||||
|
// QAbstractNativeEventFilter interface
|
||||||
|
bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void pollForHotkeyRelease();
|
||||||
|
// QHotkeyPrivate interface
|
||||||
|
quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
|
||||||
|
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
|
||||||
|
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||||
|
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QString formatWinError(DWORD winError);
|
||||||
|
QTimer pollTimer;
|
||||||
|
QList<QHotkey::NativeShortcut> polledShortcuts;
|
||||||
|
};
|
||||||
|
NATIVE_INSTANCE(QHotkeyPrivateWin)
|
||||||
|
|
||||||
|
QHotkeyPrivateWin::QHotkeyPrivateWin(){
|
||||||
|
pollTimer.setInterval(50);
|
||||||
|
connect(&pollTimer, &QTimer::timeout, this, &QHotkeyPrivateWin::pollForHotkeyRelease);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::isPlatformSupported()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateWin::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result)
|
||||||
|
{
|
||||||
|
Q_UNUSED(eventType)
|
||||||
|
Q_UNUSED(result)
|
||||||
|
|
||||||
|
MSG* msg = static_cast<MSG*>(message);
|
||||||
|
if(msg->message == WM_HOTKEY) {
|
||||||
|
QHotkey::NativeShortcut shortcut = {HIWORD(msg->lParam), LOWORD(msg->lParam)};
|
||||||
|
this->activateShortcut(shortcut);
|
||||||
|
if (this->polledShortcuts.empty())
|
||||||
|
this->pollTimer.start();
|
||||||
|
this->polledShortcuts.append(shortcut);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QHotkeyPrivateWin::pollForHotkeyRelease()
|
||||||
|
{
|
||||||
|
auto it = std::remove_if(this->polledShortcuts.begin(), this->polledShortcuts.end(), [this](const QHotkey::NativeShortcut &shortcut) {
|
||||||
|
bool pressed = (GetAsyncKeyState(shortcut.key) & (1 << 15)) != 0;
|
||||||
|
if (!pressed)
|
||||||
|
this->releaseShortcut(shortcut);
|
||||||
|
return !pressed;
|
||||||
|
});
|
||||||
|
this->polledShortcuts.erase(it, this->polledShortcuts.end());
|
||||||
|
if (this->polledShortcuts.empty())
|
||||||
|
this->pollTimer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QHotkeyPrivateWin::nativeKeycode(Qt::Key keycode, bool &ok)
|
||||||
|
{
|
||||||
|
ok = true;
|
||||||
|
if(keycode <= 0xFFFF) {//Try to obtain the key from it's "character"
|
||||||
|
const SHORT vKey = VkKeyScanW(static_cast<WCHAR>(keycode));
|
||||||
|
if(vKey > -1)
|
||||||
|
return LOBYTE(vKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
//find key from switch/case --> Only finds a very small subset of keys
|
||||||
|
switch (keycode)
|
||||||
|
{
|
||||||
|
case Qt::Key_Escape:
|
||||||
|
return VK_ESCAPE;
|
||||||
|
case Qt::Key_Tab:
|
||||||
|
case Qt::Key_Backtab:
|
||||||
|
return VK_TAB;
|
||||||
|
case Qt::Key_Backspace:
|
||||||
|
return VK_BACK;
|
||||||
|
case Qt::Key_Return:
|
||||||
|
case Qt::Key_Enter:
|
||||||
|
return VK_RETURN;
|
||||||
|
case Qt::Key_Insert:
|
||||||
|
return VK_INSERT;
|
||||||
|
case Qt::Key_Delete:
|
||||||
|
return VK_DELETE;
|
||||||
|
case Qt::Key_Pause:
|
||||||
|
return VK_PAUSE;
|
||||||
|
case Qt::Key_Print:
|
||||||
|
return VK_PRINT;
|
||||||
|
case Qt::Key_Clear:
|
||||||
|
return VK_CLEAR;
|
||||||
|
case Qt::Key_Home:
|
||||||
|
return VK_HOME;
|
||||||
|
case Qt::Key_End:
|
||||||
|
return VK_END;
|
||||||
|
case Qt::Key_Left:
|
||||||
|
return VK_LEFT;
|
||||||
|
case Qt::Key_Up:
|
||||||
|
return VK_UP;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
return VK_RIGHT;
|
||||||
|
case Qt::Key_Down:
|
||||||
|
return VK_DOWN;
|
||||||
|
case Qt::Key_PageUp:
|
||||||
|
return VK_PRIOR;
|
||||||
|
case Qt::Key_PageDown:
|
||||||
|
return VK_NEXT;
|
||||||
|
case Qt::Key_CapsLock:
|
||||||
|
return VK_CAPITAL;
|
||||||
|
case Qt::Key_NumLock:
|
||||||
|
return VK_NUMLOCK;
|
||||||
|
case Qt::Key_ScrollLock:
|
||||||
|
return VK_SCROLL;
|
||||||
|
|
||||||
|
case Qt::Key_F1:
|
||||||
|
return VK_F1;
|
||||||
|
case Qt::Key_F2:
|
||||||
|
return VK_F2;
|
||||||
|
case Qt::Key_F3:
|
||||||
|
return VK_F3;
|
||||||
|
case Qt::Key_F4:
|
||||||
|
return VK_F4;
|
||||||
|
case Qt::Key_F5:
|
||||||
|
return VK_F5;
|
||||||
|
case Qt::Key_F6:
|
||||||
|
return VK_F6;
|
||||||
|
case Qt::Key_F7:
|
||||||
|
return VK_F7;
|
||||||
|
case Qt::Key_F8:
|
||||||
|
return VK_F8;
|
||||||
|
case Qt::Key_F9:
|
||||||
|
return VK_F9;
|
||||||
|
case Qt::Key_F10:
|
||||||
|
return VK_F10;
|
||||||
|
case Qt::Key_F11:
|
||||||
|
return VK_F11;
|
||||||
|
case Qt::Key_F12:
|
||||||
|
return VK_F12;
|
||||||
|
case Qt::Key_F13:
|
||||||
|
return VK_F13;
|
||||||
|
case Qt::Key_F14:
|
||||||
|
return VK_F14;
|
||||||
|
case Qt::Key_F15:
|
||||||
|
return VK_F15;
|
||||||
|
case Qt::Key_F16:
|
||||||
|
return VK_F16;
|
||||||
|
case Qt::Key_F17:
|
||||||
|
return VK_F17;
|
||||||
|
case Qt::Key_F18:
|
||||||
|
return VK_F18;
|
||||||
|
case Qt::Key_F19:
|
||||||
|
return VK_F19;
|
||||||
|
case Qt::Key_F20:
|
||||||
|
return VK_F20;
|
||||||
|
case Qt::Key_F21:
|
||||||
|
return VK_F21;
|
||||||
|
case Qt::Key_F22:
|
||||||
|
return VK_F22;
|
||||||
|
case Qt::Key_F23:
|
||||||
|
return VK_F23;
|
||||||
|
case Qt::Key_F24:
|
||||||
|
return VK_F24;
|
||||||
|
|
||||||
|
case Qt::Key_Menu:
|
||||||
|
return VK_APPS;
|
||||||
|
case Qt::Key_Help:
|
||||||
|
return VK_HELP;
|
||||||
|
case Qt::Key_MediaNext:
|
||||||
|
return VK_MEDIA_NEXT_TRACK;
|
||||||
|
case Qt::Key_MediaPrevious:
|
||||||
|
return VK_MEDIA_PREV_TRACK;
|
||||||
|
case Qt::Key_MediaPlay:
|
||||||
|
return VK_MEDIA_PLAY_PAUSE;
|
||||||
|
case Qt::Key_MediaStop:
|
||||||
|
return VK_MEDIA_STOP;
|
||||||
|
case Qt::Key_VolumeDown:
|
||||||
|
return VK_VOLUME_DOWN;
|
||||||
|
case Qt::Key_VolumeUp:
|
||||||
|
return VK_VOLUME_UP;
|
||||||
|
case Qt::Key_VolumeMute:
|
||||||
|
return VK_VOLUME_MUTE;
|
||||||
|
case Qt::Key_Mode_switch:
|
||||||
|
return VK_MODECHANGE;
|
||||||
|
case Qt::Key_Select:
|
||||||
|
return VK_SELECT;
|
||||||
|
case Qt::Key_Printer:
|
||||||
|
return VK_PRINT;
|
||||||
|
case Qt::Key_Execute:
|
||||||
|
return VK_EXECUTE;
|
||||||
|
case Qt::Key_Sleep:
|
||||||
|
return VK_SLEEP;
|
||||||
|
case Qt::Key_Period:
|
||||||
|
return VK_DECIMAL;
|
||||||
|
case Qt::Key_Play:
|
||||||
|
return VK_PLAY;
|
||||||
|
case Qt::Key_Cancel:
|
||||||
|
return VK_CANCEL;
|
||||||
|
|
||||||
|
case Qt::Key_Forward:
|
||||||
|
return VK_BROWSER_FORWARD;
|
||||||
|
case Qt::Key_Refresh:
|
||||||
|
return VK_BROWSER_REFRESH;
|
||||||
|
case Qt::Key_Stop:
|
||||||
|
return VK_BROWSER_STOP;
|
||||||
|
case Qt::Key_Search:
|
||||||
|
return VK_BROWSER_SEARCH;
|
||||||
|
case Qt::Key_Favorites:
|
||||||
|
return VK_BROWSER_FAVORITES;
|
||||||
|
case Qt::Key_HomePage:
|
||||||
|
return VK_BROWSER_HOME;
|
||||||
|
|
||||||
|
case Qt::Key_LaunchMail:
|
||||||
|
return VK_LAUNCH_MAIL;
|
||||||
|
case Qt::Key_LaunchMedia:
|
||||||
|
return VK_LAUNCH_MEDIA_SELECT;
|
||||||
|
case Qt::Key_Launch0:
|
||||||
|
return VK_LAUNCH_APP1;
|
||||||
|
case Qt::Key_Launch1:
|
||||||
|
return VK_LAUNCH_APP2;
|
||||||
|
|
||||||
|
case Qt::Key_Massyo:
|
||||||
|
return VK_OEM_FJ_MASSHOU;
|
||||||
|
case Qt::Key_Touroku:
|
||||||
|
return VK_OEM_FJ_TOUROKU;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if(keycode <= 0xFFFF)
|
||||||
|
return static_cast<BYTE>(keycode);
|
||||||
|
else {
|
||||||
|
ok = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QHotkeyPrivateWin::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
|
||||||
|
{
|
||||||
|
quint32 nMods = 0;
|
||||||
|
if (modifiers & Qt::ShiftModifier)
|
||||||
|
nMods |= MOD_SHIFT;
|
||||||
|
if (modifiers & Qt::ControlModifier)
|
||||||
|
nMods |= MOD_CONTROL;
|
||||||
|
if (modifiers & Qt::AltModifier)
|
||||||
|
nMods |= MOD_ALT;
|
||||||
|
if (modifiers & Qt::MetaModifier)
|
||||||
|
nMods |= MOD_WIN;
|
||||||
|
ok = true;
|
||||||
|
return nMods;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateWin::registerShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
BOOL ok = RegisterHotKey(NULL,
|
||||||
|
HKEY_ID(shortcut),
|
||||||
|
shortcut.modifier + MOD_NOREPEAT,
|
||||||
|
shortcut.key);
|
||||||
|
if(ok)
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
error = QHotkeyPrivateWin::formatWinError(::GetLastError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateWin::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
BOOL ok = UnregisterHotKey(NULL, HKEY_ID(shortcut));
|
||||||
|
if(ok)
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
error = QHotkeyPrivateWin::formatWinError(::GetLastError());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QHotkeyPrivateWin::formatWinError(DWORD winError)
|
||||||
|
{
|
||||||
|
wchar_t *buffer = NULL;
|
||||||
|
DWORD num = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
|
NULL,
|
||||||
|
winError,
|
||||||
|
0,
|
||||||
|
(LPWSTR)&buffer,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if(buffer) {
|
||||||
|
QString res = QString::fromWCharArray(buffer, num);
|
||||||
|
LocalFree(buffer);
|
||||||
|
return res;
|
||||||
|
} else
|
||||||
|
return QString();
|
||||||
|
}
|
268
src/qhotkey/qhotkey_x11.cpp
Normal file
268
src/qhotkey/qhotkey_x11.cpp
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
#include "qhotkey.h"
|
||||||
|
#include "qhotkey_p.h"
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#else
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QX11Info>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QThreadStorage>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
//compatibility to pre Qt 5.8
|
||||||
|
#ifndef Q_FALLTHROUGH
|
||||||
|
#define Q_FALLTHROUGH() (void)0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class QHotkeyPrivateX11 : public QHotkeyPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// QAbstractNativeEventFilter interface
|
||||||
|
bool nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// QHotkeyPrivate interface
|
||||||
|
quint32 nativeKeycode(Qt::Key keycode, bool &ok) Q_DECL_OVERRIDE;
|
||||||
|
quint32 nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok) Q_DECL_OVERRIDE;
|
||||||
|
static QString getX11String(Qt::Key keycode);
|
||||||
|
bool registerShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||||
|
bool unregisterShortcut(QHotkey::NativeShortcut shortcut) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const QVector<quint32> specialModifiers;
|
||||||
|
static const quint32 validModsMask;
|
||||||
|
xcb_key_press_event_t prevHandledEvent;
|
||||||
|
xcb_key_press_event_t prevEvent;
|
||||||
|
|
||||||
|
static QString formatX11Error(Display *display, int errorCode);
|
||||||
|
|
||||||
|
class HotkeyErrorHandler {
|
||||||
|
public:
|
||||||
|
HotkeyErrorHandler();
|
||||||
|
~HotkeyErrorHandler();
|
||||||
|
|
||||||
|
static bool hasError;
|
||||||
|
static QString errorString;
|
||||||
|
|
||||||
|
private:
|
||||||
|
XErrorHandler prevHandler;
|
||||||
|
|
||||||
|
static int handleError(Display *display, XErrorEvent *error);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
NATIVE_INSTANCE(QHotkeyPrivateX11)
|
||||||
|
|
||||||
|
bool QHotkeyPrivate::isPlatformSupported()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
return qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
|
#else
|
||||||
|
return QX11Info::isPlatformX11();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<quint32> QHotkeyPrivateX11::specialModifiers = {0, Mod2Mask, LockMask, (Mod2Mask | LockMask)};
|
||||||
|
const quint32 QHotkeyPrivateX11::validModsMask = ShiftMask | ControlMask | Mod1Mask | Mod4Mask;
|
||||||
|
|
||||||
|
bool QHotkeyPrivateX11::nativeEventFilter(const QByteArray &eventType, void *message, _NATIVE_EVENT_RESULT *result)
|
||||||
|
{
|
||||||
|
Q_UNUSED(eventType)
|
||||||
|
Q_UNUSED(result)
|
||||||
|
|
||||||
|
auto *genericEvent = static_cast<xcb_generic_event_t *>(message);
|
||||||
|
if (genericEvent->response_type == XCB_KEY_PRESS) {
|
||||||
|
xcb_key_press_event_t keyEvent = *static_cast<xcb_key_press_event_t *>(message);
|
||||||
|
this->prevEvent = keyEvent;
|
||||||
|
if (this->prevHandledEvent.response_type == XCB_KEY_RELEASE) {
|
||||||
|
if(this->prevHandledEvent.time == keyEvent.time) return false;
|
||||||
|
}
|
||||||
|
this->activateShortcut({keyEvent.detail, keyEvent.state & QHotkeyPrivateX11::validModsMask});
|
||||||
|
} else if (genericEvent->response_type == XCB_KEY_RELEASE) {
|
||||||
|
xcb_key_release_event_t keyEvent = *static_cast<xcb_key_release_event_t *>(message);
|
||||||
|
this->prevEvent = keyEvent;
|
||||||
|
QTimer::singleShot(50, [this, keyEvent] {
|
||||||
|
if(this->prevEvent.time == keyEvent.time && this->prevEvent.response_type == keyEvent.response_type && this->prevEvent.detail == keyEvent.detail){
|
||||||
|
this->releaseShortcut({keyEvent.detail, keyEvent.state & QHotkeyPrivateX11::validModsMask});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this->prevHandledEvent = keyEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QHotkeyPrivateX11::getX11String(Qt::Key keycode)
|
||||||
|
{
|
||||||
|
switch(keycode){
|
||||||
|
|
||||||
|
case Qt::Key_MediaLast :
|
||||||
|
case Qt::Key_MediaPrevious :
|
||||||
|
return QStringLiteral("XF86AudioPrev");
|
||||||
|
case Qt::Key_MediaNext :
|
||||||
|
return QStringLiteral("XF86AudioNext");
|
||||||
|
case Qt::Key_MediaPause :
|
||||||
|
case Qt::Key_MediaPlay :
|
||||||
|
case Qt::Key_MediaTogglePlayPause :
|
||||||
|
return QStringLiteral("XF86AudioPlay");
|
||||||
|
case Qt::Key_MediaRecord :
|
||||||
|
return QStringLiteral("XF86AudioRecord");
|
||||||
|
case Qt::Key_MediaStop :
|
||||||
|
return QStringLiteral("XF86AudioStop");
|
||||||
|
default :
|
||||||
|
return QKeySequence(keycode).toString(QKeySequence::NativeText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QHotkeyPrivateX11::nativeKeycode(Qt::Key keycode, bool &ok)
|
||||||
|
{
|
||||||
|
QString keyString = getX11String(keycode);
|
||||||
|
|
||||||
|
KeySym keysym = XStringToKeysym(keyString.toLatin1().constData());
|
||||||
|
if (keysym == NoSymbol) {
|
||||||
|
//not found -> just use the key
|
||||||
|
if(keycode <= 0xFFFF)
|
||||||
|
keysym = keycode;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
const QNativeInterface::QX11Application *x11Interface = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
|
Display *display = x11Interface->display();
|
||||||
|
#else
|
||||||
|
const bool x11Interface = QX11Info::isPlatformX11();
|
||||||
|
Display *display = QX11Info::display();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(x11Interface) {
|
||||||
|
auto res = XKeysymToKeycode(display, keysym);
|
||||||
|
if(res != 0)
|
||||||
|
ok = true;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 QHotkeyPrivateX11::nativeModifiers(Qt::KeyboardModifiers modifiers, bool &ok)
|
||||||
|
{
|
||||||
|
quint32 nMods = 0;
|
||||||
|
if (modifiers & Qt::ShiftModifier)
|
||||||
|
nMods |= ShiftMask;
|
||||||
|
if (modifiers & Qt::ControlModifier)
|
||||||
|
nMods |= ControlMask;
|
||||||
|
if (modifiers & Qt::AltModifier)
|
||||||
|
nMods |= Mod1Mask;
|
||||||
|
if (modifiers & Qt::MetaModifier)
|
||||||
|
nMods |= Mod4Mask;
|
||||||
|
ok = true;
|
||||||
|
return nMods;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
const QNativeInterface::QX11Application *x11Interface = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
|
||||||
|
Display *display = x11Interface->display();
|
||||||
|
#else
|
||||||
|
const bool x11Interface = QX11Info::isPlatformX11();
|
||||||
|
Display *display = QX11Info::display();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!display || !x11Interface)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
HotkeyErrorHandler errorHandler;
|
||||||
|
for(quint32 specialMod : QHotkeyPrivateX11::specialModifiers) {
|
||||||
|
XGrabKey(display,
|
||||||
|
shortcut.key,
|
||||||
|
shortcut.modifier | specialMod,
|
||||||
|
DefaultRootWindow(display),
|
||||||
|
True,
|
||||||
|
GrabModeAsync,
|
||||||
|
GrabModeAsync);
|
||||||
|
}
|
||||||
|
XSync(display, False);
|
||||||
|
|
||||||
|
if(errorHandler.hasError) {
|
||||||
|
error = errorHandler.errorString;
|
||||||
|
this->unregisterShortcut(shortcut);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
Display *display = qGuiApp->nativeInterface<QNativeInterface::QX11Application>()->display();
|
||||||
|
#else
|
||||||
|
Display *display = QX11Info::display();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!display)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
HotkeyErrorHandler errorHandler;
|
||||||
|
for(quint32 specialMod : QHotkeyPrivateX11::specialModifiers) {
|
||||||
|
XUngrabKey(display,
|
||||||
|
shortcut.key,
|
||||||
|
shortcut.modifier | specialMod,
|
||||||
|
XDefaultRootWindow(display));
|
||||||
|
}
|
||||||
|
XSync(display, False);
|
||||||
|
|
||||||
|
if(HotkeyErrorHandler::hasError) {
|
||||||
|
error = HotkeyErrorHandler::errorString;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QHotkeyPrivateX11::formatX11Error(Display *display, int errorCode)
|
||||||
|
{
|
||||||
|
char errStr[256];
|
||||||
|
XGetErrorText(display, errorCode, errStr, 256);
|
||||||
|
return QString::fromLatin1(errStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ---------- QHotkeyPrivateX11::HotkeyErrorHandler implementation ----------
|
||||||
|
|
||||||
|
bool QHotkeyPrivateX11::HotkeyErrorHandler::hasError = false;
|
||||||
|
QString QHotkeyPrivateX11::HotkeyErrorHandler::errorString;
|
||||||
|
|
||||||
|
QHotkeyPrivateX11::HotkeyErrorHandler::HotkeyErrorHandler()
|
||||||
|
{
|
||||||
|
prevHandler = XSetErrorHandler(&HotkeyErrorHandler::handleError);
|
||||||
|
}
|
||||||
|
|
||||||
|
QHotkeyPrivateX11::HotkeyErrorHandler::~HotkeyErrorHandler()
|
||||||
|
{
|
||||||
|
XSetErrorHandler(prevHandler);
|
||||||
|
hasError = false;
|
||||||
|
errorString.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int QHotkeyPrivateX11::HotkeyErrorHandler::handleError(Display *display, XErrorEvent *error)
|
||||||
|
{
|
||||||
|
switch (error->error_code) {
|
||||||
|
case BadAccess:
|
||||||
|
case BadValue:
|
||||||
|
case BadWindow:
|
||||||
|
if (error->request_code == 33 || //grab key
|
||||||
|
error->request_code == 34) {// ungrab key
|
||||||
|
hasError = true;
|
||||||
|
errorString = QHotkeyPrivateX11::formatX11Error(display, error->error_code);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Q_FALLTHROUGH();
|
||||||
|
// fall through
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user