mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T177, addressing some overlay messages frame issues
* use enum for buttons * removed unused declaration setInnerFrameFactor * private slots -> private
This commit is contained in:
@@ -540,7 +540,7 @@ namespace BlackGui
|
||||
|
||||
bool CDbStashComponent::showOverlayMessagesWithConfirmation(
|
||||
const CStatusMessageList &msgs, bool appendOldMessages,
|
||||
const QString &confirmation, std::function<void ()> okLambda, int defaultButton, bool onlyErrors, int timeoutMs)
|
||||
const QString &confirmation, std::function<void ()> okLambda, QMessageBox::StandardButton defaultButton, bool onlyErrors, int timeoutMs)
|
||||
{
|
||||
if (msgs.isEmpty()) { return false; }
|
||||
if (!msgs.hasErrorMessages() && onlyErrors) { return false; }
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
#include <QStringList>
|
||||
#include <functional>
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace BlackGui
|
||||
bool showOverlayMessagesWithConfirmation(
|
||||
const BlackMisc::CStatusMessageList &msgs, bool appendOldMessages,
|
||||
const QString &confirmation, std::function<void()> okLambda,
|
||||
int defaultButton, bool onlyErrors = false, int timeoutMs = -1);
|
||||
QMessageBox::StandardButton defaultButton, bool onlyErrors = false, int timeoutMs = -1);
|
||||
|
||||
//! Display message
|
||||
bool showOverlayMessage(const BlackMisc::CStatusMessage &msg, int timeoutMs = -1);
|
||||
|
||||
@@ -53,10 +53,10 @@ namespace BlackGui
|
||||
{
|
||||
this->init(w, h);
|
||||
this->showKillButton(false);
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &COverlayMessages::ps_onStyleSheetsChanged);
|
||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &COverlayMessages::ps_okClicked);
|
||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &COverlayMessages::ps_cancelClicked);
|
||||
connect(ui->tb_Kill, &QPushButton::clicked, this, &COverlayMessages::ps_killClicked);
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &COverlayMessages::onStyleSheetsChanged);
|
||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &COverlayMessages::onOkClicked);
|
||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &COverlayMessages::onCancelClicked);
|
||||
connect(ui->tb_Kill, &QPushButton::clicked, this, &COverlayMessages::onKillClicked);
|
||||
|
||||
ui->tvp_StatusMessages->setResizeMode(CStatusMessageView::ResizingAlways);
|
||||
ui->tvp_StatusMessages->setForceColumnsToMaxSize(false); // problems with multiline entries, with T138 we need multiline messages
|
||||
@@ -89,25 +89,25 @@ namespace BlackGui
|
||||
ui->lbl_Header->setText(m_header.isEmpty() ? header : m_header);
|
||||
}
|
||||
|
||||
void COverlayMessages::ps_onStyleSheetsChanged()
|
||||
void COverlayMessages::onStyleSheetsChanged()
|
||||
{
|
||||
// stlye sheet
|
||||
// stylesheet
|
||||
}
|
||||
|
||||
void COverlayMessages::ps_okClicked()
|
||||
void COverlayMessages::onOkClicked()
|
||||
{
|
||||
m_lastConfirmation = QMessageBox::Ok;
|
||||
if (m_okLambda) { m_okLambda(); }
|
||||
this->close();
|
||||
}
|
||||
|
||||
void COverlayMessages::ps_cancelClicked()
|
||||
void COverlayMessages::onCancelClicked()
|
||||
{
|
||||
m_lastConfirmation = QMessageBox::Cancel;
|
||||
this->close();
|
||||
}
|
||||
|
||||
void COverlayMessages::ps_killClicked()
|
||||
void COverlayMessages::onKillClicked()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Shutdown the application.");
|
||||
@@ -134,10 +134,10 @@ namespace BlackGui
|
||||
|
||||
bool COverlayMessages::displayTextMessage(const CTextMessage &textMessage) const
|
||||
{
|
||||
if (!sApp || sApp->isShuttingDown() || !sApp->getIContextOwnAircraft()) { return false; }
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextOwnAircraft()) { return false; }
|
||||
const CTextMessageSettings s = m_messageSettings.getThreadLocal();
|
||||
if (s.popup(textMessage)) { return true; } // fast check without needing own aircraft
|
||||
const CSimulatedAircraft ownAircraft(sApp->getIContextOwnAircraft()->getOwnAircraft());
|
||||
const CSimulatedAircraft ownAircraft(sGui->getIContextOwnAircraft()->getOwnAircraft());
|
||||
return s.popup(textMessage, ownAircraft);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace BlackGui
|
||||
void COverlayMessages::showOverlayMessages(const BlackMisc::CStatusMessageList &messages, bool appendOldMessages, int timeOutMs)
|
||||
{
|
||||
if (messages.isEmpty()) { return; }
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (this->hasPendingConfirmation())
|
||||
{
|
||||
// defer message
|
||||
@@ -180,7 +180,7 @@ namespace BlackGui
|
||||
void COverlayMessages::showOverlayMessage(const BlackMisc::CStatusMessage &message, int timeOutMs)
|
||||
{
|
||||
if (message.isEmpty()) { return; }
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (this->hasPendingConfirmation())
|
||||
{
|
||||
// defer message
|
||||
@@ -208,7 +208,7 @@ namespace BlackGui
|
||||
{
|
||||
if (textMessage.isEmpty()) { return; }
|
||||
if (!displayTextMessage(textMessage)) { return; }
|
||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
|
||||
if (this->hasPendingConfirmation())
|
||||
{
|
||||
@@ -351,7 +351,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void COverlayMessages::showOverlayMessagesWithConfirmation(const CStatusMessageList &messages, bool appendOldMessages, const QString &confirmationMessage, std::function<void ()> okLambda, int defaultButton, int timeOutMs)
|
||||
void COverlayMessages::showOverlayMessagesWithConfirmation(const CStatusMessageList &messages, bool appendOldMessages, const QString &confirmationMessage, std::function<void ()> okLambda, QMessageBox::StandardButton defaultButton, int timeOutMs)
|
||||
{
|
||||
if (this->hasPendingConfirmation())
|
||||
{
|
||||
@@ -363,10 +363,10 @@ namespace BlackGui
|
||||
return;
|
||||
}
|
||||
this->setConfirmationMessage(confirmationMessage);
|
||||
this->setDefaultConfirmationButton(defaultButton);
|
||||
this->showOverlayMessages(messages, appendOldMessages, timeOutMs);
|
||||
m_awaitingConfirmation = true; // needs to be after showOverlayMessages
|
||||
m_okLambda = okLambda;
|
||||
this->setDefaultConfirmationButton(defaultButton);
|
||||
}
|
||||
|
||||
void COverlayMessages::clearOverlayMessages()
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace BlackGui
|
||||
bool appendOldMessages,
|
||||
const QString &confirmationMessage,
|
||||
std::function<void()> okLambda,
|
||||
int defaultButton = QMessageBox::Cancel,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::Cancel,
|
||||
int timeOutMs = -1);
|
||||
|
||||
//! Clear the overlay messages
|
||||
@@ -130,19 +130,6 @@ namespace BlackGui
|
||||
//! \copydoc QFrame::keyPressEvent
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private slots:
|
||||
//! Stylesheet changed
|
||||
void ps_onStyleSheetsChanged();
|
||||
|
||||
//! OK clicked (only when confirmation bar is active)
|
||||
void ps_okClicked();
|
||||
|
||||
//! Cancel clicked (only when confirmation bar is active)
|
||||
void ps_cancelClicked();
|
||||
|
||||
//! Kill clicked (only when errors)
|
||||
void ps_killClicked();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::COverlayMessages> ui;
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TextMessageSettings> m_messageSettings { this };
|
||||
@@ -154,6 +141,18 @@ namespace BlackGui
|
||||
QTimer m_autoCloseTimer { this };
|
||||
QList<std::function<void()>> m_pendingMessageCalls;
|
||||
|
||||
//! Stylesheet changed
|
||||
void onStyleSheetsChanged();
|
||||
|
||||
//! OK clicked (only when confirmation bar is active)
|
||||
void onOkClicked();
|
||||
|
||||
//! Cancel clicked (only when confirmation bar is active)
|
||||
void onCancelClicked();
|
||||
|
||||
//! Kill clicked (only when errors)
|
||||
void onKillClicked();
|
||||
|
||||
//! Init widget
|
||||
void init(int w, int h);
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>487</width>
|
||||
<height>337</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -34,12 +34,6 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_StatusMessagesComponentsInner">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_StatusMessagesComponentInner">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
@@ -55,12 +49,6 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Header">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_Header">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
@@ -229,14 +217,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CStatusMessageFormSmall" name="form_StatusMessageSmall">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="BlackGui::Components::CStatusMessageFormSmall" name="form_StatusMessageSmall"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -314,12 +295,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Confirmation">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_ConfirmationFrame">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
@@ -357,6 +332,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Confirmation">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -46,7 +46,10 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void COverlayMessagesFrame::showOverlayMessagesWithConfirmation(const BlackMisc::CStatusMessageList &messages, bool appendOldMessages, const QString &confirmationMessage, std::function<void ()> okLambda, int defaultButton, int timeOutMs)
|
||||
void COverlayMessagesFrame::showOverlayMessagesWithConfirmation(
|
||||
const BlackMisc::CStatusMessageList &messages, bool appendOldMessages,
|
||||
const QString &confirmationMessage, std::function<void ()> okLambda,
|
||||
QMessageBox::StandardButton defaultButton, int timeOutMs)
|
||||
{
|
||||
if (messages.isEmpty()) { return; }
|
||||
this->initInnerFrame();
|
||||
|
||||
@@ -55,17 +55,13 @@ namespace BlackGui
|
||||
//! Show kill button
|
||||
void showKillButton(bool killButton);
|
||||
|
||||
//! 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,
|
||||
bool appendOldMessages,
|
||||
const QString &confirmationMessage,
|
||||
std::function<void()> okLambda,
|
||||
int defaultButton = QMessageBox::Cancel,
|
||||
QMessageBox::StandardButton defaultButton = QMessageBox::Cancel,
|
||||
int timeOutMs = -1
|
||||
);
|
||||
|
||||
|
||||
@@ -317,14 +317,12 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::settingsChanged()
|
||||
{
|
||||
if (this->allowsMultipleSelectedRows())
|
||||
if (!this->allowsMultipleSelectedRows()) { return; }
|
||||
const CGeneralGuiSettings settings = m_guiSettings.getThreadLocal();
|
||||
m_originalSelectionMode = settings.getPreferredSelection();
|
||||
if (this->isCurrentlyAllowingMultipleRowSelections())
|
||||
{
|
||||
const CGeneralGuiSettings settings = m_guiSettings.getThreadLocal();
|
||||
m_originalSelectionMode = settings.getPreferredSelection();
|
||||
if (this->isCurrentlyAllowingMultipleRowSelections())
|
||||
{
|
||||
this->setSelectionMode(settings.getPreferredSelection());
|
||||
}
|
||||
this->setSelectionMode(settings.getPreferredSelection());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,10 +791,7 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::ps_setSingleSelection()
|
||||
{
|
||||
if (this->allowsMultipleSelectedRows())
|
||||
{
|
||||
this->setSelectionMode(SingleSelection);
|
||||
}
|
||||
this->setSelectionMode(SingleSelection);
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::ps_setExtendedSelection()
|
||||
|
||||
Reference in New Issue
Block a user