diff --git a/src/blackgui/components/settingsnetworkcomponent.ui b/src/blackgui/components/settingsnetworkcomponent.ui index 91a617e9d..5f9667a89 100644 --- a/src/blackgui/components/settingsnetworkcomponent.ui +++ b/src/blackgui/components/settingsnetworkcomponent.ui @@ -34,7 +34,7 @@ - + Qt::Vertical @@ -47,8 +47,41 @@ + + + + Services + + + + + + + 0 + 100 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + BlackGui::Components::CSettingsVatsimReadersComponent + QFrame +
blackgui/components/settingsvatsimreaderscomponent.h
+ 1 +
+
diff --git a/src/blackgui/components/settingsnetworkserverscomponent.cpp b/src/blackgui/components/settingsnetworkserverscomponent.cpp index 96b89c63a..c5a358432 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.cpp +++ b/src/blackgui/components/settingsnetworkserverscomponent.cpp @@ -38,7 +38,6 @@ namespace BlackGui { namespace Components { - CSettingsNetworkServersComponent::CSettingsNetworkServersComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CSettingsNetworkServersComponent) diff --git a/src/blackgui/components/settingsvatsimreaderscomponent.cpp b/src/blackgui/components/settingsvatsimreaderscomponent.cpp new file mode 100644 index 000000000..fb049ec2b --- /dev/null +++ b/src/blackgui/components/settingsvatsimreaderscomponent.cpp @@ -0,0 +1,79 @@ +/* Copyright (C) 2016 + * 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 "settingsvatsimreaderscomponent.h" +#include "ui_settingsvatsimreaderscomponent.h" + +using namespace BlackMisc; +using namespace BlackMisc::PhysicalQuantities; +using namespace BlackCore; +using namespace BlackCore::Settings; + +namespace BlackGui +{ + namespace Components + { + CSettingsVatsimReadersComponent::CSettingsVatsimReadersComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CSettingsVatsimReadersComponent) + { + ui->setupUi(this); + connect(ui->pb_Save, &QPushButton::clicked, this, &CSettingsVatsimReadersComponent::ps_save); + connect(ui->pb_Reload, &QPushButton::clicked, this, &CSettingsVatsimReadersComponent::ps_reload); + this->initValues(); + } + + CSettingsVatsimReadersComponent::~CSettingsVatsimReadersComponent() + { } + + void CSettingsVatsimReadersComponent::ps_settingsChanged() + { + this->initValues(); + } + + void CSettingsVatsimReadersComponent::ps_save() + { + const int metarSec = this->m_settingsMetars.get().getPeriodicTime().toMs() / 1000; + const int bookingsSec = this->m_settingsBookings.get().getPeriodicTime().toMs() / 1000; + const int dataFileSec = this->m_settingsDataFile.get().getPeriodicTime().toMs() / 1000; + + const int newMetarSec = ui->sb_Metar->value(); + if (newMetarSec != metarSec) + { + this->m_settingsMetars.setAndSaveProperty(CSettingsReader::IndexPeriodicTime, CVariant::fromValue(CTime{static_cast(newMetarSec), CTimeUnit::s()})); + } + const int newBookingsSec = ui->sb_Bookings->value(); + if (newBookingsSec != bookingsSec) + { + this->m_settingsBookings.setAndSaveProperty(CSettingsReader::IndexPeriodicTime, CVariant::fromValue(CTime{static_cast(newBookingsSec), CTimeUnit::s()})); + } + const int newDataFileSec = ui->sb_DataFile->value(); + if (newDataFileSec != dataFileSec) + { + this->m_settingsBookings.setAndSaveProperty(CSettingsReader::IndexPeriodicTime, CVariant::fromValue(CTime{static_cast(newDataFileSec), CTimeUnit::s()})); + } + } + + void CSettingsVatsimReadersComponent::ps_reload() + { + this->initValues(); + } + + void CSettingsVatsimReadersComponent::initValues() + { + const int metarSec = this->m_settingsMetars.get().getPeriodicTime().toMs() / 1000; + const int bookingsSec = this->m_settingsBookings.get().getPeriodicTime().toMs() / 1000; + const int dataFileSec = this->m_settingsDataFile.get().getPeriodicTime().toMs() / 1000; + + ui->sb_Metar->setValue(metarSec); + ui->sb_Bookings->setValue(bookingsSec); + ui->sb_DataFile->setValue(dataFileSec); + } + } // ns +} // ns diff --git a/src/blackgui/components/settingsvatsimreaderscomponent.h b/src/blackgui/components/settingsvatsimreaderscomponent.h new file mode 100644 index 000000000..cd40ce7d4 --- /dev/null +++ b/src/blackgui/components/settingsvatsimreaderscomponent.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2016 + * 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_COMPONENTS_SETTINGSVATSIMREADERSCOMPONENT_H +#define BLACKGUI_COMPONENTS_SETTINGSVATSIMREADERSCOMPONENT_H + +#include "blackcore/settings/reader.h" +#include +#include + +namespace Ui { class CSettingsVatsimReadersComponent; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Settings for readers + */ + class CSettingsVatsimReadersComponent : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CSettingsVatsimReadersComponent(QWidget *parent = nullptr); + + //! Destructor + ~CSettingsVatsimReadersComponent(); + + private slots: + void ps_settingsChanged(); + void ps_save(); + void ps_reload(); + + private: + void initValues(); + + QScopedPointer ui; + BlackMisc::CSetting m_settingsBookings { this, &CSettingsVatsimReadersComponent::ps_settingsChanged }; + BlackMisc::CSetting m_settingsDataFile { this, &CSettingsVatsimReadersComponent::ps_settingsChanged }; + BlackMisc::CSetting m_settingsMetars { this, &CSettingsVatsimReadersComponent::ps_settingsChanged }; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/settingsvatsimreaderscomponent.ui b/src/blackgui/components/settingsvatsimreaderscomponent.ui new file mode 100644 index 000000000..1024039ac --- /dev/null +++ b/src/blackgui/components/settingsvatsimreaderscomponent.ui @@ -0,0 +1,116 @@ + + + CSettingsVatsimReadersComponent + + + + 0 + 0 + 204 + 147 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + METARs (secs.) + + + + + + + 10 + + + 500 + + + 1 + + + 30 + + + + + + + Data file (secs.) + + + + + + + 10 + + + 500 + + + 1 + + + 30 + + + + + + + Bookings (secs.) + + + + + + + 10 + + + 500 + + + 1 + + + 30 + + + + + + + + + + reload + + + + + + + save + + + + + + + + + + +