Commit 8585cc01 authored by Anthony Léonard's avatar Anthony Léonard Committed by Kateryna Kostiuk

deselect conversation when right panel disappear

When the back button is pressed, the selected conversation in the list
is now deselected. Prior to this patch, it was necessary to select
another conversation then the first one to reopen the chat view with
a contact.

Change-Id: I46a253ecd2161c76bb4d8bab26b7b1389248abc9
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 01634109
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#import <api/conversation.h> #import <api/conversation.h>
#import <api/conversationmodel.h> #import <api/conversationmodel.h>
@class RingWindowController;
@interface ConversationVC : NSViewController @interface ConversationVC : NSViewController
-(void) initFrame; -(void) initFrame;
...@@ -36,4 +38,6 @@ ...@@ -36,4 +38,6 @@
- (void) setConversationUid:(const std::string)convUid model:(lrc::api::ConversationModel*)model; - (void) setConversationUid:(const std::string)convUid model:(lrc::api::ConversationModel*)model;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow;
@end @end
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#import "AvailableAccountModel.h" #import "AvailableAccountModel.h"
#import "MessagesVC.h" #import "MessagesVC.h"
#import "utils.h" #import "utils.h"
#import "RingWindowController.h"
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
...@@ -62,6 +63,8 @@ ...@@ -62,6 +63,8 @@
const lrc::api::conversation::Info* cachedConv_; const lrc::api::conversation::Info* cachedConv_;
lrc::api::ConversationModel* convModel_; lrc::api::ConversationModel* convModel_;
RingWindowController* delegate;
// All those connections are needed to invalidate cached conversation as pointer // All those connections are needed to invalidate cached conversation as pointer
// may not be referencing the same conversation anymore // may not be referencing the same conversation anymore
QMetaObject::Connection modelSortedConnection_, filterChangedConnection_, newConversationConnection_, conversationRemovedConnection_; QMetaObject::Connection modelSortedConnection_, filterChangedConnection_, newConversationConnection_, conversationRemovedConnection_;
...@@ -73,6 +76,15 @@ ...@@ -73,6 +76,15 @@
@implementation ConversationVC @implementation ConversationVC
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow
{
if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
{
delegate = mainWindow;
}
return self;
}
-(const lrc::api::conversation::Info*) getCurrentConversation -(const lrc::api::conversation::Info*) getCurrentConversation
{ {
if (convModel_ == nil || convUid_.empty()) if (convModel_ == nil || convUid_.empty())
...@@ -191,6 +203,7 @@ ...@@ -191,6 +203,7 @@
} }
- (IBAction)backPressed:(id)sender { - (IBAction)backPressed:(id)sender {
[delegate rightPanelClosed];
[self animateOut]; [self animateOut];
} }
......
...@@ -49,4 +49,10 @@ namespace lrc { ...@@ -49,4 +49,10 @@ namespace lrc {
*/ */
- (void) selectAccount:(const lrc::api::account::Info&)accInfo; - (void) selectAccount:(const lrc::api::account::Info&)accInfo;
/**
* Method triggered when a panel on the right is closed by user action. It triggers any action needed
* on itself or other view controllers to react properly to this event.
*/
-(void) rightPanelClosed;
@end @end
...@@ -95,7 +95,7 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde ...@@ -95,7 +95,7 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
lrc_ = std::make_unique<lrc::api::Lrc>(); lrc_ = std::make_unique<lrc::api::Lrc>();
currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil]; currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil];
offlineVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil]; offlineVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil delegate:self];
// toolbar items // toolbar items
chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:&(lrc_->getAccountModel()) delegate:self]; chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:&(lrc_->getAccountModel()) delegate:self];
contactRequestVC = [[ContactRequestVC alloc] initWithNibName:@"ContactRequest" bundle:nil]; contactRequestVC = [[ContactRequestVC alloc] initWithNibName:@"ContactRequest" bundle:nil];
...@@ -373,6 +373,11 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde ...@@ -373,6 +373,11 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
[self updateRingID]; [self updateRingID];
} }
-(void)rightPanelClosed
{
[smartViewVC deselect];
}
#pragma mark - NSToolbarDelegate #pragma mark - NSToolbarDelegate
- (nullable NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag - (nullable NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{ {
......
...@@ -46,4 +46,9 @@ namespace lrc { ...@@ -46,4 +46,9 @@ namespace lrc {
*/ */
-(void)selectConversation:(const lrc::api::conversation::Info&)conv model:(lrc::api::ConversationModel*)model; -(void)selectConversation:(const lrc::api::conversation::Info&)conv model:(lrc::api::ConversationModel*)model;
/**
* Deselect any selected conversation
*/
-(void)deselect;
@end @end
...@@ -189,6 +189,12 @@ NSInteger const PRESENCE_TAG = 800; ...@@ -189,6 +189,12 @@ NSInteger const PRESENCE_TAG = 800;
} }
} }
-(void)deselect
{
selectedUid_.clear();
[smartView deselectAll:nil];
}
#pragma mark - NSTableViewDelegate methods #pragma mark - NSTableViewDelegate methods
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
......
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