[2bbe924ad8] | 1 | /*! |
---|
| 2 | * \file globals.h |
---|
[21c03af787] | 3 | * \author Copyright © 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 | * \brief Contains TSPSG global defines. |
---|
| 9 | * |
---|
| 10 | * <b>TSPSG: TSP Solver and Generator</b> |
---|
| 11 | * |
---|
| 12 | * This file is part of TSPSG. |
---|
| 13 | * |
---|
| 14 | * TSPSG is free software: you can redistribute it and/or modify |
---|
| 15 | * it under the terms of the GNU General Public License as published by |
---|
[2940c14782] | 16 | * the Free Software Foundation, either version 2 of the License, or |
---|
[2bbe924ad8] | 17 | * (at your option) any later version. |
---|
| 18 | * |
---|
| 19 | * TSPSG is distributed in the hope that it will be useful, |
---|
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 22 | * GNU General Public License for more details. |
---|
| 23 | * |
---|
| 24 | * You should have received a copy of the GNU General Public License |
---|
| 25 | * along with TSPSG. If not, see <http://www.gnu.org/licenses/>. |
---|
| 26 | */ |
---|
| 27 | |
---|
| 28 | #ifndef GLOBALS_H |
---|
| 29 | #define GLOBALS_H |
---|
| 30 | |
---|
| 31 | // INCLUDES |
---|
[07e43cf61a] | 32 | #include <QtGlobal> |
---|
[356169a3d3] | 33 | #if QT_VERSION < QT_VERSION_CHECK(4,5,0) |
---|
[9eb63a1598] | 34 | # error You are using Qt version < 4.5 but minimum required version is 4.5.0. Compilation aborted. |
---|
[2a436ea693] | 35 | #endif |
---|
[1241232377] | 36 | #if defined(Q_OS_WINCE_WM) || defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) || defined(Q_OS_BLACKBERRY) |
---|
[9eb63a1598] | 37 | //! This is defined on handheld devices (e.g., Windows Mobile, Symbian). |
---|
| 38 | # define HANDHELD |
---|
| 39 | # define QT_NO_STATUSTIP |
---|
[2a436ea693] | 40 | #endif |
---|
[9adbc413c7] | 41 | #if defined(QT_NO_SVG) && !defined(NOSVG) |
---|
[9eb63a1598] | 42 | # define NOSVG |
---|
[9adbc413c7] | 43 | #endif |
---|
[2bbe924ad8] | 44 | |
---|
| 45 | // TSPSG Defaults |
---|
| 46 | #include "defaults.h" |
---|
| 47 | |
---|
| 48 | // DEFINES |
---|
| 49 | //! Maximum available number of cities |
---|
| 50 | #define MAX_NUM_CITIES 50 |
---|
| 51 | //! Maximum allowed value for random generation limits |
---|
| 52 | #define MAX_RAND_VALUE 1000 |
---|
| 53 | |
---|
| 54 | // Paths |
---|
| 55 | /*! |
---|
| 56 | * \def PATH_L10N |
---|
| 57 | * \brief Path to internationalization files. |
---|
| 58 | */ |
---|
| 59 | #ifndef PATH_L10N |
---|
[9eb63a1598] | 60 | # define PATH_L10N "l10n" |
---|
[2bbe924ad8] | 61 | #endif // PATH_L10N |
---|
| 62 | /*! |
---|
| 63 | * \def PATH_DOCS |
---|
[07e43cf61a] | 64 | * \brief Path to documentation files. |
---|
[2bbe924ad8] | 65 | */ |
---|
| 66 | #ifndef PATH_DOCS |
---|
[9eb63a1598] | 67 | # define PATH_DOCS "help" |
---|
[2bbe924ad8] | 68 | #endif // PATH_DOCS |
---|
| 69 | |
---|
| 70 | //! TSPSG Task file signature - letters \c TSPT |
---|
| 71 | #define TSPT quint32(0x54535054) |
---|
| 72 | //! TSPSG Task file version |
---|
| 73 | #define TSPT_VERSION quint8(1) |
---|
| 74 | //! TSPSG Task file metadata version |
---|
| 75 | #define TSPT_META_VERSION quint8(1) |
---|
| 76 | //! TSPSG Task file metadata size in bytes (incl. version) |
---|
| 77 | #define TSPT_META_SIZE 2 |
---|
| 78 | //! ZKomModRd Task file signature - letters \c ZK |
---|
| 79 | #define ZKT quint16(0x5A4B) |
---|
| 80 | //! ZKomModRd Task file version |
---|
| 81 | #define ZKT_VERSION quint8(1) |
---|
| 82 | |
---|
| 83 | //! This string represents infinite value in the table |
---|
| 84 | #define INFSTR "---" |
---|
| 85 | |
---|
[8f2427aaf0] | 86 | //! Number of centimeters in 1 inch |
---|
| 87 | #define CM_IN_INCH 2.54 |
---|
| 88 | //! Factor for high quality graph generation |
---|
| 89 | #define HQ_FACTOR 2 |
---|
| 90 | |
---|
[f5c945d7ac] | 91 | /*! |
---|
| 92 | * \brief Checks whether the updater app is installed/available. |
---|
| 93 | * \return \c true if updater app is available, oherwise \c false. |
---|
| 94 | * \note The updater app is only available under Windows at this moment. |
---|
| 95 | * On other systems this function always returns \c false. |
---|
| 96 | */ |
---|
[07e43cf61a] | 97 | bool hasUpdater(); |
---|
[b26dc16dcf] | 98 | |
---|
[07e43cf61a] | 99 | class QSettings; |
---|
| 100 | class QObject; |
---|
[31694c8b58] | 101 | /*! |
---|
| 102 | * \brief Creates QSettings instance with TSPSG-specific options. |
---|
| 103 | * \param parent A QObject which will become parent for new QSetting instance. |
---|
| 104 | * \return A pointer to new QSettings instance. |
---|
| 105 | */ |
---|
| 106 | QSettings *initSettings(QObject *parent); |
---|
| 107 | |
---|
[b8a2a118c4] | 108 | #ifndef HANDHELD |
---|
[07e43cf61a] | 109 | class QWidget; |
---|
[2bbe924ad8] | 110 | /*! |
---|
| 111 | * \brief Enables or disables a mask for the \a widget. |
---|
| 112 | * \param widget A widget to toggle mask on. |
---|
| 113 | * \param enable Set to \c true to enable mask or \c false to disable it. |
---|
| 114 | * |
---|
| 115 | * This function is used to enable an outlined font effect for \c QLabel with a static text. |
---|
| 116 | */ |
---|
| 117 | void toggleStyle(QWidget *widget, bool enable); |
---|
[b8a2a118c4] | 118 | #endif // HANDHELD |
---|
[2bbe924ad8] | 119 | |
---|
[cac8759dba] | 120 | #ifndef DOXYGEN_EXCLUDE |
---|
| 121 | |
---|
[7ed8b57eea] | 122 | #if defined(HANDHELD) && !defined(Q_OS_BLACKBERRY) |
---|
[d97db6d321] | 123 | # define ICON_SIZE "48x48" |
---|
[9eb63a1598] | 124 | # define ICON_FORMAT "png" |
---|
[cac8759dba] | 125 | #else |
---|
[9eb63a1598] | 126 | # define ICON_SIZE "128x128" |
---|
| 127 | # define ICON_FORMAT "png" |
---|
[cac8759dba] | 128 | #endif |
---|
| 129 | |
---|
[356169a3d3] | 130 | #if QT_VERSION >= QT_VERSION_CHECK(4,6,0) |
---|
[9eb63a1598] | 131 | # define GET_ICON(x) QIcon::fromTheme(x, QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT)) |
---|
[2a436ea693] | 132 | #else |
---|
[9eb63a1598] | 133 | # define GET_ICON(x) QIcon(":/images/icons/"ICON_SIZE"/"x"."ICON_FORMAT) |
---|
[fec08a47e5] | 134 | // No QVariant::toReal() member in Qt < 4.6 |
---|
| 135 | // A quick hack to maintain compatibility with Qt 4.5.x |
---|
| 136 | # define toReal toDouble |
---|
[2a436ea693] | 137 | #endif |
---|
| 138 | |
---|
[2bbe924ad8] | 139 | // Sanity checks |
---|
| 140 | // Check that default number of cities is sane (<= MAX_NUM_CITIES) |
---|
| 141 | #if DEF_NUM_CITIES > MAX_NUM_CITIES |
---|
[9eb63a1598] | 142 | # undef DEF_NUM_CITIES |
---|
| 143 | # define DEF_NUM_CITIES MAX_NUM_CITIES |
---|
[2bbe924ad8] | 144 | #endif |
---|
| 145 | // Check that maximum for random generation is sane (<= MAX_RAND_VALUE) |
---|
| 146 | #if DEF_RAND_MAX > MAX_RAND_VALUE |
---|
[9eb63a1598] | 147 | # undef DEF_RAND_MAX |
---|
| 148 | # define DEF_RAND_MAX MAX_RAND_VALUE |
---|
[2bbe924ad8] | 149 | #endif |
---|
| 150 | // Check that DEF_RAND_MIN <= DEF_RAND_MAX |
---|
| 151 | #if DEF_RAND_MIN > DEF_RAND_MAX |
---|
[9eb63a1598] | 152 | # undef DEF_RAND_MIN |
---|
| 153 | # define DEF_RAND_MIN DEF_RAND_MAX |
---|
[2bbe924ad8] | 154 | #endif |
---|
| 155 | |
---|
[cac8759dba] | 156 | #endif // DOXYGEN_EXCLUDE |
---|
| 157 | |
---|
[2bbe924ad8] | 158 | #endif // GLOBALS_H |
---|