mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 11:05:44 +08:00
Settings for text messages, ascending or descending (latest first/last)
This commit is contained in:
@@ -33,7 +33,7 @@ namespace BlackGui
|
|||||||
explicit CSettingsTextMessageStyle(QWidget *parent = nullptr);
|
explicit CSettingsTextMessageStyle(QWidget *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CSettingsTextMessageStyle();
|
virtual ~CSettingsTextMessageStyle() override;
|
||||||
|
|
||||||
//! Fmily, size and style
|
//! Fmily, size and style
|
||||||
QStringList getFamilySizeStyle() const;
|
QStringList getFamilySizeStyle() const;
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>CSettingsTextMessageStyle</class>
|
<class>CSettingsTextMessageStyle</class>
|
||||||
<widget class="QFrame" name="CSettingsTextMessageStyle">
|
<widget class="QFrame" name="CSettingsTextMessageStyle">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>440</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Text message style</string>
|
<string>Text message style</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ namespace BlackGui
|
|||||||
c = connect(ui->comp_AtcStations, &CAtcButtonComponent::requestAtcStation, this, &CTextMessageComponent::onAtcButtonClicked, Qt::QueuedConnection);
|
c = connect(ui->comp_AtcStations, &CAtcButtonComponent::requestAtcStation, this, &CTextMessageComponent::onAtcButtonClicked, Qt::QueuedConnection);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect");
|
||||||
|
|
||||||
|
c = connect(ui->cb_LatestFirst, &QCheckBox::toggled, this, &CTextMessageComponent::onLatestFirstChanged, Qt::QueuedConnection);
|
||||||
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect");
|
||||||
|
|
||||||
// style sheet
|
// style sheet
|
||||||
c = connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CTextMessageComponent::onStyleSheetChanged, Qt::QueuedConnection);
|
c = connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CTextMessageComponent::onStyleSheetChanged, Qt::QueuedConnection);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect");
|
||||||
@@ -106,10 +109,12 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
// init decoupled when sub components are fully init
|
// init decoupled when sub components are fully init
|
||||||
if (!myself || !sGui || sGui->isShuttingDown()) { return; }
|
if (!myself || !sGui || sGui->isShuttingDown()) { return; }
|
||||||
this->onSettingsChanged();
|
this->onSettingsChanged(); // init
|
||||||
this->showCurrentFrequenciesFromCockpit();
|
this->showCurrentFrequenciesFromCockpit();
|
||||||
|
const bool latestFirst = m_messageSettings.get().isLatestFirst();
|
||||||
|
ui->tvp_TextMessagesAll->setSorting(CTextMessage::IndexUtcTimestamp, latestFirst ? Qt::DescendingOrder : Qt::AscendingOrder);
|
||||||
|
|
||||||
// hde for the beginning
|
// hide for the beginning
|
||||||
ui->gb_Settings->setChecked(false);
|
ui->gb_Settings->setChecked(false);
|
||||||
ui->gb_MessageTo->setChecked(false);
|
ui->gb_MessageTo->setChecked(false);
|
||||||
});
|
});
|
||||||
@@ -239,7 +244,8 @@ namespace BlackGui
|
|||||||
// message for me? right frequency? otherwise quit
|
// message for me? right frequency? otherwise quit
|
||||||
if (this->hasAllMessagesTab() && (relevantForMe || message.isServerMessage()))
|
if (this->hasAllMessagesTab() && (relevantForMe || message.isServerMessage()))
|
||||||
{
|
{
|
||||||
ui->tvp_TextMessagesAll->insert(message);
|
ui->tvp_TextMessagesAll->push_back(message); // no sorting
|
||||||
|
ui->tvp_TextMessagesAll->resort();
|
||||||
}
|
}
|
||||||
if (!relevantForMe) { continue; }
|
if (!relevantForMe) { continue; }
|
||||||
|
|
||||||
@@ -270,6 +276,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->comp_SettingsOverlay->setVisible(checked);
|
ui->comp_SettingsOverlay->setVisible(checked);
|
||||||
ui->comp_SettingsStyle->setVisible(checked);
|
ui->comp_SettingsStyle->setVisible(checked);
|
||||||
|
ui->cb_LatestFirst->setVisible(checked);
|
||||||
ui->gb_Settings->setFlat(!checked);
|
ui->gb_Settings->setFlat(!checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,17 +291,30 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
QList<CTextMessageTextEdit *> textEdits = this->findAllTextEdit();
|
QList<CTextMessageTextEdit *> textEdits = this->findAllTextEdit();
|
||||||
const QString style = this->getStyleSheet();
|
const QString style = this->getStyleSheet();
|
||||||
|
const bool latestFirst = m_messageSettings.get().isLatestFirst();
|
||||||
for (CTextMessageTextEdit *textEdit : textEdits)
|
for (CTextMessageTextEdit *textEdit : textEdits)
|
||||||
{
|
{
|
||||||
|
textEdit->setLatestFirst(latestFirst);
|
||||||
textEdit->setStyleSheetForContent(style);
|
textEdit->setStyleSheetForContent(style);
|
||||||
}
|
}
|
||||||
ui->comp_SettingsStyle->setStyle(this->getStyleSheet());
|
ui->comp_SettingsStyle->setStyle(this->getStyleSheet());
|
||||||
|
if (latestFirst != ui->cb_LatestFirst->isChecked()) { ui->cb_LatestFirst->setChecked(latestFirst); }
|
||||||
this->update(); // refresh window
|
this->update(); // refresh window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CTextMessageComponent::onLatestFirstChanged(bool checked)
|
||||||
|
{
|
||||||
|
CTextMessageSettings s = m_messageSettings.get();
|
||||||
|
if (s.isLatestFirst() == checked) { return; }
|
||||||
|
s.setLatestFirst(checked);
|
||||||
|
const CStatusMessage m = m_messageSettings.setAndSave(s);
|
||||||
|
CLogMessage::preformatted(m);
|
||||||
|
this->onSettingsChanged(); // latest first
|
||||||
|
}
|
||||||
|
|
||||||
void CTextMessageComponent::onStyleSheetChanged()
|
void CTextMessageComponent::onStyleSheetChanged()
|
||||||
{
|
{
|
||||||
this->onSettingsChanged();
|
this->onSettingsChanged(); // style sheet
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTextMessageComponent::onAtcButtonClicked(const CAtcStation &station)
|
void CTextMessageComponent::onAtcButtonClicked(const CAtcStation &station)
|
||||||
@@ -308,6 +328,7 @@ namespace BlackGui
|
|||||||
const QString style = ui->comp_SettingsStyle->getStyle();
|
const QString style = ui->comp_SettingsStyle->getStyle();
|
||||||
CTextMessageSettings s = m_messageSettings.get();
|
CTextMessageSettings s = m_messageSettings.get();
|
||||||
s.setStyleSheet(style);
|
s.setStyleSheet(style);
|
||||||
|
s.setLatestFirst(ui->cb_LatestFirst->isChecked());
|
||||||
const CStatusMessage m = m_messageSettings.setAndSave(s);
|
const CStatusMessage m = m_messageSettings.setAndSave(s);
|
||||||
CLogMessage::preformatted(m);
|
CLogMessage::preformatted(m);
|
||||||
this->onStyleSheetChanged();
|
this->onStyleSheetChanged();
|
||||||
|
|||||||
@@ -199,6 +199,9 @@ namespace BlackGui
|
|||||||
//! Settings have been changed
|
//! Settings have been changed
|
||||||
void onSettingsChanged();
|
void onSettingsChanged();
|
||||||
|
|
||||||
|
//! Latest 1st checked
|
||||||
|
void onLatestFirstChanged(bool checked);
|
||||||
|
|
||||||
//! Style sheet has been changed
|
//! Style sheet has been changed
|
||||||
void onStyleSheetChanged();
|
void onStyleSheetChanged();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>CTextMessageComponent</class>
|
<class>CTextMessageComponent</class>
|
||||||
<widget class="QFrame" name="CTextMessageComponent">
|
<widget class="QFrame" name="CTextMessageComponent">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>260</width>
|
||||||
|
<height>367</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Text messages</string>
|
<string>Text messages</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -249,10 +257,7 @@
|
|||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="vl_Settings">
|
<layout class="QGridLayout" name="gl_Settings">
|
||||||
<property name="spacing">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -265,8 +270,8 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<item alignment="Qt::AlignRight">
|
<item row="1" column="1">
|
||||||
<widget class="BlackGui::Components::CSettingsTextMessageInlineComponent" name="comp_SettingsOverlay">
|
<widget class="BlackGui::Components::CSettingsTextMessageStyle" name="comp_SettingsStyle">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>200</width>
|
<width>200</width>
|
||||||
@@ -275,8 +280,15 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item alignment="Qt::AlignRight">
|
<item row="1" column="0" alignment="Qt::AlignRight">
|
||||||
<widget class="BlackGui::Components::CSettingsTextMessageStyle" name="comp_SettingsStyle">
|
<widget class="QCheckBox" name="cb_LatestFirst">
|
||||||
|
<property name="text">
|
||||||
|
<string>latest 1st</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="BlackGui::Components::CSettingsTextMessageInlineComponent" name="comp_SettingsOverlay">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>200</width>
|
<width>200</width>
|
||||||
|
|||||||
@@ -74,12 +74,13 @@ namespace BlackGui
|
|||||||
QString CTextMessageSettings::convertToQString(bool i18n) const
|
QString CTextMessageSettings::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n);
|
||||||
return QStringLiteral("Private: %1 supervisor: %2 frequency: %3 all: %4 focus: %5").arg(
|
return QStringLiteral("Private: %1 supervisor: %2 frequency: %3 all: %4 focus: %5 latest 1st: %6").arg(
|
||||||
boolToOnOff(this->getPopupPrivateMessages()),
|
boolToOnOff(this->getPopupPrivateMessages()),
|
||||||
boolToOnOff(this->getPopupSupervisorMessages()),
|
boolToOnOff(this->getPopupSupervisorMessages()),
|
||||||
boolToOnOff(this->getPopupFrequencyMessages()),
|
boolToOnOff(this->getPopupFrequencyMessages()),
|
||||||
boolToOnOff(this->getPopupAllMessages()),
|
boolToOnOff(this->getPopupAllMessages()),
|
||||||
boolToYesNo(this->focusOverlayWindow())
|
boolToYesNo(this->focusOverlayWindow()),
|
||||||
|
boolToYesNo(this->isLatestFirst())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +96,7 @@ namespace BlackGui
|
|||||||
case IndexPopupSupervisorMessages: return CVariant::fromValue(this->popupSupervisorMessages());
|
case IndexPopupSupervisorMessages: return CVariant::fromValue(this->popupSupervisorMessages());
|
||||||
case IndexPopupSelcalMessages: return CVariant::fromValue(this->popupSelcalMessages());
|
case IndexPopupSelcalMessages: return CVariant::fromValue(this->popupSelcalMessages());
|
||||||
case IndexStyle: return CVariant::fromValue(this->getStyleSheet());
|
case IndexStyle: return CVariant::fromValue(this->getStyleSheet());
|
||||||
|
case IndexLatestFirst: return CVariant::fromValue(this->isLatestFirst());
|
||||||
case IndexFocus: return CVariant::fromValue(this->focusOverlayWindow());
|
case IndexFocus: return CVariant::fromValue(this->focusOverlayWindow());
|
||||||
default: return CValueObject::propertyByIndex(index);
|
default: return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
@@ -112,6 +114,7 @@ namespace BlackGui
|
|||||||
case IndexPopupPrivateMessages: this->setPopupPrivateMessages(variant.toBool()); break;
|
case IndexPopupPrivateMessages: this->setPopupPrivateMessages(variant.toBool()); break;
|
||||||
case IndexPopupSelcalMessages: this->setPopupSelcalMessages(variant.toBool()); break;
|
case IndexPopupSelcalMessages: this->setPopupSelcalMessages(variant.toBool()); break;
|
||||||
case IndexFocus: this->setFocusOverlayWindows(variant.toBool()); break;
|
case IndexFocus: this->setFocusOverlayWindows(variant.toBool()); break;
|
||||||
|
case IndexLatestFirst: this->setLatestFirst(variant.toBool()); break;
|
||||||
case IndexStyle: this->setStyleSheet(variant.toQString()); break;
|
case IndexStyle: this->setStyleSheet(variant.toQString()); break;
|
||||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace BlackGui
|
|||||||
IndexPopupAllMessages,
|
IndexPopupAllMessages,
|
||||||
IndexPopupSelcalMessages,
|
IndexPopupSelcalMessages,
|
||||||
IndexFocus,
|
IndexFocus,
|
||||||
|
IndexLatestFirst,
|
||||||
IndexStyle
|
IndexStyle
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,6 +96,12 @@ namespace BlackGui
|
|||||||
//! Popup the given message? Complete check including frequencies.
|
//! Popup the given message? Complete check including frequencies.
|
||||||
bool popup(const BlackMisc::Network::CTextMessage &textMessage, const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft) const;
|
bool popup(const BlackMisc::Network::CTextMessage &textMessage, const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft) const;
|
||||||
|
|
||||||
|
//! Latest messages 1st?
|
||||||
|
bool isLatestFirst() const { return m_latestFirst; }
|
||||||
|
|
||||||
|
//! Latest messages 1st?
|
||||||
|
void setLatestFirst(bool latestFirst) { m_latestFirst = latestFirst; }
|
||||||
|
|
||||||
//! CSS style sheet
|
//! CSS style sheet
|
||||||
const QString &getStyleSheet() const { return m_styleSheet; }
|
const QString &getStyleSheet() const { return m_styleSheet; }
|
||||||
|
|
||||||
@@ -126,6 +133,7 @@ namespace BlackGui
|
|||||||
bool m_popupAllMessages = false;
|
bool m_popupAllMessages = false;
|
||||||
bool m_popupSelcalMessages = true;
|
bool m_popupSelcalMessages = true;
|
||||||
bool m_focus = true;
|
bool m_focus = true;
|
||||||
|
bool m_latestFirst = false; //!< latest messages first
|
||||||
QString m_styleSheet;
|
QString m_styleSheet;
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
@@ -135,6 +143,8 @@ namespace BlackGui
|
|||||||
BLACK_METAMEMBER(popupFrequencyMessages),
|
BLACK_METAMEMBER(popupFrequencyMessages),
|
||||||
BLACK_METAMEMBER(popupAllMessages),
|
BLACK_METAMEMBER(popupAllMessages),
|
||||||
BLACK_METAMEMBER(popupSelcalMessages),
|
BLACK_METAMEMBER(popupSelcalMessages),
|
||||||
|
BLACK_METAMEMBER(focus),
|
||||||
|
BLACK_METAMEMBER(latestFirst),
|
||||||
BLACK_METAMEMBER(styleSheet)
|
BLACK_METAMEMBER(styleSheet)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user