• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

main.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2007 Frerich Raabe <raabe@kde.org>
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00015  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00016  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00017  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00018  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00019  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00020  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00021  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00023  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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     //At this point arg(0) is always set
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 

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal