Commit 745e4d68 authored by Alexandre Lision's avatar Alexandre Lision

ring: add wizard at start up

- Adds welcome window, and creates a Ring account for the user
- Displays hash and offers email sharing
- Appears if no Ring account is detected

Refs #66840

Change-Id: I1c436a52d5e96fa47fc5222c3f3ded0c405a68d2
parent 2acc5ca0
<?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">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccAdvancedVC">
......@@ -256,7 +255,7 @@
<matrix verticalHuggingPriority="750" fixedFrame="YES" allowsEmptySelection="NO" autorecalculatesCellSize="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2yz-X7-dVm">
<rect key="frame" x="64" y="255" width="320" height="38"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<size key="cellSize" width="217" height="18"/>
<size key="cellSize" width="216" height="18"/>
<size key="intercellSpacing" width="4" height="2"/>
<buttonCell key="prototype" type="radio" title="Radio" imagePosition="left" alignment="left" inset="2" id="fB0-X8-GXk">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
......
......@@ -37,7 +37,8 @@
@interface AppDelegate : NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate>
@property RingWindowController* ringWindowController;
- (void) showWizard;
- (void) showMainWindow;
@end
......
......@@ -31,15 +31,33 @@
#import <callmodel.h>
#import <accountmodel.h>
#import <protocolmodel.h>
#import <QItemSelectionModel>
#import <account.h>
#import "RingWizardWC.h"
@interface AppDelegate()
@property RingWindowController* ringWindowController;
@property RingWizardWC* wizard;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow"];
[self.ringWindowController showWindow:nil];
if([self checkForRingAccount]) {
[self showMainWindow];
} else {
[self showWizard];
}
[self connect];
}
......@@ -68,4 +86,50 @@
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
/**
* click in MainMenu "Setup Ring"
*/
- (IBAction)showWizard:(id)sender {
[self showWizard];
}
- (void) showWizard
{
NSLog(@"Showing wizard");
if(self.wizard == nil) {
self.wizard = [[RingWizardWC alloc] initWithWindowNibName:@"RingWizard"];
}
[self.wizard.window orderFront:self];
}
- (void) showMainWindow
{
if(self.ringWindowController == nil)
self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow"];
[self.ringWindowController.window makeKeyAndOrderFront:self];
}
- (BOOL) checkForRingAccount
{
for (int i = 0 ; i < AccountModel::instance()->rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance()->index(i);
Account* acc = AccountModel::instance()->getAccountByModelIndex(idx);
if(acc->protocol() == Account::Protocol::RING) {
return YES;
}
}
return FALSE;
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
if([self checkForRingAccount]) {
[self showMainWindow];
} else {
[self showWizard];
}
return YES;
}
@end
......@@ -42,6 +42,7 @@ SET(ringclient_SRCS
AudioPrefsVC.mm
VideoPrefsVC.mm
GeneralPrefsVC.mm
RingWizardWC.mm
HistoryViewController.mm
MinimalHistoryBackend.mm)
......@@ -59,7 +60,8 @@ SET(ringclient_FORMS
AccSecurity.xib
AudioPrefs.xib
VideoPrefs.xib
PreferencesScreen.xib)
PreferencesScreen.xib
RingWizard.xib)
SET(ringclient_HDRS
AppDelegate.h
......@@ -78,6 +80,7 @@ SET(ringclient_HDRS
VideoPrefsVC.h
GeneralPrefsVC.h
HistoryViewController.h
RingWizardWC.h
QNSTreeController.h
MinimalHistoryBackend.h)
......
......@@ -62,6 +62,14 @@
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="478989275">
<reference key="NSMenu" ref="110575045"/>
<string key="NSTitle">Setup Ring</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="304266470">
<reference key="NSMenu" ref="110575045"/>
<bool key="NSIsDisabled">YES</bool>
......@@ -1049,6 +1057,14 @@
</object>
<int key="connectionID">588</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">showWizard:</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="478989275"/>
</object>
<int key="connectionID">591</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
......@@ -1276,6 +1292,7 @@
<reference ref="1056857174"/>
<reference ref="238522557"/>
<reference ref="342932134"/>
<reference ref="478989275"/>
</array>
<reference key="parent" ref="694149608"/>
</object>
......@@ -1573,6 +1590,11 @@
<reference key="object" ref="738670835"/>
<reference key="parent" ref="963351320"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">589</int>
<reference key="object" ref="478989275"/>
<reference key="parent" ref="110575045"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
......@@ -1654,13 +1676,14 @@
<string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="589.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">588</int>
<int key="maxID">591</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
......@@ -1672,6 +1695,24 @@
<string key="minorKey">../../AppDelegate.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">AppDelegate</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">showWizard:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">showWizard:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">showWizard:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../../AppDelegate.mm</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">RingWindowController</string>
<string key="superclassName">NSWindowController</string>
......
......@@ -8,7 +8,6 @@
<connections>
<outlet property="currentView" destination="se5-gp-TjO" id="Sae-7F-MB3"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
<outlet property="windowView" destination="se5-gp-TjO" id="Enr-gP-asz"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
......@@ -167,7 +166,7 @@
</tabViewItem>
</tabViewItems>
</tabView>
<customView misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tSW-YT-asL">
<customView focusRingType="none" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tSW-YT-asL">
<rect key="frame" x="323" y="0.0" width="725" height="626"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="626" id="5yo-rb-X1O"/>
......@@ -206,4 +205,7 @@
</connections>
</viewController>
</objects>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>
</resources>
</document>
......@@ -34,6 +34,8 @@
#import <account.h>
#import <call.h>
#import "AppDelegate.h"
@interface RingWindowController ()
@property NSSearchField* callField;
......@@ -46,9 +48,9 @@ static NSString* const kSearchViewIdentifier = @"SearchViewIdentifier";
static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier";
- (void)windowDidLoad {
[super windowDidLoad];
[self.window setReleasedWhenClosed:FALSE];
[self displayMainToolBar];
}
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="RingWizardWC">
<connections>
<outlet property="createButton" destination="rC1-mU-Scu" id="JrT-qi-fF5"/>
<outlet property="goToAppButton" destination="hKA-b6-heE" id="voO-WW-sdE"/>
<outlet property="indicationLabel" destination="07z-dh-DdR" id="SIY-tg-tdZ"/>
<outlet property="nickname" destination="Phj-na-SP1" id="HYj-kV-lyE"/>
<outlet property="progressBar" destination="nRx-qJ-VIe" id="qJ2-ra-GkK"/>
<outlet property="window" destination="4LP-GX-BkH" id="vNm-J0-gmv"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Ring" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" animationBehavior="default" id="4LP-GX-BkH">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="163" y="205" width="480" height="321"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
<view key="contentView" id="Wgr-xH-z0G">
<rect key="frame" x="0.0" y="0.0" width="480" height="321"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rAn-Kv-PgL">
<rect key="frame" x="18" y="265" width="79" height="36"/>
<textFieldCell key="cell" controlSize="mini" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Hello" id="uqu-uh-Wao">
<font key="font" metaFont="system" size="30"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Phj-na-SP1">
<rect key="frame" x="161" y="149" width="159" height="22"/>
<textFieldCell key="cell" controlSize="mini" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="5Z7-Wi-530">
<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>
<button translatesAutoresizingMaskIntoConstraints="NO" id="rC1-mU-Scu">
<rect key="frame" x="390" y="17" width="72" height="29"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="68" id="3Oi-R8-jmQ"/>
</constraints>
<buttonCell key="cell" type="bevel" title="OK" bezelStyle="regularSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="wDw-Ut-RUm">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="createRingAccount:" target="-2" id="CBc-Mm-dzm"/>
</connections>
</button>
<progressIndicator hidden="YES" ambiguous="YES" misplaced="YES" maxValue="100" indeterminate="YES" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="nRx-qJ-VIe">
<rect key="frame" x="192" y="150" width="96" height="20"/>
</progressIndicator>
<button hidden="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hKA-b6-heE">
<rect key="frame" x="288" y="17" width="98" height="29"/>
<buttonCell key="cell" type="bevel" title="Continue" bezelStyle="regularSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Kwr-LJ-K8C">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="goToApp:" target="-2" id="o8v-93-fE5"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="07z-dh-DdR">
<rect key="frame" x="170" y="179" width="140" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="122" id="e4n-it-xKq"/>
</constraints>
<textFieldCell key="cell" controlSize="mini" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Tell me who you are" id="yph-hz-tyP">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="rC1-mU-Scu" secondAttribute="trailing" constant="20" id="02s-v0-sLn"/>
<constraint firstItem="rAn-Kv-PgL" firstAttribute="top" secondItem="Wgr-xH-z0G" secondAttribute="top" constant="20" id="CTX-YQ-cEW"/>
<constraint firstAttribute="centerX" secondItem="nRx-qJ-VIe" secondAttribute="centerX" id="D7h-Vj-QkJ"/>
<constraint firstAttribute="centerX" secondItem="Phj-na-SP1" secondAttribute="centerX" id="Djw-wQ-YZj"/>
<constraint firstItem="rC1-mU-Scu" firstAttribute="leading" secondItem="hKA-b6-heE" secondAttribute="trailing" constant="8" id="RUS-zV-JtN"/>
<constraint firstAttribute="bottom" secondItem="hKA-b6-heE" secondAttribute="bottom" constant="20" id="TGf-Kl-MPP"/>
<constraint firstItem="rAn-Kv-PgL" firstAttribute="leading" secondItem="Wgr-xH-z0G" secondAttribute="leading" constant="20" id="Yhs-QQ-67T"/>
<constraint firstAttribute="bottom" secondItem="rC1-mU-Scu" secondAttribute="bottom" constant="20" id="dbf-vQ-Wby"/>
<constraint firstAttribute="centerX" secondItem="07z-dh-DdR" secondAttribute="centerX" id="sjA-hA-pg4"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="cKX-Z2-yDq"/>
</connections>
<point key="canvasLocation" x="790" y="11.5"/>
</window>
</objects>
</document>
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import <Cocoa/Cocoa.h>
@interface RingWizardWC : NSWindowController <NSWindowDelegate>{
NSButton *goToAppButton;
}
@end
/*
* 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
* 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import "RingWizardWC.h"
#import <accountmodel.h>
#import <protocolmodel.h>
#import <QItemSelectionModel>
#import <account.h>
#import "AppDelegate.h"
@interface RingWizardWC ()
@property (assign) IBOutlet NSButton *goToAppButton;
@property (assign) IBOutlet NSTextField *nickname;
@property (assign) IBOutlet NSProgressIndicator *progressBar;
@property (assign) IBOutlet NSTextField *indicationLabel;
@property (assign) IBOutlet NSButton *createButton;
@end
@implementation RingWizardWC
@synthesize goToAppButton;
@synthesize nickname;
@synthesize progressBar;
@synthesize indicationLabel;
@synthesize createButton;
- (void)windowDidLoad {
[super windowDidLoad];
[self.window makeKeyAndOrderFront:nil];
[self.window setLevel:NSStatusWindowLevel];
[self.window makeMainWindow];
[self checkForRingAccount];
}
- (void) checkForRingAccount
{
for (int i = 0 ; i < AccountModel::instance()->rowCount() ; ++i) {
QModelIndex idx = AccountModel::instance()->index(i);
Account* acc = AccountModel::instance()->getAccountByModelIndex(idx);
if(acc->protocol() == Account::Protocol::RING) {
[indicationLabel setStringValue:@"Ring is already ready to work"];
[self displayHash:acc->username().toNSString()];
}
}
}
- (void) displayHash:(NSString* ) hash
{
[nickname setFrameSize:NSMakeSize(400, nickname.frame.size.height)];
[nickname setStringValue:hash];
[nickname setEditable:NO];
[nickname setHidden:NO];
[goToAppButton setHidden:NO];
NSSharingService* emailSharingService = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
[createButton setTitle:@"Share by mail"];
//[createButton setImage:emailSharingService.image];
[createButton setAlternateImage:emailSharingService.alternateImage];
[createButton setAction:@selector(shareByEmail)];
}
- (IBAction)createRingAccount:(id)sender {
[nickname setHidden:YES];
[progressBar setHidden:NO];
[createButton setEnabled:NO];
[indicationLabel setStringValue:@"Just a moment..."];
QModelIndex qIdx = AccountModel::instance()->protocolModel()->selectionModel()->currentIndex();
[self setCallback];
[self performSelector:@selector(saveAccount) withObject:nil afterDelay:1];
}
- (void) saveAccount
{
NSString* newAccName = @"My Ring";
Account* newAcc = AccountModel::instance()->add([newAccName UTF8String], Account::Protocol::RING);
newAcc->setAlias([[nickname stringValue] UTF8String]);
newAcc << Account::EditAction::SAVE;
}
- (void) setCallback
{
QObject::connect(AccountModel::instance(),
&AccountModel::accountStateChanged,
[=](Account *account, const Account::RegistrationState state) {
NSLog(@"Account created!");
[progressBar setHidden:YES];
[createButton setEnabled:YES];
[indicationLabel setStringValue:@"This is your number, share it with your friends!"];
[self displayHash:account->username().toNSString()];
});
}
- (IBAction)goToApp:(id)sender {
[self.window close];
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[appDelegate showMainWindow];
}
- (void) shareByEmail
{
/*
Create the array of items to share.
Start with just the content of the text view. If there's an image, add that too.
*/
NSMutableArray *shareItems = [[NSMutableArray alloc] initWithObjects:[nickname stringValue], nil];
NSSharingService* emailSharingService = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail];
/*
Perform the service using the array of items.
*/
[emailSharingService performWithItems:shareItems];
}
# pragma NSWindowDelegate methods
- (BOOL)windowShouldClose:(id)sender
{
NSLog(@"windowShouldClose");
return YES;
}
- (void)windowDidBecomeKey:(NSNotification *)notification
{
NSLog(@"windowDidBecomeKey");
}
- (void)windowDidResignKey:(NSNotification *)notification
{
NSLog(@"windowDidResignKey");
}
- (void)windowDidBecomeMain:(NSNotification *)notification
{
NSLog(@"windowDidBecomeMain");
}
- (void)windowDidResignMain:(NSNotification *)notification
{
NSLog(@"windowDidResignMain");
[self.window close];
}
- (void)windowWillClose:(NSNotification *)notification
{
//NSLog(@"windowWillClose");
AppDelegate *appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
[appDelegate showMainWindow];
}
@end
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