Class MApplication.
--HG-- branch : feature
This commit is contained in:
parent
4cecde8941
commit
9228e417b2
|
@ -27,13 +27,35 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "tmainwindow.h"
|
#include "tmainwindow.h"
|
||||||
#include <QApplication>
|
#include "mapplication.h"
|
||||||
|
|
||||||
|
#include <QMessageBox> // For QT_REQUIRE_VERSION
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
Q_INIT_RESOURCE(icon);
|
||||||
TMainWindow w;
|
|
||||||
w.show();
|
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
207
src/app/tape/mapplication.cpp
Normal file
207
src/app/tape/mapplication.cpp
Normal file
|
@ -0,0 +1,207 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file mapplication.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "mapplication.h"
|
||||||
|
#include "version.h"
|
||||||
|
#include "tmainwindow.h"
|
||||||
|
|
||||||
|
#include <QFileOpenEvent>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
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<MApplication *>(QCoreApplication::instance()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool MApplication::IsTheOnly() const
|
||||||
|
{
|
||||||
|
return (localServer != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
TMainWindow *MApplication::MainWindow()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
if (mainWindows.isEmpty())
|
||||||
|
{
|
||||||
|
NewMainWindow();
|
||||||
|
}
|
||||||
|
return mainWindows[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QList<TMainWindow *> MApplication::MainWindows()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
QList<TMainWindow*> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
70
src/app/tape/mapplication.h
Normal file
70
src/app/tape/mapplication.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file mapplication.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef MAPPLICATION_H
|
||||||
|
#define MAPPLICATION_H
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
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<TMainWindow*> 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<QPointer<TMainWindow> > mainWindows;
|
||||||
|
QLocalServer *localServer;
|
||||||
|
|
||||||
|
void Clean();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAPPLICATION_H
|
5
src/app/tape/share/resources/icon.qrc
Normal file
5
src/app/tape/share/resources/icon.qrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>icon/64x64/logo.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
BIN
src/app/tape/share/resources/icon/64x64/logo.ico
Normal file
BIN
src/app/tape/share/resources/icon/64x64/logo.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
src/app/tape/share/resources/icon/64x64/logo.png
Normal file
BIN
src/app/tape/share/resources/icon/64x64/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
34
src/app/tape/share/resources/tape.rc
Normal file
34
src/app/tape/share/resources/tape.rc
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
IDI_ICON1 ICON DISCARDABLE "icon/64x64/logo.ico"
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#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
|
|
@ -4,11 +4,13 @@
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/main.cpp \
|
$$PWD/main.cpp \
|
||||||
$$PWD/tmainwindow.cpp \
|
$$PWD/tmainwindow.cpp \
|
||||||
$$PWD/stable.cpp
|
$$PWD/stable.cpp \
|
||||||
|
$$PWD/mapplication.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/tmainwindow.h \
|
$$PWD/tmainwindow.h \
|
||||||
$$PWD/stable.h
|
$$PWD/stable.h \
|
||||||
|
$$PWD/mapplication.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/tmainwindow.ui
|
$$PWD/tmainwindow.ui
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
# File with common stuff for whole project
|
# File with common stuff for whole project
|
||||||
include(../../../common.pri)
|
include(../../../common.pri)
|
||||||
|
|
||||||
QT += core gui widgets
|
QT += core gui widgets network
|
||||||
|
|
||||||
# Name of binary file
|
# Name of binary file
|
||||||
TARGET = tape
|
TARGET = tape
|
||||||
|
@ -43,6 +43,11 @@ UI_DIR = uic
|
||||||
# Suport subdirectories. Just better project code tree.
|
# Suport subdirectories. Just better project code tree.
|
||||||
include(tape.pri)
|
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.
|
# Set using ccache. Function enable_ccache() defined in common.pri.
|
||||||
macx {
|
macx {
|
||||||
CONFIG(debug, debug|release){
|
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{
|
}else{
|
||||||
# Release mode
|
# Release mode
|
||||||
DEFINES += V_NO_ASSERT
|
DEFINES += V_NO_ASSERT
|
||||||
|
@ -113,34 +114,29 @@ CONFIG(debug, debug|release){
|
||||||
QMAKE_LFLAGS_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
|
noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols
|
||||||
# do nothing
|
# do nothing
|
||||||
} else {
|
} else {
|
||||||
|
@ -165,3 +161,6 @@ noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
share/resources/icon.qrc
|
||||||
|
|
|
@ -42,3 +42,9 @@ TMainWindow::~TMainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TMainWindow::LoadFile(const QString &path)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,9 @@ public:
|
||||||
explicit TMainWindow(QWidget *parent = 0);
|
explicit TMainWindow(QWidget *parent = 0);
|
||||||
virtual ~TMainWindow() Q_DECL_OVERRIDE;
|
virtual ~TMainWindow() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void LoadFile(const QString &path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(TMainWindow)
|
Q_DISABLE_COPY(TMainWindow)
|
||||||
Ui::TMainWindow *ui;
|
Ui::TMainWindow *ui;
|
||||||
|
|
38
src/app/tape/version.h
Normal file
38
src/app/tape/version.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file version.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#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
|
72
src/libs/vmisc/projectversion.cpp
Normal file
72
src/libs/vmisc/projectversion.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file projectversion.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "projectversion.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QSysInfo>
|
||||||
|
|
||||||
|
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("<unknown compiler>");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString buildCompatibilityString()
|
||||||
|
{
|
||||||
|
return QCoreApplication::tr("Based on Qt %1 (%2, %3 bit)").arg(QLatin1String(qVersion()), compilerString(),
|
||||||
|
QString::number(QSysInfo::WordSize));
|
||||||
|
}
|
67
src/libs/vmisc/projectversion.h
Normal file
67
src/libs/vmisc/projectversion.h
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file projectversion.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @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
|
||||||
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#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
|
|
@ -8,7 +8,8 @@ SOURCES += \
|
||||||
$$PWD/backport/qcommandlineoption.cpp \
|
$$PWD/backport/qcommandlineoption.cpp \
|
||||||
$$PWD/backport/qcommandlineparser.cpp \
|
$$PWD/backport/qcommandlineparser.cpp \
|
||||||
$$PWD/vsettings.cpp \
|
$$PWD/vsettings.cpp \
|
||||||
$$PWD/vabstractapplication.cpp
|
$$PWD/vabstractapplication.cpp \
|
||||||
|
projectversion.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/stable.h \
|
$$PWD/stable.h \
|
||||||
|
@ -19,4 +20,5 @@ HEADERS += \
|
||||||
$$PWD/backport/qcommandlineoption.h \
|
$$PWD/backport/qcommandlineoption.h \
|
||||||
$$PWD/backport/qcommandlineparser.h \
|
$$PWD/backport/qcommandlineparser.h \
|
||||||
$$PWD/vsettings.h \
|
$$PWD/vsettings.h \
|
||||||
$$PWD/vabstractapplication.h
|
$$PWD/vabstractapplication.h \
|
||||||
|
projectversion.h
|
||||||
|
|
|
@ -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{
|
}else{
|
||||||
# Release mode
|
# Release mode
|
||||||
DEFINES += V_NO_ASSERT
|
DEFINES += V_NO_ASSERT
|
||||||
|
@ -100,4 +104,30 @@ CONFIG(debug, debug|release){
|
||||||
QMAKE_LFLAGS_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.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user