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
diff --git a/src/AccSecurityVC.mm b/src/AccSecurityVC.mm
index d1e7321..41aa92c 100644
--- a/src/AccSecurityVC.mm
+++ b/src/AccSecurityVC.mm
@@ -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.
diff --git a/src/AppDelegate.mm b/src/AppDelegate.mm
index 7c66b6b..8eb6673 100644
--- a/src/AppDelegate.mm
+++ b/src/AppDelegate.mm
@@ -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];
diff --git a/src/ConversationVC.mm b/src/ConversationVC.mm
index 7d1f7f4..64c68e2 100644
--- a/src/ConversationVC.mm
+++ b/src/ConversationVC.mm
@@ -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]];
diff --git a/src/CurrentCallVC.mm b/src/CurrentCallVC.mm
index b3daccc..2d8cbb3 100644
--- a/src/CurrentCallVC.mm
+++ b/src/CurrentCallVC.mm
@@ -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];
diff --git a/src/SmartViewVC.mm b/src/SmartViewVC.mm
index 6910ec7..c98b9a0 100644
--- a/src/SmartViewVC.mm
+++ b/src/SmartViewVC.mm
@@ -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"
diff --git a/src/backends/AddressBookBackend.mm b/src/backends/AddressBookBackend.mm
index a2b8158..b175666 100644
--- a/src/backends/AddressBookBackend.mm
+++ b/src/backends/AddressBookBackend.mm
@@ -117,13 +117,13 @@
{
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];
diff --git a/src/delegates/ImageManipulationDelegate.mm b/src/delegates/ImageManipulationDelegate.mm
index f3a67da..30e916e 100644
--- a/src/delegates/ImageManipulationDelegate.mm
+++ b/src/delegates/ImageManipulationDelegate.mm
@@ -126,7 +126,7 @@
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);
diff --git a/src/main.mm b/src/main.mm
index fd412b7..5acf9bf 100644
--- a/src/main.mm
+++ b/src/main.mm
@@ -54,7 +54,7 @@
//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);
diff --git a/src/views/IconButton.h b/src/views/IconButton.h
index 3e1dd4e..92e8f2d 100644
--- a/src/views/IconButton.h
+++ b/src/views/IconButton.h
@@ -46,6 +46,11 @@
@property (nonatomic, strong) NSNumber* cornerRadius;
/*
+ * Define pressed state of the button
+ */
+@property (atomic, getter=isPressed) BOOL pressed;
+
+/*
* Padding
* default value : 5.0
*/
diff --git a/src/views/IconButton.mm b/src/views/IconButton.mm
index 45aa00e..5ce29ef 100644
--- a/src/views/IconButton.mm
+++ b/src/views/IconButton.mm
@@ -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];