Commit 4baba4ca authored by Alexandre Lision's avatar Alexandre Lision

osx: fix client compatibility

Xcode does not warn when using unavailable APIs on older SDKs.
After recompiling against the 10.8 SDK, errors appeared across the
client.

- NSButton.highlight state has been added in OSX 10.10
- window.beginSheet has been added in OSX 10.9
- window.keyWindow has been added in OSX 10.10
- NSViewController.viewDidLoad has been added in OSX 10.10
- NSString.containsString has been added in OSX 10.10

Change-Id: I9c4e271f49711570859d85d43608cf8edf294e01
Tuleap: #343
parent 6517be88
......@@ -314,14 +314,31 @@
{
certificateWC = [[CertificateWC alloc] initWithWindowNibName:@"CertificateWindow"];
[certificateWC setCertificate:[self currentAccount]->tlsCaListCertificate()];
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
[self.view.window beginSheet:certificateWC.window completionHandler:nil];
#else
[NSApp beginSheet: certificateWC.window
modalForWindow: self.view.window
modalDelegate: self
didEndSelector: nil
contextInfo: nil];
#endif
}
- (IBAction)showEndpointCertificate:(id)sender
{
certificateWC = [[CertificateWC alloc] initWithWindowNibName:@"CertificateWindow"];
[certificateWC setCertificate:[self currentAccount]->tlsCertificate()];
[self.view.window beginSheet:certificateWC.window completionHandler:nil];}
#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9
[self.view.window beginSheet:certificateWC.window completionHandler:nil];
#else
[NSApp beginSheet: certificateWC.window
modalForWindow: self.view.window
modalDelegate: self
didEndSelector: nil
contextInfo: nil];
#endif
}
/*
Delegate method of NSPathControl to determine how the NSOpenPanel will look/behave.
......
......@@ -101,7 +101,7 @@
// Don't show a notification if we are sending the text OR window already has focus OR user disabled notifications
if(qvariant_cast<Media::Media::Direction>(qIdx.data((int)Media::TextRecording::Role::Direction)) == Media::Media::Direction::OUT
|| self.ringWindowController.window.keyWindow || !shouldNotify)
|| self.ringWindowController.window.isMainWindow || !shouldNotify)
return;
NSUserNotification* notification = [[NSUserNotification alloc] init];
......
......@@ -64,8 +64,8 @@
@implementation ConversationVC
- (void)viewDidLoad {
[super viewDidLoad];
- (void)loadView {
[super loadView];
// Do view setup here.
[self.view setWantsLayer:YES];
[self.view setLayer:[CALayer layer]];
......
......@@ -46,6 +46,7 @@
#import "PersonLinkerVC.h"
#import "ChatVC.h"
#import "BrokerVC.h"
#import "views/IconButton.h"
@interface RendererConnectionsHolder : NSObject
......@@ -73,17 +74,17 @@
// Call Controls
@property (unsafe_unretained) IBOutlet NSView* controlsPanel;
@property QHash<int, NSButton*> actionHash;
@property (unsafe_unretained) IBOutlet NSButton* holdOnOffButton;
@property (unsafe_unretained) IBOutlet NSButton* hangUpButton;
@property (unsafe_unretained) IBOutlet NSButton* recordOnOffButton;
@property (unsafe_unretained) IBOutlet NSButton* pickUpButton;
@property (unsafe_unretained) IBOutlet NSButton* muteAudioButton;
@property (unsafe_unretained) IBOutlet NSButton* muteVideoButton;
@property (unsafe_unretained) IBOutlet NSButton* addContactButton;
@property (unsafe_unretained) IBOutlet NSButton* transferButton;
@property (unsafe_unretained) IBOutlet NSButton* addParticipantButton;
@property (unsafe_unretained) IBOutlet NSButton* chatButton;
@property QHash<int, IconButton*> actionHash;
@property (unsafe_unretained) IBOutlet IconButton* holdOnOffButton;
@property (unsafe_unretained) IBOutlet IconButton* hangUpButton;
@property (unsafe_unretained) IBOutlet IconButton* recordOnOffButton;
@property (unsafe_unretained) IBOutlet IconButton* pickUpButton;
@property (unsafe_unretained) IBOutlet IconButton* muteAudioButton;
@property (unsafe_unretained) IBOutlet IconButton* muteVideoButton;
@property (unsafe_unretained) IBOutlet IconButton* addContactButton;
@property (unsafe_unretained) IBOutlet IconButton* transferButton;
@property (unsafe_unretained) IBOutlet IconButton* addParticipantButton;
@property (unsafe_unretained) IBOutlet IconButton* chatButton;
// Join call panel
......@@ -136,10 +137,9 @@
{
const QModelIndex& idx = CallModel::instance().userActionModel()->index(row,0);
UserActionModel::Action action = qvariant_cast<UserActionModel::Action>(idx.data(UserActionModel::Role::ACTION));
NSButton* a = actionHash[(int) action];
if (a) {
if (auto a = actionHash[(int) action]) {
[a setHidden:!(idx.flags() & Qt::ItemIsEnabled)];
[a setHighlighted:(idx.data(Qt::CheckStateRole) == Qt::Checked) ? YES : NO];
[a setPressed:(idx.data(Qt::CheckStateRole) == Qt::Checked) ? YES : NO];
}
}
......@@ -543,7 +543,7 @@
[self.addParticipantButton setHidden:YES];
[self.transferButton setHidden:YES];
[self.chatButton setState:NSOffState];
[self.chatButton setPressed:NO];
[self.mergeCallsButton setState:NSOffState];
[self collapseRightView];
......
......@@ -39,6 +39,7 @@
#import "delegates/ImageManipulationDelegate.h"
#import "views/HoverTableRowView.h"
#import "PersonLinkerVC.h"
#import "views/IconButton.h"
#import "views/RingOutlineView.h"
#import "views/ContextualTableCellView.h"
......
......@@ -117,13 +117,13 @@ void AddressBookBackend::handleNotification(NSNotification* ns)
{
for (NSString* r in ns.userInfo[kABInsertedRecords]) {
ABRecord* inserted = [[ABAddressBook sharedAddressBook] recordForUniqueId:r];
if (inserted && [[[ABAddressBook sharedAddressBook] recordClassFromUniqueId:r] containsString:@"ABPerson"]) {
if (inserted && [[[ABAddressBook sharedAddressBook] recordClassFromUniqueId:r] rangeOfString:@"ABPerson"].location != NSNotFound) {
editor<Person>()->addExisting(this->abPersonToPerson(inserted));
}
}
for (NSString* r in ns.userInfo[kABUpdatedRecords]) {
if ([[[ABAddressBook sharedAddressBook] recordClassFromUniqueId:r] containsString:@"ABPerson"]) {
if ([[[ABAddressBook sharedAddressBook] recordClassFromUniqueId:r] rangeOfString:@"ABPerson"].location != NSNotFound) {
Person* toUpdate = PersonModel::instance().getPersonByUid([r UTF8String]);
if (toUpdate) {
ABPerson* updated = [[ABAddressBook sharedAddressBook] recordForUniqueId:r];
......
......@@ -126,7 +126,7 @@ namespace Interfaces {
QPixmap ImageManipulationDelegate::drawDefaultUserPixmap(const QSize& size, bool displayPresence, bool isPresent) {
// create the image somehow, load from file, draw into it...
auto sourceImgRef = CGImageSourceCreateWithData((CFDataRef)[[NSImage imageNamed:@"default_user_icon"] TIFFRepresentation], NULL);
auto sourceImgRef = CGImageSourceCreateWithData((__bridge CFDataRef)[[NSImage imageNamed:@"default_user_icon"] TIFFRepresentation], NULL);
auto imgRef = CGImageSourceCreateImageAtIndex(sourceImgRef, 0, NULL);
auto finalpxm = QtMac::fromCGImageRef(resizeCGImage(imgRef, size));
CFRelease(sourceImgRef);
......
......@@ -54,7 +54,7 @@ int main(int argc, const char *argv[]) {
//We need to check if primary language is an English variant (en, en-CA etc...) before installing a translator
NSString* lang = [[NSLocale preferredLanguages] objectAtIndex:0];
if (![lang containsString:@"en"]) {
if (![lang rangeOfString:@"en"].location != NSNotFound) {
QTranslator translator;
if (translator.load(QLocale::system(), "lrc", "_", dir.absolutePath()+"/Resources/QtTranslations")) {
app->installTranslator(&translator);
......
......@@ -45,6 +45,11 @@
*/
@property (nonatomic, strong) NSNumber* cornerRadius;
/*
* Define pressed state of the button
*/
@property (atomic, getter=isPressed) BOOL pressed;
/*
* Padding
* default value : 5.0
......
......@@ -34,6 +34,14 @@
if (self.imageInsets == 0)
self.imageInsets = 8.0f;
self.pressed = NO;
}
-(void) setPressed:(BOOL)newVal
{
_pressed = newVal;
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)dirtyRect
......@@ -44,7 +52,7 @@
NSColor* backgroundStrokeColor;
NSColor* tintColor = [NSColor whiteColor];
if (self.mouseDown || self.isHighlighted) {
if (self.mouseDown || self.isPressed) {
if (self.highlightColor) {
backgroundColor = self.highlightColor;
backgroundStrokeColor = [self.highlightColor darkenColorByValue:0.1];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment