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

presence: display status in SmartList

Add green circle in the SmartList if contact is online.

Change-Id: I911d48239d9c95644111183edc620c6342c5ec63
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 6a53636b
......@@ -198,7 +198,9 @@ SET(ringclient_VIEWS
src/views/AccountMenuItemView.h
src/views/AccountMenuItemView.mm
src/views/ContactRequestCellView.h
src/views/ContactRequestCellView.mm)
src/views/ContactRequestCellView.mm
src/views/RoundedTextField.h
src/views/RoundedTextField.mm)
SET(ringclient_OTHERS
src/main.mm
......
......@@ -74,6 +74,7 @@ NSInteger const CALL_BUTTON_TAG = 400;
NSInteger const TXT_BUTTON_TAG = 500;
NSInteger const CANCEL_BUTTON_TAG = 600;
NSInteger const RING_ID_LABEL = 700;
NSInteger const PRESENCE_TAG = 800;
- (void)awakeFromNib
{
......@@ -276,6 +277,13 @@ NSInteger const RING_ID_LABEL = 700;
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(qIdx.data(Qt::DecorationRole)))];
NSView* presenceView = [result viewWithTag:PRESENCE_TAG];
if (qIdx.data(static_cast<int>(Ring::Role::IsPresent)).value<bool>()) {
[presenceView setHidden:NO];
} else {
[presenceView setHidden:YES];
}
return result;
}
......
/*
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
@interface RoundedTextField : NSTextField
/*
* default value : [NSColor controlColor]
*/
@property (nonatomic, strong) NSColor* bgColor;
/*
* default value : [bgColor darkenColorByValue:0.1];
*/
@property (nonatomic, strong) NSColor* borderColor;
/*
* default value : (self.frame) / 2;
*/
@property (nonatomic, strong) NSNumber* cornerRadius;
@end
/*
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "RoundedTextField.h"
#import "NSColor+RingTheme.h"
@implementation RoundedTextField
-(void) awakeFromNib {
if (!self.bgColor) {
self.bgColor = [NSColor controlColor];
}
if (!self.cornerRadius) {
self.cornerRadius = @(NSWidth(self.frame) / 2);
}
if(!self.borderColor) {
self.borderColor = [self.bgColor darkenColorByValue:0.1];
}
self.backgroundColor = [NSColor controlColor];
}
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
NSColor* backgroundColor = self.bgColor;
NSColor* borderColor = self.borderColor;
NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect: dirtyRect xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
[backgroundColor setFill];
[ovalPath fill];
[borderColor setStroke];
[ovalPath setLineWidth: 0.5];
[ovalPath stroke];
NSDictionary *att = nil;
NSMutableParagraphStyle *style =
[[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setLineBreakMode:NSLineBreakByWordWrapping];
[style setAlignment:NSCenterTextAlignment];
att = [[NSDictionary alloc] initWithObjectsAndKeys:
style, NSParagraphStyleAttributeName,
[self textColor],
NSForegroundColorAttributeName, nil];
[[self stringValue] drawInRect:dirtyRect withAttributes:att];
}
@end
......@@ -136,6 +136,26 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="750" verticalHuggingPriority="750" tag="800" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YkV-D4-ddd" userLabel="PresenceIndicator" customClass="RoundedTextField">
<rect key="frame" x="1" y="40" width="14" height="14"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="5eQ-PD-Kp7"/>
<constraint firstAttribute="width" constant="10" id="ZIX-dc-Wn9"/>
</constraints>
<textFieldCell key="cell" enabled="NO" sendsActionOnEndEditing="YES" alignment="center" id="1DZ-7a-3Qp">
<font key="font" metaFont="system"/>
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="bgColor">
<color key="value" red="0.5" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" red="0.0" green="0.77454969618055558" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</textField>
</subviews>
<constraints>
<constraint firstItem="MYe-rn-qOP" firstAttribute="trailing" secondItem="sHH-wj-oHs" secondAttribute="trailing" id="1nI-oe-P2F"/>
......@@ -144,12 +164,14 @@
<constraint firstItem="sHH-wj-oHs" firstAttribute="leading" secondItem="Z6G-mQ-L3J" secondAttribute="leading" constant="3" id="CGt-hN-ulS"/>
<constraint firstItem="epa-Ih-aKF" firstAttribute="top" secondItem="sHH-wj-oHs" secondAttribute="top" id="Jzr-F8-Ysa"/>
<constraint firstItem="sHH-wj-oHs" firstAttribute="top" secondItem="Z6G-mQ-L3J" secondAttribute="top" constant="6" id="KMX-Ru-AEa"/>
<constraint firstItem="YkV-D4-ddd" firstAttribute="leading" secondItem="sHH-wj-oHs" secondAttribute="leading" id="MpR-B5-MBz"/>
<constraint firstItem="MYe-rn-qOP" firstAttribute="bottom" secondItem="sHH-wj-oHs" secondAttribute="bottom" id="QV9-5r-9us"/>
<constraint firstAttribute="bottom" secondItem="sHH-wj-oHs" secondAttribute="bottom" constant="6" id="SJ6-9t-r0l"/>
<constraint firstAttribute="trailing" secondItem="DAd-lc-L62" secondAttribute="trailing" constant="3" id="Zsb-GR-rRN"/>
<constraint firstItem="DAd-lc-L62" firstAttribute="centerY" secondItem="Z6G-mQ-L3J" secondAttribute="centerY" id="amg-Ei-hAd"/>
<constraint firstItem="DAd-lc-L62" firstAttribute="leading" secondItem="epi-ZP-as5" secondAttribute="trailing" constant="56" id="bds-RX-Cy1"/>
<constraint firstItem="epi-ZP-as5" firstAttribute="top" secondItem="epa-Ih-aKF" secondAttribute="bottom" constant="1" id="fRe-jg-u4e"/>
<constraint firstItem="YkV-D4-ddd" firstAttribute="top" secondItem="sHH-wj-oHs" secondAttribute="top" id="ii8-rc-4Jt"/>
<constraint firstItem="DAd-lc-L62" firstAttribute="leading" secondItem="bZ6-1S-zx2" secondAttribute="trailing" constant="5" id="nBC-JZ-zqv"/>
<constraint firstItem="epa-Ih-aKF" firstAttribute="leading" secondItem="epi-ZP-as5" secondAttribute="leading" id="qhg-du-Idh"/>
<constraint firstItem="epa-Ih-aKF" firstAttribute="leading" secondItem="sHH-wj-oHs" secondAttribute="trailing" constant="8" symbolic="YES" id="sdS-XG-xRu"/>
......
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