OSDN Git Service

kget: if torrent settings file is deleted apply default settings
authorIvailo Monev <xakepa10@gmail.com>
Fri, 25 Mar 2022 10:20:40 +0000 (12:20 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 25 Mar 2022 10:20:40 +0000 (12:20 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kget/transfer-plugins/torrent/dlgtorrent.cpp
kget/transfer-plugins/torrent/dlgtorrent.ui
kget/transfer-plugins/torrent/transferTorrent.cpp

index 3c9a740..24700fb 100644 (file)
@@ -212,7 +212,7 @@ void DlgTorrentSettings::loadSettings(const lt::settings_pack &ltsettings)
         m_ui.settingsTableWidget->setItem(tablerowcount, 0, tablewidget);
 
         QSpinBox* tablecellwidget = new QSpinBox();
-        tablecellwidget->setRange(-INT_MAX, INT_MAX);
+        tablecellwidget->setRange(INT_MIN, INT_MAX);
         tablecellwidget->setValue(ltsettings.get_int(settingindex));
         connect(
             tablecellwidget, SIGNAL(valueChanged(int)),
index 959f193..bac2634 100644 (file)
@@ -41,9 +41,6 @@
      </column>
     </widget>
    </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout"/>
-   </item>
   </layout>
  </widget>
  <customwidgets>
index 6712785..3ac30d2 100644 (file)
@@ -714,20 +714,9 @@ void TransferTorrent::applySettings()
     }
 
     QFile settingsfile(KStandardDirs::locateLocal("appdata", "torrentsettings.json"));
-    if (!settingsfile.exists()) {
-        kDebug(5001) << "settings file does not exist";
-        return;
-    }
-
-    if (!settingsfile.open(QFile::ReadOnly)) {
-        kWarning(5001) << "could not open settings file";
-        return;
-    }
-
-    const QJsonDocument settingsjson = QJsonDocument::fromJson(settingsfile.readAll());
-    if (settingsjson.isNull()) {
-        kWarning(5001) << "could not parse settings file";
-        return;
+    QJsonDocument settingsjson;
+    if (settingsfile.open(QFile::ReadOnly)) {
+        settingsjson = QJsonDocument::fromJson(settingsfile.readAll());
     }
 
     const QVariantMap settingsmap = settingsjson.toVariant().toMap();