8#include <QtCore/QOperatingSystemVersion>
9#include <QtCore/QVariant>
17#include <QtCore/qfileinfo.h>
18#include <QtCore/private/qcore_mac_p.h>
19#include <QtGui/private/qfont_p.h>
20#include <QtGui/private/qguiapplication_p.h>
21#include <QtGui/private/qcoregraphics_p.h>
22#include <QtGui/qpainter.h>
23#include <QtGui/qtextformat.h>
24#include <QtGui/private/qcoretextfontdatabase_p.h>
25#include <QtGui/private/qappleiconengine_p.h>
26#include <QtGui/private/qfontengine_coretext_p.h>
27#include <QtGui/private/qabstractfileiconengine_p.h>
28#include <qpa/qplatformdialoghelper.h>
29#include <qpa/qplatformintegration.h>
30#include <qpa/qplatformnativeinterface.h>
37#include <CoreServices/CoreServices.h>
68 const auto inactiveHighlight =
qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]);
113#define MAC_PALETTE_ENTRY(pal, active, inactive) \
114 QMacPaletteMap(pal, [NSColor active], [NSColor inactive])
130#undef MAC_PALETTE_ENTRY
136 QHash<QPlatformTheme::Palette, QPalette*> palettes;
159 auto selectedMenuItemColor = [[NSColor controlAccentColor] highlightWithLevel:0.3];
178 NSArray<NSColor *> *baseColors = nil;
179 NSColor *activeHighlightColor = nil;
180 baseColors = [NSColor alternatingContentBackgroundColors];
181 activeHighlightColor = [NSColor selectedContentBackgroundColor];
219 NSAppearance.currentAppearance = NSApp.effectiveAppearance;
225 NSSystemColorsDidChangeNotification, [
this] {
239 delete m_systemPalette;
240 m_systemPalette =
nullptr;
259 QWindowSystemInterface::handleThemeChange<QWindowSystemInterface::SynchronousDelivery>();
264 switch (dialogType) {
277 switch (dialogType) {
291#ifndef QT_NO_SYSTEMTRAYICON
294 return new QCocoaSystemTrayIcon;
301 if (!m_systemPalette)
303 return m_systemPalette;
315 const auto *coreTextFontDatabase =
static_cast<QCoreTextFontDatabase *
>(platformIntegration->fontDatabase());
328 CGAffineTransform old_xform = CGContextGetCTM(
ctx);
329 CGContextConcatCTM(
ctx, CGAffineTransformInvert(old_xform));
330 CGContextConcatCTM(
ctx, CGAffineTransformIdentity);
333 b.blue =
b.green =
b.red = 255*255;
334 PlotIconRefInContext(
ctx, &
rect, kAlignNone, kTransformNone, &
b, kPlotIconRefNormalFlags,
icon);
343 iconType = kQuestionMarkIcon;
346 iconType = kAlertNoteIcon;
349 iconType = kAlertCautionIcon;
352 iconType = kAlertStopIcon;
355 iconType = kDesktopIcon;
358 iconType = kTrashIcon;
361 iconType = kComputerIcon;
364 iconType = kGenericFloppyIcon;
367 iconType = kGenericHardDiskIcon;
371 iconType = kGenericCDROMIcon;
374 iconType = kGenericNetworkIcon;
377 iconType = kOpenFolderIcon;
381 iconType = kGenericFolderIcon;
385 iconType = kGenericDocumentIcon;
392 IconRef
icon =
nullptr;
410 QPlatformTheme::IconOptions opts) :
424 return qt_mac_toQPixmap(iconImage,
size);
448 return QVariant([[NSApplication sharedApplication] isFullKeyboardAccessEnabled] ?
459 return QVariant(
bool([[NSApplication sharedApplication] presentationOptions] & NSApplicationPresentationFullScreen));
461 return !NSScreen.screensHaveSeparateSpaces;
465 return NSEvent.doubleClickInterval * 1000;
467 return NSEvent.keyRepeatDelay * 1000;
469 return 1.0 / NSEvent.keyRepeatInterval;
478 return m_colorScheme;
483 NSAppearance *appearance = nil;
486 appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
489 appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
494 if (appearance != NSApp.effectiveAppearance)
495 NSApplication.sharedApplication.appearance = appearance;
505void QCocoaTheme::updateColorScheme()
520 : QPlatformTheme::standardButtonShortcut(
button);
526 qCDebug(lcQpaMenus) <<
"Created" << menuItem;
539 static bool haveMenubar =
false;
552#ifndef QT_NO_SHORTCUT
563 auto bindings = QPlatformTheme::keyBindings(
key);
567 const auto originalKeyModifiers = keyCombination.keyboardModifiers();
576 QList<QKeySequence> swappedBindings;
577 for (
auto binding : bindings) {
579 swappedBindings.append(
QKeySequence(swapCtrlMeta(binding[0])));
582 bindings = swappedBindings;
Helper base class for retrieving icons for files for usage by QFileIconProvider and related.
QFileInfo fileInfo() const
static QList< QSize > availableIconSizes(double aspectRatio=1.0)
const QColor & color() const
Returns the brush color.
QPixmap filePixmap(const QSize &size, QIcon::Mode, QIcon::State) override
QCocoaFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts)
QList< QSize > availableSizes(QIcon::Mode=QIcon::Normal, QIcon::State=QIcon::Off) override
QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options={}) const override
Return an icon for fileInfo, observing iconOptions.
Qt::ColorScheme colorScheme() const override
QString standardButtonText(int button) const override
Returns the text of a standard button.
QPlatformDialogHelper * createPlatformDialogHelper(DialogType dialogType) const override
QPlatformMenu * createPlatformMenu() const override
void handleSystemThemeChange()
QIconEngine * createIconEngine(const QString &iconName) const override
Factory function for the QIconEngine used by QIcon::fromTheme().
QPlatformMenuBar * createPlatformMenuBar() const override
QList< QKeySequence > keyBindings(QKeySequence::StandardKey key) const override
const QPalette * palette(Palette type=SystemPalette) const override
bool usePlatformNativeDialog(DialogType dialogType) const override
QKeySequence standardButtonShortcut(int button) const override
QPlatformSystemTrayIcon * createPlatformSystemTrayIcon() const override
Factory function for QSystemTrayIcon.
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override
void requestColorScheme(Qt::ColorScheme scheme) override
QVariant themeHint(ThemeHint hint) const override
const QFont * font(Font type=SystemFont) const override
QPlatformMenuItem * createPlatformMenuItem() const override
The QColor class provides colors based on RGB, HSV or CMYK values.
QColor darker(int f=200) const noexcept
QColor lighter(int f=150) const noexcept
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
QFont * themeFont(QPlatformTheme::Font) const
static FontSmoothing fontSmoothing()
QString canonicalFilePath() const
Returns the file system entry's canonical path, including the entry's name, that is,...
static QFontCache * instance()
static QPlatformIntegration * platformIntegration()
T value(const Key &key) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
The QIconEngine class provides an abstract base class for QIcon renderers.
The QIcon class provides scalable icons in different modes and states.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
State
This enum describes the state for which a pixmap is intended to be used.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static Q_CORE_EXPORT QOperatingSystemVersionBase current()
static constexpr QOperatingSystemVersionBase MacOSMojave
\variable QOperatingSystemVersion::MacOSMojave
The QPalette class contains color groups for each widget state.
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\macro QT_RESTRICTED_CAST_FROM_ASCII
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
@ AA_MacDontSwapCtrlAndMeta
static const int mac_widget_colors_count
#define MAC_PALETTE_ENTRY(pal, active, inactive)
QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height)
static QHash< QPlatformTheme::Palette, QPalette * > qt_mac_createRolePalettes()
static QT_BEGIN_NAMESPACE QPalette * qt_mac_createSystemPalette()
static QMacPaletteMap mac_widget_colors[]
#define QT_IGNORE_DEPRECATIONS(statement)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
QBrush qt_mac_toQBrush(CGColorRef color)
QColor qt_mac_toQColor(CGColorRef color)
#define qCDebug(category,...)
GLboolean GLboolean GLboolean b
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QPlatformTheme::Palette paletteRole
QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i)