8#include <QtCore/QVariant>
16#include <QtCore/qfileinfo.h>
17#include <QtCore/private/qcore_mac_p.h>
18#include <QtGui/private/qfont_p.h>
19#include <QtGui/private/qguiapplication_p.h>
20#include <QtGui/private/qcoregraphics_p.h>
21#include <QtGui/qpainter.h>
22#include <QtGui/qtextformat.h>
23#include <QtGui/private/qcoretextfontdatabase_p.h>
24#include <QtGui/private/qappleiconengine_p.h>
25#include <QtGui/private/qfontengine_coretext_p.h>
26#include <QtGui/private/qabstractfileiconengine_p.h>
27#include <qpa/qplatformdialoghelper.h>
28#include <qpa/qplatformintegration.h>
29#include <qpa/qplatformnativeinterface.h>
36#include <CoreServices/CoreServices.h>
67 const auto inactiveHighlight =
qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]);
112#define MAC_PALETTE_ENTRY(pal, active, inactive) \
113 QMacPaletteMap(pal, [NSColor active], [NSColor inactive])
129#undef MAC_PALETTE_ENTRY
135 QHash<QPlatformTheme::Palette, QPalette*> palettes;
158 auto selectedMenuItemColor = [[NSColor controlAccentColor] highlightWithLevel:0.3];
177 NSArray<NSColor *> *baseColors = nil;
178 NSColor *activeHighlightColor = nil;
179 baseColors = [NSColor alternatingContentBackgroundColors];
180 activeHighlightColor = [NSColor selectedContentBackgroundColor];
217 NSAppearance.currentAppearance = NSApp.effectiveAppearance;
222 NSSystemColorsDidChangeNotification, [
this] {
236 delete m_systemPalette;
237 m_systemPalette =
nullptr;
256 QWindowSystemInterface::handleThemeChange<QWindowSystemInterface::SynchronousDelivery>();
261 switch (dialogType) {
274 switch (dialogType) {
288#ifndef QT_NO_SYSTEMTRAYICON
291 return new QCocoaSystemTrayIcon;
298 if (!m_systemPalette)
300 return m_systemPalette;
312 const auto *coreTextFontDatabase =
static_cast<QCoreTextFontDatabase *
>(platformIntegration->fontDatabase());
325 CGAffineTransform old_xform = CGContextGetCTM(
ctx);
326 CGContextConcatCTM(
ctx, CGAffineTransformInvert(old_xform));
327 CGContextConcatCTM(
ctx, CGAffineTransformIdentity);
330 b.blue =
b.green =
b.red = 255*255;
331 PlotIconRefInContext(
ctx, &
rect, kAlignNone, kTransformNone, &
b, kPlotIconRefNormalFlags,
icon);
340 iconType = kQuestionMarkIcon;
343 iconType = kAlertNoteIcon;
346 iconType = kAlertCautionIcon;
349 iconType = kAlertStopIcon;
352 iconType = kDesktopIcon;
355 iconType = kTrashIcon;
358 iconType = kComputerIcon;
361 iconType = kGenericFloppyIcon;
364 iconType = kGenericHardDiskIcon;
368 iconType = kGenericCDROMIcon;
371 iconType = kGenericNetworkIcon;
374 iconType = kOpenFolderIcon;
378 iconType = kGenericFolderIcon;
382 iconType = kGenericDocumentIcon;
389 IconRef
icon =
nullptr;
407 QPlatformTheme::IconOptions opts) :
421 return qt_mac_toQPixmap(iconImage,
size);
445 return QVariant([[NSApplication sharedApplication] isFullKeyboardAccessEnabled] ?
458 return !NSScreen.screensHaveSeparateSpaces;
462 return NSEvent.doubleClickInterval * 1000;
464 return NSEvent.keyRepeatDelay * 1000;
466 return 1.0 / NSEvent.keyRepeatInterval;
477 return m_colorScheme;
482 NSAppearance *appearance = nil;
485 appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
488 appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
493 if (appearance != NSApp.effectiveAppearance)
494 NSApplication.sharedApplication.appearance = appearance;
504void QCocoaTheme::updateColorScheme()
519 : QPlatformTheme::standardButtonShortcut(
button);
525 qCDebug(lcQpaMenus) <<
"Created" << menuItem;
538 static bool haveMenubar =
false;
551#ifndef QT_NO_SHORTCUT
562 auto bindings = QPlatformTheme::keyBindings(
key);
566 const auto originalKeyModifiers = keyCombination.keyboardModifiers();
575 QList<QKeySequence> swappedBindings;
576 for (
auto binding : bindings) {
578 swappedBindings.append(
QKeySequence(swapCtrlMeta(binding[0])));
581 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
Returns sizes of all images that are contained in the engine for the specific mode and state.
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
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)