mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #742, dialog to search for color livery
This commit is contained in:
committed by
Mathew Sutcliffe
parent
74740991a3
commit
c5f60bc582
53
src/blackgui/components/dbliverycolorsearch.cpp
Normal file
53
src/blackgui/components/dbliverycolorsearch.cpp
Normal file
@@ -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
|
||||
53
src/blackgui/components/dbliverycolorsearch.h
Normal file
53
src/blackgui/components/dbliverycolorsearch.h
Normal file
@@ -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 <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
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::CDbLiveryColorSearch> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
106
src/blackgui/components/dbliverycolorsearch.ui
Normal file
106
src/blackgui/components/dbliverycolorsearch.ui
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDbLiveryColorSearch</class>
|
||||
<widget class="QDialog" name="CDbLiveryColorSearch">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>237</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Search color livery</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QDialogButtonBox" name="bb_LiveryColorSearch">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="BlackGui::Components::CColorSelector" name="comp_FuselageSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="BlackGui::Components::CColorSelector" name="comp_TailSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Fuselage">
|
||||
<property name="text">
|
||||
<string>Fuselage:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Tail">
|
||||
<property name="text">
|
||||
<string>Tail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CColorSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/colorselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_LiveryColorSearch</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CDbLiveryColorSearch</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bb_LiveryColorSearch</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CDbLiveryColorSearch</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user