macos 程序意外退出_如何在MacOS中将Command + Q保留为“慢速退出”应用程序

macos 程序意外退出

macos 程序意外退出

To quit an app on a Mac, you can just press Command+Q on your keyboard. This however, can lead to unintended consequences, namely accidentally quitting apps if your fingers are in the wrong place.

要在Mac上退出某个应用,只需按键盘上的Command + Q。 但是,这可能会导致意想不到的后果,即如果手指放在错误的位置,则会意外退出应用程序

A while back, Chrome introduced a feature that let you switch to a “slow quit”, requiring you to hold Command+Q for a few seconds before an app would actually quit. If you like this feature, and want it in your other Mac apps, there is a third-party utility that can help you do so.

不久前,Chrome推出了一项功能,可让您切换到“缓慢退出”状态,要求您按住Command + Q几秒钟才能真正退出应用程序。 如果您喜欢此功能,并希望在其他Mac应用程序中使用它,则可以使用第三方实用程序来帮助您。

It’s called SlowQuitApps, and you can find the latest stable releases on this page. Keep in mind that this app is still very much in beta and may not be feature-complete. In our test, it proved to be stable enough and worked as intended, however.

它称为SlowQuitApps ,您可以在此页面上找到最新的稳定版本 。 请记住,此应用仍处于测试阶段,可能功能不完整。 在我们的测试中,事实证明它足够稳定并且可以按预期工作。

Download SlowQuitApps from the link above, then install it by dragging SlowQuitApps it into your Applications folder.

从上面的链接下载SlowQuitApps,然后通过将SlowQuitApps拖到“应用程序”文件夹中进行安装。

The first time you launch SlowQuitApps, it will ask you if you want to automatically launch it when you log in. We clicked “Yes”. You can always change this at a later time.

首次启动SlowQuitApps时,它将询问您是否要在登录时自动启动它。我们单击“是”。 您随时可以在以后更改它。

Once installed, SlowQuitApps will act as an intermediary between you and Command+Q. When you press Command+Q, a black countdown overlay will appear on top of your app. This overlay will count down until the application quits, or you release the keyboard shortcut.

安装完成后,SlowQuitApps将充当您和Command + Q之间的中介。 当您按Command + Q时,黑色的倒计时叠加层将出现在您的应用程序顶部。 在应用程序退出之前,该覆盖层将递减计数,或者您释放键盘快捷键。

In other words, it will abort quitting the application if you release Command+Q before the countdown completes.

换句话说,如果您在倒计时完成之前释放Command + Q,它将中止退出应用程序。

You can also adjust the delay if you prefer. By default, it is set to quit applications after 2 seconds, but you can make that longer or shorter by opening the Terminal and typing the following command and hitting “Enter”:

您也可以根据需要调整延迟时间。 默认情况下,它设置为2秒后退出应用程序,但是您可以通过打开“终端”并键入以下命令并单击“ Enter”来延长或缩短该应用程序:

$ defaults write com.dteoh.SlowQuitApps delay 5000

You want to change the value after “delay” accordingly. This value is in milliseconds, so if you want the delay to be 10 seconds, you’d use “10000”, as seen in the following screenshot.

您要相应地在“延迟”之后更改值。 该值以毫秒为单位,因此,如果您希望延迟时间为10秒,则可以使用“ 10000”,如以下屏幕截图所示。

Finally, to uninstall SlowQuitApps, delete it from your Applications folder.

最后,要卸载SlowQuitApps,请从“应用程序”文件夹中将其删除。

To change whether it runs when you login, open your System Preferences, then click “Users & Groups”.

要更改其在登录时是否运行,请打开“系统偏好设置”,然后单击“用户和组”。

Click on your user profile, then click the “Login Items” tab. You have two options, you can uncheck the box next to this item to temporarily disable it, or you can remove it altogether by selecting it and then clicking the small “-” symbol as shown by the red arrow.

单击您的用户个人资料,然后单击“登录项目”选项卡。 您有两个选项,您可以取消选中该项目旁边的框以暂时禁用它,也可以通过选择它然后单击红色箭头所示的小“-”符号将其完全删除。

Note, this does not remove the application from your computer, it simply stops it from launching when you log in.

请注意,这不会从计算机中删除该应用程序,只会在您登录时阻止其启动。

Just keep in mind, disabling or removing the login item means that SlowQuitApps won’t start automatically unless you re-add the login item or reinstall the app.

请记住,禁用或删除登录项意味着SlowQuitApps不会自动启动,除非您重新添加登录项或重新安装该应用程序。

The other thing to know is that SlowQuitApps doesn’t work when you Command+Q from the app switcher (Command+Tab).

要知道的另一件事是,当您从应用程序切换器(Command + Tab)进行Command + Q时,SlowQuitApps不起作用。

Hopefully, the developer will add this option in a future release.

希望开发人员在将来的版本中添加此选项。

For now however, it should significantly reduce the number of applications you accidentally quit, just be sure to set the delay long enough for you to react.

但是,现在,它应该可以大大减少意外退出的应用程序的数量,只需确保将延迟设置足够长的时间,以便您做出React。

翻译自: https://www.howtogeek.com/263342/how-to-hold-commandq-to-slow-quit-apps-in-macos/

macos 程序意外退出

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
macOS 上,当程序退出时,系统会向它的子进程发送 SIGTERM 信号,使得子进程也随之退出。如果你希望程序退出时不影响 QProcess 的执行,可以通过以下步骤实现: 1. 在程序退出时,不要直接调用 exit() 函数,而是通过捕获 SIGTERM 信号来处理程序退出。 2. 在 QProcess 启动之前,设置 QProcess 的 ProcessChannelMode 为 QProcess::SeparateChannels,这样可以将子进程的标准输出和标准错误输出分别传递到 QProcess 的 readyReadStandardOutput() 和 readyReadStandardError() 信号中。 3. 在收到 SIGTERM 信号时,不要直接调用 QProcess 的 terminate() 函数,而是先向子进程发送 SIGINT 信号,等待一段时间后再调用 QProcess 的 terminate() 函数,确保子进程有足够的时间完成它的任务。 4. 在程序退出前,需要等待 QProcess 执行完成,可以通过调用 QProcess 的 waitForFinished() 函数实现。 以下是示例代码: ```cpp #include <QCoreApplication> #include <QProcess> #include <signal.h> void handleSigTerm(int signum) { // 发送 SIGINT 信号给子进程 QProcess::execute("killall", "-INT", "your_process_name"); // 等待一段时间,确保子进程有足够的时间完成它的任务 QThread::msleep(1000); // 终止子进程 QProcess::execute("killall", "-TERM", "your_process_name"); } int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); // 设置信号处理函数 signal(SIGTERM, handleSigTerm); // 创建 QProcess QProcess process; process.setProcessChannelMode(QProcess::SeparateChannels); // 启动子进程 process.start("your_process_name", QStringList() << "arg1" << "arg2"); // 等待子进程执行完成 process.waitForFinished(-1); // 程序退出 return app.exec(); } ``` 其中,your_process_name 为你要执行的子进程的名称。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值