swift
Loading...
Searching...
No Matches
textmessagecomponent.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_GUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
7#define SWIFT_GUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
8
9#include <QFrame>
10#include <QObject>
11#include <QScopedPointer>
12#include <QString>
13
17#include "gui/swiftguiexport.h"
20#include "misc/identifier.h"
23#include "misc/variant.h"
24
25namespace Ui
26{
27 class CTextMessageComponent;
28}
29namespace swift::gui
30{
33
34 namespace components
35 {
38 {
40
41 public:
43 explicit CTextMessageComponent(QWidget *parent = nullptr);
44
47
49 bool setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) override;
50
53 bool handleGlobalCommandLineText(const QString &commandLine, const swift::misc::CIdentifier &originator);
54
57 void fontSizeMinus();
58 void fontSizePlus();
60
63
66
68 void setTab(TextMessageTab tab);
69
71 bool hasAllMessagesTab() const;
72
74 void showSettings(bool show);
75
77 void showTextMessageEntry(bool show);
78
80 void focusTextEntry();
81
84
86 bool isShowingRealNames() const { return m_showRealNames; }
87
89 void setShowingRealNames(bool show) { m_showRealNames = show; }
90
91 // ---------- overlay test messages -------------
92
94 void setAsUsedInOverlayMode() { m_usedAsOverlayWidget = true; }
95
97 void activate(bool send, bool receive);
98
100 bool isActivated() const { return m_activeSend || m_activeReceive; }
101
103 void setAtcButtonsRowsColumns(int rows, int cols, bool setMaxElements);
104
106 void setAtcButtonsBackgroundUpdates(bool backgroundUpdates);
107
109 void updateAtcStationsButtons();
110
111 signals:
114 void displayInInfoWindow(const swift::misc::CVariant &message, std::chrono::milliseconds displayDuration);
115
117 void commandEntered(const QString &commandLine, const swift::misc::CIdentifier &originator);
118
121
122 private:
124 swift::misc::CIdentifier m_identifier { "TextMessageComponent", this };
126 this, &CTextMessageComponent::onSettingsChanged
127 };
129 bool m_usedAsOverlayWidget = false;
130 bool m_activeSend = true;
131 bool m_activeReceive = true;
132 bool m_showRealNames = true;
133
135 QWidget *getTabWidget(TextMessageTab tab) const;
136
138 CTextMessageTextEdit *getTextEdit(TextMessageTab tab) const;
139
141 void selectTabWidget(TextMessageTab tab);
142
144 void selectTabWidget(const swift::misc::aviation::CCallsign &callsign, bool addIfNotExisting);
145
147 bool isCloseableTab(const QWidget *tabWidget) const;
148
150 QWidget *addNewTextMessageTab(const swift::misc::aviation::CCallsign &callsign);
151
153 QWidget *findTextMessageTabByCallsign(const swift::misc::aviation::CCallsign &callsign,
154 bool callsignResolution = false) const;
155
157 QWidget *findTextMessageTabByName(const QString &name) const;
158
160 void addPrivateChannelTextMessage(const swift::misc::network::CTextMessage &textMessage);
161
163 swift::misc::simulation::CSimulatedAircraft getOwnAircraft() const;
164
166 bool isCorrespondingTextMessageTabSelected(const swift::misc::network::CTextMessage &textMessage) const;
167
169 bool isNetworkConnected() const;
170
173 void showCurrentFrequenciesFromCockpit();
174 void showCurrentFrequenciesFromCockpit(const swift::misc::simulation::CSimulatedAircraft &ownAircraft);
176
178 void displayTextMessage(const swift::misc::network::CTextMessageList &messages);
179
181 QString textMessageToCommand(const QString &enteredLine);
182
184 const swift::misc::CIdentifier &componentIdentifier() const { return m_identifier; }
185
187 void handleEnteredTextMessage(const QString &textMessage);
188
190 void onTextMessageReceived(const swift::misc::network::CTextMessageList &messages);
191
193 void onTextMessageSent(const swift::misc::network::CTextMessage &sentMessage);
194
196 void onChangedAircraftCockpit(const swift::misc::simulation::CSimulatedAircraft &aircraft,
197 const swift::misc::CIdentifier &originator);
198
200 void onSettingsChecked(bool checked);
201
203 void onMessageToChecked(bool checked);
204
206 void onSettingsChanged();
207
209 void onLatestFirstChanged(bool checked);
210
212 void onStyleSheetChanged();
213
215 void onAtcButtonClicked(const swift::misc::aviation::CAtcStation &station);
216
218 void updateSettings();
219
221 QList<CTextMessageTextEdit *> findAllTextEdit() const;
222
224 QString getStyleSheet() const;
225
227 void closeTextMessageTab();
228
230 void updateAllTabs();
231
233 void topLevelChanged(QWidget *widget, bool topLevel);
234
236 void textMessageEntered();
237
239 void setTabWidgetDescription(const swift::misc::aviation::CCallsign &callsign, int widgetIndex);
240
242 QString getCallsignAndRealName(const swift::misc::aviation::CCallsign &callsign) const;
243
245 bool isVisibleWidgetHack() const;
246
248 swift::misc::aviation::CCallsign getCallsignPropertyForTab(int tabIndex, bool validated) const;
249
251 void emitDisplayInInfoWindow(const misc::CVariant &message, std::chrono::milliseconds displayDuration);
252
254 static QString firstPartOfTabText(const QString &tabText);
255 };
256 } // namespace components
257} // namespace swift::gui
258
259#endif // SWIFT_GUI_COMPONENTS_TEXTMESSAGECOMPONENT_H
Specialized class for dock widgets serving as info area.
CEnableForDockWidgetInfoArea(CDockWidgetInfoArea *parentInfoArea=nullptr)
Constructor.
Specialized text edit for displaying text messages.
CTextMessageComponent(QWidget *parent=nullptr)
Constructor.
void showTextMessageEntry(bool show)
Show an text entry field.
void removeAllMessagesTab()
Remove the all tab, the operation cannot be undone.
void setShowingRealNames(bool show)
Showing real names.
bool handleGlobalCommandLineText(const QString &commandLine, const swift::misc::CIdentifier &originator)
Used to allow direct input from global command line when visible.
void commandEntered(const QString &commandLine, const swift::misc::CIdentifier &originator)
Command line was entered.
void displayInInfoWindow(const swift::misc::CVariant &message, std::chrono::milliseconds displayDuration)
Message to be displayed in central info window.
void textMessageTabSelected()
Text message tab selected.
bool isShowingRealNames() const
Showing real names.
void showCorrespondingTab(const swift::misc::aviation::CCallsign &callsign)
Display the tab for given callsign.
bool setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
Corresponding dockable widget in info area.
void setAsUsedInOverlayMode()
Used as overlay and not dock widget.
void showCorrespondingTabForFrequency(const swift::misc::physical_quantities::CFrequency &frequency)
Display the tab for given frequency.
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition identifier.h:29
Class template for accessing a specific value in the CSettingsCache.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition variant.h:69
Value object encapsulating information about an ATC station.
Definition atcstation.h:38
Value object encapsulating information of a callsign.
Definition callsign.h:30
Value object encapsulating information of a text message.
Definition textmessage.h:31
Value object encapsulating a list of text messages.
Comprehensive information of an aircraft.
High level reusable GUI components.
GUI related classes.
QFrame(QWidget *parent, Qt::WindowFlags f)
Q_OBJECTQ_OBJECT
QObject * parent() const const
QWidget(QWidget *parent, Qt::WindowFlags f)
void show()
#define SWIFT_GUI_EXPORT
Export a class or function from the library.