mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #503, thanks to RW`s research, changed to non-QDockwidget navigator
* QDialog based navigator * Removed no longer used info area and navigator dock widget * fixed style sheet * added some space which can be used to drag navigator when frameless * callback when frameless is toggled Status: https://dev.vatsim-germany.org/issues/503#note-10
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
/* 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);
|
||||
|
||||
// remove widgets just required for GUI builder, but not needed for promoted component
|
||||
this->ui->comp_Navigator->layout()->removeWidget(this->ui->qw_NavigatorDummy);
|
||||
delete this->ui->qw_NavigatorDummy;
|
||||
this->ui->qw_NavigatorDummy = nullptr;
|
||||
|
||||
// init area
|
||||
this->initInfoArea();
|
||||
}
|
||||
|
||||
CInvisibleInfoAreaComponent::~CInvisibleInfoAreaComponent()
|
||||
{ }
|
||||
|
||||
QSize CInvisibleInfoAreaComponent::getPreferredSizeWhenFloating(int areaIndex) const
|
||||
{
|
||||
InfoArea area = static_cast<InfoArea>(areaIndex);
|
||||
switch (area)
|
||||
{
|
||||
case InfoAreaNavigator:
|
||||
{
|
||||
return this->ui->comp_Navigator->minimumSize();
|
||||
}
|
||||
default:
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown index for invisible info area");
|
||||
return QSize(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
const QPixmap &CInvisibleInfoAreaComponent::indexToPixmap(int areaIndex) const
|
||||
{
|
||||
Q_UNUSED(areaIndex);
|
||||
return CIcons::empty();
|
||||
}
|
||||
|
||||
CNavigatorDockWidget *CInvisibleInfoAreaComponent::getNavigatorComponent()
|
||||
{
|
||||
return this->ui->comp_Navigator;
|
||||
}
|
||||
|
||||
void CInvisibleInfoAreaComponent::toggleNavigator()
|
||||
{
|
||||
this->ui->comp_Navigator->toggleFloating();
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
@@ -1,66 +0,0 @@
|
||||
/* 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/blackguiexport.h"
|
||||
#include "blackgui/infoarea.h"
|
||||
#include "blackgui/components/navigatordockwidget.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui { class CInvisibleInfoAreaComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
//! Info area to carry info areas on visibile when floating
|
||||
class BLACKGUI_EXPORT CInvisibleInfoAreaComponent : public BlackGui::CInfoArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Info areas
|
||||
enum InfoArea
|
||||
{
|
||||
// index must match tab index!
|
||||
InfoAreaNavigator = 0
|
||||
};
|
||||
|
||||
//! 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;
|
||||
|
||||
//! Get navigator component
|
||||
BlackGui::Components::CNavigatorDockWidget *getNavigatorComponent();
|
||||
|
||||
public slots:
|
||||
//! Navigator floating
|
||||
void toggleNavigator();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CInvisibleInfoAreaComponent> ui;
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
#endif // guard
|
||||
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CInvisibleInfoAreaComponent</class>
|
||||
<widget class="QMainWindow" name="CInvisibleInfoAreaComponent">
|
||||
<property name="windowTitle">
|
||||
<string>Invisible info area</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="qw_InvisibleInfoArea">
|
||||
<layout class="QVBoxLayout" name="vl_InvisibleInfoAreaComponent">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="BlackGui::Components::CNavigatorDockWidget" name="comp_Navigator">
|
||||
<property name="features">
|
||||
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||
</property>
|
||||
<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_NavigatorDummy"/>
|
||||
</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>
|
||||
@@ -9,10 +9,8 @@
|
||||
|
||||
#include "navigatordialog.h"
|
||||
#include "ui_navigatordialog.h"
|
||||
#include "blackgui/infoarea.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QGridLayout>
|
||||
#include <QAction>
|
||||
@@ -24,10 +22,12 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
// If the dialog is a normal window, it stays open when the parent is minimized
|
||||
// (and the parent is null for the dialog). If the dialog is a tool winow it is always
|
||||
// minimized, regardless of dialog`s parent
|
||||
CNavigatorDialog::CNavigatorDialog(QWidget *parent) :
|
||||
QDialog(parent, Qt::Tool),
|
||||
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowTool, false, "NavigatorDialog", this),
|
||||
QDialog(parent, modeToWindowFlags(CEnableForFramelessWindow::WindowTool)),
|
||||
CEnableForFramelessWindow(CEnableForFramelessWindow::WindowTool, false, "navigatorFrameless", this),
|
||||
ui(new Ui::CNavigatorDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -64,7 +64,8 @@ namespace BlackGui
|
||||
this->ui->fr_NavigatorDialogInner->setLayout(gridLayout);
|
||||
int r = 0;
|
||||
int c = 0;
|
||||
for (const auto &action : actions())
|
||||
|
||||
for (const auto &action : this->actions())
|
||||
{
|
||||
QToolButton *tb = new QToolButton(this->ui->fr_NavigatorDialogInner);
|
||||
tb->setDefaultAction(action);
|
||||
@@ -79,7 +80,8 @@ namespace BlackGui
|
||||
|
||||
int w = 16 * gridLayout->columnCount();
|
||||
int h = 16 * gridLayout->rowCount();
|
||||
QSize min(w, h);
|
||||
this->m_currentColumns = gridLayout->columnCount();
|
||||
QSize min(w + 2, h + 2);
|
||||
this->ui->fr_NavigatorDialogInner->setMinimumSize(min);
|
||||
this->setMinimumSize(min);
|
||||
this->adjustSize();
|
||||
@@ -90,11 +92,17 @@ namespace BlackGui
|
||||
this->setFrameless(!this->isFrameless());
|
||||
}
|
||||
|
||||
void CNavigatorDialog::toggleNavigator()
|
||||
{
|
||||
this->setVisible(!this->isVisible());
|
||||
}
|
||||
|
||||
void CNavigatorDialog::ps_onStyleSheetsChanged()
|
||||
{
|
||||
const QString fn(CStyleSheetUtility::fileNameNavigator());
|
||||
const QString qss(CStyleSheetUtility::instance().style(fn));
|
||||
this->setStyleSheet(qss);
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
void CNavigatorDialog::mouseMoveEvent(QMouseEvent *event)
|
||||
@@ -107,6 +115,27 @@ namespace BlackGui
|
||||
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
||||
}
|
||||
|
||||
void CNavigatorDialog::changeEvent(QEvent *evt)
|
||||
{
|
||||
QEvent::Type t = evt->type();
|
||||
if (t == QEvent::WindowStateChange)
|
||||
{
|
||||
evt->ignore();
|
||||
hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
QDialog::changeEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
void CNavigatorDialog::windowFlagsChanged()
|
||||
{
|
||||
if (this->m_firstBuild) { return; }
|
||||
this->ps_onStyleSheetsChanged();
|
||||
this->buildNavigator(this->m_currentColumns);
|
||||
}
|
||||
|
||||
void CNavigatorDialog::ps_showContextMenu(const QPoint &pos)
|
||||
{
|
||||
QPoint globalPos = this->mapToGlobal(pos);
|
||||
@@ -129,8 +158,20 @@ namespace BlackGui
|
||||
|
||||
void CNavigatorDialog::insertOwnActions()
|
||||
{
|
||||
// add some space for frameless navigators where I can move the navigator
|
||||
QAction *a = new QAction(BlackMisc::CIcons::empty16(), "move navigator here", this);
|
||||
if (this->actions().isEmpty())
|
||||
{
|
||||
this->addAction(a);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->insertAction(this->actions().first(), a);
|
||||
}
|
||||
|
||||
// close
|
||||
QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), Qt::white, QSize(16, 16)));
|
||||
QAction *a = new QAction(i, "Close", this);
|
||||
a = new QAction(i, "Close", this);
|
||||
connect(a, &QAction::triggered, this, &CNavigatorDialog::close);
|
||||
this->addAction(a);
|
||||
}
|
||||
@@ -145,20 +186,19 @@ namespace BlackGui
|
||||
|
||||
void CNavigatorDialog::addToContextMenu(QMenu *contextMenu) const
|
||||
{
|
||||
QAction *a;
|
||||
a = contextMenu->addAction(CIcons::resize16(), "1 row", this, &CNavigatorDialog::ps_changeLayout);
|
||||
QAction *a = contextMenu->addAction(CIcons::resize16(), "1 row", this, SLOT(ps_changeLayout()));
|
||||
a->setData("1r");
|
||||
a = contextMenu->addAction(CIcons::resize16(), "2 rows", this, &CNavigatorDialog::ps_changeLayout);
|
||||
a = contextMenu->addAction(CIcons::resize16(), "2 rows", this, SLOT(ps_changeLayout()));
|
||||
a->setData("2r");
|
||||
a = contextMenu->addAction(CIcons::resize16(), "1 column", this, &CNavigatorDialog::ps_changeLayout);
|
||||
a = contextMenu->addAction(CIcons::resize16(), "1 column", this, SLOT(ps_changeLayout()));
|
||||
a->setData("1c");
|
||||
a = contextMenu->addAction(CIcons::resize16(), "2 columns", this, &CNavigatorDialog::ps_changeLayout);
|
||||
a = contextMenu->addAction(CIcons::resize16(), "2 columns", this, SLOT(ps_changeLayout()));
|
||||
a->setData("2c");
|
||||
|
||||
contextMenu->addSeparator();
|
||||
|
||||
QString frameLessActionText = this->isFrameless() ? "Normal window" : "Frameless";
|
||||
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), frameLessActionText, this, &CNavigatorDialog::toggleFrameless);
|
||||
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), frameLessActionText, this, SLOT(toggleFrameless()));
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforframelesswindow.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
#include <QMenu>
|
||||
@@ -24,13 +25,12 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
/*!
|
||||
* Navigators dialog
|
||||
* Navigator dialog
|
||||
*/
|
||||
class BLACKGUI_EXPORT CNavigatorDialog :
|
||||
public QDialog,
|
||||
public CEnableForFramelessWindow
|
||||
public QDialog,
|
||||
public CEnableForFramelessWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -44,9 +44,13 @@ namespace BlackGui
|
||||
//! Navigator
|
||||
void buildNavigator(int columns);
|
||||
|
||||
public slots:
|
||||
//! Toggle frameless mode
|
||||
void toggleFrameless();
|
||||
|
||||
//! Toggle visibility
|
||||
void toggleNavigator();
|
||||
|
||||
protected:
|
||||
//! Style sheet has changed
|
||||
void ps_onStyleSheetsChanged();
|
||||
@@ -57,6 +61,12 @@ namespace BlackGui
|
||||
//! \copydoc QMainWindow::mousePressEvent
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
|
||||
//! \copydoc QMainWindow::mousePressEvent
|
||||
virtual void changeEvent(QEvent *evt) override;
|
||||
|
||||
//! \copydoc CEnableForFramelessWindow::windowFlagsChanged
|
||||
virtual void windowFlagsChanged() override;
|
||||
|
||||
private slots:
|
||||
//! Context menu
|
||||
void ps_showContextMenu(const QPoint &pos);
|
||||
@@ -76,8 +86,8 @@ namespace BlackGui
|
||||
|
||||
QScopedPointer<Ui::CNavigatorDialog> ui;
|
||||
bool m_firstBuild = true;
|
||||
int m_currentColumns = 1;
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
<width>48</width>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
||||
@@ -1,163 +0,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.
|
||||
*/
|
||||
|
||||
#include "navigatordockwidget.h"
|
||||
#include "blackgui/infoarea.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "ui_navigatordockwidget.h"
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QGridLayout>
|
||||
#include <QAction>
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CNavigatorDockWidget::CNavigatorDockWidget(QWidget *parent) :
|
||||
CDockWidgetInfoArea(parent),
|
||||
ui(new Ui::CNavigatorDockWidget)
|
||||
{
|
||||
this->allowStatusBar(false);
|
||||
ui->setupUi(this);
|
||||
this->ps_onStyleSheetsChanged();
|
||||
}
|
||||
|
||||
CNavigatorDockWidget::~CNavigatorDockWidget()
|
||||
{ }
|
||||
|
||||
void CNavigatorDockWidget::addAction(QAction *action)
|
||||
{
|
||||
if (action)
|
||||
{
|
||||
this->m_actions.append(action);
|
||||
QToolButton *tb = new QToolButton(this->ui->fr_NavigatorDockWidgetInner);
|
||||
tb->setDefaultAction(action);
|
||||
tb->setObjectName(this->objectName().append(":").append(action->objectName()));
|
||||
this->m_widgets.append(tb);
|
||||
}
|
||||
}
|
||||
|
||||
void CNavigatorDockWidget::addActions(QList<QAction *> actions)
|
||||
{
|
||||
if (actions.isEmpty()) { return; }
|
||||
for (QAction *a : actions)
|
||||
{
|
||||
this->addAction(a);
|
||||
}
|
||||
}
|
||||
|
||||
void CNavigatorDockWidget::buildNavigator(int columns)
|
||||
{
|
||||
if (m_firstBuild)
|
||||
{
|
||||
m_firstBuild = false;
|
||||
this->insertOwnActions();
|
||||
}
|
||||
|
||||
// remove old layout
|
||||
CGuiUtility::deleteLayout(this->ui->fr_NavigatorDockWidgetInner->layout(), false);
|
||||
|
||||
// new layout
|
||||
QGridLayout *gridLayout = new QGridLayout(this->ui->fr_NavigatorDockWidgetInner);
|
||||
gridLayout->setObjectName("gl_CNavigatorDockWidget");
|
||||
gridLayout->setSpacing(0);
|
||||
gridLayout->setMargin(0);
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
this->ui->fr_NavigatorDockWidgetInner->setLayout(gridLayout);
|
||||
int r = 0;
|
||||
int c = 0;
|
||||
for (int i = 0; i < this->m_widgets.size(); i++)
|
||||
{
|
||||
gridLayout->addWidget(this->m_widgets[i], r, c++);
|
||||
this->m_widgets[i]->show();
|
||||
if (c < columns) { continue; }
|
||||
c = 0;
|
||||
r++;
|
||||
}
|
||||
|
||||
// set the real values
|
||||
c = gridLayout->columnCount();
|
||||
r = gridLayout->rowCount();
|
||||
QSize ws = this->setMinimumSizeForWidgets(r, c);
|
||||
this->resize(ws);
|
||||
|
||||
// see documentation, required as layout was changed
|
||||
// this requires setting widget again
|
||||
this->ui->fr_NavigatorDockWidgetInner->show();
|
||||
this->setWidget(this->ui->fr_NavigatorDockWidgetInner);
|
||||
}
|
||||
|
||||
void CNavigatorDockWidget::addToContextMenu(QMenu *contextMenu) const
|
||||
{
|
||||
QAction *a;
|
||||
a = contextMenu->addAction(CIcons::resize16(), "1 row", this, SLOT(ps_changeLayout()));
|
||||
a->setData("1r");
|
||||
a = contextMenu->addAction(CIcons::resize16(), "2 rows", this, SLOT(ps_changeLayout()));
|
||||
a->setData("2r");
|
||||
a = contextMenu->addAction(CIcons::resize16(), "1 column", this, SLOT(ps_changeLayout()));
|
||||
a->setData("1c");
|
||||
a = contextMenu->addAction(CIcons::resize16(), "2 columns", this, SLOT(ps_changeLayout()));
|
||||
a->setData("2c");
|
||||
contextMenu->addSeparator();
|
||||
CDockWidgetInfoArea::addToContextMenu(contextMenu);
|
||||
}
|
||||
|
||||
void CNavigatorDockWidget::ps_onStyleSheetsChanged()
|
||||
{
|
||||
const QString fn(CStyleSheetUtility::fileNameNavigator());
|
||||
const QString qss(CStyleSheetUtility::instance().style(fn));
|
||||
this->setStyleSheet(qss);
|
||||
}
|
||||
|
||||
void CNavigatorDockWidget::ps_changeLayout()
|
||||
{
|
||||
QAction *a = qobject_cast<QAction *>(QObject::sender());
|
||||
if (!a) { return; }
|
||||
QString v(a->data().toString());
|
||||
if (v == "1c") { buildNavigator(1);}
|
||||
else if (v == "2c") { buildNavigator(2);}
|
||||
else if (v == "1r") { buildNavigator(columnsForRows(1));}
|
||||
else if (v == "2r") { buildNavigator(columnsForRows(2));}
|
||||
}
|
||||
|
||||
void CNavigatorDockWidget::insertOwnActions()
|
||||
{
|
||||
QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), Qt::white, QSize(16, 16)));
|
||||
QAction *a = new QAction(i, "Close", this);
|
||||
connect(a, &QAction::triggered, this, &CNavigatorDockWidget::close);
|
||||
this->addAction(a);
|
||||
}
|
||||
|
||||
int CNavigatorDockWidget::columnsForRows(int rows)
|
||||
{
|
||||
Q_ASSERT_X(rows >= 0, Q_FUNC_INFO, "no rows");
|
||||
int items = this->m_widgets.size();
|
||||
int c = items / rows;
|
||||
return (c * rows) < items ? c + 1 : c;
|
||||
}
|
||||
|
||||
QSize CNavigatorDockWidget::setMinimumSizeForWidgets(int rows, int columns)
|
||||
{
|
||||
int w = 20 * columns;
|
||||
int h = 20 * rows;
|
||||
QSize min(w, h);
|
||||
this->ui->qw_NavigatorDockWidgetOuter->setMinimumSize(min);
|
||||
this->ui->fr_NavigatorDockWidgetInner->setMinimumSize(min);
|
||||
this->setMinimumSize(min);
|
||||
return min;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
@@ -1,80 +0,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 BLACKGUI_COMPONENTS_NAVIGATORDOCKWIDGET_H
|
||||
#define BLACKGUI_COMPONENTS_NAVIGATORDOCKWIDGET_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/dockwidgetinfoarea.h"
|
||||
#include <QDockWidget>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CNavigatorDockWidget; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
//! Dock widget for navigators
|
||||
class BLACKGUI_EXPORT CNavigatorDockWidget : public BlackGui::CDockWidgetInfoArea
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CNavigatorDockWidget(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CNavigatorDockWidget();
|
||||
|
||||
//! Add action as navigator item
|
||||
void addAction(QAction * action);
|
||||
|
||||
//! Add actions as navigator items
|
||||
void addActions(QList<QAction *> actions);
|
||||
|
||||
//! Navigator
|
||||
void buildNavigator(int columns);
|
||||
|
||||
protected:
|
||||
//! \copydoc CDockWidgetInfoArea::addToContextMenu
|
||||
virtual void addToContextMenu(QMenu *contextMenu) const override;
|
||||
|
||||
protected:
|
||||
//! \copydoc CDockWidget::ps_onStyleSheetsChanged
|
||||
virtual void ps_onStyleSheetsChanged() override;
|
||||
|
||||
private slots:
|
||||
//! Change the layout
|
||||
void ps_changeLayout();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CNavigatorDockWidget> ui;
|
||||
QList<QWidget *> m_widgets;
|
||||
QList<QAction *> m_actions;
|
||||
bool m_firstBuild = true;
|
||||
|
||||
//! Insert own actions
|
||||
void insertOwnActions();
|
||||
|
||||
//! How many columns for given rows
|
||||
int columnsForRows(int rows);
|
||||
|
||||
//! Set widgets to their minimum size
|
||||
QSize setMinimumSizeForWidgets(int rows, int columns);
|
||||
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
@@ -1,72 +0,0 @@
|
||||
<?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>60</width>
|
||||
<height>38</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>38</height>
|
||||
</size>
|
||||
</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_NavigatorDockWidgetOuter">
|
||||
<layout class="QVBoxLayout" name="vl_NavigatorDockWidgetOuter">
|
||||
<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>
|
||||
<widget class="QFrame" name="fr_NavigatorDockWidgetInner">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -55,7 +55,7 @@ namespace BlackGui
|
||||
//! Frameless?
|
||||
bool isFrameless() const { return this->m_windowMode == WindowFrameless; }
|
||||
|
||||
//! The main application
|
||||
//! Is main application, explicitly set
|
||||
bool isMainApplicationWindow() const { return m_mainApplicationWindow; }
|
||||
|
||||
//! Always on top?
|
||||
@@ -76,7 +76,7 @@ namespace BlackGui
|
||||
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
|
||||
WindowMode m_originalWindowMode = WindowNormal; //!< mode when initialized
|
||||
bool m_mainApplicationWindow = false; //!< is the main application window (only 1)
|
||||
QWidget *m_widget = nullptr; //!< corresponding main window or dock widget
|
||||
QWidget *m_widget = nullptr; //!< corresponding widget or dock widget
|
||||
QSizeGrip *m_framelessSizeGrip = nullptr; //!< size grip object
|
||||
QByteArray m_framelessPropertyName; //!< property name for frameless widgets
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
#fr_NavigatorDockWidgetInner[framelessDockWidget="true"] {
|
||||
#fr_NavigatorDialogInner[navigatorFrameless="true"] {
|
||||
margin: 0px;
|
||||
padding: 3px;
|
||||
border: 2px solid green;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#fr_NavigatorDockWidgetInner QToolButton {
|
||||
#fr_NavigatorDialogInner[navigatorFrameless="false"] {
|
||||
margin: 0px;
|
||||
padding: 3px;
|
||||
border: 0px;
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
#fr_NavigatorDialogInner QToolButton {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/audio/notificationsounds.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QMainWindow>
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackSound;
|
||||
@@ -88,7 +87,6 @@ void SwiftGuiStd::performGracefulShutdown()
|
||||
|
||||
// clean up GUI
|
||||
this->ui->comp_MainInfoArea->dockAllWidgets();
|
||||
this->ui->comp_InvisibleInfoArea->dockAllWidgets();
|
||||
|
||||
// allow some other parts to react
|
||||
QApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
@@ -203,7 +201,6 @@ void SwiftGuiStd::ps_displayStatusMessageInGui(const CStatusMessage &statusMessa
|
||||
|
||||
// main info areas
|
||||
this->ui->comp_MainInfoArea->displayStatusMessage(statusMessage);
|
||||
this->ui->comp_InvisibleInfoArea->displayStatusMessage(statusMessage);
|
||||
|
||||
// list
|
||||
this->ui->comp_MainInfoArea->getLogComponent()->appendStatusMessageToList(statusMessage);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
#include "blackgui/components/maininfoareacomponent.h"
|
||||
#include "blackgui/components/navigatordialog.h"
|
||||
#include "blackgui/transpondermodeselector.h"
|
||||
#include "blackgui/models/atcstationlistmodel.h"
|
||||
#include "blackgui/models/serverlistmodel.h"
|
||||
@@ -110,6 +111,8 @@ protected:
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::SwiftGuiStd> ui;
|
||||
// if I pass the parent, the dialog is always center over the parent
|
||||
QScopedPointer<BlackGui::Components::CNavigatorDialog> m_navigator{new BlackGui::Components::CNavigatorDialog()};
|
||||
bool m_init = false;
|
||||
BlackGui::CManagedStatusBar m_statusBar;
|
||||
BlackMisc::CLogSubscriber m_logSubscriber { this, &SwiftGuiStd::ps_displayStatusMessageInGui };
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pg_MainInfoArea">
|
||||
<layout class="QVBoxLayout" name="vl_MainInfoArea">
|
||||
@@ -192,28 +192,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pg_InvisibleAreas">
|
||||
<layout class="QVBoxLayout" name="vl_InvisibleArea">
|
||||
<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>
|
||||
<widget class="BlackGui::Components::CInvisibleInfoAreaComponent" name="comp_InvisibleInfoArea" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -243,7 +221,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>21</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -605,12 +583,6 @@
|
||||
<header>blackgui/components/internalscomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CInvisibleInfoAreaComponent</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>blackgui/components/invisibleinfoareacomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::COverlayMessagesFrame</class>
|
||||
<extends>QFrame</extends>
|
||||
|
||||
@@ -81,15 +81,12 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
|
||||
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);
|
||||
this->m_navigator->addAction(this->getToggleWindowVisibilityAction(this->m_navigator.data()));
|
||||
this->m_navigator->addActions(this->ui->comp_MainInfoArea->getInfoAreaToggleFloatingActions(this->m_navigator.data()));
|
||||
this->m_navigator->addAction(this->getWindowNormalAction(this->m_navigator.data()));
|
||||
this->m_navigator->addAction(this->getWindowMinimizeAction(this->m_navigator.data()));
|
||||
this->m_navigator->addAction(this->getToggleStayOnTopAction(this->m_navigator.data()));
|
||||
this->m_navigator->buildNavigator(1);
|
||||
|
||||
// wire GUI signals
|
||||
this->initGuiSignals();
|
||||
@@ -181,7 +178,7 @@ 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_WindowToggleNavigator, &QAction::triggered, this->ui->comp_InvisibleInfoArea, &CInvisibleInfoAreaComponent::toggleNavigator);
|
||||
connect(this->ui->menu_WindowToggleNavigator, &QAction::triggered, this->m_navigator.data(), &CNavigatorDialog::toggleNavigator);
|
||||
|
||||
connect(this->ui->menu_InternalsCompileInfo, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
|
||||
connect(this->ui->menu_InternalsEnvVars, &QAction::triggered, this, &SwiftGuiStd::ps_onMenuClicked);
|
||||
|
||||
Reference in New Issue
Block a user