source: tspsg/src/main.cpp @ 7ed8b57eea

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

[BB10] UI fixes:

  • added proxy style and stylesheet to fix some UI issues on BlackBerry?;
  • removed style selection option because most styles have UI issues and removed About Qt menu item because About Qt dialog is too big;
  • load bigger (128x128) icons on BlackBerry? 10;
  • removed printing related items from menu as there's no printer;
  • made dialogs to be shown maximized;
  • made solution graph smaller;
  • made font smaller;
  • made output text color black;
  • start editing table cells on single tap;
  • don't show keyboard in about dialog.

Cherry-picks from
aa64ad40827cde0a444cd8198b0f3457aa191f8f
95b0ef73dcb4517ac2ae08867494204bbe8d7ea6
ccdffe3a5f84f12fba2e2f19ab249c31f1fcf35d
628500a5d687889823197e476953859d529af4f0

  • Property mode set to 100644
File size: 4.1 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#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.