From 05acaaa8fc5392d97c5226b8e459cb224a09f55f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 18 Aug 2015 13:36:17 +0300 Subject: [PATCH] Run Tape for creating measurement file. --HG-- branch : feature --- src/app/valentina/core/vapplication.cpp | 53 +++++++++++++++++++++++++ src/app/valentina/core/vapplication.h | 1 + src/app/valentina/mainwindow.cpp | 13 ++++-- src/app/valentina/mainwindow.h | 1 + src/app/valentina/mainwindow.ui | 9 +++++ 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 0e89e38b1..ed4725db3 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -308,6 +308,59 @@ QString VApplication::translationsPath() const #endif } +//--------------------------------------------------------------------------------------------------------------------- +QString VApplication::TapeFilePath() const +{ + const QString tape = QStringLiteral("tape"); +#ifdef Q_OS_WIN + QFileInfo tapeFile(QApplication::applicationDirPath() + "/" + tape + ".exe"); + if (tapeFile.exists()) + { + return fileBundle.absoluteFilePath(); + } + else + { + return QApplication::applicationDirPath() + "/../../tape/bin/" + tape + ".exe"; + } +#elif defined(Q_OS_MAC) + QFileInfo tapeFile(QApplication::applicationDirPath() + "/" + tape); + if (tapeFile.exists()) + { + return tapeFile.absoluteFilePath(); + } + else + { + QFileInfo file(QApplication::applicationDirPath() + "/../../tape/bin/" + tape); + if (file.exists()) + { + return file.absoluteFilePath(); + } + else + { + return tape; + } + } +#else // Unix + QFileInfo file(QApplication::applicationDirPath() + "/../../tape/bin/" + tape); + if (file.exists()) + { + return file.absoluteFilePath(); + } + else + { + QFileInfo tapeFile(QApplication::applicationDirPath() + "/" + tape); + if (tapeFile.exists()) + { + return tapeFile.absoluteFilePath(); + } + else + { + return tape; + } + } +#endif +} + //--------------------------------------------------------------------------------------------------------------------- QString VApplication::LogDirPath() const { diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index c52a6af60..33f25950c 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -60,6 +60,7 @@ public: void InitOptions(); QString translationsPath() const; + QString TapeFilePath() const; QTimer *getAutoSaveTimer() const; void setAutoSaveTimer(QTimer *value); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index a6276cd55..30234806a 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -301,6 +301,7 @@ void MainWindow::LoadMeasurements(const QString &path) delete m; return; } + helpLabel->setText(tr("Measurements loaded")); } //--------------------------------------------------------------------------------------------------------------------- @@ -1001,6 +1002,12 @@ void MainWindow::LoadStandard() } } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::CreateMeasurements() +{ + QProcess::startDetached(qApp->TapeFilePath()); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolBarOption enable option toolbar. @@ -1033,9 +1040,9 @@ void MainWindow::ToolBarOption() //--------------------------------------------------------------------------------------------------------------------- QComboBox *MainWindow::SetGradationList(const QString &label, const QStringList &list) { - ui->toolBarOption->addWidget(new QLabel(label)); + ui->toolBarOption->addWidget(new QLabel(label, this)); - QComboBox *comboBox = new QComboBox; + QComboBox *comboBox = new QComboBox(this); comboBox->addItems(list); ui->toolBarOption->addWidget(comboBox); @@ -2766,7 +2773,7 @@ void MainWindow::CreateActions() connect(ui->actionShowCurveDetails, &QAction::triggered, this, &MainWindow::ActionCurveDetailsMode); connect(ui->actionLoadIndividual, &QAction::triggered, this, &MainWindow::LoadIndividual); connect(ui->actionLoadStandard, &QAction::triggered, this, &MainWindow::LoadStandard); - + connect(ui->actionCreateNew, &QAction::triggered, this, &MainWindow::CreateMeasurements); connect(ui->actionExportAs, &QAction::triggered, this, &MainWindow::ExportLayoutAs); connect(ui->actionPrintPreview, &QAction::triggered, this, &MainWindow::PrintPreviewOrigin); connect(ui->actionPrintPreviewTailed, &QAction::triggered, this, &MainWindow::PrintPreviewTiled); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 53ed0b530..2a36866dd 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -162,6 +162,7 @@ protected: private slots: void LoadIndividual(); void LoadStandard(); + void CreateMeasurements(); private: Q_DISABLE_COPY(MainWindow) /** @brief ui keeps information about user interface */ diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 8581cefc1..a2b105a24 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -1087,6 +1087,7 @@ + @@ -1872,6 +1873,14 @@ Load Standard ... + + + Create new ... + + + Create new measurements + +