refs #312, Navigator (aka navigation bars)

* different dyn. property names for main window, dock window and infoarea
* dyn.properties for nested QWidgets
* style sheet for navigator
* utility function to delete layout
* added standard OS icons, some formatting in CICons
* actions in main window to be used in navigator
* main window becomes normal window when minimized so it is correctly displayed in Win taskbar

Remark: Frameless floating dockwidgets with rounded borders not yet working
This commit is contained in:
Klaus Basan
2015-04-16 19:17:11 +02:00
parent a05fa7494f
commit 72aa072f30
29 changed files with 832 additions and 243 deletions

View File

@@ -49,7 +49,7 @@ BlackGui::CEnableForFramelessWindow::WindowMode CIntroWindow::getWindowMode() co
if (this->ui->rb_WindowFrameless->isChecked())
return BlackGui::CEnableForFramelessWindow::WindowFrameless;
else
return BlackGui::CEnableForFramelessWindow::WindowNormal;
return BlackGui::CEnableForFramelessWindow::WindowTool;
}
/*

View File

@@ -41,34 +41,39 @@ using namespace BlackMisc::Hardware;
*/
SwiftGuiStd::SwiftGuiStd(BlackGui::CEnableForFramelessWindow::WindowMode windowMode, QWidget *parent) :
QMainWindow(parent, CEnableForFramelessWindow::modeToWindowFlags(windowMode)),
CEnableForFramelessWindow(windowMode, true, this),
CEnableForFramelessWindow(windowMode, true, "framelessMainWindow", this),
ui(new Ui::SwiftGuiStd)
{
// GUI
ui->setupUi(this);
this->ui->wi_CentralWidgetOutside->setProperty("frameless", this->isFrameless());
this->setDynamicProperties(windowMode == CEnableForFramelessWindow::WindowFrameless);
this->m_compInfoWindow = new CInfoWindowComponent(this); // setupUi has to be first!
}
/*
* Destructor
*/
SwiftGuiStd::~SwiftGuiStd()
{ }
void SwiftGuiStd::mouseMoveEvent(QMouseEvent *event)
{
if (!handleMouseMoveEvent(event))
{
QMainWindow::mouseMoveEvent(event);
}
}
void SwiftGuiStd::mousePressEvent(QMouseEvent *event)
{
if (!handleMousePressEvent(event))
{
QMainWindow::mousePressEvent(event);
}
}
void SwiftGuiStd::performGracefulShutdown()
{
if (!this->m_init) { return; }
this->m_init = false;
// tell GUI components to shut down
emit requestGracefulShutdown();
// tell context GUI is going down
if (this->getIContextApplication())
{
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ApplicationGui, IContextApplication::ApplicationStops);
}
// clean up GUI
this->ui->comp_MainInfoArea->dockAllWidgets();
this->ui->comp_InvisibleInfoArea->dockAllWidgets();
// close info window
if (this->m_compInfoWindow)
@@ -77,9 +82,21 @@ void SwiftGuiStd::performGracefulShutdown()
this->m_compInfoWindow = nullptr;
}
if (!this->m_init) { return; }
this->m_init = false;
// tell GUI components to shut down
emit requestGracefulShutdown();
// shut down all timers
this->stopAllTimers(true);
// tell context GUI is going down
if (this->getIContextApplication())
{
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ApplicationGui, IContextApplication::ApplicationStops);
}
// if we have a context, we shut some things down
if (this->m_contextNetworkAvailable)
{
@@ -103,6 +120,73 @@ void SwiftGuiStd::closeEvent(QCloseEvent *event)
QApplication::exit();
}
void SwiftGuiStd::changeEvent(QEvent *event)
{
if (event->type() == QEvent::WindowStateChange)
{
// make sure a tool window is changed to Normal window so it is show in taskbar
if (!this->isFrameless())
{
bool toolWindow(this->isToolWindow());
if (isMinimized())
{
if (toolWindow)
{
// still tool, force normal window
BlackMisc::singleShot(0, QThread::currentThread(), [ = ]()
{
this->ps_showMinimized();
});
}
}
else
{
if (!toolWindow)
{
// not tool, force tool window
BlackMisc::singleShot(0, QThread::currentThread(), [ = ]()
{
this->ps_showNormal();
});
}
}
} // frameless?
}
QMainWindow::changeEvent(event);
}
QAction *SwiftGuiStd::getWindowMinimizeAction(QObject *parent)
{
QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarMinButton), Qt::white, QSize(16, 16)));
QAction *a = new QAction(i, "Window minimized", parent);
connect(a, &QAction::triggered, this, &SwiftGuiStd::ps_showMinimized);
return a;
}
QAction *SwiftGuiStd::getWindowNormalAction(QObject *parent)
{
QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarNormalButton), Qt::white, QSize(16, 16)));
QAction *a = new QAction(i, "Window normal", parent);
connect(a, &QAction::triggered, this, &SwiftGuiStd::ps_showNormal);
return a;
}
QAction *SwiftGuiStd::getToggleWindowVisibilityAction(QObject *parent)
{
QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarShadeButton), Qt::white, QSize(16, 16)));
QAction *a = new QAction(i, "Toogle main window visibility", parent);
connect(a, &QAction::triggered, this, &SwiftGuiStd::ps_toggleWindowVisibility);
return a;
}
QAction *SwiftGuiStd::getToggleStayOnTopAction(QObject *parent)
{
QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton), Qt::white, QSize(16, 16)));
QAction *a = new QAction(i, "Toogle main window on top", parent);
connect(a, &QAction::triggered, this, &SwiftGuiStd::ps_toogleWindowStayOnTop);
return a;
}
void SwiftGuiStd::ps_setMainPage(SwiftGuiStd::MainPageIndex mainPage)
{
this->ui->sw_MainMiddle->setCurrentIndex(mainPage);
@@ -228,7 +312,7 @@ void SwiftGuiStd::updateGuiStatusInformation()
if (this->m_contextNetworkAvailable)
{
bool dbus = !this->getIContextNetwork()->isUsingImplementingObject();
network = dbus ? now : "local";
network = dbus ? now : "local";
this->ui->comp_InfoBarStatus->setDBusStatus(dbus);
}
@@ -253,18 +337,30 @@ void SwiftGuiStd::ps_toogleWindowStayOnTop()
{
flags ^= Qt::WindowStaysOnTopHint;
flags |= Qt::WindowStaysOnBottomHint;
this->ps_displayStatusMessageInGui(CLogMessage(this).info("Window on bottom"));
CLogMessage(this).info("Window on bottom");
}
else
{
flags ^= Qt::WindowStaysOnBottomHint;
flags |= Qt::WindowStaysOnTopHint;
this->ps_displayStatusMessageInGui(CLogMessage(this).info("Window on top"));
CLogMessage(this).info("Window on top");
}
this->setWindowFlags(flags);
this->show();
}
void SwiftGuiStd::ps_toggleWindowVisibility()
{
if (this->isVisible())
{
this->hide();
}
else
{
this->show();
}
}
void SwiftGuiStd::ps_registerHotkeyFunctions()
{
CInputManager *m_inputManager = BlackCore::CInputManager::getInstance();
@@ -308,6 +404,18 @@ void SwiftGuiStd::ps_onChangedMainInfoAreaFloating(bool floating)
Q_UNUSED(floating);
}
void SwiftGuiStd::ps_showMinimized()
{
if (!this->isFrameless()) { toolToNormalWindow(); }
this->showMinimized();
}
void SwiftGuiStd::ps_showNormal()
{
if (!this->isFrameless()) { normalToToolWindow(); }
this->showNormal();
}
void SwiftGuiStd::playNotifcationSound(CNotificationSounds::Notification notification) const
{
if (!this->m_contextAudioAvailable) return;

View File

@@ -84,14 +84,29 @@ signals:
protected:
//! \copydoc QMainWindow::mouseMoveEvent
virtual void mouseMoveEvent(QMouseEvent *event) override { if (!handleMouseMoveEvent(event)) { QMainWindow::mouseMoveEvent(event); } ; }
virtual void mouseMoveEvent(QMouseEvent *event) override;
//! \copydoc QMainWindow::mousePressEvent
virtual void mousePressEvent(QMouseEvent *event) override { if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); } }
virtual void mousePressEvent(QMouseEvent *event) override;
//! \copydoc QMainWindow::closeEvent
virtual void closeEvent(QCloseEvent *event) override;
//! \copydoc QMainWindow::changeEvent
virtual void changeEvent(QEvent *event) override;
//! Get a minimize action which minimizes the window
QAction *getWindowMinimizeAction(QObject *parent);
//! Get a normal window action which minimizes the window
QAction *getWindowNormalAction(QObject *parent);
//! Toggle window visibility action
QAction *getToggleWindowVisibilityAction(QObject *parent);
//! Toggle window stay on top action
QAction *getToggleStayOnTopAction(QObject *parent);
private:
QScopedPointer<Ui::SwiftGuiStd> ui;
bool m_init = false;
@@ -125,6 +140,9 @@ private:
//! Init dynamic menus
void initDynamicMenus();
//! Menu icons where required
void initMenuIcons();
//! Graceful shutdown
void performGracefulShutdown();
@@ -140,7 +158,7 @@ private:
//! Context availability, used by watchdog
void setContextAvailability();
//! \brief Position of own plane for testing
//! Position of own plane for testing
//! \param wgsLatitude WGS latitude
//! \param wgsLongitude WGS longitude
//! \param altitude
@@ -148,7 +166,6 @@ private:
//! Is given main page selected?
//! \param mainPage index to be checked
//! \return
bool isMainPageSelected(MainPageIndex mainPage) const;
//! Start all update timers
@@ -157,11 +174,9 @@ private:
//! Stop all update timers
void stopUpdateTimersWhenDisconnected();
/*!
* \brief Stop all timers
* \param disconnect also disconnect signal/slots
*/
void stopAllTimers(bool disconnect);
//! \brief Stop all timers
//! \param disconnect also disconnect signal/slots
void stopAllTimers(bool disconnectSignalSlots);
//! Play notifcation sound
void playNotifcationSound(BlackSound::CNotificationSounds::Notification notification) const;
@@ -189,11 +204,9 @@ private slots:
//! Settings have been changed
void ps_onChangedSetttings(uint typeValue);
/*!
* \brief Connection status changed
* \param from old status, as int so it is compliant with DBus
* \param to new status, as int so it is compliant with DBus
*/
//! Connection status changed
//! \param from old status, as int so it is compliant with DBus
//! \param to new status, as int so it is compliant with DBus
void ps_onConnectionStatusChanged(int from, int to);
//
@@ -224,9 +237,12 @@ private slots:
//! Change opacity 0-100
void ps_onChangedWindowOpacity(int opacity = -1);
//! Toogle Windows stay on top
//! Toogle if windows stays on top
void ps_toogleWindowStayOnTop();
//! Toggle window visibility
void ps_toggleWindowVisibility();
//! Set the hotkey functions
void ps_registerHotkeyFunctions();
@@ -238,6 +254,12 @@ private slots:
//! Whole main info area floating
void ps_onChangedMainInfoAreaFloating(bool floating);
//! Show window minimized
void ps_showMinimized();
//! Show window normal
void ps_showNormal();
};
#pragma pop_macro("interface")

View File

@@ -124,7 +124,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="pg_MainInfoArea">
<layout class="QVBoxLayout" name="vl_MainInfoArea">

View File

@@ -15,6 +15,7 @@
#include "blackgui/guiutility.h"
#include "blackgui/components/textmessagecomponent.h"
#include "blackgui/components/cockpitcomponent.h"
#include "blackgui/components/navigatordockwidget.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/models/keyboardkeylistmodel.h"
#include "blackmisc/icons.h"
@@ -32,7 +33,6 @@ using namespace BlackMisc::Hardware;
using namespace BlackGui;
using namespace BlackGui::Components;
/*
* Init data
*/
@@ -46,6 +46,7 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
// icon, initial position where intro was before
this->setWindowIcon(CIcons::swift24());
this->setWindowTitle(CProject::systemNameAndVersion());
this->setObjectName("SwiftGuiStd");
QPoint pos = CGuiUtility::introWindowPosition();
this->move(pos);
@@ -70,7 +71,11 @@ 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);
this->m_timerContextWatchdog->setObjectName(this->objectName().append(":m_timerContextWatchdog"));
}
// context
this->createRuntime(runtimeConfig, this);
@@ -81,6 +86,17 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
this->ui->dw_InfoBarStatus->allowStatusBar(false);
this->ui->dw_InfoBarStatus->setPreferredSizeWhenFloating(this->ui->dw_InfoBarStatus->size()); // set floating size
// navigator
CNavigatorDockWidget *nav = this->ui->comp_InvisibleInfoArea->getNavigatorComponent();
Q_ASSERT(nav);
nav->addAction(this->getToggleWindowVisibilityAction(nav));
nav->addActions(this->ui->comp_MainInfoArea->getInfoAreaToggleFloatingActions(nav));
nav->addAction(this->getWindowNormalAction(nav));
nav->addAction(this->getWindowMinimizeAction(nav));
nav->addAction(this->getToggleStayOnTopAction(nav));
this->ui->comp_InvisibleInfoArea->getNavigatorComponent()->buildNavigator(1);
// wire GUI signals
this->initGuiSignals();
@@ -107,6 +123,7 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
// start screen and complete menu
this->ps_setMainPageToInfoArea();
this->initDynamicMenus();
this->initMenuIcons();
// starting
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ApplicationGui, IContextApplication::ApplicationStarts);
@@ -237,10 +254,10 @@ void SwiftGuiStd::stopUpdateTimersWhenDisconnected()
/*
* Stop all timers
*/
void SwiftGuiStd::stopAllTimers(bool disconnect)
void SwiftGuiStd::stopAllTimers(bool disconnectSignalSlots)
{
this->m_timerContextWatchdog->stop();
this->stopUpdateTimersWhenDisconnected();
if (!disconnect) return;
if (!disconnectSignalSlots) { return; }
this->disconnect(this->m_timerContextWatchdog);
}

View File

@@ -70,7 +70,7 @@ void SwiftGuiStd::ps_onMenuClicked()
}
else if (sender == this->ui->menu_WindowMinimize)
{
this->showMinimized();
this->ps_showMinimized();
}
else if (sender == this->ui->menu_WindowToggleOnTop)
{
@@ -107,3 +107,8 @@ void SwiftGuiStd::initDynamicMenus()
this->ui->menu_InfoAreas->addActions(this->ui->comp_MainInfoArea->getInfoAreaSelectActions(this->ui->menu_InfoAreas));
}
void SwiftGuiStd::initMenuIcons()
{
this->ui->menu_WindowMinimize->setIcon(this->style()->standardIcon(QStyle::SP_TitleBarMinButton));
}