diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index db061854b..cb13bcee6 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -27,13 +27,35 @@ *************************************************************************/ #include "tmainwindow.h" -#include +#include "mapplication.h" + +#include // For QT_REQUIRE_VERSION int main(int argc, char *argv[]) { - QApplication a(argc, argv); - TMainWindow w; - w.show(); + Q_INIT_RESOURCE(icon); - return a.exec(); + QT_REQUIRE_VERSION(argc, argv, "5.0.0"); + + MApplication app(argc, argv); + if (not app.IsTheOnly()) + { + return 0; + } + + QStringList args = QCoreApplication::arguments(); + if (args.count() > 1) + { + args.removeFirst(); + for (int i = 0; i < args.size(); ++i) + { + app.NewMainWindow(); + app.MainWindow()->LoadFile(args.at(i)); + } + } + else + { + app.NewMainWindow(); + } + return app.exec(); } diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp new file mode 100644 index 000000000..cece94815 --- /dev/null +++ b/src/app/tape/mapplication.cpp @@ -0,0 +1,207 @@ +/************************************************************************ + ** + ** @file mapplication.cpp + ** @author Roman Telezhynskyi + ** @date 8 7, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "mapplication.h" +#include "version.h" +#include "tmainwindow.h" + +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +MApplication::MApplication(int &argc, char **argv) + :QApplication(argc, argv), + mainWindows(), + localServer(nullptr) +{ + setApplicationDisplayName(VER_PRODUCTNAME_STR); + setApplicationName(VER_INTERNALNAME_STR); + setOrganizationName(VER_COMPANYNAME_STR); + setOrganizationDomain(VER_COMPANYDOMAIN_STR); + // Setting the Application version + setApplicationVersion(APP_VERSION_STR); + setWindowIcon(QIcon(":/icon/64x64/logo.png")); + + const QString serverName = QCoreApplication::applicationName(); + QLocalSocket socket; + socket.connectToServer(serverName); + if (socket.waitForConnected(500)) + { + QTextStream stream(&socket); + QStringList args = QCoreApplication::arguments(); + if (args.count() > 1) + { + args.removeFirst(); + const QString arguments = args.join(";;"); + stream << arguments; + } + else + { + stream << QString(); + } + stream.flush(); + socket.waitForBytesWritten(); + return; + } + + localServer = new QLocalServer(this); + connect(localServer, &QLocalServer::newConnection, this, &MApplication::NewLocalSocketConnection); + if (!localServer->listen(serverName)) + { + if (localServer->serverError() == QAbstractSocket::AddressInUseError + && QFile::exists(localServer->serverName())) + { + QFile::remove(localServer->serverName()); + localServer->listen(serverName); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +MApplication::~MApplication() +{ + for (int i = 0; i < mainWindows.size(); ++i) + { + TMainWindow *window = mainWindows.at(i); + delete window; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +MApplication *MApplication::instance() +{ + return (static_cast(QCoreApplication::instance())); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MApplication::IsTheOnly() const +{ + return (localServer != 0); +} + +//--------------------------------------------------------------------------------------------------------------------- +TMainWindow *MApplication::MainWindow() +{ + Clean(); + if (mainWindows.isEmpty()) + { + NewMainWindow(); + } + return mainWindows[0]; +} + +//--------------------------------------------------------------------------------------------------------------------- +QList MApplication::MainWindows() +{ + Clean(); + QList list; + for (int i = 0; i < mainWindows.count(); ++i) + { + list.append(mainWindows.at(i)); + } + return list; +} + +#if defined(Q_WS_MAC) +bool MApplication::event(QEvent* event) +{ + switch (event->type()) + { + case QEvent::ApplicationActivate: + { + Clean(); + if (!mainWindows.isEmpty()) + { + TMainWindow *mw = MainWindow(); + if (mw && !mw->isMinimized()) + { + MainWindow()->show(); + } + return true; + } + } + default: + break; + } + return QApplication::event(event); +} +#endif + +//--------------------------------------------------------------------------------------------------------------------- +TMainWindow *MApplication::NewMainWindow() +{ + TMainWindow *tape = new TMainWindow(); + mainWindows.prepend(tape); + tape->show(); + return tape; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MApplication::OpenFile(const QString &path) +{ + MainWindow()->LoadFile(path); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MApplication::NewLocalSocketConnection() +{ + QLocalSocket *socket = localServer->nextPendingConnection(); + if (not socket) + { + return; + } + socket->waitForReadyRead(1000); + QTextStream stream(socket); + QString path; + stream >> path; + if (not path.isEmpty()) + { + const QStringList args = path.split(";;"); + for (int i = 0; i < args.size(); ++i) + { + NewMainWindow(); + OpenFile(args.at(i)); + } + } + delete socket; + MainWindow()->raise(); + MainWindow()->activateWindow(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MApplication::Clean() +{ + // cleanup any deleted main windows first + for (int i = mainWindows.count() - 1; i >= 0; --i) + { + if (mainWindows.at(i).isNull()) + { + mainWindows.removeAt(i); + } + } +} diff --git a/src/app/tape/mapplication.h b/src/app/tape/mapplication.h new file mode 100644 index 000000000..63d498f30 --- /dev/null +++ b/src/app/tape/mapplication.h @@ -0,0 +1,70 @@ +/************************************************************************ + ** + ** @file mapplication.h + ** @author Roman Telezhynskyi + ** @date 8 7, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef MAPPLICATION_H +#define MAPPLICATION_H + +#include + +class TMainWindow; +class QLocalServer; + +class MApplication : public QApplication +{ + Q_OBJECT + +public: + MApplication(int &argc, char **argv); + virtual ~MApplication() Q_DECL_OVERRIDE; + + static MApplication *instance(); + + bool IsTheOnly() const; + TMainWindow *MainWindow(); + QList MainWindows(); + +#if defined(Q_WS_MAC) + bool event(QEvent *event); +#endif + +public slots: + TMainWindow *NewMainWindow(); + +private slots: + void OpenFile(const QString &path); + void NewLocalSocketConnection(); + +private: + Q_DISABLE_COPY(MApplication) + QList > mainWindows; + QLocalServer *localServer; + + void Clean(); +}; + +#endif // MAPPLICATION_H diff --git a/src/app/tape/share/resources/icon.qrc b/src/app/tape/share/resources/icon.qrc new file mode 100644 index 000000000..dfda1bb66 --- /dev/null +++ b/src/app/tape/share/resources/icon.qrc @@ -0,0 +1,5 @@ + + + icon/64x64/logo.png + + diff --git a/src/app/tape/share/resources/icon/64x64/logo.ico b/src/app/tape/share/resources/icon/64x64/logo.ico new file mode 100644 index 000000000..07d2a8d44 Binary files /dev/null and b/src/app/tape/share/resources/icon/64x64/logo.ico differ diff --git a/src/app/tape/share/resources/icon/64x64/logo.png b/src/app/tape/share/resources/icon/64x64/logo.png new file mode 100644 index 000000000..6be8c4449 Binary files /dev/null and b/src/app/tape/share/resources/icon/64x64/logo.png differ diff --git a/src/app/tape/share/resources/tape.rc b/src/app/tape/share/resources/tape.rc new file mode 100644 index 000000000..564b611a4 --- /dev/null +++ b/src/app/tape/share/resources/tape.rc @@ -0,0 +1,34 @@ +IDI_ICON1 ICON DISCARDABLE "icon/64x64/logo.ico" + +#include +#include "../../version.h" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_PRODUCTVERSION +FILEOS VOS__WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", VER_COMPANYNAME_STR + VALUE "FileDescription", VER_FILEDESCRIPTION_STR + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", VER_INTERNALNAME_STR + VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR + VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR + VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR + VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR + VALUE "ProductName", VER_PRODUCTNAME_STR + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04E4 //U.S. English + END +END diff --git a/src/app/tape/tape.pri b/src/app/tape/tape.pri index bf0208ced..e466365c5 100644 --- a/src/app/tape/tape.pri +++ b/src/app/tape/tape.pri @@ -4,11 +4,13 @@ SOURCES += \ $$PWD/main.cpp \ $$PWD/tmainwindow.cpp \ - $$PWD/stable.cpp + $$PWD/stable.cpp \ + $$PWD/mapplication.cpp HEADERS += \ $$PWD/tmainwindow.h \ - $$PWD/stable.h + $$PWD/stable.h \ + $$PWD/mapplication.h FORMS += \ $$PWD/tmainwindow.ui diff --git a/src/app/tape/tape.pro b/src/app/tape/tape.pro index ab6a4cac1..9afca9cdb 100644 --- a/src/app/tape/tape.pro +++ b/src/app/tape/tape.pro @@ -7,7 +7,7 @@ # File with common stuff for whole project include(../../../common.pri) -QT += core gui widgets +QT += core gui widgets network # Name of binary file TARGET = tape @@ -43,6 +43,11 @@ UI_DIR = uic # Suport subdirectories. Just better project code tree. include(tape.pri) +# Compilation will fail without this files after we added them to this section. +OTHER_FILES += \ + share/resources/tape.rc \ # For Windows system. + share/resources/icon/64x64/logo.ico # Tape's logo. + # Set using ccache. Function enable_ccache() defined in common.pri. macx { CONFIG(debug, debug|release){ @@ -91,10 +96,6 @@ CONFIG(debug, debug|release){ } } - #Calculate latest tag distance and build revision only in release mode. Change number each time requare - #recompilation precompiled headers file. - DEFINES += "LATEST_TAG_DISTANCE=0" - DEFINES += "BUILD_REVISION=\\\"unknown\\\"" }else{ # Release mode DEFINES += V_NO_ASSERT @@ -113,34 +114,29 @@ CONFIG(debug, debug|release){ QMAKE_LFLAGS_RELEASE = } } - - macx{ - HG = /usr/local/bin/hg # Can't defeat PATH variable on Mac OS. - }else { - HG = hg # All other platforms all OK. - } - #latest tag distance number for using in version - HG_DISTANCE=$$system($${HG} log -r. --template '{latesttagdistance}') - isEmpty(HG_DISTANCE){ - HG_DISTANCE = 0 # if we can't find local revision left 0. - } - message("Latest tag distance:" $${HG_DISTANCE}) - DEFINES += "LATEST_TAG_DISTANCE=$${HG_DISTANCE}" # Make available latest tag distance number in sources. - - #build revision number for using in version - unix { - HG_HESH=$$system("$${HG} log -r. --template '{node|short}'") - } else { - # Use escape character before "|" on Windows - HG_HESH=$$system($${HG} log -r. --template "{node^|short}") - } - isEmpty(HG_HESH){ - HG_HESH = "unknown" # if we can't find build revision left unknown. - } - message("Build revision:" $${HG_HESH}) - DEFINES += "BUILD_REVISION=\\\"$${HG_HESH}\\\"" # Make available build revision number in sources. } +# Path to recource file. +win32:RC_FILE = share/resources/tape.rc + +#VMisc static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vmisc/$${DESTDIR}/ -lvmisc + +INCLUDEPATH += $$PWD/../../libs/vmisc +DEPENDPATH += $$PWD/../../libs/vmisc + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/vmisc.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vmisc/$${DESTDIR}/libvmisc.a + +#VWidgets static library +unix|win32: LIBS += -L$$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/ -lvwidgets + +INCLUDEPATH += $$PWD/../../libs/vwidgets +DEPENDPATH += $$PWD/../../libs/vwidgets + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a + noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols # do nothing } else { @@ -165,3 +161,6 @@ noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols } } } + +RESOURCES += \ + share/resources/icon.qrc diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 2c902dc00..6332184c6 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -42,3 +42,9 @@ TMainWindow::~TMainWindow() { delete ui; } + +//--------------------------------------------------------------------------------------------------------------------- +void TMainWindow::LoadFile(const QString &path) +{ + +} diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index 00854643c..f0a4a44d8 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -44,6 +44,9 @@ public: explicit TMainWindow(QWidget *parent = 0); virtual ~TMainWindow() Q_DECL_OVERRIDE; +public slots: + void LoadFile(const QString &path); + private: Q_DISABLE_COPY(TMainWindow) Ui::TMainWindow *ui; diff --git a/src/app/tape/version.h b/src/app/tape/version.h new file mode 100644 index 000000000..a9c28a5f7 --- /dev/null +++ b/src/app/tape/version.h @@ -0,0 +1,38 @@ +/************************************************************************ + ** + ** @file version.h + ** @author Roman Telezhynskyi + ** @date November 15, 2013 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2013-2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VERSION_H +#define VERSION_H + +#include "../../libs/vmisc/projectversion.h" + +#define VER_INTERNALNAME_STR "Tape" +#define VER_ORIGINALFILENAME_STR "tape.exe" +#define VER_PRODUCTNAME_STR "Tape" + +#endif // VERSION_H diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp new file mode 100644 index 000000000..d984e962b --- /dev/null +++ b/src/libs/vmisc/projectversion.cpp @@ -0,0 +1,72 @@ +/************************************************************************ + ** + ** @file projectversion.cpp + ** @author Roman Telezhynskyi + ** @date 8 7, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "projectversion.h" +#include +#include +#include + +extern const int MAJOR_VERSION = 0; +extern const int MINOR_VERSION = 3; +extern const int DEBUG_VERSION = 3; + +extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) + .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); + +//--------------------------------------------------------------------------------------------------------------------- +QString compilerString() +{ +#if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too + QString isAppleString; +#if defined(__apple_build_version__) // Apple clang has other version numbers + isAppleString = QLatin1String(" (Apple)"); +#endif + return QLatin1String("Clang " ) + QString::number(__clang_major__) + QLatin1Char('.') + + QString::number(__clang_minor__) + isAppleString; +#elif defined(Q_CC_GNU) + return QLatin1String("GCC " ) + QLatin1String(__VERSION__); +#elif defined(Q_CC_MSVC) + if (_MSC_VER >= 1800) // 1800: MSVC 2013 (yearly release cycle) + { + compiler = QLatin1String("MSVC ") + QString::number(2008 + ((_MSC_VER / 100) - 13)); + } + if (_MSC_VER >= 1500) // 1500: MSVC 2008, 1600: MSVC 2010, ... (2-year release cycle) + { + return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15)); + } +#else + return QLatin1String(""); +#endif +} + +//--------------------------------------------------------------------------------------------------------------------- +QString buildCompatibilityString() +{ + return QCoreApplication::tr("Based on Qt %1 (%2, %3 bit)").arg(QLatin1String(qVersion()), compilerString(), + QString::number(QSysInfo::WordSize)); +} diff --git a/src/libs/vmisc/projectversion.h b/src/libs/vmisc/projectversion.h new file mode 100644 index 000000000..40bd5c36b --- /dev/null +++ b/src/libs/vmisc/projectversion.h @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file projectversion.h + ** @author Roman Telezhynskyi + ** @date 8 7, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef PROJECTVERSION_H +#define PROJECTVERSION_H + +class QString; + +extern const int MAJOR_VERSION; +extern const int MINOR_VERSION; +extern const int DEBUG_VERSION; + +extern const QString APP_VERSION_STR; + +/* + APP_VERSION is (major << 16) + (minor << 8) + patch. +*/ +#define APP_VERSION 0x000300 + +// Change version number in version.cpp too. + +#define VER_FILEVERSION 0,3,3,0 +#define VER_FILEVERSION_STR "0.3.3.0\0" + +#define VER_PRODUCTVERSION VER_FILEVERSION +#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR + +#define VER_COMPANYNAME_STR "ValentinaTeam" +#define VER_FILEDESCRIPTION_STR "Patternmaking program." +//#define VER_INTERNALNAME_STR "Valentina" // Defined in program +#define VER_LEGALCOPYRIGHT_STR "Copyright © 2014-2015 Valentina Team" +#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved" +#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR +//#define VER_ORIGINALFILENAME_STR "valentina.exe" // Defined in program +//#define VER_PRODUCTNAME_STR "Valentina" // Defined in program + +#define VER_COMPANYDOMAIN_STR "www.valentina-project.org" + +QString compilerString(); +QString buildCompatibilityString(); + +#endif // PROJECTVERSION_H diff --git a/src/libs/vmisc/vmisc.pri b/src/libs/vmisc/vmisc.pri index e33858f0a..884b59efe 100644 --- a/src/libs/vmisc/vmisc.pri +++ b/src/libs/vmisc/vmisc.pri @@ -8,7 +8,8 @@ SOURCES += \ $$PWD/backport/qcommandlineoption.cpp \ $$PWD/backport/qcommandlineparser.cpp \ $$PWD/vsettings.cpp \ - $$PWD/vabstractapplication.cpp + $$PWD/vabstractapplication.cpp \ + projectversion.cpp HEADERS += \ $$PWD/stable.h \ @@ -19,4 +20,5 @@ HEADERS += \ $$PWD/backport/qcommandlineoption.h \ $$PWD/backport/qcommandlineparser.h \ $$PWD/vsettings.h \ - $$PWD/vabstractapplication.h + $$PWD/vabstractapplication.h \ + projectversion.h diff --git a/src/libs/vmisc/vmisc.pro b/src/libs/vmisc/vmisc.pro index ac78aa553..7db4fdbe6 100644 --- a/src/libs/vmisc/vmisc.pro +++ b/src/libs/vmisc/vmisc.pro @@ -82,6 +82,10 @@ CONFIG(debug, debug|release){ } } + #Calculate latest tag distance and build revision only in release mode. Change number each time requare + #recompilation precompiled headers file. + DEFINES += "LATEST_TAG_DISTANCE=0" + DEFINES += "BUILD_REVISION=\\\"unknown\\\"" }else{ # Release mode DEFINES += V_NO_ASSERT @@ -100,4 +104,30 @@ CONFIG(debug, debug|release){ QMAKE_LFLAGS_RELEASE = } } + + macx{ + HG = /usr/local/bin/hg # Can't defeat PATH variable on Mac OS. + }else { + HG = hg # All other platforms all OK. + } + #latest tag distance number for using in version + HG_DISTANCE=$$system($${HG} log -r. --template '{latesttagdistance}') + isEmpty(HG_DISTANCE){ + HG_DISTANCE = 0 # if we can't find local revision left 0. + } + message("Latest tag distance:" $${HG_DISTANCE}) + DEFINES += "LATEST_TAG_DISTANCE=$${HG_DISTANCE}" # Make available latest tag distance number in sources. + + #build revision number for using in version + unix { + HG_HESH=$$system("$${HG} log -r. --template '{node|short}'") + } else { + # Use escape character before "|" on Windows + HG_HESH=$$system($${HG} log -r. --template "{node^|short}") + } + isEmpty(HG_HESH){ + HG_HESH = "unknown" # if we can't find build revision left unknown. + } + message("Build revision:" $${HG_HESH}) + DEFINES += "BUILD_REVISION=\\\"$${HG_HESH}\\\"" # Make available build revision number in sources. }