Terminal: Clean up settings

Qt Creator <= 10 accidentally wrote the default terminal into the
settings on macOS instead of leaving the values empty. So the change
from "openTerminal.py" to just "Terminal.app" might not be correctly
reflected in the settings.

Make sure that the terminal setting is removed in all cases, if it is
set to the default.

Amends f003234510

Change-Id: I9d099999f55b4003ac6e7f4a4b679b893eaffc90
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Eike Ziller
2023-06-08 10:31:17 +02:00
parent 9dabb9d0aa
commit b6c452d59d
2 changed files with 11 additions and 0 deletions

View File

@@ -114,6 +114,8 @@ TerminalCommand TerminalCommand::terminalEmulator()
if (s_settings && HostOsInfo::isAnyUnixHost() && s_settings->contains(kTerminalCommandKey)) { if (s_settings && HostOsInfo::isAnyUnixHost() && s_settings->contains(kTerminalCommandKey)) {
FilePath command = FilePath::fromSettings(s_settings->value(kTerminalCommandKey)); FilePath command = FilePath::fromSettings(s_settings->value(kTerminalCommandKey));
// TODO Remove some time after Qt Creator 11
// Work around Qt Creator <= 10 writing the default terminal to the settings.
if (HostOsInfo::isMacHost() && command.endsWith("openTerminal.py")) if (HostOsInfo::isMacHost() && command.endsWith("openTerminal.py"))
command = FilePath::fromString("Terminal.app"); command = FilePath::fromString("Terminal.app");

View File

@@ -63,6 +63,7 @@
#include <utils/stylehelper.h> #include <utils/stylehelper.h>
#include <utils/theme/theme.h> #include <utils/theme/theme.h>
#include <utils/touchbar/touchbar.h> #include <utils/touchbar/touchbar.h>
#include <utils/terminalcommand.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <QAbstractProxyModel> #include <QAbstractProxyModel>
@@ -1228,6 +1229,14 @@ void MainWindow::saveSettings()
EditorManagerPrivate::saveSettings(); EditorManagerPrivate::saveSettings();
m_leftNavigationWidget->saveSettings(settings); m_leftNavigationWidget->saveSettings(settings);
m_rightNavigationWidget->saveSettings(settings); m_rightNavigationWidget->saveSettings(settings);
// TODO Remove some time after Qt Creator 11
// Work around Qt Creator <= 10 writing the default terminal to the settings.
// TerminalCommand writes the terminal to the settings when changing it, which usually is
// enough. But because of the bug in Qt Creator <= 10 we want to clean up the settings
// even if the user never touched the terminal setting.
if (HostOsInfo::isMacHost())
TerminalCommand::setTerminalEmulator(TerminalCommand::terminalEmulator());
} }
void MainWindow::saveWindowSettings() void MainWindow::saveWindowSettings()