source: tspsg/src/main.cpp @ 21c03af787

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

Updated copyright endyear from 2012 to 2013.

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