Compare commits
79 Commits
openglwidg
...
ci-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
949ed40006 | ||
|
|
f2a9dd4db4 | ||
|
|
ed67081b74 | ||
|
|
705d931231 | ||
|
|
d1367c9dd4 | ||
|
|
31402ee9f8 | ||
|
|
b7cbac88b3 | ||
|
|
fe8c88771f | ||
|
|
befcd9eadf | ||
|
|
46e5aea61c | ||
|
|
103db689ff | ||
|
|
bc34470d3c | ||
|
|
646bddfea3 | ||
|
|
cb63f0e6ea | ||
|
|
c941b2dfde | ||
|
|
671b932804 | ||
|
|
f76d3b4834 | ||
|
|
c248f79971 | ||
|
|
0566677a9d | ||
|
|
268998961b | ||
|
|
716d6f7f25 | ||
|
|
ceb7c91844 | ||
|
|
0a78dcf460 | ||
|
|
da7d23c127 | ||
|
|
64d80b2c53 | ||
|
|
f2a029a0c6 | ||
|
|
c1b60959ae | ||
|
|
d53728c0a8 | ||
|
|
a7ad4386e4 | ||
|
|
4e90a38c52 | ||
|
|
4947548224 | ||
|
|
991b69cc51 | ||
|
|
df1fa27127 | ||
|
|
936eba01cd | ||
|
|
9f8dd99cac | ||
|
|
90e5adde29 | ||
|
|
ddbed9ea14 | ||
|
|
c305432ab2 | ||
|
|
e836b154eb | ||
|
|
782589523e | ||
|
|
bb105d2ef6 | ||
|
|
483bb7354a | ||
|
|
7d9f9b43a7 | ||
|
|
7fd5cbe9d7 | ||
|
|
a16d17a8bf | ||
|
|
faf24cd531 | ||
|
|
979d76aa47 | ||
|
|
0a55bcd586 | ||
|
|
f41a6f06fe | ||
|
|
349d584228 | ||
|
|
fcad7763ff | ||
|
|
1bec4234c3 | ||
|
|
0be5ba8cf6 | ||
|
|
7245dced84 | ||
|
|
e2f611ea9a | ||
|
|
1f21eb0200 | ||
|
|
f2378636e2 | ||
|
|
509b2356d1 | ||
|
|
30b802bd10 | ||
|
|
e857421fdf | ||
|
|
8dcdc8fad2 | ||
|
|
f964ce2c68 | ||
|
|
eb9b439d11 | ||
|
|
a13ed7e4d6 | ||
|
|
8cfa5c8e0e | ||
|
|
2878559ee6 | ||
|
|
6ff39bccf8 | ||
|
|
952131a1e9 | ||
|
|
5edbcc1970 | ||
|
|
04f6d9168e | ||
|
|
cea1327dac | ||
|
|
1c41cbff82 | ||
|
|
06e8451fc0 | ||
|
|
3ff6918b1f | ||
|
|
ac3af4c6cd | ||
|
|
41bb861417 | ||
|
|
6e63418798 | ||
|
|
65781b7cac | ||
|
|
d7e6c613c6 |
63
.github/workflows/linux-builds.yml
vendored
63
.github/workflows/linux-builds.yml
vendored
@@ -1,34 +1,59 @@
|
||||
name: linux-builds
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
jobs:
|
||||
build_ubuntu_2204_cmake:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
env:
|
||||
QT_VERSION: 6.4.2
|
||||
QT_DIR: ${{ github.workspace }}/Qt
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: install qt
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Fetch full history and tags
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update --fix-missing
|
||||
sudo apt-get install qt5-default
|
||||
sudo apt-get install qtbase5-private-dev qtdeclarative5-dev
|
||||
- name: qmake
|
||||
run: qmake
|
||||
- name: make
|
||||
run: make -j4
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential cmake ninja-build libgl1-mesa-dev libxkbcommon-x11-0 libx11-dev
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
version: ${{ env.QT_VERSION }}
|
||||
target: desktop
|
||||
host: linux
|
||||
arch: gcc_64
|
||||
dir: ${{ env.QT_DIR }}
|
||||
setup-python: false
|
||||
|
||||
- name: Configure with CMake
|
||||
run: |
|
||||
cmake -S . -B build \
|
||||
-DCMAKE_PREFIX_PATH="${{ env.QT_DIR }}/Qt/${{ env.QT_VERSION }}/gcc_64" \
|
||||
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-G Ninja
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build
|
||||
|
||||
- name: Run CMake install (optional)
|
||||
run: cmake --install build
|
||||
|
||||
build_ubuntu_2204:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache Qt
|
||||
id: cache-qt-6-4
|
||||
uses: actions/cache@v1 # not v2!
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ../Qt/6.4.2
|
||||
key: ${{ runner.os }}-QtCache-Qt6-4
|
||||
|
||||
102
.github/workflows/windows-cmake.yml
vendored
Normal file
102
.github/workflows/windows-cmake.yml
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
name: windows-builds
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build_windows_msvc:
|
||||
name: Build with MSVC and Ninja
|
||||
runs-on: windows-2022
|
||||
|
||||
env:
|
||||
QT_VERSION: 6.4.2
|
||||
QT_DIR: ${{ github.workspace }}\Qt
|
||||
|
||||
steps:
|
||||
- name: 📦 Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: ⚙️ Install Ninja build system
|
||||
run: choco install ninja --no-progress
|
||||
|
||||
- name: 📥 Install Qt for MSVC
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
version: ${{ env.QT_VERSION }}
|
||||
target: desktop
|
||||
host: windows
|
||||
arch: win64_msvc2019_64
|
||||
dir: ${{ env.QT_DIR }}
|
||||
setup-python: false
|
||||
|
||||
- name: 🏗️ Setup MSVC Developer Environment
|
||||
uses: TheMrMilchmann/setup-msvc-dev@v3
|
||||
with:
|
||||
arch: x64
|
||||
|
||||
- name: 🛠️ Configure CMake with Ninja + MSVC
|
||||
run: |
|
||||
cmake -S . -B build -G Ninja `
|
||||
-DCMAKE_PREFIX_PATH="${{ env.QT_DIR }}\Qt\${{ env.QT_VERSION }}\msvc2019_64" `
|
||||
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}\install" `
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
shell: powershell
|
||||
|
||||
- name: 🔨 Build with Ninja + MSVC
|
||||
run: cmake --build build
|
||||
shell: powershell
|
||||
|
||||
- name: 📦 Install built files
|
||||
run: cmake --install build
|
||||
shell: powershell
|
||||
|
||||
build_windows_mingw:
|
||||
name: Build with Qt's MinGW and CMake (no Ninja)
|
||||
runs-on: windows-2022
|
||||
|
||||
env:
|
||||
QT_VERSION: 6.8.3
|
||||
QT_DIR: ${{ github.workspace }}\Qt
|
||||
|
||||
steps:
|
||||
- name: 📦 Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: 📥 Install Qt + MinGW
|
||||
uses: jurplel/install-qt-action@v4
|
||||
with:
|
||||
aqtversion: '==3.1.19'
|
||||
version: ${{ env.QT_VERSION }}
|
||||
target: desktop
|
||||
host: windows
|
||||
arch: win64_mingw
|
||||
dir: ${{ env.QT_DIR }}
|
||||
tools: 'tools_mingw1310'
|
||||
setup-python: false
|
||||
|
||||
- name: ➕ Add Qt-bundled MinGW to PATH
|
||||
shell: powershell
|
||||
run: |
|
||||
echo "${{ env.QT_DIR }}\Tools\mingw1310_64\bin" >> $env:GITHUB_PATH
|
||||
|
||||
- name: 🛠️ Configure CMake (MinGW)
|
||||
shell: powershell
|
||||
run: |
|
||||
cmake -S . -B build-mingw `
|
||||
-DCMAKE_PREFIX_PATH="${{ env.QT_DIR }}\Qt\${{ env.QT_VERSION }}\mingw_64" `
|
||||
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}\install `
|
||||
-DCMAKE_BUILD_TYPE=Release `
|
||||
-G "MinGW Makefiles"
|
||||
|
||||
- name: 🔨 Build with CMake (MinGW)
|
||||
shell: powershell
|
||||
run: cmake --build build-mingw -- -j2
|
||||
|
||||
- name: 📦 Install built files (MinGW)
|
||||
shell: powershell
|
||||
run: cmake --install build-mingw
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -9,8 +9,7 @@ ui_*
|
||||
Makefile
|
||||
*.dll
|
||||
*.a
|
||||
build-*
|
||||
build_*
|
||||
build*
|
||||
|
||||
# IDEs
|
||||
.idea
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
if (POLICY CMP0091)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
endif (POLICY CMP0091)
|
||||
|
||||
41
README.md
41
README.md
@@ -161,6 +161,7 @@ know it from Visual Studio.
|
||||
- [Auto-Hide Functionality](#auto-hide-functionality)
|
||||
- [Python Bindings](#python-bindings)
|
||||
- [PySide6](#pyside6)
|
||||
- [PyQt6](#pyqt6)
|
||||
- [PyQt5](#pyqt5)
|
||||
- [Tested Compatible Environments](#tested-compatible-environments)
|
||||
- [Supported Qt Versions](#supported-qt-versions)
|
||||
@@ -189,7 +190,7 @@ know it from Visual Studio.
|
||||
- [RDE – Robox Development Environment](#rde--robox-development-environment)
|
||||
- [ResInsight](#resinsight)
|
||||
- [ADTF 3](#adtf-3)
|
||||
- [DREAM.3D NX](#dream3d-nx)
|
||||
- [DREAM3D-NX](#dream3d-nx)
|
||||
- [LabPlot](#labplot)
|
||||
- [Alternative Docking System Implementations](#alternative-docking-system-implementations)
|
||||
- [KDDockWidgets](#kddockwidgets)
|
||||
@@ -308,7 +309,7 @@ More about the auto hide configuration options in the [online documentation...](
|
||||

|
||||
|
||||
Thanks to the contribution of several users, the Advanced Docking System comes
|
||||
with a complete Python integration. Python bindings are available for **PyQt5** and
|
||||
with a complete Python integration. Python bindings are available for **PyQt5**, **PyQt6**, and
|
||||
**PySide6**.
|
||||
|
||||
### PySide6
|
||||
@@ -328,6 +329,24 @@ The PySide6 bindings were contributed by:
|
||||
|
||||
Please file PySide6-QtAds-specific issues on its [pyside6_qtads](https://github.com/mborgerson/pyside6_qtads) fork for tracking. For more information about the PySide6 bindings read [this](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/issues/298) issue.
|
||||
|
||||
### PyQt6
|
||||
|
||||
A PyQt6 ADS package is available via PyPi and can be installed on Windows,
|
||||
macOS, and Linux with:
|
||||
|
||||
```bash
|
||||
pip install PyQt6Ads
|
||||
```
|
||||
|
||||
Sample code is available [here](https://github.com/pyapp-kit/PyQt6Ads/tree/main/examples).
|
||||
|
||||
The PyQt6 bindings were contributed by:
|
||||
|
||||
- [tlambert03](https://github.com/tlambert03)
|
||||
|
||||
Please file PyQt6Ads-specific issues at [pyapp-kit/PyQt6Ads](https://github.com/pyapp-kit/PyQt6Ads).
|
||||
|
||||
|
||||
### PyQt5
|
||||
|
||||
A package is available via [conda-forge](https://github.com/conda-forge/pyqtads-feedstock).
|
||||
@@ -462,7 +481,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// Create the dock manager after the ui is setup. Because the
|
||||
// parent parameter is a QMainWindow the dock manager registers
|
||||
// itself as the central widget as such the ui must be set up first.
|
||||
m_DockManager = new ads::CDockManager(this);
|
||||
DockManager = new ads::CDockManager(this);
|
||||
|
||||
// Create example content label - this can be any application specific
|
||||
// widget
|
||||
@@ -473,7 +492,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
// Create a dock widget with the title Label 1 and set the created label
|
||||
// as the dock widget content
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget("Label 1");
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget("Label 1");
|
||||
DockWidget->setWidget(l);
|
||||
|
||||
// Add the toggleViewAction of the dock widget to the menu to give
|
||||
@@ -481,7 +500,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
ui->menuView->addAction(DockWidget->toggleViewAction());
|
||||
|
||||
// Add the dock widget to the top dock widget area
|
||||
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
||||
DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -582,7 +601,7 @@ highlights are:
|
||||
- Simple Drag & Drop user interface.
|
||||
- Load data from file.
|
||||
- Connect to live streaming of data.
|
||||
- Save the visualization layout and configurations to re-use them later.
|
||||
- Save the visualization layout and configurations to reuse them later.
|
||||
- Fast OpenGL visualization.
|
||||
- Can handle thousands of timeseries and millions of data points.
|
||||
- Transform your data using a simple editor: derivative, moving average, integral, etc…
|
||||
@@ -667,15 +686,17 @@ says about the switch to Qt Advanced Docking:
|
||||
|
||||

|
||||
|
||||
### [DREAM.3D NX](https://github.com/BlueQuartzSoftware/DREAM3D)
|
||||
### [DREAM3D-NX](https://www.dream3d.io)
|
||||
|
||||
DREAM.3D *(Digital Representation Environment for Analysis of Materials in 3D)* is an open source, cross-platform and modular, software suite that allows users to prepare, reconstruct, quantify, instantiate, and mesh, multidimensional, multimodal microstructural data, as well as many other applications.
|
||||
DREAM3D-NX *(Digital Representation Environment for Analysis of Materials in 3D)* is a cross-platform and modular, software suite that allows users to prepare, reconstruct, quantify, instantiate, and mesh, multidimensional, multimodal microstructural data, as well as many other applications.
|
||||
|
||||
[BlueQuartz Software](http://www.bluequartz.net/) is currently completely rewriting the DREAM.3D application. For the upcoming version **[DREAM3D NX](http://www.dream3d.io/)** they improved the UI by using the Advanced Docking System. An [early version](http://www.dream3d.io/) of **DREAM3D NX** with ADS is already available to any user who would like to take the brand new version out for a spin.
|
||||
[BlueQuartz Software](http://www.bluequartz.net/) has completely rewritten the old DREAM.3D version 6.5 application
|
||||
taking advantage of the Advanced Docking System to present a highly customizable user interface
|
||||
for DREAM3D-NX Version 7.
|
||||
|
||||

|
||||
|
||||
[read more...](http://dream3d.bluequartz.net/)
|
||||
[read more...](http://www.dream3d.io/)
|
||||
|
||||
### [LabPlot](https://labplot.kde.org/)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_demo VERSION ${VERSION_SHORT})
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
@@ -27,7 +27,7 @@ target_link_libraries(AdvancedDockingSystemDemo PUBLIC Qt${QT_VERSION_MAJOR}::Co
|
||||
if(WIN32 AND QT_VERSION_MAJOR LESS 6)
|
||||
target_link_libraries(AdvancedDockingSystemDemo PUBLIC Qt${QT_VERSION_MAJOR}::AxContainer)
|
||||
endif()
|
||||
target_link_libraries(AdvancedDockingSystemDemo PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(AdvancedDockingSystemDemo PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
set_target_properties(AdvancedDockingSystemDemo PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTORCC ON
|
||||
|
||||
@@ -64,15 +64,6 @@
|
||||
#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>
|
||||
@@ -84,19 +75,17 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "DockManager.h"
|
||||
#include "DockWidget.h"
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
#include "DockAreaTabBar.h"
|
||||
#include "FloatingDockContainer.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockComponentsFactory.h"
|
||||
#include "StatusDialog.h"
|
||||
#include "DockManager.h"
|
||||
#include "DockSplitter.h"
|
||||
#include "DockWidget.h"
|
||||
#include "FloatingDockContainer.h"
|
||||
#include "ImageViewer.h"
|
||||
#include "glwidget.h"
|
||||
|
||||
|
||||
#include "MyDockAreaTitleBar.h"
|
||||
#include "StatusDialog.h"
|
||||
|
||||
/**
|
||||
* Returns a random number from 0 to highest - 1
|
||||
@@ -157,7 +146,7 @@ public:
|
||||
using Super = ads::CDockComponentsFactory;
|
||||
ads::CDockAreaTitleBar* createDockAreaTitleBar(ads::CDockAreaWidget* DockArea) const override
|
||||
{
|
||||
auto TitleBar = new ads::CDockAreaTitleBar(DockArea);
|
||||
auto TitleBar = new MyDockAreaTitleBar(DockArea);
|
||||
auto CustomButton = new QToolButton(DockArea);
|
||||
CustomButton->setToolTip(QObject::tr("Help"));
|
||||
CustomButton->setIcon(svgIcon(":/adsdemo/images/help_outline.svg"));
|
||||
@@ -247,7 +236,7 @@ struct MainWindowPrivate
|
||||
m->setRootPath(QDir::currentPath());
|
||||
w->setModel(m);
|
||||
w->setRootIndex(m->index(QDir::currentPath()));
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1")
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Filesystem %1")
|
||||
.arg(FileSystemCount++));
|
||||
DockWidget->setWidget(w);
|
||||
DockWidget->setIcon(svgIcon(":/adsdemo/images/folder_open.svg"));
|
||||
@@ -268,7 +257,7 @@ struct MainWindowPrivate
|
||||
{
|
||||
static int CalendarCount = 0;
|
||||
QCalendarWidget* w = new QCalendarWidget();
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Calendar %1").arg(CalendarCount++));
|
||||
// The following lines are for testing the setWidget() and takeWidget()
|
||||
// functionality
|
||||
DockWidget->setWidget(w);
|
||||
@@ -313,7 +302,7 @@ struct MainWindowPrivate
|
||||
.arg(LabelCount)
|
||||
.arg(QTime::currentTime().toString("hh:mm:ss:zzz")));
|
||||
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Label %1").arg(LabelCount++));
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Label %1").arg(LabelCount++));
|
||||
DockWidget->setWidget(l);
|
||||
DockWidget->setIcon(svgIcon(":/adsdemo/images/font_download.svg"));
|
||||
ui.menuView->addAction(DockWidget->toggleViewAction());
|
||||
@@ -331,7 +320,7 @@ struct MainWindowPrivate
|
||||
w->setPlaceholderText("This is an editor. If you close the editor, it will be "
|
||||
"deleted. Enter your text here.");
|
||||
w->setStyleSheet("border: none");
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Editor %1").arg(EditorCount++));
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Editor %1").arg(EditorCount++));
|
||||
DockWidget->setWidget(w);
|
||||
DockWidget->setIcon(svgIcon(":/adsdemo/images/edit.svg"));
|
||||
DockWidget->setFeature(ads::CDockWidget::CustomCloseHandling, true);
|
||||
@@ -374,7 +363,7 @@ struct MainWindowPrivate
|
||||
|
||||
auto Result = w->loadFile(FileName);
|
||||
qDebug() << "loadFile result: " << Result;
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Image Viewer %1").arg(ImageViewerCount++));
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Image Viewer %1").arg(ImageViewerCount++));
|
||||
DockWidget->setIcon(svgIcon(":/adsdemo/images/photo.svg"));
|
||||
DockWidget->setWidget(w,ads:: CDockWidget::ForceNoScrollArea);
|
||||
auto ToolBar = DockWidget->createDefaultToolBar();
|
||||
@@ -389,7 +378,7 @@ struct MainWindowPrivate
|
||||
{
|
||||
static int TableCount = 0;
|
||||
auto w = new CMinSizeTableWidget();
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Table %1").arg(TableCount++));
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Table %1").arg(TableCount++));
|
||||
static int colCount = 5;
|
||||
static int rowCount = 30;
|
||||
w->setColumnCount(colCount);
|
||||
@@ -428,7 +417,7 @@ struct MainWindowPrivate
|
||||
ads::CDockWidget *createQQuickWidget()
|
||||
{
|
||||
QQuickWidget *widget = new QQuickWidget();
|
||||
ads::CDockWidget *dockWidget = new ads::CDockWidget("Quick");
|
||||
ads::CDockWidget *dockWidget = DockManager->createDockWidget("Quick");
|
||||
dockWidget->setWidget(widget);
|
||||
return dockWidget;
|
||||
}
|
||||
@@ -443,7 +432,7 @@ struct MainWindowPrivate
|
||||
{
|
||||
static int ActiveXCount = 0;
|
||||
QAxWidget* w = new QAxWidget("{6bf52a52-394a-11d3-b153-00c04f79faa6}", parent);
|
||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Active X %1").arg(ActiveXCount++));
|
||||
ads::CDockWidget* DockWidget = DockManager->createDockWidget(QString("Active X %1").arg(ActiveXCount++));
|
||||
DockWidget->setWidget(w);
|
||||
ui.menuView->addAction(DockWidget->toggleViewAction());
|
||||
return DockWidget;
|
||||
@@ -481,12 +470,12 @@ void MainWindowPrivate::createContent()
|
||||
appendFeaturStringToWindowTitle(FileSystemWidget);
|
||||
|
||||
// Test custom factory - we inject a help button into the title bar
|
||||
ads::CDockComponentsFactory::setFactory(new CCustomComponentsFactory());
|
||||
DockManager->setComponentsFactory(new CCustomComponentsFactory());
|
||||
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
||||
// Uncomment the next line if you would like to test the
|
||||
// HideSingleWidgetTitleBar functionality
|
||||
// TopDockArea->setDockAreaFlag(ads::CDockAreaWidget::HideSingleWidgetTitleBar, true);
|
||||
ads::CDockComponentsFactory::resetDefaultFactory();
|
||||
DockManager->setComponentsFactory(ads::CDockComponentsFactory::factory());
|
||||
|
||||
// We create a calendar widget and clear all flags to prevent the dock area
|
||||
// from closing
|
||||
@@ -668,30 +657,6 @@ 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");
|
||||
@@ -700,6 +665,12 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -752,9 +723,6 @@ 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
|
||||
@@ -801,6 +769,9 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
// uncomment if you would like to enable dock widget auto hiding
|
||||
CDockManager::setAutoHideConfigFlags({CDockManager::DefaultAutoHideConfig});
|
||||
|
||||
// uncomment if you would like to disable closing auto hide widget with mouse click outside of auto hide container
|
||||
//CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideCloseOnOutsideMouseClick, false);
|
||||
|
||||
// uncomment if you would like to enable an equal distribution of the
|
||||
// available size of a splitter to all contained dock widgets
|
||||
// CDockManager::setConfigFlag(CDockManager::EqualSplitOnInsertion, true);
|
||||
@@ -1086,74 +1057,3 @@ void CMainWindow::lockWorkspace(bool Value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::createOpenGlWidget()
|
||||
{
|
||||
qDebug() << ":createOpenGlWidget ";
|
||||
static int OpenGlWidgetCount = 0;
|
||||
|
||||
auto w = new GLWidget();
|
||||
auto DockWidget = new ads::CDockWidget(QString("OpenGL Viewer %1").arg(OpenGlWidgetCount++));
|
||||
DockWidget->setIcon(svgIcon(":/adsdemo/images/deployed_code.svg"));
|
||||
DockWidget->setWidget(w, ads:: CDockWidget::ForceNoScrollArea);
|
||||
d->DockManager->addDockWidget(ads::RightDockWidgetArea, DockWidget);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::createCoin3DViewer()
|
||||
{
|
||||
qDebug() << ":createCoin3DViewer ";
|
||||
static int Coin3DWidgetCount = 0;
|
||||
static SoSeparator* Root;
|
||||
if (!Coin3DWidgetCount)
|
||||
{
|
||||
Root = new SoSeparator();
|
||||
Root->ref();
|
||||
auto Cone = new SoCone();
|
||||
Root->addChild(Cone);
|
||||
}
|
||||
|
||||
auto Viewer = new SoQtExaminerViewer(this, nullptr, true, SoQtFullViewer::BUILD_ALL);
|
||||
Viewer->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
|
||||
Viewer->setAnimationEnabled(false);
|
||||
Viewer->setFeedbackVisibility(true);
|
||||
Viewer->setSampleBuffers(4);
|
||||
Viewer->setSceneGraph(Root);
|
||||
//d->Viewer->setBackgroundColor(toSbColor(QColor(38, 38, 38)));
|
||||
auto DockWidget = new ads::CDockWidget(QString("Coin3D Viewer %1").arg(Coin3DWidgetCount++));
|
||||
DockWidget->setIcon(svgIcon(":/adsdemo/images/category.svg"));
|
||||
DockWidget->setWidget(Viewer->getWidget(), ads:: CDockWidget::ForceNoScrollArea);
|
||||
d->DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::createQuarterViewer()
|
||||
{
|
||||
qDebug() << ":createQuarterViewer ";
|
||||
static int QuarterWidgetCount = 0;
|
||||
static SoSeparator* Root;
|
||||
if (!QuarterWidgetCount)
|
||||
{
|
||||
Root = new SoSeparator();
|
||||
Root->ref();
|
||||
SoBaseColor * col = new SoBaseColor;
|
||||
col->rgb = SbColor(1, 1, 0);
|
||||
Root->addChild(col);
|
||||
Root->addChild(new SoCone);
|
||||
}
|
||||
|
||||
using namespace SIM::Coin3D::Quarter;
|
||||
auto Viewer = new QuarterWidget();
|
||||
Viewer->setTransparencyType(QuarterWidget::SORTED_OBJECT_BLEND);
|
||||
Viewer->setNavigationModeFile();
|
||||
Viewer->setSceneGraph(Root);
|
||||
//d->Viewer->setBackgroundColor(toSbColor(QColor(38, 38, 38)));
|
||||
auto DockWidget = new ads::CDockWidget(QString("Quarter Viewer %1").arg(QuarterWidgetCount++));
|
||||
DockWidget->setIcon(svgIcon(":/adsdemo/images/category.svg"));
|
||||
DockWidget->setWidget(Viewer, ads:: CDockWidget::ForceNoScrollArea);
|
||||
d->DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +69,6 @@ private slots:
|
||||
void applyVsStyle();
|
||||
void createImageViewer();
|
||||
void lockWorkspace(bool Value);
|
||||
void createOpenGlWidget();
|
||||
void createCoin3DViewer();
|
||||
void createQuarterViewer();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
58
demo/MyDockAreaTitleBar.h
Normal file
58
demo/MyDockAreaTitleBar.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef QTADS_MYDOCKAREATITLEBAR_H
|
||||
#define QTADS_MYDOCKAREATITLEBAR_H
|
||||
/*******************************************************************************
|
||||
** Qt Advanced Docking System
|
||||
** Copyright (C) 2017 Uwe Kindler
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <DockAreaTitleBar.h>
|
||||
|
||||
|
||||
/**
|
||||
* Custom DockAreaTitleBar that adds a custom context menu
|
||||
*/
|
||||
class MyDockAreaTitleBar : public ads::CDockAreaTitleBar
|
||||
{
|
||||
public:
|
||||
explicit MyDockAreaTitleBar(ads::CDockAreaWidget *parent) :
|
||||
CDockAreaTitleBar(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QMenu* buildContextMenu(QMenu*) override
|
||||
{
|
||||
auto menu = ads::CDockAreaTitleBar::buildContextMenu(nullptr);
|
||||
menu->addSeparator();
|
||||
auto action = menu->addAction(tr("Format HardDrive"));
|
||||
|
||||
connect(action, &QAction::triggered, this, [this]()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("No, just kidding");
|
||||
msgBox.setStandardButtons(QMessageBox::Abort);
|
||||
msgBox.setDefaultButton(QMessageBox::Abort);
|
||||
msgBox.exec();
|
||||
});
|
||||
|
||||
return menu;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QTADS_MYDOCKAREATITLEBAR_H
|
||||
@@ -1,9 +1,8 @@
|
||||
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||
|
||||
|
||||
TARGET = AdvancedDockingSystemDemo
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
QT += core gui widgets quick quickwidgets opengl
|
||||
QT += core gui widgets quick quickwidgets
|
||||
|
||||
include(../ads.pri)
|
||||
|
||||
@@ -11,8 +10,6 @@ lessThan(QT_MAJOR_VERSION, 6) {
|
||||
win32 {
|
||||
QT += axcontainer
|
||||
}
|
||||
} else {
|
||||
QT += openglwidgets
|
||||
}
|
||||
|
||||
CONFIG += c++14
|
||||
@@ -29,19 +26,14 @@ HEADERS += \
|
||||
MainWindow.h \
|
||||
StatusDialog.h \
|
||||
ImageViewer.h \
|
||||
RenderWidget.h \
|
||||
glwidget.h \
|
||||
logo.h
|
||||
|
||||
RenderWidget.h
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
MainWindow.cpp \
|
||||
StatusDialog.cpp \
|
||||
ImageViewer.cpp \
|
||||
RenderWidget.cpp \
|
||||
glwidget.cpp \
|
||||
logo.cpp
|
||||
RenderWidget.cpp
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
@@ -55,24 +47,3 @@ 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
|
||||
|
||||
@@ -39,7 +39,5 @@
|
||||
<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>
|
||||
|
||||
@@ -1,280 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// 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
|
||||
@@ -1,5 +0,0 @@
|
||||
<?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>
|
||||
|
Before Width: | Height: | Size: 755 B |
@@ -1,5 +0,0 @@
|
||||
<?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>
|
||||
|
Before Width: | Height: | Size: 791 B |
103
demo/logo.cpp
103
demo/logo.cpp
@@ -1,103 +0,0 @@
|
||||
// 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
28
demo/logo.h
@@ -1,28 +0,0 @@
|
||||
// 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,7 +3,6 @@
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QQuickWindow>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -42,8 +41,7 @@ int main(int argc, char *argv[])
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
#endif
|
||||
#endif
|
||||
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
|
||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||
std::shared_ptr<int> b;
|
||||
QApplication a(argc, argv);
|
||||
a.setApplicationName("Advanced Docking System Demo");
|
||||
a.setQuitOnLastWindowClosed(true);
|
||||
|
||||
BIN
doc/cfg_flag_AutoHideOpenOnDragHover.gif
Normal file
BIN
doc/cfg_flag_AutoHideOpenOnDragHover.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 269 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 364 KiB After Width: | Height: | Size: 382 KiB |
@@ -29,8 +29,8 @@
|
||||
- [`MiddleMouseButtonClosesTab`](#middlemousebuttonclosestab)
|
||||
- [`DisableTabTextEliding`](#disabletabtexteliding)
|
||||
- [`ShowTabTextOnlyForActiveTab`](#showtabtextonlyforactivetab)
|
||||
- [Auto-Hide Configuration Flags](#auto-hide-configuration-flags)
|
||||
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
|
||||
- [`DoubleClickUndocksWidget`](#doubleclickundockswidget)
|
||||
- [Auto Hide Dock Widgets](#auto-hide-dock-widgets)
|
||||
- [Pinning Auto-Hide Widgets to a certain border](#pinning-auto-hide-widgets-to-a-certain-border)
|
||||
- [Show / Hide Auto-Hide Widgets via Mouse Over](#show--hide-auto-hide-widgets-via-mouse-over)
|
||||
- [Drag \& Drop to Auto-Hide](#drag--drop-to-auto-hide)
|
||||
@@ -39,6 +39,7 @@
|
||||
- [Auto-Hide Drag to Float / Dock](#auto-hide-drag-to-float--dock)
|
||||
- [Auto-Hide Context Menu](#auto-hide-context-menu)
|
||||
- [Adding Auto Hide Widgets](#adding-auto-hide-widgets)
|
||||
- [Auto-Hide Configuration Flags](#auto-hide-configuration-flags)
|
||||
- [Setting Auto-Hide Flags](#setting-auto-hide-flags)
|
||||
- [`AutoHideFeatureEnabled`](#autohidefeatureenabled)
|
||||
- [`DockAreaHasAutoHideButton`](#dockareahasautohidebutton)
|
||||
@@ -49,6 +50,8 @@
|
||||
- [`AutoHideCloseButtonCollapsesDock`](#autohideclosebuttoncollapsesdock)
|
||||
- [`AutoHideHasCloseButton`](#autohidehasclosebutton)
|
||||
- [`AutoHideHasMinimizeButton`](#autohidehasminimizebutton)
|
||||
- [`AutoHideOpenOnDragHover`](#autohideopenondraghover)
|
||||
- [`AutoHideCloseOnOutsideMouseClick`](#autohidecloseonoutsidemouseclick)
|
||||
- [DockWidget Feature Flags](#dockwidget-feature-flags)
|
||||
- [`DockWidgetClosable`](#dockwidgetclosable)
|
||||
- [`DockWidgetMovable`](#dockwidgetmovable)
|
||||
@@ -62,6 +65,8 @@
|
||||
- [Central Widget](#central-widget)
|
||||
- [Empty Dock Area](#empty-dock-area)
|
||||
- [Custom Close Handling](#custom-close-handling)
|
||||
- [Globally Lock Docking Features](#globally-lock-docking-features)
|
||||
- [Dock Widget Size / Minimum Size Handling](#dock-widget-size--minimum-size-handling)
|
||||
- [Styling](#styling)
|
||||
- [Disabling the Internal Style Sheet](#disabling-the-internal-style-sheet)
|
||||
|
||||
@@ -150,7 +155,7 @@ This ie enabled by default to minimize the size of the saved data.
|
||||
|
||||
### `TabCloseButtonIsToolButton`
|
||||
|
||||
If enabled the tab close buttons will be `QToolButtons` instead of `QPushButtons` -
|
||||
If enabled the tab close buttons will be `QToolButtons` instead of `QPushButtons` -
|
||||
disabled by default. Normally the default configuration should be ok but if your
|
||||
application requires `QToolButtons` instead of `QPushButtons` for styling reasons
|
||||
or for any other reasons, then you can enable this flag.
|
||||
@@ -181,7 +186,7 @@ constant, that means, if enabled, the tabs need more space.
|
||||
|
||||
### `DragPreviewIsDynamic`
|
||||
|
||||
If non-opaque undocking is enabled, this flag defines the behavior of the drag
|
||||
If non-opaque undocking is enabled, this flag defines the behavior of the drag
|
||||
preview window. If this flag is enabled, then it will give the user the
|
||||
impression, that the floating drag preview is dynamically adjusted to the drop
|
||||
area. In order to give the perfect impression, you should disable the flags
|
||||
@@ -197,7 +202,7 @@ CDockManager::setConfigFlag(CDockManager::DragPreviewHasWindowFrame, false);
|
||||
|
||||
### `DragPreviewShowsContentPixmap`
|
||||
|
||||
If non-opaque undocking is enabled, the created drag preview window shows a
|
||||
If non-opaque undocking is enabled, the created drag preview window shows a
|
||||
copy of the content of the dock widget / dock are that is dragged, if this
|
||||
flag is enabled (default).
|
||||
|
||||
@@ -210,7 +215,7 @@ like window without any content.
|
||||
|
||||
### `DragPreviewHasWindowFrame`
|
||||
|
||||
If non-opaque undocking is enabled, then this flag configures if the drag
|
||||
If non-opaque undocking is enabled, then this flag configures if the drag
|
||||
preview is frameless (default) or looks like a real window. If it is enabled,
|
||||
then the drag preview is a transparent window with a system window frame.
|
||||
|
||||
@@ -378,7 +383,7 @@ ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar
|
||||
|
||||
If you have a content widget that does not support focussing for some reason
|
||||
(like `QVTKOpenGLStereoWidget` from the [VTK library](https://github.com/Kitware/VTK)),
|
||||
then you can manually switch the focus by reacting on mouse events. The
|
||||
then you can manually switch the focus by reacting on mouse events. The
|
||||
following code shows, how to install en event filter on the `QVTKOpenGLStereoWidget`
|
||||
to properly switch the focus on `QEvent::MouseButtonPress`:
|
||||
|
||||
@@ -422,7 +427,7 @@ bool CMainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||
### `EqualSplitOnInsertion`
|
||||
|
||||
This flag configures how the space is distributed if a new dock widget is
|
||||
inserted into an existing dock area. The flag is disabled by default. If 3
|
||||
inserted into an existing dock area. The flag is disabled by default. If 3
|
||||
dock widgets are inserted with the following code
|
||||
|
||||
```c++
|
||||
@@ -433,7 +438,7 @@ then this is the result, if the flag is disabled:
|
||||
|
||||

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

|
||||
@@ -495,13 +500,16 @@ for active tabs. Inactive tabs only show their icon:
|
||||
|
||||

|
||||
|
||||
## Auto-Hide Configuration Flags
|
||||
### `DoubleClickUndocksWidget`
|
||||
|
||||
### Auto Hide Dock Widgets
|
||||
If the flag is set (default), a double click on a tab undocks the dock widget.
|
||||
If you would like to disable undocking, just clear this flag.
|
||||
|
||||
## Auto Hide Dock Widgets
|
||||
|
||||
The Advanced Docking System supports "Auto-Hide" functionality for **all**
|
||||
dock containers. The "Auto Hide" feature allows to display more information
|
||||
using less screen space by hiding or showing windows pinned to one of the
|
||||
using less screen space by hiding or showing windows pinned to one of the
|
||||
four dock container borders.
|
||||
|
||||
Enabling this feature adds a button with a pin icon to each dock area.
|
||||
@@ -563,7 +571,7 @@ That means, you can drag them to a different border or sidebar:
|
||||
|
||||
### Auto-Hide Tab Sorting
|
||||
|
||||
You can drag Auto-Hide tabs to a new position in the current sidebar
|
||||
You can drag Auto-Hide tabs to a new position in the current sidebar
|
||||
to sort them:
|
||||
|
||||

|
||||
@@ -598,6 +606,8 @@ DockManager->addAutoHideDockWidget(SideBarLeft, TableDockWidget);
|
||||
|
||||
See `autohide` example or the demo application to learn how it works.
|
||||
|
||||
## Auto-Hide Configuration Flags
|
||||
|
||||
### Setting Auto-Hide Flags
|
||||
|
||||
The Advanced Docking System has a number of global configuration flags to
|
||||
@@ -632,7 +642,7 @@ the other Auto-Hide flags will be evaluated.
|
||||
|
||||
### `DockAreaHasAutoHideButton`
|
||||
|
||||
If this flag is set (default), then each dock area has a pin button in the title
|
||||
If this flag is set (default), then each dock area has a pin button in the title
|
||||
bar to toggle Auto-Hide state.
|
||||
|
||||

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

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

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

|
||||
|
||||
Said dock must be set to accept drops to hide when cursor leaves its scope. See `AutoHideDragNDropExample` for more details.
|
||||
|
||||
### `AutoHideCloseOnOutsideMouseClick`
|
||||
|
||||
If this flag is set (default), the auto hide dock container will collapse if the
|
||||
user clicks outside of the container. If not set, the auto hide container can be
|
||||
closed only via click on auto hide sidebar tab.
|
||||
|
||||
## DockWidget Feature Flags
|
||||
|
||||
### `DockWidgetClosable`
|
||||
@@ -825,6 +849,93 @@ Normally clicking the close button of a dock widget will just hide the widget an
|
||||
|
||||
When an entire area is closed, the default behavior is to hide the dock widgets it contains regardless of the `DockWidgetDeleteOnClose` flag except if there is only one dock widget. In this special case, the `DockWidgetDeleteOnClose` flag is followed. This behavior can be changed by setting the `DockWidgetForceCloseWithArea` flag to all the dock widgets that needs to be closed with their area.
|
||||
|
||||
## Globally Lock Docking Features
|
||||
|
||||
It is possible to globally lock features of all dock widgets to "freeze" the
|
||||
current workspace layout. That means, you can now lock your workspace
|
||||
to avoid accidentally dragging a docked view. When locking wasn't possible,
|
||||
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 to define which features
|
||||
shall get locked:
|
||||
|
||||
- `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 all dock widget features
|
||||
globally.
|
||||
|
||||
```c++
|
||||
DockManager->lockDockWidgetFeaturesGlobally();
|
||||
DockManager->lockDockWidgetFeaturesGlobally(CDockWidget::NoDockWidgetFeatures);
|
||||
```
|
||||
|
||||
## Dock Widget Size / Minimum Size Handling
|
||||
|
||||
There are several `CDockWidget` mode enums to control how a `CDockWidget` is
|
||||
resized and how the docking system handles the minimum size of a dockwidget.
|
||||
|
||||
The first one is the `eInsertMode` enum:
|
||||
|
||||
```c++
|
||||
enum eInsertMode
|
||||
{
|
||||
AutoScrollArea,
|
||||
ForceScrollArea,
|
||||
ForceNoScrollArea
|
||||
};
|
||||
```
|
||||
|
||||
The InsertMode defines how the widget is inserted into the dock widget, when you
|
||||
call the `CDockWidget::setWidget` method:
|
||||
|
||||
```c++
|
||||
DockWidget->setWidget(widget, CDockWidget::AutoScrollArea);
|
||||
```
|
||||
|
||||
The content of a dock widget should be resizable do a very small size to
|
||||
prevent the dock widget from blocking the resizing. To ensure, that a
|
||||
dock widget can be resized very well, it is better to insert the content
|
||||
widget into a scroll area or to provide a widget that is already a scroll
|
||||
area or that contains a scroll area (such as an `QAbstractItemView`)
|
||||
If the InsertMode is `AutoScrollArea`, the DockWidget tries to automatically
|
||||
detect how to insert the given widget. If the widget is derived from
|
||||
`QScrollArea` (i.e. an `QAbstractItemView`), then the widget is inserted
|
||||
directly. If the given widget is not a scroll area, the widget will be
|
||||
inserted into a scroll area.
|
||||
|
||||
To force insertion into a scroll area, you can also provide the InsertMode
|
||||
`ForceScrollArea`. In this case a scroll area will also be created for content
|
||||
widgets that are derived from `QScrollArea` To prevent insertion into a scroll
|
||||
area, you can provide the InsertMode `ForceNoScrollArea`. In this case, the
|
||||
content widget is always inserted directly.
|
||||
|
||||
A second enum, the `eMinimumSizeHintMode` defines, which value will be returned
|
||||
from the `CDockWidget::minimumSizeHint()` function:
|
||||
|
||||
```c++
|
||||
enum eMinimumSizeHintMode
|
||||
{
|
||||
MinimumSizeHintFromDockWidget,
|
||||
MinimumSizeHintFromContent,
|
||||
MinimumSizeHintFromDockWidgetMinimumSize,
|
||||
MinimumSizeHintFromContentMinimumSize,
|
||||
};
|
||||
```
|
||||
|
||||
To ensure, that a dock widget does not block resizing, the dock widget
|
||||
reimplements `minimumSizeHint()` function to return a very small minimum
|
||||
size hint. If you would like to adhere the `minimumSizeHint()` from the
|
||||
content widget, then set the `minimumSizeHintMode()` to
|
||||
`MinimumSizeHintFromContent`. If you would like to use the `minimumSize()`
|
||||
value of the content widget or the dock widget, then you can use the
|
||||
`MinimumSizeHintFromDockWidgetMinimumSize` or
|
||||
`MinimumSizeHintFromContentMinimumSize` modes.
|
||||
|
||||
## Styling
|
||||
|
||||
The Advanced Docking System supports styling via [Qt Style Sheets](https://doc.qt.io/qt-5/stylesheet.html). All components like splitters, tabs, buttons, titlebar and
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(QtADSExamples LANGUAGES CXX VERSION ${VERSION_SHORT})
|
||||
add_subdirectory(simple)
|
||||
add_subdirectory(hideshow)
|
||||
@@ -6,5 +6,6 @@ add_subdirectory(sidebar)
|
||||
add_subdirectory(deleteonclose)
|
||||
add_subdirectory(centralwidget)
|
||||
add_subdirectory(autohide)
|
||||
add_subdirectory(autohidedragndrop)
|
||||
add_subdirectory(emptydockarea)
|
||||
add_subdirectory(dockindock)
|
||||
add_subdirectory(dockindock)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_autohide VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -9,7 +9,7 @@ add_executable(AutoHideExample WIN32
|
||||
mainwindow.ui
|
||||
)
|
||||
target_include_directories(AutoHideExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(AutoHideExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(AutoHideExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(AutoHideExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
29
examples/autohidedragndrop/CMakeLists.txt
Normal file
29
examples/autohidedragndrop/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_autohide_dragndrop VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
add_executable(AutoHideDragNDropExample WIN32
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
mainwindow.ui
|
||||
droppableitem.cpp
|
||||
)
|
||||
target_include_directories(AutoHideDragNDropExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(AutoHideDragNDropExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(AutoHideDragNDropExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
set_target_properties(AutoHideDragNDropExample PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTORCC ON
|
||||
AUTOUIC ON
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
VERSION ${VERSION_SHORT}
|
||||
EXPORT_NAME "Qt Advanced Docking System Auto Hide With Drag N Drop Example"
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
|
||||
)
|
||||
36
examples/autohidedragndrop/autohidedragndrop.pro
Normal file
36
examples/autohidedragndrop/autohidedragndrop.pro
Normal file
@@ -0,0 +1,36 @@
|
||||
ADS_OUT_ROOT = $${OUT_PWD}/../..
|
||||
|
||||
QT += core gui widgets
|
||||
|
||||
TARGET = AutoHideDragNDropExample
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
TEMPLATE = app
|
||||
CONFIG += c++14
|
||||
CONFIG += debug_and_release
|
||||
adsBuildStatic {
|
||||
DEFINES += ADS_STATIC
|
||||
}
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
droppableitem.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
droppableitem.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||
include(../../ads.pri)
|
||||
INCLUDEPATH += ../../src
|
||||
DEPENDPATH += ../../src
|
||||
|
||||
38
examples/autohidedragndrop/droppableitem.cpp
Normal file
38
examples/autohidedragndrop/droppableitem.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "droppableitem.h"
|
||||
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDragLeaveEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMimeData>
|
||||
#include <qsizepolicy.h>
|
||||
|
||||
DroppableItem::DroppableItem(const QString& text, QWidget* parent)
|
||||
: QPushButton(text, parent)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
setSizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding);
|
||||
}
|
||||
|
||||
void DroppableItem::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasText())
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
setCursor(Qt::DragMoveCursor);
|
||||
}
|
||||
}
|
||||
|
||||
void DroppableItem::dragLeaveEvent(QDragLeaveEvent* event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
unsetCursor();
|
||||
}
|
||||
|
||||
void DroppableItem::dropEvent(QDropEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasText())
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
setText(event->mimeData()->text());
|
||||
}
|
||||
}
|
||||
19
examples/autohidedragndrop/droppableitem.h
Normal file
19
examples/autohidedragndrop/droppableitem.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <QObject>
|
||||
#include <QPushButton>
|
||||
|
||||
class QDragEnterEvent;
|
||||
class QDragLeaveEvent;
|
||||
class QDropEvent;
|
||||
|
||||
class DroppableItem : public QPushButton
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
DroppableItem(const QString& text = QString(), QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
};
|
||||
10
examples/autohidedragndrop/main.cpp
Normal file
10
examples/autohidedragndrop/main.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <mainwindow.h>
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
CMainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
84
examples/autohidedragndrop/main.py
Normal file
84
examples/autohidedragndrop/main.py
Normal file
@@ -0,0 +1,84 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PyQt5 import uic
|
||||
from PyQt5.QtCore import Qt, QTimer, QDir, QSignalBlocker
|
||||
from PyQt5.QtGui import QCloseEvent, QIcon
|
||||
from PyQt5.QtWidgets import (QApplication, QLabel, QCalendarWidget, QFrame, QTreeView,
|
||||
QTableWidget, QFileSystemModel, QPlainTextEdit, QToolBar,
|
||||
QWidgetAction, QComboBox, QAction, QSizePolicy, QInputDialog)
|
||||
|
||||
import PyQtAds as QtAds
|
||||
|
||||
UI_FILE = os.path.join(os.path.dirname(__file__), 'mainwindow.ui')
|
||||
MainWindowUI, MainWindowBase = uic.loadUiType(UI_FILE)
|
||||
|
||||
class MainWindow(MainWindowUI, MainWindowBase):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setupUi(self)
|
||||
|
||||
QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.OpaqueSplitterResize, True)
|
||||
QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.XmlCompressionEnabled, False)
|
||||
QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.FocusHighlighting, True)
|
||||
QtAds.CDockManager.setAutoHideConfigFlag(QtAds.CDockManager.AutoHideOpenOnDragHover, True);
|
||||
self.dock_manager = QtAds.CDockManager(self)
|
||||
|
||||
# Set central widget
|
||||
text_edit = QPlainTextEdit()
|
||||
text_edit.setPlaceholderText("This is the central editor. Enter your text here.")
|
||||
central_dock_widget = QtAds.CDockWidget("CentralWidget")
|
||||
central_dock_widget.setWidget(text_edit)
|
||||
central_dock_area = self.dock_manager.setCentralWidget(central_dock_widget)
|
||||
central_dock_area.setAllowedAreas(QtAds.DockWidgetArea.OuterDockAreas)
|
||||
|
||||
|
||||
droppable_item = DroppableItem("Drop text here.")
|
||||
drop_dock_widget = QtAds.CDockWidget("Tab")
|
||||
drop_dock_widget.setWidget(droppable_item)
|
||||
drop_dock_widget.setMinimumSizeHintMode(QtAds.CDockWidget.MinimumSizeHintFromDockWidget)
|
||||
drop_dock_widget.setMinimumSize(200, 150)
|
||||
drop_dock_widget.setAcceptDrops(True)
|
||||
drop_area = self.dock_manager.addDockWidget(QtAds.DockWidgetArea.LeftDockWidgetArea, drop_dock_widget)
|
||||
drop_area.setAcceptDrops(True)
|
||||
self.menuView.addAction(drop_dock_widget.toggleViewAction())
|
||||
|
||||
self.create_perspective_ui()
|
||||
|
||||
def create_perspective_ui(self):
|
||||
save_perspective_action = QAction("Create Perspective", self)
|
||||
save_perspective_action.triggered.connect(self.save_perspective)
|
||||
perspective_list_action = QWidgetAction(self)
|
||||
self.perspective_combobox = QComboBox(self)
|
||||
self.perspective_combobox.setSizeAdjustPolicy(QComboBox.AdjustToContents)
|
||||
self.perspective_combobox.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||
self.perspective_combobox.activated[str].connect(self.dock_manager.openPerspective)
|
||||
perspective_list_action.setDefaultWidget(self.perspective_combobox)
|
||||
self.toolBar.addSeparator()
|
||||
self.toolBar.addAction(perspective_list_action)
|
||||
self.toolBar.addAction(save_perspective_action)
|
||||
|
||||
def save_perspective(self):
|
||||
perspective_name, ok = QInputDialog.getText(self, "Save Perspective", "Enter Unique name:")
|
||||
if not ok or not perspective_name:
|
||||
return
|
||||
|
||||
self.dock_manager.addPerspective(perspective_name)
|
||||
blocker = QSignalBlocker(self.perspective_combobox)
|
||||
self.perspective_combobox.clear()
|
||||
self.perspective_combobox.addItems(self.dock_manager.perspectiveNames())
|
||||
self.perspective_combobox.setCurrentText(perspective_name)
|
||||
|
||||
def closeEvent(self, event: QCloseEvent):
|
||||
self.dock_manager.deleteLater()
|
||||
super().closeEvent(event)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
w = MainWindow()
|
||||
w.show()
|
||||
app.exec_()
|
||||
131
examples/autohidedragndrop/mainwindow.cpp
Normal file
131
examples/autohidedragndrop/mainwindow.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
#include "mainwindow.h"
|
||||
#include "droppableitem.h"
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QWidgetAction>
|
||||
#include <QFileSystemModel>
|
||||
#include <QTableWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QSettings>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QToolBar>
|
||||
|
||||
#include "AutoHideDockContainer.h"
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
|
||||
using namespace ads;
|
||||
|
||||
CMainWindow::CMainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::CMainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
||||
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover, true);
|
||||
CDockManager::setConfigParam(CDockManager::AutoHideOpenOnDragHoverDelay_ms, 500);
|
||||
DockManager = new CDockManager(this);
|
||||
|
||||
// Set central widget
|
||||
QPlainTextEdit* w = new QPlainTextEdit();
|
||||
w->setPlaceholderText("This is the central editor. Enter your text here.");
|
||||
CDockWidget* CentralDockWidget = new CDockWidget("CentralWidget");
|
||||
CentralDockWidget->setWidget(w);
|
||||
auto* CentralDockArea = DockManager->setCentralWidget(CentralDockWidget);
|
||||
CentralDockArea->setAllowedAreas(DockWidgetArea::OuterDockAreas);
|
||||
|
||||
{
|
||||
DroppableItem* droppableItem = new DroppableItem("Drop text here.");
|
||||
CDockWidget* dropDockWidget = new CDockWidget("Tab 1");
|
||||
dropDockWidget->setWidget(droppableItem);
|
||||
dropDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||
dropDockWidget->setMinimumSize(200,150);
|
||||
dropDockWidget->setAcceptDrops(true);
|
||||
const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::SideBarLeft, dropDockWidget);
|
||||
autoHideContainer->setSize(480);
|
||||
autoHideContainer->setAcceptDrops(true);
|
||||
ui->menuView->addAction(dropDockWidget->toggleViewAction());
|
||||
}
|
||||
{
|
||||
DroppableItem* droppableItem = new DroppableItem("Drop text here.");
|
||||
CDockWidget* dropDockWidget = new CDockWidget("Tab 2");
|
||||
dropDockWidget->setWidget(droppableItem);
|
||||
dropDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||
dropDockWidget->setMinimumSize(200,150);
|
||||
dropDockWidget->setAcceptDrops(true);
|
||||
const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::SideBarRight, dropDockWidget);
|
||||
autoHideContainer->setSize(480);
|
||||
autoHideContainer->setAcceptDrops(true);
|
||||
ui->menuView->addAction(dropDockWidget->toggleViewAction());
|
||||
}
|
||||
|
||||
QTableWidget* propertiesTable = new QTableWidget();
|
||||
propertiesTable->setColumnCount(3);
|
||||
propertiesTable->setRowCount(10);
|
||||
CDockWidget* PropertiesDockWidget = new CDockWidget("Properties");
|
||||
PropertiesDockWidget->setWidget(propertiesTable);
|
||||
PropertiesDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||
PropertiesDockWidget->resize(250, 150);
|
||||
PropertiesDockWidget->setMinimumSize(200,150);
|
||||
DockManager->addDockWidget(DockWidgetArea::RightDockWidgetArea, PropertiesDockWidget, CentralDockArea);
|
||||
ui->menuView->addAction(PropertiesDockWidget->toggleViewAction());
|
||||
|
||||
createPerspectiveUi();
|
||||
}
|
||||
|
||||
CMainWindow::~CMainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::createPerspectiveUi()
|
||||
{
|
||||
SavePerspectiveAction = new QAction("Create Perspective", this);
|
||||
connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
|
||||
PerspectiveListAction = new QWidgetAction(this);
|
||||
PerspectiveComboBox = new QComboBox(this);
|
||||
PerspectiveComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
connect(PerspectiveComboBox, SIGNAL(currentTextChanged(const QString&)),
|
||||
DockManager, SLOT(openPerspective(const QString&)));
|
||||
PerspectiveListAction->setDefaultWidget(PerspectiveComboBox);
|
||||
ui->toolBar->addSeparator();
|
||||
ui->toolBar->addAction(PerspectiveListAction);
|
||||
ui->toolBar->addAction(SavePerspectiveAction);
|
||||
}
|
||||
|
||||
|
||||
void CMainWindow::savePerspective()
|
||||
{
|
||||
QString PerspectiveName = QInputDialog::getText(this, "Save Perspective", "Enter unique name:");
|
||||
if (PerspectiveName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DockManager->addPerspective(PerspectiveName);
|
||||
QSignalBlocker Blocker(PerspectiveComboBox);
|
||||
PerspectiveComboBox->clear();
|
||||
PerspectiveComboBox->addItems(DockManager->perspectiveNames());
|
||||
PerspectiveComboBox->setCurrentText(PerspectiveName);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
// Delete dock manager here to delete all floating widgets. This ensures
|
||||
// that all top level windows of the dock manager are properly closed
|
||||
DockManager->deleteLater();
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
43
examples/autohidedragndrop/mainwindow.h
Normal file
43
examples/autohidedragndrop/mainwindow.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QComboBox>
|
||||
#include <QWidgetAction>
|
||||
|
||||
#include "DockManager.h"
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockWidget.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class CMainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class CMainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMainWindow(QWidget *parent = nullptr);
|
||||
~CMainWindow();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
private:
|
||||
QAction* SavePerspectiveAction = nullptr;
|
||||
QWidgetAction* PerspectiveListAction = nullptr;
|
||||
QComboBox* PerspectiveComboBox = nullptr;
|
||||
|
||||
Ui::CMainWindow *ui;
|
||||
|
||||
ads::CDockManager* DockManager;
|
||||
ads::CDockAreaWidget* StatusDockArea;
|
||||
ads::CDockWidget* TimelineDockWidget;
|
||||
|
||||
void createPerspectiveUi();
|
||||
|
||||
private slots:
|
||||
void savePerspective();
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
47
examples/autohidedragndrop/mainwindow.ui
Normal file
47
examples/autohidedragndrop/mainwindow.ui
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CMainWindow</class>
|
||||
<widget class="QMainWindow" name="CMainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1284</width>
|
||||
<height>757</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1284</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuView">
|
||||
<property name="title">
|
||||
<string>View</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuView"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_centralwidget VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -9,7 +9,7 @@ add_executable(CentralWidgetExample WIN32
|
||||
mainwindow.ui
|
||||
)
|
||||
target_include_directories(CentralWidgetExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(CentralWidgetExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(CentralWidgetExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(CentralWidgetExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
28
examples/configflags/CMakeLists.txt
Normal file
28
examples/configflags/CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_centralwidget VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
add_executable(configFlagsExample WIN32
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
mainwindow.ui
|
||||
)
|
||||
target_include_directories(CentralWidgetExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(CentralWidgetExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(CentralWidgetExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
set_target_properties(CentralWidgetExample PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTORCC ON
|
||||
AUTOUIC ON
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
VERSION ${VERSION_SHORT}
|
||||
EXPORT_NAME "Qt Advanced Docking System Central Widget Example"
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin"
|
||||
)
|
||||
34
examples/configflags/configflags.pro
Normal file
34
examples/configflags/configflags.pro
Normal file
@@ -0,0 +1,34 @@
|
||||
ADS_OUT_ROOT = $${OUT_PWD}/../..
|
||||
|
||||
QT += core gui widgets
|
||||
|
||||
TARGET = ConfigFlagsExample
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
TEMPLATE = app
|
||||
CONFIG += c++14
|
||||
CONFIG += debug_and_release
|
||||
adsBuildStatic {
|
||||
DEFINES += ADS_STATIC
|
||||
}
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||
include(../../ads.pri)
|
||||
INCLUDEPATH += ../../src
|
||||
DEPENDPATH += ../../src
|
||||
|
||||
10
examples/configflags/main.cpp
Normal file
10
examples/configflags/main.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <mainwindow.h>
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
CMainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
65
examples/configflags/mainwindow.cpp
Normal file
65
examples/configflags/mainwindow.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QToolBar>
|
||||
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
|
||||
|
||||
using namespace ads;
|
||||
|
||||
|
||||
CMainWindow::CMainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::CMainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Add the toolbar
|
||||
auto toolbar_ = addToolBar("Top Toolbar");
|
||||
|
||||
// Create the dock manager
|
||||
ads::CDockManager::setConfigFlags(ads::CDockManager::DefaultOpaqueConfig);
|
||||
ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasCloseButton,
|
||||
false);
|
||||
ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasUndockButton,
|
||||
false);
|
||||
ads::CDockManager::setConfigFlag(
|
||||
ads::CDockManager::DockAreaHasTabsMenuButton, false);
|
||||
auto DockManager = new ads::CDockManager(this);
|
||||
|
||||
// Create a dockable widget
|
||||
QLabel *l1 = new QLabel();
|
||||
l1->setWordWrap(true);
|
||||
l1->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||
l1->setText("Docking widget 1");
|
||||
ads::CDockWidget *dockWidget1 = new ads::CDockWidget("Dock 1");
|
||||
dockWidget1->setWidget(l1);
|
||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, dockWidget1);
|
||||
|
||||
QLabel *l2 = new QLabel();
|
||||
l2->setWordWrap(true);
|
||||
l2->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||
l2->setText("Docking widget 2");
|
||||
ads::CDockWidget *dockWidget2 = new ads::CDockWidget("Dock 2");
|
||||
dockWidget2->setWidget(l2);
|
||||
DockManager->addDockWidget(ads::RightDockWidgetArea, dockWidget2);
|
||||
|
||||
// Add menu actions
|
||||
ui->menuView->addAction(dockWidget1->toggleViewAction());
|
||||
ui->menuView->addAction(dockWidget2->toggleViewAction());
|
||||
toolbar_->addAction(dockWidget1->toggleViewAction());
|
||||
toolbar_->addAction(dockWidget2->toggleViewAction());
|
||||
}
|
||||
|
||||
|
||||
CMainWindow::~CMainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
27
examples/configflags/mainwindow.h
Normal file
27
examples/configflags/mainwindow.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QComboBox>
|
||||
#include <QWidgetAction>
|
||||
|
||||
#include "DockManager.h"
|
||||
#include "DockAreaWidget.h"
|
||||
#include "DockWidget.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class CMainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class CMainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMainWindow(QWidget *parent = nullptr);
|
||||
~CMainWindow();
|
||||
|
||||
private:
|
||||
Ui::CMainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
47
examples/configflags/mainwindow.ui
Normal file
47
examples/configflags/mainwindow.ui
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CMainWindow</class>
|
||||
<widget class="QMainWindow" name="CMainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1284</width>
|
||||
<height>757</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1284</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuView">
|
||||
<property name="title">
|
||||
<string>View</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuView"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_deleteonclose VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -7,7 +7,7 @@ add_executable(DeleteOnCloseTest WIN32
|
||||
main.cpp
|
||||
)
|
||||
target_include_directories(DeleteOnCloseTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(DeleteOnCloseTest PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(DeleteOnCloseTest PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(DeleteOnCloseTest PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_dockindock VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -12,7 +12,7 @@ add_executable(DockInDockExample WIN32
|
||||
mainframe.cpp
|
||||
)
|
||||
target_include_directories(DockInDockExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(DockInDockExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(DockInDockExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(DockInDockExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_centralwidget VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -9,7 +9,7 @@ add_executable(EmptyDockAreaExample WIN32
|
||||
mainwindow.ui
|
||||
)
|
||||
target_include_directories(EmptyDockAreaExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(EmptyDockAreaExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(EmptyDockAreaExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(EmptyDockAreaExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
@@ -32,9 +32,12 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||
, ui(new Ui::CMainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true);
|
||||
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
|
||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaHasCloseButton, false );
|
||||
ads::CDockManager::setConfigFlag( ads::CDockManager::AllTabsHaveCloseButton, true );
|
||||
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaHasUndockButton, false );
|
||||
ads::CDockManager::setConfigFlag( ads::CDockManager::DockAreaDynamicTabsMenuButtonVisibility, true );
|
||||
ads::CDockManager::setConfigFlag( ads::CDockManager::DisableTabTextEliding, true );
|
||||
ads::CDockManager::setConfigFlag( ads::CDockManager::DoubleClickUndocksWidget, false );
|
||||
DockManager = new CDockManager(this);
|
||||
|
||||
// Set central widget
|
||||
@@ -98,8 +101,13 @@ void CMainWindow::createPerspectiveUi()
|
||||
PerspectiveComboBox = new QComboBox(this);
|
||||
PerspectiveComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
PerspectiveComboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
connect(PerspectiveComboBox, &QComboBox::textActivated,
|
||||
DockManager, &CDockManager::openPerspective);
|
||||
#else
|
||||
connect(PerspectiveComboBox, SIGNAL(activated(const QString&)),
|
||||
DockManager, SLOT(openPerspective(const QString&)));
|
||||
#endif
|
||||
PerspectiveListAction->setDefaultWidget(PerspectiveComboBox);
|
||||
ui->toolBar->addSeparator();
|
||||
ui->toolBar->addAction(PerspectiveListAction);
|
||||
|
||||
@@ -2,10 +2,12 @@ TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS = \
|
||||
autohide \
|
||||
autohidedragndrop \
|
||||
centralwidget \
|
||||
simple \
|
||||
hideshow \
|
||||
sidebar \
|
||||
deleteonclose \
|
||||
emptydockarea \
|
||||
dockindock
|
||||
dockindock \
|
||||
configflags
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_hideshow VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -9,7 +9,7 @@ add_executable(HideShowExample WIN32
|
||||
MainWindow.ui
|
||||
)
|
||||
target_include_directories(HideShowExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(HideShowExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(HideShowExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(HideShowExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_sidebar VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -9,7 +9,7 @@ add_executable(SidebarExample WIN32
|
||||
MainWindow.ui
|
||||
)
|
||||
target_include_directories(SidebarExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(SidebarExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(SidebarExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(SidebarExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(ads_example_simple VERSION ${VERSION_SHORT})
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
|
||||
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
|
||||
@@ -9,7 +9,7 @@ add_executable(SimpleExample WIN32
|
||||
MainWindow.ui
|
||||
)
|
||||
target_include_directories(SimpleExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
|
||||
target_link_libraries(SimpleExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)
|
||||
target_link_libraries(SimpleExample PRIVATE qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
target_link_libraries(SimpleExample PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
@@ -12,10 +12,14 @@ class CTitleBarButton : QToolButton
|
||||
%End
|
||||
|
||||
public:
|
||||
CTitleBarButton(bool visible = true, QWidget* parent /TransferThis/ = Q_NULLPTR );
|
||||
CTitleBarButton(bool ShowInTitleBar, bool HideWhenDisabled, TitleBarButton ButtonId,
|
||||
QWidget* /TransferThis/ = Q_NULLPTR );
|
||||
virtual void setVisible(bool);
|
||||
void setShowInTitleBar(bool);
|
||||
|
||||
TitleBarButton buttonId() const;
|
||||
ads::CDockAreaTitleBar* titleBar() const;
|
||||
bool isInAutoHideArea() const;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *ev);
|
||||
@@ -44,13 +48,15 @@ public:
|
||||
ads::CDockAreaTabBar* tabBar() const;
|
||||
ads::CTitleBarButton* button(ads::TitleBarButton which) const;
|
||||
ads::CElidingLabel* autoHideTitleLabel() const;
|
||||
ads::CDockAreaWidget* dockAreaWidget() const;
|
||||
void updateDockWidgetActionsButtons();
|
||||
virtual void setVisible(bool Visible);
|
||||
void insertWidget(int index, QWidget *widget /Transfer/ );
|
||||
int indexOf(QWidget *widget) const;
|
||||
QString titleBarButtonToolTip(ads::TitleBarButton Button) const;
|
||||
void setAreaFloating();
|
||||
|
||||
void showAutoHideControls(bool Show);
|
||||
bool isAutoHide() const;
|
||||
|
||||
signals:
|
||||
void tabBarClicked(int index);
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
ads::CDockManager* dockManager() const;
|
||||
ads::CDockContainerWidget* dockContainer() const;
|
||||
ads::CAutoHideDockContainer* autoHideDockContainer() const;
|
||||
ads::CDockSplitter* parentSplitter() const;
|
||||
bool isAutoHide() const;
|
||||
void setAutoHideDockContainer(CAutoHideDockContainer*);
|
||||
virtual QSize minimumSizeHint() const;
|
||||
|
||||
@@ -20,13 +20,14 @@ class CDockContainerWidget : QFrame
|
||||
|
||||
protected:
|
||||
virtual bool event(QEvent *e);
|
||||
QSplitter* rootSplitter() const;
|
||||
ads::CDockSplitter* rootSplitter() const;
|
||||
ads::CAutoHideDockContainer* createAndSetupAutoHideContainer(ads::SideBarLocation area, ads::CDockWidget* DockWidget /Transfer/, int TabIndex = -1);
|
||||
void createRootSplitter();
|
||||
void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
|
||||
void dropWidget(QWidget* Widget, DockWidgetArea DropArea, CDockAreaWidget* TargetAreaWidget, int TabIndex = -1);
|
||||
void addDockArea(ads::CDockAreaWidget* DockAreaWidget /Transfer/, ads::DockWidgetArea area = ads::CenterDockWidgetArea);
|
||||
void removeDockArea(ads::CDockAreaWidget* area /TransferBack/);
|
||||
/*QList<QPointer<ads::CDockAreaWidget>> removeAllDockAreas();*/
|
||||
void saveState(QXmlStreamWriter& Stream) const;
|
||||
bool restoreState(CDockingStateReader& Stream, bool Testing);
|
||||
ads::CDockAreaWidget* lastAddedDockAreaWidget(ads::DockWidgetArea area) const;
|
||||
|
||||
@@ -172,6 +172,8 @@ public:
|
||||
FloatingContainerForceNativeTitleBar,
|
||||
FloatingContainerForceQWidgetTitleBar,
|
||||
MiddleMouseButtonClosesTab,
|
||||
DisableTabTextEliding,
|
||||
ShowTabTextOnlyForActiveTab,
|
||||
DefaultDockAreaButtons,
|
||||
DefaultBaseConfig,
|
||||
DefaultOpaqueConfig,
|
||||
@@ -188,6 +190,8 @@ public:
|
||||
AutoHideSideBarsIconOnly,
|
||||
AutoHideShowOnMouseOver,
|
||||
AutoHideCloseButtonCollapsesDock,
|
||||
AutoHideHasCloseButton,
|
||||
AutoHideHasMinimizeButton,
|
||||
DefaultAutoHideConfig,
|
||||
};
|
||||
typedef QFlags<ads::CDockManager::eAutoHideFlag> AutoHideFlags;
|
||||
@@ -245,6 +249,12 @@ public:
|
||||
void setSplitterSizes(ads::CDockAreaWidget *ContainedArea, const QList<int>& sizes);
|
||||
static void setFloatingContainersTitle(const QString& Title);
|
||||
static QString floatingContainersTitle();
|
||||
void setDockWidgetToolBarStyle(Qt::ToolButtonStyle Style, ads::CDockWidget::eState State);
|
||||
Qt::ToolButtonStyle dockWidgetToolBarStyle(ads::CDockWidget::eState State) const;
|
||||
void setDockWidgetToolBarIconSize(const QSize& IconSize, ads::CDockWidget::eState State);
|
||||
QSize dockWidgetToolBarIconSize(ads::CDockWidget::eState State) const;
|
||||
ads::CDockWidget::DockWidgetFeatures globallyLockedDockWidgetFeatures() const;
|
||||
void lockDockWidgetFeaturesGlobally(ads::CDockWidget::DockWidgetFeatures Features = ads::CDockWidget::GloballyLockableFeatures);
|
||||
|
||||
public slots:
|
||||
void endLeavingMinimizedState();
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
DefaultDockWidgetFeatures,
|
||||
AllDockWidgetFeatures,
|
||||
DockWidgetAlwaysCloseAndDelete,
|
||||
GloballyLockableFeatures,
|
||||
NoDockWidgetFeatures
|
||||
};
|
||||
typedef QFlags<ads::CDockWidget::DockWidgetFeature> DockWidgetFeatures;
|
||||
@@ -49,6 +50,12 @@ public:
|
||||
StateDocked,
|
||||
StateFloating
|
||||
};
|
||||
|
||||
enum eToolBarStyleSource
|
||||
{
|
||||
ToolBarStyleFromDockManager,
|
||||
ToolBarStyleFromDockWidget
|
||||
};
|
||||
|
||||
enum eInsertMode
|
||||
{
|
||||
@@ -72,7 +79,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
CDockWidget(const QString &title, QWidget* parent /TransferThis/ = 0);
|
||||
CDockWidget(const QString &title, QWidget* parent /TransferThis/ = Q_NULLPTR);
|
||||
virtual ~CDockWidget();
|
||||
virtual QSize minimumSizeHint() const;
|
||||
void setWidget(QWidget* widget /Transfer/, ads::CDockWidget::eInsertMode InsertMode = AutoScrollArea);
|
||||
@@ -82,6 +89,7 @@ public:
|
||||
void setFeatures(ads::CDockWidget::DockWidgetFeatures features);
|
||||
void setFeature(ads::CDockWidget::DockWidgetFeature flag, bool on);
|
||||
ads::CDockWidget::DockWidgetFeatures features() const;
|
||||
void notifyFeaturesChanged();
|
||||
ads::CDockManager* dockManager() const;
|
||||
ads::CDockContainerWidget* dockContainer() const;
|
||||
ads::CFloatingDockContainer* floatingDockContainer() const;
|
||||
@@ -95,6 +103,7 @@ public:
|
||||
bool isInFloatingContainer() const;
|
||||
bool isClosed() const;
|
||||
QAction* toggleViewAction() const;
|
||||
void setToggleViewAction(QAction* action);
|
||||
void setToggleViewActionMode(ads::CDockWidget::eToggleViewActionMode Mode);
|
||||
void setMinimumSizeHintMode(ads::CDockWidget::eMinimumSizeHintMode Mode);
|
||||
ads::CDockWidget::eMinimumSizeHintMode minimumSizeHintMode() const;
|
||||
@@ -104,6 +113,8 @@ public:
|
||||
QToolBar* toolBar() const;
|
||||
QToolBar* createDefaultToolBar();
|
||||
void setToolBar(QToolBar* ToolBar /Transfer/ );
|
||||
void setToolBarStyleSource(ads::CDockWidget::eToolBarStyleSource Source);
|
||||
ads::CDockWidget::eToolBarStyleSource toolBarStyleSource() const;
|
||||
void setToolBarStyle(Qt::ToolButtonStyle Style, ads::CDockWidget::eState State);
|
||||
Qt::ToolButtonStyle toolBarStyle(ads::CDockWidget::eState State) const;
|
||||
void setToolBarIconSize(const QSize& IconSize, ads::CDockWidget::eState State);
|
||||
|
||||
@@ -17,8 +17,8 @@ protected:
|
||||
virtual void mouseDoubleClickEvent( QMouseEvent *ev );
|
||||
|
||||
public:
|
||||
CElidingLabel(QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
|
||||
CElidingLabel(const QString& text, QWidget* parent /TransferThis/ = 0, Qt::WindowFlags f = 0);
|
||||
CElidingLabel(QWidget* parent /TransferThis/ = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags ());
|
||||
CElidingLabel(const QString& text, QWidget* parent /TransferThis/ = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags ());
|
||||
virtual ~CElidingLabel();
|
||||
Qt::TextElideMode elideMode() const;
|
||||
void setElideMode(Qt::TextElideMode mode);
|
||||
|
||||
@@ -44,6 +44,7 @@ protected:
|
||||
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
QWidget* MouseEventHandler);
|
||||
virtual void finishDragging();
|
||||
void deleteContent();
|
||||
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size);
|
||||
void moveFloating();
|
||||
bool restoreState(ads::CDockingStateReader& Stream, bool Testing);
|
||||
@@ -82,6 +83,7 @@ public:
|
||||
bool hasTopLevelDockWidget() const;
|
||||
ads::CDockWidget* topLevelDockWidget() const;
|
||||
QList<ads::CDockWidget*> dockWidgets() const;
|
||||
void finishDropOperation();
|
||||
|
||||
%If (WS_X11)
|
||||
void onMaximizeRequest();
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace ads
|
||||
TitleBarButtonTabsMenu,
|
||||
TitleBarButtonUndock,
|
||||
TitleBarButtonClose,
|
||||
TitleBarButtonAutoHide
|
||||
TitleBarButtonAutoHide,
|
||||
TitleBarButtonMinimize
|
||||
};
|
||||
|
||||
enum eDragState
|
||||
|
||||
@@ -124,6 +124,21 @@ struct AutoHideDockContainerPrivate
|
||||
*/
|
||||
AutoHideDockContainerPrivate(CAutoHideDockContainer *_public);
|
||||
|
||||
/**
|
||||
* Convenience function to ease access to dock manager components factory
|
||||
*/
|
||||
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
|
||||
{
|
||||
if (!DockWidget || !DockWidget->dockManager())
|
||||
{
|
||||
return CDockComponentsFactory::factory();
|
||||
}
|
||||
else
|
||||
{
|
||||
return DockWidget->dockManager()->componentsFactory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function to get a dock widget area
|
||||
*/
|
||||
@@ -199,7 +214,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL
|
||||
{
|
||||
hide(); // auto hide dock container is initially always hidden
|
||||
d->SideTabBarArea = area;
|
||||
d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr);
|
||||
d->SideTab = d->componentsFactory()->createDockWidgetSideTab(nullptr);
|
||||
connect(d->SideTab, &CAutoHideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState);
|
||||
d->DockArea = new CDockAreaWidget(DockWidget->dockManager(), parent);
|
||||
d->DockArea->setObjectName("autoHideDockArea");
|
||||
@@ -410,8 +425,8 @@ void CAutoHideDockContainer::cleanupAndDelete()
|
||||
const auto dockWidget = d->DockWidget;
|
||||
if (dockWidget)
|
||||
{
|
||||
|
||||
auto SideTab = d->SideTab;
|
||||
dockWidget->setSideTabWidget(nullptr);
|
||||
SideTab->removeFromSideBar();
|
||||
SideTab->setParent(nullptr);
|
||||
SideTab->hide();
|
||||
@@ -587,8 +602,12 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
|
||||
return Super::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
// user clicked into container - collapse the auto hide widget
|
||||
collapseView(true);
|
||||
// user clicked outside of autohide container - collapse the auto hide widget
|
||||
if (CDockManager::testAutoHideConfigFlag(
|
||||
CDockManager::AutoHideCloseOnOutsideMouseClick))
|
||||
{
|
||||
collapseView(true);
|
||||
}
|
||||
}
|
||||
else if (event->type() == internal::FloatingWidgetDragStartEvent)
|
||||
{
|
||||
@@ -657,6 +676,14 @@ bool CAutoHideDockContainer::event(QEvent* event)
|
||||
return Super::event(event);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CAutoHideDockContainer::dragLeaveEvent(QDragLeaveEvent*)
|
||||
{
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover))
|
||||
{
|
||||
collapseView(true);
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
Qt::Orientation CAutoHideDockContainer::orientation() const
|
||||
@@ -709,4 +736,3 @@ int CAutoHideDockContainer::tabIndex() const
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ protected:
|
||||
virtual void resizeEvent(QResizeEvent* event) override;
|
||||
virtual void leaveEvent(QEvent *event) override;
|
||||
virtual bool event(QEvent* event) override;
|
||||
virtual void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
||||
|
||||
/**
|
||||
* Updates the size considering the size limits and the resize margins
|
||||
@@ -139,7 +140,7 @@ public:
|
||||
|
||||
/**
|
||||
* Moves the contents to the parent container widget
|
||||
* Used before removing this Auto Hide dock container
|
||||
* Used before removing this Auto Hide dock container
|
||||
*/
|
||||
void moveContentsToParent();
|
||||
|
||||
|
||||
@@ -414,7 +414,14 @@ void CAutoHideSideBar::saveState(QXmlStreamWriter& s) const
|
||||
QSize CAutoHideSideBar::minimumSizeHint() const
|
||||
{
|
||||
QSize Size = sizeHint();
|
||||
Size.setWidth(10);
|
||||
if (d->isHorizontal())
|
||||
{
|
||||
Size.setWidth(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Size.setHeight(0);
|
||||
}
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include <QApplication>
|
||||
#include <QElapsedTimer>
|
||||
#include <QMenu>
|
||||
#include <QEvent>
|
||||
#include <QTimer>
|
||||
|
||||
#include "AutoHideDockContainer.h"
|
||||
#include "AutoHideSideBar.h"
|
||||
@@ -41,6 +43,7 @@
|
||||
#include "DockWidget.h"
|
||||
#include "FloatingDragPreview.h"
|
||||
#include "DockOverlay.h"
|
||||
#include "ads_globals.h"
|
||||
|
||||
namespace ads
|
||||
{
|
||||
@@ -55,6 +58,7 @@ struct AutoHideTabPrivate
|
||||
CAutoHideSideBar* SideBar = nullptr;
|
||||
Qt::Orientation Orientation{Qt::Vertical};
|
||||
QElapsedTimer TimeSinceHoverMousePress;
|
||||
QTimer DragOverTimer;
|
||||
bool MousePressed = false;
|
||||
eDragState DragState = DraggingInactive;
|
||||
QPoint GlobalDragStartMousePosition;
|
||||
@@ -252,6 +256,14 @@ CAutoHideTab::CAutoHideTab(QWidget* parent) :
|
||||
{
|
||||
setAttribute(Qt::WA_NoMousePropagation);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover)) {
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
d->DragOverTimer.setInterval(CDockManager::configParam(
|
||||
CDockManager::AutoHideOpenOnDragHoverDelay_ms, 500).toInt());
|
||||
d->DragOverTimer.setSingleShot(true);
|
||||
connect(&d->DragOverTimer, &QTimer::timeout, this, &CAutoHideTab::onDragHoverDelayExpired);
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +367,6 @@ bool CAutoHideTab::event(QEvent* event)
|
||||
case QEvent::Leave:
|
||||
d->forwardEventToDockContainer(event);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -493,48 +504,74 @@ void CAutoHideTab::mouseReleaseEvent(QMouseEvent* ev)
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CAutoHideTab::mouseMoveEvent(QMouseEvent* ev)
|
||||
void CAutoHideTab::mouseMoveEvent(QMouseEvent *ev)
|
||||
{
|
||||
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||
{
|
||||
d->DragState = DraggingInactive;
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
// move floating window
|
||||
if (d->isDraggingState(DraggingFloatingWidget))
|
||||
{
|
||||
d->FloatingWidget->moveFloating();
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
// move tab
|
||||
if (d->isDraggingState(DraggingTab))
|
||||
{
|
||||
// Moving the tab is always allowed because it does not mean moving the
|
||||
// dock widget around
|
||||
//d->moveTab(ev);
|
||||
}
|
||||
|
||||
auto MappedPos = mapToParent(ev->pos());
|
||||
bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right());
|
||||
// Maybe a fixed drag distance is better here ?
|
||||
int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - internal::globalPositionOf(ev).y());
|
||||
if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar)
|
||||
if (!(ev->buttons() & Qt::LeftButton)
|
||||
|| d->isDraggingState(DraggingInactive))
|
||||
{
|
||||
// Floating is only allowed for widgets that are floatable
|
||||
// We can create the drag preview if the widget is movable.
|
||||
auto Features = d->DockWidget->features();
|
||||
if (Features.testFlag(CDockWidget::DockWidgetFloatable) || (Features.testFlag(CDockWidget::DockWidgetMovable)))
|
||||
{
|
||||
d->startFloating();
|
||||
}
|
||||
return;
|
||||
d->DragState = DraggingInactive;
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
Super::mouseMoveEvent(ev);
|
||||
// move floating window
|
||||
if (d->isDraggingState(DraggingFloatingWidget))
|
||||
{
|
||||
d->FloatingWidget->moveFloating();
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
// move tab
|
||||
if (d->isDraggingState(DraggingTab))
|
||||
{
|
||||
// Moving the tab is always allowed because it does not mean moving the
|
||||
// dock widget around
|
||||
//d->moveTab(ev);
|
||||
}
|
||||
|
||||
auto MappedPos = mapToParent(ev->pos());
|
||||
bool MouseOutsideBar = (MappedPos.x() < 0)
|
||||
|| (MappedPos.x() > parentWidget()->rect().right());
|
||||
// Maybe a fixed drag distance is better here ?
|
||||
int DragDistanceY = qAbs(
|
||||
d->GlobalDragStartMousePosition.y()
|
||||
- internal::globalPositionOf(ev).y());
|
||||
if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar)
|
||||
{
|
||||
// Floating is only allowed for widgets that are floatable
|
||||
// We can create the drag preview if the widget is movable.
|
||||
auto Features = d->DockWidget->features();
|
||||
if (Features.testFlag(CDockWidget::DockWidgetFloatable)
|
||||
|| (Features.testFlag(CDockWidget::DockWidgetMovable)))
|
||||
{
|
||||
d->startFloating();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Super::mouseMoveEvent(ev);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CAutoHideTab::dragEnterEvent(QDragEnterEvent *ev)
|
||||
{
|
||||
Q_UNUSED(ev);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover))
|
||||
{
|
||||
d->DragOverTimer.start();
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CAutoHideTab::dragLeaveEvent(QDragLeaveEvent *ev)
|
||||
{
|
||||
Q_UNUSED(ev);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideOpenOnDragHover))
|
||||
{
|
||||
d->DragOverTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -544,7 +581,6 @@ void CAutoHideTab::requestCloseDockWidget()
|
||||
d->DockWidget->requestCloseDockWidget();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
int CAutoHideTab::tabIndex() const
|
||||
{
|
||||
@@ -557,4 +593,28 @@ int CAutoHideTab::tabIndex() const
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CAutoHideTab::onDragHoverDelayExpired()
|
||||
{
|
||||
static const char* const PropertyId = "ActiveDragOverAutoHideContainer";
|
||||
|
||||
// First we check if there is an active auto hide container that is visible
|
||||
// In this case, we collapse it before we open the new one
|
||||
auto v = d->DockWidget->dockManager()->property(PropertyId);
|
||||
if (v.isValid())
|
||||
{
|
||||
auto ActiveAutoHideContainer = v.value<QPointer<CAutoHideDockContainer>>();
|
||||
if (ActiveAutoHideContainer)
|
||||
{
|
||||
ActiveAutoHideContainer->collapseView(true);
|
||||
}
|
||||
}
|
||||
|
||||
auto AutoHideContainer = d->DockWidget->autoHideDockContainer();
|
||||
AutoHideContainer->collapseView(false);
|
||||
d->DockWidget->dockManager()->setProperty(PropertyId,
|
||||
QVariant::fromValue(QPointer<CAutoHideDockContainer>(AutoHideContainer)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ADS_EXPORT CAutoHideTab : public CPushButton
|
||||
Q_PROPERTY(bool activeTab READ isActiveTab)
|
||||
Q_PROPERTY(bool iconOnly READ iconOnly)
|
||||
|
||||
private:
|
||||
private:
|
||||
AutoHideTabPrivate* d; ///< private data (pimpl)
|
||||
friend struct AutoHideTabPrivate;
|
||||
friend class CDockWidget;
|
||||
@@ -67,6 +67,7 @@ private:
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAutoHideToActionClicked();
|
||||
void onDragHoverDelayExpired();
|
||||
|
||||
protected:
|
||||
void setSideBar(CAutoHideSideBar *SideTabBar);
|
||||
@@ -76,6 +77,8 @@ protected:
|
||||
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent* ev) override;
|
||||
virtual void dragEnterEvent(QDragEnterEvent* ev) override;
|
||||
virtual void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
||||
|
||||
public:
|
||||
using Super = CPushButton;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT})
|
||||
include(GNUInstallDirs)
|
||||
if (${QT_VERSION_MAJOR})
|
||||
message(STATUS "Forced to use Qt version ${QT_VERSION_MAJOR}")
|
||||
find_package(QT NAMES Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
|
||||
@@ -70,7 +71,7 @@ if (UNIX AND NOT APPLE)
|
||||
set(ads_HEADERS linux/FloatingWidgetTitleBar.h ${ads_HEADERS})
|
||||
endif()
|
||||
|
||||
set(library_name "qt${QT_VERSION_MAJOR}advanceddocking")
|
||||
set(library_name "qtadvanceddocking-qt${QT_VERSION_MAJOR}")
|
||||
if(BUILD_STATIC)
|
||||
add_library(${library_name} STATIC ${ads_SRCS} ${ads_HEADERS})
|
||||
target_compile_definitions( ${library_name} PUBLIC ADS_STATIC)
|
||||
@@ -84,6 +85,11 @@ add_library(ads::${library_name} ALIAS ${library_name})
|
||||
target_link_libraries(${library_name} PUBLIC Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets)
|
||||
|
||||
if(QT_VERSION_MAJOR STREQUAL "6")
|
||||
target_link_libraries(${library_name} PRIVATE Qt6::GuiPrivate) #needed for <qpa/qplatformnativeinterface.h>
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
find_package(X11 REQUIRED)
|
||||
@@ -126,7 +132,7 @@ install(FILES ${ads_HEADERS}
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../gnu-lgpl-v2.1.md"
|
||||
DESTINATION license/ads
|
||||
DESTINATION share/ads/license
|
||||
COMPONENT license
|
||||
)
|
||||
install(TARGETS ${library_name}
|
||||
|
||||
@@ -111,7 +111,7 @@ 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, [&, TabWidget]
|
||||
QTimer::singleShot(0, _this, [&, TabWidget]
|
||||
{
|
||||
_this->ensureWidgetVisible(TabWidget);
|
||||
});
|
||||
@@ -160,19 +160,9 @@ CDockAreaTabBar::~CDockAreaTabBar()
|
||||
//============================================================================
|
||||
void CDockAreaTabBar::wheelEvent(QWheelEvent* Event)
|
||||
{
|
||||
Event->accept();
|
||||
const int direction = Event->angleDelta().y();
|
||||
if (direction < 0)
|
||||
{
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - 20);
|
||||
}
|
||||
QCoreApplication::sendEvent(horizontalScrollBar(), Event);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTabBar::setCurrentIndex(int index)
|
||||
{
|
||||
@@ -344,27 +334,13 @@ void CDockAreaTabBar::onTabCloseRequested()
|
||||
void CDockAreaTabBar::onCloseOtherTabsRequested()
|
||||
{
|
||||
auto Sender = qobject_cast<CDockWidgetTab*>(sender());
|
||||
for (int i = 0; i < count(); ++i)
|
||||
{
|
||||
auto Tab = tab(i);
|
||||
if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender)
|
||||
{
|
||||
// If the dock widget is deleted with the closeTab() call, its tab
|
||||
// it will no longer be in the layout, and thus the index needs to
|
||||
// be updated to not skip any tabs
|
||||
int Offset = Tab->dockWidget()->features().testFlag(
|
||||
CDockWidget::DockWidgetDeleteOnClose) ? 1 : 0;
|
||||
closeTab(i);
|
||||
|
||||
// If the the dock widget blocks closing, i.e. if the flag
|
||||
// CustomCloseHandling is set, and the dock widget is still open,
|
||||
// then we do not need to correct the index
|
||||
if (Tab->dockWidget()->isClosed())
|
||||
{
|
||||
i -= Offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = count() - 1; i >= 0; --i) {
|
||||
auto Tab = tab(i);
|
||||
if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender) {
|
||||
closeTab(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -390,15 +366,18 @@ void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos)
|
||||
|
||||
int fromIndex = d->TabsLayout->indexOf(MovingTab);
|
||||
auto MousePos = mapFromGlobal(GlobalPos);
|
||||
MousePos.rx() = qMax(d->firstTab()->geometry().left(), MousePos.x());
|
||||
MousePos.rx() = qMin(d->lastTab()->geometry().right(), MousePos.x());
|
||||
MousePos.rx() = qMax(0, MousePos.x());
|
||||
MousePos.rx() = qMin(width(), MousePos.x());
|
||||
int toIndex = -1;
|
||||
// Find tab under mouse
|
||||
for (int i = 0; i < count(); ++i)
|
||||
{
|
||||
CDockWidgetTab* DropTab = tab(i);
|
||||
auto TabGeometry = DropTab->geometry();
|
||||
TabGeometry.setTopLeft(d->TabsContainerWidget->mapToParent(TabGeometry.topLeft()));
|
||||
TabGeometry.setBottomRight(d->TabsContainerWidget->mapToParent(TabGeometry.bottomRight()));
|
||||
if (DropTab == MovingTab || !DropTab->isVisibleTo(this)
|
||||
|| !DropTab->geometry().contains(MousePos))
|
||||
|| !TabGeometry.contains(MousePos))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -470,6 +449,15 @@ bool CDockAreaTabBar::eventFilter(QObject *watched, QEvent *event)
|
||||
updateGeometry();
|
||||
break;
|
||||
|
||||
// Manage wheel event
|
||||
case QEvent::Wheel:
|
||||
// Ignore wheel events if tab is currently dragged
|
||||
if (Tab->dragState() == DraggingInactive)
|
||||
{
|
||||
wheelEvent((QWheelEvent* )event);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -545,6 +533,13 @@ int CDockAreaTabBar::tabInsertIndexAt(const QPoint& Pos) const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
bool CDockAreaTabBar::areTabsOverflowing() const
|
||||
{
|
||||
return d->TabsContainerWidget->width() > width();
|
||||
}
|
||||
|
||||
} // namespace ads
|
||||
|
||||
|
||||
|
||||
@@ -65,8 +65,7 @@ private Q_SLOTS:
|
||||
void onTabWidgetMoved(const QPoint& GlobalPos);
|
||||
|
||||
protected:
|
||||
virtual void wheelEvent(QWheelEvent* Event) override;
|
||||
|
||||
virtual void wheelEvent(QWheelEvent* Event) override;
|
||||
|
||||
public:
|
||||
using Super = QScrollArea;
|
||||
@@ -153,6 +152,12 @@ public:
|
||||
*/
|
||||
virtual QSize sizeHint() const override;
|
||||
|
||||
/**
|
||||
* This function returns true, if the tabs need more space than the size
|
||||
* of the tab bar.
|
||||
*/
|
||||
bool areTabsOverflowing() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* This property sets the index of the tab bar's visible tab
|
||||
|
||||
@@ -114,6 +114,14 @@ struct DockAreaTitleBarPrivate
|
||||
return DockArea->dockManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function for access to dock manager components factory
|
||||
*/
|
||||
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
|
||||
{
|
||||
return dockManager()->componentsFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given config flag is set
|
||||
* Convenience function to ease config flag testing
|
||||
@@ -377,27 +385,51 @@ CDockAreaTabBar* CDockAreaTitleBar::tabBar() const
|
||||
return d->TabBar;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Super::resizeEvent(event);
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility)
|
||||
&& CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
|
||||
{
|
||||
// Use queued connection to ensure that the resizing and relayouting has
|
||||
// finished to ensure that the d->TabBar->areTabsOverflowing() function
|
||||
// returns the correct value
|
||||
QMetaObject::invokeMethod(this, "markTabsMenuOutdated", Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::markTabsMenuOutdated()
|
||||
{
|
||||
if(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
|
||||
{
|
||||
bool hasElidedTabTitle = false;
|
||||
for (int i = 0; i < d->TabBar->count(); ++i)
|
||||
bool TabsMenuButtonVisible = false;
|
||||
if (CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
|
||||
{
|
||||
if (!d->TabBar->isTabOpen(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CDockWidgetTab* Tab = d->TabBar->tab(i);
|
||||
if(Tab->isTitleElided())
|
||||
{
|
||||
hasElidedTabTitle = true;
|
||||
break;
|
||||
}
|
||||
TabsMenuButtonVisible = d->TabBar->areTabsOverflowing();
|
||||
}
|
||||
bool visible = (hasElidedTabTitle && (d->TabBar->count() > 1));
|
||||
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
|
||||
else
|
||||
{
|
||||
bool hasElidedTabTitle = false;
|
||||
for (int i = 0; i < d->TabBar->count(); ++i)
|
||||
{
|
||||
if (!d->TabBar->isTabOpen(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CDockWidgetTab* Tab = d->TabBar->tab(i);
|
||||
if(Tab->isTitleElided())
|
||||
{
|
||||
hasElidedTabTitle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
TabsMenuButtonVisible = (hasElidedTabTitle && (d->TabBar->count() > 1));
|
||||
}
|
||||
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, TabsMenuButtonVisible));
|
||||
}
|
||||
d->MenuOutdated = true;
|
||||
}
|
||||
@@ -709,6 +741,11 @@ void CDockAreaTitleBar::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
d->makeAreaFloating(event->pos(), DraggingInactive);
|
||||
}
|
||||
|
||||
@@ -744,24 +781,35 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
return;
|
||||
}
|
||||
|
||||
const bool isAutoHide = d->DockArea->isAutoHide();
|
||||
auto Menu = buildContextMenu(nullptr);
|
||||
Menu->exec(ev->globalPos());
|
||||
delete Menu;
|
||||
}
|
||||
|
||||
QMenu* CDockAreaTitleBar::buildContextMenu(QMenu *Menu)
|
||||
{
|
||||
const bool isAutoHide = d->DockArea->isAutoHide();
|
||||
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
||||
QAction* Action;
|
||||
QMenu Menu(this);
|
||||
if (!isTopLevelArea)
|
||||
if (Menu == nullptr)
|
||||
{
|
||||
Menu = new QMenu(this);
|
||||
}
|
||||
|
||||
if (!isTopLevelArea)
|
||||
{
|
||||
Action = Menu.addAction(isAutoHide ? tr("Detach") : tr("Detach Group"),
|
||||
Action = Menu->addAction(isAutoHide ? tr("Detach") : tr("Detach Group"),
|
||||
this, SLOT(onUndockButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(isAutoHide ? tr("Unpin (Dock)") : tr("Pin Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||
Action = Menu->addAction(isAutoHide ? tr("Unpin (Dock)") : tr("Pin Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||
auto AreaIsPinnable = d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(AreaIsPinnable);
|
||||
|
||||
if (!isAutoHide)
|
||||
{
|
||||
auto menu = Menu.addMenu(tr("Pin Group To..."));
|
||||
auto menu = Menu->addMenu(tr("Pin Group To..."));
|
||||
menu->setEnabled(AreaIsPinnable);
|
||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||
@@ -769,28 +817,27 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
d->createAutoHideToAction(tr("Bottom"), SideBarBottom, menu);
|
||||
}
|
||||
}
|
||||
Menu.addSeparator();
|
||||
Menu->addSeparator();
|
||||
}
|
||||
|
||||
if (isAutoHide)
|
||||
{
|
||||
Action = Menu.addAction(tr("Minimize"), this, SLOT(minimizeAutoHideContainer()));
|
||||
Action = Menu.addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered()));
|
||||
Action = Menu->addAction(tr("Minimize"), this, SLOT(minimizeAutoHideContainer()));
|
||||
Action = Menu->addAction(tr("Close"), this, SLOT(onAutoHideCloseActionTriggered()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Action = Menu.addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
Action = Menu->addAction(isAutoHide ? tr("Close") : tr("Close Group"), this, SLOT(onCloseButtonClicked()));
|
||||
}
|
||||
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
if (!isAutoHide && !isTopLevelArea)
|
||||
{
|
||||
Action = Menu.addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
Action = Menu->addAction(tr("Close Other Groups"), d->DockArea, SLOT(closeOtherAreas()));
|
||||
}
|
||||
Menu.exec(ev->globalPos());
|
||||
return Menu;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::insertWidget(int index, QWidget *widget)
|
||||
{
|
||||
|
||||
@@ -152,6 +152,11 @@ protected:
|
||||
*/
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event) override;
|
||||
|
||||
/**
|
||||
* Handle resize events
|
||||
*/
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Call this slot to tell the title bar that it should update the tabs menu
|
||||
@@ -244,6 +249,20 @@ public:
|
||||
*/
|
||||
bool isAutoHide() const;
|
||||
|
||||
/**
|
||||
* Fills the provided menu with standard entries. If a nullptr is passed, a
|
||||
* new menu is created and filled with standard entries.
|
||||
* This function is called from the actual version of contextMenuEvent, but
|
||||
* can be called from any code. Caller is responsible of deleting the created
|
||||
* object.
|
||||
*
|
||||
* @param menu The QMenu to fill with standard entries. If nullptr, a new
|
||||
* QMenu will be created.
|
||||
* @return The filled QMenu, either the provided one or a newly created one if
|
||||
* nullptr was passed.
|
||||
*/
|
||||
virtual QMenu *buildContextMenu(QMenu *);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted if a tab in the tab bar is clicked by the user
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#include <QStackedLayout>
|
||||
#include <QScrollBar>
|
||||
#include <QWheelEvent>
|
||||
#include <QStyle>
|
||||
#include <QPushButton>
|
||||
#include <QDebug>
|
||||
@@ -270,6 +269,14 @@ struct DockAreaWidgetPrivate
|
||||
*/
|
||||
DockAreaWidgetPrivate(CDockAreaWidget* _public);
|
||||
|
||||
/**
|
||||
* Convenience function to ease components factory access
|
||||
*/
|
||||
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
|
||||
{
|
||||
return DockManager->componentsFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the layout for top area with tabs and close button
|
||||
*/
|
||||
@@ -372,10 +379,10 @@ void DockAreaWidgetPrivate::updateTitleBarButtonStates()
|
||||
|
||||
if (_this->isAutoHide())
|
||||
{
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideHasCloseButton))
|
||||
{
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideHasCloseButton))
|
||||
{
|
||||
TitleBar->button(TitleBarButtonClose)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -865,10 +872,22 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
||||
bool IsAutoHide = isAutoHide();
|
||||
if (!CDockManager::testConfigFlag(CDockManager::AlwaysShowTabs))
|
||||
{
|
||||
bool Hidden = Container->hasTopLevelDockWidget() && (Container->isFloating()
|
||||
|| CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar));
|
||||
Hidden |= (d->Flags.testFlag(HideSingleWidgetTitleBar) && openDockWidgetsCount() == 1);
|
||||
Hidden &= !IsAutoHide; // Titlebar must always be visible when auto hidden so it can be dragged
|
||||
bool Hidden = false;
|
||||
if (!IsAutoHide) // Titlebar must always be visible when auto hidden so it can be dragged
|
||||
{
|
||||
if (Container->isFloating() || CDockManager::testConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar))
|
||||
{
|
||||
// Always show title bar if it contains title bar actions
|
||||
if (CDockWidget* TopLevelWidget = Container->topLevelDockWidget())
|
||||
Hidden |= TopLevelWidget->titleBarActions().empty();
|
||||
}
|
||||
if (!Hidden && d->Flags.testFlag(HideSingleWidgetTitleBar))
|
||||
{
|
||||
// Always show title bar if it contains title bar actions
|
||||
auto DockWidgets = openedDockWidgets();
|
||||
Hidden |= (DockWidgets.size() == 1) && DockWidgets.front()->titleBarActions().empty();
|
||||
}
|
||||
}
|
||||
d->TitleBar->setVisible(!Hidden);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
|
||||
QT_FORWARD_DECLARE_CLASS(QAbstractButton)
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
|
||||
namespace ads
|
||||
{
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
|
||||
namespace ads
|
||||
{
|
||||
static std::unique_ptr<CDockComponentsFactory> DefaultFactory(new CDockComponentsFactory());
|
||||
|
||||
static QSharedPointer<ads::CDockComponentsFactory> DefaultFactory;
|
||||
|
||||
|
||||
//============================================================================
|
||||
@@ -52,9 +53,13 @@ CDockAreaTitleBar* CDockComponentsFactory::createDockAreaTitleBar(CDockAreaWidge
|
||||
|
||||
|
||||
//============================================================================
|
||||
const CDockComponentsFactory* CDockComponentsFactory::factory()
|
||||
QSharedPointer<ads::CDockComponentsFactory> CDockComponentsFactory::factory()
|
||||
{
|
||||
return DefaultFactory.get();
|
||||
if (!DefaultFactory)
|
||||
{
|
||||
DefaultFactory.reset(new CDockComponentsFactory());
|
||||
}
|
||||
return DefaultFactory;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +75,7 @@ void CDockComponentsFactory::resetDefaultFactory()
|
||||
{
|
||||
DefaultFactory.reset(new CDockComponentsFactory());
|
||||
}
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -66,9 +66,11 @@ public:
|
||||
virtual CDockAreaTitleBar* createDockAreaTitleBar(CDockAreaWidget* DockArea) const;
|
||||
|
||||
/**
|
||||
* Returns the default components factory
|
||||
* This returns the default dock components factory instance.
|
||||
* If no components factory is assigned to a specific dock manager, this
|
||||
* global factory instance will be used.
|
||||
*/
|
||||
static const CDockComponentsFactory* factory();
|
||||
static QSharedPointer<ads::CDockComponentsFactory> factory();
|
||||
|
||||
/**
|
||||
* Sets a new default factory for creation of GUI elements.
|
||||
@@ -82,15 +84,6 @@ public:
|
||||
static void resetDefaultFactory();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Convenience function to ease factory instance access
|
||||
*/
|
||||
inline const CDockComponentsFactory* componentsFactory()
|
||||
{
|
||||
return CDockComponentsFactory::factory();
|
||||
}
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -423,6 +423,13 @@ CDockWidget* CDockFocusController::focusedDockWidget() const
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
CDockAreaWidget* CDockFocusController::focusedDockArea() const
|
||||
{
|
||||
return d->FocusedArea.data();
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
void CDockFocusController::setDockWidgetTabPressed(bool Value)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,12 @@ public:
|
||||
*/
|
||||
CDockWidget* focusedDockWidget() const;
|
||||
|
||||
/**
|
||||
* Returns the dock area that contains the focusedDockWidget() or nullptr if
|
||||
* the focused dock widget is not in this area.
|
||||
*/
|
||||
CDockAreaWidget* focusedDockArea() const;
|
||||
|
||||
/**
|
||||
* Request focus highlighting for the given dock widget assigned to the tab
|
||||
* given in Tab parameter
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <QApplication>
|
||||
#include <QWindow>
|
||||
#include <QWindowStateChangeEvent>
|
||||
#include <QVector>
|
||||
|
||||
#include "FloatingDockContainer.h"
|
||||
#include "DockOverlay.h"
|
||||
@@ -59,6 +60,8 @@
|
||||
#include "DockAreaTitleBar.h"
|
||||
#include "DockFocusController.h"
|
||||
#include "DockSplitter.h"
|
||||
#include "DockComponentsFactory.h"
|
||||
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
#include "linux/FloatingWidgetTitleBar.h"
|
||||
@@ -94,6 +97,7 @@ enum eStateFileVersion
|
||||
|
||||
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig;
|
||||
static CDockManager::AutoHideFlags StaticAutoHideConfigFlags; // auto hide feature is disabled by default
|
||||
static QVector<QVariant> StaticConfigParams(CDockManager::ConfigParamCount);
|
||||
|
||||
static QString FloatingContainersTitle;
|
||||
|
||||
@@ -123,6 +127,7 @@ struct DockManagerPrivate
|
||||
QSize ToolBarIconSizeDocked = QSize(16, 16);
|
||||
QSize ToolBarIconSizeFloating = QSize(24, 24);
|
||||
CDockWidget::DockWidgetFeatures LockedDockWidgetFeatures;
|
||||
QSharedPointer<ads::CDockComponentsFactory> ComponentFactory {ads::CDockComponentsFactory::factory()};
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@@ -525,14 +530,27 @@ CDockManager::CDockManager(QWidget *parent) :
|
||||
window()->installEventFilter(this);
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
connect(qApp, &QApplication::focusWindowChanged, [](QWindow* focusWindow)
|
||||
connect(qApp, &QApplication::focusWindowChanged, [this](QWindow* focusWindow)
|
||||
{
|
||||
// bring modal dialogs to foreground to ensure that they are in front of any
|
||||
// floating dock widget
|
||||
if (focusWindow && focusWindow->isModal())
|
||||
if (!focusWindow)
|
||||
{
|
||||
focusWindow->raise();
|
||||
return;
|
||||
}
|
||||
|
||||
// bring the main application window that hosts the dock manager and all floating
|
||||
// widgets in front of any other application
|
||||
this->raise();
|
||||
for (auto FloatingWidget : d->FloatingWidgets)
|
||||
{
|
||||
if (FloatingWidget)
|
||||
{
|
||||
FloatingWidget->raise();
|
||||
}
|
||||
}
|
||||
|
||||
// ensure that the dragged floating window is in front of the main application window
|
||||
// and any other floating widget - this will also ensure that modal dialogs come to foreground
|
||||
focusWindow->raise();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
@@ -550,7 +568,7 @@ CDockManager::~CDockManager()
|
||||
{
|
||||
if (!area || area->dockManager() != this) continue;
|
||||
|
||||
// QPointer delete safety - just in case some dock wigdet in destruction
|
||||
// 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() )
|
||||
@@ -579,6 +597,35 @@ CDockManager::~CDockManager()
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockWidget* CDockManager::createDockWidget(const QString &title, QWidget* parent)
|
||||
{
|
||||
return new CDockWidget(this, title, parent);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
QSharedPointer<ads::CDockComponentsFactory> CDockManager::componentsFactory() const
|
||||
{
|
||||
return d->ComponentFactory;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::setComponentsFactory(ads::CDockComponentsFactory* factory)
|
||||
{
|
||||
setComponentsFactory(QSharedPointer<ads::CDockComponentsFactory>(factory));
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::setComponentsFactory(QSharedPointer<ads::CDockComponentsFactory> factory)
|
||||
{
|
||||
d->ComponentFactory = factory;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
bool CDockManager::eventFilter(QObject *obj, QEvent *e)
|
||||
@@ -1475,6 +1522,30 @@ CDockWidget::DockWidgetFeatures CDockManager::globallyLockedDockWidgetFeatures()
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void CDockManager::setConfigParam(CDockManager::eConfigParam Param, QVariant Value)
|
||||
{
|
||||
StaticConfigParams[Param] = Value;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
QVariant CDockManager::configParam(eConfigParam Param, QVariant Default)
|
||||
{
|
||||
return StaticConfigParams[Param].isValid() ? StaticConfigParams[Param] : Default;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void CDockManager::raise()
|
||||
{
|
||||
if (parentWidget())
|
||||
{
|
||||
parentWidget()->raise();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -215,6 +215,8 @@ public:
|
||||
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
|
||||
DoubleClickUndocksWidget = 0x10000000, //!< If the flag is set, a double click on a tab undocks the widget
|
||||
|
||||
|
||||
DefaultDockAreaButtons = DockAreaHasCloseButton
|
||||
| DockAreaHasUndockButton
|
||||
@@ -223,7 +225,8 @@ public:
|
||||
DefaultBaseConfig = DefaultDockAreaButtons
|
||||
| ActiveTabHasCloseButton
|
||||
| XmlCompressionEnabled
|
||||
| FloatingContainerHasWidgetTitle, ///< default base configuration settings
|
||||
| FloatingContainerHasWidgetTitle
|
||||
| DoubleClickUndocksWidget, ///< default base configuration settings
|
||||
|
||||
DefaultOpaqueConfig = DefaultBaseConfig
|
||||
| OpaqueSplitterResize
|
||||
@@ -254,14 +257,26 @@ public:
|
||||
AutoHideCloseButtonCollapsesDock = 0x40, ///< Close button of an auto hide container collapses the dock instead of hiding it completely
|
||||
AutoHideHasCloseButton = 0x80, //< If the flag is set an auto hide title bar has a close button
|
||||
AutoHideHasMinimizeButton = 0x100, ///< if this flag is set, the auto hide title bar has a minimize button to collapse the dock widget
|
||||
AutoHideOpenOnDragHover = 0x200, ///< if this flag is set, dragging hover the tab bar will open the dock
|
||||
AutoHideCloseOnOutsideMouseClick = 0x400, ///< if this flag is set, the auto hide dock container will collapse if the user clicks outside of the container, if not set, the auto hide container can be closed only via click on sidebar tab
|
||||
|
||||
DefaultAutoHideConfig = AutoHideFeatureEnabled
|
||||
| DockAreaHasAutoHideButton
|
||||
| AutoHideHasMinimizeButton
|
||||
| AutoHideCloseOnOutsideMouseClick
|
||||
|
||||
};
|
||||
Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag)
|
||||
|
||||
/**
|
||||
* Global configuration parameters that you can set via setConfigParam()
|
||||
*/
|
||||
enum eConfigParam
|
||||
{
|
||||
AutoHideOpenOnDragHoverDelay_ms, ///< Delay in ms before the dock opens on drag hover if AutoHideOpenOnDragHover flag is set
|
||||
ConfigParamCount // just a delimiter to count number of config params
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
@@ -277,6 +292,39 @@ public:
|
||||
*/
|
||||
virtual ~CDockManager() override;
|
||||
|
||||
/**
|
||||
* Creates a new dock widget with the specified title and optional parent
|
||||
* widget.
|
||||
*
|
||||
* The new dock widget will be managed by the dock manager, and its lifetime
|
||||
* will be tied to the dock manager. If a parent widget is provided, the dock
|
||||
* widget will be created as a child of the parent widget. If no parent widget
|
||||
* is provided, the dock widget will be created as a top-level widget.
|
||||
*
|
||||
* @param title The title of the dock widget.
|
||||
* @param parent The parent widget, if any. Defaults to nullptr.
|
||||
* @return Returns a pointer to the created CDockWidget.
|
||||
*/
|
||||
CDockWidget *createDockWidget(const QString &title, QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* Returns the dock manager specific factory for creating components of
|
||||
* fock widgets
|
||||
*/
|
||||
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const;
|
||||
|
||||
/**
|
||||
* Sets a custom factory for creating components of dock widgets.
|
||||
* The pointer is stored internally into a shared pointer so you should not
|
||||
* delete the given factory object as long as it is used by the dock manager.
|
||||
*/
|
||||
void setComponentsFactory(ads::CDockComponentsFactory* Factory);
|
||||
|
||||
/**
|
||||
* Sets a custom factory for creating components of dock widgets.
|
||||
*/
|
||||
void setComponentsFactory(QSharedPointer<ads::CDockComponentsFactory>);
|
||||
|
||||
/**
|
||||
* This function returns the global configuration flags
|
||||
*/
|
||||
@@ -323,6 +371,17 @@ public:
|
||||
*/
|
||||
static bool testAutoHideConfigFlag(eAutoHideFlag Flag);
|
||||
|
||||
/**
|
||||
* Sets the value for the given config parameter
|
||||
*/
|
||||
static void setConfigParam(eConfigParam Param, QVariant Value);
|
||||
|
||||
/**
|
||||
* Returns the value for the given config parameter or the default value
|
||||
* if the parameter is not set.
|
||||
*/
|
||||
static QVariant configParam(eConfigParam Param, QVariant Default);
|
||||
|
||||
/**
|
||||
* Returns the global icon provider.
|
||||
* The icon provider enables the use of custom icons in case using
|
||||
@@ -711,6 +770,12 @@ public Q_SLOTS:
|
||||
*/
|
||||
void hideManagerAndFloatingWidgets();
|
||||
|
||||
/**
|
||||
* Calls raise() for the widget that hosts this dock manager.
|
||||
* This will bring the widget in front of any other application that is running
|
||||
*/
|
||||
void raise();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted if the list of perspectives changed.
|
||||
|
||||
@@ -102,6 +102,14 @@ struct DockWidgetPrivate
|
||||
*/
|
||||
DockWidgetPrivate(CDockWidget* _public);
|
||||
|
||||
/**
|
||||
* Convenience function to ease components factory access
|
||||
*/
|
||||
QSharedPointer<ads::CDockComponentsFactory> componentsFactory() const
|
||||
{
|
||||
return DockManager ? DockManager->componentsFactory() : CDockComponentsFactory::factory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show dock widget
|
||||
*/
|
||||
@@ -358,9 +366,17 @@ void DockWidgetPrivate::setToolBarStyleFromDockManager()
|
||||
|
||||
//============================================================================
|
||||
CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
||||
QFrame(parent),
|
||||
d(new DockWidgetPrivate(this))
|
||||
CDockWidget(nullptr, title, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockWidget::CDockWidget(CDockManager *manager, const QString &title, QWidget* parent)
|
||||
: QFrame(parent),
|
||||
d(new DockWidgetPrivate(this))
|
||||
{
|
||||
d->DockManager = manager;
|
||||
d->Layout = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||
d->Layout->setContentsMargins(0, 0, 0, 0);
|
||||
d->Layout->setSpacing(0);
|
||||
@@ -368,7 +384,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
||||
setWindowTitle(title);
|
||||
setObjectName(title);
|
||||
|
||||
d->TabWidget = componentsFactory()->createDockWidgetTab(this);
|
||||
d->TabWidget = d->componentsFactory()->createDockWidgetTab(this);
|
||||
|
||||
d->ToggleViewAction = new QAction(title, this);
|
||||
d->ToggleViewAction->setCheckable(true);
|
||||
@@ -382,6 +398,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockWidget::~CDockWidget()
|
||||
{
|
||||
@@ -824,9 +841,9 @@ void CDockWidget::saveState(QXmlStreamWriter& s) const
|
||||
void CDockWidget::flagAsUnassigned()
|
||||
{
|
||||
d->Closed = true;
|
||||
setParent(d->DockManager);
|
||||
setVisible(false);
|
||||
setDockArea(nullptr);
|
||||
setParent(d->DockManager);
|
||||
tabWidget()->setParent(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,8 +256,35 @@ public:
|
||||
* during runtime, you need to set a unique object name explicitly
|
||||
* by calling setObjectName() after construction.
|
||||
* Use the layoutFlags to configure the layout of the dock widget.
|
||||
* \note If you would like to use custom TabWidget implementations, you need
|
||||
* to use the constructor with the CDockManager argument.
|
||||
*/
|
||||
CDockWidget(const QString &title, QWidget* parent = nullptr);
|
||||
Q_DECL_DEPRECATED explicit CDockWidget(const QString &title, QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* This constructor creates a dock widget for the given dock manager with the
|
||||
* provided title.
|
||||
*
|
||||
* @param manager Pointer to the dock manager that owns the dock widget.
|
||||
* @param title The title is the text that is shown in the window title when
|
||||
* the dock widget is floating and it is the title that is shown in the
|
||||
* titlebar or the tab of this dock widget if it is tabified.
|
||||
* @param parent Pointer to the parent widget, defaults to nullptr.
|
||||
*
|
||||
* @note The object name of the dock widget is also set to the title. The
|
||||
* object name is required by the dock manager to properly save and restore
|
||||
* the state of the dock widget. That means, the title needs to be unique. If
|
||||
* the title is not unique or if you would like to change the title during
|
||||
* runtime, you need to set a unique object name explicitly by calling
|
||||
* setObjectName() after construction. Use the layoutFlags to configure the
|
||||
* layout of the dock widget.
|
||||
*
|
||||
* @note this constructor is preferred over the two argument version, especially
|
||||
* when custom factories are in use. Indeed, it will use the Dock Manager factory,
|
||||
* and not the default factory. For this reason, the original constructor should
|
||||
* be deprecated in favour of this version.
|
||||
*/
|
||||
CDockWidget(CDockManager *manager, const QString &title, QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* Virtual Destructor
|
||||
|
||||
@@ -529,26 +529,34 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||
return;
|
||||
}
|
||||
|
||||
auto Menu = buildContextMenu(nullptr);
|
||||
d->saveDragStartMousePosition(ev->globalPos());
|
||||
Menu->exec(ev->globalPos());
|
||||
}
|
||||
|
||||
QMenu* CDockWidgetTab::buildContextMenu(QMenu *Menu)
|
||||
{
|
||||
if (Menu == nullptr) {
|
||||
Menu = new QMenu(this);
|
||||
}
|
||||
|
||||
const bool isFloatable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable);
|
||||
const bool isNotOnlyTabInContainer = !d->DockArea->dockContainer()->hasTopLevelDockWidget();
|
||||
const bool isTopLevelArea = d->DockArea->isTopLevelArea();
|
||||
const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
|
||||
QAction* Action;
|
||||
QMenu Menu(this);
|
||||
|
||||
if (!isTopLevelArea)
|
||||
{
|
||||
Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||
Action = Menu->addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||
Action->setEnabled(isDetachable);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(tr("Pin"), this, SLOT(autoHideDockWidget()));
|
||||
Action = Menu->addAction(tr("Pin"), this, SLOT(autoHideDockWidget()));
|
||||
auto IsPinnable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(IsPinnable);
|
||||
|
||||
auto menu = Menu.addMenu(tr("Pin To..."));
|
||||
auto menu = Menu->addMenu(tr("Pin To..."));
|
||||
menu->setEnabled(IsPinnable);
|
||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||
@@ -557,17 +565,16 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||
}
|
||||
}
|
||||
|
||||
Menu.addSeparator();
|
||||
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||
Menu->addSeparator();
|
||||
Action = Menu->addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||
Action->setEnabled(isClosable());
|
||||
if (d->DockArea->openDockWidgetsCount() > 1)
|
||||
{
|
||||
Action = Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
||||
Action = Menu->addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
||||
}
|
||||
Menu.exec(ev->globalPos());
|
||||
|
||||
return Menu;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CDockWidgetTab::isActiveTab() const
|
||||
{
|
||||
@@ -592,9 +599,9 @@ void CDockWidgetTab::setActiveTab(bool active)
|
||||
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
|
||||
{
|
||||
bool UpdateFocusStyle = false;
|
||||
if (active && !hasFocus())
|
||||
{
|
||||
//setFocus(Qt::OtherFocusReason);
|
||||
// Update the focus only, if this the dock area of this tab is the focused dock area
|
||||
if (active && !hasFocus() && (d->focusController()->focusedDockArea() == this->dockAreaWidget()))
|
||||
{
|
||||
d->focusController()->setDockWidgetTabFocused(this);
|
||||
UpdateFocusStyle = true;
|
||||
}
|
||||
@@ -692,7 +699,7 @@ QString CDockWidgetTab::text() const
|
||||
//============================================================================
|
||||
void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
if (event->button() == Qt::LeftButton && CDockManager::testConfigFlag(CDockManager::DoubleClickUndocksWidget))
|
||||
{
|
||||
// If this is the last dock area in a dock container it does not make
|
||||
// sense to move it to a new floating widget and leave this one
|
||||
@@ -789,6 +796,13 @@ bool CDockWidgetTab::event(QEvent *e)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
eDragState CDockWidgetTab::dragState() const
|
||||
{
|
||||
return d->DragState;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidgetTab::onDockWidgetFeaturesChanged()
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include "ads_globals.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
|
||||
namespace ads
|
||||
{
|
||||
class CDockWidget;
|
||||
@@ -178,6 +180,26 @@ public:
|
||||
*/
|
||||
void setIconSize(const QSize& Size);
|
||||
|
||||
/**
|
||||
* Returns the current drag state of this tab.
|
||||
* Use this function to determine if the tab is currently being dragged
|
||||
*/
|
||||
eDragState dragState() const;
|
||||
|
||||
/**
|
||||
* Fills the provided menu with standard entries. If a nullptr is passed, a
|
||||
* new menu is created and filled with standard entries.
|
||||
* This function is called from the actual version of contextMenuEvent, but
|
||||
* can be called from any code. Caller is responsible of deleting the created
|
||||
* object.
|
||||
*
|
||||
* @param menu The QMenu to fill with standard entries. If nullptr, a new
|
||||
* QMenu will be created.
|
||||
* @return The filled QMenu, either the provided one or a newly created one if
|
||||
* nullptr was passed.
|
||||
*/
|
||||
virtual QMenu *buildContextMenu(QMenu *);
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void setVisible(bool visible) override;
|
||||
|
||||
|
||||
@@ -1331,7 +1331,8 @@ void CFloatingDockContainer::onMaximizeRequest()
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::showNormal(bool fixGeometry)
|
||||
{
|
||||
if (windowState() == Qt::WindowMaximized)
|
||||
if ( (windowState() & Qt::WindowMaximized) != 0 ||
|
||||
(windowState() & Qt::WindowFullScreen) != 0)
|
||||
{
|
||||
QRect oldNormal = normalGeometry();
|
||||
Super::showNormal();
|
||||
|
||||
@@ -131,15 +131,6 @@ protected:
|
||||
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
eDragState DragState, QWidget* MouseEventHandler) override;
|
||||
|
||||
/**
|
||||
* Call this function to start dragging the floating widget
|
||||
*/
|
||||
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
QWidget* MouseEventHandler)
|
||||
{
|
||||
startFloating(DragStartMousePos, Size, DraggingFloatingWidget, MouseEventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function if you explicitly want to signal that dragging has
|
||||
* finished
|
||||
@@ -149,7 +140,7 @@ protected:
|
||||
/**
|
||||
* 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
|
||||
* destructor before deleting the floating widget
|
||||
*/
|
||||
void deleteContent();
|
||||
|
||||
@@ -236,6 +227,15 @@ public:
|
||||
*/
|
||||
CDockContainerWidget* dockContainer() const;
|
||||
|
||||
/**
|
||||
* Call this function to start dragging the floating widget
|
||||
*/
|
||||
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
QWidget* MouseEventHandler)
|
||||
{
|
||||
startFloating(DragStartMousePos, Size, DraggingFloatingWidget, MouseEventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns true, if it can be closed.
|
||||
* It can be closed, if all dock widgets in all dock areas can be closed
|
||||
|
||||
@@ -283,7 +283,7 @@ QString detectWindowManagerX11()
|
||||
}
|
||||
if(sup_windows.length() == 0)
|
||||
{
|
||||
ADS_PRINT("Failed to get the supporting window on non EWMH comform WM.");
|
||||
ADS_PRINT("Failed to get the supporting window on non EWMH conform WM.");
|
||||
return "UNKNOWN";
|
||||
}
|
||||
support_win = sup_windows[0];
|
||||
|
||||
@@ -158,7 +158,7 @@ enum SideBarLocation
|
||||
SideBarBottom,
|
||||
SideBarNone
|
||||
};
|
||||
Q_ENUMS(SideBarLocation);
|
||||
Q_ENUMS(SideBarLocation)
|
||||
|
||||
|
||||
namespace internal
|
||||
@@ -236,7 +236,7 @@ SideBarLocation toSideBarLocation(DockWidgetArea Area);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true for the top or bottom side bar ansd false for the
|
||||
* Returns true for the top or bottom side bar and false for the
|
||||
* left and right side bar
|
||||
*/
|
||||
bool isHorizontalSideBarLocation(SideBarLocation Location);
|
||||
|
||||
Reference in New Issue
Block a user