Commit abf4e273 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Alexandre Lision

selected account: behaviour on conversation

This commit add a few changes to prevent bugs when account is changed
during call or conversation or when:

- Receiving an incoming call change selected account to be the same
as call destination account
- Making a call disable account selection
- Changing the selected account close current conversation

Tuleap: #1532
Change-Id: Ia37fabce0285a02233b35e69e73244e14d0a334a
Reviewed-by: default avatarAlexandre Lision <alexandre.lision@savoirfairelinux.com>
parent 312f913f
......@@ -28,6 +28,8 @@
#import <media/textrecording.h>
#import <QItemSelectionModel>
#import <account.h>
#import <AvailableAccountModel.h>
#if ENABLE_SPARKLE
#import <Sparkle/Sparkle.h>
......@@ -120,6 +122,14 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet
QObject::connect(&CallModel::instance(),
&CallModel::incomingCall,
[=](Call* call) {
// on incoming call set selected account match call destination account
if (call->account()) {
QModelIndex index = call->account()->index();
index = AvailableAccountModel::instance().mapFromSource(index);
AvailableAccountModel::instance().selectionModel()->setCurrentIndex(index,
QItemSelectionModel::ClearAndSelect);
}
BOOL shouldComeToForeground = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::WindowBehaviour];
BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::Notifications];
if (shouldComeToForeground) {
......
......@@ -21,4 +21,7 @@
@interface ChooseAccountVC : NSViewController
-(void) enable;
-(void) disable;
@end
......@@ -206,4 +206,11 @@ QMetaObject::Connection accountUpdate;
selectedMenuItem = nil;
}
-(void) enable {
[accountSelectionButton setEnabled:YES];
}
-(void) disable {
[accountSelectionButton setEnabled:NO];
}
@end
......@@ -108,15 +108,18 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarItem
if(!current.isValid()) {
[offlineVC animateOut];
[currentCallVC animateOut];
[chooseAccountVC enable];
return;
}
if (!call) {
[currentCallVC animateOut];
[offlineVC animateIn];
[chooseAccountVC enable];
} else {
[currentCallVC animateIn];
[offlineVC animateOut];
[chooseAccountVC disable];
}
});
......@@ -130,16 +133,19 @@ NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarItem
if (previous.isValid()) {
// We were already on a call
[currentCallVC animateOut];
[chooseAccountVC enable];
} else {
// Make sure Conversation view hides when selecting a valid call
[currentCallVC animateIn];
[offlineVC animateOut];
[chooseAccountVC disable];
}
});
QObject::connect(AvailableAccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[self](const QModelIndex& idx){
[self updateRingID];
[offlineVC animateOut];
});
}
......
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