swift
dbliverycolorsearch.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include "ui_dbliverycolorsearch.h"
7 
8 #include "core/webdataservices.h"
9 #include "gui/guiapplication.h"
11 
12 using namespace swift::misc;
13 using namespace swift::misc::aviation;
14 
15 namespace swift::gui::components
16 {
17  CDbLiveryColorSearch::CDbLiveryColorSearch(QWidget *parent) : QFrame(parent), ui(new Ui::CDbLiveryColorSearch)
18  {
19  ui->setupUi(this);
20  this->setFocusProxy(ui->comp_FuselageSelector);
21  }
22 
24 
26  {
27  const CRgbColor fuselage = ui->comp_FuselageSelector->getColor();
28  const CRgbColor tail = ui->comp_TailSelector->getColor();
29  const CLiveryList liveries(sGui->getWebDataServices()->getLiveries());
30  return liveries.findClosestColorLiveryOrDefault(fuselage, tail);
31  }
32 
34  {
35  if (livery.isColorLivery())
36  {
37  ui->comp_FuselageSelector->setColor(livery.getColorFuselage());
38  ui->comp_TailSelector->setColor(livery.getColorTail());
39  }
40  }
41 } // namespace swift::gui::components
CWebDataServices * getWebDataServices() const
Get the web data services.
swift::misc::aviation::CLiveryList getLiveries() const
Liveries.
Search for best matching color livery.
void presetColorLivery(const swift::misc::aviation::CLivery &livery)
Preset colors.
swift::misc::aviation::CLivery getLivery() const
Found livery if any, otherwise default.
Value object encapsulating information about an airpot.
Definition: livery.h:29
const CRgbColor & getColorTail() const
Get tail color.
Definition: livery.h:95
bool isColorLivery() const
Color livery?
Definition: livery.cpp:180
const CRgbColor & getColorFuselage() const
Get fuselage color.
Definition: livery.h:92
Value object for a list of airports.
Definition: liverylist.h:29
CLivery findClosestColorLiveryOrDefault(const CRgbColor &fuselage, const CRgbColor &tail) const
Search for colors.
Definition: liverylist.cpp:87
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Definition: aboutdialog.cpp:13
Free functions in swift::misc.