Plasma
main.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "fullview.h"
00027
00028 #include <QPixmapCache>
00029
00030 #include <KApplication>
00031 #include <KAboutData>
00032 #include <KAction>
00033 #include <KCmdLineArgs>
00034 #include <KLocale>
00035 #include <KStandardAction>
00036
00037 using namespace Plasma;
00038
00039 static const char description[] = I18N_NOOP( "Run Plasma applets in their own window" );
00040
00041 int main(int argc, char **argv)
00042 {
00043 KAboutData aboutData( "plasmoidviewer", 0, ki18n( "Plasma Applet Viewer" ),
00044 "1.0", ki18n( description ), KAboutData::License_BSD,
00045 ki18n( "(C) 2007, The KDE Team" ) );
00046 aboutData.setProgramIconName( "plasma" );
00047 aboutData.addAuthor( ki18n( "Frerich Raabe" ),
00048 ki18n( "Original author" ),
00049 "raabe@kde.org" );
00050
00051 KCmdLineArgs::init( argc, argv, &aboutData );
00052
00053 KCmdLineOptions options;
00054 options.add( "f" );
00055 options.add( "formfactor <name>", ki18n( "The formfactor to use (horizontal, vertical, mediacenter or planar)" ), "planar");
00056 options.add( "l" );
00057 options.add( "location <name>", ki18n( "The location constraint to start the Containment with (floating, desktop, fullscreen, top, bottom, left, right)" ), "floating");
00058 options.add( "p" );
00059 options.add( "pixmapcache <size>", ki18n("The size in KB to set the pixmap cache to"));
00060 options.add( "!+applet", ki18n( "Name of applet to add (required)" ) );
00061 options.add( "+[args]", ki18n( "Optional arguments of the applet to add" ) );
00062 KCmdLineArgs::addCmdLineOptions( options );
00063
00064 KApplication app;
00065
00066 KCmdLineArgs *args = KCmdLineArgs::parsedArgs() ;
00067 if ( args->count() == 0 ) {
00068 KCmdLineArgs::usageError(i18n("No applet name specified"));
00069 }
00070
00071 QString formfactor;
00072 if (args->isSet("formfactor")) {
00073 kDebug() << "setting FormFactor to" << args->getOption("formfactor");
00074 formfactor = args->getOption("formfactor");
00075 }
00076
00077 QString location;
00078 if (args->isSet("location")) {
00079 kDebug() << "setting Location to" << args->getOption("location");
00080 location = args->getOption("location");
00081 }
00082
00083 QVariantList appletArgs;
00084 for ( int i = 1; i < args->count(); ++i ) {
00085 appletArgs << args->arg(i);
00086 }
00087
00088 FullView view( formfactor, location );
00089
00090 view.addApplet( args->arg(0), appletArgs );
00091 view.show();
00092
00093 QAction *action = KStandardAction::quit(&app, SLOT(quit()), &view);
00094 view.addAction(action);
00095
00096 if (args->isSet("pixmapcache")) {
00097 kDebug() << "setting pixmap cach to" << args->getOption("pixmapcache").toInt();
00098 QPixmapCache::setCacheLimit(args->getOption("pixmapcache").toInt());
00099 }
00100 args->clear();
00101
00102 return app.exec();
00103 }
00104