mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 08:17:49 -06:00
STAR-322: Improvements to date calculation and signalling
This commit is contained in:
parent
4f82a2759a
commit
2b8358fda8
2 changed files with 12 additions and 15 deletions
|
@ -1,10 +1,9 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from time import time
|
||||
from typing import Dict, List, Optional, Set
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from PyQt5.QtCore import QObject, QUrl, pyqtProperty, pyqtSignal, pyqtSlot
|
||||
|
||||
|
@ -215,8 +214,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|||
if not self._active_printer:
|
||||
self.setActivePrinter(self._printers[0])
|
||||
|
||||
if removed_printers or added_printers or updated_printers:
|
||||
self._clusterPrintersChanged.emit()
|
||||
self.printersChanged.emit()
|
||||
|
||||
## Updates the local list of print jobs with the list received from the cloud.
|
||||
# \param jobs: The print jobs received from the cloud.
|
||||
|
@ -388,12 +386,10 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
@pyqtSlot(int, result = str)
|
||||
def formatDuration(self, seconds: int) -> str:
|
||||
# TODO: this really shouldn't be in this class
|
||||
return Duration(seconds).getDisplayString(DurationFormat.Format.Short)
|
||||
|
||||
@pyqtSlot(int, result = str)
|
||||
def getTimeCompleted(self, time_remaining: int) -> str:
|
||||
# TODO: this really shouldn't be in this class
|
||||
return formatTimeCompleted(time_remaining)
|
||||
|
||||
@pyqtSlot(int, result = str)
|
||||
|
@ -413,7 +409,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|||
|
||||
@pyqtProperty(bool, notify = printJobsChanged)
|
||||
def receivedPrintJobs(self) -> bool:
|
||||
return True
|
||||
return bool(self._print_jobs)
|
||||
|
||||
@pyqtSlot()
|
||||
def openPrintJobControlPanel(self) -> None:
|
||||
|
|
|
@ -29,24 +29,25 @@ def findChanges(previous: Dict[str, T], received: Dict[str, U]) -> Tuple[List[T]
|
|||
return removed, added, updated
|
||||
|
||||
|
||||
def formatTimeCompleted(time_remaining: int) -> str:
|
||||
completed = datetime.now() + timedelta(seconds=time_remaining)
|
||||
def formatTimeCompleted(seconds_remaining: int) -> str:
|
||||
completed = datetime.now() + timedelta(seconds=seconds_remaining)
|
||||
return "{hour:02d}:{minute:02d}".format(hour = completed.hour, minute = completed.minute)
|
||||
|
||||
|
||||
def formatDateCompleted(time_remaining: int) -> str:
|
||||
remaining = timedelta(seconds=time_remaining)
|
||||
completed = datetime.now() + remaining
|
||||
def formatDateCompleted(seconds_remaining: int) -> str:
|
||||
now = datetime.now()
|
||||
completed = now + timedelta(seconds=seconds_remaining)
|
||||
days = (completed.date() - now.date()).days
|
||||
i18n = i18nCatalog("cura")
|
||||
|
||||
# If finishing date is more than 7 days out, using "Mon Dec 3 at HH:MM" format
|
||||
if remaining.days >= 7:
|
||||
if days >= 7:
|
||||
return completed.strftime("%a %b ") + "{day}".format(day = completed.day)
|
||||
# If finishing date is within the next week, use "Monday at HH:MM" format
|
||||
elif remaining.days >= 2:
|
||||
elif days >= 2:
|
||||
return completed.strftime("%a")
|
||||
# If finishing tomorrow, use "tomorrow at HH:MM" format
|
||||
elif remaining.days >= 1:
|
||||
elif days >= 1:
|
||||
return i18n.i18nc("@info:status", "tomorrow")
|
||||
# If finishing today, use "today at HH:MM" format
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue