Преглед изворни кода

Expiry Warning removed

Removed warning for impending currency expiry as the implementation was obnoxious. If desired at a later stage, should be redesigned from the ground up.
Felix Turo пре 3 година
родитељ
комит
dcc969bbff

+ 14 - 14
CMakeLists.txt

@@ -124,20 +124,20 @@ set(PROJECT_SOURCES
 # https://bugreports.qt.io/browse/QTBUG-76410
 # Before working on the translations themselves, check for updates and consider not updating for
 # every build due to danger of loss of translations...
-if (Qt5Widgets_FOUND)
-    if (Qt5Widgets_VERSION VERSION_LESS 5.15.0)
-        message("Translations are available for Qt5 version >= 5.15")
-    else()
-        message("Qt > 5.15 detected. Enabling translations.")
-        set(TS_FILES
-            l10n/openpilotlog_en.ts
-            l10n/openpilotlog_de.ts
-            l10n/openpilotlog_es.ts
-        )
-        set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "l10n")
-        qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
-    endif(Qt5Widgets_VERSION VERSION_LESS 5.15.0)
-endif(Qt5Widgets_FOUND)
+#if (Qt5Widgets_FOUND)
+#    if (Qt5Widgets_VERSION VERSION_LESS 5.15.0)
+#        message("Translations are available for Qt5 version >= 5.15")
+#    else()
+#        message("Qt > 5.15 detected. Enabling translations.")
+#        set(TS_FILES
+#            l10n/openpilotlog_en.ts
+#            l10n/openpilotlog_de.ts
+#            l10n/openpilotlog_es.ts
+#        )
+#        set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "l10n")
+#        qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
+#    endif(Qt5Widgets_VERSION VERSION_LESS 5.15.0)
+#endif(Qt5Widgets_FOUND)
 
 if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
     qt_add_executable(openPilotLog

+ 0 - 38
src/gui/widgets/homewidget.cpp

@@ -37,7 +37,6 @@ HomeWidget::HomeWidget(QWidget *parent) :
 {
     ui->setupUi(this);
     today = QDate::currentDate();
-    currWarningThreshold = ASettings::read(ASettings::UserData::CurrWarningThreshold).toInt();
     ftlWarningThreshold = ASettings::read(ASettings::UserData::FtlWarningThreshold).toDouble();
     auto logo = QPixmap(Opl::Assets::LOGO);
     ui->logoLabel->setPixmap(logo);
@@ -54,10 +53,6 @@ HomeWidget::HomeWidget(QWidget *parent) :
     fillTotals();
     fillSelectedCurrencies();
     fillLimitations();
-
-    // This implementation is annoying. Review or remove.
-    //if (ASettings::read(ASettings::UserData::CurrWarningEnabled).toBool())
-    //    warnCurrencies();
 }
 
 HomeWidget::~HomeWidget()
@@ -71,7 +66,6 @@ void HomeWidget::refresh()
     const auto label_list = this->findChildren<QLabel *>();
     for (const auto label : label_list)
         label->setVisible(true);
-    currWarningThreshold = ASettings::read(ASettings::UserData::CurrWarningThreshold).toInt();
     for (const auto &label : qAsConst(limitationDisplayLabels))
         label->setStyleSheet(QString());
 
@@ -215,38 +209,6 @@ void HomeWidget::fillLimitations()
     }
 }
 
-/*!
- * \brief HomeWidget::warnCurrencies loops through all the currencies and warns the user about
- * impending expiries.
- */
-void HomeWidget::warnCurrencies()
-{
-    for (int i = 1 ; i <= 6; i++) {
-        // Get the Currency entry
-        auto entry = aDB->getCurrencyEntry(ACurrencyEntry::CurrencyName(i));
-        const auto currency_date = entry.getData().value(Opl::Db::CURRENCIES_EXPIRYDATE).toDate();
-        if (!currency_date.isValid())
-            continue;
-        const auto currency_name = entry.getData().value(Opl::Db::CURRENCIES_DESCRIPTION).toString();
-
-        // check expiration dates
-        if (today >= currency_date) {
-            // is expired
-            WARN(tr("Your currency <b>%1</b> is expired since %2.<br><br>")
-                 .arg(currency_name,
-                      currency_date.toString(Qt::TextDate)));
-            continue;
-        } else if (today.addDays(currWarningThreshold) >=currency_date) {
-            // expires less than <currWarningThreshold> days from current Date
-            QString days_to_expiry = QString::number(today.daysTo(currency_date));
-            WARN(tr("Your currency <b>%1</b> expires in <b>%2</b> days (%3).<br><br>")
-                 .arg(currency_name,
-                      days_to_expiry,
-                      currency_date.toString(Qt::TextDate)));
-        }
-    }
-}
-
 const QString HomeWidget::userName()
 {
     const auto statement = QStringLiteral("SELECT firstname FROM pilots WHERE ROWID=1");

+ 1 - 2
src/gui/widgets/homewidget.h

@@ -57,7 +57,7 @@ private:
      * \brief currWarningThreshold - Retreived from ASettings::UserData::CurrWarningThreshold, the number
      * of days before expiry that the user gets notified about impending expiries.
      */
-    int            currWarningThreshold;
+    int currWarningThreshold = 30;
     /*!
      * \brief ftlWarningThreshold - Retreived from ASettings::UserData::FtlWarningThreshold, the percentage
      * of how close the user has to be to reaching a Flight Time Limitation before getting notified.
@@ -98,7 +98,6 @@ private:
      * \brief Retreives the users first name from the database.
      */
     const QString userName();
-    void warnCurrencies();
 
 public slots:
     void refresh();

+ 0 - 24
src/gui/widgets/settingswidget.cpp

@@ -178,12 +178,9 @@ void SettingsWidget::readSettings()
     ui->currMedCheckBox->setChecked(ASettings::read(ASettings::UserData::ShowMedCurrency).toBool());
     ui->currCustom1CheckBox->setChecked(ASettings::read(ASettings::UserData::ShowCustom1Currency).toBool());
     ui->currCustom2CheckBox->setChecked(ASettings::read(ASettings::UserData::ShowCustom2Currency).toBool());
-    ui->currWarningThresholdSpinBox->setValue(ASettings::read(ASettings::UserData::CurrWarningThreshold).toInt());
-    ui->currWarningCheckBox->setChecked(ASettings::read(ASettings::UserData::CurrWarningEnabled).toBool());
     ui->currCustom1LineEdit->setText(ASettings::read(ASettings::UserData::Custom1CurrencyName).toString());
     ui->currCustom2LineEdit->setText(ASettings::read(ASettings::UserData::Custom2CurrencyName).toString());
 
-
     /*
      * Misc Tab
      */
@@ -678,27 +675,6 @@ void SettingsWidget::on_currCustom2CheckBox_stateChanged(int arg1)
     emit settingChanged(HomeWidget);
 }
 
-void SettingsWidget::on_currWarningCheckBox_stateChanged(int arg1)
-{
-    switch (arg1) {
-    case Qt::CheckState::Checked:
-        ASettings::write(ASettings::UserData::CurrWarningEnabled, true);
-        break;
-    case Qt::CheckState::Unchecked:
-        ASettings::write(ASettings::UserData::CurrWarningEnabled, false);
-        break;
-    default:
-        break;
-    }
-    emit settingChanged(HomeWidget);
-}
-
-void SettingsWidget::on_currWarningThresholdSpinBox_valueChanged(int arg1)
-{
-    ASettings::write(ASettings::UserData::CurrWarningThreshold, arg1);
-    emit settingChanged(SettingSignal::HomeWidget);
-}
-
 void SettingsWidget::on_currCustom1LineEdit_editingFinished()
 {
     ASettings::write(ASettings::UserData::Custom1CurrencyName, ui->currCustom1LineEdit->text());

+ 0 - 4
src/gui/widgets/settingswidget.h

@@ -105,10 +105,6 @@ private slots:
 
     void on_currCustom2CheckBox_stateChanged(int arg1);
 
-    void on_currWarningCheckBox_stateChanged(int arg1);
-
-    void on_currWarningThresholdSpinBox_valueChanged(int arg1);
-
     void on_currCustom1LineEdit_editingFinished();
 
     void on_currCustom2LineEdit_editingFinished();

+ 119 - 205
src/gui/widgets/settingswidget.ui

@@ -17,7 +17,7 @@
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
-      <number>3</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="personalTab">
       <attribute name="title">
@@ -371,76 +371,56 @@
       <attribute name="title">
        <string>Currencies</string>
       </attribute>
-      <layout class="QGridLayout" name="gridLayout_7">
-       <item row="0" column="2">
-        <spacer name="verticalSpacer_2">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>35</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item row="1" column="0">
-        <widget class="QLabel" name="headerCurrencyLabel">
+      <layout class="QGridLayout" name="gridLayout_6">
+       <item row="3" column="3">
+        <widget class="QCheckBox" name="currToLdgCheckBox">
          <property name="minimumSize">
           <size>
-           <width>280</width>
+           <width>140</width>
            <height>0</height>
           </size>
          </property>
-         <property name="text">
-          <string>Currency</string>
+         <property name="layoutDirection">
+          <enum>Qt::LeftToRight</enum>
          </property>
-         <property name="alignment">
-          <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
+         <property name="text">
+          <string/>
          </property>
         </widget>
        </item>
-       <item row="1" column="3">
-        <widget class="QLabel" name="headerExpirationLabel">
+       <item row="8" column="0">
+        <widget class="QLineEdit" name="currCustom1LineEdit">
          <property name="minimumSize">
           <size>
-           <width>140</width>
+           <width>280</width>
            <height>0</height>
           </size>
          </property>
          <property name="text">
-          <string>Expiration Date</string>
+          <string/>
          </property>
-         <property name="alignment">
-          <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
+         <property name="placeholderText">
+          <string>custom currency</string>
          </property>
         </widget>
        </item>
-       <item row="1" column="4">
-        <widget class="QLabel" name="headerShowLabel">
+       <item row="5" column="3">
+        <widget class="QCheckBox" name="currTrCheckBox">
          <property name="minimumSize">
           <size>
            <width>140</width>
            <height>0</height>
           </size>
          </property>
-         <property name="text">
-          <string>Show on Home Page</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
+         <property name="layoutDirection">
+          <enum>Qt::LeftToRight</enum>
          </property>
-        </widget>
-       </item>
-       <item row="2" column="0" colspan="5">
-        <widget class="Line" name="line">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
+         <property name="text">
+          <string/>
          </property>
         </widget>
        </item>
-       <item row="3" column="0" rowspan="2">
+       <item row="3" column="0">
         <widget class="QLabel" name="currToLdgLabel">
          <property name="minimumSize">
           <size>
@@ -449,15 +429,25 @@
           </size>
          </property>
          <property name="text">
-          <string>Take-off / Landing (automatic)</string>
+          <string>Take-off / Landing (days)</string>
          </property>
         </widget>
        </item>
-       <item row="4" column="3" rowspan="2">
-        <widget class="QDateEdit" name="currToLdgDateEdit">
-         <property name="enabled">
-          <bool>false</bool>
+       <item row="1" column="1">
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>168</height>
+          </size>
          </property>
+        </spacer>
+       </item>
+       <item row="4" column="2">
+        <widget class="QDateEdit" name="currLicDateEdit">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -473,6 +463,9 @@
          <property name="calendarPopup">
           <bool>true</bool>
          </property>
+         <property name="timeSpec">
+          <enum>Qt::UTC</enum>
+         </property>
          <property name="date">
           <date>
            <year>2020</year>
@@ -482,37 +475,8 @@
          </property>
         </widget>
        </item>
-       <item row="5" column="4">
-        <widget class="QCheckBox" name="currToLdgCheckBox">
-         <property name="minimumSize">
-          <size>
-           <width>140</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="layoutDirection">
-          <enum>Qt::LeftToRight</enum>
-         </property>
-         <property name="text">
-          <string/>
-         </property>
-        </widget>
-       </item>
-       <item row="6" column="0">
-        <widget class="QLabel" name="currLicLabel">
-         <property name="minimumSize">
-          <size>
-           <width>280</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>Licence</string>
-         </property>
-        </widget>
-       </item>
-       <item row="6" column="3">
-        <widget class="QDateEdit" name="currLicDateEdit">
+       <item row="5" column="2">
+        <widget class="QDateEdit" name="currTrDateEdit">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -540,8 +504,8 @@
          </property>
         </widget>
        </item>
-       <item row="6" column="4">
-        <widget class="QCheckBox" name="currLicCheckBox">
+       <item row="9" column="3">
+        <widget class="QCheckBox" name="currCustom2CheckBox">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -556,21 +520,8 @@
          </property>
         </widget>
        </item>
-       <item row="7" column="0">
-        <widget class="QLabel" name="currTrLabel">
-         <property name="minimumSize">
-          <size>
-           <width>280</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="text">
-          <string>Type Rating</string>
-         </property>
-        </widget>
-       </item>
-       <item row="7" column="3">
-        <widget class="QDateEdit" name="currTrDateEdit">
+       <item row="7" column="2">
+        <widget class="QDateEdit" name="currMedDateEdit">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -598,8 +549,31 @@
          </property>
         </widget>
        </item>
-       <item row="7" column="4">
-        <widget class="QCheckBox" name="currTrCheckBox">
+       <item row="3" column="2">
+        <widget class="QSpinBox" name="currToLdgSpinBox">
+         <property name="toolTip">
+          <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Number of days for TO/LDG currency. Default 90&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+         </property>
+         <property name="value">
+          <number>90</number>
+         </property>
+        </widget>
+       </item>
+       <item row="7" column="0">
+        <widget class="QLabel" name="currMedLabel">
+         <property name="minimumSize">
+          <size>
+           <width>280</width>
+           <height>0</height>
+          </size>
+         </property>
+         <property name="text">
+          <string>Medical</string>
+         </property>
+        </widget>
+       </item>
+       <item row="8" column="3">
+        <widget class="QCheckBox" name="currCustom1CheckBox">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -614,20 +588,20 @@
          </property>
         </widget>
        </item>
-       <item row="8" column="0">
-        <widget class="QLabel" name="currLckLabel">
+       <item row="9" column="0">
+        <widget class="QLineEdit" name="currCustom2LineEdit">
          <property name="minimumSize">
           <size>
            <width>280</width>
            <height>0</height>
           </size>
          </property>
-         <property name="text">
-          <string>Line Check</string>
+         <property name="placeholderText">
+          <string>custom currency</string>
          </property>
         </widget>
        </item>
-       <item row="8" column="3">
+       <item row="6" column="2">
         <widget class="QDateEdit" name="currLckDateEdit">
          <property name="minimumSize">
           <size>
@@ -656,24 +630,21 @@
          </property>
         </widget>
        </item>
-       <item row="8" column="4">
-        <widget class="QCheckBox" name="currLckCheckBox">
+       <item row="6" column="0">
+        <widget class="QLabel" name="currLckLabel">
          <property name="minimumSize">
           <size>
-           <width>140</width>
+           <width>280</width>
            <height>0</height>
           </size>
          </property>
-         <property name="layoutDirection">
-          <enum>Qt::LeftToRight</enum>
-         </property>
          <property name="text">
-          <string/>
+          <string>Line Check</string>
          </property>
         </widget>
        </item>
-       <item row="9" column="0">
-        <widget class="QLabel" name="currMedLabel">
+       <item row="5" column="0">
+        <widget class="QLabel" name="currTrLabel">
          <property name="minimumSize">
           <size>
            <width>280</width>
@@ -681,41 +652,25 @@
           </size>
          </property>
          <property name="text">
-          <string>Medical</string>
+          <string>Type Rating</string>
          </property>
         </widget>
        </item>
-       <item row="9" column="3">
-        <widget class="QDateEdit" name="currMedDateEdit">
+       <item row="4" column="0">
+        <widget class="QLabel" name="currLicLabel">
          <property name="minimumSize">
           <size>
-           <width>140</width>
+           <width>280</width>
            <height>0</height>
           </size>
          </property>
-         <property name="currentSection">
-          <enum>QDateTimeEdit::MonthSection</enum>
-         </property>
-         <property name="displayFormat">
-          <string>MM/dd/yyyy</string>
-         </property>
-         <property name="calendarPopup">
-          <bool>true</bool>
-         </property>
-         <property name="timeSpec">
-          <enum>Qt::UTC</enum>
-         </property>
-         <property name="date">
-          <date>
-           <year>2020</year>
-           <month>1</month>
-           <day>1</day>
-          </date>
+         <property name="text">
+          <string>Licence</string>
          </property>
         </widget>
        </item>
-       <item row="9" column="4">
-        <widget class="QCheckBox" name="currMedCheckBox">
+       <item row="6" column="3">
+        <widget class="QCheckBox" name="currLckCheckBox">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -730,24 +685,21 @@
          </property>
         </widget>
        </item>
-       <item row="10" column="0">
-        <widget class="QLineEdit" name="currCustom1LineEdit">
-         <property name="minimumSize">
+       <item row="10" column="1">
+        <spacer name="verticalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
           <size>
-           <width>280</width>
-           <height>0</height>
+           <width>20</width>
+           <height>167</height>
           </size>
          </property>
-         <property name="text">
-          <string/>
-         </property>
-         <property name="placeholderText">
-          <string>custom currency</string>
-         </property>
-        </widget>
+        </spacer>
        </item>
-       <item row="10" column="3">
-        <widget class="QDateEdit" name="currCustom1DateEdit">
+       <item row="9" column="2">
+        <widget class="QDateEdit" name="currCustom2DateEdit">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -775,8 +727,8 @@
          </property>
         </widget>
        </item>
-       <item row="10" column="4">
-        <widget class="QCheckBox" name="currCustom1CheckBox">
+       <item row="4" column="3">
+        <widget class="QCheckBox" name="currLicCheckBox">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -791,21 +743,8 @@
          </property>
         </widget>
        </item>
-       <item row="11" column="0">
-        <widget class="QLineEdit" name="currCustom2LineEdit">
-         <property name="minimumSize">
-          <size>
-           <width>280</width>
-           <height>0</height>
-          </size>
-         </property>
-         <property name="placeholderText">
-          <string>custom currency</string>
-         </property>
-        </widget>
-       </item>
-       <item row="11" column="3">
-        <widget class="QDateEdit" name="currCustom2DateEdit">
+       <item row="8" column="2">
+        <widget class="QDateEdit" name="currCustom1DateEdit">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -833,8 +772,8 @@
          </property>
         </widget>
        </item>
-       <item row="11" column="4">
-        <widget class="QCheckBox" name="currCustom2CheckBox">
+       <item row="7" column="3">
+        <widget class="QCheckBox" name="currMedCheckBox">
          <property name="minimumSize">
           <size>
            <width>140</width>
@@ -849,46 +788,21 @@
          </property>
         </widget>
        </item>
-       <item row="12" column="0" colspan="5">
-        <widget class="Line" name="line_2">
-         <property name="orientation">
-          <enum>Qt::Horizontal</enum>
-         </property>
-        </widget>
-       </item>
-       <item row="13" column="1">
-        <layout class="QGridLayout" name="gridLayout_6">
-         <item row="0" column="0">
-          <widget class="QCheckBox" name="currWarningCheckBox">
-           <property name="text">
-            <string>Warn me about expiring currencies</string>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="1">
-          <widget class="QSpinBox" name="currWarningThresholdSpinBox"/>
-         </item>
-         <item row="0" column="2">
-          <widget class="QLabel" name="label">
-           <property name="text">
-            <string>days before expiry</string>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </item>
-       <item row="14" column="1">
-        <spacer name="verticalSpacer">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
+       <item row="2" column="3">
+        <widget class="QLabel" name="headerShowLabel">
+         <property name="minimumSize">
           <size>
-           <width>20</width>
-           <height>35</height>
+           <width>140</width>
+           <height>0</height>
           </size>
          </property>
-        </spacer>
+         <property name="text">
+          <string>Show on Home Page</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
+         </property>
+        </widget>
        </item>
       </layout>
      </widget>