6#include <QtCore/qtimer.h>
7#include <QtGui/qfontdatabase.h>
8#include <qpa/qplatformtheme.h>
10#include <private/qfont_p.h>
11#include <private/qfontengine_p.h>
12#include <private/qfontengine_coretext_p.h>
28 int pSize =
qRound([cocoaFont pointSize]);
30 QString family(
QCFString((CFStringRef)CTFontDescriptorCopyAttribute(
font, kCTFontFamilyNameAttribute)));
31 QString style(
QCFString(((CFStringRef)CTFontDescriptorCopyAttribute(
font, kCTFontStyleNameAttribute))));
43- (
void)changeFont:(
id)sender;
51 NSFontPanel *mFontPanel;
64 mFontPanel = [NSFontPanel sharedFontPanel];
72 [mFontPanel setRestorable:NO];
73 [mFontPanel setDelegate:self];
82 [mStolenContentView release];
83 [mFontPanel setDelegate:nil];
84 [[NSNotificationCenter defaultCenter] removeObserver:self];
93 [mFontPanel setTitle:helper->options()->windowTitle().toNSString()];
96 [
self restoreOriginalContentView];
100 [mStolenContentView retain];
101 mFontPanel.contentView = nil;
105 [mPanelButtons addSubview:mStolenContentView];
106 mPanelButtons.panelContentsMargins = NSEdgeInsetsMake(0, 0, 7, 0);
117- (
void)restoreOriginalContentView
121 [mStolenContentView removeFromSuperview];
122 [mFontPanel setContentView:mStolenContentView];
124 [mPanelButtons release];
132 [
self finishOffWithCode:NSModalResponseOK];
135- (
void)onCancelClicked
140 [
self finishOffWithCode:NSModalResponseCancel];
144- (
void)changeFont:(
id)sender
153 NSFontManager *fontManager = [NSFontManager sharedFontManager];
154 NSFont *selectedFont = [fontManager selectedFont];
156 selectedFont = [NSFont systemFontOfSize:[NSFont systemFontSize]];
158 NSFont *panelFont = [fontManager convertFont:selectedFont];
165- (
void)showModelessPanel
177 dispatch_async(dispatch_get_main_queue(), ^{
178 [mFontPanel makeKeyAndOrderFront:mFontPanel];
182- (BOOL)runApplicationModalPanel
193 [NSApp runModalForWindow:mFontPanel];
205- (BOOL)worksWhenModal
215- (BOOL)windowShouldClose:(
id)window
221 [
self finishOffWithCode:NSModalResponseCancel];
239 [NSApp stopModalWithCode:code];
280 if (mDelegate->mHelper == helper)
281 mDelegate->mHelper =
nullptr;
290 return [
mDelegate runApplicationModalPanel];
309 return mDelegate->mQtFont;
314 NSFontManager *mgr = [NSFontManager sharedFontManager];
315 NSFont *nsFont = nil;
318 NSFontTraitMask
mask = 0;
320 mask |= NSItalicFontMask;
324 mask |= NSBoldFontMask;
328 nsFont = [mgr fontWithFamily:fontInfo.family().toNSString()
331 size:fontInfo.pointSize()];
333 [mgr setSelectedFont:nsFont isMultiple:NO];
334 mDelegate->mQtFont =
font;
349 sharedFontPanel()->cleanup(
this);
354 if (sharedFontPanel()->
exec())
364 sharedFontPanel()->init(
this);
365 return sharedFontPanel()->show(windowModality,
parent);
370 sharedFontPanel()->hide();
375 sharedFontPanel()->init(
this);
376 sharedFontPanel()->setCurrentFont(
font);
381 return sharedFontPanel()->currentFont();
void restoreOriginalContentView()
virtual void wakeUp()=0
\threadsafe
static void clearCurrentThreadCocoaEventDispatcherInterruptFlag()
QFont currentFont() const override
bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override
~QCocoaFontDialogHelper()
void setCurrentFont(const QFont &) override
void init(QCocoaFontDialogHelper *helper)
bool show(Qt::WindowModality windowModality, QWindow *parent)
QFont currentFont() const
void setCurrentFont(const QFont &font)
void cleanup(QCocoaFontDialogHelper *helper)
static QAbstractEventDispatcher * eventDispatcher()
Returns a pointer to the event dispatcher object for the main thread.
static QFont font(const QString &family, const QString &style, int pointSize)
Returns a QFont object that has family family, style style and point size pointSize.
bool testOption(FontDialogOption option) const
void setStrikeOut(bool)
If enable is true, sets strikeout on; otherwise sets strikeout off.
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
bool underline() const
Returns true if underline has been set; otherwise returns false.
Weight weight() const
Returns the weight of the font, using the same scale as the \l{QFont::Weight} enumeration.
void setUnderline(bool)
If enable is true, sets underline on; otherwise sets underline off.
Style style() const
Returns the style of the font.
QObject * parent() const
Returns a pointer to the parent object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
QNSPanelContentsWrapper * mPanelButtons
QCocoaColorDialogHelper * mHelper
NSView * mStolenContentView
QCocoaFontDialogHelper * mHelper
QNSPanelContentsWrapper * mPanelButtons
static QT_USE_NAMESPACE QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont)
NSView * mStolenContentView
#define QT_NAMESPACE_ALIAS_OBJC_CLASS(__KLASS__)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
int qRound(qfloat16 d) noexcept
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLuint GLuint GLfloat weight
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent