Compare commits
33 Commits
4.2.0
...
openglwidg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e38212eade | ||
|
|
8eb200b9a9 | ||
|
|
5af55c1258 | ||
|
|
ae7d6cc655 | ||
|
|
8da0713bf0 | ||
|
|
08da925fde | ||
|
|
fb58c435ef | ||
|
|
6bf593ef4b | ||
|
|
6b3b7750cb | ||
|
|
541db8e214 | ||
|
|
644c828f00 | ||
|
|
ed6636ae26 | ||
|
|
1a543e946d | ||
|
|
9bdefd6055 | ||
|
|
8fd691968c | ||
|
|
7abc698d09 | ||
|
|
5b23248fb8 | ||
|
|
46a5cee9c9 | ||
|
|
6c2c9888be | ||
|
|
44ff9e9956 | ||
|
|
f848df74c3 | ||
|
|
6c98c29855 | ||
|
|
c34d479d5c | ||
|
|
a7a97e6978 | ||
|
|
ec018a4c70 | ||
|
|
0fabebb0fe | ||
|
|
521e1fbe39 | ||
|
|
5f2aeaef00 | ||
|
|
818e568f4a | ||
|
|
5d6831d179 | ||
|
|
a2c94c16b5 | ||
|
|
68f1084bf0 | ||
|
|
761bfc50d6 |
146
.clang-format
Normal file
146
.clang-format
Normal file
@@ -0,0 +1,146 @@
|
||||
---
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: AfterColon
|
||||
BreakStringLiterals: true
|
||||
|
||||
ColumnLimit: 82
|
||||
CommentPragmas: '^(!.*|@c)'
|
||||
|
||||
CompactNamespaces: false
|
||||
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
|
||||
FixNamespaceComments: true
|
||||
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^<windows(\.h)?>' # windows headers
|
||||
Priority: -1
|
||||
- Regex: '^<labbcan[[:alnum:]._/]+' # labbcan headers
|
||||
Priority: 1
|
||||
- Regex: '^<diag[[:alnum:]._/]+' # usl headers
|
||||
Priority: 1
|
||||
- Regex: '^<usl[[:alnum:]._/]+' # usl headers
|
||||
Priority: 1
|
||||
- Regex: '^<qt5compat[[:alnum:]._/]+' # qtlabb headers
|
||||
Priority: 2
|
||||
- Regex: '^<qtcoreaddons[[:alnum:]._/]+' # qtlabb headers
|
||||
Priority: 2
|
||||
- Regex: '^<qtlabb[[:alnum:]._/]+' # qtlabb headers
|
||||
Priority: 2
|
||||
- Regex: '<Q[[:alnum:].]+>' # Qt headers
|
||||
Priority: 3
|
||||
- Regex: '^<sila_cpp[[:alnum:]._/]+' # sila_cpp headers
|
||||
Priority: 4
|
||||
- Regex: '<[[:alnum:]._/]+\.h>' # other headers
|
||||
Priority: 5
|
||||
- Regex: '<[[:alnum:]._/]+>' # system headers
|
||||
Priority: 6
|
||||
- Regex: '.*'
|
||||
Priority: 7
|
||||
|
||||
IncludeIsMainRegex: '(_p)?$'
|
||||
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
|
||||
NamespaceIndentation: None
|
||||
|
||||
PenaltyBreakAssignment: 20
|
||||
PenaltyBreakBeforeFirstCallParameter: 15
|
||||
PenaltyBreakComment: 10
|
||||
PenaltyBreakFirstLessLess: 5
|
||||
# PenaltyBreakOpenParenthesis: 30
|
||||
PenaltyBreakString: 150
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 100
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 150
|
||||
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
|
||||
SortIncludes: CaseSensitive
|
||||
SortUsingDeclarations: true
|
||||
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: Never
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
|
||||
Standard: c++17
|
||||
|
||||
StatementMacros: [ 'Q_UNUSED', 'PIMPL_D', 'PIMPL_Q', 'OD_ENTRY', 'OD_ENTRY_PROCIMG' ]
|
||||
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
*.pro.user
|
||||
*.pro.user*
|
||||
/build
|
||||
*.o
|
||||
*.dylib
|
||||
@@ -7,6 +7,10 @@ qrc_*
|
||||
moc_*
|
||||
ui_*
|
||||
Makefile
|
||||
*.dll
|
||||
*.a
|
||||
build-*
|
||||
build_*
|
||||
|
||||
# IDEs
|
||||
.idea
|
||||
|
||||
@@ -368,7 +368,7 @@ The application can be compiled for macOS. A user reported, that the library wor
|
||||
[](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
|
||||
[](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/actions?query=workflow%3Alinux-builds)
|
||||
|
||||
Unfortunately, there is no such thing as a Linux operating system. Linux is a heterogeneous environment with a variety of different distributions. So it is not possible to support "Linux" like this is possible for Windows. It is only possible to support and test a small subset of Linux distributions. The library can be compiled for and has been developed and tested with the some Linux distributions. Depending on the used window manager or compositor, dock widgets
|
||||
Unfortunately, there is no such thing as a Linux operating system. Linux is a heterogeneous environment with a variety of different distributions. So it is not possible to support "Linux" like it is possible for Windows. It is only possible to support and test a small subset of Linux distributions. The library can be compiled for and has been developed and tested with some Linux distributions. Depending on the used window manager or compositor, dock widgets
|
||||
with native title bars are supported or not. If native title bars are not supported,
|
||||
the library switches to `QWidget` based title bars.
|
||||
|
||||
|
||||
@@ -64,6 +64,15 @@
|
||||
#include <QElapsedTimer>
|
||||
#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)
|
||||
#include <QRandomGenerator>
|
||||
@@ -85,6 +94,7 @@
|
||||
#include "StatusDialog.h"
|
||||
#include "DockSplitter.h"
|
||||
#include "ImageViewer.h"
|
||||
#include "glwidget.h"
|
||||
|
||||
|
||||
|
||||
@@ -592,19 +602,29 @@ void MainWindowPrivate::createActions()
|
||||
ui.toolBar->addAction(ui.actionRestoreState);
|
||||
ui.actionRestoreState->setIcon(svgIcon(":/adsdemo/images/restore.svg"));
|
||||
|
||||
SavePerspectiveAction = new QAction("Create Perspective", _this);
|
||||
SavePerspectiveAction->setIcon(svgIcon(":/adsdemo/images/picture_in_picture.svg"));
|
||||
_this->connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
|
||||
ui.toolBar->addSeparator();
|
||||
|
||||
QAction* a = ui.toolBar->addAction("Lock Workspace");
|
||||
a->setIcon(svgIcon(":/adsdemo/images/lock_outline.svg"));
|
||||
a->setCheckable(true);
|
||||
a->setChecked(false);
|
||||
QObject::connect(a, &QAction::triggered, _this, &CMainWindow::lockWorkspace);
|
||||
|
||||
PerspectiveListAction = new QWidgetAction(_this);
|
||||
PerspectiveComboBox = new QComboBox(_this);
|
||||
PerspectiveComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
PerspectiveListAction->setDefaultWidget(PerspectiveComboBox);
|
||||
ui.toolBar->addSeparator();
|
||||
ui.toolBar->addAction(PerspectiveListAction);
|
||||
|
||||
a = SavePerspectiveAction = ui.toolBar->addAction("Create Perspective");
|
||||
a->setIcon(svgIcon(":/adsdemo/images/picture_in_picture.svg"));
|
||||
QObject::connect(a, &QAction::triggered, _this, &CMainWindow::savePerspective);
|
||||
ui.toolBar->addAction(SavePerspectiveAction);
|
||||
|
||||
QAction* a = ui.toolBar->addAction("Create Floating Editor");
|
||||
ui.toolBar->addSeparator();
|
||||
|
||||
a = ui.toolBar->addAction("Create Floating Editor");
|
||||
a->setProperty("Floating", true);
|
||||
a->setToolTip("Creates floating dynamic dockable editor windows that are deleted on close");
|
||||
a->setIcon(svgIcon(":/adsdemo/images/note_add.svg"));
|
||||
@@ -626,6 +646,7 @@ void MainWindowPrivate::createActions()
|
||||
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
|
||||
ui.menuTests->addAction(a);
|
||||
|
||||
ui.toolBar->addSeparator();
|
||||
a = ui.toolBar->addAction("Create Floating Table");
|
||||
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
|
||||
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
||||
@@ -647,6 +668,30 @@ void MainWindowPrivate::createActions()
|
||||
a = Menu->addAction("Pinned Image Viewer");
|
||||
_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();
|
||||
a = ui.menuTests->addAction("Show Status Dialog");
|
||||
@@ -655,12 +700,6 @@ void MainWindowPrivate::createActions()
|
||||
a = ui.menuTests->addAction("Toggle Label 0 Window Title");
|
||||
_this->connect(a, SIGNAL(triggered()), SLOT(toggleDockWidgetWindowTitle()));
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -713,6 +752,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
d->ui.setupUi(this);
|
||||
setWindowTitle(QApplication::instance()->applicationName());
|
||||
d->createActions();
|
||||
SoQt::init(this);
|
||||
SoDB::init();
|
||||
SIM::Coin3D::Quarter::Quarter::init();
|
||||
|
||||
// uncomment the following line if the tab close button should be
|
||||
// a QToolButton instead of a QPushButton
|
||||
@@ -1030,3 +1072,88 @@ void CMainWindow::createImageViewer()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::lockWorkspace(bool Value)
|
||||
{
|
||||
if (Value)
|
||||
{
|
||||
d->DockManager->lockDockWidgetFeaturesGlobally();
|
||||
}
|
||||
else
|
||||
{
|
||||
d->DockManager->lockDockWidgetFeaturesGlobally(ads::CDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,10 @@ private slots:
|
||||
void toggleDockWidgetWindowTitle();
|
||||
void applyVsStyle();
|
||||
void createImageViewer();
|
||||
void lockWorkspace(bool Value);
|
||||
void createOpenGlWidget();
|
||||
void createCoin3DViewer();
|
||||
void createQuarterViewer();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||
|
||||
|
||||
TARGET = AdvancedDockingSystemDemo
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
QT += core gui widgets quick quickwidgets
|
||||
QT += core gui widgets quick quickwidgets opengl
|
||||
|
||||
include(../ads.pri)
|
||||
|
||||
@@ -10,6 +11,8 @@ lessThan(QT_MAJOR_VERSION, 6) {
|
||||
win32 {
|
||||
QT += axcontainer
|
||||
}
|
||||
} else {
|
||||
QT += openglwidgets
|
||||
}
|
||||
|
||||
CONFIG += c++14
|
||||
@@ -26,14 +29,19 @@ HEADERS += \
|
||||
MainWindow.h \
|
||||
StatusDialog.h \
|
||||
ImageViewer.h \
|
||||
RenderWidget.h
|
||||
RenderWidget.h \
|
||||
glwidget.h \
|
||||
logo.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
MainWindow.cpp \
|
||||
StatusDialog.cpp \
|
||||
ImageViewer.cpp \
|
||||
RenderWidget.cpp
|
||||
RenderWidget.cpp \
|
||||
glwidget.cpp \
|
||||
logo.cpp
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
@@ -47,3 +55,24 @@ LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||
|
||||
INCLUDEPATH += ../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
|
||||
|
||||
@@ -36,5 +36,10 @@
|
||||
<file>images/panorama.svg</file>
|
||||
<file>images/ads_icon2.svg</file>
|
||||
<file>images/font_download.svg</file>
|
||||
<file>images/lock_outline.svg</file>
|
||||
<file>images/lock.svg</file>
|
||||
<file>images/lock_open.svg</file>
|
||||
<file>images/deployed_code.svg</file>
|
||||
<file>images/category.svg</file>
|
||||
</qresource>
|
||||
</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 |
6
demo/images/lock.svg
Normal file
6
demo/images/lock.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||
<desc>lock 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>
|
||||
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||
<path d="M853.33,426.67v426.66c0,46.93 -38.4,85.34 -85.33,85.34h-512c-46.93,0 -85.33,-38.41 -85.33,-85.34v-426.66c0,-46.93 38.4,-85.34 85.33,-85.34h42.67v-85.33c0,-117.76 95.57,-213.33 213.33,-213.33c117.76,0 213.33,95.57 213.33,213.33v85.33h42.67c46.93,0 85.33,38.41 85.33,85.34zM644.27,256c0,-72.96 -59.31,-132.27 -132.27,-132.27c-72.96,0 -132.27,59.31 -132.27,132.27v85.33h264.54zM597.33,640c0,-46.93 -38.4,-85.33 -85.33,-85.33c-46.93,0 -85.33,38.4 -85.33,85.33c0,46.93 38.4,85.33 85.33,85.33c46.93,0 85.33,-38.4 85.33,-85.33z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 932 B |
6
demo/images/lock_open.svg
Normal file
6
demo/images/lock_open.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||
<desc>lock_open 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>
|
||||
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||
<path d="M853.33,426.67v426.66c0,46.93 -38.4,85.34 -85.33,85.34h-512c-46.93,0 -85.33,-38.41 -85.33,-85.34v-426.66c0,-46.93 38.4,-85.34 85.33,-85.34h388.27v-85.33c0,-72.96 -59.31,-132.27 -132.27,-132.27c-72.96,0 -132.27,59.31 -132.27,132.27h-81.06c0,-117.76 95.57,-213.33 213.33,-213.33c117.76,0 213.33,95.57 213.33,213.33v85.33h42.67c46.93,0 85.33,38.41 85.33,85.34zM768,426.67h-512v426.66h512zM426.67,640c0,-46.93 38.4,-85.33 85.33,-85.33c46.93,0 85.33,38.4 85.33,85.33c0,46.93 -38.4,85.33 -85.33,85.33c-46.93,0 -85.33,-38.4 -85.33,-85.33z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 948 B |
6
demo/images/lock_outline.svg
Normal file
6
demo/images/lock_outline.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||
<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>
|
||||
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||
<path d="M853.33,426.67v426.66c0,46.93 -38.4,85.34 -85.33,85.34h-512c-46.93,0 -85.33,-38.41 -85.33,-85.34v-426.66c0,-46.93 38.4,-85.34 85.33,-85.34h42.67v-85.33c0,-117.76 95.57,-213.33 213.33,-213.33c117.76,0 213.33,95.57 213.33,213.33v85.33h42.67c46.93,0 85.33,38.41 85.33,85.34zM768,426.67h-512v426.66h512zM379.73,341.33h264.54v-85.33c0,-72.96 -59.31,-132.27 -132.27,-132.27c-72.96,0 -132.27,59.31 -132.27,132.27zM426.67,640c0,-46.93 38.4,-85.33 85.33,-85.33c46.93,0 85.33,38.4 85.33,85.33c0,46.93 -38.4,85.33 -85.33,85.33c-46.93,0 -85.33,-38.4 -85.33,-85.33z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 972 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 <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QQuickWindow>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -41,7 +42,8 @@ int main(int argc, char *argv[])
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
#endif
|
||||
std::shared_ptr<int> b;
|
||||
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
|
||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
QApplication a(argc, argv);
|
||||
a.setApplicationName("Advanced Docking System Demo");
|
||||
a.setQuitOnLastWindowClosed(true);
|
||||
|
||||
@@ -12,10 +12,10 @@ styles as much as possible.
|
||||
|
||||
## Features
|
||||
|
||||
### Docking everywhere - no central widget
|
||||
### Docking everywhere - with or without a central widget
|
||||
|
||||
There is no central widget like in the Qt docking system. You can dock on every
|
||||
border of the main window or you can dock into each dock area - so you are
|
||||
The Advanced Docking System works with or without a central widget.
|
||||
You can dock on every border of the main window or you can dock into each dock area - so you are
|
||||
free to dock almost everywhere.
|
||||
|
||||

|
||||
|
||||
BIN
doc/cfg_flag_ShowTabTextOnlyForActiveTab_true.png
Normal file
BIN
doc/cfg_flag_ShowTabTextOnlyForActiveTab_true.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -28,6 +28,7 @@
|
||||
- [`FloatingContainerForceQWidgetTitleBar` (Linux only)](#floatingcontainerforceqwidgettitlebar-linux-only)
|
||||
- [`MiddleMouseButtonClosesTab`](#middlemousebuttonclosestab)
|
||||
- [`DisableTabTextEliding`](#disabletabtexteliding)
|
||||
- [`ShowTabTextOnlyForActiveTab`](#showtabtextonlyforactivetab)
|
||||
- [Auto-Hide Configuration Flags](#auto-hide-configuration-flags)
|
||||
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
|
||||
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
|
||||
@@ -302,8 +303,9 @@ or to close it via the close button.
|
||||
|
||||

|
||||
|
||||
The Advanced Docking System is meant for applications without a static central
|
||||
widget and normally does not know anything about a central static widget.
|
||||
Unless a central widget explicitly has been set with setCentralWidget, the
|
||||
Advanced Docking System is without a static central widget and it wouldn't know
|
||||
about a central static widget.
|
||||
Therefore this flag is disabled by default and a central single dock widget
|
||||
still has a titlebar to drag it out of the main window.
|
||||
|
||||
@@ -486,6 +488,13 @@ many tabs as possible even if there is not much space:
|
||||
|
||||

|
||||
|
||||
### `ShowTabTextOnlyForActiveTab`
|
||||
|
||||
Set this flag (default = false) to show label texts in dock area tabs only
|
||||
for active tabs. Inactive tabs only show their icon:
|
||||
|
||||

|
||||
|
||||
## Auto-Hide Configuration Flags
|
||||
|
||||
### Auto Hide Dock Widgets
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <QApplication>
|
||||
#include "../../examples/simple/MainWindow.h"
|
||||
#include "mainframe.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QSplitter>
|
||||
#include "AutoHideTab.h"
|
||||
|
||||
class QXmlStreamWriter;
|
||||
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
|
||||
|
||||
namespace ads
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "ads_globals.h"
|
||||
#include "AutoHideTab.h"
|
||||
|
||||
class QXmlStreamWriter;
|
||||
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
|
||||
|
||||
namespace ads
|
||||
{
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
|
||||
namespace ads
|
||||
{
|
||||
static const char* const LocationProperty = "Location";
|
||||
|
||||
/**
|
||||
* Private data class of CDockWidgetTab class (pimpl)
|
||||
@@ -102,7 +101,7 @@ struct AutoHideTabPrivate
|
||||
QMenu* Menu)
|
||||
{
|
||||
auto Action = Menu->addAction(Title);
|
||||
Action->setProperty("Location", Location);
|
||||
Action->setProperty(internal::LocationProperty, Location);
|
||||
QObject::connect(Action, &QAction::triggered, _this, &CAutoHideTab::onAutoHideToActionClicked);
|
||||
Action->setEnabled(Location != _this->sideBarLocation());
|
||||
return Action;
|
||||
@@ -174,7 +173,7 @@ void AutoHideTabPrivate::updateOrientation()
|
||||
bool AutoHideTabPrivate::startFloating(eDragState DraggingState)
|
||||
{
|
||||
auto DockArea = DockWidget->dockAreaWidget();
|
||||
ADS_PRINT("isFloating " << dockContainer->isFloating());
|
||||
ADS_PRINT("isFloating " << dockContainer()->isFloating());
|
||||
|
||||
ADS_PRINT("startFloating");
|
||||
DragState = DraggingState;
|
||||
@@ -419,7 +418,7 @@ void CAutoHideTab::unpinDockWidget()
|
||||
//===========================================================================
|
||||
void CAutoHideTab::onAutoHideToActionClicked()
|
||||
{
|
||||
int Location = sender()->property(LocationProperty).toInt();
|
||||
int Location = sender()->property(internal::LocationProperty).toInt();
|
||||
d->DockWidget->setAutoHide(true, (SideBarLocation)Location);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ set(ads_SRCS
|
||||
AutoHideTab.cpp
|
||||
AutoHideDockContainer.cpp
|
||||
PushButton.cpp
|
||||
ResizeHandle.cpp
|
||||
ResizeHandle.cpp
|
||||
ads.qrc
|
||||
)
|
||||
set(ads_HEADERS
|
||||
@@ -62,7 +62,7 @@ set(ads_HEADERS
|
||||
AutoHideTab.h
|
||||
AutoHideDockContainer.h
|
||||
PushButton.h
|
||||
ResizeHandle.h
|
||||
ResizeHandle.h
|
||||
)
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
||||
if (UNIX AND NOT APPLE)
|
||||
@@ -120,7 +120,7 @@ write_basic_package_version_file(
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
install(FILES ${ads_HEADERS}
|
||||
DESTINATION include/${library_name}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${library_name}
|
||||
COMPONENT headers
|
||||
)
|
||||
install(FILES
|
||||
@@ -131,25 +131,25 @@ install(FILES
|
||||
)
|
||||
install(TARGETS ${library_name}
|
||||
EXPORT adsTargets
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
INCLUDES DESTINATION include/${library_name}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${library_name}
|
||||
)
|
||||
|
||||
install(EXPORT adsTargets
|
||||
FILE adsTargets.cmake
|
||||
NAMESPACE ads::
|
||||
DESTINATION lib/cmake/${library_name}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name}
|
||||
)
|
||||
install(FILES qtadvanceddockingConfig.cmake RENAME ${library_name}Config.cmake
|
||||
DESTINATION lib/cmake/${library_name}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name}
|
||||
)
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${library_name}ConfigVersion.cmake"
|
||||
DESTINATION lib/cmake/${library_name}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${library_name}
|
||||
)
|
||||
|
||||
target_include_directories(${library_name} PUBLIC
|
||||
$<INSTALL_INTERFACE:include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
)
|
||||
|
||||
@@ -111,8 +111,9 @@ void DockAreaTabBarPrivate::updateTabs()
|
||||
// Sometimes the synchronous calculation of the rectangular area fails
|
||||
// Therefore we use QTimer::singleShot here to execute the call
|
||||
// within the event loop - see #520
|
||||
QTimer::singleShot(0, [&, TabWidget]{
|
||||
_this->ensureWidgetVisible(TabWidget);
|
||||
QTimer::singleShot(0, TabWidget, [&, TabWidget]
|
||||
{
|
||||
_this->ensureWidgetVisible(TabWidget);
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
|
||||
namespace ads
|
||||
{
|
||||
static const char* const LocationProperty = "Location";
|
||||
|
||||
/**
|
||||
* Private data class of CDockAreaTitleBar class (pimpl)
|
||||
@@ -159,7 +158,7 @@ struct DockAreaTitleBarPrivate
|
||||
QMenu* Menu)
|
||||
{
|
||||
auto Action = Menu->addAction(Title);
|
||||
Action->setProperty("Location", Location);
|
||||
Action->setProperty(internal::LocationProperty, Location);
|
||||
QObject::connect(Action, &QAction::triggered, _this, &CDockAreaTitleBar::onAutoHideToActionClicked);
|
||||
return Action;
|
||||
}
|
||||
@@ -179,7 +178,8 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
|
||||
// Tabs menu button
|
||||
TabsMenuButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasTabsMenuButton));
|
||||
TabsMenuButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasTabsMenuButton),
|
||||
false, TitleBarButtonTabsMenu);
|
||||
TabsMenuButton->setObjectName("tabsMenuButton");
|
||||
TabsMenuButton->setAutoRaise(true);
|
||||
TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
|
||||
@@ -197,7 +197,8 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
SLOT(onTabsMenuActionTriggered(QAction*)));
|
||||
|
||||
// Undock button
|
||||
UndockButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasUndockButton));
|
||||
UndockButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasUndockButton),
|
||||
true, TitleBarButtonUndock);
|
||||
UndockButton->setObjectName("detachGroupButton");
|
||||
UndockButton->setAutoRaise(true);
|
||||
internal::setToolTip(UndockButton, QObject::tr("Detach Group"));
|
||||
@@ -208,7 +209,8 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
|
||||
// AutoHide Button
|
||||
const auto autoHideEnabled = testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled);
|
||||
AutoHideButton = new CTitleBarButton(testAutoHideConfigFlag(CDockManager::DockAreaHasAutoHideButton) && autoHideEnabled);
|
||||
AutoHideButton = new CTitleBarButton(testAutoHideConfigFlag(CDockManager::DockAreaHasAutoHideButton) && autoHideEnabled,
|
||||
true, TitleBarButtonAutoHide);
|
||||
AutoHideButton->setObjectName("dockAreaAutoHideButton");
|
||||
AutoHideButton->setAutoRaise(true);
|
||||
internal::setToolTip(AutoHideButton, _this->titleBarButtonToolTip(TitleBarButtonAutoHide));
|
||||
@@ -220,7 +222,8 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
_this->connect(AutoHideButton, SIGNAL(clicked()), SLOT(onAutoHideButtonClicked()));
|
||||
|
||||
// Minimize button
|
||||
MinimizeButton = new CTitleBarButton(testAutoHideConfigFlag(CDockManager::AutoHideHasMinimizeButton));
|
||||
MinimizeButton = new CTitleBarButton(testAutoHideConfigFlag(CDockManager::AutoHideHasMinimizeButton),
|
||||
false, TitleBarButtonMinimize);
|
||||
MinimizeButton->setObjectName("dockAreaMinimizeButton");
|
||||
MinimizeButton->setAutoRaise(true);
|
||||
MinimizeButton->setVisible(false);
|
||||
@@ -231,7 +234,8 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
_this->connect(MinimizeButton, SIGNAL(clicked()), SLOT(minimizeAutoHideContainer()));
|
||||
|
||||
// Close button
|
||||
CloseButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasCloseButton));
|
||||
CloseButton = new CTitleBarButton(testConfigFlag(CDockManager::DockAreaHasCloseButton),
|
||||
true, TitleBarButtonClose);
|
||||
CloseButton->setObjectName("dockAreaCloseButton");
|
||||
CloseButton->setAutoRaise(true);
|
||||
internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
|
||||
@@ -510,7 +514,7 @@ void CDockAreaTitleBar::updateDockWidgetActionsButtons()
|
||||
int InsertIndex = indexOf(d->TabsMenuButton);
|
||||
for (auto Action : Actions)
|
||||
{
|
||||
auto Button = new CTitleBarButton(true, this);
|
||||
auto Button = new CTitleBarButton(true, false, TitleBarButtonTabsMenu, this);
|
||||
Button->setDefaultAction(Action);
|
||||
Button->setAutoRaise(true);
|
||||
Button->setPopupMode(QToolButton::InstantPopup);
|
||||
@@ -564,7 +568,7 @@ void CDockAreaTitleBar::onAutoHideDockAreaActionClicked()
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onAutoHideToActionClicked()
|
||||
{
|
||||
int Location = sender()->property(LocationProperty).toInt();
|
||||
int Location = sender()->property(internal::LocationProperty).toInt();
|
||||
d->DockArea->toggleAutoHide((SideBarLocation)Location);
|
||||
}
|
||||
|
||||
@@ -856,10 +860,25 @@ void CDockAreaTitleBar::showAutoHideControls(bool Show)
|
||||
|
||||
|
||||
//============================================================================
|
||||
CTitleBarButton::CTitleBarButton(bool showInTitleBar, QWidget* parent)
|
||||
bool CDockAreaTitleBar::isAutoHide() const
|
||||
{
|
||||
return d->DockArea && d->DockArea->isAutoHide();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* CDockAreaTitleBar::dockAreaWidget() const
|
||||
{
|
||||
return d->DockArea;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CTitleBarButton::CTitleBarButton(bool showInTitleBar, bool hideWhenDisabled, TitleBarButton ButtonId, QWidget* parent)
|
||||
: tTitleBarButton(parent),
|
||||
ShowInTitleBar(showInTitleBar),
|
||||
HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons))
|
||||
HideWhenDisabled(CDockManager::testConfigFlag(CDockManager::DockAreaHideDisabledButtons) && hideWhenDisabled),
|
||||
TitleBarButtonId(ButtonId)
|
||||
{
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
@@ -894,16 +913,47 @@ void CTitleBarButton::setShowInTitleBar(bool Show)
|
||||
//============================================================================
|
||||
bool CTitleBarButton::event(QEvent *ev)
|
||||
{
|
||||
if (QEvent::EnabledChange == ev->type() && HideWhenDisabled)
|
||||
if (QEvent::EnabledChange != ev->type() || !HideWhenDisabled || !ShowInTitleBar)
|
||||
{
|
||||
// force setVisible() call
|
||||
// Calling setVisible() directly here doesn't work well when button is expected to be shown first time
|
||||
QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection, Q_ARG(bool, isEnabled()));
|
||||
return Super::event(ev);
|
||||
}
|
||||
|
||||
bool Show = true;
|
||||
if (isInAutoHideArea())
|
||||
{
|
||||
switch (TitleBarButtonId)
|
||||
{
|
||||
case TitleBarButtonClose: Show = CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideHasCloseButton); break;
|
||||
case TitleBarButtonUndock: Show = false; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// force setVisible() call - Calling setVisible() directly here doesn't
|
||||
// work well when button is expected to be shown first time
|
||||
QMetaObject::invokeMethod(this, "setVisible", Qt::QueuedConnection,
|
||||
Q_ARG(bool, isEnabledTo(this->parentWidget()) & Show));
|
||||
|
||||
return Super::event(ev);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockAreaTitleBar* CTitleBarButton::titleBar() const
|
||||
{
|
||||
return qobject_cast<CDockAreaTitleBar*>(parentWidget());
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CTitleBarButton::isInAutoHideArea() const
|
||||
{
|
||||
auto TitleBar = titleBar();
|
||||
return TitleBar && TitleBar->isAutoHide();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CSpacerWidget::CSpacerWidget(QWidget* Parent /*= 0*/) : Super(Parent)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,7 @@ class CDockAreaTabBar;
|
||||
class CDockAreaWidget;
|
||||
struct DockAreaTitleBarPrivate;
|
||||
class CElidingLabel;
|
||||
class CDockAreaTitleBar;
|
||||
|
||||
using tTitleBarButton = QToolButton;
|
||||
|
||||
@@ -59,10 +60,12 @@ class CTitleBarButton : public tTitleBarButton
|
||||
private:
|
||||
bool ShowInTitleBar = true;
|
||||
bool HideWhenDisabled = false;
|
||||
TitleBarButton TitleBarButtonId;
|
||||
|
||||
public:
|
||||
using Super = tTitleBarButton;
|
||||
CTitleBarButton(bool ShowInTitleBar = true, QWidget* parent = nullptr);
|
||||
CTitleBarButton(bool ShowInTitleBar, bool HideWhenDisabled, TitleBarButton ButtonId,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* Adjust this visibility change request with our internal settings:
|
||||
@@ -74,6 +77,22 @@ public:
|
||||
*/
|
||||
void setShowInTitleBar(bool Show);
|
||||
|
||||
/**
|
||||
* Identifier for the title bar button
|
||||
*/
|
||||
TitleBarButton buttonId() const {return TitleBarButtonId;}
|
||||
|
||||
/**
|
||||
* Return the title bar that contains this button
|
||||
*/
|
||||
CDockAreaTitleBar* titleBar() const;
|
||||
|
||||
/**
|
||||
* Returns true, if the button is in a title bar in an auto hide area
|
||||
*/
|
||||
bool isInAutoHideArea() const;
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Handle EnabledChanged signal to set button invisible if the configured
|
||||
@@ -169,6 +188,11 @@ public:
|
||||
*/
|
||||
CElidingLabel* autoHideTitleLabel() const;
|
||||
|
||||
/**
|
||||
* Returns the dock area widget that contains this title bar
|
||||
*/
|
||||
CDockAreaWidget* dockAreaWidget() const;
|
||||
|
||||
/**
|
||||
* Updates the visibility of the dock widget actions in the title bar
|
||||
*/
|
||||
@@ -215,6 +239,11 @@ public:
|
||||
*/
|
||||
void showAutoHideControls(bool Show);
|
||||
|
||||
/**
|
||||
* Returns true, if the auto hide controls are visible
|
||||
*/
|
||||
bool isAutoHide() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted if a tab in the tab bar is clicked by the user
|
||||
|
||||
@@ -52,7 +52,7 @@ class CSpacerWidget : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Super = QWidget;
|
||||
CSpacerWidget(QWidget* Parent = 0);
|
||||
CSpacerWidget(QWidget* Parent = nullptr);
|
||||
virtual QSize sizeHint() const override {return QSize(0, 0);}
|
||||
virtual QSize minimumSizeHint() const override {return QSize(0, 0);}
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ class CDockAreaLayout
|
||||
{
|
||||
private:
|
||||
QBoxLayout* m_ParentLayout;
|
||||
QList<QWidget*> m_Widgets;
|
||||
QList<QPointer<QWidget>> m_Widgets;
|
||||
int m_CurrentIndex = -1;
|
||||
QWidget* m_CurrentWidget = nullptr;
|
||||
|
||||
@@ -370,10 +370,21 @@ void DockAreaWidgetPrivate::updateTitleBarButtonStates()
|
||||
return;
|
||||
}
|
||||
|
||||
TitleBar->button(TitleBarButtonClose)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
TitleBar->button(TitleBarButtonUndock)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
if (_this->isAutoHide())
|
||||
{
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideHasCloseButton))
|
||||
{
|
||||
TitleBar->button(TitleBarButtonClose)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TitleBar->button(TitleBarButtonUndock)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
TitleBar->button(TitleBarButtonClose)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
}
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetPinnable));
|
||||
TitleBar->updateDockWidgetActionsButtons();
|
||||
@@ -393,7 +404,7 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
|
||||
bool IsAutoHide = _this->isAutoHide();
|
||||
if (IsAutoHide)
|
||||
{
|
||||
bool ShowCloseButton = CDockManager::autoHideConfigFlags().testFlag(CDockManager::AutoHideHasCloseButton);
|
||||
bool ShowCloseButton = CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideHasCloseButton);
|
||||
TitleBar->button(TitleBarButtonClose)->setVisible(ShowCloseButton);
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
||||
TitleBar->button(TitleBarButtonUndock)->setVisible(false);
|
||||
@@ -410,7 +421,8 @@ void DockAreaWidgetPrivate::updateTitleBarButtonVisibility(bool IsTopLevel)
|
||||
else
|
||||
{
|
||||
TitleBar->button(TitleBarButtonClose)->setVisible(true);
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(true);
|
||||
bool ShowAutoHideButton = CDockManager::testAutoHideConfigFlag(CDockManager::DockAreaHasAutoHideButton);
|
||||
TitleBar->button(TitleBarButtonAutoHide)->setVisible(ShowAutoHideButton);
|
||||
TitleBar->button(TitleBarButtonUndock)->setVisible(true);
|
||||
TitleBar->button(TitleBarButtonTabsMenu)->setVisible(true);
|
||||
}
|
||||
@@ -464,6 +476,13 @@ CAutoHideDockContainer* CDockAreaWidget::autoHideDockContainer() const
|
||||
return d->AutoHideDockContainer;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockSplitter* CDockAreaWidget::parentSplitter() const
|
||||
{
|
||||
return internal::findParent<CDockSplitter*>(this);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
bool CDockAreaWidget::isAutoHide() const
|
||||
{
|
||||
@@ -600,7 +619,7 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
|
||||
this->toggleView(false);
|
||||
|
||||
// Hide empty parent splitters
|
||||
auto Splitter = internal::findParent<CDockSplitter*>(this);
|
||||
auto Splitter = parentSplitter();
|
||||
internal::hideEmptyParentSplitters(Splitter);
|
||||
|
||||
//Hide empty floating widget
|
||||
@@ -749,7 +768,7 @@ int CDockAreaWidget::openDockWidgetsCount() const
|
||||
int Count = 0;
|
||||
for (int i = 0; i < d->ContentsLayout->count(); ++i)
|
||||
{
|
||||
if (!dockWidget(i)->isClosed())
|
||||
if (dockWidget(i) && !dockWidget(i)->isClosed())
|
||||
{
|
||||
++Count;
|
||||
}
|
||||
@@ -765,7 +784,7 @@ QList<CDockWidget*> CDockAreaWidget::openedDockWidgets() const
|
||||
for (int i = 0; i < d->ContentsLayout->count(); ++i)
|
||||
{
|
||||
CDockWidget* DockWidget = dockWidget(i);
|
||||
if (!DockWidget->isClosed())
|
||||
if (DockWidget && !DockWidget->isClosed())
|
||||
{
|
||||
DockWidgetList.append(dockWidget(i));
|
||||
}
|
||||
@@ -779,7 +798,7 @@ int CDockAreaWidget::indexOfFirstOpenDockWidget() const
|
||||
{
|
||||
for (int i = 0; i < d->ContentsLayout->count(); ++i)
|
||||
{
|
||||
if (!dockWidget(i)->isClosed())
|
||||
if (dockWidget(i) && !dockWidget(i)->isClosed())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@@ -802,7 +821,6 @@ CDockWidget* CDockAreaWidget::dockWidget(int Index) const
|
||||
return qobject_cast<CDockWidget*>(d->ContentsLayout->widget(Index));
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaWidget::reorderDockWidget(int fromIndex, int toIndex)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@ class CDockContainerWidget;
|
||||
class DockContainerWidgetPrivate;
|
||||
class CDockAreaTitleBar;
|
||||
class CDockingStateReader;
|
||||
class CDockSplitter;
|
||||
|
||||
|
||||
/**
|
||||
@@ -216,6 +217,11 @@ public:
|
||||
*/
|
||||
CAutoHideDockContainer* autoHideDockContainer() const;
|
||||
|
||||
/**
|
||||
* Returns the parent splitter that contains this dock area
|
||||
*/
|
||||
CDockSplitter* parentSplitter() const;
|
||||
|
||||
/**
|
||||
* Returns true if the dock area is in an auto hide container
|
||||
*/
|
||||
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
CDockContainerWidget* _this;
|
||||
QPointer<CDockManager> DockManager;
|
||||
unsigned int zOrderIndex = 0;
|
||||
QList<CDockAreaWidget*> DockAreas;
|
||||
QList<QPointer<CDockAreaWidget>> DockAreas;
|
||||
QList<CAutoHideDockContainer*> AutoHideWidgets;
|
||||
QMap<SideBarLocation, CAutoHideSideBar*> SideTabBarWidgets;
|
||||
QGridLayout* Layout = nullptr;
|
||||
@@ -299,7 +299,11 @@ public:
|
||||
VisibleDockAreaCount = 0;
|
||||
for (auto DockArea : DockAreas)
|
||||
{
|
||||
VisibleDockAreaCount += DockArea->isHidden() ? 0 : 1;
|
||||
if (!DockArea)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
VisibleDockAreaCount += (DockArea->isHidden() ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,16 +591,7 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
||||
auto InsertParam = internal::dockAreaInsertParameters(area);
|
||||
auto NewDockAreas = FloatingContainer->findChildren<CDockAreaWidget*>(
|
||||
QString(), Qt::FindChildrenRecursively);
|
||||
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetArea);
|
||||
|
||||
if (!TargetAreaSplitter)
|
||||
{
|
||||
QSplitter* Splitter = newSplitter(InsertParam.orientation());
|
||||
Layout->replaceWidget(TargetArea, Splitter);
|
||||
Splitter->addWidget(TargetArea);
|
||||
updateSplitterHandles(Splitter);
|
||||
TargetAreaSplitter = Splitter;
|
||||
}
|
||||
auto TargetAreaSplitter = TargetArea->parentSplitter();
|
||||
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
|
||||
auto FloatingSplitter = FloatingContainer->rootSplitter();
|
||||
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
||||
@@ -742,7 +737,7 @@ void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidg
|
||||
}
|
||||
|
||||
auto InsertParam = internal::dockAreaInsertParameters(area);
|
||||
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetArea);
|
||||
auto TargetAreaSplitter = TargetArea->parentSplitter();
|
||||
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
|
||||
auto Sizes = TargetAreaSplitter->sizes();
|
||||
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
||||
@@ -877,7 +872,7 @@ void DockContainerWidgetPrivate::moveToContainer(QWidget* Widget, DockWidgetArea
|
||||
// it already has and do nothing, if it is the same place. It would
|
||||
// also work without this check, but it looks nicer with the check
|
||||
// because there will be no layout updates
|
||||
auto Splitter = internal::findParent<CDockSplitter*>(DroppedDockArea);
|
||||
auto Splitter = DroppedDockArea->parentSplitter();
|
||||
auto InsertParam = internal::dockAreaInsertParameters(area);
|
||||
if (Splitter == RootSplitter && InsertParam.orientation() == Splitter->orientation())
|
||||
{
|
||||
@@ -933,7 +928,10 @@ void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*
|
||||
//============================================================================
|
||||
void DockContainerWidgetPrivate::appendDockAreas(const QList<CDockAreaWidget*> NewDockAreas)
|
||||
{
|
||||
DockAreas.append(NewDockAreas);
|
||||
for (auto *newDockArea : NewDockAreas)
|
||||
{
|
||||
DockAreas.append(newDockArea);
|
||||
}
|
||||
for (auto DockArea : NewDockAreas)
|
||||
{
|
||||
QObject::connect(DockArea,
|
||||
@@ -1364,7 +1362,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
|
||||
NewDockArea->addDockWidget(Dockwidget);
|
||||
auto InsertParam = internal::dockAreaInsertParameters(area);
|
||||
|
||||
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetDockArea);
|
||||
auto TargetAreaSplitter = TargetDockArea->parentSplitter();
|
||||
int index = TargetAreaSplitter ->indexOf(TargetDockArea);
|
||||
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
||||
{
|
||||
@@ -1381,7 +1379,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::addDockWidgetToDockArea(DockWidgetA
|
||||
{
|
||||
ADS_PRINT("TargetAreaSplitter->orientation() != InsertParam.orientation()");
|
||||
auto TargetAreaSizes = TargetAreaSplitter->sizes();
|
||||
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
||||
auto NewSplitter = newSplitter(InsertParam.orientation());
|
||||
NewSplitter->addWidget(TargetDockArea);
|
||||
|
||||
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
||||
@@ -1572,7 +1570,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
||||
|
||||
area->disconnect(this);
|
||||
d->DockAreas.removeAll(area);
|
||||
CDockSplitter* Splitter = internal::findParent<CDockSplitter*>(area);
|
||||
auto Splitter = area->parentSplitter();
|
||||
|
||||
// Remove are from parent splitter and recursively hide tree of parent
|
||||
// splitters if it has no visible content
|
||||
@@ -1645,12 +1643,21 @@ emitAndExit:
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
QList<QPointer<CDockAreaWidget>> CDockContainerWidget::removeAllDockAreas()
|
||||
{
|
||||
auto Result = d->DockAreas;
|
||||
d->DockAreas.clear();
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* CDockContainerWidget::dockAreaAt(const QPoint& GlobalPos) const
|
||||
{
|
||||
for (const auto& DockArea : d->DockAreas)
|
||||
{
|
||||
if (DockArea->isVisible() && DockArea->rect().contains(DockArea->mapFromGlobal(GlobalPos)))
|
||||
if (DockArea && DockArea->isVisible() && DockArea->rect().contains(DockArea->mapFromGlobal(GlobalPos)))
|
||||
{
|
||||
return DockArea;
|
||||
}
|
||||
@@ -1687,7 +1694,7 @@ int CDockContainerWidget::visibleDockAreaCount() const
|
||||
int Result = 0;
|
||||
for (auto DockArea : d->DockAreas)
|
||||
{
|
||||
Result += DockArea->isHidden() ? 0 : 1;
|
||||
Result += (!DockArea || DockArea->isHidden()) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@@ -1758,7 +1765,7 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
|
||||
if (Dropped)
|
||||
{
|
||||
// Fix https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/351
|
||||
FloatingWidget->hideAndDeleteLater();
|
||||
FloatingWidget->finishDropOperation();
|
||||
|
||||
// If we dropped a floating widget with only one single dock widget, then we
|
||||
// drop a top level widget that changes from floating to docked now
|
||||
@@ -1811,7 +1818,7 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
|
||||
QList<CDockAreaWidget*> Result;
|
||||
for (auto DockArea : d->DockAreas)
|
||||
{
|
||||
if (!DockArea->isHidden())
|
||||
if (DockArea && !DockArea->isHidden())
|
||||
{
|
||||
Result.append(DockArea);
|
||||
}
|
||||
@@ -1827,7 +1834,7 @@ QList<CDockWidget*> CDockContainerWidget::openedDockWidgets() const
|
||||
QList<CDockWidget*> DockWidgetList;
|
||||
for (auto DockArea : d->DockAreas)
|
||||
{
|
||||
if (!DockArea->isHidden())
|
||||
if (DockArea && !DockArea->isHidden())
|
||||
{
|
||||
DockWidgetList.append(DockArea->openedDockWidgets());
|
||||
}
|
||||
@@ -1842,7 +1849,7 @@ bool CDockContainerWidget::hasOpenDockAreas() const
|
||||
{
|
||||
for (auto DockArea : d->DockAreas)
|
||||
{
|
||||
if (!DockArea->isHidden())
|
||||
if (DockArea && !DockArea->isHidden())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1943,7 +1950,7 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
|
||||
|
||||
|
||||
//============================================================================
|
||||
QSplitter* CDockContainerWidget::rootSplitter() const
|
||||
CDockSplitter* CDockContainerWidget::rootSplitter() const
|
||||
{
|
||||
return d->RootSplitter;
|
||||
}
|
||||
@@ -2065,8 +2072,12 @@ CDockAreaWidget* CDockContainerWidget::topLevelDockArea() const
|
||||
QList<CDockWidget*> CDockContainerWidget::dockWidgets() const
|
||||
{
|
||||
QList<CDockWidget*> Result;
|
||||
for (const auto DockArea : d->DockAreas)
|
||||
for (const auto& DockArea : d->DockAreas)
|
||||
{
|
||||
if (!DockArea)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Result.append(DockArea->dockWidgets());
|
||||
}
|
||||
|
||||
@@ -2097,8 +2108,12 @@ void CDockContainerWidget::removeAutoHideWidget(CAutoHideDockContainer* Autohide
|
||||
CDockWidget::DockWidgetFeatures CDockContainerWidget::features() const
|
||||
{
|
||||
CDockWidget::DockWidgetFeatures Features(CDockWidget::AllDockWidgetFeatures);
|
||||
for (const auto DockArea : d->DockAreas)
|
||||
for (const auto& DockArea : d->DockAreas)
|
||||
{
|
||||
if (!DockArea)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Features &= DockArea->features();
|
||||
}
|
||||
|
||||
@@ -2116,9 +2131,9 @@ CFloatingDockContainer* CDockContainerWidget::floatingWidget() const
|
||||
//============================================================================
|
||||
void CDockContainerWidget::closeOtherAreas(CDockAreaWidget* KeepOpenArea)
|
||||
{
|
||||
for (const auto DockArea : d->DockAreas)
|
||||
for (const auto& DockArea : d->DockAreas)
|
||||
{
|
||||
if (DockArea == KeepOpenArea)
|
||||
if (!DockArea || DockArea == KeepOpenArea)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ struct FloatingDragPreviewPrivate;
|
||||
class CDockingStateReader;
|
||||
class CAutoHideSideBar;
|
||||
class CAutoHideTab;
|
||||
class CDockSplitter;
|
||||
struct AutoHideTabPrivate;
|
||||
struct AutoHideDockContainerPrivate;
|
||||
|
||||
@@ -94,7 +95,7 @@ protected:
|
||||
/**
|
||||
* Access function for the internal root splitter
|
||||
*/
|
||||
QSplitter* rootSplitter() const;
|
||||
CDockSplitter* rootSplitter() const;
|
||||
|
||||
/**
|
||||
* Creates and initializes a dockwidget auto hide container into the given area.
|
||||
@@ -138,6 +139,11 @@ protected:
|
||||
*/
|
||||
void removeDockArea(CDockAreaWidget* area);
|
||||
|
||||
/**
|
||||
* Remove all dock areas and returns the list of removed dock areas
|
||||
*/
|
||||
QList<QPointer<CDockAreaWidget>> removeAllDockAreas();
|
||||
|
||||
/**
|
||||
* Saves the state into the given stream
|
||||
*/
|
||||
|
||||
@@ -115,6 +115,7 @@ DockFocusControllerPrivate::DockFocusControllerPrivate(
|
||||
//============================================================================
|
||||
void DockFocusControllerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
|
||||
{
|
||||
if (!DockWidget) return;
|
||||
if (!DockWidget->features().testFlag(CDockWidget::DockWidgetFocusable))
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -103,8 +103,8 @@ static QString FloatingContainersTitle;
|
||||
struct DockManagerPrivate
|
||||
{
|
||||
CDockManager* _this;
|
||||
QList<CFloatingDockContainer*> FloatingWidgets;
|
||||
QList<CFloatingDockContainer*> HiddenFloatingWidgets;
|
||||
QList<QPointer<CFloatingDockContainer>> FloatingWidgets;
|
||||
QList<QPointer<CFloatingDockContainer>> HiddenFloatingWidgets;
|
||||
QList<CDockContainerWidget*> Containers;
|
||||
CDockOverlay* ContainerOverlay;
|
||||
CDockOverlay* DockAreaOverlay;
|
||||
@@ -122,6 +122,7 @@ struct DockManagerPrivate
|
||||
Qt::ToolButtonStyle ToolBarStyleFloating = Qt::ToolButtonTextUnderIcon;
|
||||
QSize ToolBarIconSizeDocked = QSize(16, 16);
|
||||
QSize ToolBarIconSizeFloating = QSize(24, 24);
|
||||
CDockWidget::DockWidgetFeatures LockedDockWidgetFeatures;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@@ -153,7 +154,10 @@ struct DockManagerPrivate
|
||||
// Hide updates of floating widgets from user
|
||||
for (auto FloatingWidget : FloatingWidgets)
|
||||
{
|
||||
FloatingWidget->hide();
|
||||
if (FloatingWidget)
|
||||
{
|
||||
FloatingWidget->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +337,8 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
|
||||
int FloatingWidgetIndex = DockContainerCount - 1;
|
||||
for (int i = FloatingWidgetIndex; i < FloatingWidgets.count(); ++i)
|
||||
{
|
||||
auto* floatingWidget = FloatingWidgets[i];
|
||||
CFloatingDockContainer* floatingWidget = FloatingWidgets[i];
|
||||
if (!floatingWidget) continue;
|
||||
_this->removeDockContainer(floatingWidget->dockContainer());
|
||||
floatingWidget->deleteLater();
|
||||
}
|
||||
@@ -536,25 +541,41 @@ CDockManager::CDockManager(QWidget *parent) :
|
||||
CDockManager::~CDockManager()
|
||||
{
|
||||
// fix memory leaks, see https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/307
|
||||
std::vector<ads::CDockAreaWidget*> areas;
|
||||
for ( int i = 0; i != dockAreaCount(); ++i )
|
||||
{
|
||||
areas.push_back( dockArea(i) );
|
||||
}
|
||||
for ( auto area : areas )
|
||||
{
|
||||
for ( auto widget : area->dockWidgets() )
|
||||
delete widget;
|
||||
std::vector<QPointer<ads::CDockAreaWidget>> areas;
|
||||
for (int i = 0; i != dockAreaCount(); ++i)
|
||||
{
|
||||
areas.push_back( dockArea(i) );
|
||||
}
|
||||
for ( auto area : areas )
|
||||
{
|
||||
if (!area || area->dockManager() != this) continue;
|
||||
|
||||
delete area;
|
||||
}
|
||||
// QPointer delete safety - just in case some dock wigdet in destruction
|
||||
// deletes another related/twin or child dock widget.
|
||||
std::vector<QPointer<QWidget>> deleteWidgets;
|
||||
for ( auto widget : area->dockWidgets() )
|
||||
{
|
||||
deleteWidgets.push_back(widget);
|
||||
}
|
||||
for ( auto ptrWdg : deleteWidgets)
|
||||
{
|
||||
delete ptrWdg;
|
||||
}
|
||||
}
|
||||
|
||||
auto FloatingWidgets = d->FloatingWidgets;
|
||||
for (auto FloatingWidget : FloatingWidgets)
|
||||
{
|
||||
FloatingWidget->deleteContent();
|
||||
delete FloatingWidget;
|
||||
}
|
||||
|
||||
// Delete Dock Widgets before Areas so widgets can access them late (like dtor)
|
||||
for ( auto area : areas )
|
||||
{
|
||||
delete area;
|
||||
}
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -568,7 +589,7 @@ bool CDockManager::eventFilter(QObject *obj, QEvent *e)
|
||||
// Window always on top of the MainWindow.
|
||||
if (e->type() == QEvent::WindowActivate)
|
||||
{
|
||||
for (auto _window : floatingWidgets())
|
||||
for (auto _window : d->FloatingWidgets)
|
||||
{
|
||||
if (!_window->isVisible() || window()->isMinimized())
|
||||
{
|
||||
@@ -590,7 +611,7 @@ bool CDockManager::eventFilter(QObject *obj, QEvent *e)
|
||||
}
|
||||
else if (e->type() == QEvent::WindowDeactivate)
|
||||
{
|
||||
for (auto _window : floatingWidgets())
|
||||
for (auto _window : d->FloatingWidgets)
|
||||
{
|
||||
if (!_window->isVisible() || window()->isMinimized())
|
||||
{
|
||||
@@ -613,7 +634,7 @@ bool CDockManager::eventFilter(QObject *obj, QEvent *e)
|
||||
// Sync minimize with MainWindow
|
||||
if (e->type() == QEvent::WindowStateChange)
|
||||
{
|
||||
for (auto _window : floatingWidgets())
|
||||
for (auto _window : d->FloatingWidgets)
|
||||
{
|
||||
if (! _window->isVisible())
|
||||
{
|
||||
@@ -725,7 +746,12 @@ const QList<CDockContainerWidget*> CDockManager::dockContainers() const
|
||||
//============================================================================
|
||||
const QList<CFloatingDockContainer*> CDockManager::floatingWidgets() const
|
||||
{
|
||||
return d->FloatingWidgets;
|
||||
QList<CFloatingDockContainer*> res;
|
||||
for (auto &fl : d->FloatingWidgets)
|
||||
{
|
||||
if (fl) res.append(fl);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -1125,7 +1151,7 @@ QAction* CDockManager::addToggleViewActionToMenu(QAction* ToggleViewAction,
|
||||
bool AlphabeticallySorted = (MenuAlphabeticallySorted == d->MenuInsertionOrder);
|
||||
if (!Group.isEmpty())
|
||||
{
|
||||
QMenu* GroupMenu = d->ViewMenuGroups.value(Group, 0);
|
||||
QMenu* GroupMenu = d->ViewMenuGroups.value(Group, nullptr);
|
||||
if (!GroupMenu)
|
||||
{
|
||||
GroupMenu = new QMenu(Group, this);
|
||||
@@ -1318,7 +1344,7 @@ QList<int> CDockManager::splitterSizes(CDockAreaWidget *ContainedArea) const
|
||||
{
|
||||
if (ContainedArea)
|
||||
{
|
||||
auto Splitter = internal::findParent<CDockSplitter*>(ContainedArea);
|
||||
auto Splitter = ContainedArea->parentSplitter();
|
||||
if (Splitter)
|
||||
{
|
||||
return Splitter->sizes();
|
||||
@@ -1335,7 +1361,7 @@ void CDockManager::setSplitterSizes(CDockAreaWidget *ContainedArea, const QList<
|
||||
return;
|
||||
}
|
||||
|
||||
auto Splitter = internal::findParent<CDockSplitter*>(ContainedArea);
|
||||
auto Splitter = ContainedArea->parentSplitter();
|
||||
if (Splitter && Splitter->count() == sizes.count())
|
||||
{
|
||||
Splitter->setSizes(sizes);
|
||||
@@ -1422,6 +1448,33 @@ QSize CDockManager::dockWidgetToolBarIconSize(CDockWidget::eState State) const
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void CDockManager::lockDockWidgetFeaturesGlobally(CDockWidget::DockWidgetFeatures Value)
|
||||
{
|
||||
// Limit the features to CDockWidget::GloballyLockableFeatures
|
||||
Value &= CDockWidget::GloballyLockableFeatures;
|
||||
if (d->LockedDockWidgetFeatures == Value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
d->LockedDockWidgetFeatures = Value;
|
||||
// Call the notifyFeaturesChanged() function for all dock widgets to update
|
||||
// the state of the close and detach buttons
|
||||
for (auto DockWidget : d->DockWidgetsMap)
|
||||
{
|
||||
DockWidget->notifyFeaturesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
CDockWidget::DockWidgetFeatures CDockManager::globallyLockedDockWidgetFeatures() const
|
||||
{
|
||||
return d->LockedDockWidgetFeatures;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -214,6 +214,7 @@ public:
|
||||
//! Users can overwrite this by setting the environment variable ADS_UseNativeTitle to "1" or "0".
|
||||
MiddleMouseButtonClosesTab = 0x2000000, //! If the flag is set, the user can use the mouse middle button to close the tab under the mouse
|
||||
DisableTabTextEliding = 0x4000000, //! Set this flag to disable eliding of tab texts in dock area tabs
|
||||
ShowTabTextOnlyForActiveTab =0x8000000, //! Set this flag to show label texts in dock area tabs only for active tabs
|
||||
|
||||
DefaultDockAreaButtons = DockAreaHasCloseButton
|
||||
| DockAreaHasUndockButton
|
||||
@@ -256,8 +257,7 @@ public:
|
||||
|
||||
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
||||
| DockAreaHasAutoHideButton
|
||||
| AutoHideCloseButtonCollapsesDock
|
||||
| AutoHideHasCloseButton
|
||||
| AutoHideHasMinimizeButton
|
||||
|
||||
};
|
||||
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
|
||||
@@ -660,6 +660,38 @@ public:
|
||||
*/
|
||||
QSize dockWidgetToolBarIconSize(CDockWidget::eState State) const;
|
||||
|
||||
/**
|
||||
* Returns all dock widget features that are globally locked by the dock
|
||||
* manager.
|
||||
* Globally locked features are removed from the features of all dock
|
||||
* widgets.
|
||||
*/
|
||||
CDockWidget::DockWidgetFeatures globallyLockedDockWidgetFeatures() const;
|
||||
|
||||
/**
|
||||
* Globally Lock features of all dock widgets to "freeze" the current
|
||||
* workspace layout.
|
||||
* For example, it is now possible to lock the workspace to avoid
|
||||
* accidentally dragging a docked view. Locking wasn’t possible before.
|
||||
* So, users had to manually dock it back to the desired place after
|
||||
* each accidental undock.
|
||||
* You can use a combination of the following feature flags:
|
||||
* - CDockWidget::DockWidgetClosable
|
||||
* - CDockWidget::DockWidgetMovable
|
||||
* - CDockWidget::DockWidgetFloatable
|
||||
* - CDockWidget::DockWidgetPinable
|
||||
*
|
||||
* To clear the locked features, you can use CDockWidget::NoDockWidgetFeatures
|
||||
* The following code shows how to lock and unlock dock widget features
|
||||
* globally.
|
||||
*
|
||||
* \code
|
||||
* DockManager->lockDockWidgetFeaturesGlobally();
|
||||
* DockManager->lockDockWidgetFeaturesGlobally(CDockWidget::NoDockWidgetFeatures);
|
||||
* \code
|
||||
*/
|
||||
void lockDockWidgetFeaturesGlobally(CDockWidget::DockWidgetFeatures Features = CDockWidget::GloballyLockableFeatures);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Opens the perspective with the given name.
|
||||
|
||||
@@ -80,8 +80,8 @@ struct DockWidgetPrivate
|
||||
QWidget* Widget = nullptr;
|
||||
CDockWidgetTab* TabWidget = nullptr;
|
||||
CDockWidget::DockWidgetFeatures Features = CDockWidget::DefaultDockWidgetFeatures;
|
||||
CDockManager* DockManager = nullptr;
|
||||
CDockAreaWidget* DockArea = nullptr;
|
||||
QPointer<CDockManager> DockManager;
|
||||
QPointer<CDockAreaWidget> DockArea;
|
||||
QAction* ToggleViewAction = nullptr;
|
||||
bool Closed = false;
|
||||
QScrollArea* ScrollArea = nullptr;
|
||||
@@ -184,11 +184,11 @@ void DockWidgetPrivate::showDockWidget()
|
||||
DockArea->setCurrentDockWidget(_this);
|
||||
DockArea->toggleView(true);
|
||||
TabWidget->show();
|
||||
QSplitter* Splitter = internal::findParent<QSplitter*>(DockArea);
|
||||
auto Splitter = DockArea->parentSplitter();
|
||||
while (Splitter && !Splitter->isVisible() && !DockArea->isAutoHide())
|
||||
{
|
||||
Splitter->show();
|
||||
Splitter = internal::findParent<QSplitter*>(Splitter);
|
||||
Splitter = internal::findParent<CDockSplitter*>(Splitter);
|
||||
}
|
||||
|
||||
CDockContainerWidget* Container = DockArea->dockContainer();
|
||||
@@ -271,7 +271,10 @@ void DockWidgetPrivate::closeAutoHideDockWidgetsIfNeeded()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DockContainer->openedDockWidgets().isEmpty())
|
||||
// If the dock container is the dock manager, or if it is not empty, then we
|
||||
// don't need to do anything
|
||||
if ((DockContainer == _this->dockManager())
|
||||
|| !DockContainer->openedDockWidgets().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -382,7 +385,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
||||
//============================================================================
|
||||
CDockWidget::~CDockWidget()
|
||||
{
|
||||
ADS_PRINT("~CDockWidget()");
|
||||
ADS_PRINT("~CDockWidget(): " << this->windowTitle());
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -511,10 +514,19 @@ void CDockWidget::setFeatures(DockWidgetFeatures features)
|
||||
return;
|
||||
}
|
||||
d->Features = features;
|
||||
notifyFeaturesChanged();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidget::notifyFeaturesChanged()
|
||||
{
|
||||
Q_EMIT featuresChanged(d->Features);
|
||||
d->TabWidget->onDockWidgetFeaturesChanged();
|
||||
if(CDockAreaWidget* DockArea = dockAreaWidget())
|
||||
{
|
||||
DockArea->onDockWidgetFeaturesChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -530,7 +542,14 @@ void CDockWidget::setFeature(DockWidgetFeature flag, bool on)
|
||||
//============================================================================
|
||||
CDockWidget::DockWidgetFeatures CDockWidget::features() const
|
||||
{
|
||||
return d->Features;
|
||||
if (d->DockManager)
|
||||
{
|
||||
return d->Features &~ d->DockManager->globallyLockedDockWidgetFeatures();
|
||||
}
|
||||
else
|
||||
{
|
||||
return d->Features;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -566,7 +585,7 @@ CDockContainerWidget* CDockWidget::dockContainer() const
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,11 +768,10 @@ void CDockWidget::toggleViewInternal(bool Open)
|
||||
if (d->DockArea)
|
||||
{
|
||||
d->DockArea->toggleDockWidgetView(this, Open);
|
||||
}
|
||||
|
||||
if (d->DockArea->isAutoHide())
|
||||
{
|
||||
d->DockArea->autoHideDockContainer()->toggleView(Open);
|
||||
if (d->DockArea->isAutoHide())
|
||||
{
|
||||
d->DockArea->autoHideDockContainer()->toggleView(Open);
|
||||
}
|
||||
}
|
||||
|
||||
if (Open && TopLevelDockWidgetBefore)
|
||||
|
||||
@@ -165,6 +165,7 @@ public:
|
||||
DefaultDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable | DockWidgetFocusable | DockWidgetPinnable,
|
||||
AllDockWidgetFeatures = DefaultDockWidgetFeatures | DockWidgetDeleteOnClose | CustomCloseHandling,
|
||||
DockWidgetAlwaysCloseAndDelete = DockWidgetForceCloseWithArea | DockWidgetDeleteOnClose,
|
||||
GloballyLockableFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable | DockWidgetPinnable,
|
||||
NoDockWidgetFeatures = 0x000
|
||||
};
|
||||
Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
|
||||
@@ -256,7 +257,7 @@ public:
|
||||
* by calling setObjectName() after construction.
|
||||
* Use the layoutFlags to configure the layout of the dock widget.
|
||||
*/
|
||||
CDockWidget(const QString &title, QWidget* parent = 0);
|
||||
CDockWidget(const QString &title, QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* Virtual Destructor
|
||||
@@ -336,6 +337,11 @@ public:
|
||||
*/
|
||||
DockWidgetFeatures features() const;
|
||||
|
||||
/**
|
||||
* Triggers notification of feature change signals and functions
|
||||
*/
|
||||
void notifyFeaturesChanged();
|
||||
|
||||
/**
|
||||
* Returns the dock manager that manages the dock widget or 0 if the widget
|
||||
* has not been assigned to any dock manager yet
|
||||
|
||||
@@ -56,7 +56,6 @@
|
||||
|
||||
namespace ads
|
||||
{
|
||||
static const char* const LocationProperty = "Location";
|
||||
using tTabLabel = CElidingLabel;
|
||||
|
||||
/**
|
||||
@@ -225,7 +224,7 @@ struct DockWidgetTabPrivate
|
||||
QMenu* Menu)
|
||||
{
|
||||
auto Action = Menu->addAction(Title);
|
||||
Action->setProperty("Location", Location);
|
||||
Action->setProperty(internal::LocationProperty, Location);
|
||||
QObject::connect(Action, &QAction::triggered, _this, &CDockWidgetTab::onAutoHideToActionClicked);
|
||||
return Action;
|
||||
}
|
||||
@@ -421,11 +420,12 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
|
||||
break;
|
||||
|
||||
default:
|
||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
|
||||
{
|
||||
d->focusController()->setDockWidgetTabPressed(false);
|
||||
}
|
||||
break; // do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
|
||||
{
|
||||
d->focusController()->setDockWidgetTabPressed(false);
|
||||
}
|
||||
}
|
||||
else if (ev->button() == Qt::MiddleButton)
|
||||
@@ -580,6 +580,14 @@ void CDockWidgetTab::setActiveTab(bool active)
|
||||
{
|
||||
d->updateCloseButtonVisibility(active);
|
||||
|
||||
if(CDockManager::testConfigFlag(CDockManager::ShowTabTextOnlyForActiveTab) && !d->Icon.isNull())
|
||||
{
|
||||
if(active)
|
||||
d->TitleLabel->setVisible(true);
|
||||
else
|
||||
d->TitleLabel->setVisible(false);
|
||||
}
|
||||
|
||||
// Focus related stuff
|
||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
|
||||
{
|
||||
@@ -755,7 +763,7 @@ void CDockWidgetTab::autoHideDockWidget()
|
||||
//===========================================================================
|
||||
void CDockWidgetTab::onAutoHideToActionClicked()
|
||||
{
|
||||
int Location = sender()->property(LocationProperty).toInt();
|
||||
int Location = sender()->property(internal::LocationProperty).toInt();
|
||||
d->DockWidget->toggleAutoHide((SideBarLocation)Location);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
* param[in] DockWidget The dock widget this title bar belongs to
|
||||
* param[in] parent The parent widget of this title bar
|
||||
*/
|
||||
CDockWidgetTab(CDockWidget* DockWidget, QWidget* parent = 0);
|
||||
CDockWidgetTab(CDockWidget* DockWidget, QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* Virtual Destructor
|
||||
|
||||
@@ -58,8 +58,8 @@ protected:
|
||||
public:
|
||||
using Super = QLabel;
|
||||
|
||||
CElidingLabel(QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags ());
|
||||
CElidingLabel(const QString& text, QWidget* parent = 0, Qt::WindowFlags f = Qt::WindowFlags ());
|
||||
CElidingLabel(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags ());
|
||||
CElidingLabel(const QString& text, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags ());
|
||||
virtual ~CElidingLabel();
|
||||
|
||||
/**
|
||||
|
||||
@@ -357,7 +357,7 @@ static const char* windowsMessageString(int MessageId)
|
||||
#endif
|
||||
|
||||
|
||||
static unsigned int zOrderCounter = 0;
|
||||
static unsigned int zOrderCounterFloating = 0;
|
||||
/**
|
||||
* Private data class of CFloatingDockContainer class (pimpl)
|
||||
*/
|
||||
@@ -365,7 +365,7 @@ struct FloatingDockContainerPrivate
|
||||
{
|
||||
CFloatingDockContainer *_this;
|
||||
CDockContainerWidget *DockContainer;
|
||||
unsigned int zOrderIndex = ++zOrderCounter;
|
||||
unsigned int zOrderIndex = ++zOrderCounterFloating;
|
||||
QPointer<CDockManager> DockManager;
|
||||
eDragState DraggingState = DraggingInactive;
|
||||
QPoint DragStartMousePosition;
|
||||
@@ -760,6 +760,7 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
|
||||
d->DockManager->notifyWidgetOrAreaRelocation(DockWidget);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CFloatingDockContainer::~CFloatingDockContainer()
|
||||
{
|
||||
@@ -771,6 +772,36 @@ CFloatingDockContainer::~CFloatingDockContainer()
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::deleteContent()
|
||||
{
|
||||
std::vector<QPointer<ads::CDockAreaWidget>> areas;
|
||||
for (int i = 0; i != dockContainer()->dockAreaCount(); ++i)
|
||||
{
|
||||
areas.push_back( dockContainer()->dockArea(i) );
|
||||
}
|
||||
for (auto area : areas)
|
||||
{
|
||||
if (!area)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// QPointer delete safety - just in case some dock widget in destruction
|
||||
// deletes another related/twin or child dock widget.
|
||||
std::vector<QPointer<QWidget>> deleteWidgets;
|
||||
for (auto widget : area->dockWidgets())
|
||||
{
|
||||
deleteWidgets.push_back(widget);
|
||||
}
|
||||
for (auto ptrWdg : deleteWidgets)
|
||||
{
|
||||
delete ptrWdg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
CDockContainerWidget* CFloatingDockContainer::dockContainer() const
|
||||
{
|
||||
@@ -787,7 +818,7 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
|
||||
if (isActiveWindow())
|
||||
{
|
||||
ADS_PRINT("FloatingWidget::changeEvent QEvent::ActivationChange ");
|
||||
d->zOrderIndex = ++zOrderCounter;
|
||||
d->zOrderIndex = ++zOrderCounterFloating;
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
if (d->DraggingState == DraggingFloatingWidget)
|
||||
@@ -1142,7 +1173,7 @@ QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::hideAndDeleteLater()
|
||||
void CFloatingDockContainer::finishDropOperation()
|
||||
{
|
||||
// Widget has been redocked, so it must be hidden right way (see
|
||||
// https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/351)
|
||||
@@ -1150,6 +1181,11 @@ void CFloatingDockContainer::hideAndDeleteLater()
|
||||
// dock widgets that shall not be toggled hidden.
|
||||
d->AutoHideChildren = false;
|
||||
hide();
|
||||
// The floating widget will be deleted now. Ensure, that the destructor
|
||||
// of the floating widget does not delete any dock areas that have been
|
||||
// moved to a new container - simply remove all dock areas before deleting
|
||||
// the floating widget
|
||||
d->DockContainer->removeAllDockAreas();
|
||||
deleteLater();
|
||||
if (d->DockManager)
|
||||
{
|
||||
|
||||
@@ -146,6 +146,13 @@ protected:
|
||||
*/
|
||||
virtual void finishDragging() override;
|
||||
|
||||
/**
|
||||
* This function deletes all dock widgets in it.
|
||||
* This functions should be called only from dock manager in its
|
||||
* destructor before deleting the floating widget
|
||||
*/
|
||||
void deleteContent();
|
||||
|
||||
/**
|
||||
* Call this function if you just want to initialize the position
|
||||
* and size of the floating widget
|
||||
@@ -258,9 +265,9 @@ public:
|
||||
QList<CDockWidget*> dockWidgets() const;
|
||||
|
||||
/**
|
||||
* This function hides the floating bar instantely and delete it later.
|
||||
* This function hides the floating widget instantly and delete it later.
|
||||
*/
|
||||
void hideAndDeleteLater();
|
||||
void finishDropOperation();
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
/**
|
||||
|
||||
@@ -92,7 +92,7 @@ xcb_atom_t xcb_get_atom(const char *name)
|
||||
}
|
||||
xcb_connection_t *connection = x11_connection();
|
||||
xcb_intern_atom_cookie_t request = xcb_intern_atom(connection, 1, strlen(name), name);
|
||||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, request, NULL);
|
||||
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, request, nullptr);
|
||||
if (!reply)
|
||||
{
|
||||
return XCB_ATOM_NONE;
|
||||
|
||||
@@ -167,6 +167,7 @@ static const bool RestoreTesting = true;
|
||||
static const bool Restore = false;
|
||||
static const char* const ClosedProperty = "close";
|
||||
static const char* const DirtyProperty = "dirty";
|
||||
static const char* const LocationProperty = "Location";
|
||||
extern const int FloatingWidgetDragStartEvent;
|
||||
extern const int DockedWidgetDragStartEvent;
|
||||
|
||||
@@ -268,7 +269,7 @@ T findParent(const QWidget* w)
|
||||
}
|
||||
parentWidget = parentWidget->parentWidget();
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -137,11 +137,11 @@ CFloatingWidgetTitleBar::CFloatingWidgetTitleBar(CFloatingDockContainer *parent)
|
||||
d->FloatingWidget = parent;
|
||||
d->createLayout();
|
||||
|
||||
auto normalPixmap = this->style()->standardPixmap(QStyle::SP_TitleBarNormalButton, 0, d->MaximizeButton);
|
||||
auto normalPixmap = this->style()->standardPixmap(QStyle::SP_TitleBarNormalButton, nullptr, d->MaximizeButton);
|
||||
d->NormalIcon.addPixmap(normalPixmap, QIcon::Normal);
|
||||
d->NormalIcon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
|
||||
|
||||
auto maxPixmap = this->style()->standardPixmap(QStyle::SP_TitleBarMaxButton, 0, d->MaximizeButton);
|
||||
auto maxPixmap = this->style()->standardPixmap(QStyle::SP_TitleBarMaxButton, nullptr, d->MaximizeButton);
|
||||
d->MaximizeIcon.addPixmap(maxPixmap, QIcon::Normal);
|
||||
d->MaximizeIcon.addPixmap(internal::createTransparentPixmap(maxPixmap, 0.25), QIcon::Disabled);
|
||||
setMaximizedIcon(d->Maximized);
|
||||
|
||||
@@ -333,7 +333,7 @@ ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaT
|
||||
|
||||
|
||||
ads--CAutoHideDockContainer #dockAreaAutoHideButton {
|
||||
qproperty-icon: url(:/ads/images/vs-pin-button-pinned-focused.svg),
|
||||
qproperty-icon: url(:/ads/images/vs-pin-button-pinned-focused.svg);
|
||||
qproperty-iconSize: 16px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user