Mercurial > public > ostc_companion
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 27 18:40:28 2025 +0100 @@ -0,0 +1,144 @@ +////////////////////////////////////////////////////////////////////////////// +/// \file main.cpp +/// \brief Wrap everything up. +/// \author JD Gascuel. +/// +/// \copyright (c) 2011-2014 JD Gascuel. All rights reserved. +/// $Id$ +////////////////////////////////////////////////////////////////////////////// +// +// BSD 2-Clause License: +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +// THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////// +// HISTORY +// 2013-03-17 : [jDG] Initial version. +// 2014-07-07 : [jDG] Cleanups for Subsurface google-summer-of-code. +// 2014-07-25 : [jDG] BSD 2-clause license. +// 2014-10-21 : [jDG] Update for Qt5.3 +// 2015-03-16 : [jDG] Update for Qt5.4.1, Renamed OSTC2c, Added OSTC2, OSTC3+ + +#include "MainWindow.h" + +#include "SettingsDialog.h" +#include "Utils/Log.h" + +#include <QApplication> +#include <QSettings> +#include <QSysInfo> +#include <QOperatingSystemVersion> + +QSettings* settings = NULL; + +////////////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + //---- LOG system and initialization ------------------------------------- + Log::init(argc, argv); + +#if 0 + LOG_TRACE("OSTC Companion " + << "v" << MAJOR_VERSION << "." << MINOR_VERSION + << (BETA_VERSION ? QString(" beta %1").arg(PATCH_VERSION) : " release") + << " " << QSysInfo::WordSize << "bits" + << " (build " BUILD_VERSION ")."); +#endif +#if 0 +#define LOG_TRACE(msg) \ + do { \ + if(Log::minLevel <= Log::LEVEL_TRACE) { \ + std::ostringstream oss; \ + oss << msg; \ + LogAction(Log::LEVEL_TRACE, __FILE__, __LINE__, LOG_FUNCTION_) << oss.str(); \ + } \ + } while(0) +#endif +#define LOG_TRACE(msg) \ + do { \ + if(Log::minLevel <= Log::LEVEL_TRACE) { \ + LogAction(Log::LEVEL_TRACE, __FILE__, __LINE__, LOG_FUNCTION_) << QString("%1").arg(msg); \ + } \ + } while(0) + +#ifdef Q_OS_WIN32 + + auto os = QOperatingSystemVersion::current(); + + if (os >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10)) { + LOG_TRACE(" Windows 10 or newer"); + } else if (os >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 8)) { + LOG_TRACE(" Windows 8"); + } + +#if 0 + switch(QSysInfo::windowsVersion()) { + case QSysInfo::WV_XP: LOG_TRACE(" Windows XP"); break; + case QSysInfo::WV_2003: LOG_TRACE(" Windows 2003"); break; + case QSysInfo::WV_VISTA: LOG_TRACE(" Windows Vista"); break; + case QSysInfo::WV_WINDOWS7: LOG_TRACE(" Windows 7"); break; + case QSysInfo::WV_WINDOWS8: LOG_TRACE(" Windows 8"); break; + case QSysInfo::WV_WINDOWS8_1: LOG_TRACE(" Windows 8.1"); break; +#if QT_VERSION < 0x0505 + case 0x00c0: +#else + case QSysInfo::WV_WINDOWS10: +#endif + LOG_TRACE(" Windows 10"); break; + default: LOG_TRACE(" Windows " << QString().sprintf("%04X", QSysInfo::windowsVersion()) ); break; + } +#endif +#elif defined(Q_OS_MACX) + if( QSysInfo::macVersion() < 2 ) + LOG_TRACE(" MacOS 9" ); + else + LOG_TRACE(" MacOS 10." << int(QSysInfo::macVersion()-2)); +#elif defined(Q_OS_LINUX) + LOG_TRACE(" Linux "); +#else +# error Unknown OS not yet implemented +#endif + // LOG_TRACE(" Qt build " << QT_VERSION_STR << " (DLL " << qVersion() << ")"); + LOG_TRACE(QString(" Qt build %1 (DLL %2)").arg(QT_VERSION_STR).arg(qVersion())); + //---- Initialize interface ---------------------------------------------- + // Allow nice display on 4K screens: + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); + + QApplication a(argc, argv); + + settings = new QSettings("OSTC", "Companion", &a); + Settings::reload(0); + MainWindow w; + w.show(); + + int rc = a.exec(); + + settings->sync(); + delete settings; + + Log::close(); + return rc; +}
