如何在c ++ / QT中以编程方式右击文件/文件夹添加自定义菜单? [英] How to add custom menu upon right click on file / folder programmatically in c++ / QT?

查看:362
本文介绍了如何在c ++ / QT中以编程方式右击文件/文件夹添加自定义菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个应用程序,像dropbox的方式同步文件和文件夹。这是一个基于c ++ / QT的安装程序。

We have an app which syncs files and folder like the way dropbox does. This is an c++ / QT based installer.

我们希望在文件或文件夹的右键单击上下文菜单中添加自定义菜单,就像dropbox在下面的屏幕截图中所做的那样。

We would like add custom menu in the right click context menu of a file or folder like the way dropbox does in the below screen shot.

我们的目标是窗口& Mac平台。任何人都可以告诉我如何开始使用它?

We are targeting both windows & Mac platforms. Can anyone suggest me how to start with it?

推荐答案

在Mac上,你会遇到问题,因为添加到一般的Finder上下文菜单已弃用。

On Mac, you're going to have problems as adding to the general Finder Context Menu has been deprecated.

所以,你可能会想,如果它被弃用,那么Dropbox如何做呢?根据我过去研究的内容,我相信他们使用代码注入来注入正在运行的Finder应用程序的地址空间,然后使用一个称为方法调换的Objective-C特性将方法调用到自己的方法中,在注入的代码。

So, you may be thinking, if it's deprecated, then how do Dropbox do this? From what I've researched in the past, I believe they use code injection to inject into the running Finder application's address space and then an Objective-C feature known as method swizzling to change calling a method to one of their own, which is located in the injected code.

这是相当hardcore和非常低的水平,但如果你要去的旅程,你可以开始查找一个库称为mach_inject和googling关于它。源代码可以在这里找到: -

This is all fairly hardcore and very low level, but if you're going to go on that journey, you can start by looking into a library called mach_inject and googling about it. The source code can be found here: -

https://github.com/ rentzsch / mach_inject

但是,请注意,有些人认为代码注入是错误的,不会安装Dropbox或任何其他使用它的软件。此外,如果您计划在Mac Store中发布产品,我不会指望允许执行代码注入的任何应用程序。

However, be aware that there are those that believe code-injection is wrong and won't install Dropbox or any other software that uses it. In addition, if you're planning on releasing a product in the Mac Store, I wouldn't expect any application that performs code injection to be allowed.

这篇关于如何在c ++ / QT中以编程方式右击文件/文件夹添加自定义菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆