diff --git a/share/qtcreator/themes/dark.creatortheme b/share/qtcreator/themes/dark.creatortheme index 7f8b3cf5c17..edf7217aed0 100644 --- a/share/qtcreator/themes/dark.creatortheme +++ b/share/qtcreator/themes/dark.creatortheme @@ -244,6 +244,7 @@ FlatProjectsMode=true FlatMenuBar=true ToolBarIconShadow=true WindowColorAsBase=false +DarkUserInteface=true [Gradients] DetailsWidgetHeaderGradient\1\color=00000000 diff --git a/share/qtcreator/themes/default.creatortheme b/share/qtcreator/themes/default.creatortheme index d4668363767..7dced12a0a6 100644 --- a/share/qtcreator/themes/default.creatortheme +++ b/share/qtcreator/themes/default.creatortheme @@ -216,6 +216,7 @@ FlatProjectsMode=false FlatMenuBar=false ToolBarIconShadow=true WindowColorAsBase=false +DarkUserInteface=false [Gradients] DetailsWidgetHeaderGradient\1\color=ffffffff diff --git a/share/qtcreator/themes/flat-dark.creatortheme b/share/qtcreator/themes/flat-dark.creatortheme index ad2a0888187..632388bd783 100644 --- a/share/qtcreator/themes/flat-dark.creatortheme +++ b/share/qtcreator/themes/flat-dark.creatortheme @@ -248,6 +248,7 @@ FlatProjectsMode=true FlatMenuBar=true ToolBarIconShadow=true WindowColorAsBase=false +DarkUserInteface=true [Gradients] DetailsWidgetHeaderGradient\1\color=00000000 diff --git a/share/qtcreator/themes/flat-light.creatortheme b/share/qtcreator/themes/flat-light.creatortheme index 1390a3135e0..bd05799c410 100644 --- a/share/qtcreator/themes/flat-light.creatortheme +++ b/share/qtcreator/themes/flat-light.creatortheme @@ -225,6 +225,7 @@ FlatProjectsMode=false FlatMenuBar=false ToolBarIconShadow=false WindowColorAsBase=false +DarkUserInteface=false [Gradients] DetailsWidgetHeaderGradient\1\color=00000000 diff --git a/share/qtcreator/themes/flat.creatortheme b/share/qtcreator/themes/flat.creatortheme index f9cfa7b7f86..cfca28f143d 100644 --- a/share/qtcreator/themes/flat.creatortheme +++ b/share/qtcreator/themes/flat.creatortheme @@ -223,6 +223,7 @@ FlatProjectsMode=false FlatMenuBar=false ToolBarIconShadow=true WindowColorAsBase=false +DarkUserInteface=false [Gradients] DetailsWidgetHeaderGradient\1\color=00000000 diff --git a/src/libs/utils/theme/theme.cpp b/src/libs/utils/theme/theme.cpp index fc3018fc1dd..4d9aeae3565 100644 --- a/src/libs/utils/theme/theme.cpp +++ b/src/libs/utils/theme/theme.cpp @@ -27,6 +27,9 @@ #include "theme_p.h" #include "../algorithm.h" #include "../qtcassert.h" +#ifdef Q_OS_MACOS +#import "theme_mac.h" +#endif #include #include @@ -69,6 +72,14 @@ void setCreatorTheme(Theme *theme) return; delete m_creatorTheme; m_creatorTheme = theme; + +#ifdef Q_OS_MACOS + // Match the native UI theme and palette with the creator + // theme by forcing light aqua for light creator themes. + if (!theme->flag(Theme::DarkUserInteface)) + Internal::forceMacOSLightAquaApperance(); +#endif + setThemeApplicationPalette(); } diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index 49c7c881ad2..7bca48b9ea3 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -337,7 +337,8 @@ public: FlatProjectsMode, FlatMenuBar, ToolBarIconShadow, - WindowColorAsBase + WindowColorAsBase, + DarkUserInteface }; Q_INVOKABLE bool flag(Flag f) const; diff --git a/src/libs/utils/theme/theme_mac.h b/src/libs/utils/theme/theme_mac.h new file mode 100644 index 00000000000..55e6d12bc02 --- /dev/null +++ b/src/libs/utils/theme/theme_mac.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +namespace Utils { +namespace Internal { + +void forceMacOSLightAquaApperance(); + +} // Internal +} // Utils diff --git a/src/libs/utils/theme/theme_mac.mm b/src/libs/utils/theme/theme_mac.mm new file mode 100644 index 00000000000..6a940240f12 --- /dev/null +++ b/src/libs/utils/theme/theme_mac.mm @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "theme_mac.h" + +#include + +#include + +#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) +@interface NSApplication (MojaveForwardDeclarations) +@property (strong) NSAppearance *appearance NS_AVAILABLE_MAC(10_14); +@end +#endif + +namespace Utils { +namespace Internal { + +void forceMacOSLightAquaApperance() +{ + if (__builtin_available(macOS 10.14, *)) + NSApp.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; +} + +} // Internal +} // Utils diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index 0cd5f68e123..41d8745baac 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -270,8 +270,10 @@ RESOURCES += $$PWD/utils.qrc osx { HEADERS += \ + $$PWD/theme/theme_mac.h \ $$PWD/fileutils_mac.h OBJECTIVE_SOURCES += \ + $$PWD/theme/theme_mac.mm \ $$PWD/fileutils_mac.mm \ $$PWD/processhandle_mac.mm LIBS += -framework Foundation -framework AppKit diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 599e9972c3f..2ada52c17ee 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -314,6 +314,15 @@ Project { ] } + Group { + name: "Theme_macos" + condition: qbs.targetOS.contains("macos") + prefix: "theme/" + files: [ + "theme_mac.h", "theme_mac.mm", + ] + } + Group { name: "ProcessHandle_macos" condition: qbs.targetOS.contains("macos")