This commit is contained in:
zhuzichu 2023-08-22 18:19:40 +08:00
parent 050c2e595f
commit 73933842cf
8 changed files with 159 additions and 57 deletions

View File

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

View File

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

View File

@ -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{
disabled:icon_button_switch.checked
iconDelegate: Image{ sourceSize: Qt.size(40,40) ; width: 20; height: 20; source: "qrc:/example/res/image/ic_home_github.png" }
onClicked:{
showSuccess("点击IconButton")
}
} }
FluIconButton{ FluIconButton{
iconSource:FluentIcons.ChromeCloseContrast iconSource:FluentIcons.ChromeCloseContrast
disabled:icon_button_switch.checked disabled:icon_button_switch.checked
iconSize: 15 iconSize: 15
text:"IconOnly"
display: Button.IconOnly
onClicked:{ onClicked:{
showSuccess("点击IconButton") showSuccess("Button.IconOnly")
} }
} }
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:"TextOnly"
display: Button.TextOnly
onClicked:{ onClicked:{
showSuccess("点击IconButton") 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")
} }
} }
} }

View File

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

View File

@ -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){
MainThread::post([=](){
QJSValue onStart = callable.property("onStart"); QJSValue onStart = callable.property("onStart");
MainThread::post([=](){onStart.call();}); onStart.call();
});
} }
void FluHttp::onFinish(const QJSValue& callable){ void FluHttp::onFinish(const QJSValue& callable){
MainThread::post([=](){
QJSValue onFinish = callable.property("onFinish"); QJSValue onFinish = callable.property("onFinish");
MainThread::post([=](){onFinish.call();}); 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){
MainThread::post([=](){
QJSValue onError = callable.property("onError"); QJSValue onError = callable.property("onError");
QJSValueList args; QJSValueList args;
args<<status<<errorString<<result; args<<status<<errorString<<result;
MainThread::post([=](){onError.call(args);}); onError.call(args);
});
} }
void FluHttp::onSuccess(const QJSValue& callable,QString result){ void FluHttp::onSuccess(const QJSValue& callable,QString result){
MainThread::post([=](){
QJSValueList args; QJSValueList args;
args<<result; args<<result;
QJSValue onSuccess = callable.property("onSuccess"); QJSValue onSuccess = callable.property("onSuccess");
MainThread::post([=](){onSuccess.call(args);}); onSuccess.call(args);
});
} }
void FluHttp::onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total){ void FluHttp::onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total){
MainThread::post([=](){
QJSValueList args; QJSValueList args;
args<<static_cast<double>(recv); args<<static_cast<double>(recv);
args<<static_cast<double>(total); args<<static_cast<double>(total);
QJSValue onDownloadProgress = callable.property("onDownloadProgress"); QJSValue onDownloadProgress = callable.property("onDownloadProgress");
MainThread::post([=](){onDownloadProgress.call(args);}); onDownloadProgress.call(args);
});
} }
void FluHttp::onUploadProgress(const QJSValue& callable,qint64 sent, qint64 total){ void FluHttp::onUploadProgress(const QJSValue& callable,qint64 sent, qint64 total){
MainThread::post([=](){
QJSValueList args; QJSValueList args;
args<<static_cast<double>(sent); args<<static_cast<double>(sent);
args<<static_cast<double>(total); args<<static_cast<double>(total);
QJSValue onUploadProgress = callable.property("onUploadProgress"); QJSValue onUploadProgress = callable.property("onUploadProgress");
MainThread::post([=](){onUploadProgress.call(args);}); onUploadProgress.call(args);
});
} }

View File

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

View File

@ -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,10 +69,19 @@ Button {
iconSource: control.iconSource iconSource: control.iconSource
} }
} }
contentItem: Item{
Component{
id:com_row
RowLayout{
Loader{ Loader{
anchors.centerIn: parent
sourceComponent: iconDelegate 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{ FluTooltip{
id:tool_tip id:tool_tip
@ -78,10 +89,53 @@ Button {
if(control.text === ""){ if(control.text === ""){
return false return false
} }
if(control.display !== Button.IconOnly){
return false
}
return hovered return hovered
} }
text:control.text text:control.text
delay: 1000 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
}
}
} }

View File

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