swift
settingscomponent.cpp
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 #include <QAction>
7 #include <QComboBox>
8 #include <QLineEdit>
9 #include <QTabBar>
10 #include <QToolButton>
11 #include <QtGlobal>
12 
13 #include "ui_settingscomponent.h"
14 
15 #include "config/buildconfig.h"
17 #include "gui/guiapplication.h"
18 
19 using namespace swift::misc;
20 using namespace swift::misc::network;
21 using namespace swift::misc::aviation;
22 using namespace swift::misc::audio;
23 using namespace swift::misc::physical_quantities;
24 using namespace swift::misc::input;
25 using namespace swift::misc::simulation;
26 using namespace swift::misc::simulation::settings;
27 using namespace swift::core;
28 using namespace swift::gui;
29 using namespace swift::config;
30 
31 namespace swift::gui::components
32 {
33  CSettingsComponent::CSettingsComponent(QWidget *parent) : QTabWidget(parent), ui(new Ui::CSettingsComponent)
34  {
35  ui->setupUi(this);
36 
37  this->tabBar()->setExpanding(false);
38  this->tabBar()->setUsesScrollButtons(true);
39  this->setCurrentIndex(0); // 1st tab
40  ui->comp_DataLoadOverview->showVisibleDbRefreshButtons(CBuildConfig::isDebugBuild() ||
42  ui->comp_DataLoadOverview->showVisibleLoadAllButtons(false, false, false);
43 
44  connect(ui->comp_SettingsGuiGeneral, &CSettingsGuiComponent::changedWindowsOpacity, this,
46  connect(ui->pb_Advanced, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
47  connect(ui->pb_Audio, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
48  connect(ui->pb_Gui, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
49  connect(ui->pb_Hotkeys, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
50  connect(ui->pb_Network, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
51  connect(ui->pb_Servers, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
52  connect(ui->pb_Simulator, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
53  connect(ui->pb_SimulatorBasics, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
54  connect(ui->pb_SimulatorMessages, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
55  connect(ui->pb_Matching, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
56  connect(ui->pb_DataLoadAndCaches, &QPushButton::released, this, &CSettingsComponent::onOverviewButtonClicked);
57  }
58 
60  default; // declared in cpp to avoid incomplete type of Ui::CSettingsComponent
61 
63  {
64  return ui->comp_SettingsSimulatorBasics->getSimulatorSettings(simulator);
65  }
66 
68  {
69  this->setCurrentIndex(static_cast<int>(tab));
70  }
71 
72  void CSettingsComponent::setSettingsOverviewTab() { this->setTab(SettingTabOverview); }
73 
74  void CSettingsComponent::setGuiOpacity(double value) { ui->comp_SettingsGuiGeneral->setGuiOpacity(value); }
75 
76  void CSettingsComponent::onOverviewButtonClicked()
77  {
78  const QObject *sender = QObject::sender();
79  if (sender == ui->pb_Advanced)
80  {
81  this->setCurrentIndex(SettingTabAdvanced);
82  return;
83  }
84  if (sender == ui->pb_Audio)
85  {
86  this->setCurrentIndex(SettingTabAudio);
87  return;
88  }
89  if (sender == ui->pb_Gui)
90  {
91  this->setCurrentIndex(SettingTabGui);
92  return;
93  }
94  if (sender == ui->pb_Hotkeys)
95  {
96  this->setCurrentIndex(SettingTabHotkeys);
97  return;
98  }
99  if (sender == ui->pb_Network)
100  {
101  this->setCurrentIndex(SettingTabNetwork);
102  return;
103  }
104  if (sender == ui->pb_Servers)
105  {
106  this->setCurrentIndex(SettingTabServers);
107  return;
108  }
109  if (sender == ui->pb_Simulator)
110  {
111  this->setCurrentIndex(SettingTabSimulator);
112  return;
113  }
114  if (sender == ui->pb_SimulatorBasics)
115  {
116  this->setCurrentIndex(SettingTabSimulatorBasics);
117  return;
118  }
119  if (sender == ui->pb_DataLoadAndCaches)
120  {
121  this->setCurrentIndex(SettingTabDataAndCaches);
122  return;
123  }
124  if (sender == ui->pb_SimulatorMessages)
125  {
126  this->setCurrentIndex(SettingTabSimulatorMessages);
127  return;
128  }
129  if (sender == ui->pb_Matching)
130  {
131  this->setCurrentIndex(SettingTabMatching);
132  return;
133  }
134  this->setCurrentIndex(SettingTabOverview);
135  }
136 } // namespace swift::gui::components
bool isDeveloperFlagSet() const
Running with dev.flag?
Definition: application.h:173
swift::misc::simulation::settings::CSpecializedSimulatorSettings getSimulatorSettings(const swift::misc::simulation::CSimulatorInfo &simulator) const
Settings for given simulator.
void setSettingsOverviewTab()
Set the overview tab.
void setGuiOpacity(double value)
GUI Opacity 0-100%.
void setTab(SettingTab tab)
Set the tab.
void changedWindowsOpacity(int opacity)
Change the windows opacity 0..100.
void changedWindowsOpacity(int opacity)
Change the windows opacity 0..100.
Simple hardcoded info about the corresponding simulator.
Definition: simulatorinfo.h:41
Allows to have specific utility functions for each simulator.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
Definition: actionbind.cpp:7
High level reusable GUI components.
Definition: aboutdialog.cpp:13
GUI related classes.
Free functions in swift::misc.