Add daily update channel.
authorCamila Ayres <hello@camilasan.com>
Mon, 15 Apr 2024 18:59:50 +0000 (20:59 +0200)
committerCamila Ayres <hello@camilasan.com>
Wed, 3 Jul 2024 14:32:09 +0000 (16:32 +0200)
- Set update channel options list in slotUpdateInfo.

Signed-off-by: Camila Ayres <hello@camilasan.com>
src/gui/generalsettings.cpp
src/gui/generalsettings.ui
src/libsync/configfile.cpp
src/libsync/configfile.h

index b57745fc2c9b20b34b177c08813dfae9b7d28723..1c77cf42e1819d5154a3b5292ea2cfae456ed8e7 100644 (file)
@@ -340,8 +340,12 @@ void GeneralSettings::slotUpdateInfo()
     }
 #endif
 
-    // Channel selection
-    _ui->updateChannel->setCurrentIndex(ConfigFile().updateChannel() == "beta" ? 1 : 0);
+    // stable, beta, daily
+    ConfigFile config;
+    const auto validUpdateChannels = config.validUpdateChannels();
+    const auto currentUpdateChannelIndex = validUpdateChannels.indexOf(config.updateChannel());
+    _ui->updateChannel->addItems(validUpdateChannels);
+    _ui->updateChannel->setCurrentIndex(currentUpdateChannelIndex);
     connect(_ui->updateChannel, &QComboBox::currentTextChanged,
         this, &GeneralSettings::slotUpdateChannelChanged, Qt::UniqueConnection);
 }
@@ -355,17 +359,24 @@ void GeneralSettings::slotUpdateChannelChanged()
             decodedTranslatedChannel = tr("stable");
         } else if (channel == QStringLiteral("beta")) {
             decodedTranslatedChannel = tr("beta");
+        } else if (channel == QStringLiteral("daily")) {
+            decodedTranslatedChannel = tr("daily");
         }
 
         return decodedTranslatedChannel;
     };
 
     const auto updateChannelFromLocalized = [](const int index) {
-        if (index == 1) {
+        switch(index) {
+        case 1:
             return QStringLiteral("beta");
+            break;
+        case 2:
+            return QStringLiteral("daily");
+            break;
+        default:
+            return QStringLiteral("stable");
         }
-
-        return QStringLiteral("stable");
     };
 
     const auto channel = updateChannelFromLocalized(_ui->updateChannel->currentIndex());
index 54f79b55d47508480ba337fe4b55209c62f9571b..aac6ea6ab82ba682e6ae30c032f01888214f3d30 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>601</width>
+    <width>667</width>
     <height>663</height>
    </rect>
   </property>
           <item>
            <spacer name="horizontalSpacer">
             <property name="orientation">
-             <enum>Qt::Horizontal</enum>
+             <enum>Qt::Orientation::Horizontal</enum>
             </property>
             <property name="sizeType">
-             <enum>QSizePolicy::Fixed</enum>
+             <enum>QSizePolicy::Policy::Fixed</enum>
             </property>
             <property name="sizeHint" stdset="0">
              <size>
           <item>
            <spacer name="horizontalSpacer_3">
             <property name="orientation">
-             <enum>Qt::Horizontal</enum>
+             <enum>Qt::Orientation::Horizontal</enum>
             </property>
             <property name="sizeType">
-             <enum>QSizePolicy::Fixed</enum>
+             <enum>QSizePolicy::Policy::Fixed</enum>
             </property>
             <property name="sizeHint" stdset="0">
              <size>
           <item>
            <spacer name="horizontalSpacer_5">
             <property name="orientation">
-             <enum>Qt::Horizontal</enum>
+             <enum>Qt::Orientation::Horizontal</enum>
             </property>
             <property name="sizeType">
-             <enum>QSizePolicy::Fixed</enum>
+             <enum>QSizePolicy::Policy::Fixed</enum>
             </property>
             <property name="sizeHint" stdset="0">
              <size>
         <item>
          <spacer name="horizontalSpacer_4">
           <property name="orientation">
-           <enum>Qt::Horizontal</enum>
+           <enum>Qt::Orientation::Horizontal</enum>
           </property>
           <property name="sizeHint" stdset="0">
            <size>
                <verstretch>0</verstretch>
               </sizepolicy>
              </property>
-             <item>
-              <property name="text">
-               <string>stable</string>
-              </property>
-             </item>
-             <item>
-              <property name="text">
-               <string>beta</string>
-              </property>
-             </item>
             </widget>
            </item>
            <item>
            <item>
             <spacer name="horizontalSpacer_6">
              <property name="orientation">
-              <enum>Qt::Horizontal</enum>
+              <enum>Qt::Orientation::Horizontal</enum>
              </property>
              <property name="sizeHint" stdset="0">
               <size>
            <item>
             <spacer name="horizontalSpacer_2">
              <property name="orientation">
-              <enum>Qt::Horizontal</enum>
+              <enum>Qt::Orientation::Horizontal</enum>
              </property>
              <property name="sizeHint" stdset="0">
               <size>
    <item row="4" column="0">
     <spacer name="verticalSpacer">
      <property name="orientation">
-      <enum>Qt::Vertical</enum>
+      <enum>Qt::Orientation::Vertical</enum>
      </property>
      <property name="sizeHint" stdset="0">
       <size>
index abc9eb8a84a605872b7be98c95aa3e7718a87aac..f70dfe2b36e66802acc0b4b73777bca9edd5082b 100644 (file)
@@ -109,8 +109,6 @@ static constexpr char forceLoginV2C[] = "forceLoginV2";
 
 static constexpr char certPath[] = "http_certificatePath";
 static constexpr char certPasswd[] = "http_certificatePasswd";
-
-static const QSet validUpdateChannels { QStringLiteral("stable"), QStringLiteral("beta") };
 }
 
 namespace OCC {
@@ -700,7 +698,7 @@ QString ConfigFile::updateChannel() const
 
     QSettings settings(configFile(), QSettings::IniFormat);
     const auto channel = settings.value(QLatin1String(updateChannelC), defaultUpdateChannel).toString();
-    if (!validUpdateChannels.contains(channel)) {
+    if (!validUpdateChannels().contains(channel)) {
         qCWarning(lcConfigFile()) << "Received invalid update channel from confog:"
                                   << channel
                                   << "defaulting to:"
@@ -711,12 +709,17 @@ QString ConfigFile::updateChannel() const
     return channel;
 }
 
+QStringList ConfigFile::validUpdateChannels() const
+{
+    return { QStringLiteral("stable"), QStringLiteral("beta"), QStringLiteral("daily") };
+}
+
 void ConfigFile::setUpdateChannel(const QString &channel)
 {
-    if (!validUpdateChannels.contains(channel)) {
+    if (!validUpdateChannels().contains(channel)) {
         qCWarning(lcConfigFile()) << "Received invalid update channel:"
                                   << channel
-                                  << "can only accept 'stable' or 'beta'. Ignoring.";
+                                  << "can only accept 'stable', 'beta' or 'daily'. Ignoring.";
         return;
     }
 
index 97ec16e2f5ad77ea3353eb735a8dabb460acd94b..851f89d10bb555476eba5b8e42e8aafcd78cc883 100644 (file)
@@ -196,6 +196,7 @@ public:
     [[nodiscard]] int updateSegment() const;
 
     [[nodiscard]] QString updateChannel() const;
+    [[nodiscard]] QStringList validUpdateChannels() const;
     void setUpdateChannel(const QString &channel);
 
     [[nodiscard]] QString overrideServerUrl() const;