Commit 4a7b95e6 authored by Alexandre Lision's avatar Alexandre Lision

ui: Add Preference screen

- enter/exit animation
- switch between panels (general/audio/video/hooks)

Refs #66840

Change-Id: I10b823c5e13c6667f1303cd51e32531a375828ff
parent 5855b6a1
......@@ -4,39 +4,10 @@
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow"];
[self.ringWindowController showWindow:nil];
}
- (PreferencesWindowController *)preferencesWindowController
{
if (!_preferencesWindowController)
{
NSLog(@"Coucou");
_preferencesWindowController = [[PreferencesWindowController alloc] initWithWindowNibName:@"PreferencesWindow"];
_preferencesWindowController.window.restorable = YES;
_preferencesWindowController.window.restorationClass = [self class];
_preferencesWindowController.window.identifier = @"preferences";
}
return _preferencesWindowController;
}
- (IBAction)launchPreferencesWindow:(id)sender {
[[self preferencesWindowController] showWindow:nil];
}
+ (void)restoreWindowWithIdentifier:(NSString *)identifier
state:(NSCoder *)state
completionHandler:(void (^)(NSWindow *, NSError *))completionHandler
{
NSLog(@"restoreWindowWithIdentifier: %@", identifier);
NSWindow *window = nil;
if ([identifier isEqualToString:@"preferences"])
{
AppDelegate *appDelegate = [NSApp delegate];
window = [[appDelegate preferencesWindowController] window];
}
completionHandler(window, nil);
}
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AudioPrefsVC">
<connections>
<outlet property="view" destination="c22-O7-iKe" id="WXt-aq-iUD"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ftI-JV-7cE">
<rect key="frame" x="114" y="229" width="78" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Recordings:" id="9HH-Pa-4Aq">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Y73-M5-wnx">
<rect key="frame" x="139" y="179" width="53" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Output:" id="2gZ-Ab-XHf">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wn2-fz-UW2">
<rect key="frame" x="151" y="128" width="42" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Input:" id="x1o-rT-jy6">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IDV-b5-br4">
<rect key="frame" x="128" y="81" width="65" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Ringtone:" id="Gr8-kY-X9a">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JuP-vn-Oim">
<rect key="frame" x="100" y="34" width="92" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Tone settings:" id="NvN-ip-svk">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="akC-1c-4RK">
<rect key="frame" x="194" y="122" width="182" height="26"/>
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="On8-vq-c0G">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<objectValues>
<string>Item 1</string>
<string>Item 2</string>
<string>Item 3</string>
</objectValues>
</comboBoxCell>
</comboBox>
<comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ni4-Q8-9bE">
<rect key="frame" x="194" y="75" width="182" height="26"/>
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="dSu-4c-qW0">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<objectValues>
<string>Item 1</string>
<string>Item 2</string>
<string>Item 3</string>
</objectValues>
</comboBoxCell>
</comboBox>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jyg-5H-Ygw">
<rect key="frame" x="196" y="33" width="94" height="18"/>
<buttonCell key="cell" type="check" title="Mute DTMF" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="pAA-Iv-EmI">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<comboBox verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sxm-vJ-peN">
<rect key="frame" x="194" y="173" width="182" height="26"/>
<comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" completes="NO" numberOfVisibleItems="5" id="FDZ-VU-Kwv">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
<objectValues>
<string>Item 1</string>
<string>Item 2</string>
<string>Item 3</string>
</objectValues>
</comboBoxCell>
</comboBox>
</subviews>
<point key="canvasLocation" x="388" y="254"/>
</customView>
</objects>
</document>
//
// AudioPrefsVC.h
// Ring
//
// Created by Alexandre Lision on 2015-02-19.
//
//
#import <Cocoa/Cocoa.h>
@interface AudioPrefsVC : NSViewController
@end
//
// AudioPrefsVC.m
// Ring
//
// Created by Alexandre Lision on 2015-02-19.
//
//
#import "AudioPrefsVC.h"
@interface AudioPrefsVC ()
@end
@implementation AudioPrefsVC
@end
......@@ -29,21 +29,30 @@ SET(ringclient_SRCS
AppDelegate.mm
RingWindowController.mm
ConversationsViewController.mm
PreferencesWindowController.mm
PreferencesViewController.mm
QNSTreeController.mm
AudioPrefsVC.mm
VideoPrefsVC.mm
GeneralPrefsVC.mm
HistoryViewController.mm
MinimalHistoryBackend.cpp)
MinimalHistoryBackend.mm)
SET(ringclient_FORMS
MainMenu.xib
RingWindow.xib
PreferencesWindow.xib)
GeneralPrefs.xib
AudioPrefs.xib
VideoPrefs.xib
PreferencesScreen.xib)
SET(ringclient_HDRS
AppDelegate.h
RingWindowController.h
ConversationsViewController.h
PreferencesWindowController.h
PreferencesViewController.h
AudioPrefsVC.h
VideoPrefsVC.h
GeneralPrefsVC.h
HistoryViewController.h
QNSTreeController.h
MinimalHistoryBackend.h)
......@@ -65,6 +74,10 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_cancel.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_email.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_new_email.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_search.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ancrage.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/audio.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/general.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/video.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_video.png)
SET_SOURCE_FILES_PROPERTIES(${ring_ICONS} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
......@@ -79,8 +92,6 @@ ADD_EXECUTABLE(${PROJ_NAME} MACOSX_BUNDLE
${myApp_ICON}
${ring_ICONS})
MESSAGE("Hello" ${Qt5Core_LIBRARIES})
TARGET_LINK_LIBRARIES( ${PROJ_NAME}
${LIB_RING_CLIENT_LIBRARY}
${Qt5Core_LIBRARIES}
......@@ -89,6 +100,8 @@ TARGET_LINK_LIBRARIES( ${PROJ_NAME}
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AppKit")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Quartz")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AVFoundation")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AddressBook")
SET_TARGET_PROPERTIES(${PROJ_NAME} PROPERTIES
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="GeneralPrefsVC">
<connections>
<outlet property="view" destination="c22-O7-iKe" id="kqH-6G-Ohq"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="562" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kYQ-jU-skU">
<rect key="frame" x="57" y="226" width="143" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Desktop Notifications:" id="xlz-zw-IJI">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dPI-8j-Y0b">
<rect key="frame" x="113" y="117" width="87" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Calls History:" id="ss6-63-XJO">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lIm-zX-RIV">
<rect key="frame" x="76" y="172" width="124" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Window behaviour:" id="sog-Ok-Y0N">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Oth-up-2k2">
<rect key="frame" x="204" y="224" width="147" height="18"/>
<buttonCell key="cell" type="check" title="Enable Notifications" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="uCL-ye-tsv">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DgD-2y-4g5">
<rect key="frame" x="204" y="115" width="195" height="18"/>
<buttonCell key="cell" type="check" title="Keep my history for at least" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="3Pb-Ec-zl5">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rF1-Fa-8rV">
<rect key="frame" x="83" y="63" width="121" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Instant Messaging:" id="afz-zn-9IW">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QmA-ZI-ZL5">
<rect key="frame" x="450" y="110" width="19" height="27"/>
<stepperCell key="cell" continuous="YES" alignment="left" maxValue="100" id="30B-YQ-Opa"/>
</stepper>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tHZ-7Q-5iP">
<rect key="frame" x="405" y="113" width="40" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" title="30" drawsBackground="YES" id="JvS-c4-OeT">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nah-Jm-ZYB">
<rect key="frame" x="472" y="117" width="33" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="days" id="e5K-l0-Nfw">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Is4-pD-LOT">
<rect key="frame" x="204" y="170" width="294" height="18"/>
<buttonCell key="cell" type="check" title="Bring Ring to foreground on incoming calls" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="uYI-hA-JHk">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LRd-Zc-tRd">
<rect key="frame" x="204" y="62" width="182" height="18"/>
<buttonCell key="cell" type="check" title="Enable instant messaging" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="6UW-Db-jnY">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
</subviews>
<point key="canvasLocation" x="374" y="349"/>
</customView>
</objects>
</document>
//
// GeneralPrefsVC.h
// Ring
//
// Created by Alexandre Lision on 2015-02-19.
//
//
#import <Cocoa/Cocoa.h>
@interface GeneralPrefsVC : NSViewController
@end
//
// GeneralPrefsVC.m
// Ring
//
// Created by Alexandre Lision on 2015-02-19.
//
//
#import "GeneralPrefsVC.h"
@interface GeneralPrefsVC ()
@end
@implementation GeneralPrefsVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
}
@end
......@@ -7,7 +7,6 @@
//
#import "HistoryViewController.h"
#import "MinimalHistoryBackend.h"
#import <historymodel.h>
......@@ -50,8 +49,8 @@
NSInteger idx = [historyView columnWithIdentifier:COLUMNID_HISTORY];
[[[[self.historyView tableColumns] objectAtIndex:idx] headerCell] setStringValue:@"Name"];
HistoryModel::instance()->addBackend(new MinimalHistoryBackend(nil),
LoadOptions::FORCE_ENABLED);
//HistoryModel::instance()->addBackend(new MinimalHistoryBackend(nil),
// LoadOptions::FORCE_ENABLED);
}
......
......@@ -1948,6 +1948,14 @@
</object>
<int key="connectionID">535</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">openPreferences:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="609285721"/>
</object>
<int key="connectionID">588</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">addFontTrait:</string>
......@@ -1988,14 +1996,6 @@
</object>
<int key="connectionID">425</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">launchPreferencesWindow:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="609285721"/>
</object>
<int key="connectionID">587</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
......@@ -3140,7 +3140,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">587</int>
<int key="maxID">588</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
......@@ -3153,21 +3153,57 @@
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">AppDelegate</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">launchPreferencesWindow:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">launchPreferencesWindow:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">launchPreferencesWindow:</string>
<string key="className">RingWindowController</string>
<string key="superclassName">NSWindowController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="closePreferences:">NSToolbarItem</string>
<string key="openPreferences:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="closePreferences:">
<string key="name">closePreferences:</string>
<string key="candidateClassName">NSToolbarItem</string>
</object>
<object class="IBActionInfo" key="openPreferences:">
<string key="name">openPreferences:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">currentView</string>
<string key="NS.object.0">NSView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">currentView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">currentView</string>
<string key="candidateClassName">NSView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../RingWindowController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">RingWindowController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="closePreferences:">NSToolbarItem</string>
<string key="openPreferences:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="closePreferences:">
<string key="name">closePreferences:</string>
<string key="candidateClassName">NSToolbarItem</string>
</object>
<object class="IBActionInfo" key="openPreferences:">
<string key="name">openPreferences:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../AppDelegate.mm</string>
<string key="minorKey">../../RingWindowController.mm</string>
</object>
</object>
</array>
......
/************************************************************************************
* Copyright (C) 2014-2015 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***********************************************************************************/
#include "minimalhistorybackend.h"
//Qt
#include <QtCore/QFile>
#include <QtCore/QHash>
#include <QtCore/qcoreapplication.h>
//Ring
#include "call.h"
#include "account.h"
#include "phonenumber.h"
#include "historymodel.h"
MinimalHistoryBackend::~MinimalHistoryBackend()
{
}
bool MinimalHistoryEditor::save(const Call* item)
{
Q_UNUSED(item)
return false;
}
bool MinimalHistoryEditor::append(const Call* item)
{
Q_UNUSED(item)
return false;
}
bool MinimalHistoryEditor::remove(Call* item)
{
Q_UNUSED(item)
return false;
}
bool MinimalHistoryEditor::edit( Call* item)
{
Q_UNUSED(item)
return false;
}
bool MinimalHistoryEditor::addNew( Call* item)
{
Q_UNUSED(item)
return false;
}
QVector<Call*> MinimalHistoryEditor::items() const
{
return QVector<Call*>();
}
QString MinimalHistoryBackend::name () const
{
return QObject::tr("Minimal history backend");
}
QString MinimalHistoryBackend::category () const
{
return QObject::tr("History");
}
QVariant MinimalHistoryBackend::icon() const
{
return QVariant();
}
bool MinimalHistoryBackend::isEnabled() const
{
return true;
}
bool MinimalHistoryBackend::load()
{
QFile file(QCoreApplication::applicationDirPath() +"/history.ini");
if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
QMap<QString,QString> hc;
while (!file.atEnd()) {
QByteArray line = file.readLine().trimmed();
//The item is complete
if ((line.isEmpty() || !line.size()) && hc.size()) {
Call* pastCall = Call::buildHistoryCall(hc);
if (pastCall->peerName().isEmpty()) {
pastCall->setPeerName(QObject::tr("Unknown"));
}
pastCall->setRecordingPath(hc[ Call::HistoryMapFields::RECORDING_PATH ]);
pastCall->setBackend(this);
m_pMediator->addItem(pastCall);
hc.clear();
}
// Add to the current set
else {
const int idx = line.indexOf("=");
if (idx >= 0)
hc[line.left(idx)] = line.right(line.size()-idx-1);
}
}
return true;
}
else
qWarning() << "History doesn't exist or is not readable";
return false;
}
bool MinimalHistoryBackend::reload()
{
return false;
}
// bool MinimalHistoryBackend::append(const Call* call)
// {
// if (call->backend() == this || call->id().isEmpty()) return false;
// //TODO support \r and \n\r end of line
// QFile file(KStandardDirs::locateLocal("appdata","")+"history.ini");
// if ( file.open(QIODevice::Append | QIODevice::Text) ) {
// const QString direction = (call->direction()==Call::Direction::INCOMING)?
// Call::HistoryStateName::INCOMING : Call::HistoryStateName::OUTGOING;
// QTextStream streamFileOut(&file);
// const Account* a = call->account();
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::CALLID ).arg(call->id() );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::TIMESTAMP_START ).arg(call->startTimeStamp() );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::TIMESTAMP_STOP ).arg(call->stopTimeStamp() );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::ACCOUNT_ID ).arg(a?QString(a->id()):"" );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::DISPLAY_NAME ).arg(call->peerName() );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::PEER_NUMBER ).arg(call->peerPhoneNumber()->uri() );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::DIRECTION ).arg(direction );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::MISSED ).arg(call->isMissed() );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::RECORDING_PATH ).arg(call->recordingPath() );
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::CONTACT_USED ).arg(false );//TODO
// if (call->peerPhoneNumber()->contact()) {
// streamFileOut << QString("%1=%2\n").arg(Call::HistoryMapFields::CONTACT_UID ).arg(
// QString(call->peerPhoneNumber()->contact()->uid())
// );
// }
// streamFileOut << "\n";
// streamFileOut.flush();
// file.close();
// return true;
// }
// else
// qWarning() << "Unable to save history";
// return false;
// }
/** Rewrite the file from scratch
* @todo Eventually check if it is necessary, it will be faster
*/
// bool MinimalHistoryBackend::save(const Call* call)
// {
// Q_UNUSED(call)
// if (call->backend() != this)
// append(call);
//
// //TODO, need to regenerate everything
// /*QFile file(KStandardDirs::locateLocal("appdata","")+"history.ini");
// if ( file.open(QIODevice::WriteOnly | QIODevice::Text) ) {
// foreach(const Call* call, HistoryModel::instance()->getHistoryCalls()) {
// qDebug() << "HERE" << call->id();
// }
// return true;
// }*/
// return false;
// }
CollectionInterface::SupportedFeatures MinimalHistoryBackend::supportedFeatures() const
{
return (CollectionInterface::SupportedFeatures) (
CollectionInterface::SupportedFeatures::NONE |
CollectionInterface::SupportedFeatures::LOAD |
CollectionInterface::SupportedFeatures::CLEAR |
// CollectionInterface::SupportedFeatures::REMOVE|
CollectionInterface::SupportedFeatures::ADD );
}
///Edit 'item', the implementation may be a GUI or somehting else
// bool MinimalHistoryBackend::edit( Call* call)
// {
// Q_UNUSED(call)
// return false;
// }
// bool MinimalHistoryBackend::remove ( Call* c )
// {
// Q_UNUSED(c)
// qDebug() << "Removing item is not yet supported";
// return true;
// }
///Add a new item to the backend
// bool MinimalHistoryBackend::addNew( Call* call)
// {
// Q_UNUSED(call)
// return true;
// }
///Add a new phone number to an existing item
// bool MinimalHistoryBackend::addPhoneNumber( Call* call , PhoneNumber* number )
// {