Enable per-chat history, line wrap by default
authorShane Synan <digitalcircuit36939@gmail.com>
Sat, 24 Sep 2016 06:59:05 +0000 (01:59 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 13 Oct 2016 20:11:37 +0000 (22:11 +0200)
Enable input widget per-chat history and line wrapping by default,
following the behavior of Quassel Web and most Messaging/SMS apps
(HexChat does per-chat history by default, but not line wrapping).

Bump settings minor version to 3, preserve old defaults for upgrades.

This shows the minimum necessary to change default settings while
preserving previous defaults for existing installs.

Resolves GH-253.

src/qtui/inputwidget.cpp
src/qtui/qtuiapplication.cpp
src/qtui/settingspages/inputwidgetsettingspage.ui

index 801ac96..898f295 100644 (file)
@@ -116,7 +116,7 @@ InputWidget::InputWidget(QWidget *parent)
     setShowStyleButtons(s.value("ShowStyleButtons", true));
 
     s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant)));
     setShowStyleButtons(s.value("ShowStyleButtons", true));
 
     s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant)));
-    setEnablePerChatHistory(s.value("EnablePerChatHistory", false));
+    setEnablePerChatHistory(s.value("EnablePerChatHistory", true));
 
     s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant)));
     setMaxLines(s.value("MaxNumLines", 5));
 
     s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant)));
     setMaxLines(s.value("MaxNumLines", 5));
@@ -125,7 +125,7 @@ InputWidget::InputWidget(QWidget *parent)
     setScrollBarsEnabled(s.value("EnableScrollBars", true));
 
     s.notify("EnableLineWrap", this, SLOT(setLineWrapEnabled(QVariant)));
     setScrollBarsEnabled(s.value("EnableScrollBars", true));
 
     s.notify("EnableLineWrap", this, SLOT(setLineWrapEnabled(QVariant)));
-    setLineWrapEnabled(s.value("EnableLineWrap", false));
+    setLineWrapEnabled(s.value("EnableLineWrap", true));
 
     s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant)));
     setMultiLineEnabled(s.value("EnableMultiLine", true));
 
     s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant)));
     setMultiLineEnabled(s.value("EnableMultiLine", true));
index 6777a56..36bb1a4 100644 (file)
@@ -210,7 +210,7 @@ bool QtUiApplication::migrateSettings()
     // --------
     // Check minor settings version, handling upgrades/downgrades as needed
     // Current minor version
     // --------
     // Check minor settings version, handling upgrades/downgrades as needed
     // Current minor version
-    const uint VERSION_MINOR_CURRENT = 2;
+    const uint VERSION_MINOR_CURRENT = 3;
     // Stored minor version
     uint versionMinor = s.versionMinor();
 
     // Stored minor version
     uint versionMinor = s.versionMinor();
 
@@ -269,10 +269,33 @@ bool QtUiApplication::applySettingsMigration(QtUiSettings settings, const uint n
     // oldest version.  Ignore those, start from 2 and higher.
     // Each missed version will be called in sequence.  E.g. to upgrade from '1' to '3', this
     // function will be called with '2', then '3'.
     // oldest version.  Ignore those, start from 2 and higher.
     // Each missed version will be called in sequence.  E.g. to upgrade from '1' to '3', this
     // function will be called with '2', then '3'.
-    case 2:
+    // Use explicit scope via { ... } to avoid cross-initialization
+    case 3:
     {
     {
-        // Use explicit scope via { ... } to avoid cross-initialization
+        // New default changes: per-chat history and line wrapping enabled by default.  Preserve
+        // the older default values for keys that haven't been saved.
+
+        // --------
+        // InputWidget settings
+        UiSettings settingsInputWidget("InputWidget");
+        const QString enableInputPerChatId = "EnablePerChatHistory";
+        if (!settingsInputWidget.valueExists(enableInputPerChatId)) {
+            // New default value is true, preserve previous behavior by setting to false
+            settingsInputWidget.setValue(enableInputPerChatId, false);
+        }
+
+        const QString enableInputLinewrap = "EnableLineWrap";
+        if (!settingsInputWidget.valueExists(enableInputLinewrap)) {
+            // New default value is true, preserve previous behavior by setting to false
+            settingsInputWidget.setValue(enableInputLinewrap, false);
+        }
+        // --------
 
 
+        // Migration complete!
+        return true;
+    }
+    case 2:
+    {
         // New default changes: sender <nick> brackets disabled, sender colors and sender CTCP
         // colors enabled.  Preserve the older default values for keys that haven't been saved.
 
         // New default changes: sender <nick> brackets disabled, sender colors and sender CTCP
         // colors enabled.  Preserve the older default values for keys that haven't been saved.
 
index b7415ec..14f3666 100644 (file)
@@ -69,7 +69,7 @@
       <string notr="true">EnablePerChatHistory</string>
      </property>
      <property name="defaultValue" stdset="0">
       <string notr="true">EnablePerChatHistory</string>
      </property>
      <property name="defaultValue" stdset="0">
-      <bool>false</bool>
+      <bool>true</bool>
      </property>
     </widget>
    </item>
      </property>
     </widget>
    </item>
       <string notr="true">EnableLineWrap</string>
      </property>
      <property name="defaultValue" stdset="0">
       <string notr="true">EnableLineWrap</string>
      </property>
      <property name="defaultValue" stdset="0">
-      <bool>false</bool>
+      <bool>true</bool>
      </property>
     </widget>
    </item>
      </property>
     </widget>
    </item>