mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #799, changed components to use settings
* removed update timer * Removed getter/setters for update times * used UI component for settings in main settings component
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Settings;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Context;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -36,11 +37,9 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
CAircraftComponent::CAircraftComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
ui(new Ui::CAircraftComponent),
|
||||
m_updateTimer(new CUpdateTimer("CAircraftComponent", &CAircraftComponent::update, this))
|
||||
ui(new Ui::CAircraftComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->tabBar()->setExpanding(false);
|
||||
@@ -55,6 +54,9 @@ namespace BlackGui
|
||||
connect(ui->tvp_AircraftInRange, &CSimulatedAircraftView::requestHighlightInSimulator, this, &CAircraftComponent::ps_onMenuHighlightInSimulator);
|
||||
connect(ui->tvp_AirportsInRange, &CSimulatedAircraftView::modelDataChanged, this, &CAircraftComponent::ps_onRowCountChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::ps_connectionStatusChanged);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CAircraftComponent::update);
|
||||
|
||||
this->ps_settingsChanged();
|
||||
}
|
||||
|
||||
CAircraftComponent::~CAircraftComponent()
|
||||
@@ -137,6 +139,11 @@ namespace BlackGui
|
||||
if (INetwork::isDisconnectedStatus(to))
|
||||
{
|
||||
ui->tvp_AircraftInRange->clear();
|
||||
this->m_updateTimer.stop();
|
||||
}
|
||||
else if (INetwork::isConnectedStatus(to))
|
||||
{
|
||||
this->m_updateTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,5 +155,11 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftComponent::ps_settingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = this->m_settings.get();
|
||||
this->m_updateTimer.setInterval(settings.getAircraftUpdateTime().toMs());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
|
||||
#include "blackcore/network.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QTabWidget>
|
||||
#include <QtGlobal>
|
||||
#include <QTimer>
|
||||
|
||||
class QWidget;
|
||||
|
||||
@@ -30,11 +31,9 @@ namespace BlackMisc
|
||||
namespace Simulation { class CSimulatedAircraft; }
|
||||
}
|
||||
namespace Ui { class CAircraftComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
class CDockWidgetInfoArea;
|
||||
|
||||
namespace Components
|
||||
{
|
||||
//! Aircraft widget
|
||||
@@ -65,15 +64,9 @@ namespace BlackGui
|
||||
void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
public slots:
|
||||
//! Update aircrafts
|
||||
//! Update aircraft
|
||||
void update();
|
||||
|
||||
//! \copydoc CUpdateTimer::setUpdateIntervalSeconds
|
||||
void setUpdateIntervalSeconds(int seconds) { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->setUpdateIntervalSeconds(seconds); }
|
||||
|
||||
//! \copydoc CUpdateTimer::stopTimer
|
||||
void stopTimer() { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->stopTimer(); }
|
||||
|
||||
private slots:
|
||||
//! Info area tab bar has changed
|
||||
void ps_infoAreaTabBarChanged(int index);
|
||||
@@ -87,9 +80,13 @@ namespace BlackGui
|
||||
//! Highlight in simulator
|
||||
void ps_onMenuHighlightInSimulator(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_settingsChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAircraftComponent::ps_settingsChanged }; //!< settings changed
|
||||
QTimer m_updateTimer { this };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Settings;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -52,8 +53,7 @@ namespace BlackGui
|
||||
CAtcStationComponent::CAtcStationComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
CIdentifiable(this),
|
||||
ui(new Ui::CAtcStationComponent),
|
||||
m_updateTimer(new CUpdateTimer("CAtcStationComponent", &CAtcStationComponent::update, this))
|
||||
ui(new Ui::CAtcStationComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->tabBar()->setExpanding(false);
|
||||
@@ -90,12 +90,16 @@ namespace BlackGui
|
||||
connect(ui->tvp_AtcStationsBooked, &CAtcStationView::modelDataChanged, this, &CAtcStationComponent::ps_onCountChanged);
|
||||
|
||||
connect(ui->pb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::ps_requestAtis);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update);
|
||||
|
||||
// runtime based connects
|
||||
this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::ps_changedAtcStationsOnline);
|
||||
this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::ps_changedAtcStationsBooked);
|
||||
this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus);
|
||||
this->connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::ps_connectionStatusChanged);
|
||||
|
||||
// settings have
|
||||
this->ps_settingsChanged();
|
||||
}
|
||||
|
||||
CAtcStationComponent::~CAtcStationComponent()
|
||||
@@ -232,6 +236,11 @@ namespace BlackGui
|
||||
{
|
||||
ui->tvp_AtcStationsOnline->clear();
|
||||
this->updateTreeView();
|
||||
this->m_updateTimer.start();
|
||||
}
|
||||
else if (INetwork::isConnectedStatus(to))
|
||||
{
|
||||
this->m_updateTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,8 +254,8 @@ namespace BlackGui
|
||||
|
||||
void CAtcStationComponent::ps_requestOnlineStationsUpdate()
|
||||
{
|
||||
this->m_updateTimer->fireTimer();
|
||||
this->m_timestampLastReadOnlineStations = CUpdateTimer::epoch(); // mark as outdated
|
||||
this->m_timestampLastReadOnlineStations.setMSecsSinceEpoch(0); // mark as outdated
|
||||
this->update();
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_infoAreaTabBarChanged(int index)
|
||||
@@ -281,10 +290,15 @@ namespace BlackGui
|
||||
sGui->getIContextOwnAircraft()->updateActiveComFrequency(frequency, unit, identifier());
|
||||
}
|
||||
|
||||
void CAtcStationComponent::ps_settingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = this->m_settings.get();
|
||||
this->m_updateTimer.setInterval(settings.getAtcUpdateTime().toMs());
|
||||
}
|
||||
|
||||
void CAtcStationComponent::updateTreeView()
|
||||
{
|
||||
//
|
||||
//! \todo EXPERIMENTAL CODE: change model so we can directly use hierarchies
|
||||
//! \fixme EXPERIMENTAL CODE: change model so we can directly use hierarchies
|
||||
QAbstractItemModel *old = (ui->tvp_AtcStationsOnlineTree->model());
|
||||
ui->tvp_AtcStationsOnlineTree->setModel(
|
||||
ui->tvp_AtcStationsOnline->derivedModel()->toAtcGroupModel()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "blackcore/network.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackmisc/aviation/atcstation.h"
|
||||
#include "blackmisc/aviation/comsystem.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QString>
|
||||
#include <QTabWidget>
|
||||
#include <QtGlobal>
|
||||
#include <QTimer>
|
||||
|
||||
class QWidget;
|
||||
|
||||
@@ -36,7 +37,6 @@ namespace Ui { class CAtcStationComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
class CDockWidgetInfoArea;
|
||||
|
||||
namespace Components
|
||||
{
|
||||
//! ATC stations component
|
||||
@@ -71,12 +71,6 @@ namespace BlackGui
|
||||
//! Update stations
|
||||
void update();
|
||||
|
||||
//! \copydoc CUpdateTimer::setUpdateIntervalSeconds
|
||||
void setUpdateIntervalSeconds(int seconds) { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->setUpdateIntervalSeconds(seconds); }
|
||||
|
||||
//! \copydoc CUpdateTimer::stopTimer
|
||||
void stopTimer() { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->stopTimer(); }
|
||||
|
||||
//! Get METAR for given ICAO airport code
|
||||
void getMetar(const QString &airportIcaoCode);
|
||||
|
||||
@@ -123,14 +117,18 @@ namespace BlackGui
|
||||
//! Set COM frequency
|
||||
void ps_setComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit);
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_settingsChanged();
|
||||
|
||||
private:
|
||||
void updateTreeView();
|
||||
QScopedPointer<Ui::CAtcStationComponent> ui;
|
||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||
QDateTime m_timestampLastReadOnlineStations = CUpdateTimer::epoch(); //!< stations read
|
||||
QDateTime m_timestampOnlineStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed
|
||||
QDateTime m_timestampLastReadBookedStations = CUpdateTimer::epoch(); //!< stations read
|
||||
QDateTime m_timestampBookedStationsChanged = CUpdateTimer::epoch(); //!< stations marked as changed
|
||||
QTimer m_updateTimer { this };
|
||||
QDateTime m_timestampLastReadOnlineStations; //!< stations read
|
||||
QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed
|
||||
QDateTime m_timestampLastReadBookedStations; //!< stations read
|
||||
QDateTime m_timestampBookedStationsChanged; //!< stations marked as changed
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CAtcStationComponent::ps_settingsChanged };
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackgui/components/mappingcomponent.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/models/aircraftmodellistmodel.h"
|
||||
@@ -51,6 +50,7 @@ using namespace BlackGui;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Models;
|
||||
using namespace BlackGui::Filters;
|
||||
using namespace BlackGui::Settings;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -59,8 +59,7 @@ namespace BlackGui
|
||||
CMappingComponent::CMappingComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CIdentifiable(this),
|
||||
ui(new Ui::CMappingComponent),
|
||||
m_updateTimer(new CUpdateTimer("CMappingComponent", &CMappingComponent::ps_backgroundUpdate, this))
|
||||
ui(new Ui::CMappingComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tvp_AircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModel);
|
||||
@@ -100,7 +99,8 @@ namespace BlackGui
|
||||
|
||||
// Updates
|
||||
ui->tvp_AircraftModels->setDisplayAutomatically(false);
|
||||
this->m_updateTimer->setUpdateInterval(10 * 1000);
|
||||
this->ps_settingsChanged();
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CMappingComponent::ps_backgroundUpdate);
|
||||
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CMappingComponent::ps_onModelSetChanged);
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::modelMatchingCompleted, this, &CMappingComponent::ps_markRenderedAircraftForUpdate);
|
||||
@@ -441,5 +441,11 @@ namespace BlackGui
|
||||
this->updateRenderedAircraftView(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_settingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = this->m_settings.get();
|
||||
this->m_updateTimer.setInterval(settings.getAircraftUpdateTime().toMs());
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackcore/network.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
@@ -24,6 +25,7 @@
|
||||
#include <QFrame>
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
#include <Qt>
|
||||
|
||||
@@ -37,15 +39,11 @@ namespace BlackMisc
|
||||
namespace Simulation { class CSimulatedAircraft; }
|
||||
}
|
||||
namespace Ui { class CMappingComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views { class CCheckBoxDelegate; }
|
||||
|
||||
namespace Components
|
||||
{
|
||||
class CUpdateTimer;
|
||||
|
||||
//! Mappings, models etc.
|
||||
class BLACKGUI_EXPORT CMappingComponent :
|
||||
public QFrame,
|
||||
@@ -138,16 +136,19 @@ namespace BlackGui
|
||||
BlackMisc::Aviation::CCallsign validateRenderedCallsign() const;
|
||||
|
||||
QScopedPointer<Ui::CMappingComponent> ui;
|
||||
bool m_missedRenderedAircraftUpdate = true;
|
||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CMappingComponent::ps_settingsChanged }; //!< settings changed
|
||||
bool m_missedRenderedAircraftUpdate = true; //! Rendered aircraft need update
|
||||
QTimer m_updateTimer { this };
|
||||
BlackGui::Views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr;
|
||||
BlackMisc::CIdentifier m_identifier;
|
||||
|
||||
private slots:
|
||||
//! Updated by timer
|
||||
void ps_backgroundUpdate();
|
||||
};
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_settingsChanged();
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "blackcore/context/contextapplication.h"
|
||||
#include "blackgui/components/registercomponent.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/views/identifierview.h"
|
||||
#include "ui_registercomponent.h"
|
||||
@@ -25,12 +24,15 @@ namespace BlackGui
|
||||
{
|
||||
CRegisterComponent::CRegisterComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CRegisterComponent),
|
||||
m_updateTimer(new CUpdateTimer("CRegisterComponent", &CRegisterComponent::ps_update, this))
|
||||
ui(new Ui::CRegisterComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_updateTimer->setUpdateIntervalSeconds(20);
|
||||
connect(sGui->getIContextApplication(), &IContextApplication::registrationChanged, this, &CRegisterComponent::ps_update);
|
||||
|
||||
// timer is there just in case something goes wrong
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CRegisterComponent::ps_update);
|
||||
m_updateTimer.setInterval(30 * 1000);
|
||||
m_updateTimer.start();
|
||||
}
|
||||
|
||||
CRegisterComponent::~CRegisterComponent()
|
||||
|
||||
@@ -14,19 +14,18 @@
|
||||
|
||||
#include <QFrame>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CRegisterComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
class CUpdateTimer;
|
||||
|
||||
//! Register components in the GUI
|
||||
//! Show registered applications (registered with core) in the GUI
|
||||
//! \sa BlackCore::Context::IContextApplication::getRegisteredApplications
|
||||
class BLACKGUI_EXPORT CRegisterComponent :
|
||||
public QFrame
|
||||
{
|
||||
@@ -45,7 +44,7 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CRegisterComponent> ui;
|
||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||
QTimer m_updateTimer;
|
||||
};
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -46,11 +46,7 @@ namespace BlackGui
|
||||
this->setCurrentIndex(0); // 1st tab
|
||||
ui->comp_DataLoadOverview->setVisibleDbRefreshButtons(false);
|
||||
|
||||
this->connect(ui->hs_SettingsGuiAircraftRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedAircraftUpdateInterval);
|
||||
this->connect(ui->hs_SettingsGuiAtcRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedAtcStationsUpdateInterval);
|
||||
this->connect(ui->hs_SettingsGuiUserRefreshTime, &QSlider::valueChanged, this, &CSettingsComponent::changedUsersUpdateInterval);
|
||||
this->connect(ui->comp_SettingsGuiGeneral, &CSettingsGuiComponent::changedWindowsOpacity, this, &CSettingsComponent::changedWindowsOpacity);
|
||||
|
||||
connect(ui->comp_SettingsGuiGeneral, &CSettingsGuiComponent::changedWindowsOpacity, this, &CSettingsComponent::changedWindowsOpacity);
|
||||
connect(ui->pb_Advanced, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked);
|
||||
connect(ui->pb_Audio, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked);
|
||||
connect(ui->pb_Gui, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked);
|
||||
@@ -70,21 +66,6 @@ namespace BlackGui
|
||||
return ui->comp_AudioSetup->playNotificationSounds();
|
||||
}
|
||||
|
||||
int CSettingsComponent::getAtcUpdateIntervalSeconds() const
|
||||
{
|
||||
return ui->hs_SettingsGuiAtcRefreshTime->value();
|
||||
}
|
||||
|
||||
int CSettingsComponent::getAircraftUpdateIntervalSeconds() const
|
||||
{
|
||||
return ui->hs_SettingsGuiAircraftRefreshTime->value();
|
||||
}
|
||||
|
||||
int CSettingsComponent::getUsersUpdateIntervalSeconds() const
|
||||
{
|
||||
return ui->hs_SettingsGuiUserRefreshTime->value();
|
||||
}
|
||||
|
||||
void CSettingsComponent::setSettingsTab(CSettingsComponent::SettingTab tab)
|
||||
{
|
||||
this->setCurrentIndex(static_cast<int>(tab));
|
||||
|
||||
@@ -57,15 +57,6 @@ namespace BlackGui
|
||||
//! \copydoc CAudioSetupComponent::playNotificationSounds
|
||||
bool playNotificationSounds() const;
|
||||
|
||||
//! ATC refresh time
|
||||
int getAtcUpdateIntervalSeconds() const;
|
||||
|
||||
//! Aircraft refresh time
|
||||
int getAircraftUpdateIntervalSeconds() const;
|
||||
|
||||
//! Aircraft refresh time
|
||||
int getUsersUpdateIntervalSeconds() const;
|
||||
|
||||
signals:
|
||||
//! Change the windows opacity 0..100
|
||||
void changedWindowsOpacity(int opacity);
|
||||
|
||||
@@ -351,138 +351,6 @@
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="fl_SettingsGui">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="gb_ViewRefreshTimes">
|
||||
<property name="title">
|
||||
<string>View refresh times</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="fl_ViewRefreshTimes">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiAircraftRefreshTime">
|
||||
<property name="toolTip">
|
||||
<string>Aircraft refresh time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Aircraft rt (5-30s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="hs_SettingsGuiAircraftRefreshTime">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::NoTicks</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiAtcRefreshTime">
|
||||
<property name="toolTip">
|
||||
<string>ATC refresh time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ATC rt (5-30s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSlider" name="hs_SettingsGuiAtcRefreshTime">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsGuiUserRefreshTime">
|
||||
<property name="toolTip">
|
||||
<string>User refresh time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User rt (5-30s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSlider" name="hs_SettingsGuiUserRefreshTime">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
<zorder>lbl_SettingsGuiUserRefreshTime</zorder>
|
||||
<zorder>lbl_SettingsGuiAtcRefreshTime</zorder>
|
||||
<zorder>lbl_SettingsGuiAircraftRefreshTime</zorder>
|
||||
<zorder>hs_SettingsGuiUserRefreshTime</zorder>
|
||||
<zorder>hs_SettingsGuiAtcRefreshTime</zorder>
|
||||
<zorder>hs_SettingsGuiAircraftRefreshTime</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QWidget" name="qw_SettingsGuiFont" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_SettingsGuiFontColor">
|
||||
@@ -514,6 +382,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="BlackGui::Components::CSettingsViewUpdateTimes" name="comp_SettingsGuiRefreshTimes">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -635,6 +513,12 @@
|
||||
<header>blackgui/components/settingssimulatormessagescomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSettingsViewUpdateTimes</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/settingsviewupdatetimes.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace BlackGui
|
||||
CSimulatorComponent::CSimulatorComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
CEnableForDockWidgetInfoArea(),
|
||||
ui(new Ui::CSimulatorComponent),
|
||||
m_updateTimer(new CUpdateTimer("CSimulatorComponent", &CSimulatorComponent::update, this))
|
||||
ui(new Ui::CSimulatorComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tvp_LiveData->setIconMode(true);
|
||||
@@ -49,11 +48,8 @@ namespace BlackGui
|
||||
this->addOrUpdateByName("info", "no data yet", CIcons::StandardIconWarning16);
|
||||
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CSimulatorComponent::ps_onSimulatorStatusChanged);
|
||||
this->setUpdateInterval(getUpdateIntervalMs());
|
||||
if (sGui->getIContextSimulator()->getSimulatorStatus() == 0)
|
||||
{
|
||||
this->stopTimer();
|
||||
}
|
||||
connect(&this->m_updateTimer, &QTimer::timeout, this, &CSimulatorComponent::update);
|
||||
this->ps_onSimulatorStatusChanged(sGui->getIContextSimulator()->getSimulatorStatus());
|
||||
}
|
||||
|
||||
CSimulatorComponent::~CSimulatorComponent()
|
||||
@@ -132,14 +128,14 @@ namespace BlackGui
|
||||
{
|
||||
if (status & ISimulator::Connected)
|
||||
{
|
||||
int intervalMs = getUpdateIntervalMs();
|
||||
this->m_updateTimer->startTimer(intervalMs);
|
||||
const int intervalMs = getUpdateIntervalMs();
|
||||
this->m_updateTimer.start(intervalMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->stopTimer();
|
||||
clear();
|
||||
update();
|
||||
this->m_updateTimer.stop();
|
||||
this->clear();
|
||||
this->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
#include "blackmisc/icons.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QScopedPointer>
|
||||
#include <QString>
|
||||
#include <QTabWidget>
|
||||
@@ -32,7 +32,6 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
//! Simulator component
|
||||
class BLACKGUI_EXPORT CSimulatorComponent :
|
||||
public QTabWidget,
|
||||
@@ -41,7 +40,6 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CSimulatorComponent(QWidget *parent = nullptr);
|
||||
|
||||
@@ -64,15 +62,6 @@ namespace BlackGui
|
||||
//! Update simulator
|
||||
void update();
|
||||
|
||||
//! \copydoc CUpdateTimer::setUpdateIntervalSeconds
|
||||
void setUpdateIntervalSeconds(int seconds) { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->setUpdateIntervalSeconds(seconds); }
|
||||
|
||||
//! \copydoc CUpdateTimer::setUpdateInterval
|
||||
void setUpdateInterval(int milliSeconds) { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->setUpdateInterval(milliSeconds); }
|
||||
|
||||
//! \copydoc CUpdateTimer::stopTimer
|
||||
void stopTimer() { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->stopTimer(); }
|
||||
|
||||
private slots:
|
||||
//! \copydoc ISimulator::simulatorStatusChanged
|
||||
void ps_onSimulatorStatusChanged(int status);
|
||||
@@ -82,7 +71,7 @@ namespace BlackGui
|
||||
int getUpdateIntervalMs() const;
|
||||
|
||||
QScopedPointer<Ui::CSimulatorComponent> ui;
|
||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||
QTimer m_updateTimer;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
void CUpdateTimer::initTimers(const QString &name)
|
||||
{
|
||||
this->m_timer = new QTimer(this);
|
||||
this->m_timerSingleShot = new QTimer(this);
|
||||
this->m_timerSingleShot->setSingleShot(true);
|
||||
this->m_timer->setObjectName(name + ":periodically");
|
||||
this->m_timerSingleShot->setObjectName(name + ":singleShot");
|
||||
}
|
||||
|
||||
CUpdateTimer::~CUpdateTimer()
|
||||
{
|
||||
if (this->parent()) { this->disconnect(this->parent()); }
|
||||
this->m_timer->stop();
|
||||
this->m_timerSingleShot->stop();
|
||||
}
|
||||
|
||||
void CUpdateTimer::setUpdateInterval(int milliSeconds)
|
||||
{
|
||||
if (milliSeconds < 100)
|
||||
{
|
||||
this->m_timer->stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_timer->setInterval(milliSeconds);
|
||||
if (!this->m_timer->isActive()) this->m_timer->start();
|
||||
}
|
||||
}
|
||||
|
||||
void CUpdateTimer::fireTimer()
|
||||
{
|
||||
Q_ASSERT(this->m_timerSingleShot);
|
||||
this->m_timer->start(); // restart other timer
|
||||
this->m_timerSingleShot->start(10);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
@@ -1,80 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_UPDATETIMER_H
|
||||
#define BLACKGUI_UPDATETIMER_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Timer used in components for updates
|
||||
//! \deprecated used at the beginning of the project, likely to be removed in the future
|
||||
class BLACKGUI_EXPORT CUpdateTimer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Construct a timer which forwards messages to the given slot of parent.
|
||||
template <typename F, typename P>
|
||||
CUpdateTimer(const QString &name, F slot, P *parent) : QObject(parent)
|
||||
{
|
||||
Q_ASSERT(parent);
|
||||
this->initTimers(name);
|
||||
bool c = this->connect(this->m_timer, &QTimer::timeout, parent, slot);
|
||||
Q_ASSERT(c);
|
||||
c = this->connect(this->m_timerSingleShot, &QTimer::timeout, parent, slot);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
virtual ~CUpdateTimer();
|
||||
|
||||
//! Date/time of 1/1/1970, used to init timestamp values as "outdated"
|
||||
static const QDateTime &epoch()
|
||||
{
|
||||
static const QDateTime e = QDateTime::fromMSecsSinceEpoch(0);
|
||||
return e;
|
||||
}
|
||||
|
||||
public slots:
|
||||
//! Update time, time < 100ms stops updates
|
||||
void setUpdateInterval(int milliSeconds);
|
||||
|
||||
//! Update time
|
||||
void setUpdateIntervalSeconds(int seconds) { this->setUpdateInterval(1000 * seconds); }
|
||||
|
||||
//! Stop timer
|
||||
void stopTimer() { this->setUpdateInterval(-1); this->m_timerSingleShot->stop(); }
|
||||
|
||||
//! Start timer
|
||||
void startTimer(int milliSeconds) { this->setUpdateInterval(milliSeconds);}
|
||||
|
||||
//! Fire the timer straight away
|
||||
void fireTimer();
|
||||
|
||||
private:
|
||||
void initTimers(const QString &name); //!< init timers
|
||||
QTimer *m_timer = nullptr; //!< periodically updating
|
||||
QTimer *m_timerSingleShot = nullptr; //!< single update
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Settings;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Context;
|
||||
|
||||
@@ -31,8 +32,7 @@ namespace BlackGui
|
||||
CUserComponent::CUserComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
CEnableForDockWidgetInfoArea(),
|
||||
ui(new Ui::CUserComponent),
|
||||
m_updateTimer(new CUpdateTimer("CUserComponent", &CUserComponent::update, this))
|
||||
ui(new Ui::CUserComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->tabBar()->setExpanding(false);
|
||||
@@ -40,6 +40,8 @@ namespace BlackGui
|
||||
connect(ui->tvp_AllUsers, &CUserView::modelDataChanged, this, &CUserComponent::ps_onCountChanged);
|
||||
connect(ui->tvp_Clients, &CClientView::modelDataChanged, this, &CUserComponent::ps_onCountChanged);
|
||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CUserComponent::ps_connectionStatusChanged);
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CUserComponent::update);
|
||||
this->ps_settingsChanged();
|
||||
}
|
||||
|
||||
CUserComponent::~CUserComponent()
|
||||
@@ -99,7 +101,19 @@ namespace BlackGui
|
||||
{
|
||||
ui->tvp_AllUsers->clear();
|
||||
ui->tvp_Clients->clear();
|
||||
this->m_updateTimer.stop();
|
||||
}
|
||||
else if (INetwork::isConnectedStatus(to))
|
||||
{
|
||||
this->m_updateTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void CUserComponent::ps_settingsChanged()
|
||||
{
|
||||
const CViewUpdateSettings settings = this->m_settings.get();
|
||||
const int ms = settings.getAtcUpdateTime().toMs();
|
||||
this->m_updateTimer.setInterval(ms);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -14,18 +14,18 @@
|
||||
|
||||
#include "blackcore/network.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QTabWidget>
|
||||
#include <QtGlobal>
|
||||
#include <QTimer>
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CUserComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
@@ -54,12 +54,6 @@ namespace BlackGui
|
||||
//! Update users
|
||||
void update();
|
||||
|
||||
//! \copydoc CUpdateTimer::setUpdateIntervalSeconds
|
||||
void setUpdateIntervalSeconds(int seconds) { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->setUpdateIntervalSeconds(seconds); }
|
||||
|
||||
//! \copydoc CUpdateTimer::stopTimer
|
||||
void stopTimer() { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->stopTimer(); }
|
||||
|
||||
private slots:
|
||||
//! Number of elements changed
|
||||
void ps_onCountChanged(int count, bool withFilter);
|
||||
@@ -67,9 +61,13 @@ namespace BlackGui
|
||||
//! Connection status
|
||||
void ps_connectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_settingsChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CUserComponent> ui;
|
||||
QScopedPointer<CUpdateTimer> m_updateTimer;
|
||||
QTimer m_updateTimer { this };
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CUserComponent::ps_settingsChanged };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/updatetimer.h"
|
||||
#include "blackcore/simulator/simulatorsettings.h"
|
||||
#include "blackmisc/geo/coordinategeodetic.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
|
||||
Reference in New Issue
Block a user