[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kjsembed
From:       Erik Lloyd Bunce <kde () bunce ! us>
Date:       2006-09-27 21:44:56
Message-ID: 1159393496.261909.24056.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 589288 by bunce:

Migrate from KJSEMBED_WITH_KDE to QT_ONLY. Made it so kjscmd can be brought up with \
KApplication, QApplication, or QCoreApplication.

 M  +39 -22    kjscmd/kjscmd.cpp  
 M  +4 -4      kjsembed/builtins.cpp  


--- trunk/KDE/kdelibs/kjsembed/kjscmd/kjscmd.cpp #589287:589288
@@ -18,18 +18,16 @@
     Boston, MA 02110-1301, USA.
 */
 
-#define KJSEMBED_WITH_KDE
-
 #include <QString>
 #include <QApplication>
 #include <QDebug>
 #include <QStringList>
 
-#ifdef KJSEMBED_WITH_KDE
+#ifndef QT_ONLY
 #include <kapplication.h>
 #include <kaboutdata.h>
 #include <kcmdlineargs.h>
-#endif // KJSEMBED_WITH_KDE
+#endif // QT_ONLY
 
 #include <kjs/interpreter.h>
 #include <kjs/ustring.h>
@@ -50,7 +48,7 @@
                           << endl;
 }
 
-#ifdef KJSEMBED_WITH_KDE
+#ifndef QT_ONLY
 
 static KCmdLineOptions options[] =
 {
@@ -58,7 +56,7 @@
     KCmdLineLastOption
 };
 
-#endif // KJSEMBED_WITH_KDE
+#endif // QT_ONLY
 
 int main( int argc, char **argv )
 {
@@ -82,6 +80,12 @@
     QString script;
     KJS::List scriptArgs;
     bool gui = true;
+#ifndef QT_ONLY
+#warning "KDE Support enabled"
+    bool kde = true;
+#else
+#warning "KDE Support disabled"
+#endif
 
     if (argc > 1)
     {
@@ -91,10 +95,18 @@
             if (arg.contains('-'))
             {
                 if ((arg == "--exec") || (arg == "-e"))
+		{
                     gui = false;
+		}
                 else if ((arg == "--interactive") || (arg == "-i"))
                     (*KJSEmbed::conout()) << "Interactive";
-                else
+#ifndef QT_ONLY
+                else if ((arg == "-n") || (arg == "--no-kde"))
+		{
+		    kde = false;
+		}
+#endif
+		else
                 {
                     printUsage(appName);
                     return 0;
@@ -115,33 +127,38 @@
         return 0;
     }
 
-#ifdef KJSEMBED_WITH_KDE
-#warning "KDE Support enabled"
-  KAboutData aboutData( "kjscmd", I18N_NOOP("KJSCmd"), "0.2",
-      I18N_NOOP(""
-       "Utility for running KJSEmbed scripts \n" ),
-      KAboutData::License_LGPL,
-       "(C) 2005-2006 The KJSEmbed Authors" );
+    // Setup QApplication
+    QCoreApplication *app;
 
-  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
-  KCmdLineArgs::init( argc, argv, &aboutData );
+#ifndef QT_ONLY
+    if (kde && gui)
+    {
+        KAboutData aboutData( "kjscmd", I18N_NOOP("KJSCmd"), "0.2",
+            I18N_NOOP(""
+            "Utility for running KJSEmbed scripts \n" ),
+            KAboutData::License_LGPL,
+            "(C) 2005-2006 The KJSEmbed Authors" );
 
-  KApplication *app = new KApplication();
-#else
-#warning "KDE Support disabled"
-    // Setup QApplication
-    QCoreApplication *app;
+        KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+        KCmdLineArgs::init( argc, argv, &aboutData );
+
+        app = new KApplication();
+    }
+    else
+#endif
     if (gui)
     {
+	qDebug("no KDE");
         app = new QApplication( argc, argv );
         dynamic_cast<QApplication*>(app)->connect( app, SIGNAL( lastWindowClosed() \
), SLOT(quit()) );  }
     else
     {
+	qDebug("no GUI");
         app = new QCoreApplication(argc, argv);
     }
     qDebug(" New QApplication %dms", time.elapsed());
-#endif
+
     app->setApplicationName( appName );
     
     // Setup Interpreter
--- trunk/KDE/kdelibs/kjsembed/kjsembed/builtins.cpp #589287:589288
@@ -68,7 +68,7 @@
     return KJS::Null();
 }
 
-#ifdef KJSEMBED_WITH_KDE
+#ifndef QT_ONLY
 
 KJS::JSValue *callLibrary( KJS::ExecState *exec, KJS::JSObject *self, const \
KJS::List &args )  {
@@ -86,7 +86,7 @@
     return KJS::Null();
 }
 
-#endif // KJSEMBED_WITH_KDE
+#endif // QT_ONLY
 
 KJS::JSValue *callAlert( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List \
&args )  {
@@ -157,9 +157,9 @@
     {"exec", 0, KJS::DontDelete|KJS::ReadOnly, &callExec},
     {"dump", 1, KJS::DontDelete|KJS::ReadOnly, &callDump},
     {"include", 1, KJS::DontDelete|KJS::ReadOnly, &callInclude},
-#ifdef KJSEMBED_WITH_KDE
+#ifndef QT_ONLY
     {"library", 1, KJS::DontDelete|KJS::ReadOnly, &callLibrary},
-#endif // KJSEMBED_WITH_KDE
+#endif // QT_ONLY
     {"alert", 1, KJS::DontDelete|KJS::ReadOnly, &callAlert},
     {"confirm", 1, KJS::DontDelete|KJS::ReadOnly, &callConfirm},
     {"isVariantType", 1, KJS::DontDelete|KJS::ReadOnly, &callIsVariantType},


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic