Compare commits

...

7 Commits

Author SHA1 Message Date
朱子楚\zhuzi
f830d5a9bf Merge branch 'main' of https://github.com/zhuzichu520/FluentUI 2024-05-09 19:41:15 +08:00
zhuzichu
ed49e3f6af
Merge pull request #499 from gao-xiangyang/main
info提示语支持主动调用函数关闭,支持关闭所有info框的函数
2024-05-09 17:10:34 +05:30
gaoxiangyang
9aa6615189 FluRadioButtons 组件支持 disabled、manuallyDisabled选项
disabled: true // 禁用所有FluRadioButton子组件
        manuallyDisabled: true // 是否指定每个FluRadioButton上的disabled选项
2024-05-08 21:10:00 +08:00
gaoxiangyang
c36515f19c info提示语支持主动调用函数关闭,支持关闭所有info框的函数 2024-05-08 20:35:31 +08:00
朱子楚\zhuzi
5f6745b630 udpate 2024-04-28 13:03:20 +08:00
朱子楚\zhuzi
4f202831b8 Merge branch 'main' of https://github.com/zhuzichu520/FluentUI 2024-04-28 10:51:29 +08:00
朱子楚\zhuzi
29cee84edd update 2024-04-28 10:51:13 +08:00
13 changed files with 247 additions and 138 deletions

View File

@ -22,18 +22,37 @@ FluScrollablePage{
FluGroupBox {
title: qsTr("RadioButton Group")
Layout.fillWidth: true
Layout.preferredHeight: 150
Layout.topMargin: 20
FluRadioButtons {
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
spacing: 10
disabled: radio_button_switch.checked
FluRadioButton { text: qsTr("E-mail") }
FluRadioButton { text: qsTr("Calendar") }
FluRadioButton { text: qsTr("Contacts") }
}
FluToggleSwitch{
id: radio_button_switch
anchors{
right: parent.right
verticalCenter: parent.verticalCenter
}
text: qsTr("Disabled")
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: 4
code:'FluGroupBox {
code:`
FluGroupBox {
title: qsTr("CheckBox Group")
ColumnLayout {
spacing: 10
@ -42,7 +61,20 @@ FluScrollablePage{
FluCheckBox { text: qsTr("Calendar") }
FluCheckBox { text: qsTr("Contacts") }
}
}'
}
FluGroupBox {
title: qsTr("RadioButton Group")
FluRadioButtons {
spacing: 10
disabled: true // FluRadioButton
manuallyDisabled: true // FluRadioButtondisabled
FluRadioButton { text: qsTr("E-mail") }
FluRadioButton { text: qsTr("Calendar") }
FluRadioButton { text: qsTr("Contacts") }
}
}
`
}
}

View File

@ -9,9 +9,13 @@ FluScrollablePage{
title: qsTr("InfoBar")
property var info1
property var info2
property var info3
FluFrame{
Layout.fillWidth: true
Layout.preferredHeight: 270
Layout.preferredHeight: 350
padding: 10
ColumnLayout{
spacing: 14
@ -49,6 +53,51 @@ FluScrollablePage{
showInfo(qsTr("This is an InfoBar in the Info Style"),0,qsTr("Manual shutdown is supported"))
}
}
FluText{
wrapMode: Text.WrapAnywhere
width: parent.width
text: qsTr("Manually close the info message box")
}
Row{
spacing: 5
FluButton{
text: (info1 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info1")
onClicked: {
if(info1) {
info1.close()
return
}
info1 = showInfo(qsTr("This is an '%1'").arg("info1"), 0)
}
}
FluButton{
text: (info2 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info2")
onClicked: {
if(info2) {
info2.close()
return
}
info2 = showInfo(qsTr("This is an '%1'").arg("info2"), 0)
}
}
FluButton{
text: (info3 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info3")
onClicked: {
if(info3) {
info3.close()
return
}
info3 = showInfo(qsTr("This is an '%1'").arg("info3"), 0)
}
}
FluButton{
text: qsTr("clear all info")
onClicked: {
clearAllInfo()
}
}
}
FluButton{
text:"Loading"
onClicked: {
@ -60,12 +109,17 @@ FluScrollablePage{
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -6
code:'showInfo(qsTr("This is an InfoBar in the Info Style"))
code:`
showInfo(qsTr("This is an InfoBar in the Info Style"))
showWarning(qsTr("This is an InfoBar in the Warning Style"))
showError(qsTr("This is an InfoBar in the Error Style"))
showSuccess(qsTr("This is an InfoBar in the Success Style"))'
showSuccess(qsTr("This is an InfoBar in the Success Style"))
var info1 = showInfo(qsTr("This is an 'Info1'"), 0)
info1.close()
`
}
}

View File

@ -73,12 +73,7 @@ void FluFrameless::componentComplete() {
int w = window()->width();
int h = window()->height();
_current = window()->winId();
window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (QQuickWindow::sceneGraphBackend() == "software") {
window()->setFlag(Qt::FramelessWindowHint, false);
}
#endif
window()->setFlags((window()->flags()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
if (!_fixSize) {
window()->setFlag(Qt::WindowMaximizeButtonHint);
}
@ -97,14 +92,14 @@ void FluFrameless::componentComplete() {
HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if (_fixSize) {
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_CAPTION);
for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) {
connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] {
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
});
}
} else {
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_CAPTION);
}
SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
connect(window(), &QQuickWindow::screenChanged, this, [hwnd] {
@ -151,29 +146,22 @@ void FluFrameless::componentComplete() {
return false;
} else if (uMsg == WM_NCCALCSIZE) {
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
bool isMaximum = ::IsZoomed(hwnd);
if (!isMaximum){
if (clientRect->top != 0)
{
clientRect->top -= 1;
clientRect->bottom -= 1;
}
} else{
const LONG originalTop = clientRect->top;
const LONG originalLeft = clientRect->left;
const LONG originalRight = clientRect->right;
const LONG originalBottom = clientRect->bottom;
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
return true;
}
int offsetSize;
bool isMaximum = ::IsZoomed(hwnd);
if (isMaximum || _isFullScreen()) {
offsetSize = 0;
} else {
offsetSize = 1;
clientRect->top = originalTop-originalTop;
}
if (!isCompositionEnabled()) {
offsetSize = 0;
}
clientRect->top = originalTop + offsetSize;
clientRect->bottom = originalBottom - offsetSize;
clientRect->left = originalLeft + offsetSize;
clientRect->right = originalRight - offsetSize;
_setMaximizeHovered(false);
*result = WVR_REDRAW;
return true;
@ -230,6 +218,18 @@ void FluFrameless::componentComplete() {
}
*result = HTCLIENT;
return true;
} else if (uMsg == WM_NCPAINT) {
if(isCompositionEnabled()){
return false;
}
*result = FALSE;
return true;
} else if (uMsg == WM_NCACTIVATE) {
if(isCompositionEnabled()){
return false;
}
*result = TRUE;
return true;
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
if (_hitMaximizeButton()) {
QMouseEvent event = QMouseEvent(QEvent::MouseButtonPress, QPoint(), QPoint(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
@ -244,23 +244,8 @@ void FluFrameless::componentComplete() {
_setMaximizePressed(false);
return true;
}
} else if (uMsg == WM_NCPAINT) {
*result = FALSE;
} else if (uMsg == WM_ERASEBKGND) {
return true;
} else if (uMsg == WM_NCACTIVATE) {
*result = static_cast<QT_NATIVE_EVENT_RESULT_TYPE>(::DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1));
return true;
} else if (uMsg == WM_GETMINMAXINFO) {
auto *minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
auto pixelRatio = window()->devicePixelRatio();
auto geometry = window()->screen()->availableGeometry();
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
minmaxInfo->ptMaxPosition.x = rect.left;
minmaxInfo->ptMaxPosition.y = rect.top;
minmaxInfo->ptMaxSize.x = qRound(geometry.width() * pixelRatio);
minmaxInfo->ptMaxSize.y = qRound(geometry.height() * pixelRatio);
return false;
} else if (uMsg == WM_NCRBUTTONDOWN) {
if (wParam == HTCAPTION) {
_showSystemMenu(QCursor::pos());

View File

@ -18,12 +18,13 @@ FluObject {
if(screenLayout){
var last = screenLayout.getLastloader();
if(last.type === type && last.text === text && moremsg === last.moremsg){
last.restart();
return;
last.duration = duration
if (duration > 0) last.restart();
return last;
}
}
initScreenLayout();
contentComponent.createObject(screenLayout,{
return contentComponent.createObject(screenLayout,{
type:type,
text:text,
duration:duration,
@ -33,7 +34,7 @@ FluObject {
function createCustom(itemcomponent,duration){
initScreenLayout();
if(itemcomponent){
contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
}
}
function initScreenLayout(){
@ -85,7 +86,9 @@ FluObject {
}
Timer {
id:delayTimer
interval: duration; running: duration > 0; repeat: duration > 0
interval: duration;
running: duration > 0;
repeat: duration > 0
onTriggered: content.close();
}
FluLoader{
@ -235,18 +238,26 @@ FluObject {
}
}
function showSuccess(text,duration=1000,moremsg){
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){
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){
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){
mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
}
function showCustom(itemcomponent,duration=1000){
mcontrol.createCustom(itemcomponent,duration);
return mcontrol.createCustom(itemcomponent,duration);
}
function clearAllInfo(){
if(mcontrol.screenLayout != null) {
mcontrol.screenLayout.destroy()
mcontrol.screenLayout = null
}
return true
}
}

View File

@ -48,9 +48,6 @@ T.MenuBarItem {
radius: 3
color: {
if(control.highlighted){
return FluTheme.itemCheckColor
}
if(control.hovered){
return FluTheme.itemHoverColor
}
return FluTheme.itemNormalColor

View File

@ -99,9 +99,9 @@ T.MenuItem {
anchors.fill: parent
anchors.margins: 3
radius: 4
color:{
color: {
if(control.highlighted){
return FluTheme.itemCheckColor
return FluTheme.itemHoverColor
}
return FluTheme.itemNormalColor
}

View File

@ -6,6 +6,8 @@ import FluentUI 1.0
ColumnLayout {
default property alias buttons: control.data
property int currentIndex : -1
property bool disabled: false
property bool manuallyDisabled: false
id:control
onCurrentIndexChanged: {
for(var i = 0;i<buttons.length;i++){
@ -16,6 +18,12 @@ ColumnLayout {
button.checked = true
}
}
onDisabledChanged: {
refreshButtonStatus()
}
onManuallyDisabledChanged: {
refreshButtonStatus()
}
Component.onCompleted: {
for(var i = 0;i<buttons.length;i++){
buttons[i].clickListener = function(){
@ -27,6 +35,12 @@ ColumnLayout {
}
}
}
currentIndex = 0
refreshButtonStatus()
}
function refreshButtonStatus() {
for(var i = 0;i<buttons.length;i++){
if(!manuallyDisabled) buttons[i].enabled = !disabled
}
}
}

View File

@ -279,13 +279,7 @@ Window {
id:loader_border
anchors.fill: parent
sourceComponent: {
if(window.useSystemAppBar){
return undefined
}
if(FluTools.isWindows10OrGreater()){
return undefined
}
if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined
}
return com_border
@ -295,16 +289,19 @@ Window {
loader_loading.sourceComponent = undefined
}
function showSuccess(text,duration,moremsg){
info_bar.showSuccess(text,duration,moremsg)
return info_bar.showSuccess(text,duration,moremsg)
}
function showInfo(text,duration,moremsg){
info_bar.showInfo(text,duration,moremsg)
return info_bar.showInfo(text,duration,moremsg)
}
function showWarning(text,duration,moremsg){
info_bar.showWarning(text,duration,moremsg)
return info_bar.showWarning(text,duration,moremsg)
}
function showError(text,duration,moremsg){
info_bar.showError(text,duration,moremsg)
return info_bar.showError(text,duration,moremsg)
}
function clearAllInfo(){
return info_bar.clearAllInfo()
}
function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()]

View File

@ -1,6 +1,6 @@
import QtQuick
import QtQuick.Controls
import FluentUI
import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
FluObject {
property var root;
@ -18,12 +18,13 @@ FluObject {
if(screenLayout){
var last = screenLayout.getLastloader();
if(last.type === type && last.text === text && moremsg === last.moremsg){
last.restart();
return;
last.duration = duration
if (duration > 0) last.restart();
return last;
}
}
initScreenLayout();
contentComponent.createObject(screenLayout,{
return contentComponent.createObject(screenLayout,{
type:type,
text:text,
duration:duration,
@ -33,7 +34,7 @@ FluObject {
function createCustom(itemcomponent,duration){
initScreenLayout();
if(itemcomponent){
contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
}
}
function initScreenLayout(){
@ -85,7 +86,9 @@ FluObject {
}
Timer {
id:delayTimer
interval: duration; running: duration > 0; repeat: duration > 0
interval: duration;
running: duration > 0;
repeat: duration > 0
onTriggered: content.close();
}
FluLoader{
@ -235,18 +238,26 @@ FluObject {
}
}
function showSuccess(text,duration=1000,moremsg){
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){
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){
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){
mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
}
function showCustom(itemcomponent,duration=1000){
mcontrol.createCustom(itemcomponent,duration);
return mcontrol.createCustom(itemcomponent,duration);
}
function clearAllInfo(){
if(mcontrol.screenLayout != null) {
mcontrol.screenLayout.destroy()
mcontrol.screenLayout = null
}
return true
}
}

View File

@ -49,9 +49,6 @@ T.MenuBarItem {
radius: 3
color: {
if(control.highlighted){
return FluTheme.itemCheckColor
}
if(control.hovered){
return FluTheme.itemHoverColor
}
return FluTheme.itemNormalColor

View File

@ -100,9 +100,9 @@ T.MenuItem {
anchors.fill: parent
anchors.margins: 3
radius: 4
color:{
color: {
if(control.highlighted){
return FluTheme.itemCheckColor
return FluTheme.itemHoverColor
}
return FluTheme.itemNormalColor
}

View File

@ -7,6 +7,8 @@ import FluentUI
ColumnLayout {
default property alias buttons: control.data
property int currentIndex : -1
property bool disabled: false
property bool manuallyDisabled: false
id:control
onCurrentIndexChanged: {
for(var i = 0;i<buttons.length;i++){
@ -17,6 +19,12 @@ ColumnLayout {
button.checked = true
}
}
onDisabledChanged: {
refreshButtonStatus()
}
onManuallyDisabledChanged: {
refreshButtonStatus()
}
Component.onCompleted: {
for(var i = 0;i<buttons.length;i++){
buttons[i].clickListener = function(){
@ -28,6 +36,12 @@ ColumnLayout {
}
}
}
currentIndex = 0
refreshButtonStatus()
}
function refreshButtonStatus() {
for(var i = 0;i<buttons.length;i++){
if(!manuallyDisabled) buttons[i].enabled = !disabled
}
}
}

View File

@ -278,13 +278,7 @@ Window {
id:loader_border
anchors.fill: parent
sourceComponent: {
if(window.useSystemAppBar){
return undefined
}
if(FluTools.isWindows10OrGreater()){
return undefined
}
if(window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){
return undefined
}
return com_border
@ -294,16 +288,19 @@ Window {
loader_loading.sourceComponent = undefined
}
function showSuccess(text,duration,moremsg){
info_bar.showSuccess(text,duration,moremsg)
return info_bar.showSuccess(text,duration,moremsg)
}
function showInfo(text,duration,moremsg){
info_bar.showInfo(text,duration,moremsg)
return info_bar.showInfo(text,duration,moremsg)
}
function showWarning(text,duration,moremsg){
info_bar.showWarning(text,duration,moremsg)
return info_bar.showWarning(text,duration,moremsg)
}
function showError(text,duration,moremsg){
info_bar.showError(text,duration,moremsg)
return info_bar.showError(text,duration,moremsg)
}
function clearAllInfo(){
return info_bar.clearAllInfo()
}
function moveWindowToDesktopCenter(){
screen = Qt.application.screens[FluTools.cursorScreenIndex()]