From 9228e417b2c23e22770fec720d6d2f1486d7df64 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 10 Jul 2015 14:14:55 +0300 Subject: [PATCH] Class MApplication. --HG-- branch : feature --- src/app/tape/main.cpp | 32 ++- src/app/tape/mapplication.cpp | 207 ++++++++++++++++++ src/app/tape/mapplication.h | 70 ++++++ src/app/tape/share/resources/icon.qrc | 5 + .../tape/share/resources/icon/64x64/logo.ico | Bin 0 -> 16958 bytes .../tape/share/resources/icon/64x64/logo.png | Bin 0 -> 1658 bytes src/app/tape/share/resources/tape.rc | 34 +++ src/app/tape/tape.pri | 6 +- src/app/tape/tape.pro | 61 +++--- src/app/tape/tmainwindow.cpp | 6 + src/app/tape/tmainwindow.h | 3 + src/app/tape/version.h | 38 ++++ src/libs/vmisc/projectversion.cpp | 72 ++++++ src/libs/vmisc/projectversion.h | 67 ++++++ src/libs/vmisc/vmisc.pri | 6 +- src/libs/vmisc/vmisc.pro | 30 +++ 16 files changed, 597 insertions(+), 40 deletions(-) create mode 100644 src/app/tape/mapplication.cpp create mode 100644 src/app/tape/mapplication.h create mode 100644 src/app/tape/share/resources/icon.qrc create mode 100644 src/app/tape/share/resources/icon/64x64/logo.ico create mode 100644 src/app/tape/share/resources/icon/64x64/logo.png create mode 100644 src/app/tape/share/resources/tape.rc create mode 100644 src/app/tape/version.h create mode 100644 src/libs/vmisc/projectversion.cpp create mode 100644 src/libs/vmisc/projectversion.h 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 0000000000000000000000000000000000000000..07d2a8d44e99d1a8b84294babe7ebcb9b10ae6bc GIT binary patch literal 16958 zcmeI4e}q+O7{|{vVQ1Wp>P_v!CzXdv;&1_uPBV{V{hk^W-z{d7tw<&-*^_ zuXE-Md0rL&5($r=jb77c&s*wwUK615dO-RL$P(I2zyaum>o5e*;UL&@2*t1P0v^FV zxB-`-6FxUl4t@wH9LY!*X0I`^r5VM2xCnb;J=DT<%32yb4Qm{Y4xg^E3bCv3+E%R(ejQT=s zkHI+D?Wr%ejG(aXf_f?P-%izXI=f0E^hu>x3-ib|6x05NWGB!M~PLc{8Ns8l_LKUN8AGrT_O2v&f?^M zE{A=}(WiX**E@X7{ja|1UCfmIRCLbSk}v;VwgdIwAuNC8YD=#C70VX285Upqg|-8A zJAd=NLhn%SbnPJ%m1k5 zqqS$ZW%l)gWv{Aqrj2?1k$W97%8KF#{Wa~(Yx~)zXSm&`(QG`e`@mOgz?OXZkK>^A zBT+m0oh69pD&yv_80!0N_yJymE3T<)#Kx4xR5XsJjq=w!q4}&*JJOk=y=3~it`++= z&s^F?6q{o#x?!l6Ym>XnJxct z#Md)Q?;@t3=2830lx0**n_{o~%;4GUDbcW9Uq=*N7RTkn2f;w-^oRdIAcGRg91Ff8=Oad*B)zh95!oV%l-} zY7B<5=-OpdZk_UfQlYlXom-Un%70`o|B9@=DDzWp8_j>d_sDYhp_1{H|MOYC{%3ps zFJ}4tNBLce`6d3eY@5-l|Hxx`UWg6g1&u9ulxEAmIS?*zkvxT$M+XKBh`kUfl;5A zw%r)M`hKYIV;#^6D?on(D3$12{8HEeJK+#${02bdQ_R@tci%YqtF0kWADTdYtF&lr zwn7(ZE~5PXA(%&f`x=Fy9#*EYIR}j})1`(EHp4M^2vZQ2*Du`5m;Wtnmc!>N>ia>^ zIb`pZE_7k}%k~JAN^~YHgVnGW))}a-{nQAusRzwtsYPuZhnvs|+P``RxYkE6`a)y@ zP8&gI#8uE5d;^oGf7+wb5$On@t=Qt76M z{|wGU0*YNHie>jr`yz^bg;77KPj-yys%vfO`MUxNkw-Y$eQnPZNc-kAXr0==m8xsq zU4#aRBZC;*eNN;Fpl6}&ldGx;1iTDb2y!J*voGawnLof z2IfVH+R~V(An3bUYJcSu#c-{uwh%|HE3*yzI?eq7=z*Qk1oco(SxE4kVE0A)G|C#d z=I~9Tn+LW?*AI4Ex$2YHkHZLPo!o+}pfjQuPQW2p1BFTrj!(eu$NmTbTOEFib0ox9 z^XVFIyY0Ajjnj^hHlwJIVq~}36U7l5ty$Z53SCDIf9>~Sho2oMPF?3{q0)z=-B#Ef z+HGji3#GbUuiw#Eja{jwm4F(DICC(aI|&(Sm;@O z7dk-Cfaw;UN4wx0+=p=}=bVobe*iSk?NARhO&aLX2GAMS2`AtZ=sfC&d!X~oM7le0 z8?HkioQI>Z8(Lurltp~sKbz|2r~k1o)uxN%)ycMMs@XD~Dc}0ZO!-^3Oof$y{cD$c zn=K!!+*qA@oNTF1dey13{P@4DO4eoSp7&qbqxlh+G<$0@Ae)7C- zmHvaOOyU1sCEX_9ua*tUI_(G)bviA)MSh)P5TtIBo5^bb)Z{A0y2?M5ru2KLD^k+` z9=mQo(rdNGJpY+q2{#4O5+|p`YFn?+W3qPrn*qL^*(T$9c HFDw5aS@PO* literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..6be8c4449c0173ee4defd8d323b516b3c0ec39ae GIT binary patch literal 1658 zcmV-=28H>FP)Tt#!4w)V8+O)>zXRqO7q=HrdUMAD(mF({tyXd(OS*dK0pL7`SKd z%yXXk&&)H=%sgjCyI8<^*n)Gg8PCr0H)0muLY>ttoxn1V;xPV!C-DRx!J(FQ1v6vR z-Hcb_<+ubd%Dcn+Q?I^m-1xl>b@uj9SKur@{q*Bj3Ear{Eqgv(4|_!Y1jug7)xo#E5*TWS!N z8UZ)p%8ELR_zJ#{f7Mo>InlG5L@zIh9^a5Dx{Q19a7}qzg#p|pmfRF}VQ&K+U8$VW zdqqzVL%*kX<0kwDPhq7(c0aA)O-&RQ1b#}4$fCTb1o5?Skyu)aLQdjZgAPm{FBU`d zKI5+xchyz6fXk&xcwJoqKT1?y5yPwuZxB7)rX?Sh0QhP`-bd?H+)<)TS><_rr=-p} z>A2=oAdjmOGOwws&>z;j694@QUr6M4@D0rrJt3CD{nnPn!`7C?BU#>0@n8eFd35o% zME>7~Rh+|r3^MnslJb`&%I4F*#dNv`Z^kw;VkU`=(j)RDE*Mt%HHnH3Rg}LrQT`Nu zB5Xo!tJ?zRgy;9y5}j@xCZLP$iToc{)Hzm?KQETRjbcro6y}7^Z^7GzhnT_=K3qrO zO$M2JXGQr-RWEfb!c)5e@5#z9sPD%1F)JFk9q+~-;d!Q}YcU;B&u7teh=wtYkI1~JXup_Nt z29HWR3q3)==URH#oS2{U+3)yi+_L+cl z@P4srD;n+H3@6}}aBugBp?tcdD}0Zu@oUuv`t}(-u71OMVv}?;ek?95dX+UMkImvd z;!?aqI8Jqs=N6k1P{aZJUKpo8;xEDxIix*zxFZbc7O~o#ix=QRaT(L(u(XK#tBl|{ zSQVaMe(T%c{`L)B{!}>c3C@ci%%@qSH?j&3jJ1YVpleO}(;3}KuzE(}Y$srS1gsOF zeRuOr!uk|gCt%tNOdB23_vNRGbpocXz_hVG0<05ocH?aK1a+ke=;50pF6d%$H`n%P zIe|N~-#gSlGH)HfGQ1-M`a(ZnKyBC3`SA(42GDF6mnXDl)Sc$@e+25aNC_qzBlNKd-O-d zF>{$Rb(HIgd%Ok14?|M~v`z8{@$KyQzD)l23T1kIM`%wz)1Y%SjDUl98P3OZ@ud+I z9)?vBp1W7QaN0Wx&$k(D*Z-co*5U+?B!q2HZA`8zl%H39C3St`9aRC^Cp|M@b6z^G zA)kt0ugoQMdbGc`uUZQ)A7w5+QFwmZpdrm8^^U6d9uOh$dHG)+qEm57CEuBMZWi%@ zA&QhCRp;mka>|g}uMGQ$s@60v-VA-sXdYkF9&Ji;ihyA<>TL2>Q;of`M#Va4+Q_z- z!I260e=0ByS$Uk8Bmr&q=%fgExGn)b)t|>SoujGpO&d8bDR<*zbqQF;^YIC3pS^5L zU52IvG?ib5CqvXQFJk#M`(eMW~+*C~}L +#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. }