ViewerPreferences.cc 2.74 KB
Newer Older
1 2 3 4 5 6 7
//========================================================================
//
// ViewerPreferences.cc
//
// This file is licensed under the GPLv2 or later
//
// Copyright 2011 Pino Toscano <pino@kde.org>
Albert Astals Cid's avatar
Albert Astals Cid committed
8
// Copyright 2017 Albert Astals Cid <aacid@kde.org>
9 10 11 12 13 14 15 16 17 18 19 20 21 22
//
//========================================================================

#include <config.h>

#include "ViewerPreferences.h"

#include "Object.h"
#include "Dict.h"

ViewerPreferences::ViewerPreferences(Dict *prefDict)
{
  init();

Albert Astals Cid's avatar
Albert Astals Cid committed
23 24
  Object obj = prefDict->lookup("HideToolbar");
  if (obj.isBool()) {
25 26 27
    hideToolbar = obj.getBool();
  }

Albert Astals Cid's avatar
Albert Astals Cid committed
28 29
  obj = prefDict->lookup("HideMenubar");
  if (obj.isBool()) {
30 31 32
    hideMenubar = obj.getBool();
  }

Albert Astals Cid's avatar
Albert Astals Cid committed
33 34
  obj = prefDict->lookup("HideWindowUI");
  if (obj.isBool()) {
35 36 37
    hideWindowUI = obj.getBool();
  }

Albert Astals Cid's avatar
Albert Astals Cid committed
38 39
  obj = prefDict->lookup("FitWindow");
  if (obj.isBool()) {
40 41 42
    fitWindow = obj.getBool();
  }

Albert Astals Cid's avatar
Albert Astals Cid committed
43 44
  obj = prefDict->lookup("CenterWindow");
  if (obj.isBool()) {
45 46 47
    centerWindow = obj.getBool();
  }

Albert Astals Cid's avatar
Albert Astals Cid committed
48 49
  obj = prefDict->lookup("DisplayDocTitle");
  if (obj.isBool()) {
50
    displayDocTitle = obj.getBool();
51
  }
52

Albert Astals Cid's avatar
Albert Astals Cid committed
53 54
  obj = prefDict->lookup("NonFullScreenPageMode");
  if (obj.isName()) {
55 56 57 58 59 60 61 62 63 64 65 66
    const char *mode = obj.getName();
    if (!strcmp(mode, "UseNone")) {
      nonFullScreenPageMode = nfpmUseNone;
    } else if (!strcmp(mode, "UseOutlines")) {
      nonFullScreenPageMode = nfpmUseOutlines;
    } else if (!strcmp(mode, "UseThumbs")) {
      nonFullScreenPageMode = nfpmUseThumbs;
    } else if (!strcmp(mode, "UseOC")) {
      nonFullScreenPageMode = nfpmUseOC;
    }
  }

Albert Astals Cid's avatar
Albert Astals Cid committed
67 68
  obj = prefDict->lookup("Direction");
  if (obj.isName()) {
69 70 71 72 73 74 75
    const char *dir = obj.getName();
    if (!strcmp(dir, "L2R")) {
      direction = directionL2R;
    } else if (!strcmp(dir, "R2L")) {
      direction = directionR2L;
    }
  }
76

Albert Astals Cid's avatar
Albert Astals Cid committed
77 78
  obj = prefDict->lookup("PrintScaling");
  if (obj.isName()) {
79 80 81 82 83 84 85 86
    const char *ps = obj.getName();
    if (!strcmp(ps, "None")) {
      printScaling = printScalingNone;
    } else if (!strcmp(ps, "AppDefault")) {
      printScaling = printScalingAppDefault;
    }
  }

Albert Astals Cid's avatar
Albert Astals Cid committed
87 88
  obj = prefDict->lookup("Duplex");
  if (obj.isName()) {
89 90 91 92 93 94 95 96 97
    const char *d = obj.getName();
    if (!strcmp(d, "Simplex")) {
      duplex = duplexSimplex;
    } else if (!strcmp(d, "DuplexFlipShortEdge")) {
      duplex = duplexDuplexFlipShortEdge;
    } else if (!strcmp(d, "DuplexFlipLongEdge")) {
      duplex = duplexDuplexFlipLongEdge;
    }
  }
98 99 100 101 102 103 104 105
}

ViewerPreferences::~ViewerPreferences()
{
}

void ViewerPreferences::init()
{
106 107 108 109 110 111
  hideToolbar = gFalse;
  hideMenubar = gFalse;
  hideWindowUI = gFalse;
  fitWindow = gFalse;
  centerWindow = gFalse;
  displayDocTitle = gFalse;
112 113
  nonFullScreenPageMode = nfpmUseNone;
  direction = directionL2R;
114 115
  printScaling = printScalingAppDefault;
  duplex = duplexNone;
116
}