From 728957c46a4dadfcda0dc45ffa60ac7637297ed0 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Tue, 26 Aug 2014 23:26:00 +0000 Subject: [PATCH] (trunk, qt) #5774 'Alternative Speed Limits Scheduled Times broken in transmission-qt' -- fixed, plus more gratuitous c++11isms --- qt/prefs-dialog.cc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/qt/prefs-dialog.cc b/qt/prefs-dialog.cc index ff16a113b..e75c3dd96 100644 --- a/qt/prefs-dialog.cc +++ b/qt/prefs-dialog.cc @@ -116,28 +116,28 @@ PrefsDialog :: doubleSpinBoxNew (int key, double low, double high, double step, } void -PrefsDialog :: timeEditingFinished () +PrefsDialog::timeEditingFinished() { - QTimeEdit * e = qobject_cast(sender()); - if (e) + auto e = qobject_cast(sender()); + if (e != nullptr) { - const int key (e->property (PREF_KEY).toInt ()); - const QTime time (e->time ()); - const int seconds (QTime().secsTo (time)); - setPref (key, seconds / 60); + const int key {e->property(PREF_KEY).toInt()}; + const QTime t {e->time()}; + const int minutes_after_midnight {t.hour()*60 + t.minute()}; + setPref(key, minutes_after_midnight); } } QTimeEdit* -PrefsDialog :: timeEditNew (int key) -{ - const int minutes (myPrefs.getInt (key)); - QTimeEdit * e = new QTimeEdit (); - e->setDisplayFormat (QString::fromUtf8 ("hh:mm")); - e->setProperty (PREF_KEY, key); - e->setTime (QTime().addSecs (minutes * 60)); - myWidgets.insert (key, e); - connect (e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished())); +PrefsDialog::timeEditNew (int key) +{ + const int minutes {myPrefs.getInt(key)}; + auto e = new QTimeEdit{}; + e->setDisplayFormat(QString::fromUtf8("hh:mm")); + e->setProperty(PREF_KEY, key); + e->setTime(QTime{minutes/60, minutes%60}); + myWidgets.insert(key, e); + connect(e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished())); return e; } -- 2.40.0