SettingsDialog¶
class nmeasim::app::SettingsDialog · Applications
Modal dialog that edits a copy of a profile in four tabs and applies the edits on OK.
Inherits QDialog
Declared in src/app/dialogs/settings_dialog.hpp (line 39)
The tabs are Simulation, Vessel, Sentences and Outputs, each a page that loads its part of the profile in the constructor. OK runs accept, which validates the pages in tab order and either shows the first problem under the tabs, leaving the dialog open, or stores every page into profile and closes the dialog. Cancel, Escape and closing the window reject the dialog and leave profile as it was passed in. The dialog never touches a profile file or the running simulation; the caller decides what to do with the result.
The dialog owns its copy of the profile and, through Qt parenthood, the tab widget, the four pages and the error label.
See also
Summary¶
Public member functions
| Name | Description |
|---|---|
SettingsDialog() |
Builds the dialog and loads a copy of a profile into every page. |
profile() |
Returns the dialog's profile. |
simulation_page() |
Returns the Simulation tab: mode, track and replay, clock, seed values, drift, destination and steering. |
vessel_page() |
Returns the Vessel tab: engines and AIS static data. |
sentences_page() |
Returns the Sentences tab: registry sentence settings and custom sentences. |
outputs_page() |
Returns the Outputs tab. |
tabs() |
Returns the tab widget, whose current tab accept switches to the page with a problem. |
error_text() |
Returns the validation message shown under the tabs. |
Public slots
| Name | Description |
|---|---|
accept() |
Validates every page and, when all pass, stores them into the profile and accepts the dialog. |
Private data members
| Name | Description |
|---|---|
profile_ |
The edited copy: the constructor's profile until accept succeeds, the stored result after. |
tabs_ |
The four tabs, in the order simulation, vessel, sentences, outputs. |
simulation_ |
The Simulation tab, owned through Qt parenthood. |
vessel_ |
The Vessel tab, owned through Qt parenthood. |
sentences_ |
The Sentences tab, owned through Qt parenthood. |
outputs_ |
The Outputs tab, owned through Qt parenthood. |
error_label_ |
Word-wrapped line under the tabs with the reason the last accept was refused, drawn in the palette's highlight colour; hidden when there is none. |
Public member functions¶
SettingsDialog()¶
explicit SettingsDialog(const io::Profile& profile, QWidget* parent = nullptr)
Builds the dialog and loads a copy of a profile into every page.
The window is titled Settings - followed by the profile name, is modal and opens at 900 by 640 pixels. It is not shown; call exec or open.
Parameters
| Name | Type | Description |
|---|---|---|
profile |
const io::Profile& |
The profile to edit; it is copied, so the caller's object is never changed and need not outlive the dialog. |
parent |
QWidget* |
Qt parent that owns the dialog and that it is centred on; null leaves ownership to the caller. |
Declared in src/app/dialogs/settings_dialog.hpp:52 · defined in src/app/dialogs/settings_dialog.cpp:18
profile()¶
const io::Profile& profile() const noexcept
Returns the dialog's profile.
Returns const io::Profile&: The profile as passed to the constructor until accept succeeds, then the edited profile. The reference stays valid for the lifetime of the dialog and its value changes only in a successful accept.
Declared in src/app/dialogs/settings_dialog.hpp:59
simulation_page()¶
SimulationPage* simulation_page() const noexcept
Returns the Simulation tab: mode, track and replay, clock, seed values, drift, destination and steering.
Returns SimulationPage*: The page, owned by the dialog.
Declared in src/app/dialogs/settings_dialog.hpp:65
vessel_page()¶
VesselPage* vessel_page() const noexcept
Returns the Vessel tab: engines and AIS static data.
Returns VesselPage*: The page, owned by the dialog.
Declared in src/app/dialogs/settings_dialog.hpp:69
sentences_page()¶
SentencesPage* sentences_page() const noexcept
Returns the Sentences tab: registry sentence settings and custom sentences.
Returns SentencesPage*: The page, owned by the dialog.
Declared in src/app/dialogs/settings_dialog.hpp:73
outputs_page()¶
OutputsPage* outputs_page() const noexcept
Returns the Outputs tab.
Returns OutputsPage*: The page, owned by the dialog.
Declared in src/app/dialogs/settings_dialog.hpp:77
tabs()¶
QTabWidget* tabs() const noexcept
Returns the tab widget, whose current tab accept switches to the page with a problem.
Returns QTabWidget*: The tab widget, owned by the dialog.
Declared in src/app/dialogs/settings_dialog.hpp:82
error_text()¶
QString error_text() const
Returns the validation message shown under the tabs.
Returns QString: The message of the last refused accept; empty before the first accept and after one that succeeded.
Declared in src/app/dialogs/settings_dialog.hpp:87 · defined in src/app/dialogs/settings_dialog.cpp:55
Public slots¶
accept()¶
void accept() override
Validates every page and, when all pass, stores them into the profile and accepts the dialog.
Connected to the OK button. The pages are checked in tab order: simulation, vessel, sentences, outputs. At the first problem its message is shown under the tabs, that page becomes the current tab and the dialog stays open with profile unchanged. Otherwise the message is hidden, every page is stored into profile, and QDialog::accept sets the result to QDialog::Accepted, hides the dialog and emits accepted and finished.
Note
Validating the outputs page commits the output being edited into that page's copy, even when the dialog is then refused.
Declared in src/app/dialogs/settings_dialog.hpp:102 · defined in src/app/dialogs/settings_dialog.cpp:59
Private data members¶
profile_¶
io::Profile profile_
The edited copy: the constructor's profile until accept succeeds, the stored result after.
Declared in src/app/dialogs/settings_dialog.hpp:107
tabs_¶
QTabWidget* tabs_
The four tabs, in the order simulation, vessel, sentences, outputs.
Declared in src/app/dialogs/settings_dialog.hpp:109
simulation_¶
SimulationPage* simulation_
The Simulation tab, owned through Qt parenthood.
Declared in src/app/dialogs/settings_dialog.hpp:111
vessel_¶
VesselPage* vessel_
The Vessel tab, owned through Qt parenthood.
Declared in src/app/dialogs/settings_dialog.hpp:113
sentences_¶
SentencesPage* sentences_
The Sentences tab, owned through Qt parenthood.
Declared in src/app/dialogs/settings_dialog.hpp:115
outputs_¶
OutputsPage* outputs_
The Outputs tab, owned through Qt parenthood.
Declared in src/app/dialogs/settings_dialog.hpp:117
error_label_¶
QLabel* error_label_
Word-wrapped line under the tabs with the reason the last accept was refused, drawn in the palette's highlight colour; hidden when there is none.
Declared in src/app/dialogs/settings_dialog.hpp:120