source: tspsg/src/main.cpp @ 21361c757d

appveyor
Last change on this file since 21361c757d was b9167cec6d, checked in by Oleksii Serdiuk, 9 years ago

Update copyright years

  • Property mode set to 100644
File size: 4.1 KB
RevLine 
[2bbe924ad8]1/*
2 *  TSPSG: TSP Solver and Generator
[b9167cec6d]3 *  Copyright (C) 2007-2016 Oleksii Serdiuk <contacts[at]oleksii[dot]name>
[2bbe924ad8]4 *
[7ba743d983]5 *  $Id: $Format:%h %ai %an$ $
6 *  $URL: http://tspsg.info/ $
[2bbe924ad8]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
[2940c14782]12 *  the Free Software Foundation, either version 2 of the License, or
[2bbe924ad8]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"
[7ed8b57eea]25#include "version.h"
26
27#ifdef Q_OS_BLACKBERRY
28#   include "bb10proxystyle.h"
29#endif // Q_OS_BLACKBERRY
[07e43cf61a]30
31#include <QDateTime>
32#include <QFontDatabase>
33#include <QTextCodec>
34#include <QTranslator>
35
[356169a3d3]36#if QT_VERSION < QT_VERSION_CHECK(4,6,0)
[9eb63a1598]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
[2bbe924ad8]44#endif
45
46//#ifdef STATIC_BUILD
[cac8759dba]47//      #ifndef NOSVG
48//              Q_IMPORT_PLUGIN(qsvgicon)
49//      #endif
[2bbe924ad8]50//#endif
51
52int main(int argc, char *argv[])
53{
[89e5214692]54#ifdef Q_OS_SYMBIAN
[1299ea5b49]55    // Not enough memory for solution graph generation with tasks
[5cbcd091ed]56    // of 20 and more cities if we use non-raster graphics system.
57    QApplication::setGraphicsSystem("raster");
58#endif
[2bbe924ad8]59QApplication app(argc, argv);
[9eb63a1598]60    app.setOverrideCursor(QCursor(Qt::WaitCursor));
61    QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
[356169a3d3]62#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
[9eb63a1598]63    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
64    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
[356169a3d3]65#endif
[c90b437dd8]66    app.setOrganizationName("Oleksii Serdiuk");
[9eb63a1598]67    app.setOrganizationDomain("oleksii.name");
68    app.setApplicationName("TSP Solver and Generator");
69    app.setApplicationVersion(BUILD_VERSION);
[2bbe924ad8]70
[7ed8b57eea]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
[9eb63a1598]77    // Seeding random number generator
78    qsrand(QDateTime::currentDateTime().toTime_t() ^ QCursor::pos().x() ^ QCursor::pos().y());
[2bbe924ad8]79
[89e5214692]80#ifdef Q_OS_WINCE_WM
[9eb63a1598]81    // Qt "leaves" unpacked .ttf files after running - let's try to delete them.
[b2e8e7ec71]82QStringList files = QDir(app.applicationDirPath(), "*.ttf").entryList();
[9eb63a1598]83    foreach (QString file, files) {
84        QFile::remove(file);
85    }
[b2e8e7ec71]86#endif
[9eb63a1598]87    // Don't load the font if it is already available
[7e8e1b444d]88    if (!QFontDatabase().families().contains(DEF_FONT_FACE)) {
89        QFontDatabase::addApplicationFont(":/files/fonts/DejaVuLGCSansMono.ttf");
90        QFontDatabase::addApplicationFont(":/files/fonts/DejaVuLGCSansMono-Bold.ttf");
91    }
[7cd6da5021]92
[2bbe924ad8]93QTranslator en;
[9eb63a1598]94    if (en.load("tspsg_en", PATH_L10N))
95        app.installTranslator(&en);
96    else if (en.load("tspsg_en", ":/l10n"))
97        app.installTranslator(&en);
[2bbe924ad8]98
99MainWindow mainwindow;
[89e5214692]100#ifdef Q_OS_SYMBIAN
[23ad8db4a5]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
[2bbe924ad8]109#ifdef HANDHELD
[9eb63a1598]110    mainwindow.showMaximized();
[31694c8b58]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
[2bbe924ad8]118#else // HANDHELD
[9eb63a1598]119    mainwindow.show();
[2bbe924ad8]120#endif // HANDHELD
[9eb63a1598]121    app.restoreOverrideCursor();
122    return app.exec();
[2bbe924ad8]123}
Note: See TracBrowser for help on using the repository browser.