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

View File

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

View File

@ -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{
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{
iconSource:FluentIcons.ChromeCloseContrast
disabled:icon_button_switch.checked
iconSize: 15
text:"IconOnly"
display: Button.IconOnly
onClicked:{
showSuccess("点击IconButton")
showSuccess("Button.IconOnly")
}
}
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:"TextOnly"
display: Button.TextOnly
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)
endif()
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml)
if(QT_VERSION VERSION_GREATER_EQUAL "6.3")
qt_standard_project_setup()
else()

View File

@ -321,41 +321,53 @@ void FluHttp::addHeaders(QNetworkRequest* request,const QMap<QString, QVariant>&
}
void FluHttp::onStart(const QJSValue& callable){
MainThread::post([=](){
QJSValue onStart = callable.property("onStart");
MainThread::post([=](){onStart.call();});
onStart.call();
});
}
void FluHttp::onFinish(const QJSValue& callable){
MainThread::post([=](){
QJSValue onFinish = callable.property("onFinish");
MainThread::post([=](){onFinish.call();});
onFinish.call();
});
}
void FluHttp::onError(const QJSValue& callable,int status,QString errorString,QString result){
MainThread::post([=](){
QJSValue onError = callable.property("onError");
QJSValueList args;
args<<status<<errorString<<result;
MainThread::post([=](){onError.call(args);});
onError.call(args);
});
}
void FluHttp::onSuccess(const QJSValue& callable,QString result){
MainThread::post([=](){
QJSValueList args;
args<<result;
QJSValue onSuccess = callable.property("onSuccess");
MainThread::post([=](){onSuccess.call(args);});
onSuccess.call(args);
});
}
void FluHttp::onDownloadProgress(const QJSValue& callable,qint64 recv, qint64 total){
MainThread::post([=](){
QJSValueList args;
args<<static_cast<double>(recv);
args<<static_cast<double>(total);
QJSValue onDownloadProgress = callable.property("onDownloadProgress");
MainThread::post([=](){onDownloadProgress.call(args);});
onDownloadProgress.call(args);
});
}
void FluHttp::onUploadProgress(const QJSValue& callable,qint64 sent, qint64 total){
MainThread::post([=](){
QJSValueList args;
args<<static_cast<double>(sent);
args<<static_cast<double>(total);
QJSValue onUploadProgress = callable.property("onUploadProgress");
MainThread::post([=](){onUploadProgress.call(args);});
onUploadProgress.call(args);
});
}

View File

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

View File

@ -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,10 +69,19 @@ Button {
iconSource: control.iconSource
}
}
contentItem: Item{
Component{
id:com_row
RowLayout{
Loader{
anchors.centerIn: parent
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
@ -78,6 +89,9 @@ Button {
if(control.text === ""){
return false
}
if(control.display !== Button.IconOnly){
return false
}
return hovered
}
text:control.text
@ -85,3 +99,43 @@ Button {
}
}
}
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
iconSource: FluentIcons.ChromeBack
Layout.leftMargin: 5
Layout.preferredWidth: 30
Layout.preferredHeight: 30
Layout.alignment: Qt.AlignVCenter
disabled: {
return d.stackItems.length <= 1