Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
J
jami-client-macos
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
38
Issues
38
List
Boards
Labels
Milestones
Security & Compliance
Security & Compliance
Dependency List
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-client-macos
Commits
43a79239
Commit
43a79239
authored
Oct 18, 2018
by
Kateryna Kostiuk
Committed by
Andreas Traczyk
Oct 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: image memory usage
Change-Id: I8ba722d89c9a54ec20d25a3d2b7dd3efb20b1dd0
parent
394f74c7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
29 deletions
+33
-29
src/AccRingGeneralVC.mm
src/AccRingGeneralVC.mm
+4
-7
src/AccSipGeneralVC.mm
src/AccSipGeneralVC.mm
+4
-8
src/ChooseAccountVC.mm
src/ChooseAccountVC.mm
+23
-11
src/views/NSImage+Extensions.mm
src/views/NSImage+Extensions.mm
+2
-3
No files found.
src/AccRingGeneralVC.mm
View file @
43a79239
...
...
@@ -137,15 +137,12 @@ typedef NS_ENUM(NSInteger, TagViews) {
-(void) updateView {
const auto& account = accountModel->getAccountInfo(self.selectedAccountID);
QByteArray ba = QByteArray::fromStdString(account.profileInfo.avatar);
QVariant photo = GlobalInstances::pixmapManipulator().personPhoto(ba, nil);
if(QtMac::toNSImage(qvariant_cast<QPixmap>(photo))) {
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:@(account.profileInfo.avatar.c_str()) options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSImage *image = [[NSImage alloc] initWithData:imageData];
if(image) {
[photoView setBordered:NO];
NSImage *image = QtMac::toNSImage(qvariant_cast<QPixmap>(photo));
CGFloat newSize = MIN(image.size.height, image.size.width);
image = [image cropImageToSize:CGSizeMake(newSize, newSize)];
[photoView setImage: [image roundCorners: image.size.height * 0.5]];
[photoView setImage: [image roundCorners: 350]];
[addProfilePhotoImage setHidden:YES];
} else {
[photoView setImage:nil];
...
...
src/AccSipGeneralVC.mm
View file @
43a79239
...
...
@@ -125,15 +125,11 @@ typedef NS_ENUM(NSInteger, TagViews) {
-(void)updateView {
const auto& account = accountModel->getAccountInfo(self.selectedAccountID);
QByteArray ba = QByteArray::fromStdString(account.profileInfo.avatar);
QVariant photo = GlobalInstances::pixmapManipulator().personPhoto(ba, nil);
if(QtMac::toNSImage(qvariant_cast<QPixmap>(photo))) {
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:@(account.profileInfo.avatar.c_str()) options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSImage *image = [[NSImage alloc] initWithData:imageData];
if(image) {
[photoView setBordered:NO];
NSImage *image = QtMac::toNSImage(qvariant_cast<QPixmap>(photo));
CGFloat newSize = MIN(image.size.height, image.size.width);
image = [image cropImageToSize:CGSizeMake(newSize, newSize)];
[photoView setImage: [image roundCorners: image.size.height * 0.5]];
[photoView setImage: [image roundCorners: 350]];
[addProfilePhotoImage setHidden:YES];
} else {
[photoView setImage:nil];
...
...
src/ChooseAccountVC.mm
View file @
43a79239
...
...
@@ -122,7 +122,11 @@ NSMenuItem* selectedMenuItem;
QObject::connect(accMdl_,
&lrc::api::NewAccountModel::accountStatusChanged,
[self] (const std::string& accountID) {
[self update];
if([self selectedAccount].id == accountID) {
[self update];
return;
}
[self updateMenuItemForAccount:accountID];
});
}
...
...
@@ -148,6 +152,16 @@ NSMenuItem* selectedMenuItem;
}
}
-(void) updateMenuItemForAccount: (const std::string&) accountID {
AccountMenuItemView *itemView =
[accountsMenu itemWithTag:[@(accountID.c_str()) intValue]].view;
if(!itemView) {
return;
}
[self configureView:itemView forAccount:accountID];
}
-(void) updateMenu {
[accountsMenu removeAllItems];
...
...
@@ -195,10 +209,10 @@ NSMenuItem* selectedMenuItem;
[itemView.accountLabel setStringValue:@(account.profileInfo.alias.c_str())];
NSString* userNameString = [self nameForAccount: account];
[itemView.userNameLabel setStringValue:userNameString];
QByteArray ba = QByteArray::fromStdString(account.profileInfo.avatar)
;
QVariant photo = GlobalInstances::pixmapManipulator().personPhoto(ba, nil)
;
if(
QtMac::toNSImage(qvariant_cast<QPixmap>(photo))
) {
[itemView.accountAvatar setImage:
QtMac::toNSImage(qvariant_cast<QPixmap>(photo))
];
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:@(account.profileInfo.avatar.c_str()) options:NSDataBase64DecodingIgnoreUnknownCharacters]
;
NSImage *image = [[NSImage alloc] initWithData:imageData]
;
if(
image
) {
[itemView.accountAvatar setImage:
image
];
} else {
[itemView.accountAvatar setImage: [NSImage imageNamed:@"default_avatar_overlay.png"]];
}
...
...
@@ -229,12 +243,10 @@ NSMenuItem* selectedMenuItem;
auto& account = [self selectedAccount];
if(account.profileInfo.type == lrc::api::profile::Type::INVALID)
return;
QByteArray ba = QByteArray::fromStdString(account.profileInfo.avatar);
QVariant photo = GlobalInstances::pixmapManipulator().personPhoto(ba, nil);
if(QtMac::toNSImage(qvariant_cast<QPixmap>(photo))) {
[profileImage setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:@(account.profileInfo.avatar.c_str()) options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSImage *image = [[NSImage alloc] initWithData:imageData];
if(image) {
[profileImage setImage: image];
} else {
[profileImage setImage: [NSImage imageNamed:@"default_avatar_overlay.png"]];
}
...
...
src/views/NSImage+Extensions.mm
View file @
43a79239
...
...
@@ -42,8 +42,7 @@
}
- (NSImage *) roundCorners:(CGFloat)radius {
NSImage *existingImage = self;
NSSize existingSize = [existingImage size];
NSSize existingSize = [self size];
NSSize newSize = NSMakeSize(existingSize.width, existingSize.height);
NSImage *composedImage = [[NSImage alloc] initWithSize:newSize];
...
...
@@ -55,7 +54,7 @@
[clipPath setWindingRule:NSEvenOddWindingRule];
[clipPath addClip];
[
existingImage
drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0, 0, newSize.width, newSize.height) operation:NSCompositeSourceOver fraction:1];
[
self
drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0, 0, newSize.width, newSize.height) operation:NSCompositeSourceOver fraction:1];
[composedImage unlockFocus];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment