mirror of https://github.com/borgbase/vorta
Update next backup time label. By @real-yfprojects (#1180)
This commit is contained in:
parent
da766c5172
commit
de971d6cd3
|
@ -19,6 +19,10 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class VortaScheduler(QtCore.QObject):
|
class VortaScheduler(QtCore.QObject):
|
||||||
|
|
||||||
|
#: The schedule for the profile with the given id changed.
|
||||||
|
schedule_changed = QtCore.pyqtSignal(int)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.timers = dict() # keep mapping of profiles to timers
|
self.timers = dict() # keep mapping of profiles to timers
|
||||||
|
@ -118,6 +122,9 @@ class VortaScheduler(QtCore.QObject):
|
||||||
|
|
||||||
self.lock.release()
|
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):
|
def reload_all_timers(self):
|
||||||
logger.debug('Refreshing all scheduler timers')
|
logger.debug('Refreshing all scheduler timers')
|
||||||
for profile in BackupProfileModel.select():
|
for profile in BackupProfileModel.select():
|
||||||
|
|
|
@ -77,6 +77,9 @@ class ScheduleTab(ScheduleBase, ScheduleUI, BackupProfileMixin):
|
||||||
self.validationWeeksCount.valueChanged.connect(
|
self.validationWeeksCount.valueChanged.connect(
|
||||||
lambda new_val, attr='validation_weeks': self.save_profile_attr(attr, new_val))
|
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, _):
|
def on_scheduler_change(self, _):
|
||||||
profile = self.profile()
|
profile = self.profile()
|
||||||
# Save scheduler settings, apply new scheduler and display next task for profile.
|
# Save scheduler settings, apply new scheduler and display next task for profile.
|
||||||
|
|
|
@ -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
|
from PyQt5 import QtCore
|
||||||
|
|
||||||
|
|
||||||
def test_schedule_tab(qapp, qtbot):
|
def test_schedule_tab(qapp, qtbot):
|
||||||
main = qapp.main_window
|
main = qapp.main_window
|
||||||
tab = main.scheduleTab
|
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)
|
qtbot.mouseClick(tab.scheduleOffRadio, QtCore.Qt.LeftButton)
|
||||||
assert tab.nextBackupDateTimeLabel.text() == 'None scheduled'
|
assert tab.nextBackupDateTimeLabel.text() == 'None scheduled'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue