amnezia-client/client/ui/macos_util.mm
pokamest 0569c6411e
Release 1.1 (#5)
* Crash fix in management server

* Openvpn scripts fixes
some refactoring

* deploy fix

* Scripts fix for macos

* OpenVpn runtime error codes handling

* MacOS deploy script fix

* easyrsa scripts for MacOS

* Refactoring
Ui improvements
Bug fixes

* new server page fix

* Fix some warnings, fix installation scripts (macOS)

* Fix crash on fatal error, remove moc files from Windows installation

* ss files

* Fix issue with easyrsa

* ss files

* shadowsocks impl

* ss fix

* ui fix

* Macos doc icon

* travis scripts

* server scripts fix

* icon changed

* Server scripts fix

* travis fix

* Bug fixes:
- auto install tap
- share connectionState
- service crash fix

* travis release

* macos deploy
2021-01-27 00:57:02 +03:00

61 lines
1.9 KiB
Text

#include <QMainWindow>
#include <Cocoa/Cocoa.h>
#include "macos_util.h"
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
void setDockIconVisible(bool visible)
{
if (!visible) {
[NSApp setActivationPolicy: NSApplicationActivationPolicyAccessory];
} else {
[NSApp setActivationPolicy: NSApplicationActivationPolicyRegular];
}
}
//this Objective-c class is used to override the action of system close button and zoom button
//https://stackoverflow.com/questions/27643659/setting-c-function-as-selector-for-nsbutton-produces-no-results
@interface ButtonPasser : NSObject{
}
@property(readwrite) QMainWindow* window;
+ (void)closeButtonAction:(id)sender;
- (void)zoomButtonAction:(id)sender;
@end
@implementation ButtonPasser{
}
+ (void)closeButtonAction:(id)sender
{
Q_UNUSED(sender);
ProcessSerialNumber pn;
GetFrontProcess (&pn);
ShowHideProcess(&pn,false);
}
- (void)zoomButtonAction:(id)sender
{
Q_UNUSED(sender);
if (0 == self.window) return;
if (self.window->isMaximized()) self.window->showNormal();
else self.window->showMaximized();
}
@end
void fixWidget(QWidget *widget)
{
NSView *view = (NSView *)widget->winId();
if (0 == view) return;
NSWindow *window = view.window;
if (0 == window) return;
//override the action of close button
//https://stackoverflow.com/questions/27643659/setting-c-function-as-selector-for-nsbutton-produces-no-results
//https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaEncyclopedia/Target-Action/Target-Action.html
// NSButton *closeButton = [window standardWindowButton:NSWindowCloseButton];
// [closeButton setTarget:[ButtonPasser class]];
// [closeButton setAction:@selector(closeButtonAction:)];
[[window standardWindowButton:NSWindowZoomButton] setHidden:YES];
[[window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
}