mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #335, Minor tweaks:
* Formatting * renaming * fixed some issues of cppcheck * new icons * smooth scrolling in views, stretching for few columns * fixed start timer in updatetimer * background colors of some LEDs
This commit is contained in:
committed by
Roland Winklmeier
parent
a9768566e6
commit
43ecc238ed
@@ -24,9 +24,7 @@ namespace BlackGui
|
||||
|
||||
CAircraftComponent::CAircraftComponent(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
CEnableForDockWidgetInfoArea(),
|
||||
CEnableForRuntime(nullptr, false),
|
||||
ui(new Ui::CAircraftComponent), m_updateTimer(nullptr)
|
||||
ui(new Ui::CAircraftComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->tabBar()->setExpanding(false);
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAircraftComponent> ui;
|
||||
CUpdateTimer *m_updateTimer;
|
||||
CUpdateTimer *m_updateTimer = nullptr;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace BlackGui
|
||||
this->connect(this->ui->pb_CockpitToggleCom2, &QPushButton::clicked, this, &CCockpitV1Component::cockpitValuesChanged);
|
||||
this->connect(this->ui->pb_CockpitSelcalTest, &QPushButton::clicked, this, &CCockpitV1Component::testSelcal);
|
||||
|
||||
this->connect(this->ui->cbp_CockpitTransponderMode, &CTransponderModeSelector::valueChanged, this, &CCockpitV1Component::cockpitValuesChanged);
|
||||
this->connect(this->ui->cbp_CockpitTransponderMode, &CTransponderModeSelector::transponderModeChanged, this, &CCockpitV1Component::cockpitValuesChanged);
|
||||
|
||||
this->connect(this->ui->di_CockpitCom1Volume, &QDial::valueChanged, this, &CCockpitV1Component::setCom1Volume);
|
||||
this->connect(this->ui->di_CockpitCom2Volume, &QDial::valueChanged, this, &CCockpitV1Component::setCom2Volume);
|
||||
|
||||
@@ -49,8 +49,8 @@ namespace BlackGui
|
||||
this->ui->led_Simulator->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Simulator connected", "Simulator disconnected", 14);
|
||||
|
||||
shape = CLedWidget::Rounded;
|
||||
this->ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Red, shape, "Ptt", "Silence", 18);
|
||||
this->ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Red, shape, "On", "Muted", 18);
|
||||
this->ui->led_Ptt->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Ptt", "Silence", 18);
|
||||
this->ui->led_Audio->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "On", "Muted", 18);
|
||||
}
|
||||
|
||||
void CInfoBarStatusComponent::setDBusStatus(bool dbus)
|
||||
|
||||
@@ -20,8 +20,12 @@ namespace BlackGui
|
||||
this->m_timer = new QTimer(this);
|
||||
this->m_timerSingleShot = new QTimer(this);
|
||||
this->m_timerSingleShot->setSingleShot(true);
|
||||
this->connect(this->m_timer, SIGNAL(timeout()), parent, slot);
|
||||
this->connect(this->m_timerSingleShot, SIGNAL(timeout()), parent, slot);
|
||||
|
||||
bool c = this->connect(this->m_timer, SIGNAL(timeout()), parent, slot);
|
||||
Q_ASSERT(c);
|
||||
c = this->connect(this->m_timerSingleShot, SIGNAL(timeout()), parent, slot);
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
}
|
||||
|
||||
CUpdateTimer::~CUpdateTimer()
|
||||
|
||||
@@ -48,6 +48,9 @@ namespace BlackGui
|
||||
//! 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();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace BlackGui
|
||||
//! Return pressed
|
||||
void ps_voiceRoomUrlsReturnPressed();
|
||||
|
||||
//! set the voice room url fields (checkboxes, line edits)
|
||||
//! Set the voice room url fields (checkboxes, line edits)
|
||||
void ps_updateAudioVoiceRoomsFromContext(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms, bool connected);
|
||||
|
||||
private:
|
||||
@@ -58,7 +58,6 @@ namespace BlackGui
|
||||
//! Update voice room views
|
||||
void updateVoiceRoomMembers();
|
||||
|
||||
|
||||
QScopedPointer<Ui::CVoiceRoomsComponent> ui;
|
||||
};
|
||||
|
||||
|
||||
@@ -169,14 +169,7 @@ namespace BlackGui
|
||||
|
||||
void CLedWidget::toggleValue()
|
||||
{
|
||||
if (m_value == Temporary || m_value == On)
|
||||
{
|
||||
m_value = Off;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_value = Off;
|
||||
}
|
||||
m_value = (m_value == Off) ? m_value = On : m_value = Off;
|
||||
setLed();
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace BlackGui
|
||||
{ }
|
||||
|
||||
CBoolIconFormatter::CBoolIconFormatter(CIcons::IconIndex onIcon, CIcons::IconIndex offIcon, const QString &onName, const QString &offName, int alignment) :
|
||||
CBoolIconFormatter(CIconList::iconForIndex(onIcon), CIconList::iconForIndex(offIcon), onName, offName, alignment)
|
||||
CBoolIconFormatter(CIconList::iconByIndex(onIcon), CIconList::iconByIndex(offIcon), onName, offName, alignment)
|
||||
{ }
|
||||
|
||||
CBoolIconFormatter::CBoolIconFormatter(const CIcon &onIcon, const CIcon &offIcon, const QString &onName, const QString &offName, int alignment) :
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Ui { class CShowHideBar; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
//! Show or hide another section
|
||||
//! Show or hide (expand / collapse) another section
|
||||
class CShowHideBar : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
/* 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 "transpondermodeselector.h"
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
CTransponderModeSelector::CTransponderModeSelector(QWidget *parent) : QComboBox(parent),
|
||||
m_currentMode(CTransponder::StateStandby), m_resetMode(CTransponder::StateStandby)
|
||||
CTransponderModeSelector::CTransponderModeSelector(QWidget *parent) : QComboBox(parent)
|
||||
{
|
||||
QComboBox::insertItems(0, CTransponderModeSelector::modes());
|
||||
connect(&this->m_resetTimer, &QTimer::timeout, this, &CTransponderModeSelector::resetTransponderMode);
|
||||
@@ -51,9 +58,9 @@ namespace BlackGui
|
||||
|
||||
void CTransponderModeSelector::setSelectedTransponderMode(CTransponder::TransponderMode mode)
|
||||
{
|
||||
if (mode != CTransponder::StateIdent) this->m_resetMode = mode;
|
||||
if (this->m_currentMode == mode) return;
|
||||
if (this->m_currentMode == CTransponder::StateIdent) emit this->identEnded();
|
||||
if (mode != CTransponder::StateIdent) { this->m_resetMode = mode; }
|
||||
if (this->m_currentMode == mode) { return; }
|
||||
if (this->m_currentMode == CTransponder::StateIdent) { emit this->transponderStateIdentEnded(); }
|
||||
this->m_currentMode = mode;
|
||||
QString m = CTransponder::modeAsString(mode);
|
||||
QComboBox::setCurrentText(m);
|
||||
@@ -65,7 +72,12 @@ namespace BlackGui
|
||||
{
|
||||
this->m_resetTimer.stop();
|
||||
}
|
||||
emit this->valueChanged();
|
||||
emit this->transponderModeChanged(this->m_currentMode);
|
||||
}
|
||||
|
||||
void CTransponderModeSelector::setSelectedTransponderModeStateIdent()
|
||||
{
|
||||
this->setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::StateIdent);
|
||||
}
|
||||
|
||||
void CTransponderModeSelector::setSelectedTransponderModeAsString(const QString &mode)
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/* 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_TRANSPONDERMODESELECTOR_H
|
||||
#define BLACKGUI_TRANSPONDERMODESELECTOR_H
|
||||
|
||||
@@ -11,65 +22,62 @@
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Selector for the transponder mode
|
||||
*/
|
||||
//! Selector for the transponder mode
|
||||
//! \remarks features ident reset
|
||||
class CTransponderModeSelector : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode m_currentMode;
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode m_resetMode;
|
||||
QTimer m_resetTimer;
|
||||
|
||||
public:
|
||||
//! \brief Constructor
|
||||
//! Constructor
|
||||
explicit CTransponderModeSelector(QWidget *parent = nullptr);
|
||||
|
||||
//! \brief Standby string
|
||||
//! Standby string
|
||||
static const QString &transponderStateStandby();
|
||||
|
||||
//! \brief Ident string
|
||||
//! Ident string
|
||||
static const QString &transponderStateIdent();
|
||||
|
||||
//! \brief Mode C string
|
||||
//! Mode C string
|
||||
static const QString &transponderModeC();
|
||||
|
||||
//! \brief All relevant modes for GUI
|
||||
//! All relevant modes for GUI
|
||||
static const QStringList &modes();
|
||||
|
||||
//! \brief Selected transponder mode
|
||||
//! Selected transponder mode
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const;
|
||||
|
||||
//! \brief Selected transponder mode
|
||||
void setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode);
|
||||
|
||||
//!\ brief Set to ident
|
||||
void setSelectedTransponderModeStateIdent()
|
||||
{
|
||||
this->setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::StateIdent);
|
||||
}
|
||||
|
||||
//! \brief Ident selected
|
||||
//! Ident selected
|
||||
bool isIdentSelected() const
|
||||
{
|
||||
return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent;
|
||||
}
|
||||
|
||||
public slots:
|
||||
//! \brief reset to last mode (unequal ident)
|
||||
//! reset to last mode (unequal ident)
|
||||
void resetTransponderMode();
|
||||
|
||||
//! \brief Selected transponder mode
|
||||
//! Selected transponder mode
|
||||
void setSelectedTransponderModeAsString(const QString &mode);
|
||||
|
||||
signals:
|
||||
//! Singal, which makes sure the value is already updated internally
|
||||
void valueChanged();
|
||||
//! Selected transponder mode
|
||||
void setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode);
|
||||
|
||||
//! \brief Ident ended
|
||||
void identEnded();
|
||||
//! Set to ident (transponder state)
|
||||
void setSelectedTransponderModeStateIdent();
|
||||
|
||||
signals:
|
||||
//! Mode / state has been changed
|
||||
void transponderModeChanged(BlackMisc::Aviation::CTransponder::TransponderMode newMode);
|
||||
|
||||
//! Ident phase ended
|
||||
void transponderStateIdentEnded();
|
||||
|
||||
private:
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode m_currentMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode m_resetMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
||||
QTimer m_resetTimer;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace BlackGui
|
||||
{
|
||||
CNameVariantPairView::CNameVariantPairView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
m_forceStretchLastColumnWhenResized = true;
|
||||
this->standardInit(new CNameVariantPairModel(true, this));
|
||||
}
|
||||
|
||||
@@ -47,4 +48,4 @@ namespace BlackGui
|
||||
return this->m_model->containsName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace BlackGui
|
||||
void setIconMode(bool withIcon);
|
||||
|
||||
//! Update or add value, QVariant version
|
||||
bool addOrUpdateByName(const QString &name, const QVariant &value, const BlackMisc::CIcon &icon = BlackMisc::CIcon(), bool resize = true, bool skipEqualValues = true);
|
||||
bool addOrUpdateByName(const QString &name, const QVariant &value, const BlackMisc::CIcon &icon = BlackMisc::CIcon(), bool performResizing = true, bool skipEqualValues = true);
|
||||
|
||||
//! Remove by name
|
||||
void removeByName(const QString &name, bool resize = true);
|
||||
void removeByName(const QString &name, bool performResizing = true);
|
||||
|
||||
//! Contains name
|
||||
bool containsName(const QString &name);
|
||||
|
||||
@@ -40,6 +40,11 @@ namespace BlackGui
|
||||
{
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &QWidget::customContextMenuRequested, this, &CViewBaseNonTemplate::ps_customMenuRequested);
|
||||
|
||||
// scroll modes
|
||||
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::customMenu(QMenu &menu) const
|
||||
@@ -82,8 +87,8 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::initRowsResizeModeToInteractive()
|
||||
{
|
||||
const int h = this->verticalHeader()->minimumSectionSize();
|
||||
this->setRowsResizeModeToInteractive(h);
|
||||
const int height = this->verticalHeader()->minimumSectionSize();
|
||||
this->setRowsResizeModeToInteractive(height);
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::setRowsResizeModeToInteractive(int height)
|
||||
@@ -94,8 +99,9 @@ namespace BlackGui
|
||||
verticalHeader->setDefaultSectionSize(height);
|
||||
}
|
||||
|
||||
bool CViewBaseNonTemplate::resize() const
|
||||
bool CViewBaseNonTemplate::performResizing() const
|
||||
{
|
||||
if (m_resizeMode == ResizingOff) { return false; }
|
||||
if (m_resizeMode == ResizingOnce) { return m_resizeCount < 1; }
|
||||
if (m_resizeMode == ResizingAuto)
|
||||
{
|
||||
@@ -103,7 +109,7 @@ namespace BlackGui
|
||||
if (m_resizeAutoNthTime < 2) return true;
|
||||
return (m_resizeCount % m_resizeAutoNthTime) == 0;
|
||||
}
|
||||
return m_resizeMode == ResizingOff;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::fullResizeToContents()
|
||||
@@ -115,7 +121,11 @@ namespace BlackGui
|
||||
m_resizeCount++;
|
||||
this->resizeColumnsToContents();
|
||||
this->resizeRowsToContents();
|
||||
|
||||
if (m_forceStretchLastColumnWhenResized)
|
||||
{
|
||||
// re-stretch
|
||||
this->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
qDebug() << this->objectName() << "resize ms:" << t.elapsed() << QThread::currentThreadId();
|
||||
}
|
||||
|
||||
@@ -158,7 +168,7 @@ namespace BlackGui
|
||||
{
|
||||
ContainerType sortedContainer = model->sortContainerByColumn(container, sortColumn, sortOrder);
|
||||
QMetaObject::invokeMethod(this, "updateContainer",
|
||||
Q_ARG(QVariant, sortedContainer.toQVariant()), Q_ARG(bool, false), Q_ARG(bool, resize));
|
||||
Q_ARG(QVariant, sortedContainer.toQVariant()), Q_ARG(bool, false), Q_ARG(bool, resize));
|
||||
});
|
||||
worker->then(this, &CViewBase::asyncUpdateFinished);
|
||||
return worker;
|
||||
@@ -166,7 +176,7 @@ namespace BlackGui
|
||||
|
||||
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::updateContainerMaybeAsync(const ContainerType &container, bool sort, bool resize)
|
||||
{
|
||||
if (container.size() > asyncThreshold && sort)
|
||||
if (container.size() > asyncRowsCountThreshold && sort)
|
||||
{
|
||||
// larger container with sorting
|
||||
updateContainerAsync(container, sort, resize);
|
||||
@@ -231,7 +241,7 @@ namespace BlackGui
|
||||
template <class ModelClass, class ContainerType> void CViewBase<ModelClass, ContainerType>::performResizeToContents()
|
||||
{
|
||||
// small set or large set?
|
||||
if (this->resize())
|
||||
if (this->performResizing())
|
||||
{
|
||||
this->fullResizeToContents();
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ namespace BlackGui
|
||||
{
|
||||
ResizingAuto, //!< always resizing, \sa m_resizeAutoNthTime
|
||||
ResizingOnce, //!< only one time
|
||||
ResizingOff
|
||||
ResizingOff //!< never
|
||||
};
|
||||
|
||||
//! When to use asynchronous updates
|
||||
static const int asyncThreshold = 50;
|
||||
//! When (rows count) to use asynchronous updates
|
||||
static const int asyncRowsCountThreshold = 50;
|
||||
|
||||
//! Clear data
|
||||
virtual void clear() = 0;
|
||||
@@ -101,21 +101,22 @@ namespace BlackGui
|
||||
//! \param variant contains the container
|
||||
//! \param sort
|
||||
//! \param resize
|
||||
virtual int performUpdateContainer(const QVariant &variant, bool sort, bool resize) = 0;
|
||||
virtual int performUpdateContainer(const QVariant &variant, bool sort, bool performResizing) = 0;
|
||||
|
||||
//! Skip resizing because of size?
|
||||
virtual bool reachedResizeThreshold() const = 0;
|
||||
|
||||
//! Resize or skip resize?
|
||||
virtual bool resize() const;
|
||||
virtual bool performResizing() const;
|
||||
|
||||
//! Init default values
|
||||
virtual void standardInit();
|
||||
|
||||
ResizeMode m_resizeMode = ResizingAuto; //!< mode
|
||||
int m_resizeCount = 0; //!< flag / counter,how many resize activities
|
||||
int m_skipResizeThreshold = 40; //!< when to skip resize
|
||||
int m_resizeCount = 0; //!< flag / counter, how many resize activities
|
||||
int m_skipResizeThreshold = 40; //!< when to skip resize (rows count)
|
||||
int m_resizeAutoNthTime = 1; //!< with ResizeAuto, resize every n-th time
|
||||
bool m_forceStretchLastColumnWhenResized = false; //! a small table might (few columns) might to fail stretching, force again
|
||||
|
||||
protected slots:
|
||||
//! Helper method with template free signature serving as callback from threaded worker
|
||||
@@ -153,13 +154,13 @@ namespace BlackGui
|
||||
virtual void clear() override { Q_ASSERT(this->m_model); this->m_model->clear(); }
|
||||
|
||||
//! Update whole container
|
||||
int updateContainer(const ContainerType &container, bool sort = true, bool resize = true);
|
||||
int updateContainer(const ContainerType &container, bool sort = true, bool performResizing = true);
|
||||
|
||||
//! Update whole container in background
|
||||
BlackMisc::CWorker *updateContainerAsync(const ContainerType &container, bool sort = true, bool resize = true);
|
||||
BlackMisc::CWorker *updateContainerAsync(const ContainerType &container, bool sort = true, bool performResizing = true);
|
||||
|
||||
//! Based on size call sync / async update
|
||||
void updateContainerMaybeAsync(const ContainerType &container, bool sort = true, bool resize = true);
|
||||
void updateContainerMaybeAsync(const ContainerType &container, bool sort = true, bool performResizing = true);
|
||||
|
||||
//! Insert
|
||||
template<class ObjectType> void insert(const ObjectType &value, bool resize = true)
|
||||
@@ -211,7 +212,7 @@ namespace BlackGui
|
||||
virtual void performResizeToContents() override;
|
||||
|
||||
//! \copydoc CViewBaseNonTemplate::performUpdateContainer
|
||||
virtual int performUpdateContainer(const QVariant &variant, bool sort, bool resize) override;
|
||||
virtual int performUpdateContainer(const QVariant &variant, bool sort, bool performResizing) override;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user