Adds initial intermediate qt6 porting state
This commit is contained in:
11247 files changed
+1891537
No files matched your search
+194
@@ -0,0 +1,194 @@
|
||||
|
||||
|
||||
|
||||
#include "osc_settings.h"
|
||||
#include "ui_osc_settings.h"
|
||||
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QDebug>
|
||||
|
||||
namespace OcSituationClient
|
||||
{
|
||||
|
||||
Settings::Settings(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_mediaplayer(new QMediaPlayer(this))
|
||||
, m_ocGroupString(QStringLiteral("ObserverController"))
|
||||
, m_opSettings(LtsUtils::OperatorSettings::getInstance())
|
||||
, m_ui(new Ui::Settings)
|
||||
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
||||
session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
|
||||
|
||||
connect(m_ui->pbSoundCheck, &LtsWidgets::LtsDragIcon::clicked, this, &Settings::onSoundCheck);
|
||||
connect(m_ui->pbResetRange, &LtsWidgets::LtsDragIcon::clicked, this, &Settings::onResetRange);
|
||||
connect(m_ui->slWarningRange, &QSlider::valueChanged, this, [this](int range)
|
||||
{
|
||||
m_ui->lblRange->setText(QString::number(range));
|
||||
});
|
||||
|
||||
#ifdef WIN32
|
||||
m_handler = CreateFile(L"\\\\.\\LCD",GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,0, NULL);
|
||||
m_monitorLightBrightness = getMonitorCurrentLightBrightness();
|
||||
connect(m_ui->slMonitorBrightness, &QSlider::valueChanged, this, [this](int range)
|
||||
{
|
||||
m_ui->lblMonitorBrightness->setText(QString::number(range));
|
||||
setMonitorLightBrightness(range);
|
||||
});
|
||||
if(m_monitorLightBrightness >= 0)
|
||||
{
|
||||
m_ui->slMonitorBrightness->setValue(m_monitorLightBrightness);
|
||||
}
|
||||
m_ui->lblMonitorBrightness->setText(QString::number(m_ui->slMonitorBrightness->value()));
|
||||
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked,
|
||||
this, [this]()
|
||||
{
|
||||
|
||||
setMonitorLightBrightness(m_monitorLightBrightness);
|
||||
});
|
||||
#else
|
||||
m_ui->slMonitorBrightness->hide();
|
||||
m_ui->lblMonitorBrightness->hide();
|
||||
m_ui->LblMonitorBrightness->hide();
|
||||
#endif
|
||||
|
||||
connect(m_ui->cbxAcusticWarning, &LtsWidgets::LtsDragIcon::clicked, this, &Settings::slotChangesMade);
|
||||
connect(m_ui->cbxVisualWarning, &LtsWidgets::LtsDragIcon::clicked, this, &Settings::slotChangesMade);
|
||||
connect(m_ui->cbxOcSituationBorder, &LtsWidgets::LtsDragIcon::clicked, this, &Settings::slotChangesMade);
|
||||
connect(m_ui->cbxMovingMapToSelf, &LtsWidgets::LtsDragIcon::clicked, this, &Settings::slotChangesMade);
|
||||
|
||||
loadOperatorSettings();
|
||||
|
||||
|
||||
m_mediaplayer->setMedia(QUrl(QLatin1String("qrc:/beep.wav")));
|
||||
m_mediaplayer->setVolume(100);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("OC-Settings"));
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void Settings::setMonitorLightBrightness(const int value)
|
||||
{
|
||||
#ifdef WIN32
|
||||
m_displayBrightness.ucDisplayPolicy = 0;
|
||||
m_displayBrightness.ucACBrightness = 0;
|
||||
m_displayBrightness.ucDCBrightness = value;
|
||||
DWORD ret = 0;
|
||||
DWORD nOutBufferSize = sizeof(m_displayBrightness);
|
||||
if(m_handler == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_handler = CreateFile(L"\\\\.\\LCD",
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
NULL);
|
||||
if(m_handler == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
qCritical()<<" couldn't CreateFile for setting monitor light brightness. Error: "<<GetLastError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!DeviceIoControl(m_handler,
|
||||
IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS,
|
||||
(DISPLAY_BRIGHTNESS*)&m_displayBrightness,
|
||||
nOutBufferSize,
|
||||
NULL,
|
||||
0,
|
||||
&ret,
|
||||
NULL))
|
||||
{
|
||||
qCritical()<<" couldn't set monitor light brightness. Error: "<<GetLastError();
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(value)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Settings::getMonitorCurrentLightBrightness()
|
||||
{
|
||||
#ifdef WIN32
|
||||
DWORD ret;
|
||||
int nRes = DeviceIoControl(
|
||||
m_handler,
|
||||
IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS ,
|
||||
NULL,
|
||||
0,
|
||||
(DISPLAY_BRIGHTNESS*)&m_displayBrightness,
|
||||
sizeof(m_displayBrightness),
|
||||
(LPDWORD) &ret,
|
||||
NULL
|
||||
);
|
||||
if(nRes !=0)
|
||||
{
|
||||
const int l = m_displayBrightness.ucDCBrightness;
|
||||
return l;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Settings::onResetRange()
|
||||
{
|
||||
m_ui->slWarningRange->setValue(WARNINGRANGEDEFAULT);
|
||||
}
|
||||
|
||||
void Settings::onSoundCheck()
|
||||
{
|
||||
m_mediaplayer->play();
|
||||
}
|
||||
|
||||
void Settings::loadOperatorSettings()
|
||||
{
|
||||
|
||||
m_ui->slWarningRange->setValue(m_opSettings->value(m_ocGroupString, QStringLiteral("WarningRange"), WARNINGRANGEDEFAULT).toInt());
|
||||
m_ui->cbxAcusticWarning->setChecked(m_opSettings->value(m_ocGroupString, QStringLiteral("AcousticWarning"), false).toBool());
|
||||
m_ui->cbxVisualWarning->setChecked(m_opSettings->value(m_ocGroupString, QStringLiteral("VisualWarning"), false).toBool());
|
||||
m_ui->cbxOcSituationBorder->setChecked(m_opSettings->value(m_ocGroupString, QStringLiteral("OcSituationBorder"), false).toBool());
|
||||
m_ui->cbxMovingMapToSelf->setChecked(m_opSettings->value(m_ocGroupString, QStringLiteral("MovingMapToSelf"), false).toBool());
|
||||
}
|
||||
|
||||
void Settings::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Settings") );
|
||||
}
|
||||
|
||||
bool Settings::apply()
|
||||
{
|
||||
|
||||
m_opSettings->setValue(m_ocGroupString, QStringLiteral("WarningRange"), m_ui->slWarningRange->value());
|
||||
m_opSettings->setValue(m_ocGroupString, QStringLiteral("AcousticWarning"), m_ui->cbxAcusticWarning->isChecked());
|
||||
m_opSettings->setValue(m_ocGroupString, QStringLiteral("VisualWarning"), m_ui->cbxVisualWarning->isChecked());
|
||||
m_opSettings->setValue(m_ocGroupString, QStringLiteral("OcSituationBorder"), m_ui->cbxOcSituationBorder->isChecked());
|
||||
m_opSettings->setValue(m_ocGroupString, QStringLiteral("MovingMapToSelf"), m_ui->cbxMovingMapToSelf->isChecked());
|
||||
|
||||
m_sitMapGuiIfc->ocSituationRange_show(m_ui->cbxOcSituationBorder->isChecked());
|
||||
|
||||
#ifdef WIN32
|
||||
m_monitorLightBrightness = getMonitorCurrentLightBrightness();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user