source: tspsg/src/main.cpp @ 2940c14782

appveyorimgbotreadme
Last change on this file since 2940c14782 was 2940c14782, checked in by Oleksii Serdiuk, 11 years ago

Relicensed TSP Solver and Generator under GPLv2 license.

Due to potential conflicts between GPLv3 and app stores.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 *  TSPSG: TSP Solver and Generator
3 *  Copyright (C) 2007-2013 Oleksii Serdiuk <contacts[at]oleksii[dot]name>
4 *
5 *  $Id: $Format:%h %ai %an$ $
6 *  $URL: http://tspsg.info/ $
7 *
8 *  This file is part of TSPSG.
9 *
10 *  TSPSG is free software: you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License as published by
12 *  the Free Software Foundation, either version 2 of the License, or
13 *  (at your option) any later version.
14 *
15 *  TSPSG is distributed in the hope that it will be useful,
16 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *  GNU General Public License for more details.
19 *
20 *  You should have received a copy of the GNU General Public License
21 *  along with TSPSG.  If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#include "mainwindow.h"
25
26#include <QDateTime>
27#include <QFontDatabase>
28#include <QTextCodec>
29#include <QTranslator>
30#include "version.h"
31
32#if QT_VERSION < QT_VERSION_CHECK(4,6,0)
33#   ifdef Q_CC_MSVC
34#       pragma message("WARNING: You are using Qt version < 4.6. Application will not support some non-critical features.")
35#   elif defined(Q_CC_GNU)
36#       warning WARNING: You are using Qt version < 4.6. Application will not support some non-critical features.
37#   else
38#       error You are using Qt version < 4.6. Application will not support some non-critical features. To continue, please, comment line 31 at main.cpp.
39#   endif
40#endif
41
42//#ifdef STATIC_BUILD
43//      #ifndef NOSVG
44//              Q_IMPORT_PLUGIN(qsvgicon)
45//      #endif
46//#endif
47
48int main(int argc, char *argv[])
49{
50#ifdef Q_OS_SYMBIAN
51    // Not enough memory for solution graph generation with tasks
52    // of 20 and more cities if we use non-raster graphics system.
53    QApplication::setGraphicsSystem("raster");
54#endif
55QApplication app(argc, argv);
56    app.setOverrideCursor(QCursor(Qt::WaitCursor));
57    QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
58#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
59    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
60    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
61#endif
62    app.setOrganizationName("Oleksii Serdiuk");
63    app.setOrganizationDomain("oleksii.name");
64    app.setApplicationName("TSP Solver and Generator");
65    app.setApplicationVersion(BUILD_VERSION);
66
67    // Seeding random number generator
68    qsrand(QDateTime::currentDateTime().toTime_t() ^ QCursor::pos().x() ^ QCursor::pos().y());
69
70#ifdef Q_OS_WINCE_WM
71    // Qt "leaves" unpacked .ttf files after running - let's try to delete them.
72QStringList files = QDir(app.applicationDirPath(), "*.ttf").entryList();
73    foreach (QString file, files) {
74        QFile::remove(file);
75    }
76#endif
77    // Don't load the font if it is already available
78    if (!QFontDatabase().families().contains(DEF_FONT_FACE)) {
79        QFontDatabase::addApplicationFont(":/files/fonts/DejaVuLGCSansMono.ttf");
80        QFontDatabase::addApplicationFont(":/files/fonts/DejaVuLGCSansMono-Bold.ttf");
81    }
82
83QTranslator en;
84    if (en.load("tspsg_en", PATH_L10N))
85        app.installTranslator(&en);
86    else if (en.load("tspsg_en", ":/l10n"))
87        app.installTranslator(&en);
88
89MainWindow mainwindow;
90#ifdef Q_OS_SYMBIAN
91    //! \hack HACK: A workaround to hide Actions menu item in Symbian.
92QWidgetList widgets = QApplication::allWidgets();
93QWidget *w = 0;
94    foreach(w, widgets) {
95        w->setContextMenuPolicy(Qt::NoContextMenu);
96    }
97#endif
98
99#ifdef HANDHELD
100    mainwindow.showMaximized();
101#ifdef Q_OS_WINCE_WM
102    /*!
103     * \hack HACK: For some reason showMaximized() stopped working on
104     *  Windows Mobile. This workaround works all the time.
105     */
106    mainwindow.setWindowState(Qt::WindowMaximized);
107#endif // Q_OS_WINCE_WM
108#else // HANDHELD
109    mainwindow.show();
110#endif // HANDHELD
111    app.restoreOverrideCursor();
112    return app.exec();
113}
Note: See TracBrowser for help on using the repository browser.