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

View File

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

View File

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

View File

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

View File

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