Qt Single Application file opened - c++

I am making an Qt Application.
And I have 2 problems that kind hard for me to figure out :
I create my own file type for my application document, so let say "something.ap". I want my OSes (Windows and Mac, maybe linux), when double click those file on file explorer, it will open using my application. How to implement this on Qt in easy way? On Windows I saw we need to edit the registry, but if there is a good way that will be best thing. And I don't have idea on Mac and Linux.
Related to number one. When I already open my "something.ap", and then I double click the same file ("something.ap"), I won't my application open again on new instance. So the behavior I want is to check if already file opened, it will raise the window of the application. I saw there is QtSingleApplication, but when I check the repository on gitorous can not be access.
Thank you for any help, and sorry if you can't understand my English.

You need to register mime type. check this
Singleton application is available here. It's not maintained any more :P. You can download source as zip or clone the git repository.

Related

Using DISM Api to Capture Image Programatically within Windows PE Environment

I've been going through the windows documentation for the Dism API with the goal of writing an exe in C++ (or whatever language can accomplish this) that can create a WIM image while running in Windows PE. I found a .NET Wrapper for the Dism API that seems like it might be useful for this purpose, but I'm unsure if a .NET app will successfully run in Windows PE. Overall, my problem is that I don't see a function that can create--and doesn't simply modify--a wim file.
If I didn't care about encapsulating this in an .exe file, the Dism documentation does show how to initially create a wim--which makes me curious why a similar function wouldn't exist within the api. Please advise if the simplest solution is to have my code call a function such as system() within the code.
To summarize, I'm looking for a way to create a wim file programmatically (called from executing an exe file) from within Windows PE.
As always, thank you for the help and advice.
I work on a project that works with DISM in WinPE quite a bit. We configure WinPE with all the .net packages as described here. Then WinPE can be configured to start an application.
I use c#, but you can do managed apps in c++ as I'm sure you know. I find putting c# code into WinPE substantially easier, but that's more a function of my experience, I suppose.
The main way we use to interact with DISM is run a command using System.Diagnostics.Process. The process runs in a separate thread, but the API is simple, and you can wait on (and/or timeout) your process for synchronization purposes. This just uses the DISM command line interface, although you can also use powershell cmdlets if you've added that package to your WinPE image. It may seem like a hacky "interface" from your app to DISM, but it works reliably, and you can keep the process window from showing up on the screen. This makes for a decent asynchronous platform for running bunches of windows imaging utilities, such as DISKPART, DISM and BCDEDIT.
The principal way you'd capture a new image is with DISM /Capture-Image. Sounds like you've already discovered this fact. Lots of options that are somewhat beyond the scope of this q/a, but I hope this gets you on a useful path.
Even though this post is a bit older, here is a possibly still relevant resource for you. Perhaps this one will help.
I've written a small GUI-based tool, project-named WIM-Backup, that uses the Windows Imaging Format (WIM) to create full backups of computer systems (operating system images) within WinPE and then restore them.
The application is hosted on GitHub, is open source, and is offered under the Apache 2.0 license.
In addition, the repository includes an illustrated step-by-step guide to help get it up and running.
Brief summary:
WIM-Backup always requires an external bootable media such as a USB flash drive.
From this drive WinPE is booted to perform a backup or restore to or from an external medium (e.g. a USB hard drive).
On the bootable USB flash drive the WinPE must be set up before (is documented illustrated in the readme).
After completion of the respective operation, a status message is displayed whether the operation was successful or failed.
After restoring a backup, you can boot normally from the destination drive.
Both the backup and restore process are relatively simple (not "rocket science").
To set up the solution, you need about 30 minutes time in the best case due to the necessary downloads (e .g. ADK)
Last but not least: it has a permissive license (non-proprietary) and is open source.
The project can be found here: WIM-Backup

C++ code to open a file in vim for editing in a terminal window from Xcode

i've been doing a search and can't quite seem to find a solution for this.
I am coding a realtime openGL visual application using openFrameworks in Xcode.
What I would like to do is to let the user press a button which opens up a terminal window with a glsl script ready for editing in vim.
So, I need to find some c++ code that
lets me launch a new terminal window
send commands to it in order to load a file in vim
close the terminal window
If anyone could point me in the right direction either with code examples or c++ libraries to look into that would be amazing. Thanks.
It's easy to open a process (like vim) with a system call, but a little trickier to open Terminal and then vim inside of that. As an alternative, I'd recommend installing Macvim (https://code.google.com/p/macvim/) which you can easily launch and control with an ofSystem call or, if you need finer-grained control, Poco::Process (http://pocoproject.org/slides/150-Processes.pdf). Since openFrameworks is built with Poco in the core, Poco::Process makes launching things easy.
Finally, as an alternative to all of that, you might look at the newly updated ofxGLEditor (https://github.com/Akira-Hayasaka/ofxGLEditor) that was just overhauled to allow live coding. You might be able to use it to edit directly in your app.
Good luck!

Create Associativity between file extension & application?

I am creating an application using Qt. The files saved from my application have their own file format & extension. I want to associate this file format with my application.
So, when a user double clicks say myfile.ext then the OS should automatically run my application (how to specify its path?) & pass path of file as an argument.
I have only used Windows until now so I am talking in terms of it. I dont know how other OS's behave. Any guidance for the same would be helpful?
PS: Even though I am using Qt which apparently has no special functionality to do what is asked here (AFAIK), it would be awesome to know how to do this in standard C++.
For Windows see the MSDN page "File Type Handlers" for how to register file type handlers.
On many popular Linux desktops, so-called .desktop files are used to define what application to use for opening a file. See the "Desktop Entry Specification" for the structure of those .desktop files. They are quite simple really, changes are you can just take an existing file from any of the popular Linux desktop environments (e.g. KDE) and modify it a bit.
It's a function of the OS, not of the C++ language.
You'll need to figure it out on each platform you are supporting.

Drag-and-drop onto the desktop or into a specific folder, without temporary storage.

I've written a little file-transfer application written in C++ using Qt 4.x. It logs into a server, shows the user a list of files available on the server, and lets the user upload or download files.
This all works fine; you can even drag a file in from the desktop (or from an open folder), and when you drop the file icon into the server-files-list-view, the dropped file gets uploaded to the server.
Now I have a request for the opposite action as well. My users would like to be able to drag a file out of the server-files-list-view and onto the desktop, or into an open folder window, and have that file get downloaded into that location.
That seems like a reasonable request, but I don't know how to implement it. Is there a way for a Qt application to find out the directory corresponding to where "drop event" occurred, when the icon was dropped onto the desktop or into an open folder window? Ideally this would be a Qt-based platform-neutral mechanism, but if that doesn't exist, then platform-specific mechanisms for MacOS/X and Windows (XP or higher) would suffice.
Even though I have never done exactly what you intend, I reckon this is doable with Qt.
You first have to deal with the drag event. This depends on the view you are using to see the files heirarchy in your server. Anyway here is a link to help you enable drag files from your view: http://www.trinitydesktop.org/docs/qt4/model-view-dnd.html In short it's just a couple a virtual functions to reimplement. The doc is here to help.
You may also see this link about how Drag/Drop events are handled in Qt: http://www.trinitydesktop.org/docs/qt4/dnd.html
I was about to answer about the drop event, when I noticed that the same question was asked word for word 3 years ago...
Qt 4.x: how to implement drag-and-drop onto the desktop or into a folder?

How to access the picture file on iPod/iPhone?

When I connect the iPod (or iPhone) to the Windows PC,
it look like an USB drive, but I can't open a file on it because I can't know the correct file path.
I was also unable to drop the file to my application because the drag source does not have CF_HDROP.
Some applications can open a file on iPod, but it was a copy on the local temp folder.
screenshot http://img862.imageshack.us/img862/5396/ipodx.png
My question is ..
How can I directly (programmatically) open and read the picture file on iPod?
If I double click on it (or right click and select Preview menu),
it launches Windows Photo Viewer -- it is not my default picture viewer.
Can I change the file (.PNG) association to other application?
What's the viewer application's requirement to be a default viewer for files on ipod?
Applications that do that use Picture Transfer Protocol (PTP). On Windows Microsoft implements many interfaces as part of Windows Image Acquisition (WIA). Read more here: http://msdn.microsoft.com/en-us/library/ms630344(v=VS.85).aspx
http://support.microsoft.com/kb/307859 or manually edit registry at HKEY_CLASSES_ROOT\.png
Try the iPhoneBrowser program. It should give you a fair idea of the path.
From everything I've read I don't think Apple gives you access to the file system on the iPhone / iTouch / iPad; they want you to use iTunes to transfer files back and forth. I believe the Android and Windows Phone environments have similar restrictions. (If you "jailbreak" or "root" your device that's obviously a different story, which is why many such utilities explicitly state they only work on rooted devices.)
In part, this is a security precaution: if it were possible to directly access the file system on the mobile device it would be that much easier for someone to plant malware on your phone or PDA.
For this reason, updates to the various mobile OSes frequently include changes to (1) make jailbreaking more difficult and/or (2) close the loopholes that allow software like the iPhoneBrowser to work.
Some of the portable music players that use (Windows) Media Player have similar limitations. For example, I had a Sansa m100 (I think) where I could just drag files to the device and the playlist would automatically get updated; on at least some of the newer models (eg the c200) you have to use Media Player to download content. Which to me is annoying since there doesn't seem to be a way to use Media Player to delete content from the device.
There probably are APIs to do this sort of thing, but I would guess they're somewhat specific to the platform you're using -- ie I don't think you're going to be able to just use CreateFile() or something like that.