Commit c65310c1 authored by Alexandre Lision's avatar Alexandre Lision

cleanup: regroup constants used across the client

Before adding more options, regroup existing client-side preferences

Refs #71614

Change-Id: Iacf2fdadb54d33551b07108911288ba3f86b36fc
parent e3843aba
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#import <QItemSelectionModel> #import <QItemSelectionModel>
#import <account.h> #import <account.h>
#import "Constants.h"
#import "RingWizardWC.h" #import "RingWizardWC.h"
@interface AppDelegate() @interface AppDelegate()
...@@ -66,8 +67,8 @@ ...@@ -66,8 +67,8 @@
QObject::connect(CallModel::instance(), QObject::connect(CallModel::instance(),
&CallModel::incomingCall, &CallModel::incomingCall,
[=](Call* call) { [=](Call* call) {
BOOL shouldComeToForeground = [[NSUserDefaults standardUserDefaults] boolForKey:@"window_behaviour"]; BOOL shouldComeToForeground = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::WindowBehaviour];
BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:@"enable_notifications"]; BOOL shouldNotify = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::Notifications];
if(shouldComeToForeground) if(shouldComeToForeground)
[NSApp activateIgnoringOtherApps:YES]; [NSApp activateIgnoringOtherApps:YES];
......
/*
* 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 <Foundation/Foundation.h>
/**
* Defines a set of preferences constants
* WARNING: If you modify a KVO compliant value, make sure to change the string associated
* in the relative xib file in IB.
*/
namespace Preferences {
/* KVO compliant */
NSString * const HistoryLimit = @"history_limit";
/* KVO compliant */
NSString * const WindowBehaviour = @"window_behaviour";
/* KVO compliant */
NSString * const Notifications = @"enable_notifications";
NSString * const ShowAdvanced = @"show_advanced";
}
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#import <categorizedhistorymodel.h> #import <categorizedhistorymodel.h>
#import "Constants.h"
@interface GeneralPrefsVC () @interface GeneralPrefsVC ()
@property (assign) IBOutlet NSTextField *historyChangedLabel; @property (assign) IBOutlet NSTextField *historyChangedLabel;
...@@ -44,7 +46,7 @@ ...@@ -44,7 +46,7 @@
- (void)loadView - (void)loadView
{ {
[super loadView]; [super loadView];
[[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"history_limit" options:NSKeyValueObservingOptionNew context:NULL]; [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:Preferences::HistoryLimit options:NSKeyValueObservingOptionNew context:NULL];
} }
- (IBAction)clearHistory:(id)sender { - (IBAction)clearHistory:(id)sender {
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#import "GeneralPrefsVC.h" #import "GeneralPrefsVC.h"
#import "AudioPrefsVC.h" #import "AudioPrefsVC.h"
#import "VideoPrefsVC.h" #import "VideoPrefsVC.h"
#import "Constants.h"
@interface PreferencesVC () @interface PreferencesVC ()
...@@ -188,7 +189,7 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; ...@@ -188,7 +189,7 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
toggleAdvancedSettings = [[NSButton alloc] initWithFrame:NSMakeRect(0,0,20,20)]; toggleAdvancedSettings = [[NSButton alloc] initWithFrame:NSMakeRect(0,0,20,20)];
[toggleAdvancedSettings setButtonType:NSSwitchButton]; [toggleAdvancedSettings setButtonType:NSSwitchButton];
[toggleAdvancedSettings setTitle:@""]; [toggleAdvancedSettings setTitle:@""];
[toggleAdvancedSettings setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"]]; [toggleAdvancedSettings setState:[[NSUserDefaults standardUserDefaults] boolForKey:Preferences::ShowAdvanced]];
[item setLabel:@"Show Advanced"]; [item setLabel:@"Show Advanced"];
[item setView:toggleAdvancedSettings]; [item setView:toggleAdvancedSettings];
[item setAction:@selector(togglePowerSettings:)]; [item setAction:@selector(togglePowerSettings:)];
...@@ -225,7 +226,7 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; ...@@ -225,7 +226,7 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
kDonePrefsIdentifer, kDonePrefsIdentifer,
nil]; nil];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"]) { if([[NSUserDefaults standardUserDefaults] boolForKey:Preferences::ShowAdvanced]) {
[items insertObject:NSToolbarSpaceItemIdentifier atIndex:5]; [items insertObject:NSToolbarSpaceItemIdentifier atIndex:5];
[items insertObject:kProfilePrefsIdentifier atIndex:2]; [items insertObject:kProfilePrefsIdentifier atIndex:2];
} else } else
...@@ -243,7 +244,7 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer"; ...@@ -243,7 +244,7 @@ static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
kVideoPrefsIdentifer, kVideoPrefsIdentifer,
nil]; nil];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"]) if([[NSUserDefaults standardUserDefaults] boolForKey:Preferences::ShowAdvanced])
[items insertObject:kProfilePrefsIdentifier atIndex:1]; [items insertObject:kProfilePrefsIdentifier atIndex:1];
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#import <call.h> #import <call.h>
#import "AppDelegate.h" #import "AppDelegate.h"
#import "Constants.h"
@interface RingWindowController () @interface RingWindowController ()
...@@ -149,8 +150,8 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier"; ...@@ -149,8 +150,8 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier";
- (void)togglePowerSettings:(id)sender - (void)togglePowerSettings:(id)sender
{ {
BOOL advanced = [[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"]; BOOL advanced = [[NSUserDefaults standardUserDefaults] boolForKey:Preferences::ShowAdvanced];
[[NSUserDefaults standardUserDefaults] setBool:!advanced forKey:@"show_advanced"]; [[NSUserDefaults standardUserDefaults] setBool:!advanced forKey:Preferences::ShowAdvanced];
[[NSUserDefaults standardUserDefaults] synchronize]; [[NSUserDefaults standardUserDefaults] synchronize];
NSToolbar* tb = [[NSToolbar alloc] initWithIdentifier: @"PreferencesToolbar"]; NSToolbar* tb = [[NSToolbar alloc] initWithIdentifier: @"PreferencesToolbar"];
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#import <contactmethod.h> #import <contactmethod.h>
#import <categorizedhistorymodel.h> #import <categorizedhistorymodel.h>
#import "../Constants.h"
class MinimalHistoryEditor : public CollectionEditor<Call> class MinimalHistoryEditor : public CollectionEditor<Call>
{ {
public: public:
...@@ -202,7 +204,7 @@ bool MinimalHistoryBackend::isEnabled() const ...@@ -202,7 +204,7 @@ bool MinimalHistoryBackend::isEnabled() const
bool MinimalHistoryBackend::load() bool MinimalHistoryBackend::load()
{ {
// get history limit from our preferences set // get history limit from our preferences set
NSInteger historyLimit = [[NSUserDefaults standardUserDefaults] integerForKey:@"history_limit"]; NSInteger historyLimit = [[NSUserDefaults standardUserDefaults] integerForKey:Preferences::HistoryLimit];
QFile file(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') +"history.ini"); QFile file(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') +"history.ini");
if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) { if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) {
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#import <person.h> #import <person.h>
#import <contactmethod.h> #import <contactmethod.h>
#import <presencestatusmodel.h> #import <presencestatusmodel.h>
#import <securityvalidationmodel.h>
#import <collectioninterface.h> #import <collectioninterface.h>
#import <useractionmodel.h> #import <useractionmodel.h>
#import <QStandardPaths> #import <QStandardPaths>
......
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