Unverified Commit d41e6fda authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Refactor handling of window title



Use enums instead of objectName. This is more future proof

Signed-off-by: Carl Schwan's avatarCarl Schwan <carl@carlschwan.eu>
parent 4d15ef11
Pipeline #227074 passed with stage
in 2 minutes and 28 seconds
......@@ -41,7 +41,15 @@ Kirigami.Page {
readonly property real hourLabelWidth: hourLabelMetrics.boundingRect(new Date(0,0,0,0,0,0,0).toLocaleTimeString(Qt.locale(), Locale.NarrowFormat)).width +
Kirigami.Units.largeSpacing * 2.5
readonly property real periodHeight: Kirigami.Units.gridUnit
readonly property var mode: Kalendar.KalendarApplication.Event
readonly property var mode: switch(daysToShow) {
case 1:
return Kalendar.KalendarApplication.Day;
case 3:
return Kalendar.KalendarApplication.ThreeDay;
case 7:
default:
return Kalendar.KalendarApplication.Week;
}
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
......
// SPDX-FileCopyrightText: 2022 Carl Schwan <carlschwan@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import org.kde.kalendar.contact 1.0
import org.kde.kalendar 1.0
import org.kde.kalendar.contact 1.0
ContactView {}
ContactView {
readonly property int mode: KalendarApplication.Contact
}
......@@ -24,7 +24,7 @@ Kirigami.Page {
property bool initialMonth: true
readonly property bool isLarge: width > Kirigami.Units.gridUnit * 40
readonly property bool isTiny: width < Kirigami.Units.gridUnit * 18
readonly property int mode: Kalendar.KalendarApplication.Event
readonly property int mode: Kalendar.KalendarApplication.Month
property bool dragDropEnabled: true
......
......@@ -62,7 +62,7 @@ Kirigami.Page {
readonly property bool isDark: KalendarUiUtils.darkMode
property real maxTimeLabelWidth: 0
property bool dragDropEnabled: true
readonly property int mode: Kalendar.KalendarApplication.Event
readonly property int mode: Kalendar.KalendarApplication.Schedule
onSelectedDateChanged: {
if (pathView.currentItem) {
......
......@@ -431,36 +431,37 @@ Kirigami.ApplicationWindow {
}
title: if(pageStack.currentItem) {
switch (pageStack.currentItem.objectName) {
case "monthView":
return i18n("Month View");
switch (pageStack.currentItem.mode) {
case KalendarApplication.Month:
return i18n("Month");
break;
case "weekView":
return i18n("Week View");
case KalendarApplication.Week:
return i18n("Week");
break;
case "threeDayView":
return i18n("3 Day View");
case KalendarApplication.ThreeDay:
return i18n("3 Days");
break;
case "dayView":
return i18n("Day View");
case KalendarApplication.Day:
return i18n("Day");
break;
case "scheduleView":
return i18n("Schedule View");
case KalendarApplication.Schedule:
return i18n("Schedule");
break;
case "todoView":
return i18n("Tasks View");
case KalendarApplication.Todo:
return i18n("Tasks");
break;
case "contactView":
return i18n("Contacts View");
case KalendarApplication.Contact:
return i18n("Contacts");
break;
case "mailView":
return i18n("Mail View");
case KalendarApplication.Mail:
return i18n("Mail");
break;
default:
return i18n("Calendar");
// Should not happen
return 'Kalendar';
}
} else {
return i18n("Calendar");
return 'Kalendar';
}
menuBar: Loader {
......
......@@ -28,10 +28,15 @@ class KalendarApplication : public QObject
public:
enum Mode {
Event,
Todo,
Contact,
Mail,
Month = 1,
Week = 2,
ThreeDay = 4,
Day = 8,
Schedule = 16,
Event = Month | Week | ThreeDay | Day | Schedule,
Todo = 32,
Contact = 64,
Mail = 128,
};
Q_ENUM(Mode)
......
......@@ -12,6 +12,7 @@ import './private'
Kirigami.ScrollablePage {
id: folderView
title: MailManager.selectedFolderName
readonly property int mode: KalendarApplication.Mail
Component {
id: contextMenu
......
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