RibbonSplashScreen, RibbonSplashScreenContent: Added.
This commit is contained in:
parent
cba90e9ecf
commit
744ef5673d
|
@ -38,7 +38,9 @@ set(ts_files i18n/${PROJECT_NAME}_zh_CN.ts i18n/${PROJECT_NAME}_en_US.ts)
|
|||
|
||||
# Source and QML files
|
||||
set(sources_files example.cpp)
|
||||
set(qml_files example.qml about.qml components/RibbonMessageListViewExample.qml pages/SettingsMenuPage.qml components/TabBar.qml)
|
||||
set(qml_files example.qml about.qml SplashScreen.qml
|
||||
components/RibbonMessageListViewExample.qml
|
||||
pages/SettingsMenuPage.qml components/TabBar.qml)
|
||||
set(qml_prefix "qml/Qt${QT_VERSION_MAJOR}/")
|
||||
list(TRANSFORM qml_files PREPEND ${qml_prefix})
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ int main(int argc, char *argv[])
|
|||
qml_static_register_types_RibbonUI();
|
||||
#endif
|
||||
#endif
|
||||
const QUrl url("qrc:/qt/qml/RibbonUIAPP/example.qml");
|
||||
const QUrl url("qrc:/qt/qml/RibbonUIAPP/SplashScreen.qml");
|
||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||
if (!obj && url == objUrl)
|
||||
|
|
|
@ -163,6 +163,27 @@
|
|||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SplashScreen</name>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/SplashScreen.qml" line="11"/>
|
||||
<location filename="../qml/Qt6/SplashScreen.qml" line="11"/>
|
||||
<source>Example App</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/SplashScreen.qml" line="12"/>
|
||||
<location filename="../qml/Qt6/SplashScreen.qml" line="12"/>
|
||||
<source>A example for users to use RibbonUI.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/SplashScreen.qml" line="23"/>
|
||||
<location filename="../qml/Qt6/SplashScreen.qml" line="23"/>
|
||||
<source>Loading...Remain %1s...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TabBar</name>
|
||||
<message>
|
||||
|
@ -503,7 +524,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="288"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="404"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="406"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="288"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="406"/>
|
||||
<source>About</source>
|
||||
|
@ -528,34 +549,37 @@
|
|||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="376"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="378"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="382"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="378"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="382"/>
|
||||
<source>Home</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="383"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="385"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="389"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="385"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="389"/>
|
||||
<source>File</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="390"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="392"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="396"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="392"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="396"/>
|
||||
<source>Search</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="397"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="399"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="399"/>
|
||||
<source>Account</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="411"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="413"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="413"/>
|
||||
<source>Settings</source>
|
||||
<translation></translation>
|
||||
|
|
|
@ -163,6 +163,27 @@
|
|||
<translation>隐藏</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SplashScreen</name>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/SplashScreen.qml" line="11"/>
|
||||
<location filename="../qml/Qt6/SplashScreen.qml" line="11"/>
|
||||
<source>Example App</source>
|
||||
<translation>示例程序</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/SplashScreen.qml" line="12"/>
|
||||
<location filename="../qml/Qt6/SplashScreen.qml" line="12"/>
|
||||
<source>A example for users to use RibbonUI.</source>
|
||||
<translation>一个为了让用户学会使用RibbonUI的示例程序。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/SplashScreen.qml" line="23"/>
|
||||
<location filename="../qml/Qt6/SplashScreen.qml" line="23"/>
|
||||
<source>Loading...Remain %1s...</source>
|
||||
<translation>加载中...剩余 %1秒...</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TabBar</name>
|
||||
<message>
|
||||
|
@ -503,7 +524,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="288"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="404"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="406"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="288"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="406"/>
|
||||
<source>About</source>
|
||||
|
@ -528,34 +549,37 @@
|
|||
<translation>测试项目 1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="376"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="378"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="382"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="378"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="382"/>
|
||||
<source>Home</source>
|
||||
<translation>主页</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="383"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="385"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="389"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="385"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="389"/>
|
||||
<source>File</source>
|
||||
<translation>文件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="390"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="392"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="396"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="392"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="396"/>
|
||||
<source>Search</source>
|
||||
<translation>搜索</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="397"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="399"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="399"/>
|
||||
<source>Account</source>
|
||||
<translation>账户</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/example.qml" line="411"/>
|
||||
<location filename="../qml/Qt5/example.qml" line="413"/>
|
||||
<location filename="../qml/Qt6/example.qml" line="413"/>
|
||||
<source>Settings</source>
|
||||
<translation>设置</translation>
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import QtQuick 2.15
|
||||
import RibbonUI 1.1
|
||||
|
||||
RibbonSplashScreen {
|
||||
id: root
|
||||
homeUrl: "qrc:/qt/qml/RibbonUIAPP/example.qml"
|
||||
delayMS: 10000
|
||||
contentArgs: {
|
||||
"implicitHeight": 250,
|
||||
"implicitWidth": 450,
|
||||
"titleText": qsTr("Example App"),
|
||||
"subTitleText": qsTr("A example for users to use RibbonUI.")
|
||||
}
|
||||
|
||||
Timer{
|
||||
interval: 1000
|
||||
triggeredOnStart: true
|
||||
repeat: true
|
||||
running: true
|
||||
property int remainSeconds: root.delayMS / 1000
|
||||
onTriggered: {
|
||||
remainSeconds -= 1
|
||||
root.showLoadingLog(qsTr("Loading...Remain %1s...").arg(remainSeconds), {})
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import QtQuick
|
||||
import RibbonUI
|
||||
|
||||
RibbonSplashScreen {
|
||||
id: root
|
||||
homeUrl: "qrc:/qt/qml/RibbonUIAPP/example.qml"
|
||||
delayMS: 10000
|
||||
contentArgs: {
|
||||
"implicitHeight": 250,
|
||||
"implicitWidth": 450,
|
||||
"titleText": qsTr("Example App"),
|
||||
"subTitleText": qsTr("A example for users to use RibbonUI.")
|
||||
}
|
||||
|
||||
Timer{
|
||||
interval: 1000
|
||||
triggeredOnStart: true
|
||||
repeat: true
|
||||
running: true
|
||||
property int remainSeconds: root.delayMS / 1000
|
||||
onTriggered: {
|
||||
remainSeconds -= 1
|
||||
root.showLoadingLog(qsTr("Loading...Remain %1s...").arg(remainSeconds), {})
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,7 +51,9 @@ set(qml_files
|
|||
RibbonRadioButton.qml RibbonBackStageMenuItem.qml RibbonTourItem.qml
|
||||
RibbonObject.qml RibbonProgressBar.qml RibbonProgressRing.qml
|
||||
RibbonBusyBar.qml RibbonBusyRing.qml RibbonPageIndicator.qml
|
||||
RibbonMessageBar.qml RibbonMessageBarGroup.qml)
|
||||
RibbonMessageBar.qml RibbonMessageBarGroup.qml RibbonSplashScreen.qml
|
||||
RibbonSplashScreenContent.qml
|
||||
)
|
||||
|
||||
# Set the QML prefix path
|
||||
set(qml_prefix "qml/Qt${QT_VERSION_MAJOR}/")
|
||||
|
|
|
@ -173,6 +173,15 @@
|
|||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RibbonSplashScreenContent</name>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonSplashScreenContent.qml" line="148"/>
|
||||
<location filename="../qml/Qt6/RibbonSplashScreenContent.qml" line="148"/>
|
||||
<source>Loading...</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RibbonSwitchButton</name>
|
||||
<message>
|
||||
|
@ -358,33 +367,33 @@
|
|||
</context>
|
||||
<context>
|
||||
<name>RibbonWindow</name>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="148"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="148"/>
|
||||
<source>Quit</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="149"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="149"/>
|
||||
<source>Minimize</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="150"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="150"/>
|
||||
<source>Cancel</source>
|
||||
<source>Quit</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="151"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="151"/>
|
||||
<source>Do you want to close this window?</source>
|
||||
<source>Minimize</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="152"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="152"/>
|
||||
<source>Cancel</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="153"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="153"/>
|
||||
<source>Do you want to close this window?</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="154"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="154"/>
|
||||
<source>Please note</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
|
|
@ -173,6 +173,15 @@
|
|||
<translation>加载中</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RibbonSplashScreenContent</name>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonSplashScreenContent.qml" line="148"/>
|
||||
<location filename="../qml/Qt6/RibbonSplashScreenContent.qml" line="148"/>
|
||||
<source>Loading...</source>
|
||||
<translation>加载中...</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RibbonSwitchButton</name>
|
||||
<message>
|
||||
|
@ -360,32 +369,32 @@
|
|||
<context>
|
||||
<name>RibbonWindow</name>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="148"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="148"/>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="150"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="150"/>
|
||||
<source>Quit</source>
|
||||
<translation>退出</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="149"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="149"/>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="151"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="151"/>
|
||||
<source>Minimize</source>
|
||||
<translation>最小化</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="150"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="150"/>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="152"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="152"/>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="151"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="151"/>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="153"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="153"/>
|
||||
<source>Do you want to close this window?</source>
|
||||
<translation>需要关闭窗口吗?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="152"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="152"/>
|
||||
<location filename="../qml/Qt5/RibbonWindow.qml" line="154"/>
|
||||
<location filename="../qml/Qt6/RibbonWindow.qml" line="154"/>
|
||||
<source>Please note</source>
|
||||
<translation>请注意</translation>
|
||||
</message>
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
import QtQuick 2.15
|
||||
import RibbonUI 1.1
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Window 2.15
|
||||
import QWindowKit 1.0
|
||||
|
||||
Window {
|
||||
id: root
|
||||
required property string homeUrl
|
||||
width: container.width
|
||||
height: container.height
|
||||
color: "transparent"
|
||||
property real delayMS: 2000
|
||||
property alias contentArgs: container.args
|
||||
property var homeArgs: ({})
|
||||
property string contentSource: "RibbonSplashScreenContent.qml"
|
||||
property var contentItems: undefined
|
||||
property bool blurBehindWindow : Qt.platform.os === 'windows' && !RibbonUI.isWin11 ? false : true
|
||||
|
||||
signal showLoadingLog(log: string, others: var)
|
||||
signal finished()
|
||||
|
||||
ColumnLayout{
|
||||
id: container
|
||||
spacing: 10
|
||||
property var args: ({})
|
||||
Loader{
|
||||
id: loader
|
||||
sourceComponent: contentSource ? undefined : contentItems
|
||||
source: contentSource ? contentSource : ""
|
||||
onLoaded: {
|
||||
root.showLoadingLog.connect(item.dealWithLog)
|
||||
if (!Object.keys(container.args).length)
|
||||
return
|
||||
else if(Object.keys(container.args).length){
|
||||
for (let arg in container.args){
|
||||
item[arg] = container.args[arg]
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.error("RibbonSplashScreen: Arguments error, please check.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject{
|
||||
id: internal
|
||||
property bool isComponentReady: false
|
||||
property var component
|
||||
property var home
|
||||
|
||||
onIsComponentReadyChanged: {
|
||||
if(isComponentReady)
|
||||
timer.running = true
|
||||
}
|
||||
|
||||
function dealWithHome(component, home){
|
||||
if (!(home.object instanceof Window))
|
||||
{
|
||||
console.error("RibbonSplashScreen: Error loading Home because instance is not Window.")
|
||||
return
|
||||
}
|
||||
home = home.object
|
||||
home.onClosing.connect(function() {
|
||||
if(!home.visible){
|
||||
component.destroy()
|
||||
home.destroy()
|
||||
}
|
||||
});
|
||||
home.raise()
|
||||
home.requestActivate()
|
||||
}
|
||||
|
||||
function configHome(){
|
||||
let home = internal.component.incubateObject(null, root.homeArgs)
|
||||
if (home.status !== Component.Ready) {
|
||||
home.onStatusChanged = function(status) {
|
||||
if (status === Component.Ready) {
|
||||
console.debug("RibbonSplashScreen:", "Object", home.object, "is now ready.")
|
||||
dealWithHome(internal.component, home)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.debug("RibbonSplashScreen:", "Object", home.object, "is ready immediately.")
|
||||
dealWithHome(internal.component, home)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer{
|
||||
id: timer
|
||||
interval: root.delayMS
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: {
|
||||
internal.isComponentReady = false
|
||||
root.visible = false
|
||||
internal.configHome()
|
||||
finished()
|
||||
}
|
||||
}
|
||||
|
||||
WindowAgent {
|
||||
id: windowAgent
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
windowAgent.setup(root)
|
||||
if (Qt.platform.os === 'windows')
|
||||
{
|
||||
windowAgent.setWindowAttribute("dwm-blur", blurBehindWindow)
|
||||
}
|
||||
if(Qt.platform.os === "osx")
|
||||
{
|
||||
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.isDarkMode ? "dark" : "light" : "none")
|
||||
}
|
||||
root.flags |= Qt.WindowStaysOnTopHint
|
||||
PlatformSupport.showSystemTitleBtns(root, false)
|
||||
root.visible = true
|
||||
windowAgent.centralize()
|
||||
raise()
|
||||
requestActivate()
|
||||
|
||||
const component = Qt.createComponent(root.homeUrl, Component.Asynchronous, null)
|
||||
|
||||
if(component.status !== Component.Ready){
|
||||
component.statusChanged.connect(function(){
|
||||
if (component.status === Component.Ready) {
|
||||
console.debug("RibbonSplashScreen:", "Component", component, "is now ready.")
|
||||
internal.component = component
|
||||
internal.isComponentReady = true
|
||||
} else if (component.status === Component.Error) {
|
||||
console.error("RibbonSplashScreen: Error loading Window Component:", component.errorString())
|
||||
}
|
||||
})
|
||||
}
|
||||
else{
|
||||
console.debug("RibbonSplashScreen:", component, "is ready immediately.")
|
||||
internal.component = component
|
||||
internal.isComponentReady = true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
import QtQuick 2.15
|
||||
import RibbonUI 1.1
|
||||
import QtQuick.Layouts 1.11
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Window 2.15
|
||||
|
||||
RibbonRectangle {
|
||||
id: control
|
||||
|
||||
property var dealWithLog: showLog
|
||||
property string picSource: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
|
||||
property string labelText: "Dylan Liu's Lab"
|
||||
property string titleText: "RibbonUI"
|
||||
property string subTitleText: "A lightweight UI framework."
|
||||
|
||||
color: {
|
||||
if (Window.window.blurBehindWindow) {
|
||||
return "transparent"
|
||||
}
|
||||
if (RibbonTheme.isDarkMode) {
|
||||
return '#2C2B29'
|
||||
}
|
||||
return '#FFFFFF'
|
||||
}
|
||||
implicitHeight: Math.max(250, btn_layout.height + title_layout.height + log_text.height + btn_layout.anchors.topMargin * 2)
|
||||
implicitWidth: Math.max(450, title_layout.width + btn_layout.anchors.topMargin * 2)
|
||||
radius: 20
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
id: btn_layout
|
||||
layoutDirection: Qt.platform.os === 'osx' ? Qt.RightToLeft : Qt.LeftToRight
|
||||
anchors{
|
||||
top:parent.top
|
||||
topMargin: 8
|
||||
right: Qt.platform.os === 'osx' ? undefined : parent.right
|
||||
rightMargin: Qt.platform.os === 'osx' ? undefined : anchors.topMargin
|
||||
left: Qt.platform.os === 'osx' ? parent.left : undefined
|
||||
leftMargin: Qt.platform.os === 'osx' ? anchors.topMargin : undefined
|
||||
}
|
||||
RibbonButton{
|
||||
showBg: false
|
||||
showHoveredBg: false
|
||||
iconSource: RibbonIcons.Subtract
|
||||
onClicked: Window.window.visibility = Window.Minimized
|
||||
}
|
||||
RibbonButton{
|
||||
showBg: false
|
||||
showHoveredBg: false
|
||||
iconSource: RibbonIcons.Dismiss
|
||||
onClicked: Qt.quit()
|
||||
}
|
||||
}
|
||||
RowLayout{
|
||||
anchors{
|
||||
top: parent.top
|
||||
topMargin: btn_layout.anchors.topMargin
|
||||
right: Qt.platform.os !== 'osx' ? undefined : parent.right
|
||||
rightMargin: Qt.platform.os !== 'osx' ? undefined : anchors.topMargin
|
||||
left: Qt.platform.os !== 'osx' ? parent.left : undefined
|
||||
leftMargin: Qt.platform.os !== 'osx' ? anchors.topMargin : undefined
|
||||
}
|
||||
Image {
|
||||
id: pic
|
||||
source: control.picSource
|
||||
visible: typeof(control.picSource) === "string"
|
||||
fillMode:Image.PreserveAspectFit
|
||||
mipmap: true
|
||||
autoTransform: true
|
||||
Layout.preferredHeight: label_text.visible ? label_text.contentHeight : 16
|
||||
Layout.preferredWidth: Layout.preferredHeight
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
Text {
|
||||
id: label_text
|
||||
text: control.labelText
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 16
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout{
|
||||
id: title_layout
|
||||
anchors.centerIn: parent
|
||||
spacing: -5
|
||||
Text {
|
||||
id: title_text
|
||||
text: control.titleText
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 50
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: subtitle_text
|
||||
text: control.subTitleText
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 15
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
RibbonBusyBar{
|
||||
Layout.topMargin: btn_layout.anchors.topMargin - title_layout.spacing
|
||||
running: true
|
||||
barWidth: control.width - btn_layout.anchors.topMargin * 4
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: log_text
|
||||
anchors{
|
||||
left: parent.left
|
||||
leftMargin: btn_layout.anchors.topMargin
|
||||
bottom: parent.bottom
|
||||
bottomMargin: btn_layout.anchors.topMargin
|
||||
}
|
||||
text: qsTr("Loading...")
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 10
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showLog(log, others){
|
||||
log_text.text = log
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
import QtQuick
|
||||
import RibbonUI
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Window
|
||||
import QWindowKit
|
||||
|
||||
Window {
|
||||
id: root
|
||||
required property string homeUrl
|
||||
width: container.width
|
||||
height: container.height
|
||||
color: "transparent"
|
||||
property real delayMS: 2000
|
||||
property alias contentArgs: container.args
|
||||
property var homeArgs: ({})
|
||||
property string contentSource: "RibbonSplashScreenContent.qml"
|
||||
property var contentItems: undefined
|
||||
property bool blurBehindWindow : Qt.platform.os === 'windows' && !RibbonUI.isWin11 ? false : true
|
||||
|
||||
signal showLoadingLog(log: string, others: var)
|
||||
signal finished()
|
||||
|
||||
ColumnLayout{
|
||||
id: container
|
||||
spacing: 10
|
||||
property var args: ({})
|
||||
Loader{
|
||||
id: loader
|
||||
sourceComponent: contentSource ? undefined : contentItems
|
||||
source: contentSource ? contentSource : ""
|
||||
onLoaded: {
|
||||
root.showLoadingLog.connect(item.dealWithLog)
|
||||
if (!Object.keys(container.args).length)
|
||||
return
|
||||
else if(Object.keys(container.args).length){
|
||||
for (let arg in container.args){
|
||||
item[arg] = container.args[arg]
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.error("RibbonSplashScreen: Arguments error, please check.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject{
|
||||
id: internal
|
||||
property bool isComponentReady: false
|
||||
property var component
|
||||
property var home
|
||||
|
||||
onIsComponentReadyChanged: {
|
||||
if(isComponentReady)
|
||||
timer.running = true
|
||||
}
|
||||
|
||||
function dealWithHome(component, home){
|
||||
if (!(home.object instanceof Window))
|
||||
{
|
||||
console.error("RibbonSplashScreen: Error loading Home because instance is not Window.")
|
||||
return
|
||||
}
|
||||
home = home.object
|
||||
home.onClosing.connect(function() {
|
||||
if(!home.visible){
|
||||
component.destroy()
|
||||
home.destroy()
|
||||
}
|
||||
});
|
||||
home.raise()
|
||||
home.requestActivate()
|
||||
}
|
||||
|
||||
function configHome(){
|
||||
let home = internal.component.incubateObject(null, root.homeArgs)
|
||||
if (home.status !== Component.Ready) {
|
||||
home.onStatusChanged = function(status) {
|
||||
if (status === Component.Ready) {
|
||||
console.debug("RibbonSplashScreen:", "Object", home.object, "is now ready.")
|
||||
dealWithHome(internal.component, home)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.debug("RibbonSplashScreen:", "Object", home.object, "is ready immediately.")
|
||||
dealWithHome(internal.component, home)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer{
|
||||
id: timer
|
||||
interval: root.delayMS
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: {
|
||||
internal.isComponentReady = false
|
||||
root.visible = false
|
||||
internal.configHome()
|
||||
finished()
|
||||
}
|
||||
}
|
||||
|
||||
WindowAgent {
|
||||
id: windowAgent
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
windowAgent.setup(root)
|
||||
if (Qt.platform.os === 'windows')
|
||||
{
|
||||
windowAgent.setWindowAttribute("dwm-blur", blurBehindWindow)
|
||||
}
|
||||
if(Qt.platform.os === "osx")
|
||||
{
|
||||
windowAgent.setWindowAttribute("blur-effect", blurBehindWindow ? RibbonTheme.isDarkMode ? "dark" : "light" : "none")
|
||||
}
|
||||
root.flags |= Qt.WindowStaysOnTopHint
|
||||
PlatformSupport.showSystemTitleBtns(root, false)
|
||||
root.visible = true
|
||||
windowAgent.centralize()
|
||||
raise()
|
||||
requestActivate()
|
||||
|
||||
const component = Qt.createComponent(root.homeUrl, Component.Asynchronous, null)
|
||||
|
||||
if(component.status !== Component.Ready){
|
||||
component.statusChanged.connect(function(){
|
||||
if (component.status === Component.Ready) {
|
||||
console.debug("RibbonSplashScreen:", "Component", component, "is now ready.")
|
||||
internal.component = component
|
||||
internal.isComponentReady = true
|
||||
} else if (component.status === Component.Error) {
|
||||
console.error("RibbonSplashScreen: Error loading Window Component:", component.errorString())
|
||||
}
|
||||
})
|
||||
}
|
||||
else{
|
||||
console.debug("RibbonSplashScreen:", component, "is ready immediately.")
|
||||
internal.component = component
|
||||
internal.isComponentReady = true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
import QtQuick
|
||||
import RibbonUI
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Window
|
||||
|
||||
RibbonRectangle {
|
||||
id: control
|
||||
|
||||
property var dealWithLog: showLog
|
||||
property string picSource: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
|
||||
property string labelText: "Dylan Liu's Lab"
|
||||
property string titleText: "RibbonUI"
|
||||
property string subTitleText: "A lightweight UI framework."
|
||||
|
||||
color: {
|
||||
if (Window.window.blurBehindWindow) {
|
||||
return "transparent"
|
||||
}
|
||||
if (RibbonTheme.isDarkMode) {
|
||||
return '#2C2B29'
|
||||
}
|
||||
return '#FFFFFF'
|
||||
}
|
||||
implicitHeight: Math.max(250, btn_layout.height + title_layout.height + log_text.height + btn_layout.anchors.topMargin * 2)
|
||||
implicitWidth: Math.max(450, title_layout.width + btn_layout.anchors.topMargin * 2)
|
||||
radius: 20
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
id: btn_layout
|
||||
layoutDirection: Qt.platform.os === 'osx' ? Qt.RightToLeft : Qt.LeftToRight
|
||||
anchors{
|
||||
top:parent.top
|
||||
topMargin: 8
|
||||
right: Qt.platform.os === 'osx' ? undefined : parent.right
|
||||
rightMargin: Qt.platform.os === 'osx' ? undefined : anchors.topMargin
|
||||
left: Qt.platform.os === 'osx' ? parent.left : undefined
|
||||
leftMargin: Qt.platform.os === 'osx' ? anchors.topMargin : undefined
|
||||
}
|
||||
RibbonButton{
|
||||
showBg: false
|
||||
showHoveredBg: false
|
||||
iconSource: RibbonIcons.Subtract
|
||||
onClicked: Window.window.visibility = Window.Minimized
|
||||
}
|
||||
RibbonButton{
|
||||
showBg: false
|
||||
showHoveredBg: false
|
||||
iconSource: RibbonIcons.Dismiss
|
||||
onClicked: Qt.quit()
|
||||
}
|
||||
}
|
||||
RowLayout{
|
||||
anchors{
|
||||
top: parent.top
|
||||
topMargin: btn_layout.anchors.topMargin
|
||||
right: Qt.platform.os !== 'osx' ? undefined : parent.right
|
||||
rightMargin: Qt.platform.os !== 'osx' ? undefined : anchors.topMargin
|
||||
left: Qt.platform.os !== 'osx' ? parent.left : undefined
|
||||
leftMargin: Qt.platform.os !== 'osx' ? anchors.topMargin : undefined
|
||||
}
|
||||
Image {
|
||||
id: pic
|
||||
source: control.picSource
|
||||
visible: typeof(control.picSource) === "string"
|
||||
fillMode:Image.PreserveAspectFit
|
||||
mipmap: true
|
||||
autoTransform: true
|
||||
Layout.preferredHeight: label_text.visible ? label_text.contentHeight : 16
|
||||
Layout.preferredWidth: Layout.preferredHeight
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
Text {
|
||||
id: label_text
|
||||
text: control.labelText
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 16
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout{
|
||||
id: title_layout
|
||||
anchors.centerIn: parent
|
||||
spacing: -5
|
||||
Text {
|
||||
id: title_text
|
||||
text: control.titleText
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 50
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: subtitle_text
|
||||
text: control.subTitleText
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 15
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
RibbonBusyBar{
|
||||
Layout.topMargin: btn_layout.anchors.topMargin - title_layout.spacing
|
||||
running: true
|
||||
barWidth: control.width - btn_layout.anchors.topMargin * 4
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: log_text
|
||||
anchors{
|
||||
left: parent.left
|
||||
leftMargin: btn_layout.anchors.topMargin
|
||||
bottom: parent.bottom
|
||||
bottomMargin: btn_layout.anchors.topMargin
|
||||
}
|
||||
text: qsTr("Loading...")
|
||||
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
|
||||
font.pixelSize: 10
|
||||
color: RibbonTheme.isDarkMode ? "white" : "black"
|
||||
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
visible: text
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 60
|
||||
easing.type: Easing.OutSine
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showLog(log, others){
|
||||
log_text.text = log
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue