swift
logincomponent.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_LOGINCOMPONENT_H
7 #define SWIFT_GUI_LOGINCOMPONENT_H
8 
9 #include <QFrame>
10 #include <QIcon>
11 #include <QObject>
12 #include <QScopedPointer>
13 #include <QString>
14 #include <QTimer>
15 
16 #include "core/data/networksetup.h"
20 #include "gui/swiftguiexport.h"
21 #include "misc/aviation/callsign.h"
22 #include "misc/datacache.h"
23 #include "misc/digestsignal.h"
27 #include "misc/network/server.h"
28 #include "misc/network/user.h"
29 #include "misc/settingscache.h"
32 
33 namespace Ui
34 {
35  class CLoginComponent;
36 }
37 namespace swift::misc::simulation
38 {
39  class CAircraftModel;
40  class CSimulatedAircraft;
41 } // namespace swift::misc::simulation
42 namespace swift::gui::components
43 {
48  {
49  Q_OBJECT
50 
51  public:
53  enum Tab
54  {
55  LoginVATSIM,
56  LoginOthers
57  };
58 
60  static const QStringList &getLogCategories();
61 
63  explicit CLoginComponent(QWidget *parent = nullptr);
64 
66  virtual ~CLoginComponent() override;
67 
69  void setAutoPopupWizad(bool autoPopup);
70 
72  void mainInfoAreaChanged(const QWidget *currentWidget);
73 
75  void setLogoffCountdown(std::chrono::seconds timeout = LogoffIntervalSeconds);
76 
78  void toggleNetworkConnection();
79 
80  signals:
83 
86 
89 
92 
95 
96  private:
97  // -------------- values from GUI -----------------
98 
100  swift::misc::network::CUser getUserFromPilotGuiValues() const;
101 
104  bool updateOwnAircraftCallsignAndPilotFromGuiValues();
105 
106  // -------------- values to GUI -----------------
107 
109  void updateGui();
110 
112  void setGuiLoginAsValues(const swift::misc::simulation::CSimulatedAircraft &ownAircraft);
113 
114  // -------------- others -----------------
115 
117  swift::misc::network::CServer getCurrentVatsimServer() const;
118 
120  swift::misc::network::CServer getCurrentOtherServer() const;
121 
123  swift::misc::network::CServer getCurrentServer() const;
124 
126  swift::misc::simulation::CAircraftModel getPrefillModel() const;
127 
129  void loginCancelled();
130 
132  void logoffCountdown();
133 
135  void autoLogoffDetection();
136 
138  void autoLogoffFrameRate(bool fatal);
139 
141  void onSimulatorModelChanged(const swift::misc::simulation::CAircraftModel &model);
142 
144  void toggleTimeout();
145 
147  void updateUiConnectState();
148 
150  void blinkConnectButton();
151 
153  void setOkButtonString(bool connected);
154 
156  void startLogoffTimerCountdown();
157 
159  bool isVatsimNetworkTabSelected() const;
160 
162  void loadRememberedUserData();
163 
165  void onSelectedServerChanged(const swift::misc::network::CServer &server);
166 
168  void onSimulatorStatusChanged(int status);
169 
171  void onNetworkStatusChanged(const swift::misc::network::CConnectionStatus &from,
173 
175  void onServerTabWidgetChanged(int index);
176 
178  bool hasValidContexts() const;
179 
180  static constexpr std::chrono::milliseconds OverlayMessageMs { 5000 };
181  static constexpr std::chrono::seconds LogoffIntervalSeconds { 20 };
182 
183  QScopedPointer<Ui::CLoginComponent> ui;
184  swift::misc::CDigestSignal m_changedLoginDataDigestSignal { this, &CLoginComponent::loginDataChangedDigest,
185  std::chrono::milliseconds { 1500 }, 10 };
186  bool m_updatePilotOnServerChanges = true;
187  bool m_networkConnected = false;
188  bool m_simulatorConnected = false;
189  const QIcon m_iconPlay { ":/pastel/icons/pastel/16/control-play.png" };
190  const QIcon m_iconPause { ":/pastel/icons/pastel/16/control-pause.png" };
191  std::chrono::seconds m_logoffIntervalSeconds = LogoffIntervalSeconds;
192  QTimer m_logoffCountdownTimer;
193 
195  this
196  };
197  swift::core::data::CNetworkSetup m_networkSetup;
198  };
199 } // namespace swift::gui::components
200 
201 #endif // SWIFT_GUI_LOGINCOMPONENT_H
Remembering the last servers and ecosystem.
Definition: networksetup.h:25
Using this class provides a QFrame with the overlay functionality already integrated.
Login component to flight network.
void loginDataChangedDigest()
Relevant login data changed (digest version)
void setAutoPopupWizad(bool autoPopup)
Automatically popup.
void requestNetworkSettings()
Request network settings.
void requestLoginPage()
Request to be shown.
Receive 1..n signals, collect them over time, and resend afer n milliseconds.
Definition: digestsignal.h:18
Value object encapsulating information about a connection status.
Value object encapsulating information of a server.
Definition: server.h:28
Value object encapsulating information of a user.
Definition: user.h:28
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Comprehensive information of an aircraft.
High level reusable GUI components.
Definition: aboutdialog.cpp:13
#define SWIFT_GUI_EXPORT
Export a class or function from the library.