Compare commits
4 Commits
improved_t
...
openglwidg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e38212eade | ||
|
|
8eb200b9a9 | ||
|
|
5af55c1258 | ||
|
|
ae7d6cc655 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -9,7 +9,8 @@ ui_*
|
|||||||
Makefile
|
Makefile
|
||||||
*.dll
|
*.dll
|
||||||
*.a
|
*.a
|
||||||
build*
|
build-*
|
||||||
|
build_*
|
||||||
|
|
||||||
# IDEs
|
# IDEs
|
||||||
.idea
|
.idea
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
if (POLICY CMP0091)
|
if (POLICY CMP0091)
|
||||||
cmake_policy(SET CMP0091 NEW)
|
cmake_policy(SET CMP0091 NEW)
|
||||||
endif (POLICY CMP0091)
|
endif (POLICY CMP0091)
|
||||||
|
|||||||
@@ -64,6 +64,15 @@
|
|||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QQuickWidget>
|
#include <QQuickWidget>
|
||||||
|
|
||||||
|
#include <Inventor/Qt/SoQt.h>
|
||||||
|
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
|
||||||
|
#include <Inventor/nodes/SoSeparator.h>
|
||||||
|
#include <Inventor/nodes/SoCone.h>
|
||||||
|
#include <Inventor/nodes/SoBaseColor.h>
|
||||||
|
|
||||||
|
#include <Quarter/QuarterWidget.h>
|
||||||
|
#include <Quarter/Quarter.h>
|
||||||
|
#include <Quarter/eventhandlers/DragDropHandler.h>
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
#include <QRandomGenerator>
|
#include <QRandomGenerator>
|
||||||
@@ -75,17 +84,19 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "DockAreaTabBar.h"
|
|
||||||
#include "DockAreaTitleBar.h"
|
|
||||||
#include "DockAreaWidget.h"
|
|
||||||
#include "DockComponentsFactory.h"
|
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
#include "DockSplitter.h"
|
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
#include "DockAreaTitleBar.h"
|
||||||
|
#include "DockAreaTabBar.h"
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "ImageViewer.h"
|
#include "DockComponentsFactory.h"
|
||||||
#include "MyDockAreaTitleBar.h"
|
|
||||||
#include "StatusDialog.h"
|
#include "StatusDialog.h"
|
||||||
|
#include "DockSplitter.h"
|
||||||
|
#include "ImageViewer.h"
|
||||||
|
#include "glwidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a random number from 0 to highest - 1
|
* Returns a random number from 0 to highest - 1
|
||||||
@@ -146,7 +157,7 @@ public:
|
|||||||
using Super = ads::CDockComponentsFactory;
|
using Super = ads::CDockComponentsFactory;
|
||||||
ads::CDockAreaTitleBar* createDockAreaTitleBar(ads::CDockAreaWidget* DockArea) const override
|
ads::CDockAreaTitleBar* createDockAreaTitleBar(ads::CDockAreaWidget* DockArea) const override
|
||||||
{
|
{
|
||||||
auto TitleBar = new MyDockAreaTitleBar(DockArea);
|
auto TitleBar = new ads::CDockAreaTitleBar(DockArea);
|
||||||
auto CustomButton = new QToolButton(DockArea);
|
auto CustomButton = new QToolButton(DockArea);
|
||||||
CustomButton->setToolTip(QObject::tr("Help"));
|
CustomButton->setToolTip(QObject::tr("Help"));
|
||||||
CustomButton->setIcon(svgIcon(":/adsdemo/images/help_outline.svg"));
|
CustomButton->setIcon(svgIcon(":/adsdemo/images/help_outline.svg"));
|
||||||
@@ -657,6 +668,30 @@ void MainWindowPrivate::createActions()
|
|||||||
a = Menu->addAction("Pinned Image Viewer");
|
a = Menu->addAction("Pinned Image Viewer");
|
||||||
_this->connect(a, SIGNAL(triggered()), SLOT(createImageViewer()));
|
_this->connect(a, SIGNAL(triggered()), SLOT(createImageViewer()));
|
||||||
|
|
||||||
|
a = ui.toolBar->addAction("Create OpenGL Viewer");
|
||||||
|
a->setToolTip("Creates a opengl widget for testing." );
|
||||||
|
a->setIcon(svgIcon(":/adsdemo/images/deployed_code.svg"));
|
||||||
|
QObject::connect(a, &QAction::triggered, _this, &CMainWindow::createOpenGlWidget);
|
||||||
|
ui.menuTests->addAction(a);
|
||||||
|
|
||||||
|
a = ui.toolBar->addAction("Create Coin3D Viewer");
|
||||||
|
a->setToolTip("Creates a Coin3D SoQt examine viewer for testing." );
|
||||||
|
a->setIcon(svgIcon(":/adsdemo/images/category.svg"));
|
||||||
|
QObject::connect(a, &QAction::triggered, _this, &CMainWindow::createCoin3DViewer);
|
||||||
|
ui.menuTests->addAction(a);
|
||||||
|
|
||||||
|
a = ui.toolBar->addAction("Create Quarter Viewer");
|
||||||
|
a->setToolTip("Creates a Coin3D Quarter examine viewer for testing." );
|
||||||
|
a->setIcon(svgIcon(":/adsdemo/images/category.svg"));
|
||||||
|
QObject::connect(a, &QAction::triggered, _this, &CMainWindow::createQuarterViewer);
|
||||||
|
ui.menuTests->addAction(a);
|
||||||
|
|
||||||
|
a = ui.toolBar->addAction("Apply VS Style");
|
||||||
|
a->setToolTip("Applies a Visual Studio light style (visual_studio_light.css)." );
|
||||||
|
a->setIcon(svgIcon(":/adsdemo/images/color_lens.svg"));
|
||||||
|
QObject::connect(a, &QAction::triggered, _this, &CMainWindow::applyVsStyle);
|
||||||
|
ui.menuTests->addAction(a);
|
||||||
|
|
||||||
|
|
||||||
ui.menuTests->addSeparator();
|
ui.menuTests->addSeparator();
|
||||||
a = ui.menuTests->addAction("Show Status Dialog");
|
a = ui.menuTests->addAction("Show Status Dialog");
|
||||||
@@ -665,12 +700,6 @@ void MainWindowPrivate::createActions()
|
|||||||
a = ui.menuTests->addAction("Toggle Label 0 Window Title");
|
a = ui.menuTests->addAction("Toggle Label 0 Window Title");
|
||||||
_this->connect(a, SIGNAL(triggered()), SLOT(toggleDockWidgetWindowTitle()));
|
_this->connect(a, SIGNAL(triggered()), SLOT(toggleDockWidgetWindowTitle()));
|
||||||
ui.menuTests->addSeparator();
|
ui.menuTests->addSeparator();
|
||||||
|
|
||||||
a = ui.toolBar->addAction("Apply VS Style");
|
|
||||||
a->setToolTip("Applies a Visual Studio light style (visual_studio_light.css)." );
|
|
||||||
a->setIcon(svgIcon(":/adsdemo/images/color_lens.svg"));
|
|
||||||
QObject::connect(a, &QAction::triggered, _this, &CMainWindow::applyVsStyle);
|
|
||||||
ui.menuTests->addAction(a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -723,6 +752,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
|||||||
d->ui.setupUi(this);
|
d->ui.setupUi(this);
|
||||||
setWindowTitle(QApplication::instance()->applicationName());
|
setWindowTitle(QApplication::instance()->applicationName());
|
||||||
d->createActions();
|
d->createActions();
|
||||||
|
SoQt::init(this);
|
||||||
|
SoDB::init();
|
||||||
|
SIM::Coin3D::Quarter::Quarter::init();
|
||||||
|
|
||||||
// uncomment the following line if the tab close button should be
|
// uncomment the following line if the tab close button should be
|
||||||
// a QToolButton instead of a QPushButton
|
// a QToolButton instead of a QPushButton
|
||||||
@@ -1054,3 +1086,74 @@ void CMainWindow::lockWorkspace(bool Value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::createOpenGlWidget()
|
||||||
|
{
|
||||||
|
qDebug() << ":createOpenGlWidget ";
|
||||||
|
static int OpenGlWidgetCount = 0;
|
||||||
|
|
||||||
|
auto w = new GLWidget();
|
||||||
|
auto DockWidget = new ads::CDockWidget(QString("OpenGL Viewer %1").arg(OpenGlWidgetCount++));
|
||||||
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/deployed_code.svg"));
|
||||||
|
DockWidget->setWidget(w, ads:: CDockWidget::ForceNoScrollArea);
|
||||||
|
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::createCoin3DViewer()
|
||||||
|
{
|
||||||
|
qDebug() << ":createCoin3DViewer ";
|
||||||
|
static int Coin3DWidgetCount = 0;
|
||||||
|
static SoSeparator* Root;
|
||||||
|
if (!Coin3DWidgetCount)
|
||||||
|
{
|
||||||
|
Root = new SoSeparator();
|
||||||
|
Root->ref();
|
||||||
|
auto Cone = new SoCone();
|
||||||
|
Root->addChild(Cone);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Viewer = new SoQtExaminerViewer(this, nullptr, true, SoQtFullViewer::BUILD_ALL);
|
||||||
|
Viewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
|
||||||
|
Viewer->setAnimationEnabled(false);
|
||||||
|
Viewer->setFeedbackVisibility(true);
|
||||||
|
Viewer->setSampleBuffers(4);
|
||||||
|
Viewer->setSceneGraph(Root);
|
||||||
|
//d->Viewer->setBackgroundColor(toSbColor(QColor(38, 38, 38)));
|
||||||
|
auto DockWidget = new ads::CDockWidget(QString("Coin3D Viewer %1").arg(Coin3DWidgetCount++));
|
||||||
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/category.svg"));
|
||||||
|
DockWidget->setWidget(Viewer->getWidget(), ads:: CDockWidget::ForceNoScrollArea);
|
||||||
|
d->DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::createQuarterViewer()
|
||||||
|
{
|
||||||
|
qDebug() << ":createQuarterViewer ";
|
||||||
|
static int QuarterWidgetCount = 0;
|
||||||
|
static SoSeparator* Root;
|
||||||
|
if (!QuarterWidgetCount)
|
||||||
|
{
|
||||||
|
Root = new SoSeparator();
|
||||||
|
Root->ref();
|
||||||
|
SoBaseColor * col = new SoBaseColor;
|
||||||
|
col->rgb = SbColor(1, 1, 0);
|
||||||
|
Root->addChild(col);
|
||||||
|
Root->addChild(new SoCone);
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace SIM::Coin3D::Quarter;
|
||||||
|
auto Viewer = new QuarterWidget();
|
||||||
|
Viewer->setTransparencyType(QuarterWidget::SORTED_OBJECT_BLEND);
|
||||||
|
Viewer->setNavigationModeFile();
|
||||||
|
Viewer->setSceneGraph(Root);
|
||||||
|
//d->Viewer->setBackgroundColor(toSbColor(QColor(38, 38, 38)));
|
||||||
|
auto DockWidget = new ads::CDockWidget(QString("Quarter Viewer %1").arg(QuarterWidgetCount++));
|
||||||
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/category.svg"));
|
||||||
|
DockWidget->setWidget(Viewer, ads:: CDockWidget::ForceNoScrollArea);
|
||||||
|
d->DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ private slots:
|
|||||||
void applyVsStyle();
|
void applyVsStyle();
|
||||||
void createImageViewer();
|
void createImageViewer();
|
||||||
void lockWorkspace(bool Value);
|
void lockWorkspace(bool Value);
|
||||||
|
void createOpenGlWidget();
|
||||||
|
void createCoin3DViewer();
|
||||||
|
void createQuarterViewer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by fuga on 08 nov 2024.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef QTADS_MYDOCKAREATITLEBAR_H
|
|
||||||
#define QTADS_MYDOCKAREATITLEBAR_H
|
|
||||||
|
|
||||||
#include <DockAreaTitleBar.h>
|
|
||||||
|
|
||||||
class MyDockAreaTitleBar : public ads::CDockAreaTitleBar {
|
|
||||||
public:
|
|
||||||
explicit MyDockAreaTitleBar(ads::CDockAreaWidget* parent)
|
|
||||||
: CDockAreaTitleBar(parent)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QMenu* buildContextMenu(QMenu*) override
|
|
||||||
{
|
|
||||||
auto menu = ads::CDockAreaTitleBar::buildContextMenu(nullptr);
|
|
||||||
menu->addSeparator();
|
|
||||||
auto action = menu->addAction(tr("Format HardDrive"));
|
|
||||||
|
|
||||||
connect(action, &QAction::triggered, this, [this](){
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setText("No, just kidding");
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Abort);
|
|
||||||
msgBox.setDefaultButton(QMessageBox::Abort);
|
|
||||||
msgBox.exec();
|
|
||||||
});
|
|
||||||
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QTADS_MYDOCKAREATITLEBAR_H
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
ADS_OUT_ROOT = $${OUT_PWD}/..
|
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||||
|
|
||||||
|
|
||||||
TARGET = AdvancedDockingSystemDemo
|
TARGET = AdvancedDockingSystemDemo
|
||||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||||
QT += core gui widgets quick quickwidgets
|
QT += core gui widgets quick quickwidgets opengl
|
||||||
|
|
||||||
include(../ads.pri)
|
include(../ads.pri)
|
||||||
|
|
||||||
@@ -10,6 +11,8 @@ lessThan(QT_MAJOR_VERSION, 6) {
|
|||||||
win32 {
|
win32 {
|
||||||
QT += axcontainer
|
QT += axcontainer
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
QT += openglwidgets
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIG += c++14
|
CONFIG += c++14
|
||||||
@@ -26,14 +29,19 @@ HEADERS += \
|
|||||||
MainWindow.h \
|
MainWindow.h \
|
||||||
StatusDialog.h \
|
StatusDialog.h \
|
||||||
ImageViewer.h \
|
ImageViewer.h \
|
||||||
RenderWidget.h
|
RenderWidget.h \
|
||||||
|
glwidget.h \
|
||||||
|
logo.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
MainWindow.cpp \
|
MainWindow.cpp \
|
||||||
StatusDialog.cpp \
|
StatusDialog.cpp \
|
||||||
ImageViewer.cpp \
|
ImageViewer.cpp \
|
||||||
RenderWidget.cpp
|
RenderWidget.cpp \
|
||||||
|
glwidget.cpp \
|
||||||
|
logo.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
@@ -47,3 +55,24 @@ LIBS += -L$${ADS_OUT_ROOT}/lib
|
|||||||
|
|
||||||
INCLUDEPATH += ../src
|
INCLUDEPATH += ../src
|
||||||
DEPENDPATH += ../src
|
DEPENDPATH += ../src
|
||||||
|
|
||||||
|
|
||||||
|
DEFINES += COIN_NOT_DLL \
|
||||||
|
SOQT_NOT_DLL \
|
||||||
|
QUARTER_NOT_DLL
|
||||||
|
|
||||||
|
LIBS *= -lopengl32
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release){
|
||||||
|
LIBS *= -llibSoQtd \
|
||||||
|
-llibCoin-80d \
|
||||||
|
-lquarterd
|
||||||
|
}else{
|
||||||
|
LIBS *= -llibSoQt \
|
||||||
|
-llibCoin-80 \
|
||||||
|
-lquarter
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add your library search path for external libraries here that contain the
|
||||||
|
# coin3d libraries
|
||||||
|
#LIBS *= -LC:/CodingXP/mingw1120_64_qt6/usr/bin
|
||||||
|
|||||||
@@ -39,5 +39,7 @@
|
|||||||
<file>images/lock_outline.svg</file>
|
<file>images/lock_outline.svg</file>
|
||||||
<file>images/lock.svg</file>
|
<file>images/lock.svg</file>
|
||||||
<file>images/lock_open.svg</file>
|
<file>images/lock_open.svg</file>
|
||||||
|
<file>images/deployed_code.svg</file>
|
||||||
|
<file>images/category.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
280
demo/glwidget.cpp
Normal file
280
demo/glwidget.cpp
Normal file
@@ -0,0 +1,280 @@
|
|||||||
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
|
#include "glwidget.h"
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QOpenGLShaderProgram>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
bool GLWidget::m_transparent = false;
|
||||||
|
|
||||||
|
GLWidget::GLWidget(QWidget *parent)
|
||||||
|
: QOpenGLWidget(parent)
|
||||||
|
{
|
||||||
|
m_core = QSurfaceFormat::defaultFormat().profile() == QSurfaceFormat::CoreProfile;
|
||||||
|
// --transparent causes the clear color to be transparent. Therefore, on systems that
|
||||||
|
// support it, the widget will become transparent apart from the logo.
|
||||||
|
if (m_transparent) {
|
||||||
|
QSurfaceFormat fmt = format();
|
||||||
|
fmt.setAlphaBufferSize(8);
|
||||||
|
setFormat(fmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GLWidget::~GLWidget()
|
||||||
|
{
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize GLWidget::minimumSizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(50, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize GLWidget::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(400, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void qNormalizeAngle(int &angle)
|
||||||
|
{
|
||||||
|
while (angle < 0)
|
||||||
|
angle += 360 * 16;
|
||||||
|
while (angle > 360 * 16)
|
||||||
|
angle -= 360 * 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::setXRotation(int angle)
|
||||||
|
{
|
||||||
|
qNormalizeAngle(angle);
|
||||||
|
if (angle != m_xRot) {
|
||||||
|
m_xRot = angle;
|
||||||
|
emit xRotationChanged(angle);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::setYRotation(int angle)
|
||||||
|
{
|
||||||
|
qNormalizeAngle(angle);
|
||||||
|
if (angle != m_yRot) {
|
||||||
|
m_yRot = angle;
|
||||||
|
emit yRotationChanged(angle);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::setZRotation(int angle)
|
||||||
|
{
|
||||||
|
qNormalizeAngle(angle);
|
||||||
|
if (angle != m_zRot) {
|
||||||
|
m_zRot = angle;
|
||||||
|
emit zRotationChanged(angle);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::cleanup()
|
||||||
|
{
|
||||||
|
if (m_program == nullptr)
|
||||||
|
return;
|
||||||
|
makeCurrent();
|
||||||
|
m_logoVbo.destroy();
|
||||||
|
delete m_program;
|
||||||
|
m_program = nullptr;
|
||||||
|
doneCurrent();
|
||||||
|
QObject::disconnect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &GLWidget::cleanup);
|
||||||
|
m_HiddenOnCleanup = isHidden();
|
||||||
|
// Hiding here prevents the base class implementation to recreate
|
||||||
|
// the QOpenGlContext immediatelly allowing us to set the surface format again
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *vertexShaderSourceCore =
|
||||||
|
"#version 150\n"
|
||||||
|
"in vec4 vertex;\n"
|
||||||
|
"in vec3 normal;\n"
|
||||||
|
"out vec3 vert;\n"
|
||||||
|
"out vec3 vertNormal;\n"
|
||||||
|
"uniform mat4 projMatrix;\n"
|
||||||
|
"uniform mat4 mvMatrix;\n"
|
||||||
|
"uniform mat3 normalMatrix;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" vert = vertex.xyz;\n"
|
||||||
|
" vertNormal = normalMatrix * normal;\n"
|
||||||
|
" gl_Position = projMatrix * mvMatrix * vertex;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char *fragmentShaderSourceCore =
|
||||||
|
"#version 150\n"
|
||||||
|
"in highp vec3 vert;\n"
|
||||||
|
"in highp vec3 vertNormal;\n"
|
||||||
|
"out highp vec4 fragColor;\n"
|
||||||
|
"uniform highp vec3 lightPos;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" highp vec3 L = normalize(lightPos - vert);\n"
|
||||||
|
" highp float NL = max(dot(normalize(vertNormal), L), 0.0);\n"
|
||||||
|
" highp vec3 color = vec3(0.39, 1.0, 0.0);\n"
|
||||||
|
" highp vec3 col = clamp(color * 0.2 + color * 0.8 * NL, 0.0, 1.0);\n"
|
||||||
|
" fragColor = vec4(col, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char *vertexShaderSource =
|
||||||
|
"attribute vec4 vertex;\n"
|
||||||
|
"attribute vec3 normal;\n"
|
||||||
|
"varying vec3 vert;\n"
|
||||||
|
"varying vec3 vertNormal;\n"
|
||||||
|
"uniform mat4 projMatrix;\n"
|
||||||
|
"uniform mat4 mvMatrix;\n"
|
||||||
|
"uniform mat3 normalMatrix;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" vert = vertex.xyz;\n"
|
||||||
|
" vertNormal = normalMatrix * normal;\n"
|
||||||
|
" gl_Position = projMatrix * mvMatrix * vertex;\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
static const char *fragmentShaderSource =
|
||||||
|
"varying highp vec3 vert;\n"
|
||||||
|
"varying highp vec3 vertNormal;\n"
|
||||||
|
"uniform highp vec3 lightPos;\n"
|
||||||
|
"void main() {\n"
|
||||||
|
" highp vec3 L = normalize(lightPos - vert);\n"
|
||||||
|
" highp float NL = max(dot(normalize(vertNormal), L), 0.0);\n"
|
||||||
|
" highp vec3 color = vec3(0.39, 1.0, 0.0);\n"
|
||||||
|
" highp vec3 col = clamp(color * 0.2 + color * 0.8 * NL, 0.0, 1.0);\n"
|
||||||
|
" gl_FragColor = vec4(col, 1.0);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
|
void GLWidget::initializeGL()
|
||||||
|
{
|
||||||
|
// In this example the widget's corresponding top-level window can change
|
||||||
|
// several times during the widget's lifetime. Whenever this happens, the
|
||||||
|
// QOpenGLWidget's associated context is destroyed and a new one is created.
|
||||||
|
// Therefore we have to be prepared to clean up the resources on the
|
||||||
|
// aboutToBeDestroyed() signal, instead of the destructor. The emission of
|
||||||
|
// the signal will be followed by an invocation of initializeGL() where we
|
||||||
|
// can recreate all resources.
|
||||||
|
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &GLWidget::cleanup);
|
||||||
|
|
||||||
|
initializeOpenGLFunctions();
|
||||||
|
glClearColor(0, 0, 0, m_transparent ? 0 : 1);
|
||||||
|
|
||||||
|
m_program = new QOpenGLShaderProgram;
|
||||||
|
m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, m_core ? vertexShaderSourceCore : vertexShaderSource);
|
||||||
|
m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, m_core ? fragmentShaderSourceCore : fragmentShaderSource);
|
||||||
|
m_program->bindAttributeLocation("vertex", 0);
|
||||||
|
m_program->bindAttributeLocation("normal", 1);
|
||||||
|
m_program->link();
|
||||||
|
|
||||||
|
m_program->bind();
|
||||||
|
m_projMatrixLoc = m_program->uniformLocation("projMatrix");
|
||||||
|
m_mvMatrixLoc = m_program->uniformLocation("mvMatrix");
|
||||||
|
m_normalMatrixLoc = m_program->uniformLocation("normalMatrix");
|
||||||
|
m_lightPosLoc = m_program->uniformLocation("lightPos");
|
||||||
|
|
||||||
|
// Create a vertex array object. In OpenGL ES 2.0 and OpenGL 2.x
|
||||||
|
// implementations this is optional and support may not be present
|
||||||
|
// at all. Nonetheless the below code works in all cases and makes
|
||||||
|
// sure there is a VAO when one is needed.
|
||||||
|
m_vao.create();
|
||||||
|
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vao);
|
||||||
|
|
||||||
|
// Setup our vertex buffer object.
|
||||||
|
m_logoVbo.create();
|
||||||
|
m_logoVbo.bind();
|
||||||
|
m_logoVbo.allocate(m_logo.constData(), m_logo.count() * sizeof(GLfloat));
|
||||||
|
|
||||||
|
// Store the vertex attribute bindings for the program.
|
||||||
|
setupVertexAttribs();
|
||||||
|
|
||||||
|
// Our camera never changes in this example.
|
||||||
|
m_camera.setToIdentity();
|
||||||
|
m_camera.translate(0, 0, -1);
|
||||||
|
|
||||||
|
// Light position is fixed.
|
||||||
|
m_program->setUniformValue(m_lightPosLoc, QVector3D(0, 0, 70));
|
||||||
|
|
||||||
|
m_program->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::setupVertexAttribs()
|
||||||
|
{
|
||||||
|
m_logoVbo.bind();
|
||||||
|
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||||
|
f->glEnableVertexAttribArray(0);
|
||||||
|
f->glEnableVertexAttribArray(1);
|
||||||
|
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat),
|
||||||
|
nullptr);
|
||||||
|
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat),
|
||||||
|
reinterpret_cast<void *>(3 * sizeof(GLfloat)));
|
||||||
|
m_logoVbo.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::paintGL()
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
m_world.setToIdentity();
|
||||||
|
m_world.rotate(180.0f - (m_xRot / 16.0f), 1, 0, 0);
|
||||||
|
m_world.rotate(m_yRot / 16.0f, 0, 1, 0);
|
||||||
|
m_world.rotate(m_zRot / 16.0f, 0, 0, 1);
|
||||||
|
|
||||||
|
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vao);
|
||||||
|
m_program->bind();
|
||||||
|
m_program->setUniformValue(m_projMatrixLoc, m_proj);
|
||||||
|
m_program->setUniformValue(m_mvMatrixLoc, m_camera * m_world);
|
||||||
|
QMatrix3x3 normalMatrix = m_world.normalMatrix();
|
||||||
|
m_program->setUniformValue(m_normalMatrixLoc, normalMatrix);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, m_logo.vertexCount());
|
||||||
|
|
||||||
|
m_program->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::resizeGL(int w, int h)
|
||||||
|
{
|
||||||
|
m_proj.setToIdentity();
|
||||||
|
m_proj.perspective(45.0f, GLfloat(w) / h, 0.01f, 100.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
m_lastPos = event->position().toPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLWidget::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
int dx = event->position().toPoint().x() - m_lastPos.x();
|
||||||
|
int dy = event->position().toPoint().y() - m_lastPos.y();
|
||||||
|
|
||||||
|
if (event->buttons() & Qt::LeftButton) {
|
||||||
|
setXRotation(m_xRot + 8 * dy);
|
||||||
|
setYRotation(m_yRot + 8 * dx);
|
||||||
|
} else if (event->buttons() & Qt::RightButton) {
|
||||||
|
setXRotation(m_xRot + 8 * dy);
|
||||||
|
setZRotation(m_zRot + 8 * dx);
|
||||||
|
}
|
||||||
|
m_lastPos = event->position().toPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GLWidget::event(QEvent *event)
|
||||||
|
{
|
||||||
|
auto Result = QOpenGLWidget::event(event);
|
||||||
|
if (event->type() == QEvent::WindowChangeInternal)
|
||||||
|
{
|
||||||
|
qDebug() << "QEvent::WindowChangeInternal";
|
||||||
|
if (!context())
|
||||||
|
{
|
||||||
|
setFormat(QSurfaceFormat::defaultFormat());
|
||||||
|
if (!m_HiddenOnCleanup)
|
||||||
|
{
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
72
demo/glwidget.h
Normal file
72
demo/glwidget.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
|
#ifndef GLWIDGET_H
|
||||||
|
#define GLWIDGET_H
|
||||||
|
|
||||||
|
#include <QOpenGLWidget>
|
||||||
|
#include <QOpenGLFunctions>
|
||||||
|
#include <QOpenGLVertexArrayObject>
|
||||||
|
#include <QOpenGLBuffer>
|
||||||
|
#include <QMatrix4x4>
|
||||||
|
#include "logo.h"
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
|
||||||
|
|
||||||
|
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GLWidget(QWidget *parent = nullptr);
|
||||||
|
~GLWidget();
|
||||||
|
|
||||||
|
static bool isTransparent() { return m_transparent; }
|
||||||
|
static void setTransparent(bool t) { m_transparent = t; }
|
||||||
|
|
||||||
|
QSize minimumSizeHint() const override;
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setXRotation(int angle);
|
||||||
|
void setYRotation(int angle);
|
||||||
|
void setZRotation(int angle);
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void xRotationChanged(int angle);
|
||||||
|
void yRotationChanged(int angle);
|
||||||
|
void zRotationChanged(int angle);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initializeGL() override;
|
||||||
|
void paintGL() override;
|
||||||
|
void resizeGL(int width, int height) override;
|
||||||
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
virtual bool event(QEvent *event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupVertexAttribs();
|
||||||
|
|
||||||
|
bool m_core;
|
||||||
|
int m_xRot = 0;
|
||||||
|
int m_yRot = 0;
|
||||||
|
int m_zRot = 0;
|
||||||
|
QPoint m_lastPos;
|
||||||
|
Logo m_logo;
|
||||||
|
QOpenGLVertexArrayObject m_vao;
|
||||||
|
QOpenGLBuffer m_logoVbo;
|
||||||
|
QOpenGLShaderProgram *m_program = nullptr;
|
||||||
|
int m_projMatrixLoc = 0;
|
||||||
|
int m_mvMatrixLoc = 0;
|
||||||
|
int m_normalMatrixLoc = 0;
|
||||||
|
int m_lightPosLoc = 0;
|
||||||
|
QMatrix4x4 m_proj;
|
||||||
|
QMatrix4x4 m_camera;
|
||||||
|
QMatrix4x4 m_world;
|
||||||
|
static bool m_transparent;
|
||||||
|
bool m_HiddenOnCleanup = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
5
demo/images/category.svg
Normal file
5
demo/images/category.svg
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<desc>lock_outline icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<path d="m243.2 467.2 246.4-403.2 246.4 403.2zm492.8 492.8q-84 0-142.8-58.8t-58.8-142.8 58.8-142.8 142.8-58.8 142.8 58.8 58.8 142.8-58.8 142.8-142.8 58.8zm-649.6-22.4v-358.4h358.4v358.4zm649.6-67.2q47.04 0 79.52-32.48t32.48-79.52-32.48-79.52-79.52-32.48-79.52 32.48-32.48 79.52 32.48 79.52 79.52 32.48zm-560-22.4h179.2v-179.2h-179.2zm226.24-470.4h174.72l-87.36-141.12z" fill="#03b8e5" fill-opacity=".87843" stroke-width=".025"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 755 B |
5
demo/images/deployed_code.svg
Normal file
5
demo/images/deployed_code.svg
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<desc>lock_outline icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<path d="m467.2 844.64v-306.88l-268.8-155.68v306.88zm89.6 0 268.8-155.68v-306.88l-268.8 155.68zm-44.8-384.16 265.44-153.44-265.44-153.44-265.44 153.44zm-358.4 306.88q-21.28-12.32-33.04-32.48t-11.76-44.8v-356.16q0-24.64 11.76-44.8t33.04-32.48l313.6-180.32q21.28-12.32 44.8-12.32t44.8 12.32l313.6 180.32q21.28 12.32 33.04 32.48t11.76 44.8v356.16q0 24.64-11.76 44.8t-33.04 32.48l-313.6 180.32q-21.28 12.32-44.8 12.32t-44.8-12.32z" fill="#03b8e5" stroke-width=".025"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 791 B |
103
demo/logo.cpp
Normal file
103
demo/logo.cpp
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
|
#include "logo.h"
|
||||||
|
#include <qmath.h>
|
||||||
|
|
||||||
|
Logo::Logo()
|
||||||
|
{
|
||||||
|
m_data.resize(2500 * 6);
|
||||||
|
|
||||||
|
const GLfloat x1 = +0.06f;
|
||||||
|
const GLfloat y1 = -0.14f;
|
||||||
|
const GLfloat x2 = +0.14f;
|
||||||
|
const GLfloat y2 = -0.06f;
|
||||||
|
const GLfloat x3 = +0.08f;
|
||||||
|
const GLfloat y3 = +0.00f;
|
||||||
|
const GLfloat x4 = +0.30f;
|
||||||
|
const GLfloat y4 = +0.22f;
|
||||||
|
|
||||||
|
quad(x1, y1, x2, y2, y2, x2, y1, x1);
|
||||||
|
quad(x3, y3, x4, y4, y4, x4, y3, x3);
|
||||||
|
|
||||||
|
extrude(x1, y1, x2, y2);
|
||||||
|
extrude(x2, y2, y2, x2);
|
||||||
|
extrude(y2, x2, y1, x1);
|
||||||
|
extrude(y1, x1, x1, y1);
|
||||||
|
extrude(x3, y3, x4, y4);
|
||||||
|
extrude(x4, y4, y4, x4);
|
||||||
|
extrude(y4, x4, y3, x3);
|
||||||
|
|
||||||
|
const int NumSectors = 100;
|
||||||
|
|
||||||
|
for (int i = 0; i < NumSectors; ++i) {
|
||||||
|
GLfloat angle = (i * 2 * M_PI) / NumSectors;
|
||||||
|
GLfloat angleSin = qSin(angle);
|
||||||
|
GLfloat angleCos = qCos(angle);
|
||||||
|
const GLfloat x5 = 0.30f * angleSin;
|
||||||
|
const GLfloat y5 = 0.30f * angleCos;
|
||||||
|
const GLfloat x6 = 0.20f * angleSin;
|
||||||
|
const GLfloat y6 = 0.20f * angleCos;
|
||||||
|
|
||||||
|
angle = ((i + 1) * 2 * M_PI) / NumSectors;
|
||||||
|
angleSin = qSin(angle);
|
||||||
|
angleCos = qCos(angle);
|
||||||
|
const GLfloat x7 = 0.20f * angleSin;
|
||||||
|
const GLfloat y7 = 0.20f * angleCos;
|
||||||
|
const GLfloat x8 = 0.30f * angleSin;
|
||||||
|
const GLfloat y8 = 0.30f * angleCos;
|
||||||
|
|
||||||
|
quad(x5, y5, x6, y6, x7, y7, x8, y8);
|
||||||
|
|
||||||
|
extrude(x6, y6, x7, y7);
|
||||||
|
extrude(x8, y8, x5, y5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logo::add(const QVector3D &v, const QVector3D &n)
|
||||||
|
{
|
||||||
|
GLfloat *p = m_data.data() + m_count;
|
||||||
|
*p++ = v.x();
|
||||||
|
*p++ = v.y();
|
||||||
|
*p++ = v.z();
|
||||||
|
*p++ = n.x();
|
||||||
|
*p++ = n.y();
|
||||||
|
*p++ = n.z();
|
||||||
|
m_count += 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logo::quad(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4)
|
||||||
|
{
|
||||||
|
QVector3D n = QVector3D::normal(QVector3D(x4 - x1, y4 - y1, 0.0f), QVector3D(x2 - x1, y2 - y1, 0.0f));
|
||||||
|
|
||||||
|
add(QVector3D(x1, y1, -0.05f), n);
|
||||||
|
add(QVector3D(x4, y4, -0.05f), n);
|
||||||
|
add(QVector3D(x2, y2, -0.05f), n);
|
||||||
|
|
||||||
|
add(QVector3D(x3, y3, -0.05f), n);
|
||||||
|
add(QVector3D(x2, y2, -0.05f), n);
|
||||||
|
add(QVector3D(x4, y4, -0.05f), n);
|
||||||
|
|
||||||
|
n = QVector3D::normal(QVector3D(x1 - x4, y1 - y4, 0.0f), QVector3D(x2 - x4, y2 - y4, 0.0f));
|
||||||
|
|
||||||
|
add(QVector3D(x4, y4, 0.05f), n);
|
||||||
|
add(QVector3D(x1, y1, 0.05f), n);
|
||||||
|
add(QVector3D(x2, y2, 0.05f), n);
|
||||||
|
|
||||||
|
add(QVector3D(x2, y2, 0.05f), n);
|
||||||
|
add(QVector3D(x3, y3, 0.05f), n);
|
||||||
|
add(QVector3D(x4, y4, 0.05f), n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Logo::extrude(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
|
||||||
|
{
|
||||||
|
QVector3D n = QVector3D::normal(QVector3D(0.0f, 0.0f, -0.1f), QVector3D(x2 - x1, y2 - y1, 0.0f));
|
||||||
|
|
||||||
|
add(QVector3D(x1, y1, +0.05f), n);
|
||||||
|
add(QVector3D(x1, y1, -0.05f), n);
|
||||||
|
add(QVector3D(x2, y2, +0.05f), n);
|
||||||
|
|
||||||
|
add(QVector3D(x2, y2, -0.05f), n);
|
||||||
|
add(QVector3D(x2, y2, +0.05f), n);
|
||||||
|
add(QVector3D(x1, y1, -0.05f), n);
|
||||||
|
}
|
||||||
28
demo/logo.h
Normal file
28
demo/logo.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
|
#ifndef LOGO_H
|
||||||
|
#define LOGO_H
|
||||||
|
|
||||||
|
#include <qopengl.h>
|
||||||
|
#include <QList>
|
||||||
|
#include <QVector3D>
|
||||||
|
|
||||||
|
class Logo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Logo();
|
||||||
|
const GLfloat *constData() const { return m_data.constData(); }
|
||||||
|
int count() const { return m_count; }
|
||||||
|
int vertexCount() const { return m_count / 6; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void quad(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3, GLfloat x4, GLfloat y4);
|
||||||
|
void extrude(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
|
||||||
|
void add(const QVector3D &v, const QVector3D &n);
|
||||||
|
|
||||||
|
QList<GLfloat> m_data;
|
||||||
|
int m_count = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LOGO_H
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ int main(int argc, char *argv[])
|
|||||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
std::shared_ptr<int> b;
|
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
|
||||||
|
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setApplicationName("Advanced Docking System Demo");
|
a.setApplicationName("Advanced Docking System Demo");
|
||||||
a.setQuitOnLastWindowClosed(true);
|
a.setQuitOnLastWindowClosed(true);
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 269 KiB |
@@ -49,7 +49,6 @@
|
|||||||
- [`AutoHideCloseButtonCollapsesDock`](#autohideclosebuttoncollapsesdock)
|
- [`AutoHideCloseButtonCollapsesDock`](#autohideclosebuttoncollapsesdock)
|
||||||
- [`AutoHideHasCloseButton`](#autohidehasclosebutton)
|
- [`AutoHideHasCloseButton`](#autohidehasclosebutton)
|
||||||
- [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton)
|
- [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton)
|
||||||
- [`AutoHideOpenOnDragHover`](#autohideopenondraghover)
|
|
||||||
- [DockWidget Feature Flags](#dockwidget-feature-flags)
|
- [DockWidget Feature Flags](#dockwidget-feature-flags)
|
||||||
- [`DockWidgetClosable`](#dockwidgetclosable)
|
- [`DockWidgetClosable`](#dockwidgetclosable)
|
||||||
- [`DockWidgetMovable`](#dockwidgetmovable)
|
- [`DockWidgetMovable`](#dockwidgetmovable)
|
||||||
@@ -151,7 +150,7 @@ This ie enabled by default to minimize the size of the saved data.
|
|||||||
|
|
||||||
### `TabCloseButtonIsToolButton`
|
### `TabCloseButtonIsToolButton`
|
||||||
|
|
||||||
If enabled the tab close buttons will be `QToolButtons` instead of `QPushButtons` -
|
If enabled the tab close buttons will be `QToolButtons` instead of `QPushButtons` -
|
||||||
disabled by default. Normally the default configuration should be ok but if your
|
disabled by default. Normally the default configuration should be ok but if your
|
||||||
application requires `QToolButtons` instead of `QPushButtons` for styling reasons
|
application requires `QToolButtons` instead of `QPushButtons` for styling reasons
|
||||||
or for any other reasons, then you can enable this flag.
|
or for any other reasons, then you can enable this flag.
|
||||||
@@ -182,7 +181,7 @@ constant, that means, if enabled, the tabs need more space.
|
|||||||
|
|
||||||
### `DragPreviewIsDynamic`
|
### `DragPreviewIsDynamic`
|
||||||
|
|
||||||
If non-opaque undocking is enabled, this flag defines the behavior of the drag
|
If non-opaque undocking is enabled, this flag defines the behavior of the drag
|
||||||
preview window. If this flag is enabled, then it will give the user the
|
preview window. If this flag is enabled, then it will give the user the
|
||||||
impression, that the floating drag preview is dynamically adjusted to the drop
|
impression, that the floating drag preview is dynamically adjusted to the drop
|
||||||
area. In order to give the perfect impression, you should disable the flags
|
area. In order to give the perfect impression, you should disable the flags
|
||||||
@@ -198,7 +197,7 @@ CDockManager::setConfigFlag(CDockManager::DragPreviewHasWindowFrame, false);
|
|||||||
|
|
||||||
### `DragPreviewShowsContentPixmap`
|
### `DragPreviewShowsContentPixmap`
|
||||||
|
|
||||||
If non-opaque undocking is enabled, the created drag preview window shows a
|
If non-opaque undocking is enabled, the created drag preview window shows a
|
||||||
copy of the content of the dock widget / dock are that is dragged, if this
|
copy of the content of the dock widget / dock are that is dragged, if this
|
||||||
flag is enabled (default).
|
flag is enabled (default).
|
||||||
|
|
||||||
@@ -211,7 +210,7 @@ like window without any content.
|
|||||||
|
|
||||||
### `DragPreviewHasWindowFrame`
|
### `DragPreviewHasWindowFrame`
|
||||||
|
|
||||||
If non-opaque undocking is enabled, then this flag configures if the drag
|
If non-opaque undocking is enabled, then this flag configures if the drag
|
||||||
preview is frameless (default) or looks like a real window. If it is enabled,
|
preview is frameless (default) or looks like a real window. If it is enabled,
|
||||||
then the drag preview is a transparent window with a system window frame.
|
then the drag preview is a transparent window with a system window frame.
|
||||||
|
|
||||||
@@ -379,7 +378,7 @@ ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar
|
|||||||
|
|
||||||
If you have a content widget that does not support focussing for some reason
|
If you have a content widget that does not support focussing for some reason
|
||||||
(like `QVTKOpenGLStereoWidget` from the [VTK library](https://github.com/Kitware/VTK)),
|
(like `QVTKOpenGLStereoWidget` from the [VTK library](https://github.com/Kitware/VTK)),
|
||||||
then you can manually switch the focus by reacting on mouse events. The
|
then you can manually switch the focus by reacting on mouse events. The
|
||||||
following code shows, how to install en event filter on the `QVTKOpenGLStereoWidget`
|
following code shows, how to install en event filter on the `QVTKOpenGLStereoWidget`
|
||||||
to properly switch the focus on `QEvent::MouseButtonPress`:
|
to properly switch the focus on `QEvent::MouseButtonPress`:
|
||||||
|
|
||||||
@@ -423,7 +422,7 @@ bool CMainWindow::eventFilter(QObject *watched, QEvent *event)
|
|||||||
### `EqualSplitOnInsertion`
|
### `EqualSplitOnInsertion`
|
||||||
|
|
||||||
This flag configures how the space is distributed if a new dock widget is
|
This flag configures how the space is distributed if a new dock widget is
|
||||||
inserted into an existing dock area. The flag is disabled by default. If 3
|
inserted into an existing dock area. The flag is disabled by default. If 3
|
||||||
dock widgets are inserted with the following code
|
dock widgets are inserted with the following code
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
@@ -434,7 +433,7 @@ then this is the result, if the flag is disabled:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
If the flag is enabled, then the space is equally distributed to all widgets
|
If the flag is enabled, then the space is equally distributed to all widgets
|
||||||
in a splitter:
|
in a splitter:
|
||||||
|
|
||||||

|

|
||||||
@@ -502,7 +501,7 @@ for active tabs. Inactive tabs only show their icon:
|
|||||||
|
|
||||||
The Advanced Docking System supports "Auto-Hide" functionality for **all**
|
The Advanced Docking System supports "Auto-Hide" functionality for **all**
|
||||||
dock containers. The "Auto Hide" feature allows to display more information
|
dock containers. The "Auto Hide" feature allows to display more information
|
||||||
using less screen space by hiding or showing windows pinned to one of the
|
using less screen space by hiding or showing windows pinned to one of the
|
||||||
four dock container borders.
|
four dock container borders.
|
||||||
|
|
||||||
Enabling this feature adds a button with a pin icon to each dock area.
|
Enabling this feature adds a button with a pin icon to each dock area.
|
||||||
@@ -564,7 +563,7 @@ That means, you can drag them to a different border or sidebar:
|
|||||||
|
|
||||||
### Auto-Hide Tab Sorting
|
### Auto-Hide Tab Sorting
|
||||||
|
|
||||||
You can drag Auto-Hide tabs to a new position in the current sidebar
|
You can drag Auto-Hide tabs to a new position in the current sidebar
|
||||||
to sort them:
|
to sort them:
|
||||||
|
|
||||||

|

|
||||||
@@ -633,7 +632,7 @@ the other Auto-Hide flags will be evaluated.
|
|||||||
|
|
||||||
### `DockAreaHasAutoHideButton`
|
### `DockAreaHasAutoHideButton`
|
||||||
|
|
||||||
If this flag is set (default), then each dock area has a pin button in the title
|
If this flag is set (default), then each dock area has a pin button in the title
|
||||||
bar to toggle Auto-Hide state.
|
bar to toggle Auto-Hide state.
|
||||||
|
|
||||||

|

|
||||||
@@ -677,7 +676,7 @@ works if this feature is enabled.
|
|||||||
Some users don't understand the distinction between closing an auto hide dock and
|
Some users don't understand the distinction between closing an auto hide dock and
|
||||||
collapsing an auto hide dock. This may lead to situations where they press the
|
collapsing an auto hide dock. This may lead to situations where they press the
|
||||||
close button (losing the side tab widget) instead of simply clicking outside
|
close button (losing the side tab widget) instead of simply clicking outside
|
||||||
the auto hide dock (collapsing the dock).
|
the auto hide dock (collapsing the dock).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -705,15 +704,6 @@ If this flag is set (disabled by default), then each auto hide widget has a mini
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
### `AutoHideOpenOnDragHover`
|
|
||||||
|
|
||||||
If this flag is set (disabled by default), then holding a dragging cursor hover an auto-hide collapsed dock's tab will open said dock:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Said dock must be set to accept drops to hide when cursor leaves its scope. See `AutoHideDragNDropExample` for more details.
|
|
||||||
|
|
||||||
## DockWidget Feature Flags
|
## DockWidget Feature Flags
|
||||||
|
|
||||||
### `DockWidgetClosable`
|
### `DockWidgetClosable`
|
||||||
|
|||||||
@@ -6,6 +6,5 @@ add_subdirectory(sidebar)
|
|||||||
add_subdirectory(deleteonclose)
|
add_subdirectory(deleteonclose)
|
||||||
add_subdirectory(centralwidget)
|
add_subdirectory(centralwidget)
|
||||||
add_subdirectory(autohide)
|
add_subdirectory(autohide)
|
||||||
add_subdirectory(autohidedragndrop)
|
|
||||||
add_subdirectory(emptydockarea)
|
add_subdirectory(emptydockarea)
|
||||||
add_subdirectory(dockindock)
|
add_subdirectory(dockindock)
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
|
||||||
project(ads_example_autohide_dragndrop VERSION ${VERSION_SHORT})
|
|
||||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
|
||||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
add_executable(AutoHideDragNDropExample WIN32
|
|
||||||
main.cpp
|
|
||||||
mainwindow.cpp
|
|
||||||
mainwindow.ui
|
|
||||||
droppableitem.cpp
|
|
||||||
)
|
|
||||||
target_include_directories(AutoHideDragNDropExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
|
||||||
target_link_libraries(AutoHideDragNDropExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
|
||||||
target_link_libraries(AutoHideDragNDropExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
|
||||||
Qt${QT_VERSION_MAJOR}::Gui
|
|
||||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
|
||||||
set_target_properties(AutoHideDragNDropExample PROPERTIES
|
|
||||||
AUTOMOC ON
|
|
||||||
AUTORCC ON
|
|
||||||
AUTOUIC ON
|
|
||||||
CXX_STANDARD 14
|
|
||||||
CXX_STANDARD_REQUIRED ON
|
|
||||||
CXX_EXTENSIONS OFF
|
|
||||||
VERSION ${VERSION_SHORT}
|
|
||||||
EXPORT_NAME "Qt Advanced Docking System Auto Hide With Drag N Drop Example"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
|
|
||||||
)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
ADS_OUT_ROOT = $${OUT_PWD}/../..
|
|
||||||
|
|
||||||
QT += core gui widgets
|
|
||||||
|
|
||||||
TARGET = AutoHideDragNDropExample
|
|
||||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
|
||||||
TEMPLATE = app
|
|
||||||
CONFIG += c++14
|
|
||||||
CONFIG += debug_and_release
|
|
||||||
adsBuildStatic {
|
|
||||||
DEFINES += ADS_STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
|
||||||
# any Qt feature that has been marked deprecated (the exact warnings
|
|
||||||
# depend on your compiler). Please consult the documentation of the
|
|
||||||
# deprecated API in order to know how to port your code away from it.
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
main.cpp \
|
|
||||||
mainwindow.cpp \
|
|
||||||
droppableitem.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
mainwindow.h \
|
|
||||||
droppableitem.h
|
|
||||||
|
|
||||||
FORMS += \
|
|
||||||
mainwindow.ui
|
|
||||||
|
|
||||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
|
||||||
include(../../ads.pri)
|
|
||||||
INCLUDEPATH += ../../src
|
|
||||||
DEPENDPATH += ../../src
|
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#include "droppableitem.h"
|
|
||||||
|
|
||||||
#include <QDragEnterEvent>
|
|
||||||
#include <QDragLeaveEvent>
|
|
||||||
#include <QDropEvent>
|
|
||||||
#include <QMimeData>
|
|
||||||
#include <qsizepolicy.h>
|
|
||||||
|
|
||||||
DroppableItem::DroppableItem(const QString& text, QWidget* parent)
|
|
||||||
: QPushButton(text, parent)
|
|
||||||
{
|
|
||||||
setAcceptDrops(true);
|
|
||||||
setSizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DroppableItem::dragEnterEvent(QDragEnterEvent* event)
|
|
||||||
{
|
|
||||||
if (event->mimeData()->hasText())
|
|
||||||
{
|
|
||||||
event->acceptProposedAction();
|
|
||||||
setCursor(Qt::DragMoveCursor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DroppableItem::dragLeaveEvent(QDragLeaveEvent* event)
|
|
||||||
{
|
|
||||||
Q_UNUSED(event);
|
|
||||||
unsetCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DroppableItem::dropEvent(QDropEvent* event)
|
|
||||||
{
|
|
||||||
if (event->mimeData()->hasText())
|
|
||||||
{
|
|
||||||
event->acceptProposedAction();
|
|
||||||
setText(event->mimeData()->text());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#include <QObject>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
class QDragEnterEvent;
|
|
||||||
class QDragLeaveEvent;
|
|
||||||
class QDropEvent;
|
|
||||||
|
|
||||||
class DroppableItem : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DroppableItem(const QString& text = QString(), QWidget* parent = nullptr);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
||||||
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
|
||||||
void dropEvent(QDropEvent* event) override;
|
|
||||||
};
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#include <mainwindow.h>
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
QApplication a(argc, argv);
|
|
||||||
CMainWindow w;
|
|
||||||
w.show();
|
|
||||||
return a.exec();
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
from PyQt5 import uic
|
|
||||||
from PyQt5.QtCore import Qt, QTimer, QDir, QSignalBlocker
|
|
||||||
from PyQt5.QtGui import QCloseEvent, QIcon
|
|
||||||
from PyQt5.QtWidgets import (QApplication, QLabel, QCalendarWidget, QFrame, QTreeView,
|
|
||||||
QTableWidget, QFileSystemModel, QPlainTextEdit, QToolBar,
|
|
||||||
QWidgetAction, QComboBox, QAction, QSizePolicy, QInputDialog)
|
|
||||||
|
|
||||||
import PyQtAds as QtAds
|
|
||||||
|
|
||||||
UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui')
|
|
||||||
MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE)
|
|
||||||
|
|
||||||
class MainWindow(MainWindowUI, MainWindowBase):
|
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
|
||||||
super().__init__(parent)
|
|
||||||
|
|
||||||
self.setupUi(self)
|
|
||||||
|
|
||||||
QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.OpaqueSplitterResize, True)
|
|
||||||
QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.XmlCompressionEnabled, False)
|
|
||||||
QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.FocusHighlighting, True)
|
|
||||||
QtAds.CDockManager.setAutoHideConfigFlag(QtAds.CDockManager.AutoHideOpenOnDragHover, True);
|
|
||||||
self.dock_manager = QtAds.CDockManager(self)
|
|
||||||
|
|
||||||
# Set central widget
|
|
||||||
text_edit = QPlainTextEdit()
|
|
||||||
text_edit.setPlaceholderText("This is the central editor. Enter your text here.")
|
|
||||||
central_dock_widget = QtAds.CDockWidget("CentralWidget")
|
|
||||||
central_dock_widget.setWidget(text_edit)
|
|
||||||
central_dock_area = self.dock_manager.setCentralWidget(central_dock_widget)
|
|
||||||
central_dock_area.setAllowedAreas(QtAds.DockWidgetArea.OuterDockAreas)
|
|
||||||
|
|
||||||
|
|
||||||
droppable_item = DroppableItem("Drop text here.")
|
|
||||||
drop_dock_widget = QtAds.CDockWidget("Tab")
|
|
||||||
drop_dock_widget.setWidget(droppable_item)
|
|
||||||
drop_dock_widget.setMinimumSizeHintMode(QtAds.CDockWidget.MinimumSizeHintFromDockWidget)
|
|
||||||
drop_dock_widget.setMinimumSize(200, 150)
|
|
||||||
drop_dock_widget.setAcceptDrops(True)
|
|
||||||
drop_area = self.dock_manager.addDockWidget(QtAds.DockWidgetArea.LeftDockWidgetArea, drop_dock_widget)
|
|
||||||
drop_area.setAcceptDrops(True)
|
|
||||||
self.menuView.addAction(drop_dock_widget.toggleViewAction())
|
|
||||||
|
|
||||||
self.create_perspective_ui()
|
|
||||||
|
|
||||||
def create_perspective_ui(self):
|
|
||||||
save_perspective_action = QAction("Create Perspective", self)
|
|
||||||
save_perspective_action.triggered.connect(self.save_perspective)
|
|
||||||
perspective_list_action = QWidgetAction(self)
|
|
||||||
self.perspective_combobox = QComboBox(self)
|
|
||||||
self.perspective_combobox.setSizeAdjustPolicy(QComboBox.AdjustToContents)
|
|
||||||
self.perspective_combobox.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
|
||||||
self.perspective_combobox.activated[str].connect(self.dock_manager.openPerspective)
|
|
||||||
perspective_list_action.setDefaultWidget(self.perspective_combobox)
|
|
||||||
self.toolBar.addSeparator()
|
|
||||||
self.toolBar.addAction(perspective_list_action)
|
|
||||||
self.toolBar.addAction(save_perspective_action)
|
|
||||||
|
|
||||||
def save_perspective(self):
|
|
||||||
perspective_name, ok = QInputDialog.getText(self, "Save Perspective", "Enter Unique name:")
|
|
||||||
if not ok or not perspective_name:
|
|
||||||
return
|
|
||||||
|
|
||||||
self.dock_manager.addPerspective(perspective_name)
|
|
||||||
blocker = QSignalBlocker(self.perspective_combobox)
|
|
||||||
self.perspective_combobox.clear()
|
|
||||||
self.perspective_combobox.addItems(self.dock_manager.perspectiveNames())
|
|
||||||
self.perspective_combobox.setCurrentText(perspective_name)
|
|
||||||
|
|
||||||
def closeEvent(self, event: QCloseEvent):
|
|
||||||
self.dock_manager.deleteLater()
|
|
||||||
super().closeEvent(event)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app = QApplication(sys.argv)
|
|
||||||
|
|
||||||
w = MainWindow()
|
|
||||||
w.show()
|
|
||||||
app.exec_()
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
#include "droppableitem.h"
|
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
|
||||||
|
|
||||||
#include <QWidgetAction>
|
|
||||||
#include <QFileSystemModel>
|
|
||||||
#include <QTableWidget>
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QToolBar>
|
|
||||||
|
|
||||||
#include "AutoHideDockContainer.h"
|
|
||||||
#include "DockAreaWidget.h"
|
|
||||||
#include "DockAreaTitleBar.h"
|
|
||||||
|
|
||||||
using namespace ads;
|
|
||||||
|
|
||||||
CMainWindow::CMainWindow(QWidget *parent)
|
|
||||||
: QMainWindow(parent)
|
|
||||||
, ui(new Ui::CMainWindow)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
|
||||||
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
|
||||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
|
||||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
|
||||||
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover, true);
|
|
||||||
CDockManager::setConfigParam(CDockManager::AutoHideOpenOnDragHoverDelay_ms, 500);
|
|
||||||
DockManager = new CDockManager(this);
|
|
||||||
|
|
||||||
// Set central widget
|
|
||||||
QPlainTextEdit* w = new QPlainTextEdit();
|
|
||||||
w->setPlaceholderText("This is the central editor. Enter your text here.");
|
|
||||||
CDockWidget* CentralDockWidget = new CDockWidget("CentralWidget");
|
|
||||||
CentralDockWidget->setWidget(w);
|
|
||||||
auto* CentralDockArea = DockManager->setCentralWidget(CentralDockWidget);
|
|
||||||
CentralDockArea->setAllowedAreas(DockWidgetArea::OuterDockAreas);
|
|
||||||
|
|
||||||
{
|
|
||||||
DroppableItem* droppableItem = new DroppableItem("Drop text here.");
|
|
||||||
CDockWidget* dropDockWidget = new CDockWidget("Tab 1");
|
|
||||||
dropDockWidget->setWidget(droppableItem);
|
|
||||||
dropDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
|
||||||
dropDockWidget->setMinimumSize(200,150);
|
|
||||||
dropDockWidget->setAcceptDrops(true);
|
|
||||||
const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::SideBarLeft, dropDockWidget);
|
|
||||||
autoHideContainer->setSize(480);
|
|
||||||
autoHideContainer->setAcceptDrops(true);
|
|
||||||
ui->menuView->addAction(dropDockWidget->toggleViewAction());
|
|
||||||
}
|
|
||||||
{
|
|
||||||
DroppableItem* droppableItem = new DroppableItem("Drop text here.");
|
|
||||||
CDockWidget* dropDockWidget = new CDockWidget("Tab 2");
|
|
||||||
dropDockWidget->setWidget(droppableItem);
|
|
||||||
dropDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
|
||||||
dropDockWidget->setMinimumSize(200,150);
|
|
||||||
dropDockWidget->setAcceptDrops(true);
|
|
||||||
const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::SideBarRight, dropDockWidget);
|
|
||||||
autoHideContainer->setSize(480);
|
|
||||||
autoHideContainer->setAcceptDrops(true);
|
|
||||||
ui->menuView->addAction(dropDockWidget->toggleViewAction());
|
|
||||||
}
|
|
||||||
|
|
||||||
QTableWidget* propertiesTable = new QTableWidget();
|
|
||||||
propertiesTable->setColumnCount(3);
|
|
||||||
propertiesTable->setRowCount(10);
|
|
||||||
CDockWidget* PropertiesDockWidget = new CDockWidget("Properties");
|
|
||||||
PropertiesDockWidget->setWidget(propertiesTable);
|
|
||||||
PropertiesDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
|
||||||
PropertiesDockWidget->resize(250, 150);
|
|
||||||
PropertiesDockWidget->setMinimumSize(200,150);
|
|
||||||
DockManager->addDockWidget(DockWidgetArea::RightDockWidgetArea, PropertiesDockWidget, CentralDockArea);
|
|
||||||
ui->menuView->addAction(PropertiesDockWidget->toggleViewAction());
|
|
||||||
|
|
||||||
createPerspectiveUi();
|
|
||||||
}
|
|
||||||
|
|
||||||
CMainWindow::~CMainWindow()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CMainWindow::createPerspectiveUi()
|
|
||||||
{
|
|
||||||
SavePerspectiveAction = new QAction("Create Perspective", this);
|
|
||||||
connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
|
|
||||||
PerspectiveListAction = new QWidgetAction(this);
|
|
||||||
PerspectiveComboBox = new QComboBox(this);
|
|
||||||
PerspectiveComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
||||||
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
||||||
connect(PerspectiveComboBox, SIGNAL(currentTextChanged(const QString&)),
|
|
||||||
DockManager, SLOT(openPerspective(const QString&)));
|
|
||||||
PerspectiveListAction->setDefaultWidget(PerspectiveComboBox);
|
|
||||||
ui->toolBar->addSeparator();
|
|
||||||
ui->toolBar->addAction(PerspectiveListAction);
|
|
||||||
ui->toolBar->addAction(SavePerspectiveAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CMainWindow::savePerspective()
|
|
||||||
{
|
|
||||||
QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:");
|
|
||||||
if (PerspectiveName.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DockManager->addPerspective(PerspectiveName);
|
|
||||||
QSignalBlocker Blocker(PerspectiveComboBox);
|
|
||||||
PerspectiveComboBox->clear();
|
|
||||||
PerspectiveComboBox->addItems(DockManager->perspectiveNames());
|
|
||||||
PerspectiveComboBox->setCurrentText(PerspectiveName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CMainWindow::closeEvent(QCloseEvent* event)
|
|
||||||
{
|
|
||||||
// Delete dock manager here to delete all floating widgets. This ensures
|
|
||||||
// that all top level windows of the dock manager are properly closed
|
|
||||||
DockManager->deleteLater();
|
|
||||||
QMainWindow::closeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#ifndef MAINWINDOW_H
|
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QWidgetAction>
|
|
||||||
|
|
||||||
#include "DockManager.h"
|
|
||||||
#include "DockAreaWidget.h"
|
|
||||||
#include "DockWidget.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
namespace Ui { class CMainWindow; }
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class CMainWindow : public QMainWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
CMainWindow(QWidget *parent = nullptr);
|
|
||||||
~CMainWindow();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent* event) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QAction* SavePerspectiveAction = nullptr;
|
|
||||||
QWidgetAction* PerspectiveListAction = nullptr;
|
|
||||||
QComboBox* PerspectiveComboBox = nullptr;
|
|
||||||
|
|
||||||
Ui::CMainWindow *ui;
|
|
||||||
|
|
||||||
ads::CDockManager* DockManager;
|
|
||||||
ads::CDockAreaWidget* StatusDockArea;
|
|
||||||
ads::CDockWidget* TimelineDockWidget;
|
|
||||||
|
|
||||||
void createPerspectiveUi();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void savePerspective();
|
|
||||||
};
|
|
||||||
#endif // MAINWINDOW_H
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>CMainWindow</class>
|
|
||||||
<widget class="QMainWindow" name="CMainWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1284</width>
|
|
||||||
<height>757</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>MainWindow</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
|
||||||
<widget class="QMenuBar" name="menubar">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1284</width>
|
|
||||||
<height>21</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<widget class="QMenu" name="menuView">
|
|
||||||
<property name="title">
|
|
||||||
<string>View</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menuView"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QToolBar" name="toolBar">
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>toolBar</string>
|
|
||||||
</property>
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
|
||||||
project(ads_example_centralwidget VERSION ${VERSION_SHORT})
|
|
||||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
|
||||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
add_executable(configFlagsExample WIN32
|
|
||||||
main.cpp
|
|
||||||
mainwindow.cpp
|
|
||||||
mainwindow.ui
|
|
||||||
)
|
|
||||||
target_include_directories(CentralWidgetExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
|
||||||
target_link_libraries(CentralWidgetExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
|
||||||
target_link_libraries(CentralWidgetExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
|
||||||
Qt${QT_VERSION_MAJOR}::Gui
|
|
||||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
|
||||||
set_target_properties(CentralWidgetExample PROPERTIES
|
|
||||||
AUTOMOC ON
|
|
||||||
AUTORCC ON
|
|
||||||
AUTOUIC ON
|
|
||||||
CXX_STANDARD 14
|
|
||||||
CXX_STANDARD_REQUIRED ON
|
|
||||||
CXX_EXTENSIONS OFF
|
|
||||||
VERSION ${VERSION_SHORT}
|
|
||||||
EXPORT_NAME "Qt Advanced Docking System Central Widget Example"
|
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
|
|
||||||
)
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
ADS_OUT_ROOT = $${OUT_PWD}/../..
|
|
||||||
|
|
||||||
QT += core gui widgets
|
|
||||||
|
|
||||||
TARGET = ConfigFlagsExample
|
|
||||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
|
||||||
TEMPLATE = app
|
|
||||||
CONFIG += c++14
|
|
||||||
CONFIG += debug_and_release
|
|
||||||
adsBuildStatic {
|
|
||||||
DEFINES += ADS_STATIC
|
|
||||||
}
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
|
||||||
# any Qt feature that has been marked deprecated (the exact warnings
|
|
||||||
# depend on your compiler). Please consult the documentation of the
|
|
||||||
# deprecated API in order to know how to port your code away from it.
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
main.cpp \
|
|
||||||
mainwindow.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
mainwindow.h
|
|
||||||
|
|
||||||
FORMS += \
|
|
||||||
mainwindow.ui
|
|
||||||
|
|
||||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
|
||||||
include(../../ads.pri)
|
|
||||||
INCLUDEPATH += ../../src
|
|
||||||
DEPENDPATH += ../../src
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#include <mainwindow.h>
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
QApplication a(argc, argv);
|
|
||||||
CMainWindow w;
|
|
||||||
w.show();
|
|
||||||
return a.exec();
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
|
||||||
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QToolBar>
|
|
||||||
|
|
||||||
#include "DockAreaWidget.h"
|
|
||||||
#include "DockAreaTitleBar.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace ads;
|
|
||||||
|
|
||||||
|
|
||||||
CMainWindow::CMainWindow(QWidget *parent) :
|
|
||||||
QMainWindow(parent),
|
|
||||||
ui(new Ui::CMainWindow)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
// Add the toolbar
|
|
||||||
auto toolbar_ = addToolBar("Top Toolbar");
|
|
||||||
|
|
||||||
// Create the dock manager
|
|
||||||
ads::CDockManager::setConfigFlags(ads::CDockManager::DefaultOpaqueConfig);
|
|
||||||
ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasCloseButton,
|
|
||||||
false);
|
|
||||||
ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasUndockButton,
|
|
||||||
false);
|
|
||||||
ads::CDockManager::setConfigFlag(
|
|
||||||
ads::CDockManager::DockAreaHasTabsMenuButton, false);
|
|
||||||
auto DockManager = new ads::CDockManager(this);
|
|
||||||
|
|
||||||
// Create a dockable widget
|
|
||||||
QLabel *l1 = new QLabel();
|
|
||||||
l1->setWordWrap(true);
|
|
||||||
l1->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
||||||
l1->setText("Docking widget 1");
|
|
||||||
ads::CDockWidget *dockWidget1 = new ads::CDockWidget("Dock 1");
|
|
||||||
dockWidget1->setWidget(l1);
|
|
||||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, dockWidget1);
|
|
||||||
|
|
||||||
QLabel *l2 = new QLabel();
|
|
||||||
l2->setWordWrap(true);
|
|
||||||
l2->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
|
||||||
l2->setText("Docking widget 2");
|
|
||||||
ads::CDockWidget *dockWidget2 = new ads::CDockWidget("Dock 2");
|
|
||||||
dockWidget2->setWidget(l2);
|
|
||||||
DockManager->addDockWidget(ads::RightDockWidgetArea, dockWidget2);
|
|
||||||
|
|
||||||
// Add menu actions
|
|
||||||
ui->menuView->addAction(dockWidget1->toggleViewAction());
|
|
||||||
ui->menuView->addAction(dockWidget2->toggleViewAction());
|
|
||||||
toolbar_->addAction(dockWidget1->toggleViewAction());
|
|
||||||
toolbar_->addAction(dockWidget2->toggleViewAction());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CMainWindow::~CMainWindow()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#ifndef MAINWINDOW_H
|
|
||||||
#define MAINWINDOW_H
|
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QWidgetAction>
|
|
||||||
|
|
||||||
#include "DockManager.h"
|
|
||||||
#include "DockAreaWidget.h"
|
|
||||||
#include "DockWidget.h"
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
namespace Ui { class CMainWindow; }
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class CMainWindow : public QMainWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
CMainWindow(QWidget *parent = nullptr);
|
|
||||||
~CMainWindow();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::CMainWindow *ui;
|
|
||||||
};
|
|
||||||
#endif // MAINWINDOW_H
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>CMainWindow</class>
|
|
||||||
<widget class="QMainWindow" name="CMainWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1284</width>
|
|
||||||
<height>757</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>MainWindow</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
|
||||||
<widget class="QMenuBar" name="menubar">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>1284</width>
|
|
||||||
<height>21</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<widget class="QMenu" name="menuView">
|
|
||||||
<property name="title">
|
|
||||||
<string>View</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menuView"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QToolBar" name="toolBar">
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>toolBar</string>
|
|
||||||
</property>
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -2,12 +2,10 @@ TEMPLATE = subdirs
|
|||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
autohide \
|
autohide \
|
||||||
autohidedragndrop \
|
|
||||||
centralwidget \
|
centralwidget \
|
||||||
simple \
|
simple \
|
||||||
hideshow \
|
hideshow \
|
||||||
sidebar \
|
sidebar \
|
||||||
deleteonclose \
|
deleteonclose \
|
||||||
emptydockarea \
|
emptydockarea \
|
||||||
dockindock \
|
dockindock
|
||||||
configflags
|
|
||||||
|
|||||||
@@ -12,14 +12,10 @@ class CTitleBarButton : QToolButton
|
|||||||
%End
|
%End
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTitleBarButton(bool ShowInTitleBar, bool HideWhenDisabled, TitleBarButton ButtonId,
|
CTitleBarButton(bool visible = true, QWidget* parent /TransferThis/ = Q_NULLPTR );
|
||||||
QWidget* /TransferThis/ = Q_NULLPTR );
|
|
||||||
virtual void setVisible(bool);
|
virtual void setVisible(bool);
|
||||||
void setShowInTitleBar(bool);
|
void setShowInTitleBar(bool);
|
||||||
|
|
||||||
TitleBarButton buttonId() const;
|
|
||||||
ads::CDockAreaTitleBar* titleBar() const;
|
|
||||||
bool isInAutoHideArea() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *ev);
|
bool event(QEvent *ev);
|
||||||
@@ -48,15 +44,13 @@ public:
|
|||||||
ads::CDockAreaTabBar* tabBar() const;
|
ads::CDockAreaTabBar* tabBar() const;
|
||||||
ads::CTitleBarButton* button(ads::TitleBarButton which) const;
|
ads::CTitleBarButton* button(ads::TitleBarButton which) const;
|
||||||
ads::CElidingLabel* autoHideTitleLabel() const;
|
ads::CElidingLabel* autoHideTitleLabel() const;
|
||||||
ads::CDockAreaWidget* dockAreaWidget() const;
|
|
||||||
void updateDockWidgetActionsButtons();
|
void updateDockWidgetActionsButtons();
|
||||||
virtual void setVisible(bool Visible);
|
virtual void setVisible(bool Visible);
|
||||||
void insertWidget(int index, QWidget *widget /Transfer/ );
|
void insertWidget(int index, QWidget *widget /Transfer/ );
|
||||||
int indexOf(QWidget *widget) const;
|
int indexOf(QWidget *widget) const;
|
||||||
QString titleBarButtonToolTip(ads::TitleBarButton Button) const;
|
QString titleBarButtonToolTip(ads::TitleBarButton Button) const;
|
||||||
void setAreaFloating();
|
void setAreaFloating();
|
||||||
void showAutoHideControls(bool Show);
|
|
||||||
bool isAutoHide() const;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tabBarClicked(int index);
|
void tabBarClicked(int index);
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public:
|
|||||||
ads::CDockManager* dockManager() const;
|
ads::CDockManager* dockManager() const;
|
||||||
ads::CDockContainerWidget* dockContainer() const;
|
ads::CDockContainerWidget* dockContainer() const;
|
||||||
ads::CAutoHideDockContainer* autoHideDockContainer() const;
|
ads::CAutoHideDockContainer* autoHideDockContainer() const;
|
||||||
ads::CDockSplitter* parentSplitter() const;
|
|
||||||
bool isAutoHide() const;
|
bool isAutoHide() const;
|
||||||
void setAutoHideDockContainer(CAutoHideDockContainer*);
|
void setAutoHideDockContainer(CAutoHideDockContainer*);
|
||||||
virtual QSize minimumSizeHint() const;
|
virtual QSize minimumSizeHint() const;
|
||||||
|
|||||||
@@ -20,14 +20,13 @@ class CDockContainerWidget : QFrame
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool event(QEvent *e);
|
virtual bool event(QEvent *e);
|
||||||
ads::CDockSplitter* rootSplitter() const;
|
QSplitter* rootSplitter() const;
|
||||||
ads::CAutoHideDockContainer* createAndSetupAutoHideContainer(ads::SideBarLocation area, ads::CDockWidget* DockWidget /Transfer/, int TabIndex = -1);
|
ads::CAutoHideDockContainer* createAndSetupAutoHideContainer(ads::SideBarLocation area, ads::CDockWidget* DockWidget /Transfer/, int TabIndex = -1);
|
||||||
void createRootSplitter();
|
void createRootSplitter();
|
||||||
void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
|
void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
|
||||||
void dropWidget(QWidget* Widget, DockWidgetArea DropArea, CDockAreaWidget* TargetAreaWidget, int TabIndex = -1);
|
void dropWidget(QWidget* Widget, DockWidgetArea DropArea, CDockAreaWidget* TargetAreaWidget, int TabIndex = -1);
|
||||||
void addDockArea(ads::CDockAreaWidget* DockAreaWidget /Transfer/, ads::DockWidgetArea area = ads::CenterDockWidgetArea);
|
void addDockArea(ads::CDockAreaWidget* DockAreaWidget /Transfer/, ads::DockWidgetArea area = ads::CenterDockWidgetArea);
|
||||||
void removeDockArea(ads::CDockAreaWidget* area /TransferBack/);
|
void removeDockArea(ads::CDockAreaWidget* area /TransferBack/);
|
||||||
/*QList<QPointer<ads::CDockAreaWidget>> removeAllDockAreas();*/
|
|
||||||
void saveState(QXmlStreamWriter& Stream) const;
|
void saveState(QXmlStreamWriter& Stream) const;
|
||||||
bool restoreState(CDockingStateReader& Stream, bool Testing);
|
bool restoreState(CDockingStateReader& Stream, bool Testing);
|
||||||
ads::CDockAreaWidget* lastAddedDockAreaWidget(ads::DockWidgetArea area) const;
|
ads::CDockAreaWidget* lastAddedDockAreaWidget(ads::DockWidgetArea area) const;
|
||||||
|
|||||||
@@ -172,8 +172,6 @@ public:
|
|||||||
FloatingContainerForceNativeTitleBar,
|
FloatingContainerForceNativeTitleBar,
|
||||||
FloatingContainerForceQWidgetTitleBar,
|
FloatingContainerForceQWidgetTitleBar,
|
||||||
MiddleMouseButtonClosesTab,
|
MiddleMouseButtonClosesTab,
|
||||||
DisableTabTextEliding,
|
|
||||||
ShowTabTextOnlyForActiveTab,
|
|
||||||
DefaultDockAreaButtons,
|
DefaultDockAreaButtons,
|
||||||
DefaultBaseConfig,
|
DefaultBaseConfig,
|
||||||
DefaultOpaqueConfig,
|
DefaultOpaqueConfig,
|
||||||
@@ -190,8 +188,6 @@ public:
|
|||||||
AutoHideSideBarsIconOnly,
|
AutoHideSideBarsIconOnly,
|
||||||
AutoHideShowOnMouseOver,
|
AutoHideShowOnMouseOver,
|
||||||
AutoHideCloseButtonCollapsesDock,
|
AutoHideCloseButtonCollapsesDock,
|
||||||
AutoHideHasCloseButton,
|
|
||||||
AutoHideHasMinimizeButton,
|
|
||||||
DefaultAutoHideConfig,
|
DefaultAutoHideConfig,
|
||||||
};
|
};
|
||||||
typedef QFlags<ads::CDockManager::eAutoHideFlag> AutoHideFlags;
|
typedef QFlags<ads::CDockManager::eAutoHideFlag> AutoHideFlags;
|
||||||
@@ -249,12 +245,6 @@ public:
|
|||||||
void setSplitterSizes(ads::CDockAreaWidget *ContainedArea, const QList<int>& sizes);
|
void setSplitterSizes(ads::CDockAreaWidget *ContainedArea, const QList<int>& sizes);
|
||||||
static void setFloatingContainersTitle(const QString& Title);
|
static void setFloatingContainersTitle(const QString& Title);
|
||||||
static QString floatingContainersTitle();
|
static QString floatingContainersTitle();
|
||||||
void setDockWidgetToolBarStyle(Qt::ToolButtonStyle Style, ads::CDockWidget::eState State);
|
|
||||||
Qt::ToolButtonStyle dockWidgetToolBarStyle(ads::CDockWidget::eState State) const;
|
|
||||||
void setDockWidgetToolBarIconSize(const QSize& IconSize, ads::CDockWidget::eState State);
|
|
||||||
QSize dockWidgetToolBarIconSize(ads::CDockWidget::eState State) const;
|
|
||||||
ads::CDockWidget::DockWidgetFeatures globallyLockedDockWidgetFeatures() const;
|
|
||||||
void lockDockWidgetFeaturesGlobally(ads::CDockWidget::DockWidgetFeatures Features = ads::CDockWidget::GloballyLockableFeatures);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void endLeavingMinimizedState();
|
void endLeavingMinimizedState();
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public:
|
|||||||
DefaultDockWidgetFeatures,
|
DefaultDockWidgetFeatures,
|
||||||
AllDockWidgetFeatures,
|
AllDockWidgetFeatures,
|
||||||
DockWidgetAlwaysCloseAndDelete,
|
DockWidgetAlwaysCloseAndDelete,
|
||||||
GloballyLockableFeatures,
|
|
||||||
NoDockWidgetFeatures
|
NoDockWidgetFeatures
|
||||||
};
|
};
|
||||||
typedef QFlags<ads::CDockWidget::DockWidgetFeature> DockWidgetFeatures;
|
typedef QFlags<ads::CDockWidget::DockWidgetFeature> DockWidgetFeatures;
|
||||||
@@ -50,12 +49,6 @@ public:
|
|||||||
StateDocked,
|
StateDocked,
|
||||||
StateFloating
|
StateFloating
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eToolBarStyleSource
|
|
||||||
{
|
|
||||||
ToolBarStyleFromDockManager,
|
|
||||||
ToolBarStyleFromDockWidget
|
|
||||||
};
|
|
||||||
|
|
||||||
enum eInsertMode
|
enum eInsertMode
|
||||||
{
|
{
|
||||||
@@ -79,7 +72,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CDockWidget(const QString &title, QWidget* parent /TransferThis/ = Q_NULLPTR);
|
CDockWidget(const QString &title, QWidget* parent /TransferThis/ = 0);
|
||||||
virtual ~CDockWidget();
|
virtual ~CDockWidget();
|
||||||
virtual QSize minimumSizeHint() const;
|
virtual QSize minimumSizeHint() const;
|
||||||
void setWidget(QWidget* widget /Transfer/, ads::CDockWidget::eInsertMode InsertMode = AutoScrollArea);
|
void setWidget(QWidget* widget /Transfer/, ads::CDockWidget::eInsertMode InsertMode = AutoScrollArea);
|
||||||
@@ -89,7 +82,6 @@ public:
|
|||||||
void setFeatures(ads::CDockWidget::DockWidgetFeatures features);
|
void setFeatures(ads::CDockWidget::DockWidgetFeatures features);
|
||||||
void setFeature(ads::CDockWidget::DockWidgetFeature flag, bool on);
|
void setFeature(ads::CDockWidget::DockWidgetFeature flag, bool on);
|
||||||
ads::CDockWidget::DockWidgetFeatures features() const;
|
ads::CDockWidget::DockWidgetFeatures features() const;
|
||||||
void notifyFeaturesChanged();
|
|
||||||
ads::CDockManager* dockManager() const;
|
ads::CDockManager* dockManager() const;
|
||||||
ads::CDockContainerWidget* dockContainer() const;
|
ads::CDockContainerWidget* dockContainer() const;
|
||||||
ads::CFloatingDockContainer* floatingDockContainer() const;
|
ads::CFloatingDockContainer* floatingDockContainer() const;
|
||||||
@@ -103,7 +95,6 @@ public:
|
|||||||
bool isInFloatingContainer() const;
|
bool isInFloatingContainer() const;
|
||||||
bool isClosed() const;
|
bool isClosed() const;
|
||||||
QAction* toggleViewAction() const;
|
QAction* toggleViewAction() const;
|
||||||
void setToggleViewAction(QAction* action);
|
|
||||||
void setToggleViewActionMode(ads::CDockWidget::eToggleViewActionMode Mode);
|
void setToggleViewActionMode(ads::CDockWidget::eToggleViewActionMode Mode);
|
||||||
void setMinimumSizeHintMode(ads::CDockWidget::eMinimumSizeHintMode Mode);
|
void setMinimumSizeHintMode(ads::CDockWidget::eMinimumSizeHintMode Mode);
|
||||||
ads::CDockWidget::eMinimumSizeHintMode minimumSizeHintMode() const;
|
ads::CDockWidget::eMinimumSizeHintMode minimumSizeHintMode() const;
|
||||||
@@ -113,8 +104,6 @@ public:
|
|||||||
QToolBar* toolBar() const;
|
QToolBar* toolBar() const;
|
||||||
QToolBar* createDefaultToolBar();
|
QToolBar* createDefaultToolBar();
|
||||||
void setToolBar(QToolBar* ToolBar /Transfer/ );
|
void setToolBar(QToolBar* ToolBar /Transfer/ );
|
||||||
void setToolBarStyleSource(ads::CDockWidget::eToolBarStyleSource Source);
|
|
||||||
ads::CDockWidget::eToolBarStyleSource toolBarStyleSource() const;
|
|
||||||
void setToolBarStyle(Qt::ToolButtonStyle Style, ads::CDockWidget::eState State);
|
void setToolBarStyle(Qt::ToolButtonStyle Style, ads::CDockWidget::eState State);
|
||||||
Qt::ToolButtonStyle toolBarStyle(ads::CDockWidget::eState State) const;
|
Qt::ToolButtonStyle toolBarStyle(ads::CDockWidget::eState State) const;
|
||||||
void setToolBarIconSize(const QSize& IconSize, ads::CDockWidget::eState State);
|
void setToolBarIconSize(const QSize& IconSize, ads::CDockWidget::eState State);
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ protected:
|
|||||||
virtual void mouseDoubleClickEvent( QMouseEvent *ev );
|
virtual void mouseDoubleClickEvent( QMouseEvent *ev );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CElidingLabel(QWidget* parent /TransferThis/ = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags ());
|
CElidingLabel(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
|
||||||
CElidingLabel(const QString& text, QWidget* parent /TransferThis/ = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags ());
|
CElidingLabel(const QString& text, QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
|
||||||
virtual ~CElidingLabel();
|
virtual ~CElidingLabel();
|
||||||
Qt::TextElideMode elideMode() const;
|
Qt::TextElideMode elideMode() const;
|
||||||
void setElideMode(Qt::TextElideMode mode);
|
void setElideMode(Qt::TextElideMode mode);
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ protected:
|
|||||||
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
QWidget* MouseEventHandler);
|
QWidget* MouseEventHandler);
|
||||||
virtual void finishDragging();
|
virtual void finishDragging();
|
||||||
void deleteContent();
|
|
||||||
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size);
|
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size);
|
||||||
void moveFloating();
|
void moveFloating();
|
||||||
bool restoreState(ads::CDockingStateReader& Stream, bool Testing);
|
bool restoreState(ads::CDockingStateReader& Stream, bool Testing);
|
||||||
@@ -83,7 +82,6 @@ public:
|
|||||||
bool hasTopLevelDockWidget() const;
|
bool hasTopLevelDockWidget() const;
|
||||||
ads::CDockWidget* topLevelDockWidget() const;
|
ads::CDockWidget* topLevelDockWidget() const;
|
||||||
QList<ads::CDockWidget*> dockWidgets() const;
|
QList<ads::CDockWidget*> dockWidgets() const;
|
||||||
void finishDropOperation();
|
|
||||||
|
|
||||||
%If (WS_X11)
|
%If (WS_X11)
|
||||||
void onMaximizeRequest();
|
void onMaximizeRequest();
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ namespace ads
|
|||||||
TitleBarButtonTabsMenu,
|
TitleBarButtonTabsMenu,
|
||||||
TitleBarButtonUndock,
|
TitleBarButtonUndock,
|
||||||
TitleBarButtonClose,
|
TitleBarButtonClose,
|
||||||
TitleBarButtonAutoHide,
|
TitleBarButtonAutoHide
|
||||||
TitleBarButtonMinimize
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eDragState
|
enum eDragState
|
||||||
|
|||||||
@@ -657,14 +657,6 @@ bool CAutoHideDockContainer::event(QEvent* event)
|
|||||||
return Super::event(event);
|
return Super::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CAutoHideDockContainer::dragLeaveEvent(QDragLeaveEvent*)
|
|
||||||
{
|
|
||||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover))
|
|
||||||
{
|
|
||||||
collapseView(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
Qt::Orientation CAutoHideDockContainer::orientation() const
|
Qt::Orientation CAutoHideDockContainer::orientation() const
|
||||||
@@ -717,3 +709,4 @@ int CAutoHideDockContainer::tabIndex() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ protected:
|
|||||||
virtual void resizeEvent(QResizeEvent* event) override;
|
virtual void resizeEvent(QResizeEvent* event) override;
|
||||||
virtual void leaveEvent(QEvent *event) override;
|
virtual void leaveEvent(QEvent *event) override;
|
||||||
virtual bool event(QEvent* event) override;
|
virtual bool event(QEvent* event) override;
|
||||||
virtual void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the size considering the size limits and the resize margins
|
* Updates the size considering the size limits and the resize margins
|
||||||
@@ -140,7 +139,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the contents to the parent container widget
|
* Moves the contents to the parent container widget
|
||||||
* Used before removing this Auto Hide dock container
|
* Used before removing this Auto Hide dock container
|
||||||
*/
|
*/
|
||||||
void moveContentsToParent();
|
void moveContentsToParent();
|
||||||
|
|
||||||
|
|||||||
@@ -414,14 +414,7 @@ void CAutoHideSideBar::saveState(QXmlStreamWriter& s) const
|
|||||||
QSize CAutoHideSideBar::minimumSizeHint() const
|
QSize CAutoHideSideBar::minimumSizeHint() const
|
||||||
{
|
{
|
||||||
QSize Size = sizeHint();
|
QSize Size = sizeHint();
|
||||||
if (d->isHorizontal())
|
Size.setWidth(10);
|
||||||
{
|
|
||||||
Size.setWidth(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Size.setHeight(0);
|
|
||||||
}
|
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QEvent>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include "AutoHideDockContainer.h"
|
#include "AutoHideDockContainer.h"
|
||||||
#include "AutoHideSideBar.h"
|
#include "AutoHideSideBar.h"
|
||||||
@@ -43,7 +41,6 @@
|
|||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "FloatingDragPreview.h"
|
#include "FloatingDragPreview.h"
|
||||||
#include "DockOverlay.h"
|
#include "DockOverlay.h"
|
||||||
#include "ads_globals.h"
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
@@ -58,7 +55,6 @@ struct AutoHideTabPrivate
|
|||||||
CAutoHideSideBar* SideBar = nullptr;
|
CAutoHideSideBar* SideBar = nullptr;
|
||||||
Qt::Orientation Orientation{Qt::Vertical};
|
Qt::Orientation Orientation{Qt::Vertical};
|
||||||
QElapsedTimer TimeSinceHoverMousePress;
|
QElapsedTimer TimeSinceHoverMousePress;
|
||||||
QTimer DragOverTimer;
|
|
||||||
bool MousePressed = false;
|
bool MousePressed = false;
|
||||||
eDragState DragState = DraggingInactive;
|
eDragState DragState = DraggingInactive;
|
||||||
QPoint GlobalDragStartMousePosition;
|
QPoint GlobalDragStartMousePosition;
|
||||||
@@ -256,14 +252,6 @@ CAutoHideTab::CAutoHideTab(QWidget* parent) :
|
|||||||
{
|
{
|
||||||
setAttribute(Qt::WA_NoMousePropagation);
|
setAttribute(Qt::WA_NoMousePropagation);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover)) {
|
|
||||||
setAcceptDrops(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
d->DragOverTimer.setInterval(CDockManager::configParam(
|
|
||||||
CDockManager::AutoHideOpenOnDragHoverDelay_ms, 500).toInt());
|
|
||||||
d->DragOverTimer.setSingleShot(true);
|
|
||||||
connect(&d->DragOverTimer, &QTimer::timeout, this, &CAutoHideTab::onDragHoverDelayExpired);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -367,6 +355,7 @@ bool CAutoHideTab::event(QEvent* event)
|
|||||||
case QEvent::Leave:
|
case QEvent::Leave:
|
||||||
d->forwardEventToDockContainer(event);
|
d->forwardEventToDockContainer(event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -504,74 +493,48 @@ void CAutoHideTab::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CAutoHideTab::mouseMoveEvent(QMouseEvent *ev)
|
void CAutoHideTab::mouseMoveEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
if (!(ev->buttons() & Qt::LeftButton)
|
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||||
|| d->isDraggingState(DraggingInactive))
|
{
|
||||||
{
|
d->DragState = DraggingInactive;
|
||||||
d->DragState = DraggingInactive;
|
Super::mouseMoveEvent(ev);
|
||||||
Super::mouseMoveEvent(ev);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// move floating window
|
// move floating window
|
||||||
if (d->isDraggingState(DraggingFloatingWidget))
|
if (d->isDraggingState(DraggingFloatingWidget))
|
||||||
{
|
{
|
||||||
d->FloatingWidget->moveFloating();
|
d->FloatingWidget->moveFloating();
|
||||||
Super::mouseMoveEvent(ev);
|
Super::mouseMoveEvent(ev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move tab
|
// move tab
|
||||||
if (d->isDraggingState(DraggingTab))
|
if (d->isDraggingState(DraggingTab))
|
||||||
{
|
{
|
||||||
// Moving the tab is always allowed because it does not mean moving the
|
// Moving the tab is always allowed because it does not mean moving the
|
||||||
// dock widget around
|
// dock widget around
|
||||||
//d->moveTab(ev);
|
//d->moveTab(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MappedPos = mapToParent(ev->pos());
|
auto MappedPos = mapToParent(ev->pos());
|
||||||
bool MouseOutsideBar = (MappedPos.x() < 0)
|
bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right());
|
||||||
|| (MappedPos.x() > parentWidget()->rect().right());
|
// Maybe a fixed drag distance is better here ?
|
||||||
// Maybe a fixed drag distance is better here ?
|
int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - internal::globalPositionOf(ev).y());
|
||||||
int DragDistanceY = qAbs(
|
if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar)
|
||||||
d->GlobalDragStartMousePosition.y()
|
|
||||||
- internal::globalPositionOf(ev).y());
|
|
||||||
if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar)
|
|
||||||
{
|
{
|
||||||
// Floating is only allowed for widgets that are floatable
|
// Floating is only allowed for widgets that are floatable
|
||||||
// We can create the drag preview if the widget is movable.
|
// We can create the drag preview if the widget is movable.
|
||||||
auto Features = d->DockWidget->features();
|
auto Features = d->DockWidget->features();
|
||||||
if (Features.testFlag(CDockWidget::DockWidgetFloatable)
|
if (Features.testFlag(CDockWidget::DockWidgetFloatable) || (Features.testFlag(CDockWidget::DockWidgetMovable)))
|
||||||
|| (Features.testFlag(CDockWidget::DockWidgetMovable)))
|
{
|
||||||
{
|
d->startFloating();
|
||||||
d->startFloating();
|
}
|
||||||
}
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Super::mouseMoveEvent(ev);
|
Super::mouseMoveEvent(ev);
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CAutoHideTab::dragEnterEvent(QDragEnterEvent *ev)
|
|
||||||
{
|
|
||||||
Q_UNUSED(ev);
|
|
||||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover))
|
|
||||||
{
|
|
||||||
d->DragOverTimer.start();
|
|
||||||
ev->accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CAutoHideTab::dragLeaveEvent(QDragLeaveEvent *ev)
|
|
||||||
{
|
|
||||||
Q_UNUSED(ev);
|
|
||||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover))
|
|
||||||
{
|
|
||||||
d->DragOverTimer.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -581,6 +544,7 @@ void CAutoHideTab::requestCloseDockWidget()
|
|||||||
d->DockWidget->requestCloseDockWidget();
|
d->DockWidget->requestCloseDockWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
int CAutoHideTab::tabIndex() const
|
int CAutoHideTab::tabIndex() const
|
||||||
{
|
{
|
||||||
@@ -593,28 +557,4 @@ int CAutoHideTab::tabIndex() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CAutoHideTab::onDragHoverDelayExpired()
|
|
||||||
{
|
|
||||||
static const char* const PropertyId = "ActiveDragOverAutoHideContainer";
|
|
||||||
|
|
||||||
// First we check if there is an active auto hide container that is visible
|
|
||||||
// In this case, we collapse it before we open the new one
|
|
||||||
auto v = d->DockWidget->dockManager()->property(PropertyId);
|
|
||||||
if (v.isValid())
|
|
||||||
{
|
|
||||||
auto ActiveAutoHideContainer = v.value<QPointer<CAutoHideDockContainer>>();
|
|
||||||
if (ActiveAutoHideContainer)
|
|
||||||
{
|
|
||||||
ActiveAutoHideContainer->collapseView(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto AutoHideContainer = d->DockWidget->autoHideDockContainer();
|
|
||||||
AutoHideContainer->collapseView(false);
|
|
||||||
d->DockWidget->dockManager()->setProperty(PropertyId,
|
|
||||||
QVariant::fromValue(QPointer<CAutoHideDockContainer>(AutoHideContainer)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class ADS_EXPORT CAutoHideTab : public CPushButton
|
|||||||
Q_PROPERTY(bool activeTab READ isActiveTab)
|
Q_PROPERTY(bool activeTab READ isActiveTab)
|
||||||
Q_PROPERTY(bool iconOnly READ iconOnly)
|
Q_PROPERTY(bool iconOnly READ iconOnly)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AutoHideTabPrivate* d; ///< private data (pimpl)
|
AutoHideTabPrivate* d; ///< private data (pimpl)
|
||||||
friend struct AutoHideTabPrivate;
|
friend struct AutoHideTabPrivate;
|
||||||
friend class CDockWidget;
|
friend class CDockWidget;
|
||||||
@@ -67,7 +67,6 @@ private:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onAutoHideToActionClicked();
|
void onAutoHideToActionClicked();
|
||||||
void onDragHoverDelayExpired();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setSideBar(CAutoHideSideBar *SideTabBar);
|
void setSideBar(CAutoHideSideBar *SideTabBar);
|
||||||
@@ -77,8 +76,6 @@ protected:
|
|||||||
virtual void mousePressEvent(QMouseEvent* ev) override;
|
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
|
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
|
||||||
virtual void mouseMoveEvent(QMouseEvent* ev) override;
|
virtual void mouseMoveEvent(QMouseEvent* ev) override;
|
||||||
virtual void dragEnterEvent(QDragEnterEvent* ev) override;
|
|
||||||
virtual void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Super = CPushButton;
|
using Super = CPushButton;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT})
|
project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT})
|
||||||
include(GNUInstallDirs)
|
|
||||||
if (${QT_VERSION_MAJOR})
|
if (${QT_VERSION_MAJOR})
|
||||||
message(STATUS "Forced to use Qt version ${QT_VERSION_MAJOR}")
|
message(STATUS "Forced to use Qt version ${QT_VERSION_MAJOR}")
|
||||||
find_package(QT NAMES Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
|
find_package(QT NAMES Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ void DockAreaTabBarPrivate::updateTabs()
|
|||||||
// Sometimes the synchronous calculation of the rectangular area fails
|
// Sometimes the synchronous calculation of the rectangular area fails
|
||||||
// Therefore we use QTimer::singleShot here to execute the call
|
// Therefore we use QTimer::singleShot here to execute the call
|
||||||
// within the event loop - see #520
|
// within the event loop - see #520
|
||||||
QTimer::singleShot(0, _this, [&, TabWidget]
|
QTimer::singleShot(0, TabWidget, [&, TabWidget]
|
||||||
{
|
{
|
||||||
_this->ensureWidgetVisible(TabWidget);
|
_this->ensureWidgetVisible(TabWidget);
|
||||||
});
|
});
|
||||||
@@ -161,13 +161,15 @@ CDockAreaTabBar::~CDockAreaTabBar()
|
|||||||
void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
|
void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
|
||||||
{
|
{
|
||||||
Event->accept();
|
Event->accept();
|
||||||
int numPixels = Event->pixelDelta().y();
|
const int direction = Event->angleDelta().y();
|
||||||
if (!numPixels)
|
if (direction < 0)
|
||||||
{
|
{
|
||||||
numPixels = Event->angleDelta().y() / 5;
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - numPixels);
|
{
|
||||||
|
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -388,18 +390,15 @@ void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos)
|
|||||||
|
|
||||||
int fromIndex = d->TabsLayout->indexOf(MovingTab);
|
int fromIndex = d->TabsLayout->indexOf(MovingTab);
|
||||||
auto MousePos = mapFromGlobal(GlobalPos);
|
auto MousePos = mapFromGlobal(GlobalPos);
|
||||||
MousePos.rx() = qMax(0, MousePos.x());
|
MousePos.rx() = qMax(d->firstTab()->geometry().left(), MousePos.x());
|
||||||
MousePos.rx() = qMin(width(), MousePos.x());
|
MousePos.rx() = qMin(d->lastTab()->geometry().right(), MousePos.x());
|
||||||
int toIndex = -1;
|
int toIndex = -1;
|
||||||
// Find tab under mouse
|
// Find tab under mouse
|
||||||
for (int i = 0; i < count(); ++i)
|
for (int i = 0; i < count(); ++i)
|
||||||
{
|
{
|
||||||
CDockWidgetTab* DropTab = tab(i);
|
CDockWidgetTab* DropTab = tab(i);
|
||||||
auto TabGeometry = DropTab->geometry();
|
|
||||||
TabGeometry.setTopLeft(d->TabsContainerWidget->mapToParent(TabGeometry.topLeft()));
|
|
||||||
TabGeometry.setBottomRight(d->TabsContainerWidget->mapToParent(TabGeometry.bottomRight()));
|
|
||||||
if (DropTab == MovingTab || !DropTab->isVisibleTo(this)
|
if (DropTab == MovingTab || !DropTab->isVisibleTo(this)
|
||||||
|| !TabGeometry.contains(MousePos))
|
|| !DropTab->geometry().contains(MousePos))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -471,15 +470,6 @@ bool CDockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
|
|||||||
updateGeometry();
|
updateGeometry();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Manage wheel event
|
|
||||||
case QEvent::Wheel:
|
|
||||||
// Ignore wheel events if tab is currently dragged
|
|
||||||
if (Tab->dragState() == DraggingInactive)
|
|
||||||
{
|
|
||||||
wheelEvent((QWheelEvent* )event);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -555,13 +545,6 @@ int CDockAreaTabBar::tabInsertIndexAt(const QPoint& Pos) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
bool CDockAreaTabBar::areTabsOverflowing() const
|
|
||||||
{
|
|
||||||
return d->TabsContainerWidget->width() > width();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -153,12 +153,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual QSize sizeHint() const override;
|
virtual QSize sizeHint() const override;
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns true, if the tabs need more space than the size
|
|
||||||
* of the tab bar.
|
|
||||||
*/
|
|
||||||
bool areTabsOverflowing() const;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* This property sets the index of the tab bar's visible tab
|
* This property sets the index of the tab bar's visible tab
|
||||||
|
|||||||
@@ -377,48 +377,27 @@ CDockAreaTabBar* CDockAreaTitleBar::tabBar() const
|
|||||||
return d->TabBar;
|
return d->TabBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CDockAreaTitleBar::resizeEvent(QResizeEvent *event)
|
|
||||||
{
|
|
||||||
Super::resizeEvent(event);
|
|
||||||
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility)
|
|
||||||
&& CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
|
|
||||||
{
|
|
||||||
markTabsMenuOutdated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTitleBar::markTabsMenuOutdated()
|
void CDockAreaTitleBar::markTabsMenuOutdated()
|
||||||
{
|
{
|
||||||
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
|
if(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
|
||||||
{
|
{
|
||||||
bool TabsMenuButtonVisible = false;
|
bool hasElidedTabTitle = false;
|
||||||
if (CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
|
for (int i = 0; i < d->TabBar->count(); ++i)
|
||||||
{
|
{
|
||||||
TabsMenuButtonVisible = d->TabBar->areTabsOverflowing();
|
if (!d->TabBar->isTabOpen(i))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool hasElidedTabTitle = false;
|
|
||||||
for (int i = 0; i < d->TabBar->count(); ++i)
|
|
||||||
{
|
{
|
||||||
if (!d->TabBar->isTabOpen(i))
|
continue;
|
||||||
{
|
}
|
||||||
continue;
|
CDockWidgetTab* Tab = d->TabBar->tab(i);
|
||||||
}
|
if(Tab->isTitleElided())
|
||||||
CDockWidgetTab* Tab = d->TabBar->tab(i);
|
{
|
||||||
if(Tab->isTitleElided())
|
hasElidedTabTitle = true;
|
||||||
{
|
break;
|
||||||
hasElidedTabTitle = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
TabsMenuButtonVisible = (hasElidedTabTitle && (d->TabBar->count() > 1));
|
|
||||||
}
|
}
|
||||||
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, TabsMenuButtonVisible));
|
bool visible = (hasElidedTabTitle && (d->TabBar->count() > 1));
|
||||||
|
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
|
||||||
}
|
}
|
||||||
d->MenuOutdated = true;
|
d->MenuOutdated = true;
|
||||||
}
|
}
|
||||||
@@ -765,35 +744,24 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Menu = buildContextMenu(nullptr);
|
const bool isAutoHide = d->DockArea->isAutoHide();
|
||||||
Menu->exec(ev->globalPos());
|
|
||||||
delete Menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu* CDockAreaTitleBar::buildContextMenu(QMenu *Menu)
|
|
||||||
{
|
|
||||||
const bool isAutoHide = d->DockArea->isAutoHide();
|
|
||||||
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
||||||
QAction* Action;
|
QAction* Action;
|
||||||
if (Menu == nullptr)
|
QMenu Menu(this);
|
||||||
{
|
if (!isTopLevelArea)
|
||||||
Menu = new QMenu(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isTopLevelArea)
|
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(isAutoHide ? tr("Detach") : tr("Detach Group"),
|
Action = Menu.addAction(isAutoHide ? tr("Detach") : tr("Detach Group"),
|
||||||
this, SLOT(onUndockButtonClicked()));
|
this, SLOT(onUndockButtonClicked()));
|
||||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(isAutoHide ? tr("Unpin (Dock)") : tr("Pin Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
Action = Menu.addAction(isAutoHide ? tr("Unpin (Dock)") : tr("Pin Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||||
auto AreaIsPinnable = d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable);
|
auto AreaIsPinnable = d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||||
Action->setEnabled(AreaIsPinnable);
|
Action->setEnabled(AreaIsPinnable);
|
||||||
|
|
||||||
if (!isAutoHide)
|
if (!isAutoHide)
|
||||||
{
|
{
|
||||||
auto menu = Menu->addMenu(tr("Pin Group To..."));
|
auto menu = Menu.addMenu(tr("Pin Group To..."));
|
||||||
menu->setEnabled(AreaIsPinnable);
|
menu->setEnabled(AreaIsPinnable);
|
||||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||||
@@ -801,27 +769,28 @@ QMenu* CDockAreaTitleBar::buildContextMenu(QMenu *Menu)
|
|||||||
d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu);
|
d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Menu->addSeparator();
|
Menu.addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAutoHide)
|
if (isAutoHide)
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(tr("Minimize"), this, SLOT(minimizeAutoHideContainer()));
|
Action = Menu.addAction(tr("Minimize"), this, SLOT(minimizeAutoHideContainer()));
|
||||||
Action = Menu->addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered()));
|
Action = Menu.addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||||
if (!isAutoHide && !isTopLevelArea)
|
if (!isAutoHide && !isTopLevelArea)
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
Action = Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||||
}
|
}
|
||||||
return Menu;
|
Menu.exec(ev->globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTitleBar::insertWidget(int index, QWidget *widget)
|
void CDockAreaTitleBar::insertWidget(int index, QWidget *widget)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,11 +152,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual void contextMenuEvent(QContextMenuEvent *event) override;
|
virtual void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle resize events
|
|
||||||
*/
|
|
||||||
virtual void resizeEvent(QResizeEvent *event) override;
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Call this slot to tell the title bar that it should update the tabs menu
|
* Call this slot to tell the title bar that it should update the tabs menu
|
||||||
@@ -249,20 +244,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isAutoHide() const;
|
bool isAutoHide() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills the provided menu with standard entries. If a nullptr is passed, a
|
|
||||||
* new menu is created and filled with standard entries.
|
|
||||||
* This function is called from the actual version of contextMenuEvent, but
|
|
||||||
* can be called from any code. Caller is responsible of deleting the created
|
|
||||||
* object.
|
|
||||||
*
|
|
||||||
* @param menu The QMenu to fill with standard entries. If nullptr, a new
|
|
||||||
* QMenu will be created.
|
|
||||||
* @return The filled QMenu, either the provided one or a newly created one if
|
|
||||||
* nullptr was passed.
|
|
||||||
*/
|
|
||||||
virtual QMenu *buildContextMenu(QMenu *);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if a tab in the tab bar is clicked by the user
|
* This signal is emitted if a tab in the tab bar is clicked by the user
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QWheelEvent>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
|
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
|
||||||
QT_FORWARD_DECLARE_CLASS(QAbstractButton)
|
QT_FORWARD_DECLARE_CLASS(QAbstractButton)
|
||||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,7 +48,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QWindowStateChangeEvent>
|
#include <QWindowStateChangeEvent>
|
||||||
#include <QVector>
|
|
||||||
|
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "DockOverlay.h"
|
#include "DockOverlay.h"
|
||||||
@@ -95,7 +94,6 @@ enum eStateFileVersion
|
|||||||
|
|
||||||
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig;
|
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig;
|
||||||
static CDockManager::AutoHideFlags StaticAutoHideConfigFlags; // auto hide feature is disabled by default
|
static CDockManager::AutoHideFlags StaticAutoHideConfigFlags; // auto hide feature is disabled by default
|
||||||
static QVector<QVariant> StaticConfigParams(CDockManager::ConfigParamCount);
|
|
||||||
|
|
||||||
static QString FloatingContainersTitle;
|
static QString FloatingContainersTitle;
|
||||||
|
|
||||||
@@ -1477,20 +1475,6 @@ CDockWidget::DockWidgetFeatures CDockManager::globallyLockedDockWidgetFeatures()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
void CDockManager::setConfigParam(CDockManager::eConfigParam Param, QVariant Value)
|
|
||||||
{
|
|
||||||
StaticConfigParams[Param] = Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
QVariant CDockManager::configParam(eConfigParam Param, QVariant Default)
|
|
||||||
{
|
|
||||||
return StaticConfigParams[Param].isValid() ? StaticConfigParams[Param] : Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -254,7 +254,6 @@ public:
|
|||||||
AutoHideCloseButtonCollapsesDock = 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
|
AutoHideCloseButtonCollapsesDock = 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
|
||||||
AutoHideHasCloseButton = 0x80, //< If the flag is set an auto hide title bar has a close button
|
AutoHideHasCloseButton = 0x80, //< If the flag is set an auto hide title bar has a close button
|
||||||
AutoHideHasMinimizeButton = 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
|
AutoHideHasMinimizeButton = 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
|
||||||
AutoHideOpenOnDragHover = 0x200, ///< if this flag is set, dragging hover the tab bar will open the dock
|
|
||||||
|
|
||||||
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
||||||
| DockAreaHasAutoHideButton
|
| DockAreaHasAutoHideButton
|
||||||
@@ -263,15 +262,6 @@ public:
|
|||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
|
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
|
||||||
|
|
||||||
/**
|
|
||||||
* Global configuration parameters that you can set via setConfigParam()
|
|
||||||
*/
|
|
||||||
enum eConfigParam
|
|
||||||
{
|
|
||||||
AutoHideOpenOnDragHoverDelay_ms, ///< Delay in ms before the dock opens on drag hover if AutoHideOpenOnDragHover flag is set
|
|
||||||
ConfigParamCount // just a delimiter to count number of config params
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor.
|
* Default Constructor.
|
||||||
@@ -333,17 +323,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
static bool testAutoHideConfigFlag(eAutoHideFlag Flag);
|
static bool testAutoHideConfigFlag(eAutoHideFlag Flag);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value for the given config parameter
|
|
||||||
*/
|
|
||||||
static void setConfigParam(eConfigParam Param, QVariant Value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value for the given config parameter or the default value
|
|
||||||
* if the parameter is not set.
|
|
||||||
*/
|
|
||||||
static QVariant configParam(eConfigParam Param, QVariant Default);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the global icon provider.
|
* Returns the global icon provider.
|
||||||
* The icon provider enables the use of custom icons in case using
|
* The icon provider enables the use of custom icons in case using
|
||||||
|
|||||||
@@ -529,34 +529,26 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Menu = buildContextMenu(nullptr);
|
|
||||||
d->saveDragStartMousePosition(ev->globalPos());
|
d->saveDragStartMousePosition(ev->globalPos());
|
||||||
Menu->exec(ev->globalPos());
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu* CDockWidgetTab::buildContextMenu(QMenu *Menu)
|
|
||||||
{
|
|
||||||
if (Menu == nullptr) {
|
|
||||||
Menu = new QMenu(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
|
const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
|
||||||
const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget();
|
const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget();
|
||||||
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
||||||
const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
|
const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
|
||||||
QAction* Action;
|
QAction* Action;
|
||||||
|
QMenu Menu(this);
|
||||||
|
|
||||||
if (!isTopLevelArea)
|
if (!isTopLevelArea)
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||||
Action->setEnabled(isDetachable);
|
Action->setEnabled(isDetachable);
|
||||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(tr("Pin"), this, SLOT(autoHideDockWidget()));
|
Action = Menu.addAction(tr("Pin"), this, SLOT(autoHideDockWidget()));
|
||||||
auto IsPinnable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable);
|
auto IsPinnable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||||
Action->setEnabled(IsPinnable);
|
Action->setEnabled(IsPinnable);
|
||||||
|
|
||||||
auto menu = Menu->addMenu(tr("Pin To..."));
|
auto menu = Menu.addMenu(tr("Pin To..."));
|
||||||
menu->setEnabled(IsPinnable);
|
menu->setEnabled(IsPinnable);
|
||||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||||
@@ -565,16 +557,17 @@ QMenu* CDockWidgetTab::buildContextMenu(QMenu *Menu)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu->addSeparator();
|
Menu.addSeparator();
|
||||||
Action = Menu->addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||||
Action->setEnabled(isClosable());
|
Action->setEnabled(isClosable());
|
||||||
if (d->DockArea->openDockWidgetsCount() > 1)
|
if (d->DockArea->openDockWidgetsCount() > 1)
|
||||||
{
|
{
|
||||||
Action = Menu->addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
Action = Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
||||||
}
|
}
|
||||||
|
Menu.exec(ev->globalPos());
|
||||||
return Menu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidgetTab::isActiveTab() const
|
bool CDockWidgetTab::isActiveTab() const
|
||||||
{
|
{
|
||||||
@@ -796,13 +789,6 @@ bool CDockWidgetTab::event(QEvent *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
eDragState CDockWidgetTab::dragState() const
|
|
||||||
{
|
|
||||||
return d->DragState;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTab::onDockWidgetFeaturesChanged()
|
void CDockWidgetTab::onDockWidgetFeaturesChanged()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,8 +35,6 @@
|
|||||||
|
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
class CDockWidget;
|
class CDockWidget;
|
||||||
@@ -180,26 +178,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setIconSize(const QSize& Size);
|
void setIconSize(const QSize& Size);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current drag state of this tab.
|
|
||||||
* Use this function to determine if the tab is currently being dragged
|
|
||||||
*/
|
|
||||||
eDragState dragState() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills the provided menu with standard entries. If a nullptr is passed, a
|
|
||||||
* new menu is created and filled with standard entries.
|
|
||||||
* This function is called from the actual version of contextMenuEvent, but
|
|
||||||
* can be called from any code. Caller is responsible of deleting the created
|
|
||||||
* object.
|
|
||||||
*
|
|
||||||
* @param menu The QMenu to fill with standard entries. If nullptr, a new
|
|
||||||
* QMenu will be created.
|
|
||||||
* @return The filled QMenu, either the provided one or a newly created one if
|
|
||||||
* nullptr was passed.
|
|
||||||
*/
|
|
||||||
virtual QMenu *buildContextMenu(QMenu *);
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void setVisible(bool visible) override;
|
virtual void setVisible(bool visible) override;
|
||||||
|
|
||||||
|
|||||||
@@ -1331,8 +1331,7 @@ void CFloatingDockContainer::onMaximizeRequest()
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::showNormal(bool fixGeometry)
|
void CFloatingDockContainer::showNormal(bool fixGeometry)
|
||||||
{
|
{
|
||||||
if ( (windowState() & Qt::WindowMaximized) != 0 ||
|
if (windowState() == Qt::WindowMaximized)
|
||||||
(windowState() & Qt::WindowFullScreen) != 0)
|
|
||||||
{
|
{
|
||||||
QRect oldNormal = normalGeometry();
|
QRect oldNormal = normalGeometry();
|
||||||
Super::showNormal();
|
Super::showNormal();
|
||||||
|
|||||||
@@ -131,6 +131,15 @@ protected:
|
|||||||
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
eDragState DragState, QWidget* MouseEventHandler) override;
|
eDragState DragState, QWidget* MouseEventHandler) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this function to start dragging the floating widget
|
||||||
|
*/
|
||||||
|
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
|
QWidget* MouseEventHandler)
|
||||||
|
{
|
||||||
|
startFloating(DragStartMousePos, Size, DraggingFloatingWidget, MouseEventHandler);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this function if you explicitly want to signal that dragging has
|
* Call this function if you explicitly want to signal that dragging has
|
||||||
* finished
|
* finished
|
||||||
@@ -140,7 +149,7 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* This function deletes all dock widgets in it.
|
* This function deletes all dock widgets in it.
|
||||||
* This functions should be called only from dock manager in its
|
* This functions should be called only from dock manager in its
|
||||||
* destructor before deleting the floating widget
|
* destructor before deleting the floating widget
|
||||||
*/
|
*/
|
||||||
void deleteContent();
|
void deleteContent();
|
||||||
|
|
||||||
@@ -227,15 +236,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
CDockContainerWidget* dockContainer() const;
|
CDockContainerWidget* dockContainer() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Call this function to start dragging the floating widget
|
|
||||||
*/
|
|
||||||
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
|
||||||
QWidget* MouseEventHandler)
|
|
||||||
{
|
|
||||||
startFloating(DragStartMousePos, Size, DraggingFloatingWidget, MouseEventHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns true, if it can be closed.
|
* This function returns true, if it can be closed.
|
||||||
* It can be closed, if all dock widgets in all dock areas can be closed
|
* It can be closed, if all dock widgets in all dock areas can be closed
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ enum SideBarLocation
|
|||||||
SideBarBottom,
|
SideBarBottom,
|
||||||
SideBarNone
|
SideBarNone
|
||||||
};
|
};
|
||||||
Q_ENUMS(SideBarLocation)
|
Q_ENUMS(SideBarLocation);
|
||||||
|
|
||||||
|
|
||||||
namespace internal
|
namespace internal
|
||||||
|
|||||||
Reference in New Issue
Block a user