Update next backup time label. By @real-yfprojects (#1180)

This commit is contained in:
yfprojects 2022-02-09 10:55:26 +00:00 committed by GitHub
parent da766c5172
commit de971d6cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 1 deletions

View File

@ -19,6 +19,10 @@ logger = logging.getLogger(__name__)
class VortaScheduler(QtCore.QObject):
#: The schedule for the profile with the given id changed.
schedule_changed = QtCore.pyqtSignal(int)
def __init__(self):
super().__init__()
self.timers = dict() # keep mapping of profiles to timers
@ -118,6 +122,9 @@ class VortaScheduler(QtCore.QObject):
self.lock.release()
# Emit signal so that e.g. the GUI can react to the new schedule
self.schedule_changed.emit(profile_id)
def reload_all_timers(self):
logger.debug('Refreshing all scheduler timers')
for profile in BackupProfileModel.select():

View File

@ -77,6 +77,9 @@ class ScheduleTab(ScheduleBase, ScheduleUI, BackupProfileMixin):
self.validationWeeksCount.valueChanged.connect(
lambda new_val, attr='validation_weeks': self.save_profile_attr(attr, new_val))
# Connect to schedule update
self.app.scheduler.schedule_changed.connect(lambda pid: self.draw_next_scheduled_backup())
def on_scheduler_change(self, _):
profile = self.profile()
# Save scheduler settings, apply new scheduler and display next task for profile.

View File

@ -1,10 +1,20 @@
from datetime import datetime as dt, date, time
from datetime import date
from datetime import datetime as dt
from datetime import time
from PyQt5 import QtCore
def test_schedule_tab(qapp, qtbot):
main = qapp.main_window
tab = main.scheduleTab
# Work around
# because already 'deleted' scheduletabs are still connected to the signal
qapp.scheduler.schedule_changed.disconnect()
qapp.scheduler.schedule_changed.connect(lambda *args: tab.draw_next_scheduled_backup())
# Test
qtbot.mouseClick(tab.scheduleOffRadio, QtCore.Qt.LeftButton)
assert tab.nextBackupDateTimeLabel.text() == 'None scheduled'