From d0893bc1c782e6ec6c4a9af2760ee0134b383532 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 20 Oct 2013 13:46:55 +0300 Subject: [PATCH] Allow the scheduler to have a start time that's after the end time. Closes #980. --- src/preferences/options_imp.cpp | 2 -- src/qtlibtorrent/bandwidthscheduler.h | 13 ++++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index cd0b3243e..588353c83 100755 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -1414,8 +1414,6 @@ bool options_imp::schedTimesOk() { if (schedule_from->time() == schedule_to->time()) msg = tr("The start time and the end time can't be the same."); - else if (schedule_from->time() > schedule_to->time()) - msg = tr("The start time can't be after the end time."); if (!msg.isEmpty()) { QMessageBox::critical(this, tr("Time Error"), msg); diff --git a/src/qtlibtorrent/bandwidthscheduler.h b/src/qtlibtorrent/bandwidthscheduler.h index 5b918d814..8e1b706d3 100644 --- a/src/qtlibtorrent/bandwidthscheduler.h +++ b/src/qtlibtorrent/bandwidthscheduler.h @@ -32,8 +32,16 @@ public slots: int sched_days = pref.getSchedulerDays(); int day = QDateTime::currentDateTime().toLocalTime().date().dayOfWeek(); bool new_mode = false; + bool reverse = false; - if (start < end && start <= now && end >= now) { + if (start > end) { + QTime temp = start; + start = end; + end = temp; + reverse = true; + } + + if (start <= now && end >= now) { switch(sched_days) { case EVERY_DAY: new_mode = true; @@ -53,6 +61,9 @@ public slots: } } + if (reverse) + new_mode = !new_mode; + if (new_mode != alt_bw_enabled) emit switchToAlternativeMode(new_mode);