ui fixes for macos
This commit is contained in:
parent
e38ff95688
commit
9fa515a9d4
6 changed files with 81 additions and 236 deletions
48
client/ui/macos_util.mm
Normal file
48
client/ui/macos_util.mm
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#include <QMainWindow>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include "macos_util.h"
|
||||
|
||||
//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];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue