main.cpp 3.81 KB
Newer Older
Jan Schäfer's avatar
Jan Schäfer committed
1 2 3 4
/***************************************************************************
                          main.cpp  -  description
                            -------------------
    begin                : Die Apr 10 19:46:49 CEST 2001
5
    copyright            : (C) 2001 by Jan Schäfer
Jan Schäfer's avatar
Jan Schäfer committed
6 7 8 9 10 11 12 13 14 15 16 17
    email                : j_schaef@informatik.uni-kl.de
***************************************************************************/

/***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
***************************************************************************/

Luigi Toscano's avatar
Luigi Toscano committed
18 19 20
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
21
#include <QDir>
Luigi Toscano's avatar
Luigi Toscano committed
22 23 24

#include <KAboutData>
#include <KLocalizedString>
Jan Schäfer's avatar
Jan Schäfer committed
25 26

#include "kimeshell.h"
27
#include "kimagemapeditor_version.h"
Jan Schäfer's avatar
Jan Schäfer committed
28 29 30 31 32 33 34

static const char *description =
  I18N_NOOP("An HTML imagemap editor");


int main(int argc, char *argv[])
{
Luigi Toscano's avatar
Luigi Toscano committed
35 36
  QApplication app(argc, argv);
  KLocalizedString::setApplicationDomain("kimagemapeditor");
Jan Schäfer's avatar
Jan Schäfer committed
37

Luigi Toscano's avatar
Luigi Toscano committed
38
  KAboutData aboutData( "kimagemapeditor", i18n("KImageMapEditor"),
39
    KIMAGEMAPEDITOR_VERSION_STRING, i18n(description), KAboutLicense::GPL,
Luigi Toscano's avatar
Luigi Toscano committed
40
    i18n("(c) 2001-2007 Jan Schaefer"), QString(),
41
    QStringLiteral("https://kde.org/applications/development/org.kde.kimagemapeditor"), QStringLiteral("janschaefer@users.sourceforge.net"));
Luigi Toscano's avatar
Luigi Toscano committed
42 43 44 45 46 47
  aboutData.addAuthor(i18n("Jan Schaefer"),QString(), "janschaefer@users.sourceforge.net");
  aboutData.addCredit(i18n("Joerg Jaspert"),i18n("For helping me with the Makefiles, and creating the Debian package"));
  aboutData.addCredit(i18n("Aaron Seigo and Michael"),i18n("For helping me fixing --enable-final mode"));
  aboutData.addCredit(i18n("Antonio Crevillen"),i18n("For the Spanish translation"));
  aboutData.addCredit(i18n("Fabrice Mous"),i18n("For the Dutch translation"));
  aboutData.addCredit(i18n("Germain Chazot"),i18n("For the French translation"));
Jan Schäfer's avatar
Jan Schäfer committed
48

49 50 51 52 53 54 55 56
  aboutData.setOrganizationDomain("kde.org");
  aboutData.setDesktopFileName(QStringLiteral("org.kde.kimagemapeditor"));
  KAboutData::setApplicationData(aboutData);

  app.setOrganizationName(QStringLiteral("KDE"));

  app.setWindowIcon(QIcon::fromTheme("kimagemapeditor", app.windowIcon()));

Luigi Toscano's avatar
Luigi Toscano committed
57 58 59 60
  QCommandLineParser parser;
  aboutData.setupCommandLine(&parser);
  parser.addVersionOption();
  parser.addHelpOption();
Jan Schäfer's avatar
Jan Schäfer committed
61

Luigi Toscano's avatar
Luigi Toscano committed
62 63 64 65
  parser.addOption(QCommandLineOption(QStringList() << QLatin1String("c") << QLatin1String("stdout"), i18n("Write HTML-Code to stdout on exit")));
  parser.addPositionalArgument(QLatin1String("[File]"), i18n("File to open"));
  parser.process(app);
  aboutData.processCommandLine(&parser);
66

Luigi Toscano's avatar
Luigi Toscano committed
67
  if (app.isSessionRestored())
Jan Schäfer's avatar
Jan Schäfer committed
68
  {
69
      kRestoreMainWindows<KimeShell>();
Jan Schäfer's avatar
Jan Schäfer committed
70 71 72
  }
  else
  {
Luigi Toscano's avatar
Luigi Toscano committed
73
      if ( parser.positionalArguments().count() == 0 )
Jan Schäfer's avatar
Jan Schäfer committed
74 75
      {
        KimeShell *kimeShell = new KimeShell();
Luigi Toscano's avatar
Luigi Toscano committed
76
        kimeShell->setStdout(parser.isSet("stdout"));
Jan Schäfer's avatar
Jan Schäfer committed
77 78 79 80 81 82 83
        kimeShell->readConfig();
        kimeShell->show();
        kimeShell->openLastFile();
      }
      else
      {
          int i = 0;
Luigi Toscano's avatar
Luigi Toscano committed
84
          for (; i < parser.positionalArguments().count(); i++ )
Jan Schäfer's avatar
Jan Schäfer committed
85 86
          {
            KimeShell *kimeShell = new KimeShell();
Luigi Toscano's avatar
Luigi Toscano committed
87
            kimeShell->setStdout(parser.isSet("stdout"));
Jan Schäfer's avatar
Jan Schäfer committed
88 89
            kimeShell->readConfig();
            kimeShell->show();
90
            kimeShell->openFile(QUrl::fromUserInput(parser.positionalArguments().at(i), QDir::currentPath(), QUrl::AssumeLocalFile));
Jan Schäfer's avatar
Jan Schäfer committed
91 92 93
          }
      }

Luigi Toscano's avatar
Luigi Toscano committed
94 95 96
  }

  return app.exec();
Jan Schäfer's avatar
Jan Schäfer committed
97
}