13 #include <kjs/kjsobject.h>
14 #include <kjs/kjsprototype.h>
15 #include <kjs/kjsarguments.h>
19 #include "../debug_p.h"
21 using namespace Okular;
25 #ifdef OKULAR_JS_CONSOLE
28 #include <qplaintextedit.h>
31 #include <kstandardguiitem.h>
33 K_GLOBAL_STATIC( KDialog, g_jsConsoleWindow )
34 static QPlainTextEdit *g_jsConsoleLog = 0;
36 static
void createConsoleWindow()
38 if ( g_jsConsoleWindow.exists() )
41 g_jsConsoleWindow->setButtons( KDialog::Close | KDialog::User1 );
42 g_jsConsoleWindow->setButtonGuiItem( KDialog::User1, KStandardGuiItem::clear() );
44 QVBoxLayout *mainLay =
new QVBoxLayout( g_jsConsoleWindow->mainWidget() );
45 mainLay->setMargin( 0 );
46 g_jsConsoleLog =
new QPlainTextEdit( g_jsConsoleWindow->mainWidget() );
47 g_jsConsoleLog->setReadOnly(
true );
48 mainLay->addWidget( g_jsConsoleLog );
50 QObject::connect( g_jsConsoleWindow, SIGNAL(closeClicked()),
51 g_jsConsoleWindow, SLOT(close()) );
52 QObject::connect( g_jsConsoleWindow, SIGNAL(user1Clicked()),
53 g_jsConsoleLog, SLOT(clear()) );
58 createConsoleWindow();
59 g_jsConsoleWindow->show();
64 if ( !g_jsConsoleWindow.exists() )
67 g_jsConsoleWindow->hide();
72 if ( !g_jsConsoleWindow.exists() )
75 g_jsConsoleLog->clear();
81 g_jsConsoleLog->appendPlainText( message );
105 static KJSObject
consoleClear( KJSContext *,
void *,
const KJSArguments & )
108 return KJSUndefined();
111 static KJSObject
consoleHide( KJSContext *,
void *,
const KJSArguments & )
114 return KJSUndefined();
118 const KJSArguments &arguments )
120 QString cMessage = arguments.at( 0 ).toString( ctx );
123 return KJSUndefined();
126 static KJSObject
consoleShow( KJSContext *,
void *,
const KJSArguments & )
129 return KJSUndefined();
134 static bool initialized =
false;
static KJSObject consolePrintln(KJSContext *ctx, void *, const KJSArguments &arguments)
static KJSObject consoleHide(KJSContext *, void *, const KJSArguments &)
static KJSObject object(KJSContext *ctx)
static KJSPrototype * g_consoleProto
static KJSObject consoleClear(KJSContext *, void *, const KJSArguments &)
static void hideConsole()
static void initType(KJSContext *ctx)
static void showConsole()
static void clearConsole()
static KJSObject consoleShow(KJSContext *, void *, const KJSArguments &)
static void outputToConsole(const QString &cMessage)