Commit 50407a87 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Create MainDrawerToggleButton component, unifying tasks view and rest of views' collapse button



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@gmail.com>
parent 2e278b07
Pipeline #246425 passed with stage
in 3 minutes and 2 seconds
// SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kalendar 1.0
import org.kde.kalendar.utils 1.0
QQC2.ToolButton {
property var mainDrawer: KalendarUiUtils.appMain.mainDrawer
visible: !Kirigami.Settings.isMobile
icon.name: mainDrawer.collapsed ? "sidebar-expand" : "sidebar-collapse"
onClicked: {
if(mainDrawer.collapsed && applicationWindow().width < mainDrawer.narrowWindowWidth) { // Collapsed due to narrow window
// We don't want to write to config as when narrow the button will only open the modal drawer
mainDrawer.collapsed = !mainDrawer.collapsed;
} else {
Config.forceCollapsedMainDrawer = !Config.forceCollapsedMainDrawer;
Config.save()
}
}
QQC2.ToolTip.text: mainDrawer.collapsed ? i18n("Expand Main Drawer") : i18n("Collapse Main Drawer")
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
......@@ -2,36 +2,15 @@
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kalendar 1.0
RowLayout {
property alias titleDateButton: titleDataButton
spacing: 0
// REMINDER: The collapse button used in the tasks view has its own implementation!!
// You can find it in its instantiating component in main.qml
MainDrawerToggleButton {}
QQC2.ToolButton {
visible: !Kirigami.Settings.isMobile
icon.name: mainDrawer.collapsed ? "sidebar-expand" : "sidebar-collapse"
onClicked: {
if(mainDrawer.collapsed && !wideScreen) { // Collapsed due to narrow window
// We don't want to write to config as when narrow the button will only open the modal drawer
mainDrawer.collapsed = !mainDrawer.collapsed;
} else {
Config.forceCollapsedMainDrawer = !Config.forceCollapsedMainDrawer;
Config.save()
}
}
QQC2.ToolTip.text: mainDrawer.collapsed ? i18n("Expand Main Drawer") : i18n("Collapse Main Drawer")
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
TitleDateButton {
id: titleDataButton
}
......
......@@ -489,6 +489,7 @@ Kirigami.ApplicationWindow {
source: Qt.resolvedUrl("qrc:/BottomToolBar.qml")
}
property alias mainDrawer: mainDrawer
globalDrawer: MainDrawer {
id: mainDrawer
mode: pageStack.currentItem ? pageStack.currentItem.mode : KalendarApplication.Event
......@@ -1113,23 +1114,7 @@ Kirigami.ApplicationWindow {
titleDelegate: RowLayout {
spacing: 0
QQC2.ToolButton {
visible: !Kirigami.Settings.isMobile
icon.name: mainDrawer.collapsed ? "sidebar-expand" : "sidebar-collapse"
onClicked: {
if(mainDrawer.collapsed && !wideScreen) { // Collapsed due to narrow window
// We don't want to write to config as when narrow the button will only open the modal drawer
mainDrawer.collapsed = !mainDrawer.collapsed;
} else {
Config.forceCollapsedMainDrawer = !Config.forceCollapsedMainDrawer;
Config.save()
}
}
QQC2.ToolTip.text: mainDrawer.collapsed ? i18n("Expand MainDrawer") : i18n("Collapse MainDrawer")
QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
}
MainDrawerToggleButton {}
Kirigami.Heading {
text: i18n("Tasks")
}
......
......@@ -63,6 +63,7 @@ SPDX-License-Identifier: CC0-1.0
<file alias="IncidenceInfoContents.qml">contents/ui/Controls/IncidenceInfoContents.qml</file>
<file alias="IncidenceInfoPopup.qml">contents/ui/Controls/IncidenceInfoPopup.qml</file>
<file alias="CheckableCollectionNavigationView.qml">contents/ui/Controls/CheckableCollectionNavigationView.qml</file>
<file alias="MainDrawerToggleButton.qml">contents/ui/Controls/MainDrawerToggleButton.qml</file>
<file alias="LocationMap.qml">contents/ui/Location/LocationMap.qml</file>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment