KDE Anwendungs Tutorials: Der KDE Anwendungs-Tutorial Leitfaden für die Integrierte Entwicklungsumgebung KDevelop
Zurück | Anhang A. KScribble-1.0 Beispiel Quellcode | Vor

# A.2. main.cpp

       1 /***************************************************************************
       2                           main.cpp  -  description
       3                              -------------------
       4     begin                : Mon Jan 31 11:05:05 CET 2000
       5     copyright            : (C) 2000 by Ralf Nolden
       6     email                : Ralf.Nolden@post.rwth-aachen.de
       7  ***************************************************************************/
       8
       9 /***************************************************************************
      10  *                                                                         *
      11  *   This program is free software; you can redistribute it and/or modify  *
      12  *   it under the terms of the GNU General Public License as published by  *
      13  *   the Free Software Foundation; either version 2 of the License, or     *
      14  *   (at your option) any later version.                                   *
      15  *                                                                         *
      16  ***************************************************************************/
      17 #include <kcmdlineargs.h>
      18 #include <kaboutdata.h>
      19 #include <klocale.h>
      20
      21 #include "kscribble.h"
      22
      23 static const char *description =
      24    I18N_NOOP("KDE 2 example application");
      25
      26 static KCmdLineOptions options[] =
      27 {
      28    {  "+[File]", I18N_NOOP("image file to open"), 0  },
      29    {  0, 0, 0  }
      30 };
      31
      32
      33 int main(int argc, char *argv[])
      34 {
      35    KAboutData aboutData( "kscribble", I18N_NOOP("KScribble"),
      36       VERSION, description, KAboutData::License_GPL,
      37       "(c) 2000, Ralf Nolden");
      38    aboutData.addAuthor("Ralf Nolden",0, "rnolden@kdevelop.de");
      39    KCmdLineArgs::init( argc, argv, &&;aboutData );
      40    KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
      41
      42    KApplication app;
      43    KImageIO::registerFormats();
      44
      45    if (app.isRestored())
      46    {
      47       RESTORE(KScribbleApp);
      48    }
      49    else
      50    {
      51       KScribbleApp *kscribble = new KScribbleApp();
      52       kscribble->show();
      53
      54       KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
      55
      56       if (args->count())
      57         for(int i=0;i<args->count();i++)
      58           kscribble->openDocumentFile(args->arg(i));
      59       else
      60         kscribble->openDocumentFile();
      61
      62       args->clear();
      63    }
      64
      65    return app.exec();
      66 }

Zurück | Anfang | Vor
KScribble-1.0 Beispiel Quellcode | Hoch | kscribble.h