From c5f60bc582a830608a657e9ccb8f0bd633969e9c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 25 Aug 2016 00:27:41 +0200 Subject: [PATCH] refs #742, dialog to search for color livery --- .../components/dbliverycolorsearch.cpp | 53 +++++++++ src/blackgui/components/dbliverycolorsearch.h | 53 +++++++++ .../components/dbliverycolorsearch.ui | 106 ++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 src/blackgui/components/dbliverycolorsearch.cpp create mode 100644 src/blackgui/components/dbliverycolorsearch.h create mode 100644 src/blackgui/components/dbliverycolorsearch.ui diff --git a/src/blackgui/components/dbliverycolorsearch.cpp b/src/blackgui/components/dbliverycolorsearch.cpp new file mode 100644 index 000000000..b68c70709 --- /dev/null +++ b/src/blackgui/components/dbliverycolorsearch.cpp @@ -0,0 +1,53 @@ +/* Copyright (C) 2015 + * 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 "dbliverycolorsearch.h" +#include "blackgui/guiapplication.h" +#include "blackcore/webdataservices.h" +#include "blackmisc/aviation/liverylist.h" +#include "ui_dbliverycolorsearch.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; + +namespace BlackGui +{ + namespace Components + { + CDbLiveryColorSearch::CDbLiveryColorSearch(QWidget *parent) : + QDialog(parent), + ui(new Ui::CDbLiveryColorSearch) + { + ui->setupUi(this); + connect(this, &CDbLiveryColorSearch::accepted, this, &CDbLiveryColorSearch::ps_onAccepted); + } + + CDbLiveryColorSearch::~CDbLiveryColorSearch() + { } + + BlackMisc::Aviation::CLivery CDbLiveryColorSearch::getLivery() const + { + return this->m_foundLivery; + } + + void CDbLiveryColorSearch::ps_onAccepted() + { + if (!sGui || !sGui->hasWebDataServices()) + { + this->m_foundLivery = CLivery(); + return; + } + + const CRgbColor fuselage = ui->comp_FuselageSelector->getColor(); + const CRgbColor tail = ui->comp_TailSelector->getColor(); + const CLiveryList liveries(sGui->getWebDataServices()->getLiveries()); + this->m_foundLivery = liveries.findClosestColorLiveryOrDefault(fuselage, tail); + } + } // ns +} // ns diff --git a/src/blackgui/components/dbliverycolorsearch.h b/src/blackgui/components/dbliverycolorsearch.h new file mode 100644 index 000000000..f43226396 --- /dev/null +++ b/src/blackgui/components/dbliverycolorsearch.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2016 + * 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_DBLIVERYCOLORSEARCH_H +#define BLACKGUI_COMPONENTS_DBLIVERYCOLORSEARCH_H + +#include "blackmisc/aviation/livery.h" +#include +#include + +namespace Ui { class CDbLiveryColorSearch; } +namespace BlackGui +{ + namespace Components + { + /*! + * Search for best color livery + */ + class CDbLiveryColorSearch : public QDialog + { + Q_OBJECT + + public: + //! Constructor + explicit CDbLiveryColorSearch(QWidget *parent = nullptr); + + //! Destructor + ~CDbLiveryColorSearch(); + + //! Found livery if any, otherwise default + BlackMisc::Aviation::CLivery getLivery() const; + + private: + //! Dialog has been accepted + void ps_onAccepted(); + + BlackMisc::Aviation::CLivery m_foundLivery; //!< lat livery found + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dbliverycolorsearch.ui b/src/blackgui/components/dbliverycolorsearch.ui new file mode 100644 index 000000000..e4ea51590 --- /dev/null +++ b/src/blackgui/components/dbliverycolorsearch.ui @@ -0,0 +1,106 @@ + + + CDbLiveryColorSearch + + + + 0 + 0 + 237 + 80 + + + + Search color livery + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Fuselage: + + + + + + + Tail: + + + + + + + + BlackGui::Components::CColorSelector + QFrame +
blackgui/components/colorselector.h
+ 1 +
+
+ + + + bb_LiveryColorSearch + accepted() + CDbLiveryColorSearch + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_LiveryColorSearch + rejected() + CDbLiveryColorSearch + reject() + + + 316 + 260 + + + 286 + 274 + + + + +