Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
main.cpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 #include <QApplication>
12 #include <QStringList>
13 #include <QString>
14 #include "core.hpp"
15 #include "terminalparser.hpp"
16 #include "login.hpp"
17 #include "exception.hpp"
18 
19 //! This function just read the parameters and return true if we can continue or not
20 bool TerminalParse(int argc, char *argv[])
21 {
22  QStringList args;
23  int i=0;
24  while (i<argc)
25  {
26  args.append(QString(argv[i]));
27  i++;
28  }
29  // we create a new terminal parser
31  // if parser get an argument which requires app to exit (like --help or --version)
32  // we can terminate it now
33  if (p->Parse())
34  {
35  delete p;
36  return false;
37  }
38  // otherwise we can delete it and continue
39  delete p;
40  return true;
41 }
42 
43 int main(int argc, char *argv[])
44 {
45  try
46  {
47  // check if arguments don't need to exit program
48  if (!TerminalParse(argc, argv))
49  {
50  return 0;
51  }
52  // we load the core
54  // now we can start the huggle :o
55  Huggle::HgApplication a(argc, argv);
57  Huggle::Core::f_Login->show();
58 
59  return a.exec();
60  } catch (Huggle::Exception fail)
61  {
62  Huggle::Core::Log("FATAL: Unhandled exception occured, description: " + fail.Message);
63  return fail.ErrorCode;
64  }
65 }
66 
static void Log(QString Message)
Write text to terminal as well as ring log.
Definition: core.cpp:563
Parses the data provided by user.
Overwrite of qapplication so that we can reimplement notify.
Definition: core.hpp:76
Window that is displayed as first when huggle is started.
Definition: login.hpp:56
QString Message
Reason for crash.
Definition: exception.hpp:27
int ErrorCode
Error code.
Definition: exception.hpp:24
Every exception raised by huggle is defined by this class.
Definition: exception.hpp:20
static void Init()
Function which is called as one of first when huggle is loaded.
Definition: core.cpp:41
static Login * f_Login
Login form.
Definition: core.hpp:113