refs #312, preparation for small navigation bars

This commit is contained in:
Klaus Basan
2015-04-02 04:02:48 +02:00
parent 6634260970
commit 425e034b19
9 changed files with 257 additions and 26 deletions

View File

@@ -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

View File

@@ -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 <QDockWidget>
#include <QScopedPointer>
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::CNavigatorDockWidget> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CNavigatorDockWidget</class>
<widget class="QDockWidget" name="CNavigatorDockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>89</width>
<height>300</height>
</rect>
</property>
<property name="floating">
<bool>true</bool>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::NoDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Navigator</string>
</property>
<widget class="QWidget" name="qw_NavigatorDockWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="toolButton_2">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -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())

View File

@@ -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;

View File

@@ -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;

View File

@@ -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")

View File

@@ -18,8 +18,8 @@
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>550</height>
<width>20</width>
<height>100</height>
</size>
</property>
<property name="windowTitle">
@@ -305,6 +305,8 @@
<addaction name="menu_WindowFont"/>
<addaction name="menu_WindowMinimize"/>
<addaction name="menu_WindowToggleOnTop"/>
<addaction name="menu_NavigatorVertical"/>
<addaction name="menu_NavigatorHorizontal"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menuWindow"/>
@@ -347,6 +349,42 @@
</attribute>
<widget class="BlackGui::Components::CInfoBarStatusComponent" name="comp_InfoBarStatus"/>
</widget>
<widget class="BlackGui::Components::CNavigatorDockWidget" name="ndw_NavigatorHorizontal">
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::NoDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Horizontal navigator</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="qw_NavigatorHorizontal"/>
</widget>
<widget class="BlackGui::Components::CNavigatorDockWidget" name="ndw_NavigatorVertical">
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="allowedAreas">
<set>Qt::NoDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Vertical navigator</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="qw_NavigatorVertical"/>
</widget>
<action name="menu_TestLocationsEDDF">
<property name="text">
<string>Position EDDF (Frankfurt, GER)</string>
@@ -428,6 +466,16 @@
<string>Ctrl+W, Ctrl+T</string>
</property>
</action>
<action name="menu_NavigatorVertical">
<property name="text">
<string>Vertical navigator</string>
</property>
</action>
<action name="menu_NavigatorHorizontal">
<property name="text">
<string>Horizontal navigator</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@@ -467,6 +515,12 @@
<header>blackgui/components/internalscomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CNavigatorDockWidget</class>
<extends>QDockWidget</extends>
<header>blackgui/components/navigatordockwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -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);