refs #312 navigation bars, contributes also to #347

* allow to set/unset frameless mode in CDockWidget
* adjusted context menus
* adjusted style sheets
* ini settings for margins
* hidden info area to host floating widgets only visible when floating (allows to CDockInfoArea widgets)
* made some private slots non-virtual
This commit is contained in:
Klaus Basan
2015-04-08 22:46:54 +02:00
parent 425e034b19
commit e7c8c28252
23 changed files with 556 additions and 175 deletions

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>27</height>
<width>415</width>
<height>20</height>
</rect>
</property>
<property name="windowTitle">
@@ -18,10 +18,13 @@
<normaloff>:/own/icons/own/swift/swift24.png</normaloff>:/own/icons/own/swift/swift24.png</iconset>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="hl_InfoBarStatus">
<property name="spacing">

View File

@@ -0,0 +1,66 @@
/* 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 "invisibleinfoareacomponent.h"
#include "ui_invisibleinfoareacomponent.h"
#include "blackmisc/icons.h"
using namespace BlackGui;
using namespace BlackMisc;
namespace BlackGui
{
namespace Components
{
CInvisibleInfoAreaComponent::CInvisibleInfoAreaComponent(QWidget *parent) :
CInfoArea(parent),
ui(new Ui::CInvisibleInfoAreaComponent)
{
ui->setupUi(this);
this->ui->comp_Navigator->allowStatusBar(false);
this->initInfoArea();
}
CInvisibleInfoAreaComponent::~CInvisibleInfoAreaComponent()
{ }
QSize CInvisibleInfoAreaComponent::getPreferredSizeWhenFloating(int areaIndex) const
{
InfoArea area = static_cast<InfoArea>(areaIndex);
switch (area)
{
case InfoAreaHorizontalNavigator:
return QSize(400, 50);
case InfoAreaVerticalNavigator:
return QSize(50, 400);
default:
return QSize(0, 0);
}
}
const QPixmap &CInvisibleInfoAreaComponent::indexToPixmap(int areaIndex) const
{
InfoArea area = static_cast<InfoArea>(areaIndex);
switch (area)
{
case InfoAreaHorizontalNavigator:
case InfoAreaVerticalNavigator:
default:
return CIcons::empty();
}
}
void CInvisibleInfoAreaComponent::toggleNavigator()
{
this->ui->comp_Navigator->toggleFloating();
}
} // ns
} // ns

View File

@@ -0,0 +1,62 @@
/* 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_INVISIBLEINFOAREACOMPONENT_H
#define BLACKGUI_COMPONENTS_INVISIBLEINFOAREACOMPONENT_H
#include "blackgui/infoarea.h"
#include <QMainWindow>
namespace Ui { class CInvisibleInfoAreaComponent; }
namespace BlackGui
{
namespace Components
{
//! Info area to carry info areas on visibile when floating
class CInvisibleInfoAreaComponent : public BlackGui::CInfoArea
{
Q_OBJECT
public:
//! Info areas
enum InfoArea
{
// index must match tab index!
InfoAreaVerticalNavigator = 0,
InfoAreaHorizontalNavigator = 1
};
//! Consturctor
explicit CInvisibleInfoAreaComponent(QWidget *parent = nullptr);
//! Destructor
~CInvisibleInfoAreaComponent();
//! \copydoc CInfoArea::getPreferredSizeWhenFloating
virtual QSize getPreferredSizeWhenFloating(int areaIndex) const override;
//! \copydoc CInfoArea::indexToPixmap
const QPixmap &indexToPixmap(int areaIndex) const override;
public slots:
//! Navigator floating
void toggleNavigator();
private:
QScopedPointer<Ui::CInvisibleInfoAreaComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CInvisibleInfoAreaComponent</class>
<widget class="QMainWindow" name="CInvisibleInfoAreaComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Invisible info area</string>
</property>
<widget class="QWidget" name="qw_InvisibleInfoArea"/>
<widget class="BlackGui::Components::CNavigatorDockWidget" name="comp_Navigator">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Navigator</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="qw_Navigaor"/>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CNavigatorDockWidget</class>
<extends>QDockWidget</extends>
<header>blackgui/components/navigatordockwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -38,7 +38,17 @@
<property name="dockOptions">
<set>QMainWindow::AllowTabbedDocks|QMainWindow::ForceTabbedDocks</set>
</property>
<widget class="QWidget" name="qw_centralWidgetEmpty"/>
<widget class="QWidget" name="qw_centralWidgetEmpty">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Cockpit">
<property name="maximumSize">
<size>
@@ -271,7 +281,7 @@
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
@@ -282,10 +292,13 @@
<item>
<widget class="BlackGui::Components::CTextMessageComponent" name="comp_TextMessages">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
@@ -309,7 +322,7 @@
<number>4</number>
</attribute>
<widget class="QWidget" name="qw_SimulatorInner">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="vl_Simulator">
<property name="spacing">
<number>0</number>
</property>
@@ -363,7 +376,7 @@
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
@@ -408,11 +421,14 @@
</size>
</property>
<layout class="QVBoxLayout" name="vl_Weather">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
@@ -423,10 +439,13 @@
<item>
<widget class="QFrame" name="fr_WeatherDummy">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
@@ -504,7 +523,7 @@
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
@@ -515,10 +534,13 @@
<item>
<widget class="BlackGui::Components::CLogComponent" name="comp_Log">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
@@ -550,7 +572,7 @@
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>

View File

@@ -7,7 +7,6 @@
* contained in the LICENSE file.
*/
#include "navigatordockwidget.h"
#include "ui_navigatordockwidget.h"
@@ -18,7 +17,7 @@ namespace BlackGui
namespace Components
{
CNavigatorDockWidget::CNavigatorDockWidget(QWidget *parent) :
CDockWidget(parent),
CDockWidgetInfoArea(parent),
ui(new Ui::CNavigatorDockWidget)
{
ui->setupUi(this);

View File

@@ -12,7 +12,7 @@
#ifndef BLACKGUI_NAVIGATORDOCKWIDGET_H
#define BLACKGUI_NAVIGATORDOCKWIDGET_H
#include "blackgui/dockwidget.h"
#include "blackgui/dockwidgetinfoarea.h"
#include <QDockWidget>
#include <QScopedPointer>
@@ -24,7 +24,7 @@ namespace BlackGui
{
//! Dock widget for navigators
class CNavigatorDockWidget : public BlackGui::CDockWidget
class CNavigatorDockWidget : public BlackGui::CDockWidgetInfoArea
{
Q_OBJECT

View File

@@ -18,9 +18,10 @@
namespace BlackGui
{
CDockWidget::CDockWidget(QWidget *parent) :
CDockWidget::CDockWidget(bool allowStatusBar, QWidget *parent) :
QDockWidget(parent),
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowNormal, false, this)
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowNormal, false, this),
m_allowStatusBar(allowStatusBar)
{
this->ps_onStyleSheetsChanged();
@@ -37,6 +38,9 @@ namespace BlackGui
}
CDockWidget::CDockWidget(QWidget *parent): CDockWidget(true, parent)
{ }
void CDockWidget::setOriginalTitleBar()
{
if (!this->m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
@@ -51,7 +55,7 @@ namespace BlackGui
this->setTitleBarWidget(this->m_titleBarWidgetEmpty);
}
void CDockWidget::setNullTitleBar()
void CDockWidget::setNullTitleBarWidget()
{
this->setTitleBarWidget(nullptr);
}
@@ -61,11 +65,21 @@ namespace BlackGui
this->m_marginsWhenFloating = margins;
}
void CDockWidget::setMarginsWhenFramelessFloating(const QMargins &margins)
{
this->m_marginsWhenFramelessFloating = margins;
}
void CDockWidget::setMarginsWhenFloating(int left, int top, int right, int bottom)
{
this->m_marginsWhenFloating = QMargins(left, top, right, bottom);
}
void CDockWidget::setMarginsWhenFramelessFloating(int left, int top, int right, int bottom)
{
this->m_marginsWhenFramelessFloating = QMargins(left, top, right, bottom);
}
void CDockWidget::setMarginsWhenDocked(const QMargins &margins)
{
this->m_marginsWhenDocked = margins;
@@ -123,9 +137,53 @@ namespace BlackGui
this->m_preferredSizeWhenFloating = size;
}
void CDockWidget::setFrameless(bool frameless)
{
CEnableForFramelessWindow::setFrameless(frameless);
// grip
bool hasStatusBar = this->m_statusBar.getStatusBar();
if (frameless)
{
if (hasStatusBar)
{
this->addFramelessSizeGripToStatusBar(this->m_statusBar.getStatusBar());
}
}
else
{
if (hasStatusBar)
{
this->hideFramelessSizeGripInStatusBar();
}
}
// margins
if (this->isFloating())
{
this->setContentsMargins(frameless ? this->m_marginsWhenFramelessFloating : this->m_marginsWhenFloating);
}
// resize
if (frameless)
{
QWidget *innerWidget = this->widget(); // the inner widget containing the layout
Q_ASSERT(innerWidget);
this->resize(innerWidget->size());
}
//! \todo CDockWidget, check if style sheet reload is needed
this->ps_onStyleSheetsChanged(); // force style sheet reload
}
void CDockWidget::toggleFloating()
{
this->setFloating(!this->isFloating());
bool floating = !this->isFloating();
if (!floating)
{
this->setFrameless(false);
}
this->setFloating(floating);
}
void CDockWidget::toggleVisibility()
@@ -140,6 +198,18 @@ namespace BlackGui
}
}
void CDockWidget::toggleFrameless()
{
if (this->isFrameless())
{
this->setFrameless(false);
}
else
{
this->setFrameless(true);
}
}
void CDockWidget::closeEvent(QCloseEvent *event)
{
if (this->isFloating())
@@ -174,11 +244,21 @@ namespace BlackGui
if (this->isFloating())
{
contextMenu->addAction(BlackMisc::CIcons::dockTop16(), "Dock", this, SLOT(toggleFloating()));
if (this->isFrameless())
{
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Normal window", this, SLOT(toggleFrameless()));
}
else
{
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Frameless", this, SLOT(toggleFrameless()));
}
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Redraw", this, SLOT(update()));
}
else
{
contextMenu->addAction(BlackMisc::CIcons::floatOne16(), "Float", this, SLOT(toggleFloating()));
}
}
void CDockWidget::initialFloating()
@@ -204,6 +284,43 @@ namespace BlackGui
}
}
bool CDockWidget::setMarginsFromSettings(const QString &section)
{
QString sectionUsed(section.isEmpty() ? this->objectName() : section);
if (sectionUsed.isEmpty()) { return false; }
const QSettings *settings = CStyleSheetUtility::instance().iniFile();
if (!settings) { return false; }
// checked if value exists as there is no way to check if key/section exist
if (settings->value(sectionUsed + "/margindocked.left").toString().isEmpty())
{
// no values considered as no section, now we check if an alias exists
sectionUsed = settings->value("alias/" + sectionUsed).toString();
if (sectionUsed.isEmpty()) { return false; }
if (settings->value(sectionUsed + "/margindocked.left").toString().isEmpty()) { return false; }
}
if (settings)
{
this->setMarginsWhenDocked(
settings->value(sectionUsed + "/margindocked.left", 1).toInt(),
settings->value(sectionUsed + "/margindocked.top", 1).toInt(),
settings->value(sectionUsed + "/margindocked.right", 1).toInt(),
settings->value(sectionUsed + "/margindocked.bottom", 1).toInt());
this->setMarginsWhenFloating(
settings->value(sectionUsed + "/marginfloating.left", 10).toInt(),
settings->value(sectionUsed + "/marginfloating.top", 10).toInt(),
settings->value(sectionUsed + "/marginfloating.right", 10).toInt(),
settings->value(sectionUsed + "/marginfloating.bottom", 10).toInt());
this->setMarginsWhenFramelessFloating(
settings->value(sectionUsed + "/marginfloating.frameless.left", 5).toInt(),
settings->value(sectionUsed + "/marginfloating.frameless.top", 5).toInt(),
settings->value(sectionUsed + "/marginfloating.frameless.right", 5).toInt(),
settings->value(sectionUsed + "/marginfloating.frameless.bottom", 5).toInt());
}
return true;
}
void CDockWidget::ps_onTopLevelChanged(bool topLevel)
{
if (topLevel)
@@ -212,21 +329,22 @@ namespace BlackGui
{
QDockWidget::setWindowTitle(this->m_windowTitleBackup);
}
this->setNullTitleBar();
this->setContentsMargins(this->m_marginsWhenFloating);
this->setNullTitleBarWidget();
if (!this->m_wasAlreadyFloating) { this->initialFloating(); }
this->setContentsMargins(
this->isFrameless() ?
this->m_marginsWhenFramelessFloating :
this->m_marginsWhenFloating
);
this->m_statusBar.show();
if (this->m_wasAlreadyFloating || this->m_resetedFloating)
{
//! \todo dock widget frameless
// this->setFrameless(topLevel);
}
this->m_wasAlreadyFloating = true;
}
else
{
// frameless
this->setFrameless(false);
if (!this->m_windowTitleWhenDocked) { QDockWidget::setWindowTitle(""); }
this->m_statusBar.hide();
this->setEmptyTitleBar();
@@ -237,9 +355,6 @@ namespace BlackGui
{
this->setMinimumSize(this->m_initialDockedMinimumSize);
}
// frameless
this->setFrameless(topLevel);
}
// relay
@@ -259,17 +374,17 @@ namespace BlackGui
if (!this->m_allowStatusBar) { return; }
this->m_statusBar.initStatusBar();
QWidget *innerDockWidget = this->widget(); // the inner widget containing the layout
Q_ASSERT(innerDockWidget);
if (!innerDockWidget) { return; }
QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(innerDockWidget->layout());
QWidget *innerWidget = this->widget(); // the inner widget containing the layout
Q_ASSERT(innerWidget);
if (!innerWidget) { return; }
QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(innerWidget->layout());
Q_ASSERT(vLayout);
if (!vLayout) { return; }
vLayout->addWidget(this->m_statusBar.getStatusBar(), 0, Qt::AlignBottom);
// adjust stretching of the original widget. It was the only widget so far
// and should occupy maximum space
QWidget *compWidget = innerDockWidget->findChild<QWidget *>(QString(), Qt::FindDirectChildrenOnly);
QWidget *compWidget = innerWidget->findChild<QWidget *>(QString(), Qt::FindDirectChildrenOnly);
Q_ASSERT(compWidget);
if (!compWidget) { return; }
QSizePolicy sizePolicy = compWidget->sizePolicy();
@@ -293,6 +408,6 @@ namespace BlackGui
void CDockWidget::ps_onStyleSheetsChanged()
{
// void, for further extensions
this->update();
}
} // namespace

View File

@@ -46,7 +46,7 @@ namespace BlackGui
void setEmptyTitleBar();
//! Set null (nullptr) title bar
void setNullTitleBar();
void setNullTitleBarWidget();
//! Margins when window is floating
void setMarginsWhenFloating(const QMargins &margins);
@@ -54,12 +54,21 @@ namespace BlackGui
//! Margins when window is floating
void setMarginsWhenFloating(int left, int top, int right, int bottom);
//! Margins when window is floating (frameless)
void setMarginsWhenFramelessFloating(const QMargins &margins);
//! Margins when window is floating (frameless)
void setMarginsWhenFramelessFloating(int left, int top, int right, int bottom);
//! Margins when widget is floating
void setMarginsWhenDocked(const QMargins &margins);
//! Margins when widget is floating
void setMarginsWhenDocked(int left, int top, int right, int bottom);
//! Set margings from .ini file
bool setMarginsFromSettings(const QString &section = "");
//! Window title backup
const QString &windowTitleBackup() const { return this->m_windowTitleBackup; }
@@ -91,6 +100,9 @@ namespace BlackGui
//! Position offset when floating first time
void setOffsetWhenFloating(const QPoint &point) { this->m_offsetWhenFloating = point; }
//! \copydoc CEnableForFramelessWindow::setFrameless
virtual void setFrameless(bool frameless) override;
public slots:
//! Toggle floating
void toggleFloating();
@@ -98,6 +110,9 @@ namespace BlackGui
//! Toggle visibility
void toggleVisibility();
//! Toggle frameless mode (EXPERIMENTAL)
void toggleFrameless();
//! Set title and internally keep a backup
void setWindowTitle(const QString &title);
@@ -115,6 +130,9 @@ namespace BlackGui
//! Constructor
explicit CDockWidget(QWidget *parent = nullptr);
//! Constructor
CDockWidget(bool allowStatusBar, QWidget *parent = nullptr);
//! Override close event
virtual void closeEvent(QCloseEvent *event) override;
@@ -141,18 +159,19 @@ namespace BlackGui
private slots:
//! Top level has been chaged
virtual void ps_onTopLevelChanged(bool topLevel);
void ps_onTopLevelChanged(bool topLevel);
//! Context menu
virtual void ps_showContextMenu(const QPoint &pos);
void ps_showContextMenu(const QPoint &pos);
//! Visibility has changed
virtual void ps_onVisibilityChanged(bool visible);
void ps_onVisibilityChanged(bool visible);
private:
QWidget *m_titleBarWidgetEmpty = nullptr; //!< replacing default title bar
QWidget *m_titleBarWidgetOriginal = nullptr; //!< the original title bar
QMargins m_marginsWhenFloating; //!< Offsets when window is floating
QMargins m_marginsWhenFramelessFloating; //!< Offsets when window is frameless floating
QMargins m_marginsWhenDocked; //!< Offsets when window is docked
CManagedStatusBar m_statusBar; //!< Status bar when floating
QString m_windowTitleBackup; //!< original title, even if the widget title is deleted for layout purposes
@@ -171,6 +190,7 @@ namespace BlackGui
//! Init status bar
void initStatusBar();
};
} // namespace

View File

@@ -22,9 +22,7 @@ namespace BlackGui
{
CDockWidgetInfoBar::CDockWidgetInfoBar(QWidget *parent) : CDockWidget(parent)
{
this->setProperty("frameless", CGuiUtility::isMainWindowFrameless());
this->setMarginsWhenDocked(0, 0, 0, -1);
this->setWindowTitle("Info bar");
this->setWindowTitle("Info status bar");
this->setWindowIcon(CIcons::swift24());
this->ps_onStyleSheetsChanged();
}
@@ -37,6 +35,7 @@ namespace BlackGui
void CDockWidgetInfoBar::ps_onStyleSheetsChanged()
{
if (!this->objectName().isEmpty()) { this->setMarginsFromSettings(); }
QString st = CStyleSheetUtility::instance().style(CStyleSheetUtility::fileNameInfoBar());
this->setStyleSheet(st);
}

View File

@@ -9,7 +9,7 @@
#include "enableforframelesswindow.h"
#include "blackmisc/icons.h"
#include <QSizeGrip>
#include "blackmisc/blackmiscfreefunctions.h"
#include <QStatusBar>
#include <QPushButton>
@@ -28,6 +28,7 @@ namespace BlackGui
void CEnableForFramelessWindow::setMode(CEnableForFramelessWindow::WindowMode mode)
{
if (mode == this->m_windowMode) { return; }
// set the main window or dock widget
this->m_widget->setWindowFlags(modeToWindowFlags(mode));
this->setWindowAttributes(mode);
this->m_widget->show();
@@ -45,7 +46,9 @@ namespace BlackGui
// http://stackoverflow.com/questions/18316710/frameless-and-transparent-window-qt5
this->m_widget->setAttribute(Qt::WA_NoSystemBackground, frameless);
this->m_widget->setAttribute(Qt::WA_TranslucentBackground, frameless);
this->m_widget->setProperty("frameless", frameless);
// property selector will check on string, so I directly provide a string
this->m_widget->setProperty("frameless", BlackMisc::boolToTrueFalse(frameless));
}
bool CEnableForFramelessWindow::handleMouseMoveEvent(QMouseEvent *event)
@@ -72,12 +75,25 @@ namespace BlackGui
return false;
}
void CEnableForFramelessWindow::addFramelessSizeGrip(QStatusBar *statusBar)
void CEnableForFramelessWindow::addFramelessSizeGripToStatusBar(QStatusBar *statusBar)
{
if (!statusBar) { return; }
QSizeGrip *grip = new QSizeGrip(this->m_widget);
grip->setObjectName("sg_FramelessSizeGrip");
statusBar->addPermanentWidget(grip);
if (!this->m_framelessSizeGrip)
{
this->m_framelessSizeGrip = new QSizeGrip(this->m_widget);
this->m_framelessSizeGrip->setObjectName("sg_FramelessSizeGrip");
statusBar->addPermanentWidget(this->m_framelessSizeGrip);
}
else
{
this->m_framelessSizeGrip->show();
}
}
void CEnableForFramelessWindow::hideFramelessSizeGripInStatusBar()
{
if (!this->m_framelessSizeGrip) { return; }
this->m_framelessSizeGrip->hide();
}
QHBoxLayout *CEnableForFramelessWindow::addFramelessCloseButton(QMenuBar *menuBar)

View File

@@ -18,6 +18,7 @@
#include <QPushButton>
#include <QHBoxLayout>
#include <QMenuBar>
#include <QSizeGrip>
namespace BlackGui
{
@@ -42,7 +43,7 @@ namespace BlackGui
void setMode(WindowMode mode);
//! Framless
void setFrameless(bool frameless);
virtual void setFrameless(bool frameless);
//! Frameless?
bool isFrameless() const { return this->m_windowMode == WindowFrameless; }
@@ -55,7 +56,10 @@ namespace BlackGui
protected:
//! Resize grip handle
void addFramelessSizeGrip(QStatusBar *statusBar);
void addFramelessSizeGripToStatusBar(QStatusBar *statusBar);
//! Resize grip handle
void hideFramelessSizeGripInStatusBar();
//! Attributes
void setWindowAttributes(WindowMode mode);
@@ -71,6 +75,7 @@ namespace BlackGui
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
bool m_mainApplicationWindow = false; //!< is the main application window (only 1)
QWidget *m_widget = nullptr; //!< corresponding main window or dock widget
QSizeGrip *m_framelessSizeGrip = nullptr;
//! Mouse press, required for frameless window
bool handleMousePressEvent(QMouseEvent *event);

View File

@@ -499,6 +499,15 @@ namespace BlackGui
}
}
void CInfoArea::setMarginsWhenFramelessFloating(int left, int top, int right, int bottom)
{
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas)
{
//! Margins when window is floating
dw->setMarginsWhenFramelessFloating(left, top, right, bottom);
}
}
void CInfoArea::setMarginsWhenDocked(int left, int top, int right, int bottom)
{
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas)
@@ -534,24 +543,21 @@ namespace BlackGui
void CInfoArea::iniFileBasedSettings()
{
const QString section(this->objectName());
const QSettings *settings = CStyleSheetUtility::instance().iniFile();
if (settings)
if (settings && !section.isEmpty())
{
this->setMarginsWhenDocked(
settings->value("infoarea/margindocked.left").toInt(),
settings->value("infoarea/margindocked.top").toInt(),
settings->value("infoarea/margindocked.right").toInt(),
settings->value("infoarea/margindocked.bottom").toInt());
this->setMarginsWhenFloating(
settings->value("infoarea/marginfloating.left").toInt(),
settings->value("infoarea/marginfloating.top").toInt(),
settings->value("infoarea/marginfloating.right").toInt(),
settings->value("infoarea/marginfloating.bottom").toInt());
for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas)
{
//! Margins when window is floating
dw->setMarginsFromSettings(section);
}
}
else
{
// some defaut if not available
this->setMarginsWhenFloating(10, 10, 20, 20); // left, top, right, bottom
// some defaults if not available
this->setMarginsWhenFloating(10, 10, 10, 10); // left, top, right, bottom
this->setMarginsWhenFramelessFloating(5, 5, 5, 5); // left, top, right, bottom
this->setMarginsWhenDocked(1, 1, 1, 1); // top has no effect
}
}

View File

@@ -182,6 +182,9 @@ namespace BlackGui
//! Margins for the floating widgets
void setMarginsWhenFloating(int left, int top, int right, int bottom);
//! Margins for the floating widgets (when frameless)
void setMarginsWhenFramelessFloating(int left, int top, int right, int bottom);
//! Margins for the dockable widgets
void setMarginsWhenDocked(int left, int top, int right, int bottom);

View File

@@ -1,5 +1,12 @@
[infoarea]
; margins as used in infoarea.cpp
[alias]
; those are the component names and valid until an object name is set
; in most cases the object name is not yet known in the constructor
; this alias makes sense as long there is one object per component
CMainInfoAreaComponent = comp_MainInfoArea
CCockpitInfoAreaComponent = comp_CockpitInfoArea
CInfoBarStatusComponent = dw_dw_InfoBarStatus
[comp_MainInfoArea]
margindocked.left = 1
margindocked.right = 1
margindocked.top = 1
@@ -8,4 +15,41 @@ margindocked.bottom = 1
marginfloating.left = 5
marginfloating.right = 20
marginfloating.top = 5
marginfloating.bottom = 20
marginfloating.bottom = 40
marginfloating.frameless.left = 5
marginfloating.frameless.right = 5
marginfloating.frameless.top = 5
marginfloating.frameless.bottom = 5
[comp_CockpitInfoArea]
margindocked.left = 1
margindocked.right = 1
margindocked.top = 1
margindocked.bottom = 1
marginfloating.left = 5
marginfloating.right = 20
marginfloating.top = 5
marginfloating.bottom = 40
marginfloating.frameless.left = 5
marginfloating.frameless.right = 5
marginfloating.frameless.top = 5
marginfloating.frameless.bottom = 5
[dw_InfoBarStatus]
margindocked.left = 0
margindocked.right = 0
margindocked.top = 0
margindocked.bottom = 0
marginfloating.left = 0
marginfloating.right = 0
marginfloating.top = 0
marginfloating.bottom = 0
marginfloating.frameless.left = 0
marginfloating.frameless.right = 0
marginfloating.frameless.top = 0
marginfloating.frameless.bottom = 0

View File

@@ -1,14 +1,13 @@
/** style is applied to a CDockWidgetInfoBar **/
/** frameless is dynamic property**/
/** for frameless only use QDockWidget[frameless="true"] QFrame **/
QFrame {
margin: 0px;
padding-left: 6px;
padding-right: 6px;
padding-bottom: 0px;
}
/** frameless is dynamic property**/
/** for frameless only use QDockWidget[frameless="true"] QFrame **/
QDockWidget QFrame
{
padding-top: 0px;
background-color: darkslategray;
background-image: url(:/textures/icons/textures/texture-outer.jpg);
border: 0px;

View File

@@ -19,25 +19,29 @@ QMainWindow {
/** required when dock widget is floating **/
/** background-image not working on QDockWidget, so I use direct children **/
#sw_MainMiddle BlackGui--CDockWidgetInfoArea {
BlackGui--CDockWidgetInfoArea[frameless="false"] {
background-color: black;
}
BlackGui--CDockWidgetInfoArea[frameless="true"] {
background-color: white;
}
/** this is the first widget in the dock area **/
/** all dock widgets shall have this QWidget as container **/
#sw_MainMiddle BlackGui--CDockWidgetInfoArea > QWidget {
BlackGui--CDockWidgetInfoArea > QWidget {
background-color: black;
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}
/** the following QFrame, likely the component itself
#sw_MainMiddle BlackGui--CDockWidgetInfoArea > QWidget > QFrame {
border: 0px;
padding: 0px;
BlackGui--CDockWidgetInfoArea > QWidget > QFrame {
border: 0px;
padding: 0px;
}
/** fix the menu, which is overridden by the above QWidget **/
#sw_MainMiddle BlackGui--CDockWidgetInfoArea > QMenu {
BlackGui--CDockWidgetInfoArea > QMenu {
border: 1px solid darkslategray; /* reserve space for selection border */
background: lightgray;
color: black;
@@ -74,7 +78,10 @@ QAbstractScrollArea #pg_StatusPageConsole { background-color: black; }
/** dw_InfoBarStatus has its own style sheet **/
#fr_CentralFrameInside {
margin: 5px;
margin-right: 5px;
margin-left: 5px;
margin-top: 2px;
margin-bottom: 5px;
}
#gb_AtcStationsOnlineInfo {

View File

@@ -413,9 +413,14 @@ QString BlackMisc::boolToOnOff(bool v, bool i18n)
return v ? "on" : "off";
}
QString BlackMisc::boolToYesNo(bool v, bool i18n)
{
Q_UNUSED(i18n);
return v ? "yes" : "no";
}
QString BlackMisc::boolToTrueFalse(bool v, bool i18n)
{
Q_UNUSED(i18n);
return v ? "true" : "false";
}

View File

@@ -177,6 +177,9 @@ namespace BlackMisc
//! Bool to yes / no
QString boolToYesNo(bool v, bool i18n = false);
//! Bool to true / false
QString boolToTrueFalse(bool v, bool i18n = false);
//! Get local host name
const QString &localHostName();

View File

@@ -308,17 +308,6 @@ 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

@@ -58,7 +58,8 @@ public:
{
MainPageInfoArea = 0,
MainPageLogin = 1,
MainPageInternals = 2
MainPageInternals = 2,
MainPageInvisible = 3
};
//! Constructor
@@ -121,9 +122,6 @@ private:
//! Init GUI signals
void initGuiSignals();
//! Init the navigstion bars
void initNavigationBars();
//! Init dynamic menus
void initDynamicMenus();
@@ -240,13 +238,6 @@ 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

@@ -90,6 +90,9 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vl_CentralFrameInside">
<property name="leftMargin">
<number>0</number>
@@ -125,7 +128,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>3</number>
</property>
<widget class="QWidget" name="pg_MainInfoArea">
<layout class="QVBoxLayout" name="vl_MainInfoArea">
@@ -193,6 +196,13 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_InvisibleAreas">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="BlackGui::Components::CInvisibleInfoAreaComponent" name="comp_InvisibleInfoArea" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
@@ -305,8 +315,7 @@
<addaction name="menu_WindowFont"/>
<addaction name="menu_WindowMinimize"/>
<addaction name="menu_WindowToggleOnTop"/>
<addaction name="menu_NavigatorVertical"/>
<addaction name="menu_NavigatorHorizontal"/>
<addaction name="menu_WindowToggleNavigator"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menuWindow"/>
@@ -344,46 +353,34 @@
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Info status bar</string>
</property>
<attribute name="dockWidgetArea">
<number>4</number>
</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 class="QWidget" name="qw_InfoBarStatusInner">
<layout class="QVBoxLayout" name="vl_InfoBarStatusOuter">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="BlackGui::Components::CInfoBarStatusComponent" name="comp_InfoBarStatus" native="true"/>
</item>
</layout>
</widget>
</widget>
<action name="menu_TestLocationsEDDF">
<property name="text">
@@ -466,9 +463,9 @@
<string>Ctrl+W, Ctrl+T</string>
</property>
</action>
<action name="menu_NavigatorVertical">
<action name="menu_WindowToggleNavigator">
<property name="text">
<string>Vertical navigator</string>
<string>Navigator</string>
</property>
</action>
<action name="menu_NavigatorHorizontal">
@@ -516,9 +513,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CNavigatorDockWidget</class>
<extends>QDockWidget</extends>
<header>blackgui/components/navigatordockwidget.h</header>
<class>BlackGui::Components::CInvisibleInfoAreaComponent</class>
<extends>QWidget</extends>
<header>blackgui/components/invisibleinfoareacomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>

View File

@@ -38,6 +38,8 @@ using namespace BlackGui::Components;
*/
void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
{
// POST(!) GUI init
if (this->m_init) { return; }
this->setVisible(false); // hide all, so no flashing windows during init
@@ -64,7 +66,7 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
this->ui->vl_CentralWidgetOutside->addWidget(this->ui->sb_MainStatusBar, 0);
// grip
this->addFramelessSizeGrip(this->ui->sb_MainStatusBar);
this->addFramelessSizeGripToStatusBar(this->ui->sb_MainStatusBar);
}
// timers
@@ -74,13 +76,14 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
this->createRuntime(runtimeConfig, this);
CEnableForRuntime::setRuntimeForComponents(this->getRuntime(), this);
// info bar and status bar
this->m_statusBar.initStatusBar(this->ui->sb_MainStatusBar);
this->ui->dw_InfoBarStatus->allowStatusBar(false);
this->ui->dw_InfoBarStatus->setPreferredSizeWhenFloating(this->ui->dw_InfoBarStatus->size()); // set floating size
// wire GUI signals
this->initGuiSignals();
// status bar
this->ui->dw_InfoBarStatus->allowStatusBar(false);
this->m_statusBar.initStatusBar(this->ui->sb_MainStatusBar);
// signal / slots contexts / timers
connect(this->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &SwiftGuiStd::ps_onConnectionTerminated);
connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::ps_onConnectionStatusChanged);
@@ -105,9 +108,6 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
this->ps_setMainPageToInfoArea();
this->initDynamicMenus();
// navigation bars
// this->initNavigationBars();
// starting
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ApplicationGui, IContextApplication::ApplicationStarts);
@@ -128,15 +128,6 @@ 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
*/
@@ -170,9 +161,8 @@ 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_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);
connect(this->ui->menu_WindowToggleNavigator, &QAction::triggered, this->ui->comp_InvisibleInfoArea, &CInvisibleInfoAreaComponent::toggleNavigator);
connect(this->ui->menu_DebugMetaTypes, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
// command line / text messages
connect(this->ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::displayInInfoWindow, this->m_compInfoWindow, &CInfoWindowComponent::display);