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

Support caption in Mac OS native Open File dialog

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.6.1, 5.9.1, 5.11
    • QPA
    • MacOS 10.11 or later

    • 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

        1. image-2018-06-29-15-08-06-159.png
          276 kB
          Tor Arne Vestbø
        2. Screen Shot 2018-06-29 at 12.00.50.png
          113 kB
          Morten Sørvig
        3. Screen Shot 2018-06-29 at 12.05.00.png
          108 kB
          Morten Sørvig
        4. Screenshot 2022-03-19 at 22.04.56.png
          94 kB
          Volker Hilsheimer
        5. Screenshot 2022-03-19 at 22.05.19.png
          104 kB
          Volker Hilsheimer
        6. Screenshot 2022-03-20 at 13.05.20.png
          121 kB
          Volker Hilsheimer
        7. Screenshot 2022-03-21 at 10.32.53.png
          161 kB
          Volker Hilsheimer
        8. Screen Shot 2022-03-21 at 5.57.30 am.png
          87 kB
          Michael Smithers

        Issue Links

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

          Activity

            People

              vhilshei Volker Hilsheimer
              hrodstein Howard Rodstein
              Vladimir Minenko Vladimir Minenko
              Votes:
              15 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes