From 45f0cea08363c754371b499d44d1d9f45024f990 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 10 Apr 2017 16:41:14 +0200 Subject: [PATCH] refs #933, UI for MCX setup --- .../components/datasettingscomponent.ui | 98 ++++++++++++------- .../modelconverterxsetupcomponent.cpp | 56 +++++++++++ .../modelconverterxsetupcomponent.h | 50 ++++++++++ .../modelconverterxsetupcomponent.ui | 50 ++++++++++ 4 files changed, 220 insertions(+), 34 deletions(-) create mode 100644 src/blackgui/components/modelconverterxsetupcomponent.cpp create mode 100644 src/blackgui/components/modelconverterxsetupcomponent.h create mode 100644 src/blackgui/components/modelconverterxsetupcomponent.ui diff --git a/src/blackgui/components/datasettingscomponent.ui b/src/blackgui/components/datasettingscomponent.ui index 0d6064c7a..46f4ef0fe 100644 --- a/src/blackgui/components/datasettingscomponent.ui +++ b/src/blackgui/components/datasettingscomponent.ui @@ -32,7 +32,7 @@ 4 - + @@ -76,11 +76,11 @@ - + - swift DB + Models - + 4 @@ -93,26 +93,13 @@ 4 - - - - Qt::Vertical + + + + QFrame::StyledPanel - - - 20 - 40 - - - - - - - - - 0 - 175 - + + QFrame::Raised @@ -169,12 +156,12 @@ - - + + - Models + swift DB - + 4 @@ -187,20 +174,33 @@ 4 - - - - QFrame::StyledPanel + + + + Qt::Vertical - - QFrame::Raised + + + 20 + 40 + + + + + + + + + 0 + 175 + - + Simulator @@ -231,6 +231,30 @@ + + + + External tools + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + + @@ -264,6 +288,12 @@
blackgui/components/settingsmodelcomponent.h
1 + + BlackGui::Components::CModelConverterXSetupComponent + QFrame +
blackgui/components/modelconverterxsetupcomponent.h
+ 1 +
diff --git a/src/blackgui/components/modelconverterxsetupcomponent.cpp b/src/blackgui/components/modelconverterxsetupcomponent.cpp new file mode 100644 index 000000000..055cd38e0 --- /dev/null +++ b/src/blackgui/components/modelconverterxsetupcomponent.cpp @@ -0,0 +1,56 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "modelconverterxsetupcomponent.h" +#include "ui_modelconverterxsetupcomponent.h" +#include "blackmisc/statusmessage.h" +#include "blackmisc/logmessage.h" +#include + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + CModelConverterXSetupComponent::CModelConverterXSetupComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CModelConverterXSetupComponent) + { + ui->setupUi(this); + connect(ui->pb_DirBrowser, &QPushButton::clicked, this, &CModelConverterXSetupComponent::selectBinary); + connect(ui->le_McxBinary, &QLineEdit::returnPressed, this, &CModelConverterXSetupComponent::saveSettings); + ui->le_McxBinary->setText(m_setting.get()); + } + + CModelConverterXSetupComponent::~CModelConverterXSetupComponent() + { } + + void CModelConverterXSetupComponent::selectBinary() + { + QString defaultValue = m_setting.get(); + if (defaultValue.isEmpty()) + { + defaultValue = QDir::currentPath(); + } + const QString fileName = QFileDialog::getOpenFileName(nullptr, + tr("ModelConverterX binary"), defaultValue, + "*.exe"); + ui->le_McxBinary->setText(fileName); + this->saveSettings(); + } + + void CModelConverterXSetupComponent::saveSettings() + { + const QString t = ui->le_McxBinary->text(); + const CStatusMessage msg = m_setting.setAndSave(t); + CLogMessage::preformatted(msg); + } + } // ns +} // ns diff --git a/src/blackgui/components/modelconverterxsetupcomponent.h b/src/blackgui/components/modelconverterxsetupcomponent.h new file mode 100644 index 000000000..c4546bb3a --- /dev/null +++ b/src/blackgui/components/modelconverterxsetupcomponent.h @@ -0,0 +1,50 @@ +/* Copyright (C) 2017 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_MODELCONVERTERXSETUPCOMPONENT_H +#define BLACKGUI_COMPONENTS_MODELCONVERTERXSETUPCOMPONENT_H + +#include "blackmisc/simulation/modelconverterx.h" +#include + +namespace Ui { class CModelConverterXSetupComponent; } +namespace BlackGui +{ + namespace Components + { + /** + * Setup to start ModelConverterX + */ + class CModelConverterXSetupComponent : public QFrame + { + Q_OBJECT + + public: + //! Ctor + explicit CModelConverterXSetupComponent(QWidget *parent = nullptr); + + //! Dtor + virtual ~CModelConverterXSetupComponent(); + + private: + //! File dialog + void selectBinary(); + + //! Save the settings + void saveSettings(); + + QScopedPointer ui; + BlackMisc::CSetting m_setting { this }; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/modelconverterxsetupcomponent.ui b/src/blackgui/components/modelconverterxsetupcomponent.ui new file mode 100644 index 000000000..cc8a53910 --- /dev/null +++ b/src/blackgui/components/modelconverterxsetupcomponent.ui @@ -0,0 +1,50 @@ + + + CModelConverterXSetupComponent + + + + 0 + 0 + 181 + 26 + + + + ModelConverteX binary + + + + 2 + + + 2 + + + 2 + + + 2 + + + + + ModelConverterX binary + + + + + + + directory browser + + + ... + + + + + + + +