Hide dock icon on minimize macOS

This commit is contained in:
Shady Nawara 2022-04-28 05:20:37 +00:00 committed by Adam Honse
parent 6cd4dc8674
commit bc5fedbbec
5 changed files with 41 additions and 0 deletions

View file

@ -18,6 +18,10 @@
#include <QCloseEvent>
#include <QStyleFactory>
#ifdef __APPLE__
#include "macutils.h"
#endif
using namespace Ui;
static QString GetIconString(device_type type, bool dark)
@ -486,6 +490,9 @@ void OpenRGBDialog2::closeEvent(QCloseEvent *event)
if (IsMinimizeOnClose() && !this->isHidden())
{
#ifdef __APPLE__
MacUtils::ToggleApplicationDocklessState(false);
#endif
hide();
event->ignore();
}
@ -1382,10 +1389,16 @@ void OpenRGBDialog2::on_ShowHide()
{
if(isHidden())
{
#ifdef __APPLE__
MacUtils::ToggleApplicationDocklessState(true);
#endif
show();
}
else
{
#ifdef __APPLE__
MacUtils::ToggleApplicationDocklessState(false);
#endif
hide();
}
}

10
qt/macutils.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef MACUTILS_H
#define MACUTILS_H
class MacUtils
{
public:
static void ToggleApplicationDocklessState(bool showDock);
};
#endif // MACUTILS_H

9
qt/macutils.mm Normal file
View file

@ -0,0 +1,9 @@
#import <Cocoa/Cocoa.h>
#include "macutils.h"
void MacUtils::ToggleApplicationDocklessState(bool showDock)
{
ProcessApplicationTransformState transformState = showDock ? ProcessApplicationTransformState(kProcessTransformToForegroundApplication) : ProcessApplicationTransformState(kProcessTransformToUIElementApplication);
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, transformState);
}