mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "blackgui/editors/form.h"
|
||||
|
||||
class QWidget;
|
||||
namespace BlackMisc { namespace Network { class CAuthenticatedUser; } }
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -21,7 +21,18 @@ namespace BlackGui
|
||||
|
||||
CForm::~CForm() { }
|
||||
|
||||
const BlackMisc::Network::CAuthenticatedUser &CForm::getSwiftDbUser() const
|
||||
void CForm::setSelectOnly()
|
||||
{
|
||||
this->setReadOnly(true);
|
||||
}
|
||||
|
||||
CStatusMessageList CForm::validate(bool withNestedObjects) const
|
||||
{
|
||||
Q_UNUSED(withNestedObjects);
|
||||
return CStatusMessageList();
|
||||
}
|
||||
|
||||
const CAuthenticatedUser &CForm::getSwiftDbUser() const
|
||||
{
|
||||
return this->m_swiftDbUser.getThreadLocal();
|
||||
}
|
||||
|
||||
@@ -13,10 +13,8 @@
|
||||
#define BLACKGUI_EDITORS_FORM_H
|
||||
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackcore/data/authenticateduser.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QObject>
|
||||
|
||||
@@ -31,7 +29,7 @@ namespace BlackGui
|
||||
/*!
|
||||
* Form base class
|
||||
*/
|
||||
class BLACKGUI_EXPORT CForm : public COverlayMessagesFrame
|
||||
class CForm : public COverlayMessagesFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -47,7 +45,10 @@ namespace BlackGui
|
||||
|
||||
//! Read only, but entity can be selected (normally used in mapping).
|
||||
//! Use setReadOnly to reset this very state
|
||||
virtual void setSelectOnly() = 0;
|
||||
virtual void setSelectOnly();
|
||||
|
||||
//! Validate, empty list means OK
|
||||
virtual BlackMisc::CStatusMessageList validate(bool withNestedObjects = true) const;
|
||||
|
||||
//! Is read only?
|
||||
bool isReadOnly() const { return m_readOnly; }
|
||||
@@ -63,7 +64,6 @@ namespace BlackGui
|
||||
//! User has been changed
|
||||
virtual void ps_userChanged();
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
113
src/blackgui/editors/fsdsetupform.cpp
Normal file
113
src/blackgui/editors/fsdsetupform.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/* 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 "fsdsetupform.h"
|
||||
#include "ui_fsdsetupform.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include <QCompleter>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CFsdSetupForm::CFsdSetupForm(QWidget *parent) :
|
||||
CForm(parent),
|
||||
ui(new Ui::CFsdSetupForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->showEnableInfo(false);
|
||||
ui->cb_Enabled->setChecked(true);
|
||||
ui->le_TextCodec->setCompleter(new QCompleter(textCodecNames(true, true), this));
|
||||
connect(ui->cb_Enabled, &QCheckBox::toggled, this, &CFsdSetupForm::ps_enabledToggled);
|
||||
}
|
||||
|
||||
CFsdSetupForm::~CFsdSetupForm()
|
||||
{ }
|
||||
|
||||
CFsdSetup CFsdSetupForm::getValue() const
|
||||
{
|
||||
if (!this->isEnabled()) { return this->getDisabledValue(); }
|
||||
CFsdSetup s(ui->le_TextCodec->text().trimmed().toLower());
|
||||
s.setSendReceiveDetails(
|
||||
ui->cb_AircraftPartsSend->isChecked(), ui->cb_AircraftPartsReceive->isChecked(),
|
||||
ui->cb_FastPositionSend->isChecked(), ui->cb_FastPositionReceive->isChecked()
|
||||
);
|
||||
return s;
|
||||
}
|
||||
|
||||
const CFsdSetup &CFsdSetupForm::getDisabledValue() const
|
||||
{
|
||||
static const CFsdSetup fsd;
|
||||
return fsd;
|
||||
}
|
||||
|
||||
void CFsdSetupForm::setValue(const BlackMisc::Network::CFsdSetup &setup)
|
||||
{
|
||||
ui->le_TextCodec->setText(setup.getTextCodec());
|
||||
const CFsdSetup::SendReceiveDetails d = setup.getSendReceiveDetails();
|
||||
|
||||
ui->cb_AircraftPartsReceive->setChecked(d & CFsdSetup::ReceiveAircraftParts);
|
||||
ui->cb_AircraftPartsSend->setChecked(d & CFsdSetup::SendAircraftParts);
|
||||
ui->cb_FastPositionReceive->setChecked(d & CFsdSetup::ReceiveInterimPositions);
|
||||
ui->cb_FastPositionSend->setChecked(d & CFsdSetup::SendIterimPositions);
|
||||
}
|
||||
|
||||
bool CFsdSetupForm::isFsdSetuoEnabled() const
|
||||
{
|
||||
return ui->cb_Enabled->isChecked();
|
||||
}
|
||||
|
||||
void CFsdSetupForm::setFsdSetupEnabled(bool enabled)
|
||||
{
|
||||
ui->cb_Enabled->setChecked(enabled);
|
||||
}
|
||||
|
||||
void CFsdSetupForm::showEnableInfo(bool visible)
|
||||
{
|
||||
ui->cb_Enabled->setVisible(visible);
|
||||
ui->lbl_Enabled->setVisible(visible);
|
||||
}
|
||||
|
||||
void CFsdSetupForm::setReadOnly(bool readonly)
|
||||
{
|
||||
ui->le_TextCodec->setReadOnly(readonly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_AircraftPartsReceive, readonly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_AircraftPartsSend, readonly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_FastPositionReceive, readonly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_FastPositionSend, readonly);
|
||||
}
|
||||
|
||||
CStatusMessageList CFsdSetupForm::validate(bool nested) const
|
||||
{
|
||||
Q_UNUSED(nested);
|
||||
const CFsdSetup val(getValue());
|
||||
CStatusMessageList msgs(val.validate());
|
||||
if (this->isReadOnly())
|
||||
{
|
||||
// in readonly I cannot change the data anyway, so skip warnings
|
||||
msgs.removeWarningsAndBelow();
|
||||
}
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CFsdSetupForm::ps_enabledToggled(bool enabled)
|
||||
{
|
||||
Q_UNUSED(enabled);
|
||||
this->setReadOnly(!enabled);
|
||||
if (!enabled)
|
||||
{
|
||||
this->setValue(CFsdSetup());
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
74
src/blackgui/editors/fsdsetupform.h
Normal file
74
src/blackgui/editors/fsdsetupform.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* 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_EDITORS_FSDSETUPCOMPONENT_H
|
||||
#define BLACKGUI_EDITORS_FSDSETUPCOMPONENT_H
|
||||
|
||||
#include "blackmisc/network/fsdsetup.h"
|
||||
#include "form.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CFsdSetupForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Setup for FSD
|
||||
*/
|
||||
class CFsdSetupForm : public CForm
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CFsdSetupForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Constructor
|
||||
~CFsdSetupForm();
|
||||
|
||||
//! FSD setup from GUI
|
||||
BlackMisc::Network::CFsdSetup getValue() const;
|
||||
|
||||
//! FSD setup when disabled
|
||||
const BlackMisc::Network::CFsdSetup &getDisabledValue() const;
|
||||
|
||||
//! Set to GUI
|
||||
void setValue(const BlackMisc::Network::CFsdSetup &setup);
|
||||
|
||||
//! Enabled?
|
||||
bool isFsdSetuoEnabled() const;
|
||||
|
||||
//! Set enabled / disabled
|
||||
void setFsdSetupEnabled(bool enabled);
|
||||
|
||||
//! Show the enable info
|
||||
void showEnableInfo(bool visible);
|
||||
|
||||
//! \name Form class implementations
|
||||
//! @{
|
||||
virtual void setReadOnly(bool readonly) override;
|
||||
virtual BlackMisc::CStatusMessageList validate(bool nested = false) const override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
//! Enable / disable
|
||||
void ps_enabledToggled(bool enabled);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CFsdSetupForm> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
133
src/blackgui/editors/fsdsetupform.ui
Normal file
133
src/blackgui/editors/fsdsetupform.ui
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CFsdSetupForm</class>
|
||||
<widget class="QFrame" name="CFsdSetupForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>189</width>
|
||||
<height>102</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="QFormLayout" name="fl_FsdSetupForm">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_TextCodec">
|
||||
<property name="text">
|
||||
<string>Text codec</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_TextCodec">
|
||||
<property name="placeholderText">
|
||||
<string>e.g. "latin1"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QFrame" name="fr_SendReceive">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_SendReceive">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_FastPositions">
|
||||
<property name="text">
|
||||
<string>Fast positions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftParts">
|
||||
<property name="text">
|
||||
<string>Aircraft parts</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsSend">
|
||||
<property name="text">
|
||||
<string>send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsReceive">
|
||||
<property name="text">
|
||||
<string>receive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_FastPositionSend">
|
||||
<property name="text">
|
||||
<string>send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" alignment="Qt::AlignHCenter">
|
||||
<widget class="QCheckBox" name="cb_FastPositionReceive">
|
||||
<property name="text">
|
||||
<string>receive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Enabled">
|
||||
<property name="text">
|
||||
<string>Enabled:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="cb_Enabled">
|
||||
<property name="text">
|
||||
<string>override defaults</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user