Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59805

Support caption in Mac OS native Open File dialog

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.6.1, 5.9.1, 5.11
    • Fix Version/s: None
    • Component/s: QPA
    • Environment:

      MacOS 10.11 or later

    • Platform/s:
      macOS

      Description

      Our program (IGOR Pro) is user-programmable in the IGOR programming language. A programmer can display an Open File dialog to ask the user to choose an input file. This is done using the Open operation. For example:

      Open/D/R/M="Choose filter coefficients file" ...
      

      The /M flag allows the programmer to specify a prompt telling the user what the program is looking for.

      In OS X 10.10 and before, the prompt appeared in the Open File dialog title bar. As explained at http://stackoverflow.com/questions/36879212/title-bar-missing-in-nsopenpanel, starting with OS X 10.11, Apple removed the title bar from the Open File dialog, so the prompt is no longer visible. This means that, if an IGOR program displays the Open File dialog, the user has no clue as to what the program is looking for. We get a lot of complaints about this from IGOR programmers.

      (Strangely, the title bar still appears in the native Save File dialog and does show the caption when called from Qt.)

      The Qt Open File dialog, as opposed to the native Open File dialog, still has a title bar and, if we use the Qt dialog, our prompt appears in the title bar, as expected. However, the Qt Open File dialog is missing a lot of features that users like and looks and feels distinctly non-native, so switching to it is not a good option.

      In qcocoafiledialoghelper.mm, we have this code:

      [mSavePanel setTitle:QCFString::toNSString(options->windowTitle())];
      

      This does no good in the Open File dialog because OS X no longer displays the title in that dialog.

      NSSavePanel, on which NSOpenPanel is based, has a message property which is described at https://developer.apple.com/reference/appkit/nssavepanel as "The message text displayed in the save panel". If you set this property, you get a facsimile of a title bar in the Open File dialog and the facsimile displays the specified message.

      I would like to see the native implementations of QFileDialog::getOpenFileName changed to set the NSSavePanel message property using the caption parameter rather than setting the title property, since the title is never displayed. The code would look like this:

      bool useMessagePropertyForCaption = false;
      if (mOptions->acceptMode() == QFileDialogOptions::AcceptOpen) {
      	const double NSAppKitVersionNumber10_11 = 1404;	// From https://developer.apple.com/library/content/releasenotes/AppKit/RN-AppKit/
      	if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_11) {
      		// As of OS X 10.11, Apple does not show the title bar in the Open File dialog, so we use the message property instead of the title property
      		useMessagePropertyForCaption = true;
      	}
      }
      if (useMessagePropertyForCaption)
      	[mSavePanel setMessage:QCFString::toNSString(options->windowTitle())];
      else
      	[mSavePanel setTitle:QCFString::toNSString(options->windowTitle())];
      

      QFileDialog::getExistingDirectory should be changed in the same way because, in OS X 10.11 and later, that dialog also does not have a title bar.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              vhilshei Volker Hilsheimer
              Reporter:
              hrodstein Howard Rodstein
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              Votes:
              13 Vote for this issue
              Watchers:
              18 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes