Mercurial > public > ostc_companion
comparison main.cpp @ 1:0b3630a29ad8
Initial version based on previous repository.
Project was ported to QT6 and in now cmake based.
| author | Ideenmodellierer <tiefenrauscher@web.de> |
|---|---|
| date | Thu, 27 Nov 2025 18:40:28 +0100 |
| parents | |
| children | 177f640940f2 |
comparison
equal
deleted
inserted
replaced
| 0:76ccd6ce50c0 | 1:0b3630a29ad8 |
|---|---|
| 1 ////////////////////////////////////////////////////////////////////////////// | |
| 2 /// \file main.cpp | |
| 3 /// \brief Wrap everything up. | |
| 4 /// \author JD Gascuel. | |
| 5 /// | |
| 6 /// \copyright (c) 2011-2014 JD Gascuel. All rights reserved. | |
| 7 /// $Id$ | |
| 8 ////////////////////////////////////////////////////////////////////////////// | |
| 9 // | |
| 10 // BSD 2-Clause License: | |
| 11 // | |
| 12 // Redistribution and use in source and binary forms, with or without | |
| 13 // modification, are permitted provided that the following conditions | |
| 14 // are met: | |
| 15 // | |
| 16 // 1. Redistributions of source code must retain the above copyright notice, | |
| 17 // this list of conditions and the following disclaimer. | |
| 18 // | |
| 19 // 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 20 // this list of conditions and the following disclaimer in the documentation | |
| 21 // and/or other materials provided with the distribution. | |
| 22 // | |
| 23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 24 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 25 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 26 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
| 27 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 28 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 29 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 30 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 31 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 32 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 33 // THE POSSIBILITY OF SUCH DAMAGE. | |
| 34 // | |
| 35 ////////////////////////////////////////////////////////////////////////////// | |
| 36 // HISTORY | |
| 37 // 2013-03-17 : [jDG] Initial version. | |
| 38 // 2014-07-07 : [jDG] Cleanups for Subsurface google-summer-of-code. | |
| 39 // 2014-07-25 : [jDG] BSD 2-clause license. | |
| 40 // 2014-10-21 : [jDG] Update for Qt5.3 | |
| 41 // 2015-03-16 : [jDG] Update for Qt5.4.1, Renamed OSTC2c, Added OSTC2, OSTC3+ | |
| 42 | |
| 43 #include "MainWindow.h" | |
| 44 | |
| 45 #include "SettingsDialog.h" | |
| 46 #include "Utils/Log.h" | |
| 47 | |
| 48 #include <QApplication> | |
| 49 #include <QSettings> | |
| 50 #include <QSysInfo> | |
| 51 #include <QOperatingSystemVersion> | |
| 52 | |
| 53 QSettings* settings = NULL; | |
| 54 | |
| 55 ////////////////////////////////////////////////////////////////////////////// | |
| 56 | |
| 57 int main(int argc, char *argv[]) | |
| 58 { | |
| 59 //---- LOG system and initialization ------------------------------------- | |
| 60 Log::init(argc, argv); | |
| 61 | |
| 62 #if 0 | |
| 63 LOG_TRACE("OSTC Companion " | |
| 64 << "v" << MAJOR_VERSION << "." << MINOR_VERSION | |
| 65 << (BETA_VERSION ? QString(" beta %1").arg(PATCH_VERSION) : " release") | |
| 66 << " " << QSysInfo::WordSize << "bits" | |
| 67 << " (build " BUILD_VERSION ")."); | |
| 68 #endif | |
| 69 #if 0 | |
| 70 #define LOG_TRACE(msg) \ | |
| 71 do { \ | |
| 72 if(Log::minLevel <= Log::LEVEL_TRACE) { \ | |
| 73 std::ostringstream oss; \ | |
| 74 oss << msg; \ | |
| 75 LogAction(Log::LEVEL_TRACE, __FILE__, __LINE__, LOG_FUNCTION_) << oss.str(); \ | |
| 76 } \ | |
| 77 } while(0) | |
| 78 #endif | |
| 79 #define LOG_TRACE(msg) \ | |
| 80 do { \ | |
| 81 if(Log::minLevel <= Log::LEVEL_TRACE) { \ | |
| 82 LogAction(Log::LEVEL_TRACE, __FILE__, __LINE__, LOG_FUNCTION_) << QString("%1").arg(msg); \ | |
| 83 } \ | |
| 84 } while(0) | |
| 85 | |
| 86 #ifdef Q_OS_WIN32 | |
| 87 | |
| 88 auto os = QOperatingSystemVersion::current(); | |
| 89 | |
| 90 if (os >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10)) { | |
| 91 LOG_TRACE(" Windows 10 or newer"); | |
| 92 } else if (os >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 8)) { | |
| 93 LOG_TRACE(" Windows 8"); | |
| 94 } | |
| 95 | |
| 96 #if 0 | |
| 97 switch(QSysInfo::windowsVersion()) { | |
| 98 case QSysInfo::WV_XP: LOG_TRACE(" Windows XP"); break; | |
| 99 case QSysInfo::WV_2003: LOG_TRACE(" Windows 2003"); break; | |
| 100 case QSysInfo::WV_VISTA: LOG_TRACE(" Windows Vista"); break; | |
| 101 case QSysInfo::WV_WINDOWS7: LOG_TRACE(" Windows 7"); break; | |
| 102 case QSysInfo::WV_WINDOWS8: LOG_TRACE(" Windows 8"); break; | |
| 103 case QSysInfo::WV_WINDOWS8_1: LOG_TRACE(" Windows 8.1"); break; | |
| 104 #if QT_VERSION < 0x0505 | |
| 105 case 0x00c0: | |
| 106 #else | |
| 107 case QSysInfo::WV_WINDOWS10: | |
| 108 #endif | |
| 109 LOG_TRACE(" Windows 10"); break; | |
| 110 default: LOG_TRACE(" Windows " << QString().sprintf("%04X", QSysInfo::windowsVersion()) ); break; | |
| 111 } | |
| 112 #endif | |
| 113 #elif defined(Q_OS_MACX) | |
| 114 if( QSysInfo::macVersion() < 2 ) | |
| 115 LOG_TRACE(" MacOS 9" ); | |
| 116 else | |
| 117 LOG_TRACE(" MacOS 10." << int(QSysInfo::macVersion()-2)); | |
| 118 #elif defined(Q_OS_LINUX) | |
| 119 LOG_TRACE(" Linux "); | |
| 120 #else | |
| 121 # error Unknown OS not yet implemented | |
| 122 #endif | |
| 123 // LOG_TRACE(" Qt build " << QT_VERSION_STR << " (DLL " << qVersion() << ")"); | |
| 124 LOG_TRACE(QString(" Qt build %1 (DLL %2)").arg(QT_VERSION_STR).arg(qVersion())); | |
| 125 //---- Initialize interface ---------------------------------------------- | |
| 126 // Allow nice display on 4K screens: | |
| 127 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); | |
| 128 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); | |
| 129 | |
| 130 QApplication a(argc, argv); | |
| 131 | |
| 132 settings = new QSettings("OSTC", "Companion", &a); | |
| 133 Settings::reload(0); | |
| 134 MainWindow w; | |
| 135 w.show(); | |
| 136 | |
| 137 int rc = a.exec(); | |
| 138 | |
| 139 settings->sync(); | |
| 140 delete settings; | |
| 141 | |
| 142 Log::close(); | |
| 143 return rc; | |
| 144 } |
