Qt 4.8.5 Mac Handle file dropping on dock icon - macos

I'm porting some Qt apps to Mac OS. And have some questions because I have no experience in developing apps for Mac OS.
Where Applications usually save there settings in Mac OS?
How to handle file dropping on icon in dock?

Mac OS X applications typically save their settings in ~/Library/Preferences/ using an XML document called a Property List. If you use the QCoreApplication::setOrganization(..) et all methods, just use QSettings and your code will remain cross platform and do the right thing.
Handling file dropping on the application icon is a little more involved but there is already a pretty good answer and also a Qt Quarterly dealing with this problem. It will basically involve:
Setting up the Info.plist in the application bundle to identify what files types are handled by your application.
Subclassing QApplication to handle QEvent::FileOpen.

Related

On macOS how can I open a gui .app hidden or off screen?

I have a cross platform need to open a gui application programmatically, but keep it hidden from the user. Effectively, I want a command line driven interface to act as a wrapper over this gui app, and insulate the end user from seeing or interacting with it. The program is from a third party, I did not write it, and I can't edit it.
I can do this one way or another on Windows, on Linux, and (in theory) on older versions of Mac, but not the most recent ones. On Windows, I can use the native api ShellEx with a hide window parameter. It's very easy and straight forward. In Linux, I can can render a gui app to a virtual frame buffer (using xvfb).
On macOS, the open command has a --hide and --background option, but they don't have any effect (at least on this app...)
I tried changing the plist file and found that LSUIElement will hide the app from the docker, but it still shows up on the screen. LSUIPresentationMode=4 or 3 OUGHT to work for exactly this, but apparently that doesn't do anything anymore as of a few os versions ago...
I tried the approach of moving the .app off of the screen with AppleScript. That works, but you have to manually grant permissions for such a thing to occur via System Preferences. In prior versions of Mac, those permissions could be twiddled on the fly via sqlLite (so long as you had sudo rights), but now they blocked that too. You can only pull that off apparently through a process of disabling "SIP" and forcing a reboot. That is totally outside the realm of what I want.
I've tried using the xvfb approach on Mac (jumping through hoops to acquire the binary they use to include stock, and now dropped), but I'm not having luck with that. I don't think it's possible to direct a mac .app to another display is it? A .app does not render on X11 by it's nature right?
What other clever ways might there be to hide a third party app on a mac? (and that still works in most recent os versions!)

What do I convert a Delphi Win32 resource DLL to for a Delphi macOS app?

I have a resource DLL for a Windows Delphi app. I want to port this to macOS, and eventually to iOS (for iPad only, not iPhone). I have yet to dip my toes into developing outside of the VCL (I don't even own a Mac yet, though I know I will need one eventually). The FireMonkey stuff, no problem (yet). I just wonder what approach to take to port a Windows resource DLL to other platforms.
For Firemonkey, you can user the dialog box in menu "Project / Resource and images".
This help page will give you code sample to use it in your program :
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Resource_Files_Support

how to make firefox or any other xulrunner based app float above all other windows in mac 10.6 and above?

afloat is very useful to keep the window above all the windows in mac, but only cocoa based applications. Is there a way that one can achieve this feature for other applications programmatically. example firefox
I do not want to use afloat, but I would like to know how to code this feature in mac.
Thanks a lot!!

How to implement "Open With" contextual menu in OS X

Apps in OS X that can open files to launch their respective applications often let the user choose the app that'll open the file. An example is the Finder.
I am still unclear about what's the best solution to implement this. The challenges are performance and showing the app's icon.
First, to get the list of apps, I found only LSCopyApplicationURLsForURL().
The major difficulty for me now is to get the app icons. All I have is the URLs (paths) to the apps. The only way I know of to get the icons would be to create a CFBundle object and then read the app's plist to get the icon data. But that appears to invole lots of disk access, and I could imagine it'll be quite inefficient if the app is located on a remote file server.
I believe that there's also a cached database about the apps, which includes icons and display names (without extension), and such. But where is the API for that?
Note: The app is Carbon based, but I can make use of Cocoa (NS...) functions if necessary. Also, Support for 10.5, even 10.4, would be appreciated.
Alright. I solved it eventually.
I now use the Carbon function GetIconRefFromFileInfo(), which still works in Lion, though it's marked deprecated/obsolete.
I had also tried to use QLThumbnailImageCreate(), but that didn't get me any results, oddly. No idea what I did wrong.
For Cocoa apps, [[NSWorkspace sharedWorkspace] iconForFile:path] can be used (thanks to C. Grunenberg of DevonTechnologies for this tip, where it's used with EasyFind).

Using Qt in a pre-existing x-platform project?

I have an existing cross platform project that runs on Mac, Linux and Windows.
Now, I want to add a 'native' UI to it - the ability to show some popup windows (to request user credentials) and perhaps FileOpen dialogs. By native I mean I want to use the systems build in file-open dialog - so on the Mac the mac file finder is shown and on Windows the shells file open window is shown.
Qt seems a good fit - its samples show that it can show the correct dialog on all platforms.
However, all the available Qt samples start at the very base level - assuming the entire project is developed in Qt. Is it possible to initialize and use Qt in a more ad-hoc fashion :- i want to keep all my Qt UI code in a seperate dll/dylib/so file with some simple exports (think ShowLoginPopup).
I think that the easiest approach would be to do it the other way around - having the Qt GUI drive the rest of the application. Qt is event based and does rely on its event loop, so you need to keep that running.

Resources