RibbonWindow: Add window manager.
This commit is contained in:
parent
453a15b37f
commit
edeee77c44
|
@ -85,7 +85,7 @@ qt_add_qml_module(${PROJECT_NAME}
|
||||||
URI ${PROJECT_NAME}
|
URI ${PROJECT_NAME}
|
||||||
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||||
RESOURCE_PREFIX "/qt/qml/"
|
RESOURCE_PREFIX "/qt/qml/"
|
||||||
QML_FILES example.qml components/RibbonMessageListViewExample.qml
|
QML_FILES example.qml about.qml components/RibbonMessageListViewExample.qml
|
||||||
RESOURCES resources/imgs/heart.png resources/imgs/search.png
|
RESOURCES resources/imgs/heart.png resources/imgs/search.png
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls
|
||||||
|
import RibbonUI
|
||||||
|
|
||||||
|
RibbonWindow {
|
||||||
|
id: window
|
||||||
|
width: Math.max(content.width, content.height + title_bar.height) + content.anchors.margins * 2
|
||||||
|
height: width
|
||||||
|
title: qsTr("About")
|
||||||
|
title_bar.show_darkmode_btn: false
|
||||||
|
title_bar.show_style_switch: false
|
||||||
|
|
||||||
|
ColumnLayout{
|
||||||
|
id: content
|
||||||
|
anchors{
|
||||||
|
centerIn: parent
|
||||||
|
margins: 10
|
||||||
|
}
|
||||||
|
spacing: 5
|
||||||
|
Image {
|
||||||
|
source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
|
||||||
|
fillMode:Image.PreserveAspectFit
|
||||||
|
Layout.preferredHeight: 120
|
||||||
|
Layout.preferredWidth: height
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
layer.enabled: true
|
||||||
|
layer.effect: RibbonShadow{}
|
||||||
|
}
|
||||||
|
RibbonText{
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
text: "RibbonUI"
|
||||||
|
font.pixelSize: 16
|
||||||
|
}
|
||||||
|
RibbonText{
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
text: `©${new Date().getFullYear()} mentalfl0w`
|
||||||
|
}
|
||||||
|
RibbonText{
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
text: `Version: V${RibbonUI.version}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ RibbonWindow {
|
||||||
width: 1200
|
width: 1200
|
||||||
height: 800
|
height: 800
|
||||||
title: qsTr("RibbonUI APP")
|
title: qsTr("RibbonUI APP")
|
||||||
|
comfirmed_quit: true
|
||||||
property bool modern_style: RibbonTheme.modern_style
|
property bool modern_style: RibbonTheme.modern_style
|
||||||
|
|
||||||
RibbonTabBar {
|
RibbonTabBar {
|
||||||
|
@ -693,6 +694,17 @@ RibbonWindow {
|
||||||
title_bar.right_content:RowLayout{
|
title_bar.right_content:RowLayout{
|
||||||
spacing: 1
|
spacing: 1
|
||||||
layoutDirection: Qt.RightToLeft
|
layoutDirection: Qt.RightToLeft
|
||||||
|
RibbonButton{
|
||||||
|
show_bg:false
|
||||||
|
icon_source: RibbonIcons.Info
|
||||||
|
icon_source_filled: RibbonIcons_Filled.Info
|
||||||
|
tip_text: qsTr("About")
|
||||||
|
hover_color: Qt.rgba(0,0,0, 0.3)
|
||||||
|
pressed_color: Qt.rgba(0,0,0, 0.4)
|
||||||
|
text_color: title_bar.title_text_color
|
||||||
|
text_color_reverse: false
|
||||||
|
onClicked: root.show_window(Qt.resolvedUrl("about.qml"))
|
||||||
|
}
|
||||||
RibbonButton{
|
RibbonButton{
|
||||||
show_bg:false
|
show_bg:false
|
||||||
icon_source: RibbonIcons.CalendarStar
|
icon_source: RibbonIcons.CalendarStar
|
||||||
|
|
|
@ -85,28 +85,55 @@ Window {
|
||||||
target_rect: Qt.rect(window_items.x + x, window_items.y + y, width, height)
|
target_rect: Qt.rect(window_items.x + x, window_items.y + y, width, height)
|
||||||
blur_enabled: true
|
blur_enabled: true
|
||||||
}
|
}
|
||||||
|
|
||||||
RibbonPopupDialog{
|
RibbonPopupDialog{
|
||||||
id: dialog
|
id: close_dialog
|
||||||
target: window_items
|
target: window_items
|
||||||
blur_enabled: true
|
blur_enabled: true
|
||||||
target_rect: Qt.rect(window_items.x + x, window_items.y + y, width, height)
|
target_rect: Qt.rect(window_items.x + x, window_items.y + y, width, height)
|
||||||
positiveText: qsTr("Quit")
|
positiveText: qsTr("Quit")
|
||||||
neutralText: qsTr("Minimize")
|
neutralText: qsTr("Minimize")
|
||||||
negativeText: qsTr("Cancel")
|
negativeText: qsTr("Cancel")
|
||||||
message: "Do you want to quit the APP?"
|
message: qsTr("Do you want to close this window?")
|
||||||
title: "Please note"
|
title: qsTr("Please note")
|
||||||
buttonFlags: RibbonPopupDialogType.NegativeButton | RibbonPopupDialogType.PositiveButton | RibbonPopupDialogType.NeutralButton
|
buttonFlags: RibbonPopupDialogType.NegativeButton | RibbonPopupDialogType.PositiveButton | RibbonPopupDialogType.NeutralButton
|
||||||
onNeutralClicked: window.visibility = Window.Minimized
|
onNeutralClicked: window.visibility = Window.Minimized
|
||||||
onPositiveClicked: {
|
onPositiveClicked: {
|
||||||
comfirmed_quit = true
|
comfirmed_quit = false
|
||||||
Qt.quit()
|
Qt.quit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosing:function(event){
|
onClosing:function(event){
|
||||||
window.raise()
|
window.raise()
|
||||||
event.accepted = comfirmed_quit
|
event.accepted = !comfirmed_quit
|
||||||
if (!comfirmed_quit)
|
if (comfirmed_quit)
|
||||||
dialog.open()
|
close_dialog.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
Loader{
|
||||||
|
id: window_loader
|
||||||
|
property var args
|
||||||
|
onLoaded: {
|
||||||
|
item.onClosing.connect(function(){
|
||||||
|
window_loader.source = ""
|
||||||
|
})
|
||||||
|
if (!window_loader.args)
|
||||||
|
return
|
||||||
|
else if(Object.keys(window_loader.args).length){
|
||||||
|
for (let arg in window_loader.args){
|
||||||
|
item[arg] = window_loader.args[arg]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.error("RibbonWindow: Arguments error, please check.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function show_window(window_url, args){
|
||||||
|
window_loader.args = args
|
||||||
|
window_loader.source = window_url
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_popup(content_url, arguments)
|
function show_popup(content_url, arguments)
|
||||||
|
|
Loading…
Reference in New Issue