mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
@@ -1,5 +1,4 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Effects
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Services
|
import qs.Services
|
||||||
@@ -13,72 +12,70 @@ Rectangle {
|
|||||||
property var selectedDateEvents: []
|
property var selectedDateEvents: []
|
||||||
property bool hasEvents: selectedDateEvents && selectedDateEvents.length > 0
|
property bool hasEvents: selectedDateEvents && selectedDateEvents.length > 0
|
||||||
|
|
||||||
signal closeDash()
|
signal closeDash
|
||||||
|
|
||||||
function weekStartJs() {
|
function weekStartJs() {
|
||||||
return Qt.locale().firstDayOfWeek % 7
|
return Qt.locale().firstDayOfWeek % 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startOfWeek(dateObj) {
|
function startOfWeek(dateObj) {
|
||||||
const d = new Date(dateObj)
|
const d = new Date(dateObj);
|
||||||
const jsDow = d.getDay()
|
const jsDow = d.getDay();
|
||||||
const diff = (jsDow - weekStartJs() + 7) % 7
|
const diff = (jsDow - weekStartJs() + 7) % 7;
|
||||||
d.setDate(d.getDate() - diff)
|
d.setDate(d.getDate() - diff);
|
||||||
return d
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
function endOfWeek(dateObj) {
|
function endOfWeek(dateObj) {
|
||||||
const d = new Date(dateObj)
|
const d = new Date(dateObj);
|
||||||
const jsDow = d.getDay()
|
const jsDow = d.getDay();
|
||||||
const add = (weekStartJs() + 6 - jsDow + 7) % 7
|
const add = (weekStartJs() + 6 - jsDow + 7) % 7;
|
||||||
d.setDate(d.getDate() + add)
|
d.setDate(d.getDate() + add);
|
||||||
return d
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelectedDateEvents() {
|
function updateSelectedDateEvents() {
|
||||||
if (CalendarService && CalendarService.khalAvailable) {
|
if (CalendarService && CalendarService.khalAvailable) {
|
||||||
const events = CalendarService.getEventsForDate(selectedDate)
|
const events = CalendarService.getEventsForDate(selectedDate);
|
||||||
selectedDateEvents = events
|
selectedDateEvents = events;
|
||||||
} else {
|
} else {
|
||||||
selectedDateEvents = []
|
selectedDateEvents = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadEventsForMonth() {
|
function loadEventsForMonth() {
|
||||||
if (!CalendarService || !CalendarService.khalAvailable) {
|
if (!CalendarService || !CalendarService.khalAvailable) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstOfMonth = new Date(calendarGrid.displayDate.getFullYear(),
|
const firstOfMonth = new Date(calendarGrid.displayDate.getFullYear(), calendarGrid.displayDate.getMonth(), 1);
|
||||||
calendarGrid.displayDate.getMonth(), 1)
|
const lastOfMonth = new Date(calendarGrid.displayDate.getFullYear(), calendarGrid.displayDate.getMonth() + 1, 0);
|
||||||
const lastOfMonth = new Date(calendarGrid.displayDate.getFullYear(),
|
|
||||||
calendarGrid.displayDate.getMonth() + 1, 0)
|
|
||||||
|
|
||||||
const startDate = startOfWeek(firstOfMonth)
|
const startDate = startOfWeek(firstOfMonth);
|
||||||
startDate.setDate(startDate.getDate() - 7)
|
startDate.setDate(startDate.getDate() - 7);
|
||||||
|
|
||||||
const endDate = endOfWeek(lastOfMonth)
|
const endDate = endOfWeek(lastOfMonth);
|
||||||
endDate.setDate(endDate.getDate() + 7)
|
endDate.setDate(endDate.getDate() + 7);
|
||||||
|
|
||||||
CalendarService.loadEvents(startDate, endDate)
|
CalendarService.loadEvents(startDate, endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectedDateChanged: updateSelectedDateEvents()
|
onSelectedDateChanged: updateSelectedDateEvents()
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
loadEventsForMonth()
|
loadEventsForMonth();
|
||||||
updateSelectedDateEvents()
|
updateSelectedDateEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
function onEventsByDateChanged() {
|
function onEventsByDateChanged() {
|
||||||
updateSelectedDateEvents()
|
updateSelectedDateEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKhalAvailableChanged() {
|
function onKhalAvailableChanged() {
|
||||||
if (CalendarService && CalendarService.khalAvailable) {
|
if (CalendarService && CalendarService.khalAvailable) {
|
||||||
loadEventsForMonth()
|
loadEventsForMonth();
|
||||||
}
|
}
|
||||||
updateSelectedDateEvents()
|
updateSelectedDateEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
target: CalendarService
|
target: CalendarService
|
||||||
@@ -133,12 +130,12 @@ Rectangle {
|
|||||||
height: 40
|
height: 40
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
text: {
|
text: {
|
||||||
const dateStr = Qt.formatDate(selectedDate, "MMM d")
|
const dateStr = Qt.formatDate(selectedDate, "MMM d");
|
||||||
if (selectedDateEvents && selectedDateEvents.length > 0) {
|
if (selectedDateEvents && selectedDateEvents.length > 0) {
|
||||||
const eventCount = selectedDateEvents.length === 1 ? I18n.tr("1 event") : selectedDateEvents.length + " " + I18n.tr("events")
|
const eventCount = selectedDateEvents.length === 1 ? I18n.tr("1 event") : selectedDateEvents.length + " " + I18n.tr("events");
|
||||||
return dateStr + " • " + eventCount
|
return dateStr + " • " + eventCount;
|
||||||
}
|
}
|
||||||
return dateStr
|
return dateStr;
|
||||||
}
|
}
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
@@ -171,10 +168,10 @@ Rectangle {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
let newDate = new Date(calendarGrid.displayDate)
|
let newDate = new Date(calendarGrid.displayDate);
|
||||||
newDate.setMonth(newDate.getMonth() - 1)
|
newDate.setMonth(newDate.getMonth() - 1);
|
||||||
calendarGrid.displayDate = newDate
|
calendarGrid.displayDate = newDate;
|
||||||
loadEventsForMonth()
|
loadEventsForMonth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,10 +206,10 @@ Rectangle {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
let newDate = new Date(calendarGrid.displayDate)
|
let newDate = new Date(calendarGrid.displayDate);
|
||||||
newDate.setMonth(newDate.getMonth() + 1)
|
newDate.setMonth(newDate.getMonth() + 1);
|
||||||
calendarGrid.displayDate = newDate
|
calendarGrid.displayDate = newDate;
|
||||||
loadEventsForMonth()
|
loadEventsForMonth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,14 +222,14 @@ Rectangle {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
model: {
|
model: {
|
||||||
const days = []
|
const days = [];
|
||||||
const loc = Qt.locale()
|
const loc = Qt.locale();
|
||||||
const qtFirst = loc.firstDayOfWeek
|
const qtFirst = loc.firstDayOfWeek;
|
||||||
for (let i = 0; i < 7; ++i) {
|
for (let i = 0; i < 7; ++i) {
|
||||||
const qtDay = ((qtFirst - 1 + i) % 7) + 1
|
const qtDay = ((qtFirst - 1 + i) % 7) + 1;
|
||||||
days.push(loc.dayName(qtDay, Locale.ShortFormat))
|
days.push(loc.dayName(qtDay, Locale.ShortFormat));
|
||||||
}
|
}
|
||||||
return days
|
return days;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -259,8 +256,8 @@ Rectangle {
|
|||||||
property date selectedDate: systemClock.date
|
property date selectedDate: systemClock.date
|
||||||
|
|
||||||
readonly property date firstDay: {
|
readonly property date firstDay: {
|
||||||
const firstOfMonth = new Date(displayDate.getFullYear(), displayDate.getMonth(), 1)
|
const firstOfMonth = new Date(displayDate.getFullYear(), displayDate.getMonth(), 1);
|
||||||
return startOfWeek(firstOfMonth)
|
return startOfWeek(firstOfMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -273,9 +270,9 @@ Rectangle {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
readonly property date dayDate: {
|
readonly property date dayDate: {
|
||||||
const date = new Date(parent.firstDay)
|
const date = new Date(parent.firstDay);
|
||||||
date.setDate(date.getDate() + index)
|
date.setDate(date.getDate() + index);
|
||||||
return date
|
return date;
|
||||||
}
|
}
|
||||||
readonly property bool isCurrentMonth: dayDate.getMonth() === calendarGrid.displayDate.getMonth()
|
readonly property bool isCurrentMonth: dayDate.getMonth() === calendarGrid.displayDate.getMonth()
|
||||||
readonly property bool isToday: dayDate.toDateString() === new Date().toDateString()
|
readonly property bool isToday: dayDate.toDateString() === new Date().toDateString()
|
||||||
@@ -290,7 +287,7 @@ Rectangle {
|
|||||||
width: Math.min(parent.width - 4, parent.height - 4, 32)
|
width: Math.min(parent.width - 4, parent.height - 4, 32)
|
||||||
height: width
|
height: width
|
||||||
color: isToday ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : dayArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
color: isToday ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : dayArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.08) : "transparent"
|
||||||
radius: width / 2
|
radius: Theme.cornerRadius
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
@@ -306,7 +303,7 @@ Rectangle {
|
|||||||
anchors.bottomMargin: 4
|
anchors.bottomMargin: 4
|
||||||
width: 12
|
width: 12
|
||||||
height: 2
|
height: 2
|
||||||
radius: 1
|
radius: Theme.cornerRadius
|
||||||
visible: CalendarService && CalendarService.khalAvailable && CalendarService.hasEventsForDate(dayDate)
|
visible: CalendarService && CalendarService.khalAvailable && CalendarService.hasEventsForDate(dayDate)
|
||||||
color: isToday ? Qt.lighter(Theme.primary, 1.3) : Theme.primary
|
color: isToday ? Qt.lighter(Theme.primary, 1.3) : Theme.primary
|
||||||
opacity: isToday ? 0.9 : 0.7
|
opacity: isToday ? 0.9 : 0.7
|
||||||
@@ -327,8 +324,8 @@ Rectangle {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (CalendarService && CalendarService.khalAvailable && CalendarService.hasEventsForDate(dayDate)) {
|
if (CalendarService && CalendarService.khalAvailable && CalendarService.hasEventsForDate(dayDate)) {
|
||||||
root.selectedDate = dayDate
|
root.selectedDate = dayDate;
|
||||||
root.showEventDetails = true
|
root.showEventDetails = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -350,19 +347,19 @@ Rectangle {
|
|||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: {
|
color: {
|
||||||
if (modelData.url && eventMouseArea.containsMouse) {
|
if (modelData.url && eventMouseArea.containsMouse) {
|
||||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12)
|
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12);
|
||||||
} else if (eventMouseArea.containsMouse) {
|
} else if (eventMouseArea.containsMouse) {
|
||||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.06)
|
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.06);
|
||||||
}
|
}
|
||||||
return Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
|
return Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency);
|
||||||
}
|
}
|
||||||
border.color: {
|
border.color: {
|
||||||
if (modelData.url && eventMouseArea.containsMouse) {
|
if (modelData.url && eventMouseArea.containsMouse) {
|
||||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3)
|
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3);
|
||||||
} else if (eventMouseArea.containsMouse) {
|
} else if (eventMouseArea.containsMouse) {
|
||||||
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.15)
|
return Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.15);
|
||||||
}
|
}
|
||||||
return "transparent"
|
return "transparent";
|
||||||
}
|
}
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
|
||||||
@@ -372,7 +369,7 @@ Rectangle {
|
|||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 3
|
anchors.leftMargin: 3
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
radius: 2
|
radius: Theme.cornerRadius
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
opacity: 0.8
|
opacity: 0.8
|
||||||
}
|
}
|
||||||
@@ -401,16 +398,16 @@ Rectangle {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
text: {
|
text: {
|
||||||
if (!modelData || modelData.allDay) {
|
if (!modelData || modelData.allDay) {
|
||||||
return I18n.tr("All day")
|
return I18n.tr("All day");
|
||||||
} else if (modelData.start && modelData.end) {
|
} else if (modelData.start && modelData.end) {
|
||||||
const timeFormat = SettingsData.use24HourClock ? "HH:mm" : "h:mm AP"
|
const timeFormat = SettingsData.use24HourClock ? "HH:mm" : "h:mm AP";
|
||||||
const startTime = Qt.formatTime(modelData.start, timeFormat)
|
const startTime = Qt.formatTime(modelData.start, timeFormat);
|
||||||
if (modelData.start.toDateString() !== modelData.end.toDateString() || modelData.start.getTime() !== modelData.end.getTime()) {
|
if (modelData.start.toDateString() !== modelData.end.toDateString() || modelData.start.getTime() !== modelData.end.getTime()) {
|
||||||
return startTime + " – " + Qt.formatTime(modelData.end, timeFormat)
|
return startTime + " – " + Qt.formatTime(modelData.end, timeFormat);
|
||||||
}
|
}
|
||||||
return startTime
|
return startTime;
|
||||||
}
|
}
|
||||||
return ""
|
return "";
|
||||||
}
|
}
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.7)
|
||||||
@@ -429,9 +426,9 @@ Rectangle {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
if (modelData.url && modelData.url !== "") {
|
if (modelData.url && modelData.url !== "") {
|
||||||
if (Qt.openUrlExternally(modelData.url) === false) {
|
if (Qt.openUrlExternally(modelData.url) === false) {
|
||||||
console.warn("Failed to open URL: " + modelData.url)
|
console.warn("Failed to open URL: " + modelData.url);
|
||||||
} else {
|
} else {
|
||||||
root.closeDash()
|
root.closeDash();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ input_path = 'SHELL_DIR/matugen/templates/gtk-light-colors.css'
|
|||||||
output_path = '~/.config/gtk-3.0/dank-colors.css'
|
output_path = '~/.config/gtk-3.0/dank-colors.css'
|
||||||
|
|
||||||
[templates.dmsgtk4]
|
[templates.dmsgtk4]
|
||||||
input_path = 'SHELL_DIR/matugen/templates/gtk-light-colors.css'
|
input_path = 'SHELL_DIR/matugen/templates/gtk-colors.css'
|
||||||
output_path = '~/.config/gtk-4.0/dank-colors.css'
|
output_path = '~/.config/gtk-4.0/dank-colors.css'
|
||||||
|
|||||||
@@ -36,3 +36,13 @@ a color between surface and surface container so I think just giving this surfac
|
|||||||
@define-color popover_fg_color {{colors.on_surface.default.hex}};
|
@define-color popover_fg_color {{colors.on_surface.default.hex}};
|
||||||
@define-color dialog_bg_color {{colors.surface_container_lowest.default.hex}};
|
@define-color dialog_bg_color {{colors.surface_container_lowest.default.hex}};
|
||||||
@define-color dialog_fg_color {{colors.on_surface.default.hex}};
|
@define-color dialog_fg_color {{colors.on_surface.default.hex}};
|
||||||
|
|
||||||
|
/* Backdrop/unfocused states - prevents white flash on window unfocus */
|
||||||
|
@define-color headerbar_backdrop_color @window_bg_color;
|
||||||
|
@define-color sidebar_backdrop_color @sidebar_bg_color;
|
||||||
|
@define-color theme_unfocused_fg_color @window_fg_color;
|
||||||
|
@define-color theme_unfocused_text_color @view_fg_color;
|
||||||
|
@define-color theme_unfocused_bg_color @window_bg_color;
|
||||||
|
@define-color theme_unfocused_base_color @window_bg_color;
|
||||||
|
@define-color theme_unfocused_selected_bg_color @accent_bg_color;
|
||||||
|
@define-color theme_unfocused_selected_fg_color @accent_fg_color;
|
||||||
|
|||||||
Reference in New Issue
Block a user