Projekt

Allgemein

Profil

Herunterladen (2,14 KB) Statistiken
| Zweig: | Markierung: | Revision:
94f5cb15 Bernd Bleßmann
package SL::Helper::UserPreferences::DisplayPreferences;

use strict;
use parent qw(Rose::Object);

use SL::Helper::UserPreferences;

use Rose::Object::MakeMethods::Generic (
'scalar --get_set_init' => [ qw(user_prefs) ],
);

sub get_longdescription_dialog_size_percentage {
$_[0]->user_prefs->get('longdescription_dialog_size_percentage');
}

sub store_longdescription_dialog_size_percentage {
$_[0]->user_prefs->store('longdescription_dialog_size_percentage', $_[1]);
}

15672788 Bernd Bleßmann
sub get_layout_style {
my $value = $_[0]->user_prefs->get('layout_style');
$value //= $::instance_conf->get_layout_style;
return $value;
}

sub store_layout_style {
my ($self, $style) = @_;

if (!$style) {
$self->user_prefs->delete('layout_style');
return;
}

6c6a8d01 Bernd Bleßmann
if ( !($style eq 'desktop' || $style eq 'mobile' || $style eq 'auto') ) {
15672788 Bernd Bleßmann
die "unknown layout style '$style'";
}

$self->user_prefs->store('layout_style', $style);
}

94f5cb15 Bernd Bleßmann
sub init_user_prefs {
SL::Helper::UserPreferences->new(
namespace => $_[0]->namespace,
)
}

# read only stuff
sub namespace { 'DisplayPreferences' }
sub version { 1 }

1;

__END__

=pod

=encoding utf-8

=head1 NAME

SL::Helper::UserPreferences::DisplayPreferences - preferences intended
to store user settings for various display settings.

=head1 SYNOPSIS

use SL::Helper::UserPreferences::DisplayPreferences;
my $prefs = SL::Helper::UserPreferences::DisplayPreferences->new();

56f841b0 Bernd Bleßmann
$prefs->store_longdescription_dialog_size_percentage(25);
94f5cb15 Bernd Bleßmann
my $value = $prefs->get_longdescription_dialog_size_percentage;

=head1 DESCRIPTION

This module manages storing the user's choise for settings for
various display settings.
15672788 Bernd Bleßmann
=head2 These settings are supported:

=over 4

=item longdescription_dialog_size_percentage

The preferred procentual size of the edit-dialog for longdescriptions
94f5cb15 Bernd Bleßmann
of positions can be stored.

15672788 Bernd Bleßmann
=item layout_style

Here the layout style can be forced to be 'desktop' or 'mobile'
regardless of the user agend string. If this user setting is unset
then the setting from the client configuration will be used.

=back

94f5cb15 Bernd Bleßmann
=head1 BUGS

None yet :)

=head1 AUTHOR

Bernd Bleßmann E<lt>bernd@kivitendo-premium.deE<gt>

=cut