compile
[kdegraphics.git] / okular / core / script / kjs_fullscreen.cpp
blobc07ac4e23d8d08e51d972a69ffa0d9a8bb1e982d
1 /***************************************************************************
2 * Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
3 * Copyright (C) 2008 by Harri Porten <porten@kde.org> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
11 #include "kjs_fullscreen_p.h"
13 #include <assert.h>
15 #include <kjs/kjsobject.h>
16 #include <kjs/kjsprototype.h>
18 #include "settings.h"
20 using namespace Okular;
22 static KJSPrototype *g_fsProto;
24 static KJSObject fsGetLoop( KJSContext *, void * )
26 return KJSBoolean( Settings::slidesLoop() );
29 static void fsSetLoop( KJSContext *ctx, void *, KJSObject value )
31 bool loop = value.toBoolean( ctx );
32 Settings::setSlidesLoop( loop );
35 static KJSObject fsGetUseTimer( KJSContext *, void * )
37 return KJSBoolean( Settings::slidesAdvance() );
40 static void fsSetUseTimer( KJSContext *ctx, void *, KJSObject value )
42 bool use = value.toBoolean( ctx );
43 Settings::setSlidesAdvance( use );
46 static KJSObject fsGetTimeDelay( KJSContext *, void * )
48 return KJSNumber( Settings::slidesAdvanceTime() );
51 static void fsSetTimeDelay( KJSContext *ctx, void *, KJSObject value )
53 int time = static_cast<int>( value.toNumber( ctx ) );
54 Settings::setSlidesAdvanceTime( time );
57 void JSFullscreen::initType( KJSContext *ctx )
59 static bool initialized = false;
60 if ( initialized )
61 return;
62 initialized = true;
64 if ( !g_fsProto )
65 g_fsProto = new KJSPrototype();
67 g_fsProto->defineProperty( ctx, "loop", fsGetLoop, fsSetLoop );
68 g_fsProto->defineProperty( ctx, "useTimer",
69 fsGetUseTimer, fsSetUseTimer );
70 g_fsProto->defineProperty( ctx, "timeDelay",
71 fsGetTimeDelay, fsSetTimeDelay );
74 KJSObject JSFullscreen::object( KJSContext *ctx )
76 assert( g_fsProto );
77 return g_fsProto->constructObject( ctx );