23 #include <qbytearray.h>
25 #include <kuniqueapplication.h>
26 #include <kaboutdata.h>
27 #include <kcmdlineargs.h>
29 #include <klibloader.h>
35 :
public KUniqueApplication
38 KigApplication(
bool gui =
true );
40 void handleArgs( KCmdLineArgs* args );
43 KigApplication::KigApplication(
bool gui )
44 : KUniqueApplication( gui, gui )
48 int KigApplication::newInstance()
50 static bool first =
true;
51 if (isSessionRestored() && first)
58 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
64 void KigApplication::handleArgs( KCmdLineArgs* args )
66 if ( args->count() == 0 )
73 for (
int i = 0; i < args->count(); i++ )
77 widget->
load( args->url( i ) );
84 KComponentData maindata( KCmdLineArgs::aboutData() );
85 KPluginLoader libraryLoader(
"kigpart" );
86 QLibrary library( libraryLoader.fileName() );
87 int ( *converterfunction )(
const KUrl&,
const QByteArray& );
88 converterfunction = ( int ( * )(
const KUrl&,
const QByteArray& ) ) library.resolve(
"convertToNative" );
89 if ( !converterfunction )
91 kError() <<
"Error: broken Kig installation: different library and application version !" << endl;
94 return (*converterfunction)( file, outfile );
97 int main(
int argc,
char **argv)
99 KAboutData about =
kigAboutData(
"kig", I18N_NOOP(
"Kig") );
101 KCmdLineArgs::init(argc, argv, &about);
103 KCmdLineOptions options;
105 options.add(
"convert-to-native", ki18n(
"Do not show a GUI. Convert the specified file to the native Kig format. Output goes to stdout unless --outfile is specified." ));
107 options.add(
"outfile <file>", ki18n(
"File to output the created native file to. '-' means output to stdout. Default is stdout as well." ));
108 options.add(
"+[URL]", ki18n(
"Document to open" ));
109 KCmdLineArgs::addCmdLineOptions( options );
110 KigApplication::addCmdLineOptions();
112 KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
113 if ( args->isSet(
"convert-to-native" ) )
115 QString outfile = args->getOption(
"outfile" );
116 if ( outfile.isEmpty() )
119 if ( args->count() == 0 )
121 kError() <<
"Error: --convert-to-native specified without a file to convert." << endl;
124 if ( args->count() > 1 )
126 kError() <<
"Error: --convert-to-native specified with more than one file to convert." << endl;
133 if ( args->isSet(
"outfile" ) )
135 kError() <<
"Error: --outfile specified without convert-to-native." << endl;
141 if (app.isSessionRestored()) RESTORE(
Kig)
void load(const KUrl &file)
Open file in this window.
int main(int argc, char **argv)
static int convertToNative(const KUrl &file, const QByteArray &outfile)
KAboutData kigAboutData(const char *name, const char *iname)
This is the application "Shell".