Okular

kjs_fullscreen.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Pino Toscano <[email protected]>
3  SPDX-FileCopyrightText: 2008 Harri Porten <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #include "kjs_fullscreen_p.h"
9 
10 #include <assert.h>
11 
12 #include <kjs/kjsobject.h>
13 #include <kjs/kjsprototype.h>
14 
15 #include "settings_core.h"
16 
17 using namespace Okular;
18 
19 static KJSPrototype *g_fsProto;
20 
21 static KJSObject fsGetLoop(KJSContext *, void *)
22 {
23  return KJSBoolean(SettingsCore::slidesLoop());
24 }
25 
26 static void fsSetLoop(KJSContext *ctx, void *, KJSObject value)
27 {
28  bool loop = value.toBoolean(ctx);
29  SettingsCore::setSlidesLoop(loop);
30 }
31 
32 static KJSObject fsGetUseTimer(KJSContext *, void *)
33 {
34  return KJSBoolean(SettingsCore::slidesAdvance());
35 }
36 
37 static void fsSetUseTimer(KJSContext *ctx, void *, KJSObject value)
38 {
39  bool use = value.toBoolean(ctx);
40  SettingsCore::setSlidesAdvance(use);
41 }
42 
43 static KJSObject fsGetTimeDelay(KJSContext *, void *)
44 {
45  return KJSNumber(SettingsCore::slidesAdvanceTime());
46 }
47 
48 static void fsSetTimeDelay(KJSContext *ctx, void *, KJSObject value)
49 {
50  int time = static_cast<int>(value.toNumber(ctx));
51  SettingsCore::setSlidesAdvanceTime(time);
52 }
53 
54 void JSFullscreen::initType(KJSContext *ctx)
55 {
56  static bool initialized = false;
57  if (initialized) {
58  return;
59  }
60  initialized = true;
61 
62  if (!g_fsProto) {
63  g_fsProto = new KJSPrototype();
64  }
65 
66  g_fsProto->defineProperty(ctx, QStringLiteral("loop"), fsGetLoop, fsSetLoop);
67  g_fsProto->defineProperty(ctx, QStringLiteral("useTimer"), fsGetUseTimer, fsSetUseTimer);
68  g_fsProto->defineProperty(ctx, QStringLiteral("timeDelay"), fsGetTimeDelay, fsSetTimeDelay);
69 }
70 
71 KJSObject JSFullscreen::object(KJSContext *ctx)
72 {
73  assert(g_fsProto);
74  return g_fsProto->constructObject(ctx);
75 }
bool toBoolean(KJSContext *ctx)
double toNumber(KJSContext *ctx)
The documentation to the global Okular namespace.
Definition: action.h:16
void defineProperty(KJSContext *ctx, const QString &name, PropertyGetter getter, PropertySetter setter=nullptr)
KJSObject constructObject(KJSContext *ctx, void *internalValue=nullptr)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 04:04:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.