refs #873, UI improvements

* allow to set inner message frame factor (width/height)
* fixed aircrft selector to keep selection
This commit is contained in:
Klaus Basan
2017-02-03 03:19:11 +01:00
committed by Mathew Sutcliffe
parent ec23863d53
commit 3afead9f71
5 changed files with 48 additions and 18 deletions

View File

@@ -20,6 +20,7 @@
#include <QStringList> #include <QStringList>
#include <QWidget> #include <QWidget>
#include <QtGlobal> #include <QtGlobal>
#include <QStringBuilder>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
@@ -53,6 +54,11 @@ namespace BlackGui
return m_aircraft[index].getCallsign(); return m_aircraft[index].getCallsign();
} }
void CRemoteAircraftSelector::indicatePartsEnabled(bool indicate)
{
m_showPartsEnabled = indicate;
}
void CRemoteAircraftSelector::showEvent(QShowEvent *event) void CRemoteAircraftSelector::showEvent(QShowEvent *event)
{ {
// force new combobox when visible // force new combobox when visible
@@ -80,11 +86,11 @@ namespace BlackGui
void CRemoteAircraftSelector::fillComboBox() void CRemoteAircraftSelector::fillComboBox()
{ {
if (!this->isVisible()) { return; } // for performance reasons if (!this->isVisible()) { return; } // for performance reasons
const CCallsign currentSelection(this->getSelectedCallsign());
m_aircraft = sGui->getIContextNetwork()->getAircraftInRange(); m_aircraft = sGui->getIContextNetwork()->getAircraftInRange();
ui->cb_RemoteAircraftSelector->clear(); ui->cb_RemoteAircraftSelector->clear();
if (m_aircraft.isEmpty()) { return; } if (m_aircraft.isEmpty()) { return; }
CCallsign currentSelection(this->getSelectedCallsign());
QStringList items; QStringList items;
for (const CSimulatedAircraft &aircraft : m_aircraft) for (const CSimulatedAircraft &aircraft : m_aircraft)
{ {
@@ -92,14 +98,20 @@ namespace BlackGui
QString i(aircraft.getCallsign().toQString()); QString i(aircraft.getCallsign().toQString());
if (aircraft.hasAircraftDesignator()) if (aircraft.hasAircraftDesignator())
{ {
i += " ("; i += QLatin1Literal(" (") %
i += aircraft.getAircraftIcaoCode().toQString(false); aircraft.getAircraftIcaoCode().toQString(false) %
i += ")"; QLatin1Literal(")");
} }
if (aircraft.hasValidRealName()) if (aircraft.hasValidRealName())
{ {
i += " - "; i += QLatin1Literal(" - ") % aircraft.getPilotRealName();
i += aircraft.getPilotRealName(); }
if (m_showPartsEnabled)
{
if (aircraft.isPartsSynchronized())
{
i += " [parts]";
}
} }
items.append(i); items.append(i);
} }

View File

@@ -25,7 +25,6 @@ class QWidget;
namespace BlackMisc { namespace Simulation { class CSimulatedAircraft; } } namespace BlackMisc { namespace Simulation { class CSimulatedAircraft; } }
namespace Ui { class CRemoteAircraftSelector; } namespace Ui { class CRemoteAircraftSelector; }
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Components
@@ -40,11 +39,14 @@ namespace BlackGui
explicit CRemoteAircraftSelector(QWidget *parent = nullptr); explicit CRemoteAircraftSelector(QWidget *parent = nullptr);
//! Destructor //! Destructor
~CRemoteAircraftSelector(); virtual ~CRemoteAircraftSelector();
//! Selected callsign //! Selected callsign
BlackMisc::Aviation::CCallsign getSelectedCallsign() const; BlackMisc::Aviation::CCallsign getSelectedCallsign() const;
//! Indicate if aircraft parts enabled aircraft
void indicatePartsEnabled(bool indicate);
protected: protected:
//! \copydoc QWidget::showEvent //! \copydoc QWidget::showEvent
virtual void showEvent(QShowEvent *event) override; virtual void showEvent(QShowEvent *event) override;
@@ -59,6 +61,7 @@ namespace BlackGui
private: private:
QScopedPointer<Ui::CRemoteAircraftSelector> ui; QScopedPointer<Ui::CRemoteAircraftSelector> ui;
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft; BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
bool m_showPartsEnabled = false;
//! Set combobox items //! Set combobox items
void fillComboBox(); void fillComboBox();

View File

@@ -100,8 +100,10 @@ namespace BlackGui
{ {
int w = this->width(); int w = this->width();
int h = this->height(); int h = this->height();
int wInner = 0.7 * w; int wInner = this->m_widthFactor * w;
int hInner = 0.7 * h; int hInner = this->m_heightFactor * h;
if (wInner > this->maximumWidth()) wInner = this->maximumWidth();
if (hInner > this->maximumHeight()) hInner = this->maximumHeight();
return QSize(wInner, hInner); return QSize(wInner, hInner);
} }

View File

@@ -47,7 +47,7 @@ namespace BlackGui
explicit COverlayMessagesFrame(QWidget *parent = nullptr); explicit COverlayMessagesFrame(QWidget *parent = nullptr);
//! Destructor //! Destructor
~COverlayMessagesFrame(); virtual ~COverlayMessagesFrame();
//! Show the inner frame //! Show the inner frame
void showStatusMessagesFrame(); void showStatusMessagesFrame();
@@ -55,13 +55,17 @@ namespace BlackGui
//! Hide the inner frame //! Hide the inner frame
void hideStatusMessagesFrame(); void hideStatusMessagesFrame();
//! Inner frame factors 0..1
//! \remarks can also be restricted by maximumHeight() / maximumWidth()
void setInnerFrameFactor(double xFactor, double yFactor);
//! \copydoc COverlayMessages::showOverlayMessagesWithConfirmation //! \copydoc COverlayMessages::showOverlayMessagesWithConfirmation
void showOverlayMessagesWithConfirmation( void showOverlayMessagesWithConfirmation(
const BlackMisc::CStatusMessageList &messages, const BlackMisc::CStatusMessageList &messages,
const QString &confirmationMessage, const QString &confirmationMessage,
std::function<void()> okLambda, std::function<void()> okLambda,
int defaultButton = QMessageBox::Cancel, int defaultButton = QMessageBox::Cancel,
int timeOutMs = -1 int timeOutMs = -1
); );
public slots: public slots:
@@ -92,6 +96,9 @@ namespace BlackGui
//! Init the inner frame (if not yet initialized) //! Init the inner frame (if not yet initialized)
void initInnerFrame(); void initInnerFrame();
double m_widthFactor = 0.7; //!< inner frame x factor
double m_heightFactor = 0.7; //!< inner frame x factor
}; };
} // ns } // ns

View File

@@ -111,10 +111,11 @@ BlackGui--CInfoArea {
background-image: url(:/textures/icons/textures/texture-inner.jpg); background-image: url(:/textures/icons/textures/texture-inner.jpg);
} }
/* Overlay messages */
BlackGui--COverlayMessages { BlackGui--COverlayMessages {
background: black; /* background is background color here */ background: transparent; /* background is background color here */
background-image: url(:/textures/icons/textures/texture-inner.jpg); background-image: url(:/textures/icons/textures/texture-inner.jpg);
border: 2px solid yellow; border: 2px solid blue;
border-radius: 10px; border-radius: 10px;
} }
@@ -273,9 +274,14 @@ QGroupBox {
} }
QGroupBox::title { QGroupBox::title {
top: 2px;
left: 5px;
subcontrol-origin: margin; subcontrol-origin: margin;
subcontrol-position: middle center; /* position at the top center */ subcontrol-position: middle left; /* position at the top center */
padding: 0 5px; padding: 0px 10px;
background-color: darkblue;
border: 1px solid green;
border-radius: 5px;
} }
QToolBox::tab { QToolBox::tab {