diff --git a/src/blackgui/components/dbliverycolorsearch.cpp b/src/blackgui/components/dbliverycolorsearch.cpp index b68c70709..7369737f8 100644 --- a/src/blackgui/components/dbliverycolorsearch.cpp +++ b/src/blackgui/components/dbliverycolorsearch.cpp @@ -21,33 +21,31 @@ namespace BlackGui namespace Components { CDbLiveryColorSearch::CDbLiveryColorSearch(QWidget *parent) : - QDialog(parent), + QFrame(parent), ui(new Ui::CDbLiveryColorSearch) { ui->setupUi(this); - connect(this, &CDbLiveryColorSearch::accepted, this, &CDbLiveryColorSearch::ps_onAccepted); + this->setFocusProxy(ui->comp_FuselageSelector); } CDbLiveryColorSearch::~CDbLiveryColorSearch() { } - BlackMisc::Aviation::CLivery CDbLiveryColorSearch::getLivery() const + 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); + return liveries.findClosestColorLiveryOrDefault(fuselage, tail); + } + + void CDbLiveryColorSearch::presetColorLivery(const CLivery &livery) + { + if (livery.isColorLivery()) + { + ui->comp_FuselageSelector->setColor(livery.getColorFuselage()); + ui->comp_TailSelector->setColor(livery.getColorTail()); + } } } // ns } // ns diff --git a/src/blackgui/components/dbliverycolorsearch.h b/src/blackgui/components/dbliverycolorsearch.h index f43226396..de24e9fbe 100644 --- a/src/blackgui/components/dbliverycolorsearch.h +++ b/src/blackgui/components/dbliverycolorsearch.h @@ -13,7 +13,7 @@ #define BLACKGUI_COMPONENTS_DBLIVERYCOLORSEARCH_H #include "blackmisc/aviation/livery.h" -#include +#include #include namespace Ui { class CDbLiveryColorSearch; } @@ -22,9 +22,9 @@ namespace BlackGui namespace Components { /*! - * Search for best color livery + * Search for best matching color livery */ - class CDbLiveryColorSearch : public QDialog + class CDbLiveryColorSearch : public QFrame { Q_OBJECT @@ -38,11 +38,8 @@ namespace BlackGui //! 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 + //! Preset colors + void presetColorLivery(const BlackMisc::Aviation::CLivery &livery); private: QScopedPointer ui; diff --git a/src/blackgui/components/dbliverycolorsearch.ui b/src/blackgui/components/dbliverycolorsearch.ui index e4ea51590..c7f311d8d 100644 --- a/src/blackgui/components/dbliverycolorsearch.ui +++ b/src/blackgui/components/dbliverycolorsearch.ui @@ -1,49 +1,19 @@ CDbLiveryColorSearch - + 0 0 - 237 - 80 + 171 + 52 Search color livery - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - @@ -58,6 +28,26 @@ + + + + + 100 + 0 + + + + + + + + + 100 + 0 + + + + @@ -69,38 +59,5 @@ - - - bb_LiveryColorSearch - accepted() - CDbLiveryColorSearch - accept() - - - 248 - 254 - - - 157 - 274 - - - - - bb_LiveryColorSearch - rejected() - CDbLiveryColorSearch - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/blackgui/components/dbliverycolorsearchdialog.cpp b/src/blackgui/components/dbliverycolorsearchdialog.cpp new file mode 100644 index 000000000..c1d488c5f --- /dev/null +++ b/src/blackgui/components/dbliverycolorsearchdialog.cpp @@ -0,0 +1,44 @@ +/* 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 "dbliverycolorsearchdialog.h" +#include "blackgui/guiapplication.h" +#include "blackcore/webdataservices.h" +#include "blackmisc/aviation/liverylist.h" +#include "ui_dbliverycolorsearchdialog.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; + +namespace BlackGui +{ + namespace Components + { + CDbLiveryColorSearchDialog::CDbLiveryColorSearchDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CDbLiveryColorSearchDialog) + { + ui->setupUi(this); + connect(this, &CDbLiveryColorSearchDialog::accepted, this, &CDbLiveryColorSearchDialog::ps_onAccepted); + } + + CDbLiveryColorSearchDialog::~CDbLiveryColorSearchDialog() + { } + + const CLivery &CDbLiveryColorSearchDialog::getLivery() const + { + return this->m_foundLivery; + } + + void CDbLiveryColorSearchDialog::ps_onAccepted() + { + this->m_foundLivery = ui->comp_LiverySearch->getLivery(); + } + } // ns +} // ns diff --git a/src/blackgui/components/dbliverycolorsearchdialog.h b/src/blackgui/components/dbliverycolorsearchdialog.h new file mode 100644 index 000000000..1f3792659 --- /dev/null +++ b/src/blackgui/components/dbliverycolorsearchdialog.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_DBLIVERYCOLORSEARCHDIALOG_H +#define BLACKGUI_COMPONENTS_DBLIVERYCOLORSEARCHDIALOG_H + +#include "blackmisc/aviation/livery.h" +#include +#include + +namespace Ui { class CDbLiveryColorSearchDialog; } +namespace BlackGui +{ + namespace Components + { + /*! + * Search for best matching color livery + */ + class CDbLiveryColorSearchDialog : public QDialog + { + Q_OBJECT + + public: + //! Constructor + explicit CDbLiveryColorSearchDialog(QWidget *parent = nullptr); + + //! Destructor + ~CDbLiveryColorSearchDialog(); + + //! Found livery if any, otherwise default + const BlackMisc::Aviation::CLivery &getLivery() const; + + private: + //! Dialog has been accepted + void ps_onAccepted(); + + BlackMisc::Aviation::CLivery m_foundLivery; //!< last livery found + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dbliverycolorsearchdialog.ui b/src/blackgui/components/dbliverycolorsearchdialog.ui new file mode 100644 index 000000000..9663a715b --- /dev/null +++ b/src/blackgui/components/dbliverycolorsearchdialog.ui @@ -0,0 +1,82 @@ + + + CDbLiveryColorSearchDialog + + + + 0 + 0 + 237 + 80 + + + + Search color livery + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + BlackGui::Components::CDbLiveryColorSearch + QFrame +
blackgui/components/dbliverycolorsearch.h
+ 1 +
+
+ + + + bb_LiveryColorSearch + accepted() + CDbLiveryColorSearchDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_LiveryColorSearch + rejected() + CDbLiveryColorSearchDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +