From b0f01a3ec6db72416169c76ccfde523762872037 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 7 Oct 2014 00:24:04 +0200 Subject: [PATCH] refs #335, formatting, member initialization, new icons, remove redundant methods --- samples/blackgui2/introwindow.cpp | 9 ++++++++ samples/blackgui2/introwindow.h | 20 +++++++++-------- src/blackgui/components/cockpitv1component.h | 6 +++-- .../components/dockwidgetinfoareacomponent.h | 5 +++-- .../components/flightplancomponent.cpp | 5 ++++- src/blackgui/components/flightplancomponent.h | 4 +++- .../components/infobarstatuscomponent.h | 4 +++- src/blackgui/components/infowindowcomponent.h | 6 ++--- src/blackgui/components/logcomponent.h | 4 +++- .../components/maininfoareacomponent.cpp | 3 ++- .../components/runtimebasedcomponent.h | 2 +- src/blackgui/components/settingscomponent.h | 4 +++- .../components/textmessagecomponent.h | 5 +++-- .../components/timerbasedcomponent.cpp | 2 +- src/blackgui/components/timerbasedcomponent.h | 6 ++--- src/blackgui/dockwidget.cpp | 14 ------------ src/blackgui/dockwidget.h | 11 +++------- src/blackgui/infoarea.h | 22 ++++++++++++++----- src/blackmisc/iconlist.cpp | 1 + src/blackmisc/icons.h | 7 ++++++ 20 files changed, 83 insertions(+), 57 deletions(-) diff --git a/samples/blackgui2/introwindow.cpp b/samples/blackgui2/introwindow.cpp index d678f2287..7e62e35ff 100644 --- a/samples/blackgui2/introwindow.cpp +++ b/samples/blackgui2/introwindow.cpp @@ -1,3 +1,12 @@ +/* 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 "introwindow.h" #include "ui_introwindow.h" #include diff --git a/samples/blackgui2/introwindow.h b/samples/blackgui2/introwindow.h index 7fb9c38f0..40e0b9b86 100644 --- a/samples/blackgui2/introwindow.h +++ b/samples/blackgui2/introwindow.h @@ -1,7 +1,13 @@ -/* Copyright (C) 2013 VATSIM Community / authors - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.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 SAMPLE_INTROWINDOW_H #define SAMPLE_INTROWINDOW_H @@ -10,11 +16,7 @@ #include #include -namespace Ui -{ - class CIntroWindow; -} - +namespace Ui { class CIntroWindow; } class CIntroWindow : public QDialog { Q_OBJECT diff --git a/src/blackgui/components/cockpitv1component.h b/src/blackgui/components/cockpitv1component.h index 9e58b9aa7..1e941f907 100644 --- a/src/blackgui/components/cockpitv1component.h +++ b/src/blackgui/components/cockpitv1component.h @@ -26,8 +26,10 @@ namespace BlackGui namespace Components { - //! User componenet (users, clients) - class CCockpitV1Component : public QWidget, public CRuntimeBasedComponent + //! Cockpit component + class CCockpitV1Component : + public QWidget, + public CRuntimeBasedComponent { Q_OBJECT diff --git a/src/blackgui/components/dockwidgetinfoareacomponent.h b/src/blackgui/components/dockwidgetinfoareacomponent.h index dad0b303f..e1893a0a5 100644 --- a/src/blackgui/components/dockwidgetinfoareacomponent.h +++ b/src/blackgui/components/dockwidgetinfoareacomponent.h @@ -21,8 +21,8 @@ namespace BlackGui namespace Components { - //! Component is residing in an dockable widget. This helper class provides access to - //! to its info area and dockable widget. + //! Helper class: Component is residing in an dockable widget. + //! This class provides access to its info area and dockable widget. class CDockWidgetInfoAreaComponent { public: @@ -53,6 +53,7 @@ namespace BlackGui private: BlackGui::CDockWidgetInfoArea *m_parentDockableInfoArea = nullptr; //!< my parent dockable widget + }; } } // namespace diff --git a/src/blackgui/components/flightplancomponent.cpp b/src/blackgui/components/flightplancomponent.cpp index df105dd37..79a007a8c 100644 --- a/src/blackgui/components/flightplancomponent.cpp +++ b/src/blackgui/components/flightplancomponent.cpp @@ -24,13 +24,16 @@ namespace BlackGui namespace Components { CFlightPlanComponent::CFlightPlanComponent(QWidget *parent) : - QTabWidget(parent), CRuntimeBasedComponent(nullptr, false), ui(new Ui::CFlightPlanComponent) + QTabWidget(parent), + CRuntimeBasedComponent(nullptr, false), + ui(new Ui::CFlightPlanComponent) { ui->setupUi(this); // fix style this->tabBar()->setExpanding(false); + // connect connect(this->ui->pb_Send, &QPushButton::pressed, this, &CFlightPlanComponent::sendFlightPlan); connect(this->ui->pb_Load, &QPushButton::pressed, this, &CFlightPlanComponent::loadFlightPlanFromNetwork); connect(this->ui->pb_Reset, &QPushButton::pressed, this, &CFlightPlanComponent::resetFlightPlan); diff --git a/src/blackgui/components/flightplancomponent.h b/src/blackgui/components/flightplancomponent.h index 6580d0219..e3ed8bdfe 100644 --- a/src/blackgui/components/flightplancomponent.h +++ b/src/blackgui/components/flightplancomponent.h @@ -25,7 +25,9 @@ namespace BlackGui { //! Flight plan widget - class CFlightPlanComponent : public QTabWidget, public CRuntimeBasedComponent + class CFlightPlanComponent : + public QTabWidget, + public CRuntimeBasedComponent { Q_OBJECT diff --git a/src/blackgui/components/infobarstatuscomponent.h b/src/blackgui/components/infobarstatuscomponent.h index 21aed80c2..a54742b80 100644 --- a/src/blackgui/components/infobarstatuscomponent.h +++ b/src/blackgui/components/infobarstatuscomponent.h @@ -22,7 +22,9 @@ namespace BlackGui namespace Components { //! Info bar displaying status (Network, Simulator, DBus) - class CInfoBarStatusComponent : public QFrame, public CRuntimeBasedComponent + class CInfoBarStatusComponent : + public QFrame, + public CRuntimeBasedComponent { Q_OBJECT diff --git a/src/blackgui/components/infowindowcomponent.h b/src/blackgui/components/infowindowcomponent.h index 03592aa0a..100c44e70 100644 --- a/src/blackgui/components/infowindowcomponent.h +++ b/src/blackgui/components/infowindowcomponent.h @@ -27,7 +27,7 @@ namespace BlackGui { /*! - * Multi purpose info window (pop up window) + * Multi purpose info window (like pop up window) */ class CInfoWindowComponent : public QWizardPage { @@ -73,6 +73,6 @@ namespace BlackGui //! Style sheet changed void onStyleSheetsChanged(); }; - } -} + } // namespace +} // namespace #endif // guard diff --git a/src/blackgui/components/logcomponent.h b/src/blackgui/components/logcomponent.h index 2cb426c8d..784fe31c8 100644 --- a/src/blackgui/components/logcomponent.h +++ b/src/blackgui/components/logcomponent.h @@ -24,7 +24,9 @@ namespace BlackGui { //! GUI displaying log and status messages - class CLogComponent : public QFrame, public CRuntimeBasedComponent + class CLogComponent : + public QFrame, + public CRuntimeBasedComponent { Q_OBJECT diff --git a/src/blackgui/components/maininfoareacomponent.cpp b/src/blackgui/components/maininfoareacomponent.cpp index df12e78ec..b6875320b 100644 --- a/src/blackgui/components/maininfoareacomponent.cpp +++ b/src/blackgui/components/maininfoareacomponent.cpp @@ -25,7 +25,8 @@ namespace BlackGui namespace Components { CMainInfoAreaComponent::CMainInfoAreaComponent(QWidget *parent) : - CInfoArea(parent), ui(new Ui::CMainInfoAreaComponent) + CInfoArea(parent), + ui(new Ui::CMainInfoAreaComponent) { ui->setupUi(this); initInfoArea(); diff --git a/src/blackgui/components/runtimebasedcomponent.h b/src/blackgui/components/runtimebasedcomponent.h index ce9055a74..a27c3a009 100644 --- a/src/blackgui/components/runtimebasedcomponent.h +++ b/src/blackgui/components/runtimebasedcomponent.h @@ -34,7 +34,7 @@ namespace BlackGui { /*! - * \brief Component, which provides reference to runtime object + * \brief Component, which provides references to runtime objects * \details Access to runtime allows to encapsualate many aspects of data access and makes * the component widely independent from a central data provideer * \sa BlackCore::CRuntime diff --git a/src/blackgui/components/settingscomponent.h b/src/blackgui/components/settingscomponent.h index 6e66fcf8d..72912e011 100644 --- a/src/blackgui/components/settingscomponent.h +++ b/src/blackgui/components/settingscomponent.h @@ -27,7 +27,9 @@ namespace BlackGui { //! Settings component - class CSettingsComponent : public QTabWidget, public CRuntimeBasedComponent + class CSettingsComponent : + public QTabWidget, + public CRuntimeBasedComponent { Q_OBJECT diff --git a/src/blackgui/components/textmessagecomponent.h b/src/blackgui/components/textmessagecomponent.h index e70512de2..3dfddee0f 100644 --- a/src/blackgui/components/textmessagecomponent.h +++ b/src/blackgui/components/textmessagecomponent.h @@ -13,7 +13,6 @@ #define BLACKGUI_TEXTMESSAGECOMPONENT_H #include "blackgui/components/runtimebasedcomponent.h" -#include "blackgui/components/timerbasedcomponent.h" #include "blackmisc/nwtextmessage.h" #include "blackmisc/avaircraft.h" #include "blackmisc/nwtextmessagelist.h" @@ -29,7 +28,9 @@ namespace BlackGui namespace Components { //! Text message widget - class CTextMessageComponent : public QTabWidget, public CRuntimeBasedComponent + class CTextMessageComponent : + public QTabWidget, + public CRuntimeBasedComponent { Q_OBJECT diff --git a/src/blackgui/components/timerbasedcomponent.cpp b/src/blackgui/components/timerbasedcomponent.cpp index 07696a405..d6aeaa2b4 100644 --- a/src/blackgui/components/timerbasedcomponent.cpp +++ b/src/blackgui/components/timerbasedcomponent.cpp @@ -14,7 +14,7 @@ namespace BlackGui namespace Components { CTimerBasedComponent::CTimerBasedComponent(const char *slot, QObject *parent) : - QObject(parent), m_timer(nullptr) + QObject(parent) { Q_ASSERT(parent); this->m_timer = new QTimer(this); diff --git a/src/blackgui/components/timerbasedcomponent.h b/src/blackgui/components/timerbasedcomponent.h index 86a28790e..1dc883371 100644 --- a/src/blackgui/components/timerbasedcomponent.h +++ b/src/blackgui/components/timerbasedcomponent.h @@ -19,7 +19,7 @@ namespace BlackGui { namespace Components { - //! Timer based componenet + //! Helper class: Timer based componenet class CTimerBasedComponent: public QObject { Q_OBJECT @@ -52,8 +52,8 @@ namespace BlackGui void fireTimer(); private: - QTimer *m_timer; - QTimer *m_timerSingleShot; + QTimer *m_timer = nullptr; + QTimer *m_timerSingleShot = nullptr; }; } } diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index a278dee43..5af9297fe 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -176,20 +176,6 @@ namespace BlackGui this->setTitleBarWidget(this->m_emptyTitleBar); } - QList CDockWidget::findEmbeddedRuntimeComponents() const - { - QList widgets = this->findChildren(); - QList widgetsWithRuntimeComponent; - foreach(QWidget * w, widgets) - { - if (dynamic_cast(w)) - { - widgetsWithRuntimeComponent.append(w); - } - } - return widgetsWithRuntimeComponent; - } - void CDockWidget::ps_showContextMenu(const QPoint &pos) { QPoint globalPos = this->mapToGlobal(pos); diff --git a/src/blackgui/dockwidget.h b/src/blackgui/dockwidget.h index 641ade8d9..08cec1f6d 100644 --- a/src/blackgui/dockwidget.h +++ b/src/blackgui/dockwidget.h @@ -98,13 +98,13 @@ namespace BlackGui //! Override close event virtual void closeEvent(QCloseEvent *event) override; - //! Paint event + //! \copydoc QWidget::paintEvent virtual void paintEvent(QPaintEvent *event) override; - //! Hide event + //! \copydoc QWidget::hideEvent void hideEvent(QHideEvent *event) override; - //! Show event + //! \copydoc QWidget::showEvent void showEvent(QShowEvent *event) override; //! Contribute to menu @@ -138,13 +138,8 @@ namespace BlackGui bool m_wasAlreadyFloating = false; bool m_selected = false; //!< selected when tabbed - //! Empty widget with no size void initTitleBarWidgets(); - - //! Find all embedded runtime components - QList findEmbeddedRuntimeComponents() const; - }; } // namespace diff --git a/src/blackgui/infoarea.h b/src/blackgui/infoarea.h index d39e3d3c0..7cb5f5181 100644 --- a/src/blackgui/infoarea.h +++ b/src/blackgui/infoarea.h @@ -60,7 +60,7 @@ namespace BlackGui void floatAllWidgets(); //! Toggle dock / floating of the whole info area - void toggleFloating(); + virtual void toggleFloating(); //! Toggle floating of index void toggleFloating(int areaIndex); @@ -75,6 +75,9 @@ namespace BlackGui //! Override close event virtual void closeEvent(QCloseEvent *event) override; + //! \copydoc QWidget::paintEvent + virtual void paintEvent(QPaintEvent *event) override; + //! Preferred size when floating virtual QSize getPreferredSizeWhenFloating(int areaIndex) const = 0; @@ -88,10 +91,10 @@ namespace BlackGui Ui::CInfoArea *ui = nullptr; QList m_dockableWidgets ; QTabBar *m_tabBar = nullptr; - bool m_showTabTexts = true; - bool m_infoAreaFloating = false; //!< whole info area floating - bool m_showTabBar = true; //!< auto ajdust the floating widgets - bool m_lockTabBar = false; //!< locked means no double clicks possible + bool m_showTabTexts = true; //!< texts for tabs + bool m_infoAreaFloating = false; //!< whole info area floating + bool m_showTabBar = true; //!< auto ajdust the floating widgets + bool m_lockTabBar = false; //!< locked means no double clicks possible //! Tabify the widgets void tabifyAllWidgets(); @@ -129,6 +132,12 @@ namespace BlackGui //! Margins for the dockable widgets void setMarginsWhenDocked(int left, int top, int right, int bottom); + //! Nested info areas + QList getChildInfoAreas() { return this->findChildren(); } + + //! Direct dock widget areas, not the nested dock widget areas + QList getOwnDockWidgetAreas(); + private slots: //! Tab bar has been double clicked void ps_tabBarDoubleClicked(int tabBarIndex); @@ -163,7 +172,8 @@ namespace BlackGui //! Dock / floating of the whole info area void ps_setInfoAreaFloating(bool floating); + }; -} +} // namespace #endif // guard diff --git a/src/blackmisc/iconlist.cpp b/src/blackmisc/iconlist.cpp index 08d276d5e..ca55d6d8c 100644 --- a/src/blackmisc/iconlist.cpp +++ b/src/blackmisc/iconlist.cpp @@ -100,6 +100,7 @@ namespace BlackMisc CIcon(CIcons::StandardIconPaperPlane16, "plane"), CIcon(CIcons::StandardIconPlugin16, "plugin"), CIcon(CIcons::StandardIconRadar16, "radar"), + CIcon(CIcons::StandardIconRadio16, "radio"), CIcon(CIcons::StandardIconRefresh16, "refresh"), CIcon(CIcons::StandardIconResize16, "resize"), CIcon(CIcons::StandardIconResizeHorizontal16, "resize (horizontal)"), diff --git a/src/blackmisc/icons.h b/src/blackmisc/icons.h index 247a755e9..209b784f1 100644 --- a/src/blackmisc/icons.h +++ b/src/blackmisc/icons.h @@ -93,6 +93,7 @@ namespace BlackMisc StandardIconPaperPlane16, StandardIconPlugin16, StandardIconRadar16, + StandardIconRadio16, StandardIconRefresh16, StandardIconResize16, StandardIconResizeHorizontal16, @@ -543,6 +544,12 @@ namespace BlackMisc return tableSheet16(); } + //! Application cockpit + static const QPixmap &appCockpit16() + { + return radio16(); + } + //! Application simulator static const QPixmap &appSimulator16() {