Rename main window id to kastsMainWindow instead of root

This commit is contained in:
Bart De Vries 2023-02-10 15:28:53 +01:00
parent 04f44bc078
commit 3f1859e14b
4 changed files with 53 additions and 53 deletions

View File

@ -23,7 +23,7 @@ Kirigami.NavigationTabBar {
Kirigami.Action { Kirigami.Action {
icon.name: "view-media-playlist" icon.name: "view-media-playlist"
text: i18n("Queue") text: i18n("Queue")
checked: "QueuePage" === root.currentPage checked: "QueuePage" === kastsMainWindow.currentPage
onTriggered: { onTriggered: {
pushPage("QueuePage"); pushPage("QueuePage");
} }
@ -31,7 +31,7 @@ Kirigami.NavigationTabBar {
Kirigami.Action { Kirigami.Action {
icon.name: "bookmarks" icon.name: "bookmarks"
text: i18n("Subscriptions") text: i18n("Subscriptions")
checked: "FeedListPage" === root.currentPage checked: "FeedListPage" === kastsMainWindow.currentPage
onTriggered: { onTriggered: {
pushPage("FeedListPage"); pushPage("FeedListPage");
} }
@ -39,7 +39,7 @@ Kirigami.NavigationTabBar {
Kirigami.Action { Kirigami.Action {
icon.name: "rss" icon.name: "rss"
text: i18n("Episodes") text: i18n("Episodes")
checked: "EpisodeListPage" === root.currentPage checked: "EpisodeListPage" === kastsMainWindow.currentPage
onTriggered: { onTriggered: {
pushPage("EpisodeListPage") pushPage("EpisodeListPage")
} }
@ -47,7 +47,7 @@ Kirigami.NavigationTabBar {
Kirigami.Action { Kirigami.Action {
icon.name: "settings-configure" icon.name: "settings-configure"
text: i18n("Settings") text: i18n("Settings")
checked: "SettingsPage" === root.currentPage checked: "SettingsPage" === kastsMainWindow.currentPage
onTriggered: { onTriggered: {
applicationWindow().pageStack.clear() applicationWindow().pageStack.clear()
applicationWindow().pageStack.push("qrc:/SettingsPage.qml", {}, { applicationWindow().pageStack.push("qrc:/SettingsPage.qml", {}, {

View File

@ -111,11 +111,11 @@ Flickable {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: root.height + root.miniplayerSize + contentToPlayerSpacing height: kastsMainWindow.height + kastsMainWindow.miniplayerSize + contentToPlayerSpacing
spacing: 0 spacing: 0
Controls.Control { Controls.Control {
implicitHeight: root.miniplayerSize + contentToPlayerSpacing implicitHeight: kastsMainWindow.miniplayerSize + contentToPlayerSpacing
Layout.fillWidth: true Layout.fillWidth: true
padding: 0 padding: 0
@ -145,7 +145,7 @@ Flickable {
MinimizedPlayerControls { MinimizedPlayerControls {
id: playControlItem id: playControlItem
height: root.miniplayerSize height: kastsMainWindow.miniplayerSize
focus: true focus: true
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

View File

@ -108,14 +108,14 @@ Kirigami.Page {
id: coverImage id: coverImage
anchors { anchors {
top: parent.top top: parent.top
bottom: root.isWidescreen ? parent.bottom : undefined bottom: kastsMainWindow.isWidescreen ? parent.bottom : undefined
left: parent.left left: parent.left
right: root.isWidescreen ? undefined : parent.right right: kastsMainWindow.isWidescreen ? undefined : parent.right
margins: 0 margins: 0
topMargin: root.isWidescreen ? 0 : (parent.height - Math.min(height, width) - imageLabels.implicitHeight - 2 * parent.textMargin) / 2 topMargin: kastsMainWindow.isWidescreen ? 0 : (parent.height - Math.min(height, width) - imageLabels.implicitHeight - 2 * parent.textMargin) / 2
} }
height: Math.min(parent.height - (root.isWidescreen ? 0 : imageLabels.implicitHeight + 2 * parent.textMargin), parent.width) height: Math.min(parent.height - (kastsMainWindow.isWidescreen ? 0 : imageLabels.implicitHeight + 2 * parent.textMargin), parent.width)
width: root.isWidescreen ? Math.min(parent.height, parent.width / 2) : Math.min(parent.width, height) width: kastsMainWindow.isWidescreen ? Math.min(parent.height, parent.width / 2) : Math.min(parent.width, height)
ImageWithFallback { ImageWithFallback {
imageSource: AudioManager.entry ? ((chapterModel.currentChapter && chapterModel.currentChapter !== undefined) ? chapterModel.currentChapter.cachedImage : AudioManager.entry.cachedImage) : "no-image" imageSource: AudioManager.entry ? ((chapterModel.currentChapter && chapterModel.currentChapter !== undefined) ? chapterModel.currentChapter.cachedImage : AudioManager.entry.cachedImage) : "no-image"
@ -130,12 +130,12 @@ Kirigami.Page {
Item { Item {
anchors { anchors {
top: root.isWidescreen ? parent.top : coverImage.bottom top: kastsMainWindow.isWidescreen ? parent.top : coverImage.bottom
bottom: parent.bottom bottom: parent.bottom
left: root.isWidescreen ? coverImage.right : parent.left left: kastsMainWindow.isWidescreen ? coverImage.right : parent.left
right: parent.right right: parent.right
leftMargin: root.isWidescreen ? parent.textMargin : 0 leftMargin: kastsMainWindow.isWidescreen ? parent.textMargin : 0
topMargin: root.isWidescreen ? 0 : parent.textMargin topMargin: kastsMainWindow.isWidescreen ? 0 : parent.textMargin
bottomMargin: 0 bottomMargin: 0
} }
@ -398,8 +398,8 @@ Kirigami.Page {
} }
Loader { Loader {
active: !root.isWidescreen active: !kastsMainWindow.isWidescreen
visible: !root.isWidescreen visible: !kastsMainWindow.isWidescreen
sourceComponent: slider sourceComponent: slider
Layout.fillWidth: true Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing Layout.leftMargin: Kirigami.Units.largeSpacing
@ -418,7 +418,7 @@ Kirigami.Page {
font: Kirigami.Theme.smallFont font: Kirigami.Theme.smallFont
} }
Loader { Loader {
active: root.isWidescreen active: kastsMainWindow.isWidescreen
sourceComponent: slider sourceComponent: slider
Layout.fillWidth: true Layout.fillWidth: true

View File

@ -17,7 +17,7 @@ import org.kde.kasts.solidextras 1.0
import org.kde.kasts 1.0 import org.kde.kasts 1.0
Kirigami.ApplicationWindow { Kirigami.ApplicationWindow {
id: root id: kastsMainWindow
title: "Kasts" title: "Kasts"
width: Kirigami.Settings.isMobile ? 360 : 800 width: Kirigami.Settings.isMobile ? 360 : 800
@ -45,7 +45,7 @@ Kirigami.ApplicationWindow {
property var lastFeed: "" property var lastFeed: ""
property string currentPage: "" property string currentPage: ""
property bool isWidescreen: root.width > root.height property bool isWidescreen: kastsMainWindow.width > kastsMainWindow.height
function getPage(page) { function getPage(page) {
switch (page) { switch (page) {
@ -68,33 +68,33 @@ Kirigami.ApplicationWindow {
Settings { Settings {
id: settings id: settings
property alias x: root.x property alias x: kastsMainWindow.x
property alias y: root.y property alias y: kastsMainWindow.y
property var mobileWidth property var mobileWidth
property var mobileHeight property var mobileHeight
property var desktopWidth property var desktopWidth
property var desktopHeight property var desktopHeight
property int headerSize: Kirigami.Units.gridUnit * 5 property int headerSize: Kirigami.Units.gridUnit * 5
property alias lastOpenedPage: root.currentPage property alias lastOpenedPage: kastsMainWindow.currentPage
} }
function saveWindowLayout() { function saveWindowLayout() {
if (Kirigami.Settings.isMobile) { if (Kirigami.Settings.isMobile) {
settings.mobileWidth = root.width; settings.mobileWidth = kastsMainWindow.width;
settings.mobileHeight = root.height; settings.mobileHeight = kastsMainWindow.height;
} else { } else {
settings.desktopWidth = root.width; settings.desktopWidth = kastsMainWindow.width;
settings.desktopHeight = root.height; settings.desktopHeight = kastsMainWindow.height;
} }
} }
function restoreWindowLayout() { function restoreWindowLayout() {
if (Kirigami.Settings.isMobile) { if (Kirigami.Settings.isMobile) {
if (settings.mobileWidth) root.width = settings.mobileWidth; if (settings.mobileWidth) kastsMainWindow.width = settings.mobileWidth;
if (settings.mobileHeight) root.height = settings.mobileHeight; if (settings.mobileHeight) kastsMainWindow.height = settings.mobileHeight;
} else { } else {
if (settings.desktopWidth) root.width = settings.desktopWidth; if (settings.desktopWidth) kastsMainWindow.width = settings.desktopWidth;
if (settings.desktopHeight) root.height = settings.desktopHeight; if (settings.desktopHeight) kastsMainWindow.height = settings.desktopHeight;
} }
} }
@ -124,7 +124,7 @@ Kirigami.ApplicationWindow {
globalDrawer: sidebar.item globalDrawer: sidebar.item
Loader { Loader {
id: sidebar id: sidebar
active: !Kirigami.Settings.isMobile || root.isWidescreen active: !Kirigami.Settings.isMobile || kastsMainWindow.isWidescreen
sourceComponent: Kirigami.OverlayDrawer { sourceComponent: Kirigami.OverlayDrawer {
id: drawer id: drawer
modal: false modal: false
@ -134,9 +134,9 @@ Kirigami.ApplicationWindow {
readonly property real pinnedWidth: Kirigami.Units.gridUnit * 3 readonly property real pinnedWidth: Kirigami.Units.gridUnit * 3
readonly property real widescreenSmallWidth: Kirigami.Units.gridUnit * 6 readonly property real widescreenSmallWidth: Kirigami.Units.gridUnit * 6
readonly property real widescreenBigWidth: Kirigami.Units.gridUnit * 10 readonly property real widescreenBigWidth: Kirigami.Units.gridUnit * 10
readonly property int buttonDisplayMode: root.isWidescreen ? (drawer.height < listViewThreshold ? Kirigami.NavigationTabButton.TextBesideIcon : Kirigami.NavigationTabButton.TextUnderIcon) : Kirigami.NavigationTabButton.IconOnly readonly property int buttonDisplayMode: kastsMainWindow.isWidescreen ? (drawer.height < listViewThreshold ? Kirigami.NavigationTabButton.TextBesideIcon : Kirigami.NavigationTabButton.TextUnderIcon) : Kirigami.NavigationTabButton.IconOnly
width: root.isWidescreen ? (drawer.height < listViewThreshold ? widescreenBigWidth : widescreenSmallWidth) : pinnedWidth width: kastsMainWindow.isWidescreen ? (drawer.height < listViewThreshold ? widescreenBigWidth : widescreenSmallWidth) : pinnedWidth
Kirigami.Theme.colorSet: Kirigami.Theme.Window Kirigami.Theme.colorSet: Kirigami.Theme.Window
Kirigami.Theme.inherit: false Kirigami.Theme.inherit: false
@ -238,8 +238,8 @@ Kirigami.ApplicationWindow {
checked: currentPage == "SettingsPage" checked: currentPage == "SettingsPage"
onClicked: { onClicked: {
checked = false; checked = false;
root.pageStack.layers.clear() kastsMainWindow.pageStack.layers.clear()
root.pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {}, { kastsMainWindow.pageStack.pushDialogLayer("qrc:/SettingsPage.qml", {}, {
title: i18n("Settings") title: i18n("Settings")
}) })
} }
@ -259,16 +259,16 @@ Kirigami.ApplicationWindow {
Connections { Connections {
target: AudioManager target: AudioManager
function onRaiseWindowRequested() { function onRaiseWindowRequested() {
root.visible = true; kastsMainWindow.visible = true;
root.show(); kastsMainWindow.show();
root.raise(); kastsMainWindow.raise();
root.requestActivate(); kastsMainWindow.requestActivate();
} }
} }
Connections { Connections {
target: AudioManager target: AudioManager
function onQuitRequested() { function onQuitRequested() {
root.close(); kastsMainWindow.close();
} }
} }
@ -292,7 +292,7 @@ Kirigami.ApplicationWindow {
visible: active visible: active
z: (!item || item.contentY === 0) ? -1 : 999 z: (!item || item.contentY === 0) ? -1 : 999
sourceComponent: FooterBar { sourceComponent: FooterBar {
contentHeight: root.height * 2 contentHeight: kastsMainWindow.height * 2
focus: true focus: true
contentToPlayerSpacing: footer.active ? footer.item.height + 1 : 0 contentToPlayerSpacing: footer.active ? footer.item.height + 1 : 0
} }
@ -313,7 +313,7 @@ Kirigami.ApplicationWindow {
footer: Loader { footer: Loader {
visible: active visible: active
height: visible ? implicitHeight : 0 height: visible ? implicitHeight : 0
active: Kirigami.Settings.isMobile && !root.isWidescreen active: Kirigami.Settings.isMobile && !kastsMainWindow.isWidescreen
sourceComponent: BottomToolbar { sourceComponent: BottomToolbar {
transparentBackground: footerLoader.active transparentBackground: footerLoader.active
opacity: (!footerLoader.item || footerLoader.item.contentY === 0) ? 1 : 0 opacity: (!footerLoader.item || footerLoader.item.contentY === 0) ? 1 : 0
@ -484,12 +484,12 @@ Kirigami.ApplicationWindow {
// Systray implementation // Systray implementation
Connections { Connections {
target: root target: kastsMainWindow
function onClosing() { function onClosing() {
if (SystrayIcon.available && SettingsManager.showTrayIcon && SettingsManager.minimizeToTray) { if (SystrayIcon.available && SettingsManager.showTrayIcon && SettingsManager.minimizeToTray) {
close.accepted = false; close.accepted = false;
root.hide(); kastsMainWindow.hide();
} else { } else {
close.accepted = true; close.accepted = true;
Qt.quit(); Qt.quit();
@ -501,14 +501,14 @@ Kirigami.ApplicationWindow {
target: SystrayIcon target: SystrayIcon
function onRaiseWindow() { function onRaiseWindow() {
if (root.visible) { if (kastsMainWindow.visible) {
root.visible = false; kastsMainWindow.visible = false;
root.hide(); kastsMainWindow.hide();
} else { } else {
root.visible = true; kastsMainWindow.visible = true;
root.show(); kastsMainWindow.show();
root.raise(); kastsMainWindow.raise();
root.requestActivate(); kastsMainWindow.requestActivate();
} }
} }
} }