mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 05:28:09 +08:00
refs #799, own component for view update times
* utility function in CTime * settings class for update times
This commit is contained in:
54
src/blackgui/components/settingsviewupdatetimes.cpp
Normal file
54
src/blackgui/components/settingsviewupdatetimes.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 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 "settingsviewupdatetimes.h"
|
||||
#include "ui_settingsviewupdatetimes.h"
|
||||
|
||||
using namespace BlackGui::Settings;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace 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);
|
||||
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());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
51
src/blackgui/components/settingsviewupdatetimes.h
Normal file
51
src/blackgui/components/settingsviewupdatetimes.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* 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_SETTINGSVIEWUPDATETIMES_H
|
||||
#define BLACKGUI_COMPONENTS_SETTINGSVIEWUPDATETIMES_H
|
||||
|
||||
#include "blackgui/settings/viewupdatesettings.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui { class CSettingsViewUpdateTimes; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/*!
|
||||
* Update rates / times
|
||||
*/
|
||||
class CSettingsViewUpdateTimes : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CSettingsViewUpdateTimes(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CSettingsViewUpdateTimes();
|
||||
|
||||
private slots:
|
||||
//! Slider changed
|
||||
void ps_sliderChanged();
|
||||
|
||||
//! Settings have been changed
|
||||
void ps_settingsChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSettingsViewUpdateTimes> ui;
|
||||
BlackMisc::CSetting<BlackGui::Settings::TViewUpdateSettings> m_settings { this, &CSettingsViewUpdateTimes::ps_settingsChanged }; //!< settings changed
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
196
src/blackgui/components/settingsviewupdatetimes.ui
Normal file
196
src/blackgui/components/settingsviewupdatetimes.ui
Normal file
@@ -0,0 +1,196 @@
|
||||
<?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>184</width>
|
||||
<height>159</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="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_ViewUpdateTimes">
|
||||
<property name="title">
|
||||
<string>View update times</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="fl_ViewRefreshTimes">
|
||||
<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="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_AtcUpdateTime">
|
||||
<property name="toolTip">
|
||||
<string>ATC update time (5-30s)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ATC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSlider" name="hs_AtcUpdateTime">
|
||||
<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="3" column="0">
|
||||
<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="3" column="1">
|
||||
<widget class="QSlider" name="hs_UserUpdateTime">
|
||||
<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="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="1" column="1">
|
||||
<widget class="QSlider" name="hs_RenderingUpdateTime">
|
||||
<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_UserUpdateTime</zorder>
|
||||
<zorder>lbl_AtcUpdateTime</zorder>
|
||||
<zorder>lbl_AircraftUpdateTime</zorder>
|
||||
<zorder>hs_UserUpdateTime</zorder>
|
||||
<zorder>hs_AtcUpdateTime</zorder>
|
||||
<zorder>hs_AircraftUpdateTime</zorder>
|
||||
<zorder>lbl_RenderingUpdateTime</zorder>
|
||||
<zorder>hs_RenderingUpdateTime</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user