From 425e034b19cc5e1ec26c2006f0d207ee4252ce34 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 2 Apr 2015 04:02:48 +0200 Subject: [PATCH] refs #312, preparation for small navigation bars --- .../components/navigatordockwidget.cpp | 31 ++++++++++ src/blackgui/components/navigatordockwidget.h | 45 ++++++++++++++ .../components/navigatordockwidget.ui | 46 +++++++++++++++ src/blackgui/dockwidget.cpp | 26 +++++++++ src/blackgui/dockwidget.h | 10 ++-- src/swiftgui_standard/swiftguistd.cpp | 17 +++++- src/swiftgui_standard/swiftguistd.h | 27 +++++---- src/swiftgui_standard/swiftguistd.ui | 58 ++++++++++++++++++- src/swiftgui_standard/swiftguistd_init.cpp | 23 ++++++-- 9 files changed, 257 insertions(+), 26 deletions(-) create mode 100644 src/blackgui/components/navigatordockwidget.cpp create mode 100644 src/blackgui/components/navigatordockwidget.h create mode 100644 src/blackgui/components/navigatordockwidget.ui diff --git a/src/blackgui/components/navigatordockwidget.cpp b/src/blackgui/components/navigatordockwidget.cpp new file mode 100644 index 000000000..679516c39 --- /dev/null +++ b/src/blackgui/components/navigatordockwidget.cpp @@ -0,0 +1,31 @@ +/* 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 "navigatordockwidget.h" +#include "ui_navigatordockwidget.h" + +using namespace BlackGui; + +namespace BlackGui +{ + namespace Components + { + CNavigatorDockWidget::CNavigatorDockWidget(QWidget *parent) : + CDockWidget(parent), + ui(new Ui::CNavigatorDockWidget) + { + ui->setupUi(this); + } + + CNavigatorDockWidget::~CNavigatorDockWidget() + { } + + } // ns +} // ns diff --git a/src/blackgui/components/navigatordockwidget.h b/src/blackgui/components/navigatordockwidget.h new file mode 100644 index 000000000..e054468cf --- /dev/null +++ b/src/blackgui/components/navigatordockwidget.h @@ -0,0 +1,45 @@ +/* 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_NAVIGATORDOCKWIDGET_H +#define BLACKGUI_NAVIGATORDOCKWIDGET_H + +#include "blackgui/dockwidget.h" +#include +#include + +namespace Ui { class CNavigatorDockWidget; } + +namespace BlackGui +{ + namespace Components + { + + //! Dock widget for navigators + class CNavigatorDockWidget : public BlackGui::CDockWidget + { + Q_OBJECT + + public: + //! Constructor + explicit CNavigatorDockWidget(QWidget *parent = nullptr); + + //! Destructor + ~CNavigatorDockWidget(); + + private: + QScopedPointer ui; + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/navigatordockwidget.ui b/src/blackgui/components/navigatordockwidget.ui new file mode 100644 index 000000000..0bb56421e --- /dev/null +++ b/src/blackgui/components/navigatordockwidget.ui @@ -0,0 +1,46 @@ + + + CNavigatorDockWidget + + + + 0 + 0 + 89 + 300 + + + + true + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + Qt::NoDockWidgetArea + + + Navigator + + + + + + + ... + + + + + + + ... + + + + + + + + + diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index 29eaaa006..28ed80255 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -76,6 +76,11 @@ namespace BlackGui this->m_marginsWhenDocked = QMargins(left, top, right, bottom); } + bool CDockWidget::isWidgetVisible() const + { + return this->m_dockWidgetVisible && this->isVisible(); + } + void CDockWidget::setWindowTitle(const QString &title) { this->m_windowTitleBackup = title; @@ -107,6 +112,17 @@ namespace BlackGui } } + void CDockWidget::resetWasAlreadyFloating() + { + this->m_wasAlreadyFloating = false; + this->m_resetedFloating = true; + } + + void CDockWidget::setPreferredSizeWhenFloating(const QSize &size) + { + this->m_preferredSizeWhenFloating = size; + } + void CDockWidget::toggleFloating() { this->setFloating(!this->isFloating()); @@ -143,6 +159,16 @@ namespace BlackGui QDockWidget::paintEvent(event); } + void CDockWidget::mouseMoveEvent(QMouseEvent *event) + { + if (!handleMouseMoveEvent(event)) { QDockWidget::mouseMoveEvent(event); } ; + } + + void CDockWidget::mousePressEvent(QMouseEvent *event) + { + if (!handleMousePressEvent(event)) { QDockWidget::mousePressEvent(event); } + } + void CDockWidget::addToContextMenu(QMenu *contextMenu) const { if (this->isFloating()) diff --git a/src/blackgui/dockwidget.h b/src/blackgui/dockwidget.h index 8321fb5e2..547a227d9 100644 --- a/src/blackgui/dockwidget.h +++ b/src/blackgui/dockwidget.h @@ -71,7 +71,7 @@ namespace BlackGui //! Is widget visible? Not to be confused with \sa QWidget::isVisbible //! \remarks Logical vsibility as in \sa QDockWidget::visibilityChanged - bool isWidgetVisible() const { return this->m_dockWidgetVisible && this->isVisible(); } + bool isWidgetVisible() const; //! Allow a status bar to be displayed void allowStatusBar(bool allow) { this->m_allowStatusBar = allow; } @@ -80,13 +80,13 @@ namespace BlackGui void showTitleWhenDocked(bool show); //! Reset first time floating, marked as never floated before - void resetWasAlreadyFloating() { this->m_wasAlreadyFloating = false; this->m_resetedFloating = true; } + void resetWasAlreadyFloating(); //! Was widget already floating? bool wasAlreadyFloating() const { return this->m_wasAlreadyFloating; } //! Size when floating first time - void setPreferredSizeWhenFloating(const QSize &size) { this->m_preferredSizeWhenFloating = size; } + void setPreferredSizeWhenFloating(const QSize &size); //! Position offset when floating first time void setOffsetWhenFloating(const QPoint &point) { this->m_offsetWhenFloating = point; } @@ -122,10 +122,10 @@ namespace BlackGui virtual void paintEvent(QPaintEvent *event) override; //! \copydoc QMainWindow::mouseMoveEvent - virtual void mouseMoveEvent(QMouseEvent *event) override { if (!handleMouseMoveEvent(event)) { QDockWidget::mouseMoveEvent(event); } ; } + virtual void mouseMoveEvent(QMouseEvent *event) override; //! \copydoc QMainWindow::mousePressEvent - virtual void mousePressEvent(QMouseEvent *event) override { if (!handleMousePressEvent(event)) { QDockWidget::mousePressEvent(event); } } + virtual void mousePressEvent(QMouseEvent *event) override; //! Contribute to menu virtual void addToContextMenu(QMenu *contextMenu) const; diff --git a/src/swiftgui_standard/swiftguistd.cpp b/src/swiftgui_standard/swiftguistd.cpp index 16477e27f..1ad65b1fc 100644 --- a/src/swiftgui_standard/swiftguistd.cpp +++ b/src/swiftgui_standard/swiftguistd.cpp @@ -149,9 +149,9 @@ bool SwiftGuiStd::isContextAudioAvailableCheck() void SwiftGuiStd::ps_displayStatusMessageInGui(const CStatusMessage &statusMessage) { - if (!this->m_init) return; - if (statusMessage.isRedundant()) return; - if (statusMessage.wasHandledBy(this)) return; + if (!this->m_init) { return; } + if (statusMessage.isRedundant()) { return; } + if (statusMessage.wasHandledBy(this)) { return; } statusMessage.markAsHandledBy(this); this->m_statusBar.displayStatusMessage(statusMessage); this->ui->comp_MainInfoArea->displayStatusMessage(statusMessage); @@ -308,6 +308,17 @@ void SwiftGuiStd::ps_onChangedMainInfoAreaFloating(bool floating) Q_UNUSED(floating); } +void SwiftGuiStd::ps_toggleNavigatorHorizontal() +{ + +} + +void SwiftGuiStd::ps_toggleNavigatorVertical() +{ + bool v = ui->ndw_NavigatorVertical->isVisible(); + ui->ndw_NavigatorVertical->setVisible(!v); +} + void SwiftGuiStd::playNotifcationSound(CNotificationSounds::Notification notification) const { if (!this->m_contextAudioAvailable) return; diff --git a/src/swiftgui_standard/swiftguistd.h b/src/swiftgui_standard/swiftguistd.h index 697c73f2b..290f54cbe 100644 --- a/src/swiftgui_standard/swiftguistd.h +++ b/src/swiftgui_standard/swiftguistd.h @@ -121,6 +121,9 @@ private: //! Init GUI signals void initGuiSignals(); + //! Init the navigstion bars + void initNavigationBars(); + //! Init dynamic menus void initDynamicMenus(); @@ -139,19 +142,15 @@ private: //! Context availability, used by watchdog void setContextAvailability(); - /*! - * \brief Position of own plane for testing - * \param wgsLatitude WGS latitude - * \param wgsLongitude WGS longitude - * \param altitude - */ + //! \brief Position of own plane for testing + //! \param wgsLatitude WGS latitude + //! \param wgsLongitude WGS longitude + //! \param altitude void setTestPosition(const QString &wgsLatitude, const QString &wgsLongitude, const BlackMisc::Aviation::CAltitude &altitude); - /*! - * \brief Is given main page selected? - * \param mainPage index to be checked - * \return - */ + //! Is given main page selected? + //! \param mainPage index to be checked + //! \return bool isMainPageSelected(MainPageIndex mainPage) const; //! Start all update timers @@ -242,6 +241,12 @@ private slots: //! Whole main info area floating void ps_onChangedMainInfoAreaFloating(bool floating); + //! Toggle horizontal navigator + void ps_toggleNavigatorHorizontal(); + + //! Toggle vertical navigator + void ps_toggleNavigatorVertical(); + }; #pragma pop_macro("interface") diff --git a/src/swiftgui_standard/swiftguistd.ui b/src/swiftgui_standard/swiftguistd.ui index 0646836d7..ca159092a 100644 --- a/src/swiftgui_standard/swiftguistd.ui +++ b/src/swiftgui_standard/swiftguistd.ui @@ -18,8 +18,8 @@ - 350 - 550 + 20 + 100 @@ -305,6 +305,8 @@ + + @@ -347,6 +349,42 @@ + + + false + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + Qt::NoDockWidgetArea + + + Horizontal navigator + + + 1 + + + + + + false + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable + + + Qt::NoDockWidgetArea + + + Vertical navigator + + + 1 + + + Position EDDF (Frankfurt, GER) @@ -428,6 +466,16 @@ Ctrl+W, Ctrl+T + + + Vertical navigator + + + + + Horizontal navigator + + @@ -467,6 +515,12 @@
blackgui/components/internalscomponent.h
1 + + BlackGui::Components::CNavigatorDockWidget + QDockWidget +
blackgui/components/navigatordockwidget.h
+ 1 +
diff --git a/src/swiftgui_standard/swiftguistd_init.cpp b/src/swiftgui_standard/swiftguistd_init.cpp index 2b0e6293a..6a56867bb 100644 --- a/src/swiftgui_standard/swiftguistd_init.cpp +++ b/src/swiftgui_standard/swiftguistd_init.cpp @@ -38,9 +38,8 @@ using namespace BlackGui::Components; */ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig) { - if (this->m_init) return; - - this->setVisible(false); + if (this->m_init) { return; } + this->setVisible(false); // hide all, so no flashing windows during init // icon, initial position where intro was before this->setWindowIcon(CIcons::swift24()); @@ -69,7 +68,7 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig) } // timers - if (this->m_timerContextWatchdog == nullptr) this->m_timerContextWatchdog = new QTimer(this); + if (this->m_timerContextWatchdog == nullptr) { this->m_timerContextWatchdog = new QTimer(this) ; } // context this->createRuntime(runtimeConfig, this); @@ -106,6 +105,9 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig) this->ps_setMainPageToInfoArea(); this->initDynamicMenus(); + // navigation bars + // this->initNavigationBars(); + // starting this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ApplicationGui, IContextApplication::ApplicationStarts); @@ -126,6 +128,15 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig) this->m_init = true; } +/* + * Init navigation bars + */ +void SwiftGuiStd::initNavigationBars() +{ + ui->ndw_NavigatorHorizontal->setVisible(false); + ui->ndw_NavigatorVertical->setVisible(false); +} + /* * GUI signals */ @@ -159,7 +170,9 @@ void SwiftGuiStd::initGuiSignals() connect(this->ui->menu_WindowFont, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_WindowMinimize, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); connect(this->ui->menu_WindowToggleOnTop, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); - connect(this->ui->menu_DebugMetaTypes, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked); + connect(this->ui->menu_NavigatorHorizontal, &QAction::triggered, this, &SwiftGuiStd::ps_toggleNavigatorHorizontal); + connect(this->ui->menu_NavigatorVertical, &QAction::triggered, this, &SwiftGuiStd::ps_toggleNavigatorVertical); + connect(this->ui->menu_DebugMetaTypes, &QAction::triggered, this, &SwiftGuiStd::ps_toggleNavigatorHorizontal); // command line / text messages connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display);