mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 22:29:13 +08:00
refs #312, preparation for small navigation bars
This commit is contained in:
31
src/blackgui/components/navigatordockwidget.cpp
Normal file
31
src/blackgui/components/navigatordockwidget.cpp
Normal 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
|
||||
45
src/blackgui/components/navigatordockwidget.h
Normal file
45
src/blackgui/components/navigatordockwidget.h
Normal 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
|
||||
46
src/blackgui/components/navigatordockwidget.ui
Normal file
46
src/blackgui/components/navigatordockwidget.ui
Normal 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>
|
||||
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user