mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 09:45:44 +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(
|
bool CDbStashComponent::showOverlayMessagesWithConfirmation(
|
||||||
const CStatusMessageList &msgs, bool appendOldMessages,
|
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.isEmpty()) { return false; }
|
||||||
if (!msgs.hasErrorMessages() && onlyErrors) { return false; }
|
if (!msgs.hasErrorMessages() && onlyErrors) { return false; }
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QString>
|
#include <QMessageBox>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ namespace BlackGui
|
|||||||
bool showOverlayMessagesWithConfirmation(
|
bool showOverlayMessagesWithConfirmation(
|
||||||
const BlackMisc::CStatusMessageList &msgs, bool appendOldMessages,
|
const BlackMisc::CStatusMessageList &msgs, bool appendOldMessages,
|
||||||
const QString &confirmation, std::function<void()> okLambda,
|
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
|
//! Display message
|
||||||
bool showOverlayMessage(const BlackMisc::CStatusMessage &msg, int timeoutMs = -1);
|
bool showOverlayMessage(const BlackMisc::CStatusMessage &msg, int timeoutMs = -1);
|
||||||
|
|||||||
@@ -53,10 +53,10 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
this->init(w, h);
|
this->init(w, h);
|
||||||
this->showKillButton(false);
|
this->showKillButton(false);
|
||||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &COverlayMessages::ps_onStyleSheetsChanged);
|
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &COverlayMessages::onStyleSheetsChanged);
|
||||||
connect(ui->pb_Ok, &QPushButton::clicked, this, &COverlayMessages::ps_okClicked);
|
connect(ui->pb_Ok, &QPushButton::clicked, this, &COverlayMessages::onOkClicked);
|
||||||
connect(ui->pb_Cancel, &QPushButton::clicked, this, &COverlayMessages::ps_cancelClicked);
|
connect(ui->pb_Cancel, &QPushButton::clicked, this, &COverlayMessages::onCancelClicked);
|
||||||
connect(ui->tb_Kill, &QPushButton::clicked, this, &COverlayMessages::ps_killClicked);
|
connect(ui->tb_Kill, &QPushButton::clicked, this, &COverlayMessages::onKillClicked);
|
||||||
|
|
||||||
ui->tvp_StatusMessages->setResizeMode(CStatusMessageView::ResizingAlways);
|
ui->tvp_StatusMessages->setResizeMode(CStatusMessageView::ResizingAlways);
|
||||||
ui->tvp_StatusMessages->setForceColumnsToMaxSize(false); // problems with multiline entries, with T138 we need multiline messages
|
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);
|
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;
|
m_lastConfirmation = QMessageBox::Ok;
|
||||||
if (m_okLambda) { m_okLambda(); }
|
if (m_okLambda) { m_okLambda(); }
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COverlayMessages::ps_cancelClicked()
|
void COverlayMessages::onCancelClicked()
|
||||||
{
|
{
|
||||||
m_lastConfirmation = QMessageBox::Cancel;
|
m_lastConfirmation = QMessageBox::Cancel;
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COverlayMessages::ps_killClicked()
|
void COverlayMessages::onKillClicked()
|
||||||
{
|
{
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText("Shutdown the application.");
|
msgBox.setText("Shutdown the application.");
|
||||||
@@ -134,10 +134,10 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool COverlayMessages::displayTextMessage(const CTextMessage &textMessage) const
|
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();
|
const CTextMessageSettings s = m_messageSettings.getThreadLocal();
|
||||||
if (s.popup(textMessage)) { return true; } // fast check without needing own aircraft
|
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);
|
return s.popup(textMessage, ownAircraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ namespace BlackGui
|
|||||||
void COverlayMessages::showOverlayMessages(const BlackMisc::CStatusMessageList &messages, bool appendOldMessages, int timeOutMs)
|
void COverlayMessages::showOverlayMessages(const BlackMisc::CStatusMessageList &messages, bool appendOldMessages, int timeOutMs)
|
||||||
{
|
{
|
||||||
if (messages.isEmpty()) { return; }
|
if (messages.isEmpty()) { return; }
|
||||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
if (this->hasPendingConfirmation())
|
if (this->hasPendingConfirmation())
|
||||||
{
|
{
|
||||||
// defer message
|
// defer message
|
||||||
@@ -180,7 +180,7 @@ namespace BlackGui
|
|||||||
void COverlayMessages::showOverlayMessage(const BlackMisc::CStatusMessage &message, int timeOutMs)
|
void COverlayMessages::showOverlayMessage(const BlackMisc::CStatusMessage &message, int timeOutMs)
|
||||||
{
|
{
|
||||||
if (message.isEmpty()) { return; }
|
if (message.isEmpty()) { return; }
|
||||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
if (this->hasPendingConfirmation())
|
if (this->hasPendingConfirmation())
|
||||||
{
|
{
|
||||||
// defer message
|
// defer message
|
||||||
@@ -208,7 +208,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (textMessage.isEmpty()) { return; }
|
if (textMessage.isEmpty()) { return; }
|
||||||
if (!displayTextMessage(textMessage)) { return; }
|
if (!displayTextMessage(textMessage)) { return; }
|
||||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
|
||||||
if (this->hasPendingConfirmation())
|
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())
|
if (this->hasPendingConfirmation())
|
||||||
{
|
{
|
||||||
@@ -363,10 +363,10 @@ namespace BlackGui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->setConfirmationMessage(confirmationMessage);
|
this->setConfirmationMessage(confirmationMessage);
|
||||||
|
this->setDefaultConfirmationButton(defaultButton);
|
||||||
this->showOverlayMessages(messages, appendOldMessages, timeOutMs);
|
this->showOverlayMessages(messages, appendOldMessages, timeOutMs);
|
||||||
m_awaitingConfirmation = true; // needs to be after showOverlayMessages
|
m_awaitingConfirmation = true; // needs to be after showOverlayMessages
|
||||||
m_okLambda = okLambda;
|
m_okLambda = okLambda;
|
||||||
this->setDefaultConfirmationButton(defaultButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void COverlayMessages::clearOverlayMessages()
|
void COverlayMessages::clearOverlayMessages()
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace BlackGui
|
|||||||
bool appendOldMessages,
|
bool appendOldMessages,
|
||||||
const QString &confirmationMessage,
|
const QString &confirmationMessage,
|
||||||
std::function<void()> okLambda,
|
std::function<void()> okLambda,
|
||||||
int defaultButton = QMessageBox::Cancel,
|
QMessageBox::StandardButton defaultButton = QMessageBox::Cancel,
|
||||||
int timeOutMs = -1);
|
int timeOutMs = -1);
|
||||||
|
|
||||||
//! Clear the overlay messages
|
//! Clear the overlay messages
|
||||||
@@ -130,19 +130,6 @@ namespace BlackGui
|
|||||||
//! \copydoc QFrame::keyPressEvent
|
//! \copydoc QFrame::keyPressEvent
|
||||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
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:
|
private:
|
||||||
QScopedPointer<Ui::COverlayMessages> ui;
|
QScopedPointer<Ui::COverlayMessages> ui;
|
||||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TextMessageSettings> m_messageSettings { this };
|
BlackMisc::CSettingReadOnly<BlackGui::Settings::TextMessageSettings> m_messageSettings { this };
|
||||||
@@ -154,6 +141,18 @@ namespace BlackGui
|
|||||||
QTimer m_autoCloseTimer { this };
|
QTimer m_autoCloseTimer { this };
|
||||||
QList<std::function<void()>> m_pendingMessageCalls;
|
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
|
//! Init widget
|
||||||
void init(int w, int h);
|
void init(int w, int h);
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>487</width>
|
||||||
<height>300</height>
|
<height>337</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -34,12 +34,6 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="fr_StatusMessagesComponentsInner">
|
<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">
|
<layout class="QVBoxLayout" name="vl_StatusMessagesComponentInner">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@@ -55,12 +49,6 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="fr_Header">
|
<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">
|
<layout class="QHBoxLayout" name="hl_Header">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>10</number>
|
<number>10</number>
|
||||||
@@ -229,14 +217,7 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="BlackGui::Components::CStatusMessageFormSmall" name="form_StatusMessageSmall">
|
<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>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -314,12 +295,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="fr_Confirmation">
|
<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">
|
<layout class="QHBoxLayout" name="hl_ConfirmationFrame">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
@@ -357,6 +332,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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; }
|
if (messages.isEmpty()) { return; }
|
||||||
this->initInnerFrame();
|
this->initInnerFrame();
|
||||||
|
|||||||
@@ -55,17 +55,13 @@ namespace BlackGui
|
|||||||
//! Show kill button
|
//! Show kill button
|
||||||
void showKillButton(bool killButton);
|
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
|
//! \copydoc COverlayMessages::showOverlayMessagesWithConfirmation
|
||||||
void showOverlayMessagesWithConfirmation(
|
void showOverlayMessagesWithConfirmation(
|
||||||
const BlackMisc::CStatusMessageList &messages,
|
const BlackMisc::CStatusMessageList &messages,
|
||||||
bool appendOldMessages,
|
bool appendOldMessages,
|
||||||
const QString &confirmationMessage,
|
const QString &confirmationMessage,
|
||||||
std::function<void()> okLambda,
|
std::function<void()> okLambda,
|
||||||
int defaultButton = QMessageBox::Cancel,
|
QMessageBox::StandardButton defaultButton = QMessageBox::Cancel,
|
||||||
int timeOutMs = -1
|
int timeOutMs = -1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -317,8 +317,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CViewBaseNonTemplate::settingsChanged()
|
void CViewBaseNonTemplate::settingsChanged()
|
||||||
{
|
{
|
||||||
if (this->allowsMultipleSelectedRows())
|
if (!this->allowsMultipleSelectedRows()) { return; }
|
||||||
{
|
|
||||||
const CGeneralGuiSettings settings = m_guiSettings.getThreadLocal();
|
const CGeneralGuiSettings settings = m_guiSettings.getThreadLocal();
|
||||||
m_originalSelectionMode = settings.getPreferredSelection();
|
m_originalSelectionMode = settings.getPreferredSelection();
|
||||||
if (this->isCurrentlyAllowingMultipleRowSelections())
|
if (this->isCurrentlyAllowingMultipleRowSelections())
|
||||||
@@ -326,7 +325,6 @@ namespace BlackGui
|
|||||||
this->setSelectionMode(settings.getPreferredSelection());
|
this->setSelectionMode(settings.getPreferredSelection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CViewBaseNonTemplate::customMenu(CMenuActions &menuActions)
|
void CViewBaseNonTemplate::customMenu(CMenuActions &menuActions)
|
||||||
{
|
{
|
||||||
@@ -792,12 +790,9 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CViewBaseNonTemplate::ps_setSingleSelection()
|
void CViewBaseNonTemplate::ps_setSingleSelection()
|
||||||
{
|
|
||||||
if (this->allowsMultipleSelectedRows())
|
|
||||||
{
|
{
|
||||||
this->setSelectionMode(SingleSelection);
|
this->setSelectionMode(SingleSelection);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CViewBaseNonTemplate::ps_setExtendedSelection()
|
void CViewBaseNonTemplate::ps_setExtendedSelection()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user