summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
Commit message (Collapse)AuthorAgeFilesLines
* macOS: Work around lack of native support for multi-part extensionsTor Arne Vestbø2024-01-171-21/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multi-part extensions such as "tar.gz" are not natively supported by macOS, e.g. one can not create a [UTType typeWithFilenameExtension:] for such an extension, and this goes all the way down to Foundation. As a result NSSavePanel gets confused when assigning a multi-part extension to allowedFileTypes, because it's using NSString operations such as stringByDeletingPathExtension or pathExtension, which also lack support for multi-part extensions. We've worked around this in the past by reducing these extensions to their last component, e.g. "tar.gz" reduced to "gz", but this results in the save panel turning the input file name "foo" into "foo.gz" if the user doesn't provide the full file name. Various attempts at working around the lack of multi-part extension support by breaking allowedFileTypes into ["tar.gz", "gz"], or doing selectively toggling of allowedFileTypes in panel:validateURL:error, have all proved to have corner cases and shortcomings of their own. As a last resort, we now treat multi-part extensions manually, by disabling the allowedFileTypes filter, and doing our own validation in the panel:validateURL:error callback. This requires us to also manually handle automatic extension for file names without extensions, as well as overwrite confirmation in the cases we do add an extension manually. The overwrite dialog and error messages for incompatible extensions have been modeled after their native macOS 14 counterparts, using translated strings from AppKit. Task-number: QTBUG-109877 Pick-to: 6.7 Change-Id: I6b7ce3c44b4c3b24802aa1f66f4593457ae4c929 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Reset save dialog extension when resetting file name filterTor Arne Vestbø2024-01-171-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | We map QFileDialog name filters to NSSavePanel.allowedFileTypes, for example turning "Text Files (*.txt)" into allowedFileTypes = @[@"txt"]. In this case, the NSSavePanel will automatically add the extension to the user's file name, if they just type "foo". When a filter allows all files, we reset the allowedFileTypes to nil, but this does not reset the automatically added extension, so if the user switches from one filter (*.txt) to another (*.*), the file name will still have a .txt extension. This is problematic when the save panel's file name field does not show the extension to the user, which can happen automatically if the user types an initial file name without an extension, overriding what we've asked by setting extensionHidden=NO. When that happens, the user is shown "foo", but the actual file name is "foo.txt". To mitigate this confusing situation we do a round-trip via the UTTypeDirectory content type, which is a valid type without any extension. This forces the save panel to remove any extensions added automatically by previous filters. Pick-to: 6.7 Change-Id: Ia17a8c2734eff656116ef77a9813113a5076e9cc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Disable currentChanged signal for NSSavePanelsTor Arne Vestbø2024-01-171-0/+8
| | | | | | | | | | | | | | | The panelSelectionDidChange callback is only called when the user selects a directory in the save panel, as all other files are not selectable. And when that happens, the reported selection is not the directory, but the current file name (which may be based on clicking an exsiting file, but that doesn't cause selection changes). To avoid this confusing and inconsistent behavior we disable the signal entirely when showing an NSSavePanel. Pick-to: 6.7 Change-Id: If706b8faa7027ca284ec8398f5c6e2a110e01f91 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Explicitly show extensions in save dialog if filter is "all files"Tor Arne Vestbø2024-01-101-11/+19
| | | | | | | | | | Otherwise clicking an existing file in the dialog will not populate the full file name, which is what you'd expect for a filter allowing all files. Pick-to: 6.7 Change-Id: Ib9a014352d5e567e54f95414e744566615d735d8 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Show extensions in file dialog when filtering on multi-part extensionTor Arne Vestbø2024-01-101-14/+22
| | | | | | | | | | | | | | | | | | | | | | | File extensions with multiple parts, such as as ".tar.gz" are not natively supported on macOS. Asking NSSavePanel to only allow file types with such extensions confuses it severely, so we work around it by reducing the native file name filter to the last component of the extension. In this situation, we explicitly tell the NSSavePanel to show the full filename, including the extension, so that the user can more easily see what the final file name will be. However, as part of 7f8a80ebf87cccb57da316202e5350eb5eca9d5d we ended up changing the logic to count the number of possible extensions for a given file type filter, not the number of parts in the extension. The logic has now been restored, but moved to init, so that it applies even if the initial filter is not a multi-part extension. Task-number: QTBUG-109877 Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I244cea1cc2977f8adf7e359ea7116bbfad0e1059 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Use single truth to track file dialog current directoryTor Arne Vestbø2023-12-111-23/+21
| | | | | | | | | | | | | | | | | | | | | Unfortunately we can not rely on the file dialog panel for this, via the directoryURL property, as that property has not yet been updated during a panel:directoryDidChange: callback, resulting in the directory reported to the user being the previous directory. Since we already have to store the current directory for the case where we haven't yet created the file dialog panel we re-use this variable as the single place to store the current directory. It's not clear whether we still need to normalize the strings we get from the NSSavePanel, but the code has been left in, even if the old callback code didn't normalize the path that we then emitted as directoryEntered(). Fixes: QTBUG-119371 Pick-to: 6.7 6.5 6.6 6.2 Change-Id: I379a47053302e73d5e06a2b941f40365c17390d5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Handle NSNull when file dialog directories changeTor Arne Vestbø2023-12-111-1/+4
| | | | | | | | | | | For some directories, such as the 'Recents' entry in the native file dialog, the panel:directoryDidChange: callback will report a NSNull for the NSString path, which results in an exception when trying to compute the length of this null entry. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: Ic9cddb54ea713b8fbdcaf0f4fb506ac96e90c9fe Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS file dialog refactor: don't heap allocate string and string listVolker Hilsheimer2023-09-081-34/+30
| | | | | | | | | | | We always allocated them in the constructor function, and never tested them for nullptr, so just manage them as regular members. As a drive-by, apply const to read-only variables in relevant code. Pick-to: 6.6 Change-Id: If0a3ac8982582f2adf5187a3c0357f4da93467fb Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Respect QDir::Hidden for native file dialogsTor Arne Vestbø2023-06-301-2/+8
| | | | | | | | | The default for showsHiddenFiles is NO, so we were not showing hidden files unless the user toggled them via the keyboard shortcut. Pick-to: 6.5 6.6 Change-Id: I796144452cf8f5a6cc46f1ba6747affcd0a35879 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Avoid triggering TCC permission dialogs in file dialogsTor Arne Vestbø2023-06-301-35/+19
| | | | | | | | | | | | | | | | | | | | | | | In our NSOpenSavePanelDelegate we respond to panel:shouldEnableURL: by checking the file dialog's filter options. As part of this, we pulled out the file's attributes using [NSFileManager attributesOfItemAtPath:], but this API triggers the TCC (Transparency, Consent, and Control) machinery to ask the user for permission to access the path in question. We could replace the directory check with fileExistsAtPath:isDirectory:, but this would still leave the checks for writable/readable/executable. Luckily for us, the plumbing for QFileInfo uses lower level CoreFoundation APIs that don't have these issues (except for isBundle, which we should fix separately). This also means we can remove the custom isHiddenFileAtURL helper, as it was based on the same kCFURLIsHiddenKey as the QFileInfo plumbing. Fixes: QTBUG-114919 Pick-to: 6.5 6.6 Change-Id: I9ebefaeb1ef7bcc5bb9a1c5cd4b993ce230cf506 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Enable dirs in file dialogs, also when treating bundles as dirsTor Arne Vestbø2023-06-301-4/+3
| | | | | | | | | | | | | | | | | | In our NSOpenSavePanelDelegate we respond to panel:shouldEnableURL: with YES if it's a directory or symlink to a directory, which matches the native behavior. But the panel has a special flag to treat bundles as directories instead of files. We were checking this flag, but ignoring the case where it was actually set (which it normally is not), and as a result would go on to filter directory names as well. We now handle both cases, and only call [NSWorkspace isFilePackageAtPath:] if needed (when the treatsFilePackagesAsDirectories flag is not set). Pick-to: 6.5 6.6 6.2 Change-Id: I2b9a16ff99b4b643389acc042c032813f432ac59 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCocoaFileDialogHelper: protect against dangling pointersTimur Pocheptsov2022-12-091-1/+13
| | | | | | | | | | | | | NSSave/Open panel is a shared object, that can outlive Qt's counterpart. While its delegate is a weak property, somehow it can outlive Qt-object, which _owns_ this delegate, as a result an attempt to emit a signal on m_helper results in a crash. QPointer can help with such problem. This is a speculative fix, since we don't have a realible reproducer. Fixes: QTBUG-109287 Change-Id: Iccc4a063a24e33e0a5c0fd07b3c203d0c17317ad Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Move QMacAutoReleasePool from qglobal.h to qcore_mac_p.hSona Kurazyan2022-09-011-0/+1
| | | | | | | | And include qcore_mac_p.h where needed. Task-number: QTBUG-99313 Change-Id: Idb1b005f1b5938e8cf329ae06ffaf0d249874db2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Plugins: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-05-041-2/+4
| | | | | | | | | As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Task-number: QTBUG-98434 Change-Id: I7fadd3cf27ad099028d70f05956303e3af62c0f5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Plugins: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-05-021-3/+3
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: Id76add7e86b6dfb89f758a9efb0644067f0f44de Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* macOS: Allow duplicate entries in file dialog name filterTor Arne Vestbø2022-04-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Using QFileDialog::setMimeTypeFilters() with a list of mime types may in some cases result in the same name for two different mime types, for example both "image/heic" and "image/heif" will result in the name "HEIF image (*.heic *.heif)". When the resulting name filter is propagated to the platform layer, we add entries to a NSPopUpButton, but the convenience API we used, addItemWithTitle:, does not allow duplicates. As a result, the entries in the menu didn't match the list of name filters we then looked up and applied to the actual file name filtering, causing off by one errors. Ideally we'd make sure the name filters are unique and well formed all the way from the QFileDialog to the platform and back, but for now we work around issue by using the NSMenu API directly, which does allow for duplicate entires. Fixes: QTBUG-101361 Pick-to: 6.2 6.3 Change-Id: Iee3db4e6c5adfdbdd7f0094b4efd65aa2ecc0f57 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QCocoaFileDialogHelper: Always enable symlinks and aliases to directoriesWilliam Jones2022-03-081-1/+6
| | | | | | | | | | | | | We always enable directories, so that the user can navigate into them, so we should do the same for symlinks and aliases to directories. This is the same behavior the native dialog has when not implementing shouldEnableURL and relying purely on allowedFileTypes. Fixes: QTBUG-28379 Pick-to: 5.15 6.2 6.3 Change-Id: I7ae4eb8120aa87cb685f3561d5e1c7257b0c9349 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Wake up event dispatcher after running modal dialog helpersTor Arne Vestbø2021-10-201-0/+4
| | | | | | | | | | | | | The root event loop may have been exited, so we need to ensure the event dispatcher is woken up so it can evaluate whether it should continue or not. For most applications this happens automatically when e.g. the user moves their mouse or press a key, but for tests this may not be the case, and the test will stall and never exit its event loop. Pick-to: 6.2 Change-Id: Ic241e3f1045481c34150289ff711b921addb18e4 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Reduce duplicated code for showing file dialogsTor Arne Vestbø2021-02-021-74/+36
| | | | | | | | | | The initialization was duplicated across the different modes. We now do the setup once, in a shared showPanel:withParent function. This also simplifies and removes the need to store the return code. Change-Id: I3c4da48cfef92bcc59c76cffa15b40150de1a9e1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Reduce duplicated updates of file dialog propertiesTor Arne Vestbø2021-02-021-13/+6
| | | | | Change-Id: I2017bfdfa6d5598405d700680ecaaf04fd6023fd Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Refactor computing of accepted extensions in file dialogsTor Arne Vestbø2021-02-021-21/+20
| | | | | Change-Id: Ie71db5a0ab66dd9d157b53297cbb9aba248fa8af Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Use single variable to track file dialog in QCocoaFileDialogHelperTor Arne Vestbø2021-02-021-64/+74
| | | | | | | | | | | | | | Relying on Objective-C's no-op behavior when sending messages to nil was nifty, but a bit confusing when trying to track the ownership model of the class. It's now explicit at the call sites what's going on (a cast). The canSelectHiddenExtension property is valid both save and open panels, but AppKit will only show it for save panels. Change-Id: I8e12d629639e2179d155b2ecda1bb2dab2a5757d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Clean up QCocoaFileDialogHelperTor Arne Vestbø2021-01-261-328/+257
| | | | | | | | | | | | | | | | | | | - Remove indirections via helper functions that did nothing but redirect. - Remove unneeded checks of !m_helper in delegate. The helper is always valid for a delegate. - Use m_ prefix for member variables, as in the rest of Qt. - Implement init: as per modern Objective-C recommendations. - Remove respondsToSelector checks that were not needed. - Use modern Objective-C property syntax. - Fix code style issues/formatting. - Remove unused functions. - Reorder and remove unused includes. - Class-initialize member variables. Change-Id: Iedc084b67bb496b2ef13001a0e6aa46d4574eb57 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Don't restrict non-modal file dialogs to open-dialogs onlyTor Arne Vestbø2021-01-261-16/+14
| | | | | | | | None of the APIs used for non-modal operation require NSOpenPanel. Pick-to: 6.0 5.15 Change-Id: I7ea49a8dad6e724a8a0d4321ea443d4cdcc5a6b1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Don't exec file dialogs via runModal unless they are app modalTor Arne Vestbø2021-01-251-20/+38
| | | | | | | | | | | | | | | | | | | | | | Non-modal or window modal dialogs are shown at show(), via AppKit APIs that are non-blocking. If we want to block execution at this point, we need to spin our own event loop. The runModal API of NSSavePanel is not meant to be used for blocking execution for already shown dialogs, but is reserved for application modal dialogs. This means we no longer trip over AppKit's understanding of what state the dialog is in, which would result in the dialog not reporting back any files. It also allows us to remove the guard for closing dialogs twice. We now also correctly close and end the application modal session if the dialog is closed programmatically using Qt APIs. Task-number: QTBUG-89959 Fixes: QTBUG-85547 Pick-to: 6.0 5.15 Change-Id: Ida3dc404417789d4823822ecfbf0935591c23878 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Remove DontConfirmOverwrite workaroundMorten Johan Sørvig2021-01-191-9/+2
| | | | | | | | | | | | Does not work any more on recent macOS versions. As a bonus, Qt now handles file names which contain “___qt_very_unlikely_prefix_” correctly. Pick-to: 5.15 6.0 Task-number: QTBUG-39791 Change-Id: I944a68efa18edc72939d953ab32ecb53d8f8e1c4 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: Don't try to close already-closed/closing file dialogTor Arne Vestbø2021-01-121-1/+7
| | | | | | | | | | | | | | | | | Doing so results in a warning about "modalSession has been exited prematurely - check for a reentrant call to endModalSession:", and on Big Sur will also result in the file failing to save because the return code from runModal will no longer be NSModalResponseOK. This would happen when the completion handler for beginSheetModalForWindow would call QNSOpenSavePanelDelegate_panelClosed, resulting in calls to QDialog::done(), which in turn tries to hide the dialog, via QCocoaFileDialogHelper::hideCocoaFilePanel(). Pick-to: 6.0 5.15 Fixes: QTBUG-89959 Change-Id: I048afe3dcc7fe62e0d0273f12b4b2c0237abb052 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Make QStringList an alias to QList<QString>Lars Knoll2020-09-121-2/+0
| | | | | | | | | | | | | | | | | | Fix our API, so that QStringList and QList<QString> are the same thing. This required a bit of refactoring in QList and moving the indexOf(), lastIndexOf() and contains() method into QListSpecialMethods. In addition, we need to ensure that the QStringList(const QString&) constructor is still available for compatibility with Qt 5. Once those two are done, all methods in QStringList can be moved into QListSpecialMethods<QString>. Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move QStringRef and remains to Qt5CompatKarsten Heimrich2020-08-201-1/+1
| | | | | | | | | Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* macOS: Clean up headersTor Arne Vestbø2020-06-051-2/+3
| | | | | | | | | | | | | | The headers are now C++ clean and can be used outside of Objective-C code. All includes of Objective-C frameworks have been moved to the implementation files. Header guards have been added in the few places they were missing. All includes are now done via #include, instead of sometimes using the #import variant. Change-Id: Ibb0a9c0bcfefbda4347737212e40e300a3184982 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Remove a bunch of dead (forward) declarationsTor Arne Vestbø2020-04-151-1/+0
| | | | | Change-Id: I402668a17b48c164658f775bacd832615a6d2587 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* macOS: Reduce save dialog extension filters to their last componentTor Arne Vestbø2020-03-041-19/+42
| | | | | | | | | | | | | | | | | | | NSSavePanel does not deal well with multi-part extensions, to the point where it will fail to open if that's the only acceptable extension. We follow Chromium's lead here and reduce the extension to its last component, which enables selecting and saving files such as 'foo.tar.gz'. To improve the user experience we always show file extensions when we detect a multi-part extension. This makes it clearer what the final extension will be, and avoids confusing macOS about the intention of the user when choosing a file that without the final extension also matches another known extension. Fixes: QTBUG-38303 Fixes: QTBUG-44227 Change-Id: Id0cee84f758c2cd59fcf1b339caa30f7da07dd1e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Simplify Objective-C namespacingTor Arne Vestbø2019-10-151-21/+0
| | | | | | | | | | | | | | | | We only need to use the QT_MANGLE_NAMESPACE macro when declaring the interface of the class. As long as we couple that with an alias declaration using QT_NAMESPACE_ALIAS_OBJC_CLASS, any further uses of the class name can be un-namespaced, including declaring categories on the class. The only snag with QT_NAMESPACE_ALIAS_OBJC_CLASS is that it can only be used once per class and translation unit, so forward declarations get hairy, but we can avoid that by just including the headers instead. Change-Id: I333bcd18fe1e18d81fbd560b0941c98b1c32460e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* macOS: Pass required parameters to NSOpenSavePanelDelegate callbacksTor Arne Vestbø2019-10-081-3/+3
| | | | | | Change-Id: I0e0322734a077e4ee948128f3ba6c074514ccbb9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QRegExp include cleanupSamuel Gaist2019-04-191-1/+0
| | | | | | | | | | | | | | | | QRegExp includes can be found in several files where there's not even a use of the class. This patch aims to avoid needless includes as well as follow the "include only what you use" moto. This patch removes a QRegExp include from the QStringList header which means that there is likely going to be code breaking since QStringList is used in many places and would get QRegExp in. [ChangeLog][Potentially Source-Incompatible Changes] qstringlist.h no longer includes qregexp.h. Change-Id: I32847532f16e419d4cb735ddc11a26551127e923 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-11-091-1/+0
|\ | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf qmake/Makefile.unix src/gui/text/qtextdocument.cpp src/gui/text/qtextdocument.h Change-Id: Iba26da0ecbf2aa4ff4b956391cfb373f977f88c9
| * Modernize the "textcodec" featureLiang Qi2018-11-071-1/+0
| | | | | | | | | | | | | | | | | | Also clean up QTextCodec usage in qmake build and some includes of qtextcodec.h. Change-Id: I0475b82690024054add4e85a8724c8ea3adcf62a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | macOS: Update all deprecated enums to their 10.12+ equivalentsTor Arne Vestbø2018-08-311-2/+2
| | | | | | | | | | Change-Id: I3034258da95c9c70eb6758db92967f438617f6e9 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Cocoa QPA: Remove uses of NULLGabriel de Dietrich2018-04-251-1/+1
| | | | | | | | | | | | Change-Id: Ia0d1f019622d20ad70b5fd8c4122b719c0286738 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Cocoa QPA: Clean up 0 as pointerGabriel de Dietrich2018-04-191-3/+3
| | | | | | | | | | | | | | | | We use nil for Objective-C null pointers and nullptr everywhere else, including CoreFoundation and similar opaque types. Change-Id: Id75c59413dec54bf4d8e83cf7ed0ff7f3d8bb480 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Cocoa Menus: Use the responder chain for menu items target/actionGabriel de Dietrich2018-04-191-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We start by setting the menu item target to nil. Then, -[qt_itemFired:] action is now in QNSView, which itself is naturally inserted in the responder chain. This removes the need to track and change the menu item's target/action when we're displaying a native dialog. Part of this is possible because we now derive our own QCocoaNSMenuItem class from NSMenuItem. We use -[respondsToSelector:] to decide whether the QNSView in the responder chain should respond to cut:, copy:, etc. And we only return YES when the view is first responder. The invocation to these action is forwarded to the same views' -[qt_itemFired:]. Message forwarding is done via forwardInvocation:, but experiments have shown that it can be done by the sole means of respondsToSelector: and direct invocation from cut:, copy:, etc. See the usage of the macro QT_COCOA_DYNAMIC_MENU_ITEM_ACTION. Menu validation also happens in QNSView and looks for modal windows. Therefore, -[worksWhenModal] is no longer necessary. Also, since the target is no longer set, the logic as documented in NSMenuItem.target won't work anymore. Most items from QCocoaMenuLoader also become QCocoaNSMenuItem and get the same target/action, which removes a bit of duplicated (and outdated) code. A particular case is the Quit item, which gets the terminate: action set until an actual menu item is added. Tested with texedit and standard dialogs examples together with menus, menurama and bigmenucreator manual tests. We also renamed some functions and variables to reflect common naming practices. Change-Id: I9b51d3be3467a666d8c3dcf8585edbc821e0282e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Clean up our Objective-C usageJake Petroules2018-02-201-25/+23
|/ | | | | | | | | | | | | | | | - Move ivars into @implementation - Use instancetype where applicable - Use dot notation for property access - Use subscript operator for dictionaries and arrays - Format selectors consistently - Use proper style for init methods - Use generics instead of void pointers where possible - Use "range for" loops instead of indexing - Replace or replace IBAction/IBOutlet with void Change-Id: I1667812a51d4dfe44ae80fe337cb1f4bc9699d92 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.11Liang Qi2018-02-141-4/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/corelib/animation/qvariantanimation.cpp src/corelib/global/qglobal.cpp src/corelib/global/qlogging.cpp src/corelib/io/qprocess_win.cpp src/corelib/json/qjsonarray.cpp src/corelib/tools/qsimd_p.h src/corelib/tools/qtimezoneprivate_p.h src/corelib/xml/qxmlstream_p.h src/gui/kernel/qsimpledrag.cpp src/gui/kernel/qsimpledrag_p.h src/plugins/generic/generic.pro src/plugins/platforms/cocoa/qcocoamenu.mm src/widgets/styles/qmacstyle_mac.mm tests/auto/concurrent/qtconcurrentmap/BLACKLIST tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/dialogs/qmessagebox/BLACKLIST Change-Id: I508d686cf20f7f8cc6a7119b9bc7c3bbb505c58e
| * Fix QFileDialog::defaultSuffix on macOSNathan Collins2018-02-011-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't prepend the default suffix to the NSSavePanel allowedFileTypes. "If no extension is given by the user, the first item in the allowedFileTypes array will be used as the extension for the save panel." The user expects to get the suffix displayed to them in the drop down filter, not the default suffix set by the developer. Apply the default suffix if neither the user or the NSSavePanel provide a suffix. Task-number: QTBUG-66066 Change-Id: I64093b9f3178bd2377a7b65d6f23aed6214a4119 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | Remove code paths for macOS < 10.11Jake Petroules2018-02-111-5/+1
| | | | | | | | | | | | | | Change-Id: I5ae02d88aa3dcd97d1f2ebf6255a68643e5d6daa Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* | Use new QString::remove(QLatin1String)Anton Kudryavtsev2018-02-051-1/+1
| | | | | | | | | | Change-Id: I5b3560709a8fb230a177511c701fd0bf25938f0f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Migrate Cocoa QPA backend to use QRegularExpressionSamuel Gaist2017-12-301-4/+6
| | | | | | | | | | | | | | | | This patch updates the Cocoa QPA backend code to use QRegularExpression in place of the deprecated QRegExp. Change-Id: I6de2774975e63f8dbff6dad0a842f35c3c4b4f83 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Clean up OS version checks for Apple platformsJake Petroules2017-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | Convert QSysInfo/QOperatingSystemVersion to __builtin_available where required or possible, or to QOperatingSystemVersion where __builtin_available cannot be used and is not needed (such as negated conditions, which are not supported by that construct). Change-Id: I83c0e7e777605b99ff4d24598bfcccf22126fdda Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-07-041-4/+0
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/widgets/util/util.pri tests/auto/corelib/thread/qthread/qthread.pro tests/auto/corelib/thread/qthread/tst_qthread.cpp Change-Id: I5c45ab54d46d3c75a5c6c116777ebf5bc47a871b