mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 11:17:15 +08:00
fix #255
This commit is contained in:
parent
050c2e595f
commit
73933842cf
@ -11,7 +11,7 @@ option(FLUENTUI_BUILD_EXAMPLES "Build FluentUI demo applications." ON)
|
|||||||
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
option(FLUENTUI_BUILD_FRAMELESSHEPLER "Build FramelessHelper." ON)
|
||||||
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
option(FLUENTUI_BUILD_STATIC_LIB "Build static library." OFF)
|
||||||
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
|
find_package(Qt6 REQUIRED COMPONENTS Core)
|
||||||
|
|
||||||
set(QT_SDK_DIR "${Qt6_DIR}")
|
set(QT_SDK_DIR "${Qt6_DIR}")
|
||||||
cmake_path(GET QT_SDK_DIR PARENT_PATH QT_SDK_DIR)
|
cmake_path(GET QT_SDK_DIR PARENT_PATH QT_SDK_DIR)
|
||||||
|
@ -128,9 +128,9 @@ set_target_properties(example PROPERTIES
|
|||||||
#链接库
|
#链接库
|
||||||
if (FLUENTUI_BUILD_STATIC_LIB)
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
target_link_libraries(example PRIVATE
|
target_link_libraries(example PRIVATE
|
||||||
Qt6::Quick
|
Qt::Quick
|
||||||
Qt6::Svg
|
Qt::Svg
|
||||||
Qt6::Network
|
Qt::Network
|
||||||
fluentui
|
fluentui
|
||||||
fluentuiplugin
|
fluentuiplugin
|
||||||
FramelessHelper::Core
|
FramelessHelper::Core
|
||||||
@ -138,9 +138,9 @@ if (FLUENTUI_BUILD_STATIC_LIB)
|
|||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(example PRIVATE
|
target_link_libraries(example PRIVATE
|
||||||
Qt6::Quick
|
Qt::Quick
|
||||||
Qt6::Svg
|
Qt::Svg
|
||||||
Qt6::Network
|
Qt::Network
|
||||||
fluentuiplugin
|
fluentuiplugin
|
||||||
FramelessHelper::Core
|
FramelessHelper::Core
|
||||||
FramelessHelper::Quick
|
FramelessHelper::Quick
|
||||||
|
@ -164,28 +164,62 @@ FluScrollablePage{
|
|||||||
|
|
||||||
FluArea{
|
FluArea{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: 68
|
height: layout_icon_button.height + 30
|
||||||
paddings: 10
|
paddings: 10
|
||||||
Layout.topMargin: 20
|
Layout.topMargin: 20
|
||||||
Row{
|
Flow{
|
||||||
spacing: 20
|
id:layout_icon_button
|
||||||
|
spacing: 10
|
||||||
anchors{
|
anchors{
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
right: icon_button_switch.left
|
||||||
}
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
iconSource:FluentIcons.ChromeCloseContrast
|
|
||||||
disabled:icon_button_switch.checked
|
disabled:icon_button_switch.checked
|
||||||
iconSize: 15
|
iconDelegate: Image{ sourceSize: Qt.size(40,40) ; width: 20; height: 20; source: "qrc:/example/res/image/ic_home_github.png" }
|
||||||
onClicked:{
|
onClicked:{
|
||||||
showSuccess("点击IconButton")
|
showSuccess("点击IconButton")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FluIconButton{
|
FluIconButton{
|
||||||
|
iconSource:FluentIcons.ChromeCloseContrast
|
||||||
disabled:icon_button_switch.checked
|
disabled:icon_button_switch.checked
|
||||||
iconDelegate: Image{ width: 20; height: 20; source: "qrc:/example/res/image/ic_home_github.png" }
|
iconSize: 15
|
||||||
|
text:"IconOnly"
|
||||||
|
display: Button.IconOnly
|
||||||
onClicked:{
|
onClicked:{
|
||||||
showSuccess("点击IconButton")
|
showSuccess("Button.IconOnly")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluIconButton{
|
||||||
|
iconSource:FluentIcons.ChromeCloseContrast
|
||||||
|
disabled:icon_button_switch.checked
|
||||||
|
iconSize: 15
|
||||||
|
text:"TextOnly"
|
||||||
|
display: Button.TextOnly
|
||||||
|
onClicked:{
|
||||||
|
showSuccess("Button.TextOnly")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluIconButton{
|
||||||
|
iconSource:FluentIcons.ChromeCloseContrast
|
||||||
|
disabled:icon_button_switch.checked
|
||||||
|
iconSize: 15
|
||||||
|
text:"TextBesideIcon"
|
||||||
|
display: Button.TextBesideIcon
|
||||||
|
onClicked:{
|
||||||
|
showSuccess("Button.TextBesideIcon")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FluIconButton{
|
||||||
|
iconSource:FluentIcons.ChromeCloseContrast
|
||||||
|
disabled:icon_button_switch.checked
|
||||||
|
iconSize: 15
|
||||||
|
text:"TextUnderIcon"
|
||||||
|
display: Button.TextUnderIcon
|
||||||
|
onClicked:{
|
||||||
|
showSuccess("Button.TextUnderIcon")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ if(APPLE)
|
|||||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
|
||||||
|
|
||||||
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
else()
|
else()
|
||||||
|
@ -321,41 +321,53 @@ void FluHttp::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FluHttp::onStart(const QJSValue& callable){
|
void FluHttp::onStart(const QJSValue& callable){
|
||||||
QJSValue onStart = callable.property("onStart");
|
MainThread::post([=](){
|
||||||
MainThread::post([=](){onStart.call();});
|
QJSValue onStart = callable.property("onStart");
|
||||||
|
onStart.call();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluHttp::onFinish(const QJSValue& callable){
|
void FluHttp::onFinish(const QJSValue& callable){
|
||||||
QJSValue onFinish = callable.property("onFinish");
|
MainThread::post([=](){
|
||||||
MainThread::post([=](){onFinish.call();});
|
QJSValue onFinish = callable.property("onFinish");
|
||||||
|
onFinish.call();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluHttp::onError(const QJSValue& callable,int status,QString errorString,QString result){
|
void FluHttp::onError(const QJSValue& callable,int status,QString errorString,QString result){
|
||||||
QJSValue onError = callable.property("onError");
|
MainThread::post([=](){
|
||||||
QJSValueList args;
|
QJSValue onError = callable.property("onError");
|
||||||
args<<status<<errorString<<result;
|
QJSValueList args;
|
||||||
MainThread::post([=](){onError.call(args);});
|
args<<status<<errorString<<result;
|
||||||
|
onError.call(args);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluHttp::onSuccess(const QJSValue& callable,QString result){
|
void FluHttp::onSuccess(const QJSValue& callable,QString result){
|
||||||
QJSValueList args;
|
MainThread::post([=](){
|
||||||
args<<result;
|
QJSValueList args;
|
||||||
QJSValue onSuccess = callable.property("onSuccess");
|
args<<result;
|
||||||
MainThread::post([=](){onSuccess.call(args);});
|
QJSValue onSuccess = callable.property("onSuccess");
|
||||||
|
onSuccess.call(args);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluHttp::onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total){
|
void FluHttp::onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total){
|
||||||
QJSValueList args;
|
MainThread::post([=](){
|
||||||
args<<static_cast<double>(recv);
|
QJSValueList args;
|
||||||
args<<static_cast<double>(total);
|
args<<static_cast<double>(recv);
|
||||||
QJSValue onDownloadProgress = callable.property("onDownloadProgress");
|
args<<static_cast<double>(total);
|
||||||
MainThread::post([=](){onDownloadProgress.call(args);});
|
QJSValue onDownloadProgress = callable.property("onDownloadProgress");
|
||||||
|
onDownloadProgress.call(args);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void FluHttp::onUploadProgress(const QJSValue& callable,qint64 sent, qint64 total){
|
void FluHttp::onUploadProgress(const QJSValue& callable,qint64 sent, qint64 total){
|
||||||
QJSValueList args;
|
MainThread::post([=](){
|
||||||
args<<static_cast<double>(sent);
|
QJSValueList args;
|
||||||
args<<static_cast<double>(total);
|
args<<static_cast<double>(sent);
|
||||||
QJSValue onUploadProgress = callable.property("onUploadProgress");
|
args<<static_cast<double>(total);
|
||||||
MainThread::post([=](){onUploadProgress.call(args);});
|
QJSValue onUploadProgress = callable.property("onUploadProgress");
|
||||||
|
onUploadProgress.call(args);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <Def.h>
|
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
#include <QDateTime>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
|
|
||||||
|
#include "Def.h"
|
||||||
|
|
||||||
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||||
{
|
{
|
||||||
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
import QtQuick.Controls.Basic
|
import QtQuick.Controls.Basic
|
||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
display: Button.IconOnly
|
||||||
property int iconSize: 20
|
property int iconSize: 20
|
||||||
property int iconSource
|
property int iconSource
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
@ -41,14 +43,14 @@ Button {
|
|||||||
Accessible.description: contentDescription
|
Accessible.description: contentDescription
|
||||||
Accessible.onPressAction: control.clicked()
|
Accessible.onPressAction: control.clicked()
|
||||||
id:control
|
id:control
|
||||||
width: 30
|
|
||||||
focusPolicy:Qt.TabFocus
|
focusPolicy:Qt.TabFocus
|
||||||
height: 30
|
|
||||||
implicitWidth: width
|
|
||||||
implicitHeight: height
|
|
||||||
padding: 0
|
padding: 0
|
||||||
|
verticalPadding: 8
|
||||||
|
horizontalPadding: 8
|
||||||
enabled: !disabled
|
enabled: !disabled
|
||||||
background: Rectangle{
|
background: Rectangle{
|
||||||
|
implicitWidth: 30
|
||||||
|
implicitHeight: 30
|
||||||
radius: control.radius
|
radius: control.radius
|
||||||
color:control.color
|
color:control.color
|
||||||
FluFocusRectangle{
|
FluFocusRectangle{
|
||||||
@ -67,21 +69,73 @@ Button {
|
|||||||
iconSource: control.iconSource
|
iconSource: control.iconSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentItem: Item{
|
|
||||||
Loader{
|
Component{
|
||||||
anchors.centerIn: parent
|
id:com_row
|
||||||
sourceComponent: iconDelegate
|
RowLayout{
|
||||||
}
|
Loader{
|
||||||
FluTooltip{
|
sourceComponent: iconDelegate
|
||||||
id:tool_tip
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||||
visible: {
|
visible: display !== Button.TextOnly
|
||||||
if(control.text === ""){
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return hovered
|
|
||||||
}
|
}
|
||||||
text:control.text
|
FluText{
|
||||||
delay: 1000
|
text:control.text
|
||||||
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||||
|
visible: display !== Button.IconOnly
|
||||||
|
}
|
||||||
|
FluTooltip{
|
||||||
|
id:tool_tip
|
||||||
|
visible: {
|
||||||
|
if(control.text === ""){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if(control.display !== Button.IconOnly){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return hovered
|
||||||
|
}
|
||||||
|
text:control.text
|
||||||
|
delay: 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component{
|
||||||
|
id:com_column
|
||||||
|
ColumnLayout{
|
||||||
|
Loader{
|
||||||
|
sourceComponent: iconDelegate
|
||||||
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||||
|
visible: display !== Button.TextOnly
|
||||||
|
}
|
||||||
|
FluText{
|
||||||
|
text:control.text
|
||||||
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||||
|
visible: display !== Button.IconOnly
|
||||||
|
}
|
||||||
|
FluTooltip{
|
||||||
|
id:tool_tip
|
||||||
|
visible: {
|
||||||
|
if(control.text === ""){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if(control.display !== Button.IconOnly){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return hovered
|
||||||
|
}
|
||||||
|
text:control.text
|
||||||
|
delay: 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem:Loader{
|
||||||
|
sourceComponent: {
|
||||||
|
if(display === Button.TextUnderIcon){
|
||||||
|
return com_column
|
||||||
|
}
|
||||||
|
return com_row
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,8 +609,6 @@ Item {
|
|||||||
id:btn_back
|
id:btn_back
|
||||||
iconSource: FluentIcons.ChromeBack
|
iconSource: FluentIcons.ChromeBack
|
||||||
Layout.leftMargin: 5
|
Layout.leftMargin: 5
|
||||||
Layout.preferredWidth: 30
|
|
||||||
Layout.preferredHeight: 30
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
disabled: {
|
disabled: {
|
||||||
return d.stackItems.length <= 1
|
return d.stackItems.length <= 1
|
||||||
|
Loading…
Reference in New Issue
Block a user