summaryrefslogtreecommitdiffstats
path: root/kwordquiz/src/main.cpp
blob: dc1e8b15c9e45e0540094f37fddb4c0e6687fb59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/***************************************************************************
                          main.cpp  -  description
                             -------------------
    begin                : Wed Jul 24 20:12:30 PDT 2002
    copyright            : (C) 2002-2003 by Peter Hedlund
    email                : peter.hedlund@kdemail.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include <kcmdlineargs.h>
#include <kaboutdata.h>

#include "kwordquiz.h"
#include "version.h"

static const char *description = I18N_NOOP("A powerful flashcard and vocabulary learning program");

static KCmdLineOptions options[] =
{
  { "m", 0, 0 },
  { "mode <number>", I18N_NOOP("A number 1-5 corresponding to the \nentries in the Mode menu"), 0 },
  { "g", 0, 0 },
  { "goto <session>", I18N_NOOP("Type of session to start with: \n'flash' for flashcard, \n'mc' for multiple choice, \n'qa' for question and answer"), 0 },
  { "+[File]", I18N_NOOP("File to open"), 0 },
  { 0, 0, 0 }
};

int main(int argc, char *argv[])
{
  KAboutData aboutData("kwordquiz",
                       I18N_NOOP("KWordQuiz"),
                       KWTQ_VERSION,
                       description,
                       KAboutData::License_GPL,
                       "(c) 2003-2005, Peter Hedlund",
                       0,
                       "http://edu.kde.org/kwordquiz",
                       "submit@bugs.kde.org");

  aboutData.addAuthor("Peter Hedlund", 0, "peter.hedlund@kdemail.net");
  aboutData.addCredit("Anne-Marie Mahfouf", I18N_NOOP("KDE Edutainment Maintainer"), "annma@kde.org", 0);

  TDECmdLineArgs::init( argc, argv, &aboutData );
  TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  TDEApplication app;

  if (app.isRestored())
  {
    RESTORE(KWordQuizApp);
  }
  else 
  {
    KWordQuizApp *kwordquiz = new KWordQuizApp();
    kwordquiz->show();

    TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();

    if (args->count())
    {
      kwordquiz->openDocumentFile(args->arg(args->count() - 1));
      TQCString mode = args->getOption("mode");
      if (!mode.isEmpty())
      {
        if (mode == "1")
          kwordquiz->slotMode1();
        if (mode == "2")
          kwordquiz->slotMode2();
        if (mode == "3")
          kwordquiz->slotMode3();
        if (mode == "4")
          kwordquiz->slotMode4();
        if (mode == "5")
          kwordquiz->slotMode5();
      }
      TQCString go_to = args->getOption("goto");
      if (!go_to.isEmpty())
      {
        if (go_to == "flash")
          kwordquiz->slotQuizFlash();
        if (go_to == "mc")
          kwordquiz->slotQuizMultiple();
        if (go_to == "qa")
          kwordquiz->slotQuizQA();
      }
    }
    else
    {
      kwordquiz->openDocumentFile();
    }
    args->clear();
  }
  return app.exec();
}