source: tspsg/src/main.cpp @ 30eb4f72f9

appveyorimgbot
Last change on this file since 30eb4f72f9 was b4b4f8d479, checked in by Oleksii Serdiuk, 10 years ago

Updated copyright endyear from 2013 to 2014

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 *  TSPSG: TSP Solver and Generator
3 *  Copyright (C) 2007-2014 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#include "version.h"
26
27#ifdef Q_OS_BLACKBERRY
28#   include "bb10proxystyle.h"
29#endif // Q_OS_BLACKBERRY
30
31#include <QDateTime>
32#include <QFontDatabase>
33#include <QTextCodec>
34#include <QTranslator>
35
36#if QT_VERSION < QT_VERSION_CHECK(4,6,0)
37#   ifdef Q_CC_MSVC
38#       pragma message("WARNING: You are using Qt version < 4.6. Application will not support some non-critical features.")
39#   elif defined(Q_CC_GNU)
40#       warning WARNING: You are using Qt version < 4.6. Application will not support some non-critical features.
41#   else
42#       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.
43#   endif
44#endif
45
46//#ifdef STATIC_BUILD
47//      #ifndef NOSVG
48//              Q_IMPORT_PLUGIN(qsvgicon)
49//      #endif
50//#endif
51
52int main(int argc, char *argv[])
53{
54#ifdef Q_OS_SYMBIAN
55    // Not enough memory for solution graph generation with tasks
56    // of 20 and more cities if we use non-raster graphics system.
57    QApplication::setGraphicsSystem("raster");
58#endif
59QApplication app(argc, argv);
60    app.setOverrideCursor(QCursor(Qt::WaitCursor));
61    QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
62#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
63    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
64    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
65#endif
66    app.setOrganizationName("Oleksii Serdiuk");
67    app.setOrganizationDomain("oleksii.name");
68    app.setApplicationName("TSP Solver and Generator");
69    app.setApplicationVersion(BUILD_VERSION);
70
71#ifdef Q_OS_BLACKBERRY
72    QApplication::setStartDragDistance(42);
73    QApplication::setStyle(new BB10ProxyStyle);
74    app.setStyleSheet(CSS_FIX);
75#endif // Q_OS_BLACKBERRY
76
77    // Seeding random number generator
78    qsrand(QDateTime::currentDateTime().toTime_t() ^ QCursor::pos().x() ^ QCursor::pos().y());
79
80#ifdef Q_OS_WINCE_WM
81    // Qt "leaves" unpacked .ttf files after running - let's try to delete them.
82QStringList files = QDir(app.applicationDirPath(), "*.ttf").entryList();
83    foreach (QString file, files) {
84        QFile::remove(file);
85    }
86#endif
87    // Don't load the font if it is already available
88    if (!QFontDatabase().families().contains(DEF_FONT_FACE)) {
89        QFontDatabase::addApplicationFont(":/files/fonts/DejaVuLGCSansMono.ttf");
90        QFontDatabase::addApplicationFont(":/files/fonts/DejaVuLGCSansMono-Bold.ttf");
91    }
92
93QTranslator en;
94    if (en.load("tspsg_en", PATH_L10N))
95        app.installTranslator(&en);
96    else if (en.load("tspsg_en", ":/l10n"))
97        app.installTranslator(&en);
98
99MainWindow mainwindow;
100#ifdef Q_OS_SYMBIAN
101    //! \hack HACK: A workaround to hide Actions menu item in Symbian.
102QWidgetList widgets = QApplication::allWidgets();
103QWidget *w = 0;
104    foreach(w, widgets) {
105        w->setContextMenuPolicy(Qt::NoContextMenu);
106    }
107#endif
108
109#ifdef HANDHELD
110    mainwindow.showMaximized();
111#ifdef Q_OS_WINCE_WM
112    /*!
113     * \hack HACK: For some reason showMaximized() stopped working on
114     *  Windows Mobile. This workaround works all the time.
115     */
116    mainwindow.setWindowState(Qt::WindowMaximized);
117#endif // Q_OS_WINCE_WM
118#else // HANDHELD
119    mainwindow.show();
120#endif // HANDHELD
121    app.restoreOverrideCursor();
122    return app.exec();
123}
Note: See TracBrowser for help on using the repository browser.