Commit d5229f34 authored by Alexandre Lision's avatar Alexandre Lision

ui: change person default icon

This commit introduces adjustements in lists layout.
In SmartList
- use custom Ring default user icon

In PersonsList
- use custom Ring default user icon
- make categories selectable
- remove background color of categories

In HistoryList
- add photo/default Ring user icon to history entries

Tuleap: #151
Change-Id: I99bba6ef95b31f9f6ac33d14f434c0a0bd53c654
parent 89edc6ad
......@@ -190,6 +190,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_made.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_transfer.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_add_participant.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_merge_calls.png
${CMAKE_CURRENT_SOURCE_DIR}/data/default_user_icon.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ancrage.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/audio.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_person_add.png
......
......@@ -20,6 +20,8 @@
//Qt
#import <QSortFilterProxyModel>
#import <QtMacExtras/qmacfunctions.h>
#import <QPixmap>
//LRC
#import <categorizedhistorymodel.h>
......@@ -27,10 +29,12 @@
#import <call.h>
#import <person.h>
#import <contactmethod.h>
#import <globalinstances.h>
#import "QNSTreeController.h"
#import "PersonLinkerVC.h"
#import "views/HoverTableRowView.h"
#import "delegates/ImageManipulationDelegate.h"
@interface HistoryVC() <NSPopoverDelegate, KeyboardShortcutDelegate, ContactLinkedDelegate> {
......@@ -45,9 +49,10 @@
@implementation HistoryVC
// Tags for Views
NSInteger const IMAGE_TAG = 100;
NSInteger const DIRECTION_TAG = 100;
NSInteger const DISPLAYNAME_TAG = 200;
NSInteger const DETAILS_TAG = 300;
NSInteger const PHOTO_TAG = 400;
- (void)awakeFromNib
{
......@@ -150,24 +155,30 @@ NSInteger const DETAILS_TAG = 300;
} else {
result = [outlineView makeViewWithIdentifier:@"HistoryCell" owner:outlineView];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
NSImageView* directionView = [result viewWithTag:DIRECTION_TAG];
if (qvariant_cast<Call::Direction>(qIdx.data((int)Call::Role::Direction)) == Call::Direction::INCOMING) {
if (qvariant_cast<Boolean>(qIdx.data((int) Call::Role::Missed))) {
[photoView setImage:[self image:[NSImage imageNamed:@"ic_call_missed"] withTintedWithColor:[NSColor redColor]]];
[directionView setImage:[self image:[NSImage imageNamed:@"ic_call_missed"] withTintedWithColor:[NSColor redColor]]];
} else {
[photoView setImage:[self image:[NSImage imageNamed:@"ic_call_received"]
[directionView setImage:[self image:[NSImage imageNamed:@"ic_call_received"]
withTintedWithColor:[NSColor colorWithCalibratedRed:116/255.0 green:179/255.0 blue:93/255.0 alpha:1.0]]];
}
} else {
if (qvariant_cast<Boolean>(qIdx.data((int) Call::Role::Missed))) {
[photoView setImage:[self image:[NSImage imageNamed:@"ic_call_missed"] withTintedWithColor:[NSColor redColor]]];
[directionView setImage:[self image:[NSImage imageNamed:@"ic_call_missed"] withTintedWithColor:[NSColor redColor]]];
} else {
[photoView setImage:[self image:[NSImage imageNamed:@"ic_call_made"]
[directionView setImage:[self image:[NSImage imageNamed:@"ic_call_made"]
withTintedWithColor:[NSColor colorWithCalibratedRed:116/255.0 green:179/255.0 blue:93/255.0 alpha:1.0]]];
}
}
auto call = qvariant_cast<Call*>(qIdx.data((int)Call::Role::Object));
NSImageView* photoView = [result viewWithTag:PHOTO_TAG];
QVariant photo = GlobalInstances::pixmapManipulator().callPhoto(call, QSize(50,50));
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
NSTextField* details = [result viewWithTag:DETAILS_TAG];
[details setStringValue:qIdx.data((int)Call::Role::FormattedDate).toString().toNSString()];
}
......
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -99,8 +99,16 @@ NSInteger const CALL_BUTTON_TAG = 400;
- (IBAction)callContact:(id)sender
{
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
auto item = [treeController selectedNodes][0];
QModelIndex qIdx = [treeController toQIdx:item];
ContactMethod* m = nil;
if (!qIdx.parent().isValid()) {
if ([personsView isItemExpanded:item]) {
[[personsView animator] collapseItem:item];
} else
[[personsView animator] expandItem:item];
return;
}
if(((NSTreeNode*)[treeController selectedNodes][0]).indexPath.length == 2) {
// Person
QVariant var = qIdx.data((int)Person::Role::Object);
......@@ -138,11 +146,7 @@ NSInteger const CALL_BUTTON_TAG = 400;
if(!qIdx.isValid())
return NO;
if(!qIdx.parent().isValid()) {
return NO;
} else {
return YES;
}
return YES;
}
// -------------------------------------------------------------------------------
......@@ -167,7 +171,6 @@ NSInteger const CALL_BUTTON_TAG = 400;
result = [outlineView makeViewWithIdentifier:@"LetterCell" owner:outlineView];
[result setWantsLayer:YES];
[result setLayer:[CALayer layer]];
[result.layer setBackgroundColor:[NSColor selectedControlColor].CGColor];
} else if(((NSTreeNode*)item).indexPath.length == 2) {
result = [outlineView makeViewWithIdentifier:@"PersonCell" owner:outlineView];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
......
......@@ -250,7 +250,7 @@ NSInteger const TXT_BUTTON_TAG = 500;
[displayName setStringValue:qIdx.data(Qt::DisplayRole).toString().toNSString()];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(40,40));
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(50,50));
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
return result;
}
......
......@@ -125,52 +125,23 @@ namespace Interfaces {
}
QPixmap ImageManipulationDelegate::drawDefaultUserPixmap(const QSize& size, bool displayPresence, bool isPresent) {
const int radius = size.height() / 2;
QPixmap pxm(size);
pxm.fill(Qt::transparent);
QPainter painter(&pxm);
painter.setCompositionMode(QPainter::CompositionMode_Clear);
painter.fillRect(0,0,size.width(),size.height(),QBrush(Qt::white));
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
// create the image somehow, load from file, draw into it...
auto sourceImgRef = CGImageSourceCreateWithData((CFDataRef)[[NSImage imageNamed:@"NSUser"] TIFFRepresentation], NULL);
auto sourceImgRef = CGImageSourceCreateWithData((CFDataRef)[[NSImage imageNamed:@"default_user_icon"] TIFFRepresentation], NULL);
auto imgRef = CGImageSourceCreateImageAtIndex(sourceImgRef, 0, NULL);
auto finalpxm = QtMac::fromCGImageRef(resizeCGImage(imgRef, size));
QRect pxRect = finalpxm.rect();
QBitmap mask(pxRect.size());
QPainter customPainter(&mask);
customPainter.setRenderHint (QPainter::Antialiasing, true );
customPainter.fillRect (pxRect , Qt::white );
customPainter.setBackground (Qt::black );
customPainter.setBrush (Qt::black );
customPainter.drawRoundedRect(pxRect,radius,radius);
finalpxm.setMask(mask);
painter.setRenderHint (QPainter::Antialiasing, true );
painter.drawPixmap(0,0,finalpxm);
painter.setBrush(Qt::NoBrush);
painter.setPen(Qt::black);
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
painter.drawRoundedRect(0,0,pxm.height(),pxm.height(),radius,radius);
CFRelease(sourceImgRef);
CFRelease(imgRef);
return pxm;
return finalpxm;
}
CGImageRef ImageManipulationDelegate::resizeCGImage(CGImageRef image, const QSize& size) {
// create context, keeping original image properties
CGColorSpaceRef colorspace = CGImageGetColorSpace(image);
CGContextRef context = CGBitmapContextCreate(NULL, size.width(), size.height(),
CGImageGetBitsPerComponent(image),
size.width() * CGImageGetBitsPerComponent(image),
colorspace,
CGImageGetAlphaInfo(image));
CGImageGetBytesPerRow(image),
CGImageGetColorSpace(image),
kCGImageAlphaPremultipliedLast);
if(context == NULL)
return nil;
......
This diff is collapsed.
This diff is collapsed.
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