mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-09 11:06:01 +08:00
refactor(ui): Remove update times from settings
This settings is not documented and likely not used by any user.
This commit is contained in:
@@ -439,9 +439,6 @@ add_library(gui SHARED
|
||||
components/settingsvatsimreaderscomponent.cpp
|
||||
components/settingsvatsimreaderscomponent.h
|
||||
components/settingsvatsimreaderscomponent.ui
|
||||
components/settingsviewupdatetimes.cpp
|
||||
components/settingsviewupdatetimes.h
|
||||
components/settingsviewupdatetimes.ui
|
||||
components/settingsxswiftbuscomponent.cpp
|
||||
components/settingsxswiftbuscomponent.h
|
||||
components/settingsxswiftbuscomponent.ui
|
||||
@@ -761,8 +758,6 @@ add_library(gui SHARED
|
||||
settings/textmessagesettings.cpp
|
||||
settings/textmessagesettings.h
|
||||
settings/updatenotification.h
|
||||
settings/viewupdatesettings.cpp
|
||||
settings/viewupdatesettings.h
|
||||
sharedstringlistcompleter.cpp
|
||||
sharedstringlistcompleter.h
|
||||
shortcut.cpp
|
||||
|
||||
@@ -58,7 +58,9 @@ namespace swift::gui::components
|
||||
&CAircraftComponent::onOwnAircraftMoved, Qt::QueuedConnection);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CAircraftComponent::update);
|
||||
|
||||
this->onSettingsChanged();
|
||||
using namespace std::chrono_literals;
|
||||
m_updateTimer.setInterval(10s);
|
||||
|
||||
m_updateTimer.start();
|
||||
}
|
||||
|
||||
@@ -149,13 +151,6 @@ namespace swift::gui::components
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftComponent::onSettingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = m_settings.get();
|
||||
const int ms = settings.getAircraftUpdateTime().toMs();
|
||||
m_updateTimer.setInterval(ms);
|
||||
}
|
||||
|
||||
void CAircraftComponent::onOwnAircraftMoved(const CLength &distance)
|
||||
{
|
||||
Q_UNUSED(distance)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "gui/enablefordockwidgetinfoarea.h"
|
||||
#include "gui/settings/viewupdatesettings.h"
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/network/connectionstatus.h"
|
||||
|
||||
@@ -88,16 +87,10 @@ namespace swift::gui
|
||||
void onConnectionStatusChanged(const swift::misc::network::CConnectionStatus &from,
|
||||
const swift::misc::network::CConnectionStatus &to);
|
||||
|
||||
//! Settings have been changed
|
||||
void onSettingsChanged();
|
||||
|
||||
//! Own aircraft has been moved
|
||||
void onOwnAircraftMoved(const swift::misc::physical_quantities::CLength &distance);
|
||||
|
||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||
swift::misc::CSettingReadOnly<swift::gui::settings::TViewUpdateSettings> m_settings {
|
||||
this, &CAircraftComponent::onSettingsChanged
|
||||
}; //!< settings changed
|
||||
QTimer m_updateTimer;
|
||||
int m_updateCounter = 0;
|
||||
};
|
||||
|
||||
@@ -152,8 +152,8 @@ namespace swift::gui::components
|
||||
this->airportsRead();
|
||||
}
|
||||
|
||||
// init settings
|
||||
this->settingsChanged();
|
||||
using namespace std::chrono_literals;
|
||||
m_updateTimer.setInterval(10ms);
|
||||
}
|
||||
|
||||
CAtcStationComponent::~CAtcStationComponent() {}
|
||||
@@ -329,22 +329,6 @@ namespace swift::gui::components
|
||||
sGui->getIContextOwnAircraft()->updateActiveComFrequency(frequency, unit, identifier());
|
||||
}
|
||||
|
||||
void CAtcStationComponent::settingsChanged()
|
||||
{
|
||||
if (!this->canAccessContext()) { return; }
|
||||
const CViewUpdateSettings settings = m_settingsView.get();
|
||||
const int ms = settings.getAtcUpdateTime().toMs();
|
||||
const bool connected = sGui->getIContextNetwork()->isConnected();
|
||||
m_updateTimer.setInterval(ms);
|
||||
if (connected)
|
||||
{
|
||||
m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc();
|
||||
m_updateTimer.start(ms); // restart
|
||||
this->update();
|
||||
}
|
||||
else { m_updateTimer.stop(); }
|
||||
}
|
||||
|
||||
void CAtcStationComponent::airportsRead() { this->initCompleters(); }
|
||||
|
||||
void CAtcStationComponent::updateTreeView()
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "gui/overlaymessagesframe.h"
|
||||
#include "gui/settings/viewupdatesettings.h"
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/aviation/atcstation.h"
|
||||
#include "misc/aviation/comsystem.h"
|
||||
@@ -130,9 +129,6 @@ namespace swift::gui
|
||||
//! Init the completers
|
||||
void initCompleters();
|
||||
|
||||
//! Settings have been changed
|
||||
void settingsChanged();
|
||||
|
||||
//! Contexts?
|
||||
bool canAccessContext() const;
|
||||
|
||||
@@ -154,9 +150,6 @@ namespace swift::gui
|
||||
swift::misc::aviation::CCallsign m_selectedCallsign;
|
||||
QDateTime m_timestampLastReadOnlineStations; //!< stations read
|
||||
QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed
|
||||
swift::misc::CSettingReadOnly<swift::gui::settings::TViewUpdateSettings> m_settingsView {
|
||||
this, &CAtcStationComponent::settingsChanged
|
||||
};
|
||||
};
|
||||
} // namespace components
|
||||
} // namespace swift::gui
|
||||
|
||||
@@ -71,8 +71,6 @@ namespace swift::gui::components
|
||||
!CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsGuiGeneral.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsDockWidget,
|
||||
!CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsDockWidget.getFilename()));
|
||||
readOnlyCheckbox(ui->cb_SettingsViewUpdate,
|
||||
!CCacheSettingsUtils::hasOtherVersionSettingsFile(info, m_settingsViewUpdate.getFilename()));
|
||||
|
||||
readOnlyCheckbox(ui->cb_SettingsEnabledSimulators, !CCacheSettingsUtils::hasOtherVersionSettingsFile(
|
||||
info, m_settingsEnabledSimulators.getFilename()));
|
||||
@@ -124,7 +122,6 @@ namespace swift::gui::components
|
||||
{
|
||||
ui->cb_SettingsGuiGeneral->setText(checkBoxText(TGeneralGui::humanReadable(), true));
|
||||
ui->cb_SettingsDockWidget->setText(checkBoxText(TDockWidget::humanReadable(), true));
|
||||
ui->cb_SettingsViewUpdate->setText(checkBoxText(TViewUpdateSettings::humanReadable(), true));
|
||||
}
|
||||
|
||||
void CCopySettingsAndCachesComponent::initSimulator()
|
||||
@@ -294,19 +291,6 @@ namespace swift::gui::components
|
||||
}
|
||||
}
|
||||
|
||||
if (ui->cb_SettingsViewUpdate->isChecked())
|
||||
{
|
||||
const QString joStr = CCacheSettingsUtils::otherVersionSettingsFileContent(
|
||||
otherVersionInfo, m_settingsViewUpdate.getFilename());
|
||||
if (!joStr.isEmpty())
|
||||
{
|
||||
const CViewUpdateSettings viewUpdate =
|
||||
CViewUpdateSettings::fromJsonNoThrow(joStr, true, success, errMsg);
|
||||
this->displayStatusMessage(m_settingsViewUpdate.setAndSave(viewUpdate), viewUpdate.toQString(true));
|
||||
copied++;
|
||||
}
|
||||
}
|
||||
|
||||
// ------- sims -------
|
||||
if (ui->cb_SettingsEnabledSimulators->isChecked())
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "gui/settings/dockwidgetsettings.h"
|
||||
#include "gui/settings/guisettings.h"
|
||||
#include "gui/settings/textmessagesettings.h"
|
||||
#include "gui/settings/viewupdatesettings.h"
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/applicationinfo.h"
|
||||
#include "misc/audio/audiosettings.h"
|
||||
@@ -113,7 +112,6 @@ namespace swift::gui::components
|
||||
swift::misc::CSetting<swift::core::audio::TOutputDevice> m_settingsAudioOutputDevice { this };
|
||||
swift::misc::CSetting<settings::TGeneralGui> m_settingsGuiGeneral { this };
|
||||
swift::misc::CSetting<settings::TDockWidget> m_settingsDockWidget { this };
|
||||
swift::misc::CSetting<settings::TViewUpdateSettings> m_settingsViewUpdate { this };
|
||||
swift::misc::CSetting<settings::TBackgroundConsolidation> m_settingsConsolidation {
|
||||
this
|
||||
}; //!< consolidation time
|
||||
|
||||
@@ -300,13 +300,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SettingsViewUpdate">
|
||||
<property name="text">
|
||||
<string>UI3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -124,7 +124,9 @@ namespace swift::gui::components
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CMappingComponent::timerUpdate);
|
||||
m_updateTimer.setObjectName(this->objectName() + "::updateTimer");
|
||||
ui->tvp_AircraftModels->setDisplayAutomatically(false);
|
||||
this->settingsChanged();
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
m_updateTimer.setInterval(10s);
|
||||
|
||||
// selector
|
||||
ui->comp_SimulatorSelector->setRememberSelection(false); // pilot client UI
|
||||
@@ -563,13 +565,6 @@ namespace swift::gui::components
|
||||
this->updateRenderedAircraftView(true); // forced update
|
||||
}
|
||||
|
||||
void CMappingComponent::settingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = m_settings.get();
|
||||
const int ms = settings.getRenderingUpdateTime().toMs();
|
||||
m_updateTimer.setInterval(ms);
|
||||
}
|
||||
|
||||
void CMappingComponent::onNetworkConnectionStatusChanged(const CConnectionStatus &from, const CConnectionStatus &to)
|
||||
{
|
||||
Q_UNUSED(from);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include "gui/enablefordockwidgetinfoarea.h"
|
||||
#include "gui/overlaymessagesframe.h"
|
||||
#include "gui/settings/viewupdatesettings.h"
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/identifiable.h"
|
||||
#include "misc/identifier.h"
|
||||
@@ -161,9 +160,6 @@ namespace swift::gui
|
||||
//! Token bucket based update
|
||||
void tokenBucketUpdateAircraft(const swift::misc::simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Settings have been changed
|
||||
void settingsChanged();
|
||||
|
||||
//! Connection status has been changed
|
||||
void onNetworkConnectionStatusChanged(const swift::misc::network::CConnectionStatus &from,
|
||||
const swift::misc::network::CConnectionStatus &to);
|
||||
@@ -191,9 +187,6 @@ namespace swift::gui
|
||||
QTimer m_updateTimer;
|
||||
bool m_missedRenderedAircraftUpdate = true; //! Rendered aircraft need update
|
||||
swift::misc::CTokenBucket m_bucket { 3, 5000, 1 };
|
||||
swift::misc::CSettingReadOnly<settings::TViewUpdateSettings> m_settings {
|
||||
this, &CMappingComponent::settingsChanged
|
||||
}; //!< settings changed
|
||||
views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr; //! checkbox in view
|
||||
};
|
||||
} // namespace components
|
||||
|
||||
@@ -272,9 +272,6 @@
|
||||
<item>
|
||||
<widget class="swift::gui::components::CSettingsGuiComponent" name="comp_SettingsGuiGeneral"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="swift::gui::components::CSettingsViewUpdateTimes" name="comp_SettingsGuiRefreshTimes"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="qw_SettingsGuiFont" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_SettingsGuiFontColor">
|
||||
@@ -692,12 +689,6 @@
|
||||
<header>gui/components/settingssimulatormessagescomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>swift::gui::components::CSettingsViewUpdateTimes</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>gui/components/settingsviewupdatetimes.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>swift::gui::components::CSettingsMatchingComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "settingsviewupdatetimes.h"
|
||||
|
||||
#include "ui_settingsviewupdatetimes.h"
|
||||
|
||||
using namespace swift::gui::settings;
|
||||
using namespace swift::misc::physical_quantities;
|
||||
|
||||
namespace swift::gui::components
|
||||
{
|
||||
CSettingsViewUpdateTimes::CSettingsViewUpdateTimes(QWidget *parent)
|
||||
: QFrame(parent), ui(new Ui::CSettingsViewUpdateTimes)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->hs_RenderingUpdateTime, &QSlider::sliderReleased, this,
|
||||
&CSettingsViewUpdateTimes::ps_sliderChanged);
|
||||
connect(ui->hs_AircraftUpdateTime, &QSlider::sliderReleased, this, &CSettingsViewUpdateTimes::ps_sliderChanged);
|
||||
connect(ui->hs_AtcUpdateTime, &QSlider::sliderReleased, this, &CSettingsViewUpdateTimes::ps_sliderChanged);
|
||||
connect(ui->hs_UserUpdateTime, &QSlider::sliderReleased, this, &CSettingsViewUpdateTimes::ps_sliderChanged);
|
||||
connect(ui->tb_ResetUser, &QToolButton::clicked, this, &CSettingsViewUpdateTimes::ps_resetUpdateTimes);
|
||||
|
||||
this->ps_settingsChanged();
|
||||
}
|
||||
|
||||
CSettingsViewUpdateTimes::~CSettingsViewUpdateTimes() {}
|
||||
|
||||
void CSettingsViewUpdateTimes::ps_sliderChanged()
|
||||
{
|
||||
CViewUpdateSettings settings;
|
||||
settings.setAircraftUpdateTime(CTime(ui->hs_AircraftUpdateTime->value(), CTimeUnit::s()));
|
||||
settings.setAtcUpdateTime(CTime(ui->hs_AtcUpdateTime->value(), CTimeUnit::s()));
|
||||
settings.setRenderingUpdateTime(CTime(ui->hs_RenderingUpdateTime->value(), CTimeUnit::s()));
|
||||
settings.setUserUpdateTime(CTime(ui->hs_UserUpdateTime->value(), CTimeUnit::s()));
|
||||
m_settings.setAndSave(settings);
|
||||
}
|
||||
|
||||
void CSettingsViewUpdateTimes::ps_settingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings(this->m_settings.get());
|
||||
ui->hs_AircraftUpdateTime->setValue(settings.getAircraftUpdateTime().toSeconds());
|
||||
ui->hs_AtcUpdateTime->setValue(settings.getAtcUpdateTime().toSeconds());
|
||||
ui->hs_RenderingUpdateTime->setValue(settings.getRenderingUpdateTime().toSeconds());
|
||||
ui->hs_UserUpdateTime->setValue(settings.getUserUpdateTime().toSeconds());
|
||||
}
|
||||
|
||||
void CSettingsViewUpdateTimes::ps_resetUpdateTimes()
|
||||
{
|
||||
CViewUpdateSettings settings;
|
||||
m_settings.setAndSave(settings);
|
||||
this->ps_settingsChanged();
|
||||
}
|
||||
} // namespace swift::gui::components
|
||||
@@ -1,51 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef SWIFT_GUI_COMPONENTS_SETTINGSVIEWUPDATETIMES_H
|
||||
#define SWIFT_GUI_COMPONENTS_SETTINGSVIEWUPDATETIMES_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include "gui/settings/viewupdatesettings.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CSettingsViewUpdateTimes;
|
||||
}
|
||||
namespace swift::gui::components
|
||||
{
|
||||
/*!
|
||||
* Update rates / times
|
||||
*/
|
||||
class CSettingsViewUpdateTimes : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CSettingsViewUpdateTimes(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSettingsViewUpdateTimes();
|
||||
|
||||
private slots:
|
||||
//! Slider changed
|
||||
void ps_sliderChanged();
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_settingsChanged();
|
||||
|
||||
//! Reset all update times
|
||||
void ps_resetUpdateTimes();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSettingsViewUpdateTimes> ui;
|
||||
swift::misc::CSetting<swift::gui::settings::TViewUpdateSettings> m_settings {
|
||||
this, &CSettingsViewUpdateTimes::ps_settingsChanged
|
||||
}; //!< settings changed
|
||||
};
|
||||
} // namespace swift::gui::components
|
||||
|
||||
#endif // SWIFT_GUI_COMPONENTS_SETTINGSVIEWUPDATETIMES_H
|
||||
@@ -1,213 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsViewUpdateTimes</class>
|
||||
<widget class="QFrame" name="CSettingsViewUpdateTimes">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>304</width>
|
||||
<height>77</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_UpdateTimes">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_ViewUpdateTimes">
|
||||
<property name="title">
|
||||
<string>View update times</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_ViewUpdateTimes">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSlider" name="hs_AtcUpdateTime">
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QToolButton" name="tb_ResetUser">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../misc/misc.qrc">
|
||||
<normaloff>:/pastel/icons/pastel/16/arrow-refresh-small.png</normaloff>:/pastel/icons/pastel/16/arrow-refresh-small.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="lbl_UserUpdateTime">
|
||||
<property name="toolTip">
|
||||
<string>User update time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QSlider" name="hs_UserUpdateTime">
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftUpdateTime">
|
||||
<property name="toolTip">
|
||||
<string>Aircraft update time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Aircraft</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="hs_AircraftUpdateTime">
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSlider" name="hs_RenderingUpdateTime">
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_RenderingUpdateTime">
|
||||
<property name="toolTip">
|
||||
<string>Rendering update time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rendering</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_AtcUpdateTime">
|
||||
<property name="toolTip">
|
||||
<string>ATC update time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ATC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>lbl_AircraftUpdateTime</zorder>
|
||||
<zorder>hs_AircraftUpdateTime</zorder>
|
||||
<zorder>lbl_RenderingUpdateTime</zorder>
|
||||
<zorder>hs_RenderingUpdateTime</zorder>
|
||||
<zorder>lbl_AtcUpdateTime</zorder>
|
||||
<zorder>hs_AtcUpdateTime</zorder>
|
||||
<zorder>lbl_UserUpdateTime</zorder>
|
||||
<zorder>hs_UserUpdateTime</zorder>
|
||||
<zorder>tb_ResetUser</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../misc/misc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -39,7 +39,9 @@ namespace swift::gui::components
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this,
|
||||
&CUserComponent::onConnectionStatusChanged);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CUserComponent::update);
|
||||
this->onSettingsChanged();
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
m_updateTimer.setInterval(10s);
|
||||
}
|
||||
|
||||
CUserComponent::~CUserComponent() {}
|
||||
@@ -103,11 +105,4 @@ namespace swift::gui::components
|
||||
}
|
||||
else if (to.isConnected()) { m_updateTimer.start(); }
|
||||
}
|
||||
|
||||
void CUserComponent::onSettingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = m_settings.get();
|
||||
const int ms = settings.getAtcUpdateTime().toMs();
|
||||
m_updateTimer.setInterval(ms);
|
||||
}
|
||||
} // namespace swift::gui::components
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "gui/enablefordockwidgetinfoarea.h"
|
||||
#include "gui/settings/viewupdatesettings.h"
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/aviation/callsign.h"
|
||||
#include "misc/network/connectionstatus.h"
|
||||
@@ -57,14 +56,8 @@ namespace swift::gui::components
|
||||
void onConnectionStatusChanged(const swift::misc::network::CConnectionStatus &from,
|
||||
const swift::misc::network::CConnectionStatus &to);
|
||||
|
||||
//! Settings have been changed
|
||||
void onSettingsChanged();
|
||||
|
||||
QScopedPointer<Ui::CUserComponent> ui;
|
||||
QTimer m_updateTimer;
|
||||
swift::misc::CSettingReadOnly<swift::gui::settings::TViewUpdateSettings> m_settings {
|
||||
this, &CUserComponent::onSettingsChanged
|
||||
};
|
||||
};
|
||||
} // namespace swift::gui::components
|
||||
#endif // SWIFT_GUI_USERCOMPONENT_H
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "gui/settings/guisettings.h"
|
||||
#include "gui/settings/navigatorsettings.h"
|
||||
#include "gui/settings/textmessagesettings.h"
|
||||
#include "gui/settings/viewupdatesettings.h"
|
||||
|
||||
namespace swift::gui
|
||||
{
|
||||
@@ -16,7 +15,6 @@ namespace swift::gui
|
||||
{
|
||||
swift::gui::settings::CDockWidgetSettings::registerMetadata();
|
||||
swift::gui::settings::CNavigatorSettings::registerMetadata();
|
||||
swift::gui::settings::CViewUpdateSettings::registerMetadata();
|
||||
swift::gui::settings::CGeneralGuiSettings::registerMetadata();
|
||||
swift::gui::settings::CTextMessageSettings::registerMetadata();
|
||||
swift::gui::components::registerMetadata();
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "viewupdatesettings.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include "gui/guiutility.h"
|
||||
#include "misc/stringutils.h"
|
||||
|
||||
using namespace swift::misc;
|
||||
using namespace swift::misc::physical_quantities;
|
||||
using namespace swift::gui;
|
||||
|
||||
SWIFT_DEFINE_VALUEOBJECT_MIXINS(swift::gui::settings, CViewUpdateSettings)
|
||||
|
||||
namespace swift::gui::settings
|
||||
{
|
||||
CViewUpdateSettings::CViewUpdateSettings() {}
|
||||
|
||||
void CViewUpdateSettings::reset()
|
||||
{
|
||||
this->m_updateAircraft = CTime(10.0, CTimeUnit::s());
|
||||
this->m_updateAtc = CTime(10.0, CTimeUnit::s());
|
||||
this->m_updateRendering = CTime(10.0, CTimeUnit::s());
|
||||
this->m_updateUser = CTime(10.0, CTimeUnit::s());
|
||||
}
|
||||
|
||||
bool CViewUpdateSettings::isValid() const
|
||||
{
|
||||
// too fast updates cause CPU overload
|
||||
static const CTime min(5.0, CTimeUnit::s());
|
||||
return this->m_updateAircraft >= min && this->m_updateAtc >= min && this->m_updateRendering >= min &&
|
||||
this->m_updateUser >= min;
|
||||
}
|
||||
|
||||
QString CViewUpdateSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
const QString s("Atc: %1 Aircraft: %2 User: %3 Rendering %4");
|
||||
return s.arg(m_updateAtc.valueRounded(CTimeUnit::s(), 2))
|
||||
.arg(m_updateAircraft.valueRounded(CTimeUnit::s(), 2))
|
||||
.arg(m_updateUser.valueRounded(CTimeUnit::s(), 2))
|
||||
.arg(m_updateRendering.valueRounded(CTimeUnit::s(), 2));
|
||||
}
|
||||
|
||||
QVariant CViewUpdateSettings::propertyByIndex(CPropertyIndexRef index) const
|
||||
{
|
||||
if (index.isMyself()) { return QVariant::fromValue(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraft: return QVariant::fromValue(this->m_updateAircraft);
|
||||
case IndexAtc: return QVariant::fromValue(this->m_updateAtc);
|
||||
case IndexRendering: return QVariant::fromValue(this->m_updateRendering);
|
||||
case IndexUser: return QVariant::fromValue(this->m_updateUser);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CViewUpdateSettings::setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
|
||||
{
|
||||
if (index.isMyself())
|
||||
{
|
||||
(*this) = variant.value<CViewUpdateSettings>();
|
||||
return;
|
||||
}
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraft: this->m_updateAircraft = variant.value<CTime>(); break;
|
||||
case IndexAtc: this->m_updateAtc = variant.value<CTime>(); break;
|
||||
case IndexRendering: this->m_updateRendering = variant.value<CTime>(); break;
|
||||
case IndexUser: this->m_updateUser = variant.value<CTime>(); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
} // namespace swift::gui::settings
|
||||
@@ -1,121 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef SWIFT_GUI_SETTINGS_VIEWUPDATESETTINGS_H
|
||||
#define SWIFT_GUI_SETTINGS_VIEWUPDATESETTINGS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
#include "gui/swiftguiexport.h"
|
||||
#include "misc/pq/time.h"
|
||||
#include "misc/propertyindex.h"
|
||||
#include "misc/settingscache.h"
|
||||
#include "misc/variant.h"
|
||||
|
||||
SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::gui::settings, CViewUpdateSettings)
|
||||
|
||||
namespace swift::gui::settings
|
||||
{
|
||||
//! Settings about view update rates
|
||||
class SWIFT_GUI_EXPORT CViewUpdateSettings : public swift::misc::CValueObject<CViewUpdateSettings>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexAtc = swift::misc::CPropertyIndexRef::GlobalIndexCViewUpdateSettings,
|
||||
IndexAircraft,
|
||||
IndexRendering,
|
||||
IndexUser
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CViewUpdateSettings();
|
||||
|
||||
//! Reset to defaults
|
||||
void reset();
|
||||
|
||||
//! Get time
|
||||
const swift::misc::physical_quantities::CTime &getAtcUpdateTime() const { return m_updateAtc; }
|
||||
|
||||
//! Set time
|
||||
void setAtcUpdateTime(const swift::misc::physical_quantities::CTime &time) { this->m_updateAtc = time; }
|
||||
|
||||
//! Get time
|
||||
const swift::misc::physical_quantities::CTime &getAircraftUpdateTime() const { return m_updateAircraft; }
|
||||
|
||||
//! Set time
|
||||
void setAircraftUpdateTime(const swift::misc::physical_quantities::CTime &time)
|
||||
{
|
||||
this->m_updateAircraft = time;
|
||||
}
|
||||
|
||||
//! Get time
|
||||
const swift::misc::physical_quantities::CTime &getUserUpdateTime() const { return m_updateUser; }
|
||||
|
||||
//! Set time
|
||||
void setUserUpdateTime(const swift::misc::physical_quantities::CTime &time) { this->m_updateUser = time; }
|
||||
|
||||
//! Get time
|
||||
const swift::misc::physical_quantities::CTime &getRenderingUpdateTime() const { return m_updateRendering; }
|
||||
|
||||
//! Set time
|
||||
void setRenderingUpdateTime(const swift::misc::physical_quantities::CTime &time)
|
||||
{
|
||||
this->m_updateRendering = time;
|
||||
}
|
||||
|
||||
//! Valid?
|
||||
bool isValid() const;
|
||||
|
||||
//! \copydoc swift::misc::mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc swift::misc::mixin::Index::propertyByIndex
|
||||
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
|
||||
|
||||
//! \copydoc swift::misc::mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
|
||||
|
||||
private:
|
||||
swift::misc::physical_quantities::CTime m_updateAtc { 10.0, swift::misc::physical_quantities::CTimeUnit::s() };
|
||||
swift::misc::physical_quantities::CTime m_updateAircraft { 10.0,
|
||||
swift::misc::physical_quantities::CTimeUnit::s() };
|
||||
swift::misc::physical_quantities::CTime m_updateRendering { 10.0,
|
||||
swift::misc::physical_quantities::CTimeUnit::s() };
|
||||
swift::misc::physical_quantities::CTime m_updateUser { 10.0, swift::misc::physical_quantities::CTimeUnit::s() };
|
||||
|
||||
SWIFT_METACLASS(
|
||||
CViewUpdateSettings,
|
||||
SWIFT_METAMEMBER(updateAtc),
|
||||
SWIFT_METAMEMBER(updateAircraft),
|
||||
SWIFT_METAMEMBER(updateRendering),
|
||||
SWIFT_METAMEMBER(updateUser));
|
||||
};
|
||||
|
||||
//! Trait for settings about update rates
|
||||
struct TViewUpdateSettings : public swift::misc::TSettingTrait<CViewUpdateSettings>
|
||||
{
|
||||
//! \copydoc swift::misc::TSettingTrait::key
|
||||
static const char *key() { return "guiviewupdate"; }
|
||||
|
||||
//! \copydoc swift::misc::TSettingTrait::humanReadable
|
||||
static const QString &humanReadable()
|
||||
{
|
||||
static const QString name("View update");
|
||||
return name;
|
||||
}
|
||||
|
||||
//! \copydoc swift::misc::TSettingTrait::isValid
|
||||
static bool isValid(const CViewUpdateSettings &settings, QString &) { return settings.isValid(); }
|
||||
};
|
||||
} // namespace swift::gui::settings
|
||||
|
||||
Q_DECLARE_METATYPE(swift::gui::settings::CViewUpdateSettings)
|
||||
Q_DECLARE_METATYPE(swift::misc::CCollection<swift::gui::settings::CViewUpdateSettings>)
|
||||
|
||||
#endif // SWIFT_GUI_SETTINGS_VIEWUPDATESETTINGS_H
|
||||
Reference in New Issue
Block a user