Hide dock icon on minimize macOS
This commit is contained in:
parent
6cd4dc8674
commit
bc5fedbbec
5 changed files with 41 additions and 0 deletions
|
|
@ -1421,11 +1421,13 @@ macx {
|
|||
|
||||
HEADERS += \
|
||||
AutoStart/AutoStart-MacOS.h \
|
||||
qt/macutils.h \
|
||||
|
||||
SOURCES += \
|
||||
dependencies/hueplusplus-1.0.0/src/LinHttpHandler.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
AutoStart/AutoStart-MacOS.cpp \
|
||||
qt/macutils.mm \
|
||||
|
||||
# Use mbedtls v2 instead of latest
|
||||
MBEDTLS_PREFIX = $$system(brew --prefix mbedtls@2)
|
||||
|
|
|
|||
7
main.cpp
7
main.cpp
|
|
@ -21,6 +21,10 @@
|
|||
|
||||
#include "OpenRGBDialog2.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "macutils.h"
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
|
|
@ -339,6 +343,9 @@ int main(int argc, char* argv[])
|
|||
|
||||
if(ret_flags & RET_FLAG_START_MINIMIZED)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
MacUtils::ToggleApplicationDocklessState(false);
|
||||
#endif
|
||||
dlg.hide();
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -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
10
qt/macutils.h
Normal 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
9
qt/macutils.mm
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue