Use the same configuration format everywhere

Create issue
Issue #622 resolved
Felix Krull created an issue

Right now, the non-portable builds use the default QSettings constructor which defaults to QSettings::NativeFormat; that means different platforms use all sorts of different locations and backends. In particular, Windows settings end up in the registry.

I suggest that we instead use plain configuration files everywhere. (Exact paths open to discussion; there's no single value in QStandardPaths that I would say is "correct" everywhere.) Advantages I see for this change:

  • Allow sharing config files between operating systems, portable and non-portable versions.
  • Make it easier/more obvious how to back up settings on Windows.
  • Hypothetical 32-bit and 64-bit Windows versions could use the same settings (I'm not sure they can with the registry backend because of Wow6432Node).

The big obvious downside is that settings from older versions would be lost unless we explicitly migrate them. Considering we're already breaking the session history, I think it's worthwhile.

@heldercorreia @polwel @teyut @thadrien Thoughts welcome :)

Comments (11)

  1. Helder Correia repo owner

    Yes, if we are to break things, now is the time. Also, we need to get things right until 1.0. Should we make a distinction between History Export and Session Export then? Or maybe this is asking for a new Export Dialog where the user can un/tick things like particular settings, history, variables, user functions, etc.

  2. Pol Welter

    I agree, all platforms should share a common config format. The INI format sounds good. There should be no issues with adopting it generally, since the portable versions use it already.

    A few words on Windows, I am not familiar enough with Linux (or OSX) to speak for them.

    The session should ideally go into %APPDATA%/roaming/speedcrunch/, as it's done now. This way the data correctly roams when the user works on multiple computers. The configuration might go there as well. I am indeed not crazy about the registry. However, is it customary that settings should roam? I am thinking of window sizes and positions, which might end up outside the monitor's bounds...

    Point is, the only QStandardPath that is designed for roaming is AppDataLocation, which is used right now. I see 3 options.

    • Drop support for roaming. No idea if that is a big deal (I guess not). Put everything in %APPDATA%/local.
    • Go on having settings and session stored in different places, e.g. %APPDATA%/local and %APPDATA%/roaming.
    • Have the config roam as well. No idea if that is a real problem either, see above.

    Personally I am OK with either of those.

  3. Felix Krull reporter

    I think the path to the session file is fine. As for roaming: the portable version is allowed to move its settings between computers, so the regular one can as well. Windows should at least not end up out of bounds due to https://bitbucket.org/heldercorreia/speedcrunch/issues/581/speedcrunch-restores-window-to-invalid.

    My preference for paths is:

    • Windows: ~/AppData/Roaming/SpeedCrunch/SpeedCrunch.ini
    • Linux: ~/.config/SpeedCrunch/SpeedCrunch.ini (same directory as now, but different extension for consistency)
    • OSX: ~/Library/Preferences/SpeedCrunch/SpeedCrunch.ini (no clue, but that's what QStandardPaths::AppConfigLocation points to)

    With the exception of Windows, AppConfigLocation seems good, but it's Qt 5.5+. So I suggest a file SpeedCrunch.ini in:

    • Windows: the current getDataPath function
    • everything else: QStandardPaths::ConfigLocation/SpeedCrunch

    Seems fine?

  4. Helder Correia repo owner

    Seems fine. I'm just not sure I missed the answer to this above: for the portable edition, is the INI file going to be stored in getDataPath() or next to the binary as of now?

  5. Felix Krull reporter

    for the portable edition, is the INI file going to be stored in getDataPath() or next to the binary as of now?

    Yes to both ;) getDataPath already points to the application directory for the portable version because that's where the session file needs to go.

  6. Tey'

    Do we really need to store the configuration and the history/session file in different places for Linux and OSX?

    Also, I believe we should migrate and delete old settings in QSettings::createQSettings().

  7. Felix Krull reporter

    Do we really need to store the configuration and the history/session file in different places for Linux and OSX?

    Well, technically, I think the current distinction is correct: the config file is obviously configuration whereas the session is more user data than configuration. That being said: any preferences from Linux desktop users?

    Also, I believe we should migrate and delete old settings in QSettings::createQSettings().

    Actually, deleting is a good point so users don't end up with both ~/.config/SpeedCrunch/SpeedCrunch.{conf,ini}... I'll see if I can figure something out on both points.

  8. Tey'

    As a (power?) user, I prefer applications to store their extra files in a same location so I don't have to dig in multiple places when I need to "play" with those files. Now, if the locations are documented properly, I guess it'd be okay for most users.

    Thanks for pull request #61, it definitely fixes the migration issue.

  9. Log in to comment