From 6a06aa046088920782f87f98cad2a2bdafb39869 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 16 Feb 2016 22:36:47 +0100 Subject: [PATCH] refs #485, moved some gui classes to components Originally components was meant for runtime based components. No longer true, so some classes now better find into that namespace. --- src/blackgui/aircraftcombinedtypeselector.cpp | 102 ------- src/blackgui/aircraftcombinedtypeselector.h | 70 ----- src/blackgui/colorselector.cpp | 197 -------------- src/blackgui/colorselector.h | 92 ------- src/blackgui/commandinput.h | 45 ---- .../aircraftcombinedtypeselector.cpp | 103 +++++++ .../components/aircraftcombinedtypeselector.h | 71 +++++ .../aircraftcombinedtypeselector.ui | 0 .../components/audiovolumecomponent.h | 2 +- src/blackgui/components/cockpitcomcomponent.h | 4 +- .../components/cockpitcomcomponent.ui | 18 +- src/blackgui/components/cockpitcomponent.h | 2 +- src/blackgui/components/colorselector.cpp | 200 ++++++++++++++ src/blackgui/components/colorselector.h | 94 +++++++ .../{ => components}/colorselector.ui | 0 .../{ => components}/commandinput.cpp | 30 ++- src/blackgui/components/commandinput.h | 48 ++++ .../components/coreinfoareacomponent.h | 4 +- src/blackgui/components/corestatuscomponent.h | 1 - .../components/flightplancomponent.ui | 6 +- src/blackgui/components/hotkeydialog.cpp | 252 ++++++++++++++++++ src/blackgui/components/hotkeydialog.h | 107 ++++++++ src/blackgui/{ => components}/hotkeydialog.ui | 0 src/blackgui/components/logcomponent.ui | 6 +- src/blackgui/components/logincomponent.ui | 14 +- src/blackgui/components/modelmodeselector.cpp | 66 +++++ src/blackgui/components/modelmodeselector.h | 62 +++++ .../{ => components}/modelmodeselector.ui | 0 .../components/selcalcodeselector.cpp | 112 ++++++++ src/blackgui/components/selcalcodeselector.h | 75 ++++++ .../{ => components}/selcalcodeselector.ui | 0 src/blackgui/components/serverform.cpp | 92 +++++++ src/blackgui/components/serverform.h | 61 +++++ src/blackgui/{ => components}/serverform.ui | 0 .../components/serverlistselector.cpp | 66 +++++ src/blackgui/components/serverlistselector.h | 50 ++++ src/blackgui/components/settingscomponent.h | 4 +- .../components/settingshotkeycomponent.cpp | 3 +- .../components/settingshotkeycomponent.h | 1 - .../components/settingsnetworkcomponent.h | 4 +- .../settingsnetworkserverscomponent.h | 4 +- .../settingsnetworkserverscomponent.ui | 6 +- src/blackgui/components/simulatorselector.cpp | 151 +++++++++++ src/blackgui/components/simulatorselector.h | 85 ++++++ .../{ => components}/simulatorselector.ui | 0 src/blackgui/components/statusmessageform.cpp | 60 +++++ src/blackgui/components/statusmessageform.h | 54 ++++ .../{ => components}/statusmessageform.ui | 0 .../components/statusmessageformsmall.cpp | 50 ++++ .../components/statusmessageformsmall.h | 54 ++++ .../statusmessageformsmall.ui | 0 .../components/textmessagecomponent.h | 4 +- .../transpondercodespinbox.cpp | 20 +- .../components/transpondercodespinbox.h | 36 +++ .../components/transpondermodeselector.cpp | 99 +++++++ .../components/transpondermodeselector.h | 87 ++++++ src/blackgui/editors/aircrafticaoform.ui | 6 +- src/blackgui/editors/liveryform.ui | 8 +- src/blackgui/editors/modelmappingform.ui | 12 +- .../editors/modelmappingmodifyform.cpp | 1 + .../editors/modelmappingmodifyform.ui | 12 +- src/blackgui/filters/aircrafticaofilterbar.ui | 6 +- .../filters/aircraftmodelfilterbar.ui | 6 +- src/blackgui/filters/liveryfilterbar.cpp | 1 + src/blackgui/filters/liveryfilterbar.ui | 8 +- src/blackgui/hotkeydialog.cpp | 251 ----------------- src/blackgui/hotkeydialog.h | 109 -------- src/blackgui/modelmodeselector.cpp | 63 ----- src/blackgui/modelmodeselector.h | 59 ---- src/blackgui/overlaymessages.ui | 12 +- src/blackgui/selcalcodeselector.cpp | 109 -------- src/blackgui/selcalcodeselector.h | 73 ----- src/blackgui/serverform.cpp | 91 ------- src/blackgui/serverform.h | 59 ---- src/blackgui/serverlistselector.cpp | 65 ----- src/blackgui/serverlistselector.h | 47 ---- src/blackgui/simulatorselector.cpp | 148 ---------- src/blackgui/simulatorselector.h | 82 ------ src/blackgui/statusmessageform.cpp | 58 ---- src/blackgui/statusmessageform.h | 52 ---- src/blackgui/statusmessageformsmall.cpp | 48 ---- src/blackgui/statusmessageformsmall.h | 52 ---- src/blackgui/textmessagetextedit.h | 2 - src/blackgui/transpondercodespinbox.h | 34 --- src/blackgui/transpondermodeselector.cpp | 96 ------- src/blackgui/transpondermodeselector.h | 85 ------ src/swiftcore/swiftcore.ui | 6 +- src/swiftguistandard/swiftguistd.h | 2 +- 88 files changed, 2243 insertions(+), 2194 deletions(-) delete mode 100644 src/blackgui/aircraftcombinedtypeselector.cpp delete mode 100644 src/blackgui/aircraftcombinedtypeselector.h delete mode 100644 src/blackgui/colorselector.cpp delete mode 100644 src/blackgui/colorselector.h delete mode 100644 src/blackgui/commandinput.h create mode 100644 src/blackgui/components/aircraftcombinedtypeselector.cpp create mode 100644 src/blackgui/components/aircraftcombinedtypeselector.h rename src/blackgui/{ => components}/aircraftcombinedtypeselector.ui (100%) create mode 100644 src/blackgui/components/colorselector.cpp create mode 100644 src/blackgui/components/colorselector.h rename src/blackgui/{ => components}/colorselector.ui (100%) rename src/blackgui/{ => components}/commandinput.cpp (50%) create mode 100644 src/blackgui/components/commandinput.h create mode 100644 src/blackgui/components/hotkeydialog.cpp create mode 100644 src/blackgui/components/hotkeydialog.h rename src/blackgui/{ => components}/hotkeydialog.ui (100%) create mode 100644 src/blackgui/components/modelmodeselector.cpp create mode 100644 src/blackgui/components/modelmodeselector.h rename src/blackgui/{ => components}/modelmodeselector.ui (100%) create mode 100644 src/blackgui/components/selcalcodeselector.cpp create mode 100644 src/blackgui/components/selcalcodeselector.h rename src/blackgui/{ => components}/selcalcodeselector.ui (100%) create mode 100644 src/blackgui/components/serverform.cpp create mode 100644 src/blackgui/components/serverform.h rename src/blackgui/{ => components}/serverform.ui (100%) create mode 100644 src/blackgui/components/serverlistselector.cpp create mode 100644 src/blackgui/components/serverlistselector.h create mode 100644 src/blackgui/components/simulatorselector.cpp create mode 100644 src/blackgui/components/simulatorselector.h rename src/blackgui/{ => components}/simulatorselector.ui (100%) create mode 100644 src/blackgui/components/statusmessageform.cpp create mode 100644 src/blackgui/components/statusmessageform.h rename src/blackgui/{ => components}/statusmessageform.ui (100%) create mode 100644 src/blackgui/components/statusmessageformsmall.cpp create mode 100644 src/blackgui/components/statusmessageformsmall.h rename src/blackgui/{ => components}/statusmessageformsmall.ui (100%) rename src/blackgui/{ => components}/transpondercodespinbox.cpp (55%) create mode 100644 src/blackgui/components/transpondercodespinbox.h create mode 100644 src/blackgui/components/transpondermodeselector.cpp create mode 100644 src/blackgui/components/transpondermodeselector.h delete mode 100644 src/blackgui/hotkeydialog.cpp delete mode 100644 src/blackgui/hotkeydialog.h delete mode 100644 src/blackgui/modelmodeselector.cpp delete mode 100644 src/blackgui/modelmodeselector.h delete mode 100644 src/blackgui/selcalcodeselector.cpp delete mode 100644 src/blackgui/selcalcodeselector.h delete mode 100644 src/blackgui/serverform.cpp delete mode 100644 src/blackgui/serverform.h delete mode 100644 src/blackgui/serverlistselector.cpp delete mode 100644 src/blackgui/serverlistselector.h delete mode 100644 src/blackgui/simulatorselector.cpp delete mode 100644 src/blackgui/simulatorselector.h delete mode 100644 src/blackgui/statusmessageform.cpp delete mode 100644 src/blackgui/statusmessageform.h delete mode 100644 src/blackgui/statusmessageformsmall.cpp delete mode 100644 src/blackgui/statusmessageformsmall.h delete mode 100644 src/blackgui/transpondercodespinbox.h delete mode 100644 src/blackgui/transpondermodeselector.cpp delete mode 100644 src/blackgui/transpondermodeselector.h diff --git a/src/blackgui/aircraftcombinedtypeselector.cpp b/src/blackgui/aircraftcombinedtypeselector.cpp deleted file mode 100644 index 5492279f3..000000000 --- a/src/blackgui/aircraftcombinedtypeselector.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (C) 2015 - * 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 "aircraftcombinedtypeselector.h" -#include "ui_aircraftcombinedtypeselector.h" -#include "blackgui/guiutility.h" - -using namespace BlackMisc::Aviation; - -namespace BlackGui -{ - - CAircraftCombinedTypeSelector::CAircraftCombinedTypeSelector(QWidget *parent) : - QFrame(parent), - ui(new Ui::CAircraftCombinedTypeSelector) - { - ui->setupUi(this); - this->connect(ui->le_CombinedType, &QLineEdit::editingFinished, this, &CAircraftCombinedTypeSelector::ps_CombinedTypeEntered); - this->connect(ui->le_CombinedType, &QLineEdit::returnPressed, this, &CAircraftCombinedTypeSelector::ps_CombinedTypeEntered); - - this->connect(ui->cb_EngineCount, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox); - this->connect(ui->cb_EngineType, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox); - this->connect(ui->cb_Type, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox); - } - - CAircraftCombinedTypeSelector::~CAircraftCombinedTypeSelector() - { } - - void CAircraftCombinedTypeSelector::setCombinedType(const QString &combinedCode) - { - QString engineCount, engineType, aircraftType; - QString cc(combinedCode.trimmed().toUpper().left(3)); - if (cc.length() > 0) { aircraftType = cc.left(1); } - if (cc.length() > 1) { engineCount = cc.mid(1, 1); } - if (cc.length() > 2) { engineType = cc.mid(2, 1); } - - CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_EngineCount, engineCount, "unspecified"); - CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_EngineType, engineType, "unspecified"); - CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_Type, aircraftType, "unspecified"); - - this->ui->le_CombinedType->setText(cc); - } - - void CAircraftCombinedTypeSelector::setCombinedType(const BlackMisc::Aviation::CAircraftIcaoCode &icao) - { - this->setCombinedType(icao.getCombinedType()); - } - - void CAircraftCombinedTypeSelector::clear() - { - this->setCombinedType(""); - this->ui->le_CombinedType->clear(); - } - - void CAircraftCombinedTypeSelector::setReadOnly(bool readOnly) - { - ui->le_CombinedType->setReadOnly(readOnly); - ui->cb_EngineCount->setEnabled(!readOnly); - ui->cb_EngineType->setEnabled(!readOnly); - ui->cb_Type->setEnabled(!readOnly); - } - - QString CAircraftCombinedTypeSelector::getCombinedType() const - { - QString ct(ui->le_CombinedType->text().trimmed().toUpper()); - if (CAircraftIcaoCode::isValidCombinedType(ct)) { return ct; } - - QString ct2(getCombinedTypeFromComboBoxes()); - return ct2; - } - - void CAircraftCombinedTypeSelector::ps_CombinedTypeEntered() - { - QString cc(ui->le_CombinedType->text().trimmed().toUpper()); - this->setCombinedType(cc); - } - - void CAircraftCombinedTypeSelector::ps_ChangedComboBox(const QString &text) - { - Q_UNUSED(text); - QString ct(getCombinedTypeFromComboBoxes()); - ui->le_CombinedType->setText(ct); - } - - QString CAircraftCombinedTypeSelector::getCombinedTypeFromComboBoxes() const - { - // try to get from combox boxes instead - QString ec = ui->cb_EngineCount->currentText().left(1); - QString t = ui->cb_Type->currentText().left(1); - QString et = ui->cb_EngineType->currentText().left(1); - - QString ct2(QString(t + ec + et).toUpper()); - return ct2.replace('U', '-'); - } - -} // ns diff --git a/src/blackgui/aircraftcombinedtypeselector.h b/src/blackgui/aircraftcombinedtypeselector.h deleted file mode 100644 index f5771432b..000000000 --- a/src/blackgui/aircraftcombinedtypeselector.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2015 - * 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_AIRCRAFTCOMBINEDTYPESELECTOR_H -#define BLACKGUI_AIRCRAFTCOMBINEDTYPESELECTOR_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/aviation/aircrafticaocode.h" -#include -#include - -namespace Ui { class CAircraftCombinedTypeSelector; } - -namespace BlackGui -{ - - /*! - * Select by comined type ("L2J", "H1T", ...) - */ - class BLACKGUI_EXPORT CAircraftCombinedTypeSelector : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CAircraftCombinedTypeSelector(QWidget *parent = nullptr); - - //! Destructor - ~CAircraftCombinedTypeSelector(); - - //! Set comined code, e.g. L1P - void setCombinedType(const QString &combinedCode); - - //! Combined code from aircraft ICAO - void setCombinedType(const BlackMisc::Aviation::CAircraftIcaoCode &icao); - - //! Clear - void clear(); - - //! Read only - void setReadOnly(bool readOnly); - - //! Get the combined type, e.g. "L2P" - QString getCombinedType() const; - - private slots: - //! Code has been entered - void ps_CombinedTypeEntered(); - - //! Changed combobox - void ps_ChangedComboBox(const QString &text); - - private: - //! Combined type from comboboxes - QString getCombinedTypeFromComboBoxes() const; - - QScopedPointer ui; - }; - -} // ns - -#endif // guard diff --git a/src/blackgui/colorselector.cpp b/src/blackgui/colorselector.cpp deleted file mode 100644 index f1763b9b9..000000000 --- a/src/blackgui/colorselector.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* 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 "blackmisc/rgbcolor.h" -#include "colorselector.h" -#include "guiutility.h" -#include "ui_colorselector.h" -#include -#include -#include -#include -#include -#include - -using namespace BlackMisc; - -namespace BlackGui -{ - CColorSelector::CColorSelector(QWidget *parent) : - QFrame(parent), - ui(new Ui::CColorSelector) - { - ui->setupUi(this); - ui->tb_ColorDialog->setIcon(CIcons::color16()); - this->setAcceptDrops(true); - connect(this->ui->tb_ColorDialog, &QToolButton::clicked, this, &CColorSelector::ps_colorDialog); - connect(this->ui->le_Color, &QLineEdit::editingFinished, this, &CColorSelector::ps_returnPressed); - connect(this->ui->le_Color, &QLineEdit::returnPressed, this, &CColorSelector::ps_returnPressed); - - QCompleter *completer = new QCompleter(QColor::colorNames(), this); - completer->setCaseSensitivity(Qt::CaseInsensitive); - completer->setMaxVisibleItems(10); - completer->setCompletionMode(QCompleter::PopupCompletion); - this->ui->le_Color->setCompleter(completer); - this->connect(completer, static_cast(&QCompleter::activated), this, &CColorSelector::ps_colorName); - } - - CColorSelector::~CColorSelector() { } - - void CColorSelector::setColor(const BlackMisc::CRgbColor &color) - { - if (color == m_lastColor) { return; } - if (!color.isValid()) - { - this->clear(); - m_lastColor = CRgbColor(); - } - else - { - this->ui->le_Color->setText(color.hex()); - this->ui->lbl_ColorIcon->setPixmap(color.toPixmap()); - m_lastColor = color; - } - emit colorChanged(color); - } - - void CColorSelector::setColor(const QColor &color) - { - this->setColor(CRgbColor(color)); - } - - const BlackMisc::CRgbColor CColorSelector::getColor() const - { - CRgbColor q(this->ui->le_Color->text()); - return q; - } - - void CColorSelector::setReadOnly(bool readOnly) - { - this->ui->le_Color->setReadOnly(readOnly); - this->ui->tb_ColorDialog->setVisible(!readOnly); - this->setAcceptDrops(!readOnly); - } - - void CColorSelector::clear() - { - this->ui->le_Color->clear(); - this->ui->lbl_ColorIcon->setPixmap(QPixmap()); - } - - void CColorSelector::dragEnterEvent(QDragEnterEvent *event) - { - if (!event) { return; } - setBackgroundRole(QPalette::Highlight); - event->acceptProposedAction(); - } - - void CColorSelector::dragMoveEvent(QDragMoveEvent *event) - { - if (!event) { return; } - event->acceptProposedAction(); - } - - void CColorSelector::dragLeaveEvent(QDragLeaveEvent *event) - { - event->accept(); - } - - void CColorSelector::dropEvent(QDropEvent *event) - { - if (!event) { return; } - const QMimeData *mime = event->mimeData(); - if (!mime) { return; } - - if (mime->hasColor()) - { - QColor color = qvariant_cast(event->mimeData()->colorData()); - if (!color.isValid()) { return; } - this->setColor(color); - } - else if (CGuiUtility::hasSwiftVariantMimeType(mime)) - { - CVariant valueVariant(CGuiUtility::fromSwiftDragAndDropData(mime)); - if (valueVariant.isValid()) - { - if (valueVariant.canConvert()) - { - CRgbColor rgb(valueVariant.value()); - if (!rgb.isValid()) { return; } - this->setColor(rgb); - } - else if (valueVariant.canConvert()) - { - QColor qColor(valueVariant.value()); - if (!qColor.isValid()) { return; } - this->setColor(qColor); - } - } - } - else if (mime->hasText()) - { - QString t = mime->text(); - if (t.isEmpty()) { return; } - if (!t.contains("{")) - { - // we assume a color string, not an object (because there are no {}) - CRgbColor c(t); - if (!c.isValid()) { return; } - this->setColor(c); - } - } - } - - void CColorSelector::mousePressEvent(QMouseEvent *event) - { - if (!event || event->button() != Qt::LeftButton) { QFrame::mousePressEvent(event); } - CRgbColor c(this->getColor()); - if (!c.isValid()) { return; } - - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - - mimeData->setColorData(QVariant::fromValue(c.toQColor())); - drag->setMimeData(mimeData); - drag->setPixmap(c.toPixmap()); - - Qt::DropAction dropAction = drag->exec(Qt::CopyAction); - Q_UNUSED(dropAction); - } - - void CColorSelector::ps_colorDialog() - { - QColor q = this->getColor().toQColor(); - if (!q.isValid()) { q = m_lastColor.toQColor(); } - QColor newColor = QColorDialog::getColor(q, this, "Color picker"); - if (!newColor.isValid()) { return; } - this->setColor(newColor); - } - - void CColorSelector::ps_returnPressed() - { - CRgbColor color = this->getColor(); - if (color.isValid()) - { - this->setColor(color); - } - } - - void CColorSelector::ps_colorName(const QString &colorName) - { - if (colorName.isEmpty()) { return; } - CRgbColor c(colorName, true); - if (c.isValid()) { this->setColor(c); } - } - - void CColorSelector::resetToLastValidColor() - { - if (!m_lastColor.isValid()) { return; } - this->setColor(this->m_lastColor); - } -} // ns diff --git a/src/blackgui/colorselector.h b/src/blackgui/colorselector.h deleted file mode 100644 index d26073af5..000000000 --- a/src/blackgui/colorselector.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2015 - * 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_COLORSELECTOR_H -#define BLACKGUI_COLORSELECTOR_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/rgbcolor.h" -#include - -namespace Ui { class CColorSelector; } - -namespace BlackGui -{ - /*! - * Select a color - */ - class BLACKGUI_EXPORT CColorSelector : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CColorSelector(QWidget *parent = nullptr); - - //! Destructor - ~CColorSelector(); - - //! Color - void setColor(const BlackMisc::CRgbColor &color); - - //! Color - void setColor(const QColor &color); - - //! Selected color - const BlackMisc::CRgbColor getColor() const; - - //! Read only - void setReadOnly(bool readOnly); - - //! Clear - void clear(); - - signals: - //! Color has been changed - void colorChanged(const BlackMisc::CRgbColor &color); - - protected: - //! \copydoc QWidget::dragEnterEvent - virtual void dragEnterEvent(QDragEnterEvent *event) override; - - //! \copydoc QWidget::dragMoveEvent - virtual void dragMoveEvent(QDragMoveEvent *event) override; - - //! \copydoc QWidget::dragLeaveEvent - virtual void dragLeaveEvent(QDragLeaveEvent *event) override; - - //! \copydoc QWidget::dropEvent - virtual void dropEvent(QDropEvent *event) override; - - //! For dragging the color - virtual void mousePressEvent(QMouseEvent *event) override; - - private slots: - //! Open up a color dilaog - void ps_colorDialog(); - - //! Enter pressed - void ps_returnPressed(); - - //! Set color by color name - void ps_colorName(const QString &colorName); - - private: - QScopedPointer ui; - BlackMisc::CRgbColor m_lastColor; - - //! Reset to last valid color - void resetToLastValidColor(); - }; - -} // ns - -#endif // guard diff --git a/src/blackgui/commandinput.h b/src/blackgui/commandinput.h deleted file mode 100644 index 432438cb7..000000000 --- a/src/blackgui/commandinput.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2015 - * 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_COMMANDINPUT_H -#define BLACKGUI_COMMANDINPUT_H - -#include "blackguiexport.h" -#include "blackmisc/identifiable.h" -#include -#include - -namespace BlackGui -{ - //! Specialized LineEdit for command inputs - class BLACKGUI_EXPORT CCommandInput : - public QLineEdit, - public BlackMisc::CIdentifiable - { - Q_OBJECT - - public: - //! Constructor - CCommandInput(QWidget *parent = nullptr); - - //! Destructor - ~CCommandInput() {} - - signals: - //! Command was entered - void commandEntered(const QString &command, const BlackMisc::CIdentifier &originator); - - private slots: - //! Basic command validation - void ps_validateCommand(); - }; -} -#endif // guard diff --git a/src/blackgui/components/aircraftcombinedtypeselector.cpp b/src/blackgui/components/aircraftcombinedtypeselector.cpp new file mode 100644 index 000000000..5a5cdf73a --- /dev/null +++ b/src/blackgui/components/aircraftcombinedtypeselector.cpp @@ -0,0 +1,103 @@ +/* Copyright (C) 2015 + * 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 "aircraftcombinedtypeselector.h" +#include "ui_aircraftcombinedtypeselector.h" +#include "blackgui/guiutility.h" + +using namespace BlackMisc::Aviation; + +namespace BlackGui +{ + namespace Components + { + CAircraftCombinedTypeSelector::CAircraftCombinedTypeSelector(QWidget *parent) : + QFrame(parent), + ui(new Ui::CAircraftCombinedTypeSelector) + { + ui->setupUi(this); + this->connect(ui->le_CombinedType, &QLineEdit::editingFinished, this, &CAircraftCombinedTypeSelector::ps_CombinedTypeEntered); + this->connect(ui->le_CombinedType, &QLineEdit::returnPressed, this, &CAircraftCombinedTypeSelector::ps_CombinedTypeEntered); + + this->connect(ui->cb_EngineCount, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox); + this->connect(ui->cb_EngineType, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox); + this->connect(ui->cb_Type, &QComboBox::currentTextChanged, this, &CAircraftCombinedTypeSelector::ps_ChangedComboBox); + } + + CAircraftCombinedTypeSelector::~CAircraftCombinedTypeSelector() + { } + + void CAircraftCombinedTypeSelector::setCombinedType(const QString &combinedCode) + { + QString engineCount, engineType, aircraftType; + QString cc(combinedCode.trimmed().toUpper().left(3)); + if (cc.length() > 0) { aircraftType = cc.left(1); } + if (cc.length() > 1) { engineCount = cc.mid(1, 1); } + if (cc.length() > 2) { engineType = cc.mid(2, 1); } + + CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_EngineCount, engineCount, "unspecified"); + CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_EngineType, engineType, "unspecified"); + CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_Type, aircraftType, "unspecified"); + + this->ui->le_CombinedType->setText(cc); + } + + void CAircraftCombinedTypeSelector::setCombinedType(const BlackMisc::Aviation::CAircraftIcaoCode &icao) + { + this->setCombinedType(icao.getCombinedType()); + } + + void CAircraftCombinedTypeSelector::clear() + { + this->setCombinedType(""); + this->ui->le_CombinedType->clear(); + } + + void CAircraftCombinedTypeSelector::setReadOnly(bool readOnly) + { + ui->le_CombinedType->setReadOnly(readOnly); + ui->cb_EngineCount->setEnabled(!readOnly); + ui->cb_EngineType->setEnabled(!readOnly); + ui->cb_Type->setEnabled(!readOnly); + } + + QString CAircraftCombinedTypeSelector::getCombinedType() const + { + QString ct(ui->le_CombinedType->text().trimmed().toUpper()); + if (CAircraftIcaoCode::isValidCombinedType(ct)) { return ct; } + + QString ct2(getCombinedTypeFromComboBoxes()); + return ct2; + } + + void CAircraftCombinedTypeSelector::ps_CombinedTypeEntered() + { + QString cc(ui->le_CombinedType->text().trimmed().toUpper()); + this->setCombinedType(cc); + } + + void CAircraftCombinedTypeSelector::ps_ChangedComboBox(const QString &text) + { + Q_UNUSED(text); + QString ct(getCombinedTypeFromComboBoxes()); + ui->le_CombinedType->setText(ct); + } + + QString CAircraftCombinedTypeSelector::getCombinedTypeFromComboBoxes() const + { + // try to get from combox boxes instead + QString ec = ui->cb_EngineCount->currentText().left(1); + QString t = ui->cb_Type->currentText().left(1); + QString et = ui->cb_EngineType->currentText().left(1); + + QString ct2(QString(t + ec + et).toUpper()); + return ct2.replace('U', '-'); + } + } // ns +} // ns diff --git a/src/blackgui/components/aircraftcombinedtypeselector.h b/src/blackgui/components/aircraftcombinedtypeselector.h new file mode 100644 index 000000000..0cc6e88fe --- /dev/null +++ b/src/blackgui/components/aircraftcombinedtypeselector.h @@ -0,0 +1,71 @@ +/* Copyright (C) 2015 + * 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_AIRCRAFTCOMBINEDTYPESELECTOR_H +#define BLACKGUI_AIRCRAFTCOMBINEDTYPESELECTOR_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/aviation/aircrafticaocode.h" +#include +#include + +namespace Ui { class CAircraftCombinedTypeSelector; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Select by comined type ("L2J", "H1T", ...) + */ + class BLACKGUI_EXPORT CAircraftCombinedTypeSelector : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CAircraftCombinedTypeSelector(QWidget *parent = nullptr); + + //! Destructor + ~CAircraftCombinedTypeSelector(); + + //! Set comined code, e.g. L1P + void setCombinedType(const QString &combinedCode); + + //! Combined code from aircraft ICAO + void setCombinedType(const BlackMisc::Aviation::CAircraftIcaoCode &icao); + + //! Clear + void clear(); + + //! Read only + void setReadOnly(bool readOnly); + + //! Get the combined type, e.g. "L2P" + QString getCombinedType() const; + + private slots: + //! Code has been entered + void ps_CombinedTypeEntered(); + + //! Changed combobox + void ps_ChangedComboBox(const QString &text); + + private: + //! Combined type from comboboxes + QString getCombinedTypeFromComboBoxes() const; + + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/aircraftcombinedtypeselector.ui b/src/blackgui/components/aircraftcombinedtypeselector.ui similarity index 100% rename from src/blackgui/aircraftcombinedtypeselector.ui rename to src/blackgui/components/aircraftcombinedtypeselector.ui diff --git a/src/blackgui/components/audiovolumecomponent.h b/src/blackgui/components/audiovolumecomponent.h index 12f381b47..15f3a3447 100644 --- a/src/blackgui/components/audiovolumecomponent.h +++ b/src/blackgui/components/audiovolumecomponent.h @@ -35,7 +35,7 @@ namespace BlackGui ~CAudioVolumeComponent(); private slots: - //! Mute toggle + //! Mute toggleBlackGui::Components::CHotkeyDialog void ps_onMuteChanged(bool muted); //! Volumes changed (elsewhere) diff --git a/src/blackgui/components/cockpitcomcomponent.h b/src/blackgui/components/cockpitcomcomponent.h index 12c330b22..bb584c1f6 100644 --- a/src/blackgui/components/cockpitcomcomponent.h +++ b/src/blackgui/components/cockpitcomcomponent.h @@ -43,10 +43,10 @@ namespace BlackGui ~CCockpitComComponent(); signals: - //! \copydoc BlackGui::CTransponderModeSelector::transponderModeChanged + //! \copydoc BlackGui::Components::CTransponderModeSelector::transponderModeChanged void transponderModeChanged(BlackMisc::Aviation::CTransponder::TransponderMode newMode); - //! \copydoc BlackGui::CTransponderModeSelector::transponderStateIdentEnded + //! \copydoc BlackGui::Components::CTransponderModeSelector::transponderStateIdentEnded void transponderStateIdentEnded(); public slots: diff --git a/src/blackgui/components/cockpitcomcomponent.ui b/src/blackgui/components/cockpitcomcomponent.ui index 2cc3abbf2..b9d2e25a6 100644 --- a/src/blackgui/components/cockpitcomcomponent.ui +++ b/src/blackgui/components/cockpitcomcomponent.ui @@ -71,7 +71,7 @@ 0 - + 0 @@ -492,7 +492,7 @@ 0 - + 0 @@ -514,7 +514,7 @@ - + 0 @@ -618,19 +618,19 @@ 1 - BlackGui::CTransponderModeSelector + BlackGui::Components::CTransponderModeSelector QComboBox -
blackgui/transpondermodeselector.h
+
blackgui/components/transpondermodeselector.h
- BlackGui::CTransponderCodeSpinBox + BlackGui::Components::CTransponderCodeSpinBox QSpinBox -
blackgui/transpondercodespinbox.h
+
blackgui/components/transpondercodespinbox.h
- BlackGui::CSelcalCodeSelector + BlackGui::Components::CSelcalCodeSelector QFrame -
blackgui/selcalcodeselector.h
+
blackgui/components/selcalcodeselector.h
1
diff --git a/src/blackgui/components/cockpitcomponent.h b/src/blackgui/components/cockpitcomponent.h index dd27e5296..51874c697 100644 --- a/src/blackgui/components/cockpitcomponent.h +++ b/src/blackgui/components/cockpitcomponent.h @@ -44,7 +44,7 @@ namespace BlackGui bool isInfoAreaShown() const; public slots: - //! \copydoc BlackGui::CTransponderModeSelector::setSelectedTransponderModeStateIdent + //! \copydoc BlackGui::Components::CTransponderModeSelector::setSelectedTransponderModeStateIdent void setSelectedTransponderModeStateIdent(); private slots: diff --git a/src/blackgui/components/colorselector.cpp b/src/blackgui/components/colorselector.cpp new file mode 100644 index 000000000..b9f01011e --- /dev/null +++ b/src/blackgui/components/colorselector.cpp @@ -0,0 +1,200 @@ +/* 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 "blackmisc/rgbcolor.h" +#include "colorselector.h" +#include "guiutility.h" +#include "ui_colorselector.h" +#include +#include +#include +#include +#include +#include + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + CColorSelector::CColorSelector(QWidget *parent) : + QFrame(parent), + ui(new Ui::CColorSelector) + { + ui->setupUi(this); + ui->tb_ColorDialog->setIcon(CIcons::color16()); + this->setAcceptDrops(true); + connect(this->ui->tb_ColorDialog, &QToolButton::clicked, this, &CColorSelector::ps_colorDialog); + connect(this->ui->le_Color, &QLineEdit::editingFinished, this, &CColorSelector::ps_returnPressed); + connect(this->ui->le_Color, &QLineEdit::returnPressed, this, &CColorSelector::ps_returnPressed); + + QCompleter *completer = new QCompleter(QColor::colorNames(), this); + completer->setCaseSensitivity(Qt::CaseInsensitive); + completer->setMaxVisibleItems(10); + completer->setCompletionMode(QCompleter::PopupCompletion); + this->ui->le_Color->setCompleter(completer); + this->connect(completer, static_cast(&QCompleter::activated), this, &CColorSelector::ps_colorName); + } + + CColorSelector::~CColorSelector() { } + + void CColorSelector::setColor(const BlackMisc::CRgbColor &color) + { + if (color == m_lastColor) { return; } + if (!color.isValid()) + { + this->clear(); + m_lastColor = CRgbColor(); + } + else + { + this->ui->le_Color->setText(color.hex()); + this->ui->lbl_ColorIcon->setPixmap(color.toPixmap()); + m_lastColor = color; + } + emit colorChanged(color); + } + + void CColorSelector::setColor(const QColor &color) + { + this->setColor(CRgbColor(color)); + } + + const BlackMisc::CRgbColor CColorSelector::getColor() const + { + CRgbColor q(this->ui->le_Color->text()); + return q; + } + + void CColorSelector::setReadOnly(bool readOnly) + { + this->ui->le_Color->setReadOnly(readOnly); + this->ui->tb_ColorDialog->setVisible(!readOnly); + this->setAcceptDrops(!readOnly); + } + + void CColorSelector::clear() + { + this->ui->le_Color->clear(); + this->ui->lbl_ColorIcon->setPixmap(QPixmap()); + } + + void CColorSelector::dragEnterEvent(QDragEnterEvent *event) + { + if (!event) { return; } + setBackgroundRole(QPalette::Highlight); + event->acceptProposedAction(); + } + + void CColorSelector::dragMoveEvent(QDragMoveEvent *event) + { + if (!event) { return; } + event->acceptProposedAction(); + } + + void CColorSelector::dragLeaveEvent(QDragLeaveEvent *event) + { + event->accept(); + } + + void CColorSelector::dropEvent(QDropEvent *event) + { + if (!event) { return; } + const QMimeData *mime = event->mimeData(); + if (!mime) { return; } + + if (mime->hasColor()) + { + QColor color = qvariant_cast(event->mimeData()->colorData()); + if (!color.isValid()) { return; } + this->setColor(color); + } + else if (CGuiUtility::hasSwiftVariantMimeType(mime)) + { + CVariant valueVariant(CGuiUtility::fromSwiftDragAndDropData(mime)); + if (valueVariant.isValid()) + { + if (valueVariant.canConvert()) + { + CRgbColor rgb(valueVariant.value()); + if (!rgb.isValid()) { return; } + this->setColor(rgb); + } + else if (valueVariant.canConvert()) + { + QColor qColor(valueVariant.value()); + if (!qColor.isValid()) { return; } + this->setColor(qColor); + } + } + } + else if (mime->hasText()) + { + QString t = mime->text(); + if (t.isEmpty()) { return; } + if (!t.contains("{")) + { + // we assume a color string, not an object (because there are no {}) + CRgbColor c(t); + if (!c.isValid()) { return; } + this->setColor(c); + } + } + } + + void CColorSelector::mousePressEvent(QMouseEvent *event) + { + if (!event || event->button() != Qt::LeftButton) { QFrame::mousePressEvent(event); } + CRgbColor c(this->getColor()); + if (!c.isValid()) { return; } + + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + + mimeData->setColorData(QVariant::fromValue(c.toQColor())); + drag->setMimeData(mimeData); + drag->setPixmap(c.toPixmap()); + + Qt::DropAction dropAction = drag->exec(Qt::CopyAction); + Q_UNUSED(dropAction); + } + + void CColorSelector::ps_colorDialog() + { + QColor q = this->getColor().toQColor(); + if (!q.isValid()) { q = m_lastColor.toQColor(); } + QColor newColor = QColorDialog::getColor(q, this, "Color picker"); + if (!newColor.isValid()) { return; } + this->setColor(newColor); + } + + void CColorSelector::ps_returnPressed() + { + CRgbColor color = this->getColor(); + if (color.isValid()) + { + this->setColor(color); + } + } + + void CColorSelector::ps_colorName(const QString &colorName) + { + if (colorName.isEmpty()) { return; } + CRgbColor c(colorName, true); + if (c.isValid()) { this->setColor(c); } + } + + void CColorSelector::resetToLastValidColor() + { + if (!m_lastColor.isValid()) { return; } + this->setColor(this->m_lastColor); + } + } // ns +} // ns diff --git a/src/blackgui/components/colorselector.h b/src/blackgui/components/colorselector.h new file mode 100644 index 000000000..595da432e --- /dev/null +++ b/src/blackgui/components/colorselector.h @@ -0,0 +1,94 @@ +/* Copyright (C) 2015 + * 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_COLORSELECTOR_H +#define BLACKGUI_COMPONENTS_COLORSELECTOR_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/rgbcolor.h" +#include + +namespace Ui { class CColorSelector; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Select a color + */ + class BLACKGUI_EXPORT CColorSelector : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CColorSelector(QWidget *parent = nullptr); + + //! Destructor + ~CColorSelector(); + + //! Color + void setColor(const BlackMisc::CRgbColor &color); + + //! Color + void setColor(const QColor &color); + + //! Selected color + const BlackMisc::CRgbColor getColor() const; + + //! Read only + void setReadOnly(bool readOnly); + + //! Clear + void clear(); + + signals: + //! Color has been changed + void colorChanged(const BlackMisc::CRgbColor &color); + + protected: + //! \copydoc QWidget::dragEnterEvent + virtual void dragEnterEvent(QDragEnterEvent *event) override; + + //! \copydoc QWidget::dragMoveEvent + virtual void dragMoveEvent(QDragMoveEvent *event) override; + + //! \copydoc QWidget::dragLeaveEvent + virtual void dragLeaveEvent(QDragLeaveEvent *event) override; + + //! \copydoc QWidget::dropEvent + virtual void dropEvent(QDropEvent *event) override; + + //! For dragging the color + virtual void mousePressEvent(QMouseEvent *event) override; + + private slots: + //! Open up a color dilaog + void ps_colorDialog(); + + //! Enter pressed + void ps_returnPressed(); + + //! Set color by color name + void ps_colorName(const QString &colorName); + + private: + QScopedPointer ui; + BlackMisc::CRgbColor m_lastColor; + + //! Reset to last valid color + void resetToLastValidColor(); + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/colorselector.ui b/src/blackgui/components/colorselector.ui similarity index 100% rename from src/blackgui/colorselector.ui rename to src/blackgui/components/colorselector.ui diff --git a/src/blackgui/commandinput.cpp b/src/blackgui/components/commandinput.cpp similarity index 50% rename from src/blackgui/commandinput.cpp rename to src/blackgui/components/commandinput.cpp index f3ac00383..90fc1c0cd 100644 --- a/src/blackgui/commandinput.cpp +++ b/src/blackgui/components/commandinput.cpp @@ -14,21 +14,23 @@ using namespace BlackMisc; namespace BlackGui { - - CCommandInput::CCommandInput(QWidget *parent) : - QLineEdit(parent), - CIdentifiable(this) + namespace Components { - connect(this, &CCommandInput::returnPressed, this, &CCommandInput::ps_validateCommand); - } - - void CCommandInput::ps_validateCommand() - { - QString commandLine(this->text().trimmed()); - this->setText(QString()); - if (commandLine.startsWith('.')) + CCommandInput::CCommandInput(QWidget *parent) : + QLineEdit(parent), + CIdentifiable(this) { - emit commandEntered(commandLine, identifier()); + connect(this, &CCommandInput::returnPressed, this, &CCommandInput::ps_validateCommand); } - } + + void CCommandInput::ps_validateCommand() + { + QString commandLine(this->text().trimmed()); + this->setText(QString()); + if (commandLine.startsWith('.')) + { + emit commandEntered(commandLine, identifier()); + } + } + } // ns } // ns diff --git a/src/blackgui/components/commandinput.h b/src/blackgui/components/commandinput.h new file mode 100644 index 000000000..050552172 --- /dev/null +++ b/src/blackgui/components/commandinput.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2015 + * 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_COMMANDINPUT_H +#define BLACKGUI_COMPONENTS_COMMANDINPUT_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/identifiable.h" +#include +#include + +namespace BlackGui +{ + namespace Components + { + //! Specialized LineEdit for command inputs + class BLACKGUI_EXPORT CCommandInput : + public QLineEdit, + public BlackMisc::CIdentifiable + { + Q_OBJECT + + public: + //! Constructor + CCommandInput(QWidget *parent = nullptr); + + //! Destructor + ~CCommandInput() {} + + signals: + //! Command was entered + void commandEntered(const QString &command, const BlackMisc::CIdentifier &originator); + + private slots: + //! Basic command validation + void ps_validateCommand(); + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/components/coreinfoareacomponent.h b/src/blackgui/components/coreinfoareacomponent.h index ff9292b4c..e54502d83 100644 --- a/src/blackgui/components/coreinfoareacomponent.h +++ b/src/blackgui/components/coreinfoareacomponent.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKGUI_COREINFOAREACOMPONENT_H -#define BLACKGUI_COREINFOAREACOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_COREINFOAREACOMPONENT_H +#define BLACKGUI_COMPONENTS_COREINFOAREACOMPONENT_H #include "blackgui/blackguiexport.h" #include "../infoarea.h" diff --git a/src/blackgui/components/corestatuscomponent.h b/src/blackgui/components/corestatuscomponent.h index b6e862618..2493a44e5 100644 --- a/src/blackgui/components/corestatuscomponent.h +++ b/src/blackgui/components/corestatuscomponent.h @@ -22,7 +22,6 @@ namespace BlackGui { namespace Components { - //! Display status information about the core class BLACKGUI_EXPORT CCoreStatusComponent : public QFrame { diff --git a/src/blackgui/components/flightplancomponent.ui b/src/blackgui/components/flightplancomponent.ui index db2806d51..18b76bd1e 100644 --- a/src/blackgui/components/flightplancomponent.ui +++ b/src/blackgui/components/flightplancomponent.ui @@ -764,7 +764,7 @@
- + QFrame::StyledPanel @@ -945,9 +945,9 @@ - BlackGui::CSelcalCodeSelector + BlackGui::Components::CSelcalCodeSelector QFrame -
blackgui/selcalcodeselector.h
+
blackgui/components/selcalcodeselector.h
1
diff --git a/src/blackgui/components/hotkeydialog.cpp b/src/blackgui/components/hotkeydialog.cpp new file mode 100644 index 000000000..3a4286eb1 --- /dev/null +++ b/src/blackgui/components/hotkeydialog.cpp @@ -0,0 +1,252 @@ +#include "hotkeydialog.h" +#include "ui_hotkeydialog.h" +#include "blackgui/stylesheetutility.h" +#include "blackmisc/input/hotkeycombination.h" +#include "blackmisc/icon.h" +#include "blackmisc/logmessage.h" +#include +#include + +using namespace BlackMisc; +using namespace BlackMisc::Input; + +namespace BlackGui +{ + namespace Components + { + CKeySelectionBox::CKeySelectionBox(QWidget *parent) : + QComboBox(parent) + { + connect(this, static_cast(&CKeySelectionBox::currentIndexChanged), this, &CKeySelectionBox::ps_updateSelectedIndex); + } + + void CKeySelectionBox::setSelectedIndex(int index) + { + m_oldIndex = index; + setCurrentIndex(m_oldIndex); + } + + void CKeySelectionBox::ps_updateSelectedIndex(int index) + { + emit keySelectionChanged(m_oldIndex, index); + m_oldIndex = index; + } + + CHotkeyDialog::CHotkeyDialog(const BlackMisc::Input::CActionHotkey &actionHotkey, QWidget *parent) : + QDialog(parent), + ui(new Ui::CHotkeyDialog), + m_actionHotkey(actionHotkey), + m_actionModel(this) + { + m_inputManager = BlackCore::CInputManager::instance(); + + ui->setupUi(this); + ui->advancedFrame->hide(); + + ui->tv_actions->setModel(&m_actionModel); + ui->pb_advancedMode->setIcon(BlackMisc::CIcons::arrowMediumSouth16()); + selectAction(); + + if (!actionHotkey.getCombination().isEmpty()) { ui->pb_selectedHotkey->setText(actionHotkey.getCombination().toQString()); } + + connect(ui->pb_advancedMode, &QPushButton::clicked, this, &CHotkeyDialog::ps_advancedModeChanged); + connect(ui->pb_selectedHotkey, &QPushButton::clicked, this, &CHotkeyDialog::ps_selectHotkey); + connect(ui->pb_accept, &QPushButton::clicked, this, &CHotkeyDialog::ps_accept); + connect(ui->pb_cancel, &QPushButton::clicked, this, &CHotkeyDialog::reject); + connect(m_inputManager, &BlackCore::CInputManager::combinationSelectionChanged, this, &CHotkeyDialog::ps_combinationSelectionChanged); + connect(m_inputManager, &BlackCore::CInputManager::combinationSelectionFinished, this, &CHotkeyDialog::ps_combinationSelectionFinished); + connect(ui->tv_actions->selectionModel(), &QItemSelectionModel::selectionChanged, this, &CHotkeyDialog::ps_changeSelectedAction); + + initStyleSheet(); + } + + CHotkeyDialog::~CHotkeyDialog() + { + } + + void CHotkeyDialog::setRegisteredApplications(const BlackMisc::CIdentifierList &applications) + { + for (const auto &app : applications) + { + ui->cb_identifier->addItem(app.getMachineName(), QVariant::fromValue(app)); + } + } + + void CHotkeyDialog::initStyleSheet() + { + const QString s = CStyleSheetUtility::instance().styles( + { + CStyleSheetUtility::fileNameFonts(), + CStyleSheetUtility::fileNameStandardWidget() + } + ); + setStyleSheet(s); + } + + CActionHotkey CHotkeyDialog::getActionHotkey(const CActionHotkey &initial, const CIdentifierList &applications, QWidget *parent) + { + CHotkeyDialog editDialog(initial, parent); + editDialog.setWindowModality(Qt::WindowModal); + // add local application + editDialog.setRegisteredApplications(applications); + if (editDialog.exec()) { return editDialog.getSelectedActionHotkey(); } + else { return {}; } + + } + + void CHotkeyDialog::ps_advancedModeChanged() + { + if (m_actionHotkey.getCombination().isEmpty()) return; + + if (!ui->advancedFrame->isVisible()) + { + setupAdvancedFrame(); + ui->advancedFrame->show(); + ui->pb_advancedMode->setIcon(BlackMisc::CIcons::arrowMediumNorth16()); + } + else + { + ui->pb_advancedMode->setIcon(BlackMisc::CIcons::arrowMediumSouth16()); + ui->advancedFrame->hide(); + ui->gb_hotkey->resize(0, 0); + } + } + + void CHotkeyDialog::ps_selectHotkey() + { + ui->pb_selectedHotkey->setText("Press any key/button..."); + m_inputManager->startCapture(); + } + + void CHotkeyDialog::ps_combinationSelectionChanged(const BlackMisc::Input::CHotkeyCombination &combination) + { + ui->pb_selectedHotkey->setText(combination.toFormattedQString()); + } + + void CHotkeyDialog::ps_combinationSelectionFinished(const BlackMisc::Input::CHotkeyCombination &combination) + { + m_actionHotkey.setCombination(combination); + synchronize(); + } + + void CHotkeyDialog::ps_changeSelectedAction(const QItemSelection &selected, const QItemSelection &deselected) + { + Q_UNUSED(deselected); + const auto index = selected.indexes().first(); + m_actionHotkey.setAction(index.data(Models::CActionModel::ActionRole).toString()); + } + + void CHotkeyDialog::ps_accept() + { + if (m_actionHotkey.getApplicableMachine().getMachineName().isEmpty()) + { + CLogMessage().validationWarning("Missing %1") << ui->gb_machine->title(); + return; + } + + if (m_actionHotkey.getCombination().isEmpty()) + { + CLogMessage().validationWarning("Missing %1") << ui->gb_hotkey->title(); + return; + } + + if (m_actionHotkey.getAction().isEmpty()) + { + CLogMessage().validationWarning("Missing %1") << ui->gb_action->title(); + return; + } + + QDialog::accept(); + } + + void CHotkeyDialog::synchronize() + { + synchronizeSimpleSelection(); + synchronizeAdvancedSelection(); + } + + void CHotkeyDialog::synchronizeSimpleSelection() + { + ui->pb_selectedHotkey->setText(m_actionHotkey.getCombination().toFormattedQString()); + } + + void CHotkeyDialog::synchronizeAdvancedSelection() + { + if (ui->advancedFrame->isVisible()) { setupAdvancedFrame(); } + } + + void CHotkeyDialog::setupAdvancedFrame() + { + clearAdvancedFrame(); + auto allSupportedKeys = CKeyboardKeyList::allSupportedKeys(); + + QStringList splittedKeys = m_actionHotkey.getCombination().toQString().split('+', QString::SkipEmptyParts); + for (const auto &splittedKey : splittedKeys) + { + if (splittedKey == "+") continue; + + int currentIndex = -1; + CKeySelectionBox *ksb = new CKeySelectionBox(ui->advancedFrame); + for (const auto &supportedKey : allSupportedKeys) + { + QString supportedKeyAsString = supportedKey.toQString(); + ksb->addItem(supportedKeyAsString, QVariant::fromValue(supportedKey)); + if (supportedKeyAsString == splittedKey) + { + currentIndex = ksb->count() - 1; + } + } + ksb->setSelectedIndex(currentIndex); + ui->advancedFrame->layout()->addWidget(ksb); + int position = ui->advancedFrame->layout()->count() - 1; + ksb->setProperty("position", position); + connect(ksb, &CKeySelectionBox::keySelectionChanged, this, &CHotkeyDialog::advancedKeyChanged); + } + } + + void CHotkeyDialog::clearAdvancedFrame() + { + QLayout *layout = ui->advancedFrame->layout(); + QLayoutItem *child; + + while ((child = layout->takeAt(0)) != 0) + { + if (child->widget()) child->widget()->deleteLater(); + delete child; + } + } + + void CHotkeyDialog::advancedKeyChanged(int oldIndex, int newIndex) + { + CKeySelectionBox *ksb = qobject_cast(sender()); + Q_ASSERT(ksb); + CKeyboardKey oldKey = ksb->itemData(oldIndex).value(); + CKeyboardKey newKey = ksb->itemData(newIndex).value(); + + auto combination = m_actionHotkey.getCombination(); + combination.replaceKey(oldKey, newKey); + m_actionHotkey.setCombination(combination); + synchronize(); + } + + void CHotkeyDialog::selectAction() + { + if (m_actionHotkey.getAction().isEmpty()) return; + + const auto tokens = m_actionHotkey.getAction().split("/", QString::SkipEmptyParts); + QModelIndex parentIndex = QModelIndex(); + + for (const auto &token : tokens) + { + QModelIndex startIndex = m_actionModel.index(0, 0, parentIndex); + auto indexList = m_actionModel.match(startIndex, Qt::DisplayRole, QVariant::fromValue(token)); + if (indexList.isEmpty()) return; + parentIndex = indexList.first(); + ui->tv_actions->expand(parentIndex); + } + + QItemSelectionModel *selectionModel = ui->tv_actions->selectionModel(); + selectionModel->select(parentIndex, QItemSelectionModel::Select); + } + } // ns +} // ns diff --git a/src/blackgui/components/hotkeydialog.h b/src/blackgui/components/hotkeydialog.h new file mode 100644 index 000000000..36665828b --- /dev/null +++ b/src/blackgui/components/hotkeydialog.h @@ -0,0 +1,107 @@ +/* Copyright (C) 2014 + * 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_HOTKEYDIALOG_H +#define BLACKGUI_COMPONENTS_HOTKEYDIALOG_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/models/actionmodel.h" +#include "blackcore/inputmanager.h" +#include "blackmisc/input/hotkeycombination.h" +#include "blackmisc/input/actionhotkeylist.h" +#include "blackmisc/identifierlist.h" +#include +#include +#include + +namespace Ui { class CHotkeyDialog; } + +namespace BlackGui +{ + namespace Components + { + /*! + * ComboBox for selecting keyboard keys + */ + class BLACKGUI_EXPORT CKeySelectionBox : public QComboBox + { + Q_OBJECT + + public: + //! Constructor + CKeySelectionBox(QWidget *parent = nullptr); + + //! Set key with index as selected + void setSelectedIndex(int index); + + signals: + //! User has changed the selection + void keySelectionChanged(int oldIndex, int newIndex); + + private slots: + void ps_updateSelectedIndex(int index); + + private: + int m_oldIndex; + }; + + /*! + * Hotkey dialog + */ + class BLACKGUI_EXPORT CHotkeyDialog : public QDialog + { + Q_OBJECT + + public: + //! Constructor + CHotkeyDialog(const BlackMisc::Input::CActionHotkey &actionHotkey, QWidget *parent = nullptr); + + //! Destructor + ~CHotkeyDialog(); + + //! Get hotkey selected by user + BlackMisc::Input::CActionHotkey getSelectedActionHotkey() const { return m_actionHotkey; } + + //! Set registered applications + void setRegisteredApplications(const BlackMisc::CIdentifierList &applications); + + //! Init style sheet + void initStyleSheet(); + + //! getHotkey runs the hotkey dialog and returns the result + static BlackMisc::Input::CActionHotkey getActionHotkey(const BlackMisc::Input::CActionHotkey &initial, const BlackMisc::CIdentifierList &applications, + QWidget *parent = nullptr); + + private: + void ps_advancedModeChanged(); + void ps_selectHotkey(); + void ps_combinationSelectionChanged(const BlackMisc::Input::CHotkeyCombination &combination); + void ps_combinationSelectionFinished(const BlackMisc::Input::CHotkeyCombination &combination); + void ps_changeSelectedAction(const QItemSelection &selected, const QItemSelection &deselected); + void ps_accept(); + + void synchronize(); + void synchronizeSimpleSelection(); + void synchronizeAdvancedSelection(); + void setupAdvancedFrame(); + void clearAdvancedFrame(); + void advancedKeyChanged(int oldIndex, int newIndex); + void selectAction(); + + QScopedPointer ui; + BlackMisc::Input::CActionHotkey m_actionHotkey; + BlackGui::Models::CActionModel m_actionModel; + BlackCore::CInputManager *m_inputManager; + }; + } // ns +} // ns + +#endif diff --git a/src/blackgui/hotkeydialog.ui b/src/blackgui/components/hotkeydialog.ui similarity index 100% rename from src/blackgui/hotkeydialog.ui rename to src/blackgui/components/hotkeydialog.ui diff --git a/src/blackgui/components/logcomponent.ui b/src/blackgui/components/logcomponent.ui index 846dd1185..65ada6749 100644 --- a/src/blackgui/components/logcomponent.ui +++ b/src/blackgui/components/logcomponent.ui @@ -83,7 +83,7 @@
- + 0 @@ -171,9 +171,9 @@
blackgui/views/statusmessageview.h
- BlackGui::CStatusMessageForm + BlackGui::Components::CStatusMessageForm QFrame -
blackgui/statusmessageform.h
+
blackgui/components/statusmessageform.h
1
diff --git a/src/blackgui/components/logincomponent.ui b/src/blackgui/components/logincomponent.ui index 59e835e83..5824b46ac 100644 --- a/src/blackgui/components/logincomponent.ui +++ b/src/blackgui/components/logincomponent.ui @@ -156,7 +156,7 @@
- + @@ -212,7 +212,7 @@ - + @@ -501,7 +501,7 @@ 2 - + QFrame::StyledPanel @@ -567,14 +567,14 @@ 1 - BlackGui::CServerListSelector + BlackGui::Components::CServerListSelector QComboBox -
blackgui/serverlistselector.h
+
blackgui/components/serverlistselector.h
- BlackGui::CServerForm + BlackGui::Components::CServerForm QFrame -
blackgui/serverform.h
+
blackgui/components/serverform.h
1
diff --git a/src/blackgui/components/modelmodeselector.cpp b/src/blackgui/components/modelmodeselector.cpp new file mode 100644 index 000000000..82a097b76 --- /dev/null +++ b/src/blackgui/components/modelmodeselector.cpp @@ -0,0 +1,66 @@ +/* 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 "modelmodeselector.h" +#include "ui_modelmodeselector.h" + +using namespace BlackMisc::Simulation; + +namespace BlackGui +{ + namespace Components + { + CModelModeSelector::CModelModeSelector(QWidget *parent) : + QFrame(parent), + ui(new Ui::CModelModeSelector) + { + ui->setupUi(this); + connect(ui->rb_Include, &QRadioButton::released, this, &CModelModeSelector::changed); + } + + CModelModeSelector::~CModelModeSelector() + { + // void + } + + BlackMisc::Simulation::CAircraftModel::ModelMode CModelModeSelector::getMode() const + { + if (ui->rb_Include->isChecked()) + { + return CAircraftModel::Include; + } + else + { + return CAircraftModel::Exclude; + } + } + + void CModelModeSelector::setValue(CAircraftModel::ModelMode mode) + { + if (mode == CAircraftModel::Include) + { + ui->rb_Include->setChecked(true); + } + else + { + ui->rb_Exclude->setChecked(true); + } + } + + void CModelModeSelector::setValue(const CAircraftModel &model) + { + this->setValue(model.getModelMode()); + } + + void CModelModeSelector::setReadOnly(bool readOnly) + { + this->setEnabled(!readOnly); + } + } // ns +} // ns diff --git a/src/blackgui/components/modelmodeselector.h b/src/blackgui/components/modelmodeselector.h new file mode 100644 index 000000000..aae07d911 --- /dev/null +++ b/src/blackgui/components/modelmodeselector.h @@ -0,0 +1,62 @@ +/* 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_MODELMODESELECTOR_H +#define BLACKGUI_COMPONENTS_MODELMODESELECTOR_H + +#include "blackguiexport.h" +#include "blackmisc/simulation/aircraftmodel.h" +#include +#include + +namespace Ui { class CModelModeSelector; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Select the mode + */ + class BLACKGUI_EXPORT CModelModeSelector : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CModelModeSelector(QWidget *parent = nullptr); + + //! Destructor + ~CModelModeSelector(); + + //! Get mode + BlackMisc::Simulation::CAircraftModel::ModelMode getMode() const; + + //! Set mode + void setValue(BlackMisc::Simulation::CAircraftModel::ModelMode mode); + + //! Set mode + void setValue(const BlackMisc::Simulation::CAircraftModel &model); + + //! Read only + void setReadOnly(bool readOnly); + + signals: + //! Value changed + void changed(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/modelmodeselector.ui b/src/blackgui/components/modelmodeselector.ui similarity index 100% rename from src/blackgui/modelmodeselector.ui rename to src/blackgui/components/modelmodeselector.ui diff --git a/src/blackgui/components/selcalcodeselector.cpp b/src/blackgui/components/selcalcodeselector.cpp new file mode 100644 index 000000000..c1d8e79a9 --- /dev/null +++ b/src/blackgui/components/selcalcodeselector.cpp @@ -0,0 +1,112 @@ +/* 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 "selcalcodeselector.h" +#include "ui_selcalcodeselector.h" +#include "blackmisc/aviation/selcal.h" +#include "blackmisc/icons.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; + +namespace BlackGui +{ + namespace Components + { + CSelcalCodeSelector::CSelcalCodeSelector(QWidget *parent) : + QFrame(parent), ui(new Ui::CSelcalCodeSelector) + { + this->ui->setupUi(this); + this->resetSelcalCodes(true); + this->setValidityHint(); + this->ui->lblp_ValidCodeIcon->setToolTips("valid SELCAL", "invalid SELCAL"); + + bool c; + c = connect(this->ui->cb_SelcalPairs1, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged())); + Q_ASSERT(c); + c = connect(this->ui->cb_SelcalPairs2, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged())); + Q_ASSERT(c); + Q_UNUSED(c); + } + + CSelcalCodeSelector::~CSelcalCodeSelector() + { } + + QString CSelcalCodeSelector::getSelcalCode() const + { + QString selcal = this->ui->cb_SelcalPairs1->currentText(); + selcal.append(this->ui->cb_SelcalPairs2->currentText()); + return selcal; + } + + BlackMisc::Aviation::CSelcal CSelcalCodeSelector::getSelcal() const + { + CSelcal selcal(getSelcalCode()); + return selcal; + } + + void CSelcalCodeSelector::resetSelcalCodes(bool allowEmptyValue) + { + this->ui->cb_SelcalPairs1->clear(); + if (allowEmptyValue) this->ui->cb_SelcalPairs1->addItem(" "); + this->ui->cb_SelcalPairs1->addItems(BlackMisc::Aviation::CSelcal::codePairs()); + this->ui->cb_SelcalPairs2->clear(); + if (allowEmptyValue) this->ui->cb_SelcalPairs2->addItem(" "); + this->ui->cb_SelcalPairs2->addItems(BlackMisc::Aviation::CSelcal::codePairs()); + } + + void CSelcalCodeSelector::setSelcalCode(const QString &selcal) + { + if (selcal.length() == 4 && this->getSelcalCode() == selcal) return; // avoid unintended signals + QString s = selcal.isEmpty() ? " " : selcal.toUpper().trimmed(); + Q_ASSERT(s.length() == 4); + if (s.length() != 4) return; + QString s1 = s.left(2); + QString s2 = s.right(2); + if (BlackMisc::Aviation::CSelcal::codePairs().contains(s1)) + { + this->ui->cb_SelcalPairs1->setCurrentText(s1); + } + if (BlackMisc::Aviation::CSelcal::codePairs().contains(s2)) + { + this->ui->cb_SelcalPairs2->setCurrentText(s2); + } + } + + void CSelcalCodeSelector::setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal) + { + this->setSelcalCode(selcal.getCode()); + } + + bool CSelcalCodeSelector::hasValidCode() const + { + QString s = this->getSelcalCode(); + if (s.length() != 4) return false; + return BlackMisc::Aviation::CSelcal::isValidCode(s); + } + + void CSelcalCodeSelector::clear() + { + if (this->ui->cb_SelcalPairs1->count() < 1) { this->resetSelcalCodes(true); } + this->ui->cb_SelcalPairs1->setCurrentIndex(0); + this->ui->cb_SelcalPairs2->setCurrentIndex(0); + } + + void CSelcalCodeSelector::ps_selcalIndexChanged() + { + this->setValidityHint(); + emit valueChanged(); + } + + void CSelcalCodeSelector::setValidityHint() + { + this->ui->lblp_ValidCodeIcon->setTicked(this->hasValidCode()); + } + } // ns +} // ns diff --git a/src/blackgui/components/selcalcodeselector.h b/src/blackgui/components/selcalcodeselector.h new file mode 100644 index 000000000..43db717c9 --- /dev/null +++ b/src/blackgui/components/selcalcodeselector.h @@ -0,0 +1,75 @@ +/* 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_SELCALCODESELECTOR_H +#define BLACKGUI_SELCALCODESELECTOR_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/aviation/selcal.h" +#include +#include + +namespace Ui { class CSelcalCodeSelector; } +namespace BlackGui +{ + namespace Components + { + //! SELCAL mode selector + class BLACKGUI_EXPORT CSelcalCodeSelector : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CSelcalCodeSelector(QWidget *parent = nullptr); + + //! Destructor + ~CSelcalCodeSelector(); + + //! SELCAL code + QString getSelcalCode() const; + + //! SELCAL + BlackMisc::Aviation::CSelcal getSelcal() const; + + //! Reset the SELCAL code + void resetSelcalCodes(bool allowEmptyValue = false); + + //! Set the SELCAL code + void setSelcalCode(const QString &selcal); + + //! Set the SELCAL code + void setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal); + + //! Valid code? + bool hasValidCode() const; + + //! Clear + void clear(); + + signals: + //! Value has been changed + void valueChanged(); + + private slots: + //! SELCAL changed + void ps_selcalIndexChanged(); + + private: + QScopedPointer ui; + + //! Set valid/invalid icon + void setValidityHint(); + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/selcalcodeselector.ui b/src/blackgui/components/selcalcodeselector.ui similarity index 100% rename from src/blackgui/selcalcodeselector.ui rename to src/blackgui/components/selcalcodeselector.ui diff --git a/src/blackgui/components/serverform.cpp b/src/blackgui/components/serverform.cpp new file mode 100644 index 000000000..9658d4daf --- /dev/null +++ b/src/blackgui/components/serverform.cpp @@ -0,0 +1,92 @@ +/* Copyright (C) 2014 + * 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 "serverform.h" +#include "ui_serverform.h" + +using namespace BlackMisc::Network; + +namespace BlackGui +{ + namespace Components + { + CServerForm::CServerForm(QWidget *parent) : + QFrame(parent), + ui(new Ui::CNetworkServerForm) + { + ui->setupUi(this); + this->ui->le_Port->setValidator(new QIntValidator(1, 65535, this)); + } + + CServerForm::~CServerForm() + { } + + void CServerForm::setServer(const CServer &server) + { + CUser user = server.getUser(); + this->ui->le_NetworkId->setText(user.getId()); + this->ui->le_RealName->setText(user.getRealName()); + this->ui->le_Name->setText(server.getName()); + this->ui->le_Password->setText(user.getPassword()); + this->ui->le_Description->setText(server.getDescription()); + this->ui->le_Address->setText(server.getAddress()); + this->ui->le_Port->setText(QString::number(server.getPort())); + } + + BlackMisc::Network::CServer CServerForm::getServer() const + { + CUser user( + this->ui->le_NetworkId->text().trimmed(), + this->ui->le_RealName->text().trimmed().simplified(), + "", + this->ui->le_Password->text().trimmed() + ); + CServer server( + this->ui->le_Name->text().trimmed().simplified(), + this->ui->le_Description->text().trimmed().simplified(), + this->ui->le_Address->text().trimmed(), + this->ui->le_Port->text().trimmed().toInt(), + user + ); + return server; + } + + void CServerForm::setReadOnly(bool readOnly) + { + this->ui->le_NetworkId->setReadOnly(readOnly); + this->ui->le_RealName->setReadOnly(readOnly); + this->ui->le_Name->setReadOnly(readOnly); + this->ui->le_Description->setReadOnly(readOnly); + this->ui->le_Address->setReadOnly(readOnly); + this->ui->le_Port->setReadOnly(readOnly); + this->ui->le_Password->setReadOnly(readOnly); + } + + void CServerForm::showPasswordField(bool show) + { + if (this->ui->le_Password->isVisible() == show) { return; } + if (m_passwordNameLabel.isEmpty()) { m_passwordNameLabel = ui->lbl_IdPassword->text(); } + if (show) + { + ui->lbl_IdPassword->setText(m_passwordNameLabel); + } + else + { + ui->lbl_IdPassword->setText("Id"); + } + this->ui->le_Password->setVisible(show); + } + + BlackMisc::CStatusMessageList CServerForm::validate() const + { + CServer server = getServer(); + return server.validate(); + } + } // ns +} // ns diff --git a/src/blackgui/components/serverform.h b/src/blackgui/components/serverform.h new file mode 100644 index 000000000..07d7d3a3d --- /dev/null +++ b/src/blackgui/components/serverform.h @@ -0,0 +1,61 @@ +/* Copyright (C) 2014 + * 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_NETWORKSERVERFORM_H +#define BLACKGUI_COMPONENTS_NETWORKSERVERFORM_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/network/server.h" +#include "blackmisc/statusmessagelist.h" +#include +#include + +namespace Ui { class CNetworkServerForm; } + +namespace BlackGui +{ + namespace Components + { + //! Server form + class BLACKGUI_EXPORT CServerForm : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CServerForm(QWidget *parent = nullptr); + + //! Destructor + ~CServerForm(); + + //! Set server + void setServer(const BlackMisc::Network::CServer &server); + + //! Get server + BlackMisc::Network::CServer getServer() const; + + //! Set read only + void setReadOnly(bool readOnly); + + //! Show the password field + void showPasswordField(bool show); + + //! Validate and provide messages (empty means OK) + BlackMisc::CStatusMessageList validate() const; + + private: + QScopedPointer ui; + QString m_passwordNameLabel; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/serverform.ui b/src/blackgui/components/serverform.ui similarity index 100% rename from src/blackgui/serverform.ui rename to src/blackgui/components/serverform.ui diff --git a/src/blackgui/components/serverlistselector.cpp b/src/blackgui/components/serverlistselector.cpp new file mode 100644 index 000000000..bbffae078 --- /dev/null +++ b/src/blackgui/components/serverlistselector.cpp @@ -0,0 +1,66 @@ +/* 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 "serverlistselector.h" + +using namespace BlackMisc::Network; + +namespace BlackGui +{ + namespace Components + { + CServerListSelector::CServerListSelector(QWidget *parent) : + QComboBox(parent) + { + } + + void CServerListSelector::setServers(const BlackMisc::Network::CServerList &servers) + { + if (this->m_servers == servers) { return; } + this->setItemStrings(servers); + } + + BlackMisc::Network::CServer CServerListSelector::currentServer() const + { + int i = currentIndex(); + if (i < 0 || i >= m_servers.size()) { return CServer(); } + return m_servers[i]; + } + + void CServerListSelector::setItemStrings(const CServerList &servers) + { + QString currentlySelected(this->currentText()); + int index = -1; + this->m_servers = servers; + this->m_items.clear(); + for (const CServer &server : servers) + { + QString d(server.getName() + ": " + server.getDescription()); + m_items.append(d); + if (!currentlySelected.isEmpty() && index < 0 && d == currentlySelected) + { + index = m_items.size() - 1; + } + } + this->clear(); // ui + this->addItems(m_items); + + // reselect + if (this->m_items.isEmpty()) { return; } + if (this->m_items.size() == 1) + { + this->setCurrentIndex(0); + } + else if (index >= 0) + { + this->setCurrentIndex(index); + } + } + } // ns +} // ns diff --git a/src/blackgui/components/serverlistselector.h b/src/blackgui/components/serverlistselector.h new file mode 100644 index 000000000..3a1d75471 --- /dev/null +++ b/src/blackgui/components/serverlistselector.h @@ -0,0 +1,50 @@ +/* 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_COMPONENTS_SERVERLISTSELECTOR_H +#define BLACKGUI_COMPONENTS_SERVERLISTSELECTOR_H + +#include "blackgui/blackguiexport.h" +#include +#include + +#include "blackmisc/network/serverlist.h" + +namespace BlackGui +{ + namespace Components + { + //! List of servers + class BLACKGUI_EXPORT CServerListSelector : public QComboBox + { + Q_OBJECT + + public: + //! Constructor + explicit CServerListSelector(QWidget *parent = nullptr); + + //! Set the servers + void setServers(const BlackMisc::Network::CServerList &servers); + + //! Get the current server + BlackMisc::Network::CServer currentServer() const; + + private: + //! Build the item string descriptions + void setItemStrings(const BlackMisc::Network::CServerList &servers); + + BlackMisc::Network::CServerList m_servers; //!< corresponding servers + QStringList m_items; //!< items strings + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/settingscomponent.h b/src/blackgui/components/settingscomponent.h index f59851a7f..63188ca7f 100644 --- a/src/blackgui/components/settingscomponent.h +++ b/src/blackgui/components/settingscomponent.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKGUI_SETTINGSCOMPONENT_H -#define BLACKGUI_SETTINGSCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_SETTINGSCOMPONENT_H +#define BLACKGUI_COMPONENTS_SETTINGSCOMPONENT_H #include "blackgui/blackguiexport.h" #include "blackmisc/network/server.h" diff --git a/src/blackgui/components/settingshotkeycomponent.cpp b/src/blackgui/components/settingshotkeycomponent.cpp index 12f98257d..762aa7e16 100644 --- a/src/blackgui/components/settingshotkeycomponent.cpp +++ b/src/blackgui/components/settingshotkeycomponent.cpp @@ -9,7 +9,7 @@ #include "settingshotkeycomponent.h" #include "ui_settingshotkeycomponent.h" -#include "blackgui/hotkeydialog.h" +#include "blackgui/components/hotkeydialog.h" #include "blackgui/guiapplication.h" #include "blackcore/contextapplication.h" #include @@ -22,7 +22,6 @@ namespace BlackGui { namespace Components { - CSettingsHotkeyComponent::CSettingsHotkeyComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CSettingsHotkeyComponent) diff --git a/src/blackgui/components/settingshotkeycomponent.h b/src/blackgui/components/settingshotkeycomponent.h index b4807464f..d763c6ddb 100644 --- a/src/blackgui/components/settingshotkeycomponent.h +++ b/src/blackgui/components/settingshotkeycomponent.h @@ -25,7 +25,6 @@ namespace BlackGui { namespace Components { - //! Configure hotkeys class BLACKGUI_EXPORT CSettingsHotkeyComponent : public QFrame diff --git a/src/blackgui/components/settingsnetworkcomponent.h b/src/blackgui/components/settingsnetworkcomponent.h index e3b5d5d9d..d87dc55d2 100644 --- a/src/blackgui/components/settingsnetworkcomponent.h +++ b/src/blackgui/components/settingsnetworkcomponent.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKGUI_SETTINGSNETWORKCOMPONENT_H -#define BLACKGUI_SETTINGSNETWORKCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_SETTINGSNETWORKCOMPONENT_H +#define BLACKGUI_COMPONENTS_SETTINGSNETWORKCOMPONENT_H #include "blackgui/blackguiexport.h" #include diff --git a/src/blackgui/components/settingsnetworkserverscomponent.h b/src/blackgui/components/settingsnetworkserverscomponent.h index ecf69ecfa..e1cc85d82 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.h +++ b/src/blackgui/components/settingsnetworkserverscomponent.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKGUI_SETTINGSNETWORKSERVERSCOMPONENT_H -#define BLACKGUI_SETTINGSNETWORKSERVERSCOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_SETTINGSNETWORKSERVERSCOMPONENT_H +#define BLACKGUI_COMPONENTS_SETTINGSNETWORKSERVERSCOMPONENT_H #include "blackgui/blackguiexport.h" #include "blackcore/data/globalsetup.h" diff --git a/src/blackgui/components/settingsnetworkserverscomponent.ui b/src/blackgui/components/settingsnetworkserverscomponent.ui index dc2368e3c..53d6aba81 100644 --- a/src/blackgui/components/settingsnetworkserverscomponent.ui +++ b/src/blackgui/components/settingsnetworkserverscomponent.ui @@ -52,7 +52,7 @@
- + 0 @@ -157,9 +157,9 @@ - BlackGui::CServerForm + BlackGui::Components::CServerForm QFrame -
blackgui/serverform.h
+
blackgui/components/serverform.h
1
diff --git a/src/blackgui/components/simulatorselector.cpp b/src/blackgui/components/simulatorselector.cpp new file mode 100644 index 000000000..8fc148caa --- /dev/null +++ b/src/blackgui/components/simulatorselector.cpp @@ -0,0 +1,151 @@ +/* Copyright (C) 2015 + * 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 "simulatorselector.h" +#include "ui_simulatorselector.h" + +using namespace BlackMisc::Simulation; + +namespace BlackGui +{ + namespace Components + { + CSimulatorSelector::CSimulatorSelector(QWidget *parent) : + QFrame(parent), + ui(new Ui::CSimulatorSelector) + { + ui->setupUi(this); + this->setMode(CheckBoxes); + + connect(this->ui->rb_FS9, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); + connect(this->ui->rb_FSX, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); + connect(this->ui->rb_P3D, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); + connect(this->ui->rb_XPlane, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); + + connect(this->ui->cb_FS9, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); + connect(this->ui->cb_FSX, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); + connect(this->ui->cb_P3D, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); + connect(this->ui->cb_XPlane, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); + } + + CSimulatorSelector::~CSimulatorSelector() + { } + + void CSimulatorSelector::setMode(CSimulatorSelector::Mode mode) + { + this->m_mode = mode; + switch (mode) + { + default: + case CheckBoxes: + this->ui->wi_CheckBoxes->setVisible(true); + this->ui->wi_RadioButtons->setVisible(false); + break; + case RadioButtons: + this->ui->wi_CheckBoxes->setVisible(false); + this->ui->wi_RadioButtons->setVisible(true); + break; + } + } + + CSimulatorInfo CSimulatorSelector::getValue() const + { + if (this->m_noSelectionMeansAll && this->isUnselected()) + { + return CSimulatorInfo::allSimulators(); + } + + switch (this->m_mode) + { + default: + case CheckBoxes: + return CSimulatorInfo(this->ui->cb_FSX->isChecked(), this->ui->cb_FS9->isChecked(), + this->ui->cb_XPlane->isChecked(), this->ui->cb_P3D->isChecked()); + case RadioButtons: + return CSimulatorInfo(this->ui->rb_FSX->isChecked(), this->ui->rb_FS9->isChecked(), + this->ui->rb_XPlane->isChecked(), this->ui->cb_P3D->isChecked()); + } + } + + void CSimulatorSelector::setValue(const CSimulatorInfo &info) + { + this->ui->cb_FSX->setChecked(info.fsx()); + this->ui->cb_FS9->setChecked(info.fs9()); + this->ui->cb_XPlane->setChecked(info.xplane()); + this->ui->cb_P3D->setChecked(info.p3d()); + + if (info.fsx()) { this->ui->cb_FSX->setChecked(info.fsx()); return; } + if (info.fs9()) { this->ui->cb_FS9->setChecked(info.fs9()); return; } + if (info.xplane()) { this->ui->cb_XPlane->setChecked(info.xplane()); return; } + if (info.p3d()) { this->ui->cb_P3D->setChecked(info.p3d()); return; } + } + + void CSimulatorSelector::setAll() + { + // checkboxes + this->ui->cb_FSX->setChecked(true); + this->ui->cb_FS9->setChecked(true); + this->ui->cb_XPlane->setChecked(true); + this->ui->cb_P3D->setChecked(true); + + // radio + this->ui->rb_FSX->setChecked(true); + } + + bool CSimulatorSelector::isUnselected() const + { + bool c = false; + switch (this->m_mode) + { + default: + case CheckBoxes: + c = this->ui->cb_FSX->isChecked() || this->ui->cb_FS9->isChecked() || + this->ui->cb_XPlane->isChecked() || this->ui->cb_P3D->isChecked(); + break; + case RadioButtons: + c = this->ui->rb_FSX->isChecked() || this->ui->rb_FS9->isChecked() || + this->ui->rb_XPlane->isChecked() || this->ui->cb_P3D->isChecked(); + break; + } + return !c; + } + + bool CSimulatorSelector::areAllSelected() const + { + bool c = false; + switch (this->m_mode) + { + default: + case CheckBoxes: + c = this->ui->cb_FSX->isChecked() && this->ui->cb_FS9->isChecked() && + this->ui->cb_XPlane->isChecked() && this->ui->cb_P3D->isChecked(); + break; + case RadioButtons: + // actually this should never be true + c = false; + break; + } + return c; + } + + void CSimulatorSelector::ps_RadioButtonChanged(bool checked) + { + if (this->m_mode != RadioButtons) { return; } + if (!checked) { return; } // only the checked ones are relevant, as the unchecked ones are accompanied with checked events + emit this->changed(this->getValue()); + } + + void CSimulatorSelector::ps_CheckBoxChanged(bool checked) + { + if (this->m_mode != CheckBoxes) { return; } + Q_UNUSED(checked); + emit this->changed(this->getValue()); + } + } // ns +} // ns diff --git a/src/blackgui/components/simulatorselector.h b/src/blackgui/components/simulatorselector.h new file mode 100644 index 000000000..f7e111ae9 --- /dev/null +++ b/src/blackgui/components/simulatorselector.h @@ -0,0 +1,85 @@ +/* Copyright (C) 2015 + * 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. + */ + +#ifndef BLACKGUI_COMPONENTS_SIMULATORSELECTOR_H +#define BLACKGUI_COMPONENTS_SIMULATORSELECTOR_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/simulation/simulatorinfo.h" +#include +#include + +namespace Ui { class CSimulatorSelector; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Select simulator + */ + class BLACKGUI_EXPORT CSimulatorSelector : public QFrame + { + Q_OBJECT + + public: + //! How to display + enum Mode + { + CheckBoxes, + RadioButtons + }; + + //! Constructor + explicit CSimulatorSelector(QWidget *parent = nullptr); + + //! Destructor + ~CSimulatorSelector(); + + //! How to display + void setMode(Mode mode); + + //! No selection treated same as all selected (filters) + void setNoSelectionMeansAll(bool v) { this->m_noSelectionMeansAll = v; } + + //! Get the value + BlackMisc::Simulation::CSimulatorInfo getValue() const; + + //! Set the value + void setValue(const BlackMisc::Simulation::CSimulatorInfo &info); + + //! Set all, only making sense with checkboxes + void setAll(); + + //! Not selected at all + bool isUnselected() const; + + //! All selected + bool areAllSelected() const; + + signals: + //! Value has been changed + void changed(const BlackMisc::Simulation::CSimulatorInfo &info); + + private slots: + //! Radio button changed + void ps_RadioButtonChanged(bool checked); + + //! Checkbox changed + void ps_CheckBoxChanged(bool checked); + + private: + QScopedPointer ui; + Mode m_mode = CheckBoxes; + bool m_noSelectionMeansAll = false; //!< for filters, no selection means all + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/simulatorselector.ui b/src/blackgui/components/simulatorselector.ui similarity index 100% rename from src/blackgui/simulatorselector.ui rename to src/blackgui/components/simulatorselector.ui diff --git a/src/blackgui/components/statusmessageform.cpp b/src/blackgui/components/statusmessageform.cpp new file mode 100644 index 000000000..e61d14125 --- /dev/null +++ b/src/blackgui/components/statusmessageform.cpp @@ -0,0 +1,60 @@ +/* Copyright (C) 2014 + * 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 "statusmessageform.h" +#include "ui_statusmessageform.h" +#include + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + CStatusMessageForm::CStatusMessageForm(QWidget *parent) : + QFrame(parent), + ui(new Ui::CStatusMessageForm) + { + ui->setupUi(this); + } + + CStatusMessageForm::~CStatusMessageForm() + { } + + void CStatusMessageForm::setVariant(const CVariant &messageVariant) + { + if (!this->isVisible()) { return; } + this->setValue(messageVariant.value()); + } + + void CStatusMessageForm::setValue(const CStatusMessage &message) + { + ui->te_Message->setPlainText(message.getMessage()); + ui->lbl_SeverityIcon->setPixmap(message.toPixmap()); + const QString hrc(message.getHumanReadablePattern()); + if (hrc.isEmpty()) + { + ui->le_Categories->setText(message.getCategories().toQString()); + ui->le_Categories->setToolTip(""); + } + else + { + ui->le_Categories->setText(hrc); + ui->le_Categories->setToolTip(message.getCategories().toQString()); + } + ui->le_Severity->setText(message.getSeverityAsString()); + ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms()); + } + + void CStatusMessageForm::toggleVisibility() + { + this->setVisible(!isVisible()); + } + } // ns +} // ns diff --git a/src/blackgui/components/statusmessageform.h b/src/blackgui/components/statusmessageform.h new file mode 100644 index 000000000..638445c4a --- /dev/null +++ b/src/blackgui/components/statusmessageform.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2015 + * 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_STATUSMESSAGEFORM_H +#define BLACKGUI_COMPONENTS_STATUSMESSAGEFORM_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/statusmessage.h" +#include + +namespace Ui { class CStatusMessageForm; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Display details about a single status message + */ + class BLACKGUI_EXPORT CStatusMessageForm : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CStatusMessageForm(QWidget *parent = nullptr); + + //! Destructor + ~CStatusMessageForm(); + + public slots: + //! Set message + void setVariant(const BlackMisc::CVariant &messageVariant); + + //! Set message + void setValue(const BlackMisc::CStatusMessage &message); + + //! Toggle visibility + void toggleVisibility(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/statusmessageform.ui b/src/blackgui/components/statusmessageform.ui similarity index 100% rename from src/blackgui/statusmessageform.ui rename to src/blackgui/components/statusmessageform.ui diff --git a/src/blackgui/components/statusmessageformsmall.cpp b/src/blackgui/components/statusmessageformsmall.cpp new file mode 100644 index 000000000..b317ea216 --- /dev/null +++ b/src/blackgui/components/statusmessageformsmall.cpp @@ -0,0 +1,50 @@ +/* Copyright (C) 2015 + * 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 "statusmessageformsmall.h" +#include "ui_statusmessageformsmall.h" +#include + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + CStatusMessageFormSmall::CStatusMessageFormSmall(QWidget *parent) : + QFrame(parent), + ui(new Ui::CStatusMessageFormSmall) + { + ui->setupUi(this); + } + + CStatusMessageFormSmall::~CStatusMessageFormSmall() + { } + + void CStatusMessageFormSmall::setVariant(const CVariant &messageVariant) + { + if (!this->isVisible()) { return; } + this->setValue(messageVariant.value()); + } + + void CStatusMessageFormSmall::setValue(const CStatusMessage &message) + { + ui->te_Message->setPlainText(message.getMessage()); + ui->lbl_SeverityIcon->setPixmap(message.toPixmap()); + ui->le_Categories->setText(message.getHumanReadablePattern()); + ui->le_Severity->setText(message.getSeverityAsString()); + ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms()); + } + + void CStatusMessageFormSmall::toggleVisibility() + { + this->setVisible(!isVisible()); + } + } // ns +} // ns diff --git a/src/blackgui/components/statusmessageformsmall.h b/src/blackgui/components/statusmessageformsmall.h new file mode 100644 index 000000000..8ebc541c3 --- /dev/null +++ b/src/blackgui/components/statusmessageformsmall.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2015 + * 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_STATUSMESSAGEFORMSMALL_H +#define BLACKGUI_COMPONENTS_STATUSMESSAGEFORMSMALL_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/statusmessage.h" +#include + +namespace Ui { class CStatusMessageFormSmall; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Display details about a single status message + */ + class BLACKGUI_EXPORT CStatusMessageFormSmall : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CStatusMessageFormSmall(QWidget *parent = nullptr); + + //! Destructor + ~CStatusMessageFormSmall(); + + public slots: + //! Set message + void setVariant(const BlackMisc::CVariant &messageVariant); + + //! Set message + void setValue(const BlackMisc::CStatusMessage &message); + + //! Toggle visibility + void toggleVisibility(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/statusmessageformsmall.ui b/src/blackgui/components/statusmessageformsmall.ui similarity index 100% rename from src/blackgui/statusmessageformsmall.ui rename to src/blackgui/components/statusmessageformsmall.ui diff --git a/src/blackgui/components/textmessagecomponent.h b/src/blackgui/components/textmessagecomponent.h index d4f311569..1cf1c96d7 100644 --- a/src/blackgui/components/textmessagecomponent.h +++ b/src/blackgui/components/textmessagecomponent.h @@ -9,8 +9,8 @@ //! \file -#ifndef BLACKGUI_TEXTMESSAGECOMPONENT_H -#define BLACKGUI_TEXTMESSAGECOMPONENT_H +#ifndef BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H +#define BLACKGUI_COMPONENTS_TEXTMESSAGECOMPONENT_H #include "blackgui/blackguiexport.h" #include "blackgui/components/enablefordockwidgetinfoarea.h" diff --git a/src/blackgui/transpondercodespinbox.cpp b/src/blackgui/components/transpondercodespinbox.cpp similarity index 55% rename from src/blackgui/transpondercodespinbox.cpp rename to src/blackgui/components/transpondercodespinbox.cpp index 5c14f4e26..59e3a7369 100644 --- a/src/blackgui/transpondercodespinbox.cpp +++ b/src/blackgui/components/transpondercodespinbox.cpp @@ -11,14 +11,16 @@ namespace BlackGui { - CTransponderCodeSpinBox::CTransponderCodeSpinBox(QWidget *parent) : - QSpinBox(parent) - { } - - QString CTransponderCodeSpinBox::textFromValue(int value) const + namespace Components { - /* 4 - number of digits, 10 - base of number, '0' - pad character*/ - return QString("%1").arg(value, 4 , 10, QChar('0')); - } + CTransponderCodeSpinBox::CTransponderCodeSpinBox(QWidget *parent) : + QSpinBox(parent) + { } -} // namespace + QString CTransponderCodeSpinBox::textFromValue(int value) const + { + /* 4 - number of digits, 10 - base of number, '0' - pad character*/ + return QString("%1").arg(value, 4 , 10, QChar('0')); + } + } // ns +} // ns diff --git a/src/blackgui/components/transpondercodespinbox.h b/src/blackgui/components/transpondercodespinbox.h new file mode 100644 index 000000000..fc2a6c143 --- /dev/null +++ b/src/blackgui/components/transpondercodespinbox.h @@ -0,0 +1,36 @@ +/* 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_COMPONENTS_TRANSPONDERCODESPINBOX_H +#define BLACKGUI_COMPONENTS_TRANSPONDERCODESPINBOX_H + +#include "blackgui/blackguiexport.h" +#include + +namespace BlackGui +{ + namespace Components + { + //! Specialized spin box for Transponder codes + class BLACKGUI_EXPORT CTransponderCodeSpinBox : public QSpinBox + { + Q_OBJECT + public: + //! Constructor + explicit CTransponderCodeSpinBox(QWidget *parent = nullptr); + + //! \copydoc QDoubleSpinBox::textFromValue + virtual QString textFromValue(int value) const override; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/transpondermodeselector.cpp b/src/blackgui/components/transpondermodeselector.cpp new file mode 100644 index 000000000..1c716539f --- /dev/null +++ b/src/blackgui/components/transpondermodeselector.cpp @@ -0,0 +1,99 @@ +/* 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 +{ + namespace Components + { + CTransponderModeSelector::CTransponderModeSelector(QWidget *parent) : QComboBox(parent) + { + QComboBox::insertItems(0, CTransponderModeSelector::modes()); + this->m_resetTimer.setObjectName(this->objectName().append(":m_resetTimer")); + connect(&this->m_resetTimer, &QTimer::timeout, this, &CTransponderModeSelector::resetTransponderMode); + connect(this, &CTransponderModeSelector::currentTextChanged, this, &CTransponderModeSelector::setSelectedTransponderModeAsString); + this->m_resetTimer.setInterval(5000); + } + + const QString &CTransponderModeSelector::transponderStateStandby() + { + static const QString s(BlackMisc::Aviation::CTransponder::modeAsString(BlackMisc::Aviation::CTransponder::StateStandby)); + return s; + } + + const QString &CTransponderModeSelector::transponderStateIdent() + { + static const QString s(BlackMisc::Aviation::CTransponder::modeAsString(BlackMisc::Aviation::CTransponder::StateIdent)); + return s; + } + + const QString &CTransponderModeSelector::transponderModeC() + { + static const QString s(BlackMisc::Aviation::CTransponder::modeAsString(BlackMisc::Aviation::CTransponder::ModeC)); + return s; + } + + const QStringList &CTransponderModeSelector::modes() + { + static QStringList modes; + if (modes.isEmpty()) + { + modes << CTransponderModeSelector::transponderStateStandby(); + modes << CTransponderModeSelector::transponderModeC(); + modes << CTransponderModeSelector::transponderStateIdent(); + } + return modes; + } + + BlackMisc::Aviation::CTransponder::TransponderMode CTransponderModeSelector::getSelectedTransponderMode() const + { + return this->m_currentMode; + } + + 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->transponderStateIdentEnded(); } + this->m_currentMode = mode; + QString m = CTransponder::modeAsString(mode); + QComboBox::setCurrentText(m); + if (mode == CTransponder::StateIdent) + { + this->m_resetTimer.start(); + } + else + { + this->m_resetTimer.stop(); + } + emit this->transponderModeChanged(this->m_currentMode); + } + + void CTransponderModeSelector::setSelectedTransponderModeStateIdent() + { + this->setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::StateIdent); + } + + void CTransponderModeSelector::setSelectedTransponderModeAsString(const QString &mode) + { + CTransponder::TransponderMode m = CTransponder::modeFromString(mode); + if (this->m_currentMode == m) return; // nothing to change + this->setSelectedTransponderMode(m); + } + + void CTransponderModeSelector::resetTransponderMode() + { + if (!this->isIdentSelected()) return; // avoid unnecessary events + this->setSelectedTransponderMode(this->m_resetMode); + } + } // ns +} // ns diff --git a/src/blackgui/components/transpondermodeselector.h b/src/blackgui/components/transpondermodeselector.h new file mode 100644 index 000000000..84e7fdf4e --- /dev/null +++ b/src/blackgui/components/transpondermodeselector.h @@ -0,0 +1,87 @@ +/* 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_COMPONENTS_TRANSPONDERMODESELECTOR_H +#define BLACKGUI_COMPONENTS_TRANSPONDERMODESELECTOR_H + +#include "blackgui/blackguiexport.h" +#include "blackmisc/aviation/transponder.h" +#include +#include +#include + + +namespace BlackGui +{ + namespace Components + { + //! Selector for the transponder mode + //! \remarks features ident reset + class BLACKGUI_EXPORT CTransponderModeSelector : public QComboBox + { + Q_OBJECT + + + public: + //! Constructor + explicit CTransponderModeSelector(QWidget *parent = nullptr); + + //! Standby string + static const QString &transponderStateStandby(); + + //! Ident string + static const QString &transponderStateIdent(); + + //! Mode C string + static const QString &transponderModeC(); + + //! All relevant modes for GUI + static const QStringList &modes(); + + //! Selected transponder mode + BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const; + + //! Ident selected + bool isIdentSelected() const + { + return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent; + } + + public slots: + //! reset to last mode (unequal ident) + void resetTransponderMode(); + + //! Selected transponder mode + void setSelectedTransponderModeAsString(const QString &mode); + + //! Selected transponder mode + void setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode); + + //! 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; + + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/editors/aircrafticaoform.ui b/src/blackgui/editors/aircrafticaoform.ui index 3514a4722..73951d133 100644 --- a/src/blackgui/editors/aircrafticaoform.ui +++ b/src/blackgui/editors/aircrafticaoform.ui @@ -145,7 +145,7 @@
- + @@ -418,9 +418,9 @@ 1 - BlackGui::CAircraftCombinedTypeSelector + BlackGui::Components::CAircraftCombinedTypeSelector QFrame -
blackgui/aircraftcombinedtypeselector.h
+
blackgui/components/aircraftcombinedtypeselector.h
1
diff --git a/src/blackgui/editors/liveryform.ui b/src/blackgui/editors/liveryform.ui index bc8ca3fb9..d914d8886 100644 --- a/src/blackgui/editors/liveryform.ui +++ b/src/blackgui/editors/liveryform.ui @@ -92,7 +92,7 @@ 0 - + QFrame::StyledPanel @@ -102,7 +102,7 @@ - + QFrame::StyledPanel @@ -235,9 +235,9 @@ 1 - BlackGui::CColorSelector + BlackGui::Components::CColorSelector QFrame -
blackgui/colorselector.h
+
blackgui/components/colorselector.h
1
diff --git a/src/blackgui/editors/modelmappingform.ui b/src/blackgui/editors/modelmappingform.ui index cca393347..d25c79143 100644 --- a/src/blackgui/editors/modelmappingform.ui +++ b/src/blackgui/editors/modelmappingform.ui @@ -64,7 +64,7 @@
- + QFrame::StyledPanel @@ -174,7 +174,7 @@ - + QFrame::StyledPanel @@ -190,15 +190,15 @@ - BlackGui::CSimulatorSelector + BlackGui::Components::CSimulatorSelector QFrame -
blackgui/simulatorselector.h
+
blackgui/components/simulatorselector.h
1
- BlackGui::CModelModeSelector + BlackGui::Components::CModelModeSelector QFrame -
blackgui/modelmodeselector.h
+
blackgui/components/modelmodeselector.h
1
diff --git a/src/blackgui/editors/modelmappingmodifyform.cpp b/src/blackgui/editors/modelmappingmodifyform.cpp index 0c1a4f3a3..0a45f5ee0 100644 --- a/src/blackgui/editors/modelmappingmodifyform.cpp +++ b/src/blackgui/editors/modelmappingmodifyform.cpp @@ -13,6 +13,7 @@ using namespace BlackMisc; using namespace BlackMisc::Simulation; +using namespace BlackGui::Components; namespace BlackGui { diff --git a/src/blackgui/editors/modelmappingmodifyform.ui b/src/blackgui/editors/modelmappingmodifyform.ui index a09e2a737..0ff8ef1de 100644 --- a/src/blackgui/editors/modelmappingmodifyform.ui +++ b/src/blackgui/editors/modelmappingmodifyform.ui @@ -28,7 +28,7 @@
- + QFrame::StyledPanel @@ -109,7 +109,7 @@ - + QFrame::StyledPanel @@ -129,15 +129,15 @@ - BlackGui::CSimulatorSelector + BlackGui::Components::CSimulatorSelector QFrame -
blackgui/simulatorselector.h
+
blackgui/components/simulatorselector.h
1
- BlackGui::CModelModeSelector + BlackGui::Components::CModelModeSelector QFrame -
blackgui/modelmodeselector.h
+
blackgui/components/modelmodeselector.h
1
diff --git a/src/blackgui/filters/aircrafticaofilterbar.ui b/src/blackgui/filters/aircrafticaofilterbar.ui index d0f62b188..89e2ef36b 100644 --- a/src/blackgui/filters/aircrafticaofilterbar.ui +++ b/src/blackgui/filters/aircrafticaofilterbar.ui @@ -122,7 +122,7 @@
- + 0 @@ -141,9 +141,9 @@ - BlackGui::CAircraftCombinedTypeSelector + BlackGui::Components::CAircraftCombinedTypeSelector QFrame -
blackgui/aircraftcombinedtypeselector.h
+
blackgui/components/aircraftcombinedtypeselector.h
1
diff --git a/src/blackgui/filters/aircraftmodelfilterbar.ui b/src/blackgui/filters/aircraftmodelfilterbar.ui index 1a50f9672..ccefc3ac8 100644 --- a/src/blackgui/filters/aircraftmodelfilterbar.ui +++ b/src/blackgui/filters/aircraftmodelfilterbar.ui @@ -166,7 +166,7 @@
- + @@ -182,9 +182,9 @@ - BlackGui::CSimulatorSelector + BlackGui::Components::CSimulatorSelector QFrame -
blackgui/simulatorselector.h
+
blackgui/components/simulatorselector.h
1
diff --git a/src/blackgui/filters/liveryfilterbar.cpp b/src/blackgui/filters/liveryfilterbar.cpp index 3bcdc6a81..12fa7092c 100644 --- a/src/blackgui/filters/liveryfilterbar.cpp +++ b/src/blackgui/filters/liveryfilterbar.cpp @@ -13,6 +13,7 @@ using namespace BlackMisc::Aviation; using namespace BlackGui::Models; +using namespace BlackGui::Components; namespace BlackGui { diff --git a/src/blackgui/filters/liveryfilterbar.ui b/src/blackgui/filters/liveryfilterbar.ui index 8ca7c58f4..2ba1a6dd5 100644 --- a/src/blackgui/filters/liveryfilterbar.ui +++ b/src/blackgui/filters/liveryfilterbar.ui @@ -124,7 +124,7 @@
- + QFrame::StyledPanel @@ -134,7 +134,7 @@ - + QFrame::StyledPanel @@ -236,9 +236,9 @@ - BlackGui::CColorSelector + BlackGui::Components::CColorSelector QFrame -
blackgui/colorselector.h
+
blackgui/components/colorselector.h
1
diff --git a/src/blackgui/hotkeydialog.cpp b/src/blackgui/hotkeydialog.cpp deleted file mode 100644 index 3bf491ca2..000000000 --- a/src/blackgui/hotkeydialog.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include "hotkeydialog.h" -#include "ui_hotkeydialog.h" -#include "blackgui/stylesheetutility.h" -#include "blackmisc/input/hotkeycombination.h" -#include "blackmisc/icon.h" -#include "blackmisc/logmessage.h" -#include -#include - -using namespace BlackMisc; -using namespace BlackMisc::Input; - -namespace BlackGui -{ - - CKeySelectionBox::CKeySelectionBox(QWidget *parent) : - QComboBox(parent) - { - connect(this, static_cast(&CKeySelectionBox::currentIndexChanged), this, &CKeySelectionBox::ps_updateSelectedIndex); - } - - void CKeySelectionBox::setSelectedIndex(int index) - { - m_oldIndex = index; - setCurrentIndex(m_oldIndex); - } - - void CKeySelectionBox::ps_updateSelectedIndex(int index) - { - emit keySelectionChanged(m_oldIndex, index); - m_oldIndex = index; - } - - CHotkeyDialog::CHotkeyDialog(const BlackMisc::Input::CActionHotkey &actionHotkey, QWidget *parent) : - QDialog(parent), - ui(new Ui::CHotkeyDialog), - m_actionHotkey(actionHotkey), - m_actionModel(this) - { - m_inputManager = BlackCore::CInputManager::instance(); - - ui->setupUi(this); - ui->advancedFrame->hide(); - - ui->tv_actions->setModel(&m_actionModel); - ui->pb_advancedMode->setIcon(BlackMisc::CIcons::arrowMediumSouth16()); - selectAction(); - - if (!actionHotkey.getCombination().isEmpty()) { ui->pb_selectedHotkey->setText(actionHotkey.getCombination().toQString()); } - - connect(ui->pb_advancedMode, &QPushButton::clicked, this, &CHotkeyDialog::ps_advancedModeChanged); - connect(ui->pb_selectedHotkey, &QPushButton::clicked, this, &CHotkeyDialog::ps_selectHotkey); - connect(ui->pb_accept, &QPushButton::clicked, this, &CHotkeyDialog::ps_accept); - connect(ui->pb_cancel, &QPushButton::clicked, this, &CHotkeyDialog::reject); - connect(m_inputManager, &BlackCore::CInputManager::combinationSelectionChanged, this, &CHotkeyDialog::ps_combinationSelectionChanged); - connect(m_inputManager, &BlackCore::CInputManager::combinationSelectionFinished, this, &CHotkeyDialog::ps_combinationSelectionFinished); - connect(ui->tv_actions->selectionModel(), &QItemSelectionModel::selectionChanged, this, &CHotkeyDialog::ps_changeSelectedAction); - - initStyleSheet(); - } - - CHotkeyDialog::~CHotkeyDialog() - { - } - - void CHotkeyDialog::setRegisteredApplications(const BlackMisc::CIdentifierList &applications) - { - for (const auto & app : applications) - { - ui->cb_identifier->addItem(app.getMachineName(), QVariant::fromValue(app)); - } - } - - void CHotkeyDialog::initStyleSheet() - { - const QString s = CStyleSheetUtility::instance().styles( - { - CStyleSheetUtility::fileNameFonts(), - CStyleSheetUtility::fileNameStandardWidget() - } - ); - setStyleSheet(s); - } - - CActionHotkey CHotkeyDialog::getActionHotkey(const CActionHotkey &initial, const CIdentifierList &applications, QWidget *parent) - { - CHotkeyDialog editDialog(initial, parent); - editDialog.setWindowModality(Qt::WindowModal); - // add local application - editDialog.setRegisteredApplications(applications); - if (editDialog.exec()) { return editDialog.getSelectedActionHotkey(); } - else { return {}; } - - } - - void CHotkeyDialog::ps_advancedModeChanged() - { - if (m_actionHotkey.getCombination().isEmpty()) return; - - if (!ui->advancedFrame->isVisible()) - { - setupAdvancedFrame(); - ui->advancedFrame->show(); - ui->pb_advancedMode->setIcon(BlackMisc::CIcons::arrowMediumNorth16()); - } - else - { - ui->pb_advancedMode->setIcon(BlackMisc::CIcons::arrowMediumSouth16()); - ui->advancedFrame->hide(); - ui->gb_hotkey->resize(0, 0); - } - } - - void CHotkeyDialog::ps_selectHotkey() - { - ui->pb_selectedHotkey->setText("Press any key/button..."); - m_inputManager->startCapture(); - } - - void CHotkeyDialog::ps_combinationSelectionChanged(const BlackMisc::Input::CHotkeyCombination &combination) - { - ui->pb_selectedHotkey->setText(combination.toFormattedQString()); - } - - void CHotkeyDialog::ps_combinationSelectionFinished(const BlackMisc::Input::CHotkeyCombination &combination) - { - m_actionHotkey.setCombination(combination); - synchronize(); - } - - void CHotkeyDialog::ps_changeSelectedAction(const QItemSelection &selected, const QItemSelection &deselected) - { - Q_UNUSED(deselected); - const auto index = selected.indexes().first(); - m_actionHotkey.setAction(index.data(Models::CActionModel::ActionRole).toString()); - } - - void CHotkeyDialog::ps_accept() - { - if (m_actionHotkey.getApplicableMachine().getMachineName().isEmpty()) - { - CLogMessage().validationWarning("Missing %1") << ui->gb_machine->title(); - return; - } - - if (m_actionHotkey.getCombination().isEmpty()) - { - CLogMessage().validationWarning("Missing %1") << ui->gb_hotkey->title(); - return; - } - - if (m_actionHotkey.getAction().isEmpty()) - { - CLogMessage().validationWarning("Missing %1") << ui->gb_action->title(); - return; - } - - QDialog::accept(); - } - - void CHotkeyDialog::synchronize() - { - synchronizeSimpleSelection(); - synchronizeAdvancedSelection(); - } - - void CHotkeyDialog::synchronizeSimpleSelection() - { - ui->pb_selectedHotkey->setText(m_actionHotkey.getCombination().toFormattedQString()); - } - - void CHotkeyDialog::synchronizeAdvancedSelection() - { - if (ui->advancedFrame->isVisible()) { setupAdvancedFrame(); } - } - - void CHotkeyDialog::setupAdvancedFrame() - { - clearAdvancedFrame(); - auto allSupportedKeys = CKeyboardKeyList::allSupportedKeys(); - - QStringList splittedKeys = m_actionHotkey.getCombination().toQString().split('+', QString::SkipEmptyParts); - for (const auto &splittedKey : splittedKeys) - { - if (splittedKey == "+") continue; - - int currentIndex = -1; - CKeySelectionBox *ksb = new CKeySelectionBox(ui->advancedFrame); - for (const auto &supportedKey : allSupportedKeys) - { - QString supportedKeyAsString = supportedKey.toQString(); - ksb->addItem(supportedKeyAsString, QVariant::fromValue(supportedKey)); - if (supportedKeyAsString == splittedKey) - { - currentIndex = ksb->count() - 1; - } - } - ksb->setSelectedIndex(currentIndex); - ui->advancedFrame->layout()->addWidget(ksb); - int position = ui->advancedFrame->layout()->count() - 1; - ksb->setProperty("position", position); - connect(ksb, &CKeySelectionBox::keySelectionChanged, this, &CHotkeyDialog::advancedKeyChanged); - } - } - - void CHotkeyDialog::clearAdvancedFrame() - { - QLayout *layout = ui->advancedFrame->layout(); - QLayoutItem *child; - - while ((child = layout->takeAt(0)) != 0) - { - if (child->widget()) child->widget()->deleteLater(); - delete child; - } - } - - void CHotkeyDialog::advancedKeyChanged(int oldIndex, int newIndex) - { - CKeySelectionBox* ksb = qobject_cast(sender()); - Q_ASSERT(ksb); - CKeyboardKey oldKey = ksb->itemData(oldIndex).value(); - CKeyboardKey newKey = ksb->itemData(newIndex).value(); - - auto combination = m_actionHotkey.getCombination(); - combination.replaceKey(oldKey, newKey); - m_actionHotkey.setCombination(combination); - synchronize(); - } - - void CHotkeyDialog::selectAction() - { - if (m_actionHotkey.getAction().isEmpty()) return; - - const auto tokens = m_actionHotkey.getAction().split("/", QString::SkipEmptyParts); - QModelIndex parentIndex = QModelIndex(); - - for (const auto &token : tokens) - { - QModelIndex startIndex = m_actionModel.index(0, 0, parentIndex); - auto indexList = m_actionModel.match(startIndex, Qt::DisplayRole, QVariant::fromValue(token)); - if (indexList.isEmpty()) return; - parentIndex = indexList.first(); - ui->tv_actions->expand(parentIndex); - } - - QItemSelectionModel * selectionModel = ui->tv_actions->selectionModel(); - selectionModel->select(parentIndex, QItemSelectionModel::Select); - } - -} diff --git a/src/blackgui/hotkeydialog.h b/src/blackgui/hotkeydialog.h deleted file mode 100644 index 9bf827ddd..000000000 --- a/src/blackgui/hotkeydialog.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2014 - * 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_HOTKEYDIALOG_H -#define BLACKGUI_HOTKEYDIALOG_H - -#include "blackgui/blackguiexport.h" -#include "blackgui/models/actionmodel.h" -#include "blackcore/inputmanager.h" -#include "blackmisc/input/hotkeycombination.h" -#include "blackmisc/input/actionhotkeylist.h" -#include "blackmisc/identifierlist.h" -#include -#include -#include - -namespace Ui -{ - class CHotkeyDialog; -} - -namespace BlackGui -{ - - /*! - * Combobox for selecting keyboard keys - */ - class BLACKGUI_EXPORT CKeySelectionBox : public QComboBox - { - Q_OBJECT - - public: - //! Constructor - CKeySelectionBox(QWidget *parent = nullptr); - - //! Set key with index as selected - void setSelectedIndex(int index); - - signals: - //! User has changed the selection - void keySelectionChanged(int oldIndex, int newIndex); - - private slots: - void ps_updateSelectedIndex(int index); - - private: - int m_oldIndex; - }; - - /*! - * Hotkey dialog - */ - class BLACKGUI_EXPORT CHotkeyDialog : public QDialog - { - Q_OBJECT - - public: - //! Constructor - CHotkeyDialog(const BlackMisc::Input::CActionHotkey &actionHotkey, QWidget *parent = nullptr); - - //! Destructor - ~CHotkeyDialog(); - - //! Get hotkey selected by user - BlackMisc::Input::CActionHotkey getSelectedActionHotkey() const { return m_actionHotkey; } - - //! Set registered applications - void setRegisteredApplications(const BlackMisc::CIdentifierList &applications); - - //! Init style sheet - void initStyleSheet(); - - //! getHotkey runs the hotkey dialog and returns the result - static BlackMisc::Input::CActionHotkey getActionHotkey(const BlackMisc::Input::CActionHotkey &initial, const BlackMisc::CIdentifierList &applications, - QWidget *parent = nullptr); - - private: - void ps_advancedModeChanged(); - void ps_selectHotkey(); - void ps_combinationSelectionChanged(const BlackMisc::Input::CHotkeyCombination &combination); - void ps_combinationSelectionFinished(const BlackMisc::Input::CHotkeyCombination &combination); - void ps_changeSelectedAction(const QItemSelection &selected, const QItemSelection &deselected); - void ps_accept(); - - void synchronize(); - void synchronizeSimpleSelection(); - void synchronizeAdvancedSelection(); - void setupAdvancedFrame(); - void clearAdvancedFrame(); - void advancedKeyChanged(int oldIndex, int newIndex); - void selectAction(); - - QScopedPointer ui; - BlackMisc::Input::CActionHotkey m_actionHotkey; - BlackGui::Models::CActionModel m_actionModel; - BlackCore::CInputManager *m_inputManager; - }; - -} - -#endif diff --git a/src/blackgui/modelmodeselector.cpp b/src/blackgui/modelmodeselector.cpp deleted file mode 100644 index 9851eb0df..000000000 --- a/src/blackgui/modelmodeselector.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* 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 "modelmodeselector.h" -#include "ui_modelmodeselector.h" - -using namespace BlackMisc::Simulation; - -namespace BlackGui -{ - CModelModeSelector::CModelModeSelector(QWidget *parent) : - QFrame(parent), - ui(new Ui::CModelModeSelector) - { - ui->setupUi(this); - connect(ui->rb_Include, &QRadioButton::released, this, &CModelModeSelector::changed); - } - - CModelModeSelector::~CModelModeSelector() - { - // void - } - - BlackMisc::Simulation::CAircraftModel::ModelMode CModelModeSelector::getMode() const - { - if (ui->rb_Include->isChecked()) - { - return CAircraftModel::Include; - } - else - { - return CAircraftModel::Exclude; - } - } - - void CModelModeSelector::setValue(CAircraftModel::ModelMode mode) - { - if (mode == CAircraftModel::Include) - { - ui->rb_Include->setChecked(true); - } - else - { - ui->rb_Exclude->setChecked(true); - } - } - - void CModelModeSelector::setValue(const CAircraftModel &model) - { - this->setValue(model.getModelMode()); - } - - void CModelModeSelector::setReadOnly(bool readOnly) - { - this->setEnabled(!readOnly); - } -} diff --git a/src/blackgui/modelmodeselector.h b/src/blackgui/modelmodeselector.h deleted file mode 100644 index 757e6f8b6..000000000 --- a/src/blackgui/modelmodeselector.h +++ /dev/null @@ -1,59 +0,0 @@ -/* 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_MODELMODESELECTOR_H -#define BLACKGUI_MODELMODESELECTOR_H - -#include "blackguiexport.h" -#include "blackmisc/simulation/aircraftmodel.h" -#include -#include - -namespace Ui { class CModelModeSelector; } - -namespace BlackGui -{ - /*! - * Select the mode - */ - class BLACKGUI_EXPORT CModelModeSelector : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CModelModeSelector(QWidget *parent = nullptr); - - //! Destructor - ~CModelModeSelector(); - - //! Get mode - BlackMisc::Simulation::CAircraftModel::ModelMode getMode() const; - - //! Set mode - void setValue(BlackMisc::Simulation::CAircraftModel::ModelMode mode); - - //! Set mode - void setValue(const BlackMisc::Simulation::CAircraftModel &model); - - //! Read only - void setReadOnly(bool readOnly); - - signals: - //! Value changed - void changed(); - - private: - QScopedPointer ui; - }; -} - -#endif // guard diff --git a/src/blackgui/overlaymessages.ui b/src/blackgui/overlaymessages.ui index 392dcf4ff..c66cb231b 100644 --- a/src/blackgui/overlaymessages.ui +++ b/src/blackgui/overlaymessages.ui @@ -166,7 +166,7 @@ 0 - + QFrame::StyledPanel @@ -195,7 +195,7 @@ 0 - + QFrame::StyledPanel @@ -332,15 +332,15 @@
blackgui/views/statusmessageview.h
- BlackGui::CStatusMessageForm + BlackGui::Components::CStatusMessageForm QFrame -
blackgui/statusmessageform.h
+
blackgui/components/statusmessageform.h
1
- BlackGui::CStatusMessageFormSmall + BlackGui::Components::CStatusMessageFormSmall QFrame -
blackgui/statusmessageformsmall.h
+
blackgui/components/statusmessageformsmall.h
1
diff --git a/src/blackgui/selcalcodeselector.cpp b/src/blackgui/selcalcodeselector.cpp deleted file mode 100644 index 8b86637ab..000000000 --- a/src/blackgui/selcalcodeselector.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* 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 "selcalcodeselector.h" -#include "ui_selcalcodeselector.h" -#include "blackmisc/aviation/selcal.h" -#include "blackmisc/icons.h" - -using namespace BlackMisc; -using namespace BlackMisc::Aviation; - -namespace BlackGui -{ - CSelcalCodeSelector::CSelcalCodeSelector(QWidget *parent) : - QFrame(parent), ui(new Ui::CSelcalCodeSelector) - { - this->ui->setupUi(this); - this->resetSelcalCodes(true); - this->setValidityHint(); - this->ui->lblp_ValidCodeIcon->setToolTips("valid SELCAL", "invalid SELCAL"); - - bool c; - c = connect(this->ui->cb_SelcalPairs1, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged())); - Q_ASSERT(c); - c = connect(this->ui->cb_SelcalPairs2, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged())); - Q_ASSERT(c); - Q_UNUSED(c); - } - - CSelcalCodeSelector::~CSelcalCodeSelector() - { } - - QString CSelcalCodeSelector::getSelcalCode() const - { - QString selcal = this->ui->cb_SelcalPairs1->currentText(); - selcal.append(this->ui->cb_SelcalPairs2->currentText()); - return selcal; - } - - BlackMisc::Aviation::CSelcal CSelcalCodeSelector::getSelcal() const - { - CSelcal selcal(getSelcalCode()); - return selcal; - } - - void CSelcalCodeSelector::resetSelcalCodes(bool allowEmptyValue) - { - this->ui->cb_SelcalPairs1->clear(); - if (allowEmptyValue) this->ui->cb_SelcalPairs1->addItem(" "); - this->ui->cb_SelcalPairs1->addItems(BlackMisc::Aviation::CSelcal::codePairs()); - this->ui->cb_SelcalPairs2->clear(); - if (allowEmptyValue) this->ui->cb_SelcalPairs2->addItem(" "); - this->ui->cb_SelcalPairs2->addItems(BlackMisc::Aviation::CSelcal::codePairs()); - } - - void CSelcalCodeSelector::setSelcalCode(const QString &selcal) - { - if (selcal.length() == 4 && this->getSelcalCode() == selcal) return; // avoid unintended signals - QString s = selcal.isEmpty() ? " " : selcal.toUpper().trimmed(); - Q_ASSERT(s.length() == 4); - if (s.length() != 4) return; - QString s1 = s.left(2); - QString s2 = s.right(2); - if (BlackMisc::Aviation::CSelcal::codePairs().contains(s1)) - { - this->ui->cb_SelcalPairs1->setCurrentText(s1); - } - if (BlackMisc::Aviation::CSelcal::codePairs().contains(s2)) - { - this->ui->cb_SelcalPairs2->setCurrentText(s2); - } - } - - void CSelcalCodeSelector::setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal) - { - this->setSelcalCode(selcal.getCode()); - } - - bool CSelcalCodeSelector::hasValidCode() const - { - QString s = this->getSelcalCode(); - if (s.length() != 4) return false; - return BlackMisc::Aviation::CSelcal::isValidCode(s); - } - - void CSelcalCodeSelector::clear() - { - if (this->ui->cb_SelcalPairs1->count() < 1) { this->resetSelcalCodes(true); } - this->ui->cb_SelcalPairs1->setCurrentIndex(0); - this->ui->cb_SelcalPairs2->setCurrentIndex(0); - } - - void CSelcalCodeSelector::ps_selcalIndexChanged() - { - this->setValidityHint(); - emit valueChanged(); - } - - void CSelcalCodeSelector::setValidityHint() - { - this->ui->lblp_ValidCodeIcon->setTicked(this->hasValidCode()); - } -} // namespace diff --git a/src/blackgui/selcalcodeselector.h b/src/blackgui/selcalcodeselector.h deleted file mode 100644 index fb7df25ac..000000000 --- a/src/blackgui/selcalcodeselector.h +++ /dev/null @@ -1,73 +0,0 @@ -/* 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_SELCALCODESELECTOR_H -#define BLACKGUI_SELCALCODESELECTOR_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/aviation/selcal.h" -#include -#include - -namespace Ui { class CSelcalCodeSelector; } -namespace BlackGui -{ - - //! SELCAL mode selector - class BLACKGUI_EXPORT CSelcalCodeSelector : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CSelcalCodeSelector(QWidget *parent = nullptr); - - //! Destructor - ~CSelcalCodeSelector(); - - //! SELCAL code - QString getSelcalCode() const; - - //! SELCAL - BlackMisc::Aviation::CSelcal getSelcal() const; - - //! Reset the SELCAL code - void resetSelcalCodes(bool allowEmptyValue = false); - - //! Set the SELCAL code - void setSelcalCode(const QString &selcal); - - //! Set the SELCAL code - void setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal); - - //! Valid code? - bool hasValidCode() const; - - //! Clear - void clear(); - - signals: - //! Value has been changed - void valueChanged(); - - private slots: - //! SELCAL changed - void ps_selcalIndexChanged(); - - private: - QScopedPointer ui; - - //! Set valid/invalid icon - void setValidityHint(); - }; -} - -#endif // guard diff --git a/src/blackgui/serverform.cpp b/src/blackgui/serverform.cpp deleted file mode 100644 index e3f81bf6c..000000000 --- a/src/blackgui/serverform.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2014 - * 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 "serverform.h" -#include "ui_serverform.h" - -using namespace BlackMisc::Network; - -namespace BlackGui -{ - - CServerForm::CServerForm(QWidget *parent) : - QFrame(parent), - ui(new Ui::CNetworkServerForm) - { - ui->setupUi(this); - this->ui->le_Port->setValidator(new QIntValidator(1, 65535, this)); - } - - CServerForm::~CServerForm() - { } - - void CServerForm::setServer(const CServer &server) - { - CUser user = server.getUser(); - this->ui->le_NetworkId->setText(user.getId()); - this->ui->le_RealName->setText(user.getRealName()); - this->ui->le_Name->setText(server.getName()); - this->ui->le_Password->setText(user.getPassword()); - this->ui->le_Description->setText(server.getDescription()); - this->ui->le_Address->setText(server.getAddress()); - this->ui->le_Port->setText(QString::number(server.getPort())); - } - - BlackMisc::Network::CServer CServerForm::getServer() const - { - CUser user( - this->ui->le_NetworkId->text().trimmed(), - this->ui->le_RealName->text().trimmed().simplified(), - "", - this->ui->le_Password->text().trimmed() - ); - CServer server( - this->ui->le_Name->text().trimmed().simplified(), - this->ui->le_Description->text().trimmed().simplified(), - this->ui->le_Address->text().trimmed(), - this->ui->le_Port->text().trimmed().toInt(), - user - ); - return server; - } - - void CServerForm::setReadOnly(bool readOnly) - { - this->ui->le_NetworkId->setReadOnly(readOnly); - this->ui->le_RealName->setReadOnly(readOnly); - this->ui->le_Name->setReadOnly(readOnly); - this->ui->le_Description->setReadOnly(readOnly); - this->ui->le_Address->setReadOnly(readOnly); - this->ui->le_Port->setReadOnly(readOnly); - this->ui->le_Password->setReadOnly(readOnly); - } - - void CServerForm::showPasswordField(bool show) - { - if (this->ui->le_Password->isVisible() == show) { return; } - if (m_passwordNameLabel.isEmpty()) { m_passwordNameLabel = ui->lbl_IdPassword->text(); } - if (show) - { - ui->lbl_IdPassword->setText(m_passwordNameLabel); - } - else - { - ui->lbl_IdPassword->setText("Id"); - } - this->ui->le_Password->setVisible(show); - } - - BlackMisc::CStatusMessageList CServerForm::validate() const - { - CServer server = getServer(); - return server.validate(); - } - -} // namespace diff --git a/src/blackgui/serverform.h b/src/blackgui/serverform.h deleted file mode 100644 index 0011e35d4..000000000 --- a/src/blackgui/serverform.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2014 - * 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_NETWORKSERVERFORM_H -#define BLACKGUI_NETWORKSERVERFORM_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/network/server.h" -#include "blackmisc/statusmessagelist.h" -#include -#include - -namespace Ui { class CNetworkServerForm; } - -namespace BlackGui -{ - - //! Server form - class BLACKGUI_EXPORT CServerForm : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CServerForm(QWidget *parent = nullptr); - - //! Destructor - ~CServerForm(); - - //! Set server - void setServer(const BlackMisc::Network::CServer &server); - - //! Get server - BlackMisc::Network::CServer getServer() const; - - //! Set read only - void setReadOnly(bool readOnly); - - //! Show the password field - void showPasswordField(bool show); - - //! Validate and provide messages (empty means OK) - BlackMisc::CStatusMessageList validate() const; - - private: - QScopedPointer ui; - QString m_passwordNameLabel; - }; -} - -#endif // guard diff --git a/src/blackgui/serverlistselector.cpp b/src/blackgui/serverlistselector.cpp deleted file mode 100644 index e5aaf4107..000000000 --- a/src/blackgui/serverlistselector.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* 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 "serverlistselector.h" - -using namespace BlackMisc::Network; - -namespace BlackGui -{ - - CServerListSelector::CServerListSelector(QWidget *parent) : - QComboBox(parent) - { - } - - void CServerListSelector::setServers(const BlackMisc::Network::CServerList &servers) - { - if (this->m_servers == servers) { return; } - this->setItemStrings(servers); - } - - BlackMisc::Network::CServer CServerListSelector::currentServer() const - { - int i = currentIndex(); - if (i < 0 || i >= m_servers.size()) { return CServer(); } - return m_servers[i]; - } - - void CServerListSelector::setItemStrings(const CServerList &servers) - { - QString currentlySelected(this->currentText()); - int index = -1; - this->m_servers = servers; - this->m_items.clear(); - for (const CServer &server : servers) - { - QString d(server.getName() + ": " + server.getDescription()); - m_items.append(d); - if (!currentlySelected.isEmpty() && index < 0 && d == currentlySelected) - { - index = m_items.size() - 1; - } - } - this->clear(); // ui - this->addItems(m_items); - - // reselect - if (this->m_items.isEmpty()) { return; } - if (this->m_items.size() == 1) - { - this->setCurrentIndex(0); - } - else if (index >= 0) - { - this->setCurrentIndex(index); - } - } - -} // namespace diff --git a/src/blackgui/serverlistselector.h b/src/blackgui/serverlistselector.h deleted file mode 100644 index 6f834db0c..000000000 --- a/src/blackgui/serverlistselector.h +++ /dev/null @@ -1,47 +0,0 @@ -/* 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_SERVERLISTSELECTOR_H -#define BLACKGUI_SERVERLISTSELECTOR_H - -#include "blackgui/blackguiexport.h" -#include -#include - -#include "blackmisc/network/serverlist.h" - -namespace BlackGui -{ - //! List of servers - class BLACKGUI_EXPORT CServerListSelector : public QComboBox - { - Q_OBJECT - - public: - //! Constructor - explicit CServerListSelector(QWidget *parent = nullptr); - - //! Set the servers - void setServers(const BlackMisc::Network::CServerList &servers); - - //! Get the current server - BlackMisc::Network::CServer currentServer() const; - - private: - //! Build the item string descriptions - void setItemStrings(const BlackMisc::Network::CServerList &servers); - - BlackMisc::Network::CServerList m_servers; //!< corresponding servers - QStringList m_items; //!< items strings - }; -} // namespace - -#endif // guard diff --git a/src/blackgui/simulatorselector.cpp b/src/blackgui/simulatorselector.cpp deleted file mode 100644 index 0620dddd5..000000000 --- a/src/blackgui/simulatorselector.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 2015 - * 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 "simulatorselector.h" -#include "ui_simulatorselector.h" - -using namespace BlackMisc::Simulation; - -namespace BlackGui -{ - CSimulatorSelector::CSimulatorSelector(QWidget *parent) : - QFrame(parent), - ui(new Ui::CSimulatorSelector) - { - ui->setupUi(this); - this->setMode(CheckBoxes); - - connect(this->ui->rb_FS9, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); - connect(this->ui->rb_FSX, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); - connect(this->ui->rb_P3D, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); - connect(this->ui->rb_XPlane, &QRadioButton::clicked, this, &CSimulatorSelector::ps_RadioButtonChanged); - - connect(this->ui->cb_FS9, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); - connect(this->ui->cb_FSX, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); - connect(this->ui->cb_P3D, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); - connect(this->ui->cb_XPlane, &QRadioButton::clicked, this, &CSimulatorSelector::ps_CheckBoxChanged); - } - - CSimulatorSelector::~CSimulatorSelector() - { } - - void CSimulatorSelector::setMode(CSimulatorSelector::Mode mode) - { - this->m_mode = mode; - switch (mode) - { - default: - case CheckBoxes: - this->ui->wi_CheckBoxes->setVisible(true); - this->ui->wi_RadioButtons->setVisible(false); - break; - case RadioButtons: - this->ui->wi_CheckBoxes->setVisible(false); - this->ui->wi_RadioButtons->setVisible(true); - break; - } - } - - CSimulatorInfo CSimulatorSelector::getValue() const - { - if (this->m_noSelectionMeansAll && this->isUnselected()) - { - return CSimulatorInfo::allSimulators(); - } - - switch (this->m_mode) - { - default: - case CheckBoxes: - return CSimulatorInfo(this->ui->cb_FSX->isChecked(), this->ui->cb_FS9->isChecked(), - this->ui->cb_XPlane->isChecked(), this->ui->cb_P3D->isChecked()); - case RadioButtons: - return CSimulatorInfo(this->ui->rb_FSX->isChecked(), this->ui->rb_FS9->isChecked(), - this->ui->rb_XPlane->isChecked(), this->ui->cb_P3D->isChecked()); - } - } - - void CSimulatorSelector::setValue(const CSimulatorInfo &info) - { - this->ui->cb_FSX->setChecked(info.fsx()); - this->ui->cb_FS9->setChecked(info.fs9()); - this->ui->cb_XPlane->setChecked(info.xplane()); - this->ui->cb_P3D->setChecked(info.p3d()); - - if (info.fsx()) { this->ui->cb_FSX->setChecked(info.fsx()); return; } - if (info.fs9()) { this->ui->cb_FS9->setChecked(info.fs9()); return; } - if (info.xplane()) { this->ui->cb_XPlane->setChecked(info.xplane()); return; } - if (info.p3d()) { this->ui->cb_P3D->setChecked(info.p3d()); return; } - } - - void CSimulatorSelector::setAll() - { - // checkboxes - this->ui->cb_FSX->setChecked(true); - this->ui->cb_FS9->setChecked(true); - this->ui->cb_XPlane->setChecked(true); - this->ui->cb_P3D->setChecked(true); - - // radio - this->ui->rb_FSX->setChecked(true); - } - - bool CSimulatorSelector::isUnselected() const - { - bool c = false; - switch (this->m_mode) - { - default: - case CheckBoxes: - c = this->ui->cb_FSX->isChecked() || this->ui->cb_FS9->isChecked() || - this->ui->cb_XPlane->isChecked() || this->ui->cb_P3D->isChecked(); - break; - case RadioButtons: - c = this->ui->rb_FSX->isChecked() || this->ui->rb_FS9->isChecked() || - this->ui->rb_XPlane->isChecked() || this->ui->cb_P3D->isChecked(); - break; - } - return !c; - } - - bool CSimulatorSelector::areAllSelected() const - { - bool c = false; - switch (this->m_mode) - { - default: - case CheckBoxes: - c = this->ui->cb_FSX->isChecked() && this->ui->cb_FS9->isChecked() && - this->ui->cb_XPlane->isChecked() && this->ui->cb_P3D->isChecked(); - break; - case RadioButtons: - // actually this should never be true - c = false; - break; - } - return c; - } - - void CSimulatorSelector::ps_RadioButtonChanged(bool checked) - { - if (this->m_mode != RadioButtons) { return; } - if (!checked) { return; } // only the checked ones are relevant, as the unchecked ones are accompanied with checked events - emit this->changed(this->getValue()); - } - - void CSimulatorSelector::ps_CheckBoxChanged(bool checked) - { - if (this->m_mode != CheckBoxes) { return; } - Q_UNUSED(checked); - emit this->changed(this->getValue()); - } -} // ns diff --git a/src/blackgui/simulatorselector.h b/src/blackgui/simulatorselector.h deleted file mode 100644 index 27240c093..000000000 --- a/src/blackgui/simulatorselector.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2015 - * 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. - */ - -#ifndef BLACKGUI_SIMULATORSELECTOR_H -#define BLACKGUI_SIMULATORSELECTOR_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/simulation/simulatorinfo.h" -#include -#include - -namespace Ui { class CSimulatorSelector; } - -namespace BlackGui -{ - /*! - * Select simulator - */ - class BLACKGUI_EXPORT CSimulatorSelector : public QFrame - { - Q_OBJECT - - public: - //! How to display - enum Mode - { - CheckBoxes, - RadioButtons - }; - - //! Constructor - explicit CSimulatorSelector(QWidget *parent = nullptr); - - //! Destructor - ~CSimulatorSelector(); - - //! How to display - void setMode(Mode mode); - - //! No selection treated same as all selected (filters) - void setNoSelectionMeansAll(bool v) { this->m_noSelectionMeansAll = v; } - - //! Get the value - BlackMisc::Simulation::CSimulatorInfo getValue() const; - - //! Set the value - void setValue(const BlackMisc::Simulation::CSimulatorInfo &info); - - //! Set all, only making sense with checkboxes - void setAll(); - - //! Not selected at all - bool isUnselected() const; - - //! All selected - bool areAllSelected() const; - - signals: - //! Value has been changed - void changed(const BlackMisc::Simulation::CSimulatorInfo &info); - - private slots: - //! Radio button changed - void ps_RadioButtonChanged(bool checked); - - //! Checkbox changed - void ps_CheckBoxChanged(bool checked); - - private: - QScopedPointer ui; - Mode m_mode = CheckBoxes; - bool m_noSelectionMeansAll = false; //!< for filters, no selection means all - }; -} - -#endif // guard diff --git a/src/blackgui/statusmessageform.cpp b/src/blackgui/statusmessageform.cpp deleted file mode 100644 index 981358e23..000000000 --- a/src/blackgui/statusmessageform.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2014 - * 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 "statusmessageform.h" -#include "ui_statusmessageform.h" -#include - -using namespace BlackMisc; - -namespace BlackGui -{ - CStatusMessageForm::CStatusMessageForm(QWidget *parent) : - QFrame(parent), - ui(new Ui::CStatusMessageForm) - { - ui->setupUi(this); - } - - CStatusMessageForm::~CStatusMessageForm() - { } - - void CStatusMessageForm::setVariant(const CVariant &messageVariant) - { - if (!this->isVisible()) { return; } - this->setValue(messageVariant.value()); - } - - void CStatusMessageForm::setValue(const CStatusMessage &message) - { - ui->te_Message->setPlainText(message.getMessage()); - ui->lbl_SeverityIcon->setPixmap(message.toPixmap()); - const QString hrc(message.getHumanReadablePattern()); - if (hrc.isEmpty()) - { - ui->le_Categories->setText(message.getCategories().toQString()); - ui->le_Categories->setToolTip(""); - } - else - { - ui->le_Categories->setText(hrc); - ui->le_Categories->setToolTip(message.getCategories().toQString()); - } - ui->le_Severity->setText(message.getSeverityAsString()); - ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms()); - } - - void CStatusMessageForm::toggleVisibility() - { - this->setVisible(!isVisible()); - } - -} // ns diff --git a/src/blackgui/statusmessageform.h b/src/blackgui/statusmessageform.h deleted file mode 100644 index 83eefbd88..000000000 --- a/src/blackgui/statusmessageform.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2015 - * 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_STATUSMESSAGEFORM_H -#define BLACKGUI_STATUSMESSAGEFORM_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/statusmessage.h" -#include - -namespace Ui { class CStatusMessageForm; } - -namespace BlackGui -{ - /*! - * Display details about a single status message - */ - class BLACKGUI_EXPORT CStatusMessageForm : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CStatusMessageForm(QWidget *parent = nullptr); - - //! Destructor - ~CStatusMessageForm(); - - public slots: - //! Set message - void setVariant(const BlackMisc::CVariant &messageVariant); - - //! Set message - void setValue(const BlackMisc::CStatusMessage &message); - - //! Toggle visibility - void toggleVisibility(); - - private: - QScopedPointer ui; - }; - -} // ns -#endif // guard diff --git a/src/blackgui/statusmessageformsmall.cpp b/src/blackgui/statusmessageformsmall.cpp deleted file mode 100644 index 48b53972a..000000000 --- a/src/blackgui/statusmessageformsmall.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2015 - * 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 "statusmessageformsmall.h" -#include "ui_statusmessageformsmall.h" -#include - -using namespace BlackMisc; - -namespace BlackGui -{ - CStatusMessageFormSmall::CStatusMessageFormSmall(QWidget *parent) : - QFrame(parent), - ui(new Ui::CStatusMessageFormSmall) - { - ui->setupUi(this); - } - - CStatusMessageFormSmall::~CStatusMessageFormSmall() - { } - - void CStatusMessageFormSmall::setVariant(const CVariant &messageVariant) - { - if (!this->isVisible()) { return; } - this->setValue(messageVariant.value()); - } - - void CStatusMessageFormSmall::setValue(const CStatusMessage &message) - { - ui->te_Message->setPlainText(message.getMessage()); - ui->lbl_SeverityIcon->setPixmap(message.toPixmap()); - ui->le_Categories->setText(message.getHumanReadablePattern()); - ui->le_Severity->setText(message.getSeverityAsString()); - ui->le_Timestamp->setText(message.getFormattedUtcTimestampYmdhms()); - } - - void CStatusMessageFormSmall::toggleVisibility() - { - this->setVisible(!isVisible()); - } - -} // ns diff --git a/src/blackgui/statusmessageformsmall.h b/src/blackgui/statusmessageformsmall.h deleted file mode 100644 index 7993c50d7..000000000 --- a/src/blackgui/statusmessageformsmall.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2015 - * 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_STATUSMESSAGEFORMSMALL_H -#define BLACKGUI_STATUSMESSAGEFORMSMALL_H - -#include "blackgui/blackguiexport.h" -#include "blackmisc/statusmessage.h" -#include - -namespace Ui { class CStatusMessageFormSmall; } - -namespace BlackGui -{ - /*! - * Display details about a single status message - */ - class BLACKGUI_EXPORT CStatusMessageFormSmall : public QFrame - { - Q_OBJECT - - public: - //! Constructor - explicit CStatusMessageFormSmall(QWidget *parent = nullptr); - - //! Destructor - ~CStatusMessageFormSmall(); - - public slots: - //! Set message - void setVariant(const BlackMisc::CVariant &messageVariant); - - //! Set message - void setValue(const BlackMisc::CStatusMessage &message); - - //! Toggle visibility - void toggleVisibility(); - - private: - QScopedPointer ui; - }; - -} // ns -#endif // guard diff --git a/src/blackgui/textmessagetextedit.h b/src/blackgui/textmessagetextedit.h index 89419bc05..dbaea8e56 100644 --- a/src/blackgui/textmessagetextedit.h +++ b/src/blackgui/textmessagetextedit.h @@ -85,9 +85,7 @@ namespace BlackGui QAction *m_actionWithSender = nullptr; QAction *m_actionWithRecipient = nullptr; QAction *m_actionWordWrap = nullptr; - }; - } // namespace #endif // guard diff --git a/src/blackgui/transpondercodespinbox.h b/src/blackgui/transpondercodespinbox.h deleted file mode 100644 index 77b9f0ede..000000000 --- a/src/blackgui/transpondercodespinbox.h +++ /dev/null @@ -1,34 +0,0 @@ -/* 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_TRANSPONDERCODESPINBOX_H -#define BLACKGUI_TRANSPONDERCODESPINBOX_H - -#include "blackgui/blackguiexport.h" -#include - -namespace BlackGui -{ - - //! Specialized spin box for Transponder codes - class BLACKGUI_EXPORT CTransponderCodeSpinBox : public QSpinBox - { - Q_OBJECT - public: - //! Constructor - explicit CTransponderCodeSpinBox(QWidget *parent = nullptr); - - //! \copydoc QDoubleSpinBox::textFromValue - virtual QString textFromValue(int value) const override; - }; -} // namespace - -#endif // guard diff --git a/src/blackgui/transpondermodeselector.cpp b/src/blackgui/transpondermodeselector.cpp deleted file mode 100644 index 9fed4af51..000000000 --- a/src/blackgui/transpondermodeselector.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* 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) - { - QComboBox::insertItems(0, CTransponderModeSelector::modes()); - this->m_resetTimer.setObjectName(this->objectName().append(":m_resetTimer")); - connect(&this->m_resetTimer, &QTimer::timeout, this, &CTransponderModeSelector::resetTransponderMode); - connect(this, &CTransponderModeSelector::currentTextChanged, this, &CTransponderModeSelector::setSelectedTransponderModeAsString); - this->m_resetTimer.setInterval(5000); - } - - const QString &CTransponderModeSelector::transponderStateStandby() - { - static const QString s(BlackMisc::Aviation::CTransponder::modeAsString(BlackMisc::Aviation::CTransponder::StateStandby)); - return s; - } - - const QString &CTransponderModeSelector::transponderStateIdent() - { - static const QString s(BlackMisc::Aviation::CTransponder::modeAsString(BlackMisc::Aviation::CTransponder::StateIdent)); - return s; - } - - const QString &CTransponderModeSelector::transponderModeC() - { - static const QString s(BlackMisc::Aviation::CTransponder::modeAsString(BlackMisc::Aviation::CTransponder::ModeC)); - return s; - } - - const QStringList &CTransponderModeSelector::modes() - { - static QStringList modes; - if (modes.isEmpty()) - { - modes << CTransponderModeSelector::transponderStateStandby(); - modes << CTransponderModeSelector::transponderModeC(); - modes << CTransponderModeSelector::transponderStateIdent(); - } - return modes; - } - - BlackMisc::Aviation::CTransponder::TransponderMode CTransponderModeSelector::getSelectedTransponderMode() const - { - return this->m_currentMode; - } - - 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->transponderStateIdentEnded(); } - this->m_currentMode = mode; - QString m = CTransponder::modeAsString(mode); - QComboBox::setCurrentText(m); - if (mode == CTransponder::StateIdent) - { - this->m_resetTimer.start(); - } - else - { - this->m_resetTimer.stop(); - } - emit this->transponderModeChanged(this->m_currentMode); - } - - void CTransponderModeSelector::setSelectedTransponderModeStateIdent() - { - this->setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::StateIdent); - } - - void CTransponderModeSelector::setSelectedTransponderModeAsString(const QString &mode) - { - CTransponder::TransponderMode m = CTransponder::modeFromString(mode); - if (this->m_currentMode == m) return; // nothing to change - this->setSelectedTransponderMode(m); - } - - void CTransponderModeSelector::resetTransponderMode() - { - if (!this->isIdentSelected()) return; // avoid unnecessary events - this->setSelectedTransponderMode(this->m_resetMode); - } -} diff --git a/src/blackgui/transpondermodeselector.h b/src/blackgui/transpondermodeselector.h deleted file mode 100644 index 05edd80d8..000000000 --- a/src/blackgui/transpondermodeselector.h +++ /dev/null @@ -1,85 +0,0 @@ -/* 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 - -#include "blackgui/blackguiexport.h" -#include "blackmisc/aviation/transponder.h" -#include -#include -#include - - -namespace BlackGui -{ - - //! Selector for the transponder mode - //! \remarks features ident reset - class BLACKGUI_EXPORT CTransponderModeSelector : public QComboBox - { - Q_OBJECT - - - public: - //! Constructor - explicit CTransponderModeSelector(QWidget *parent = nullptr); - - //! Standby string - static const QString &transponderStateStandby(); - - //! Ident string - static const QString &transponderStateIdent(); - - //! Mode C string - static const QString &transponderModeC(); - - //! All relevant modes for GUI - static const QStringList &modes(); - - //! Selected transponder mode - BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const; - - //! Ident selected - bool isIdentSelected() const - { - return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent; - } - - public slots: - //! reset to last mode (unequal ident) - void resetTransponderMode(); - - //! Selected transponder mode - void setSelectedTransponderModeAsString(const QString &mode); - - //! Selected transponder mode - void setSelectedTransponderMode(BlackMisc::Aviation::CTransponder::TransponderMode mode); - - //! 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 - -#endif // guard diff --git a/src/swiftcore/swiftcore.ui b/src/swiftcore/swiftcore.ui index dfd8e9979..f6ec98d10 100644 --- a/src/swiftcore/swiftcore.ui +++ b/src/swiftcore/swiftcore.ui @@ -125,7 +125,7 @@ QTextEdit {
- + @@ -148,9 +148,9 @@ QTextEdit { 1 - BlackGui::CCommandInput + BlackGui::Components::CCommandInput QLineEdit -
blackgui/commandinput.h
+
blackgui/components/commandinput.h
1
diff --git a/src/swiftguistandard/swiftguistd.h b/src/swiftguistandard/swiftguistd.h index 547157162..5f84b90a0 100644 --- a/src/swiftguistandard/swiftguistd.h +++ b/src/swiftguistandard/swiftguistd.h @@ -21,7 +21,7 @@ #include "blackcore/data/globalsetup.h" #include "blackgui/components/maininfoareacomponent.h" #include "blackgui/components/navigatordialog.h" -#include "blackgui/transpondermodeselector.h" +#include "blackgui/components/transpondermodeselector.h" #include "blackgui/models/atcstationlistmodel.h" #include "blackgui/models/serverlistmodel.h" #include "blackgui/models/userlistmodel.h"