mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-23 03:10:10 +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_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}")
|
||||
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)
|
||||
target_link_libraries(example PRIVATE
|
||||
Qt6::Quick
|
||||
Qt6::Svg
|
||||
Qt6::Network
|
||||
Qt::Quick
|
||||
Qt::Svg
|
||||
Qt::Network
|
||||
fluentui
|
||||
fluentuiplugin
|
||||
FramelessHelper::Core
|
||||
@ -138,9 +138,9 @@ if (FLUENTUI_BUILD_STATIC_LIB)
|
||||
)
|
||||
else()
|
||||
target_link_libraries(example PRIVATE
|
||||
Qt6::Quick
|
||||
Qt6::Svg
|
||||
Qt6::Network
|
||||
Qt::Quick
|
||||
Qt::Svg
|
||||
Qt::Network
|
||||
fluentuiplugin
|
||||
FramelessHelper::Core
|
||||
FramelessHelper::Quick
|
||||
|
@ -164,28 +164,62 @@ FluScrollablePage{
|
||||
|
||||
FluArea{
|
||||
Layout.fillWidth: true
|
||||
height: 68
|
||||
height: layout_icon_button.height + 30
|
||||
paddings: 10
|
||||
Layout.topMargin: 20
|
||||
Row{
|
||||
spacing: 20
|
||||
Flow{
|
||||
id:layout_icon_button
|
||||
spacing: 10
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
right: icon_button_switch.left
|
||||
}
|
||||
FluIconButton{
|
||||
iconSource:FluentIcons.ChromeCloseContrast
|
||||
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:{
|
||||
showSuccess("点击IconButton")
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
iconSource:FluentIcons.ChromeCloseContrast
|
||||
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:{
|
||||
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)
|
||||
endif()
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
|
||||
|
||||
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
|
||||
qt_standard_project_setup()
|
||||
else()
|
||||
|
@ -321,41 +321,53 @@ void FluHttp::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>&
|
||||
}
|
||||
|
||||
void FluHttp::onStart(const QJSValue& callable){
|
||||
QJSValue onStart = callable.property("onStart");
|
||||
MainThread::post([=](){onStart.call();});
|
||||
MainThread::post([=](){
|
||||
QJSValue onStart = callable.property("onStart");
|
||||
onStart.call();
|
||||
});
|
||||
}
|
||||
|
||||
void FluHttp::onFinish(const QJSValue& callable){
|
||||
QJSValue onFinish = callable.property("onFinish");
|
||||
MainThread::post([=](){onFinish.call();});
|
||||
MainThread::post([=](){
|
||||
QJSValue onFinish = callable.property("onFinish");
|
||||
onFinish.call();
|
||||
});
|
||||
}
|
||||
|
||||
void FluHttp::onError(const QJSValue& callable,int status,QString errorString,QString result){
|
||||
QJSValue onError = callable.property("onError");
|
||||
QJSValueList args;
|
||||
args<<status<<errorString<<result;
|
||||
MainThread::post([=](){onError.call(args);});
|
||||
MainThread::post([=](){
|
||||
QJSValue onError = callable.property("onError");
|
||||
QJSValueList args;
|
||||
args<<status<<errorString<<result;
|
||||
onError.call(args);
|
||||
});
|
||||
}
|
||||
|
||||
void FluHttp::onSuccess(const QJSValue& callable,QString result){
|
||||
QJSValueList args;
|
||||
args<<result;
|
||||
QJSValue onSuccess = callable.property("onSuccess");
|
||||
MainThread::post([=](){onSuccess.call(args);});
|
||||
MainThread::post([=](){
|
||||
QJSValueList args;
|
||||
args<<result;
|
||||
QJSValue onSuccess = callable.property("onSuccess");
|
||||
onSuccess.call(args);
|
||||
});
|
||||
}
|
||||
|
||||
void FluHttp::onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total){
|
||||
QJSValueList args;
|
||||
args<<static_cast<double>(recv);
|
||||
args<<static_cast<double>(total);
|
||||
QJSValue onDownloadProgress = callable.property("onDownloadProgress");
|
||||
MainThread::post([=](){onDownloadProgress.call(args);});
|
||||
MainThread::post([=](){
|
||||
QJSValueList args;
|
||||
args<<static_cast<double>(recv);
|
||||
args<<static_cast<double>(total);
|
||||
QJSValue onDownloadProgress = callable.property("onDownloadProgress");
|
||||
onDownloadProgress.call(args);
|
||||
});
|
||||
}
|
||||
|
||||
void FluHttp::onUploadProgress(const QJSValue& callable,qint64 sent, qint64 total){
|
||||
QJSValueList args;
|
||||
args<<static_cast<double>(sent);
|
||||
args<<static_cast<double>(total);
|
||||
QJSValue onUploadProgress = callable.property("onUploadProgress");
|
||||
MainThread::post([=](){onUploadProgress.call(args);});
|
||||
MainThread::post([=](){
|
||||
QJSValueList args;
|
||||
args<<static_cast<double>(sent);
|
||||
args<<static_cast<double>(total);
|
||||
QJSValue onUploadProgress = callable.property("onUploadProgress");
|
||||
onUploadProgress.call(args);
|
||||
});
|
||||
}
|
||||
|
@ -3,10 +3,12 @@
|
||||
#include <QScreen>
|
||||
#include <QQuickWindow>
|
||||
#include <QDir>
|
||||
#include <Def.h>
|
||||
#include <QtMath>
|
||||
#include <QDateTime>
|
||||
#include <QThreadPool>
|
||||
|
||||
#include "Def.h"
|
||||
|
||||
Screenshot::Screenshot(QQuickItem* parent) : QQuickPaintedItem(parent)
|
||||
{
|
||||
_desktopGeometry = qApp->primaryScreen()->virtualGeometry();
|
||||
|
@ -1,9 +1,11 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
|
||||
Button {
|
||||
display: Button.IconOnly
|
||||
property int iconSize: 20
|
||||
property int iconSource
|
||||
property bool disabled: false
|
||||
@ -41,14 +43,14 @@ Button {
|
||||
Accessible.description: contentDescription
|
||||
Accessible.onPressAction: control.clicked()
|
||||
id:control
|
||||
width: 30
|
||||
focusPolicy:Qt.TabFocus
|
||||
height: 30
|
||||
implicitWidth: width
|
||||
implicitHeight: height
|
||||
padding: 0
|
||||
verticalPadding: 8
|
||||
horizontalPadding: 8
|
||||
enabled: !disabled
|
||||
background: Rectangle{
|
||||
implicitWidth: 30
|
||||
implicitHeight: 30
|
||||
radius: control.radius
|
||||
color:control.color
|
||||
FluFocusRectangle{
|
||||
@ -67,21 +69,73 @@ Button {
|
||||
iconSource: control.iconSource
|
||||
}
|
||||
}
|
||||
contentItem: Item{
|
||||
Loader{
|
||||
anchors.centerIn: parent
|
||||
sourceComponent: iconDelegate
|
||||
}
|
||||
FluTooltip{
|
||||
id:tool_tip
|
||||
visible: {
|
||||
if(control.text === ""){
|
||||
return false
|
||||
}
|
||||
return hovered
|
||||
|
||||
Component{
|
||||
id:com_row
|
||||
RowLayout{
|
||||
Loader{
|
||||
sourceComponent: iconDelegate
|
||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||
visible: display !== Button.TextOnly
|
||||
}
|
||||
text:control.text
|
||||
delay: 1000
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
iconSource: FluentIcons.ChromeBack
|
||||
Layout.leftMargin: 5
|
||||
Layout.preferredWidth: 30
|
||||
Layout.preferredHeight: 30
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
disabled: {
|
||||
return d.stackItems.length <= 1
|
||||
|
Loading…
Reference in New Issue
Block a user