Compare commits
215 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
084c5c5995 | ||
|
|
65c080ae8e | ||
|
|
f9927cef29 | ||
|
|
5778dfe929 | ||
|
|
2150ebf45e | ||
|
|
6021ee8094 | ||
|
|
eebb2a6297 | ||
|
|
0fb1363b1a | ||
|
|
2ca03cc56d | ||
|
|
4a2768015c | ||
|
|
861ce67725 | ||
|
|
c530a4a4ec | ||
|
|
2378f46067 | ||
|
|
ea707369a0 | ||
|
|
7640e9bdcf | ||
|
|
4a0266bc76 | ||
|
|
6d1f97649e | ||
|
|
2af4b1f75c | ||
|
|
c0cde1e31e | ||
|
|
ee809da7a7 | ||
|
|
a253e4a0b5 | ||
|
|
779c4b928c | ||
|
|
056f04d408 | ||
|
|
e085a29484 | ||
|
|
ffd35cbce3 | ||
|
|
8c1f065f3f | ||
|
|
5af6b4e324 | ||
|
|
b47a777f5c | ||
|
|
5b3a0a28df | ||
|
|
02143eac71 | ||
|
|
5e230d8874 | ||
|
|
a45a035bb3 | ||
|
|
05f8ce15a2 | ||
|
|
45af8867b2 | ||
|
|
8e522ce311 | ||
|
|
178603e3ba | ||
|
|
552cee514d | ||
|
|
4105f70089 | ||
|
|
0bd34a5a6e | ||
|
|
a5dd566b37 | ||
|
|
1724f7f5ec | ||
|
|
6cd09addae | ||
|
|
93382350db | ||
|
|
db90e5415f | ||
|
|
9679fd67cc | ||
|
|
c84c98f49a | ||
|
|
716acd5f68 | ||
|
|
e782b4813b | ||
|
|
b27a24b3c4 | ||
|
|
18c65cdf34 | ||
|
|
e049cb0353 | ||
|
|
8d42e7777d | ||
|
|
e682ab8ea5 | ||
|
|
c6ff7f5230 | ||
|
|
309fe1a14a | ||
|
|
6b45274686 | ||
|
|
0f72fabe67 | ||
|
|
d3ad17d2c6 | ||
|
|
a8e0f1904f | ||
|
|
2ee7deb6d5 | ||
|
|
2e88d8651e | ||
|
|
232b6b9a61 | ||
|
|
5978aaaedc | ||
|
|
3332f6050e | ||
|
|
a1de28c969 | ||
|
|
8af53b4199 | ||
|
|
bddf4c417d | ||
|
|
e345773cfc | ||
|
|
c1816bf507 | ||
|
|
4f97e07eb6 | ||
|
|
2fe542c3ef | ||
|
|
07f9c6d016 | ||
|
|
8ea7c265a7 | ||
|
|
3cd12ce1d3 | ||
|
|
1be8f2861d | ||
|
|
e15af4101a | ||
|
|
4504457da2 | ||
|
|
f497944d2c | ||
|
|
aee9fb1c95 | ||
|
|
316d9a00b5 | ||
|
|
b353c210ee | ||
|
|
490e853435 | ||
|
|
7393addf64 | ||
|
|
a2b9650469 | ||
|
|
ca39ab0b44 | ||
|
|
ae997d3d75 | ||
|
|
c48cf3875d | ||
|
|
46fb18fc58 | ||
|
|
8da6904dcd | ||
|
|
2a51359159 | ||
|
|
ec48140309 | ||
|
|
fe64f407c0 | ||
|
|
136d6d966c | ||
|
|
05ff005613 | ||
|
|
3ff154aff1 | ||
|
|
de645b3cca | ||
|
|
f6174faebb | ||
|
|
0d3ec46095 | ||
|
|
53fed8b765 | ||
|
|
5752bfb58b | ||
|
|
5378d90ba7 | ||
|
|
ae96bbc0a0 | ||
|
|
c10ff7c688 | ||
|
|
d2fb1579a5 | ||
|
|
156cc71040 | ||
|
|
909c189d7f | ||
|
|
50c529b77f | ||
|
|
84b501205a | ||
|
|
664a1674ab | ||
|
|
0c5ef5e158 | ||
|
|
b776fc24a6 | ||
|
|
c5e7104413 | ||
|
|
2c7764ecf7 | ||
|
|
bed99eacc2 | ||
|
|
dae677e479 | ||
|
|
a05078c947 | ||
|
|
3fcf05fb29 | ||
|
|
cdca8c2ac0 | ||
|
|
53ec8b896a | ||
|
|
6e6c1512a6 | ||
|
|
8e0ea57319 | ||
|
|
9bd55cc15a | ||
|
|
c8d4487a95 | ||
|
|
12b0182337 | ||
|
|
a2b07fd97f | ||
|
|
078905181e | ||
|
|
7c9ed9b624 | ||
|
|
ac164c3a97 | ||
|
|
2b7232c9b3 | ||
|
|
6cc7d79832 | ||
|
|
0b88843d76 | ||
|
|
554f26a614 | ||
|
|
10fbb6f302 | ||
|
|
bf27207dd9 | ||
|
|
97f02d39e6 | ||
|
|
64231d037d | ||
|
|
6eb869014e | ||
|
|
a564ca5ce5 | ||
|
|
365b989364 | ||
|
|
a3baf7dcf6 | ||
|
|
538e690c22 | ||
|
|
b1309da89a | ||
|
|
d2f751ef87 | ||
|
|
35c1b04c58 | ||
|
|
0de1a9ccae | ||
|
|
c45327aafd | ||
|
|
8853c751d6 | ||
|
|
e978a32a09 | ||
|
|
ca5683f5bf | ||
|
|
c630a59afe | ||
|
|
b9b8ff9c76 | ||
|
|
e2c5204d00 | ||
|
|
5ee94d7602 | ||
|
|
69894f3f88 | ||
|
|
641946bff5 | ||
|
|
27dd7a1b75 | ||
|
|
5425f2b9e1 | ||
|
|
4320e350c8 | ||
|
|
8351aa11e7 | ||
|
|
e98fd5bcb3 | ||
|
|
a012af2aac | ||
|
|
df285dd385 | ||
|
|
a6ed4354a9 | ||
|
|
1fccb943fe | ||
|
|
7bd3765fa7 | ||
|
|
9b56ca08e1 | ||
|
|
49a7682e74 | ||
|
|
e25bf2eac2 | ||
|
|
f7c8384b73 | ||
|
|
9bd06401d9 | ||
|
|
b44a7e75ca | ||
|
|
c9645ef85b | ||
|
|
fd09a681c4 | ||
|
|
e113790bbe | ||
|
|
957dce5d1f | ||
|
|
e352ce559b | ||
|
|
0c3ef64d3e | ||
|
|
f72e2ce058 | ||
|
|
befdcce343 | ||
|
|
6fc8964ffc | ||
|
|
6cb1f33451 | ||
|
|
ee616c2541 | ||
|
|
7dd2a3c83c | ||
|
|
9db502e652 | ||
|
|
1ad6caeb8a | ||
|
|
4dde545c8f | ||
|
|
b7a5918974 | ||
|
|
ddfa6c2a43 | ||
|
|
275520ae29 | ||
|
|
1078387f5d | ||
|
|
c33dddbd47 | ||
|
|
2570a880af | ||
|
|
40a8d9e6b4 | ||
|
|
9af6622466 | ||
|
|
4fa89374c4 | ||
|
|
1aaa56ef29 | ||
|
|
d298a47bda | ||
|
|
146b65206a | ||
|
|
616ad9f86e | ||
|
|
aa9762718c | ||
|
|
f26bee6677 | ||
|
|
fb18de4868 | ||
|
|
e204e10113 | ||
|
|
a06a14d6cd | ||
|
|
88d4bea2c1 | ||
|
|
b8ad2f7577 | ||
|
|
32e5d599f7 | ||
|
|
48382ccd82 | ||
|
|
e37e4fdf57 | ||
|
|
c9a97534a8 | ||
|
|
8f54dd2a82 | ||
|
|
c0d6f959ec | ||
|
|
8570139cd1 | ||
|
|
b38919e909 | ||
|
|
b19cc98c84 |
160
.appveyor.yml
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
version: '2.3.2.{build}'
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
|
image: Visual Studio 2015
|
||||||
|
clone_depth: 1
|
||||||
|
environment:
|
||||||
|
global:
|
||||||
|
# Appveyor doesn't have Qt 12 yet
|
||||||
|
LatestLTSQtVersion: 5.9
|
||||||
|
LatestQtVersion: 5.11
|
||||||
|
matrix:
|
||||||
|
# Latest version of Qt, dll, 64bit, MSVC 2015, qmake
|
||||||
|
- QT5: C:\Qt\%LatestQtVersion%\msvc2015_64
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: amd64
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "false"
|
||||||
|
use_cmake: "false"
|
||||||
|
# 32 bit builds
|
||||||
|
# MSVC 2015 builds
|
||||||
|
# Dynamic Library builds
|
||||||
|
# LTS version of Qt, dll, 32bit, MSVC 2015, qmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "false"
|
||||||
|
use_cmake: "false"
|
||||||
|
# LTS version of Qt, dll, 32bit, MSVC 2015, cmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "false"
|
||||||
|
use_cmake: "true"
|
||||||
|
# end Dynamic Library builds
|
||||||
|
# Static Library builds
|
||||||
|
# LTS version of Qt, static, 32bit, MSVC 2015, qmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "true"
|
||||||
|
use_cmake: "false"
|
||||||
|
# LTS version of Qt, static, 32bit, MSVC 2015, cmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "true"
|
||||||
|
use_cmake: "true"
|
||||||
|
# end Static Library builds
|
||||||
|
# end MSVC 2015 builds
|
||||||
|
# MinGW builds
|
||||||
|
# Dynamic Library builds
|
||||||
|
# LTS version of Qt, dll, 32bit, MinGW, qmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
|
||||||
|
COMPILER: C:\Qt\Tools\mingw530_32
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "true"
|
||||||
|
use_static: "false"
|
||||||
|
use_cmake: "false"
|
||||||
|
# LTS version of Qt, dll, 32bit, MinGW, cmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
|
||||||
|
COMPILER: C:\Qt\Tools\mingw530_32
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "true"
|
||||||
|
use_static: "false"
|
||||||
|
use_cmake: "true"
|
||||||
|
# end Dynamic Library builds
|
||||||
|
# Static Library builds
|
||||||
|
# LTS version of Qt, static, 32bit, MinGW, qmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
|
||||||
|
COMPILER: C:\Qt\Tools\mingw530_32
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "true"
|
||||||
|
use_static: "true"
|
||||||
|
use_cmake: "false"
|
||||||
|
# LTS version of Qt, static, 32bit, MinGW, cmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32
|
||||||
|
COMPILER: C:\Qt\Tools\mingw530_32
|
||||||
|
targetPlatform: x86
|
||||||
|
use_mingw: "true"
|
||||||
|
use_static: "true"
|
||||||
|
use_cmake: "true"
|
||||||
|
# end Static Library builds
|
||||||
|
# end MinGW builds
|
||||||
|
# end 32 bit builds
|
||||||
|
# 64 bit builds
|
||||||
|
# MSVC 2015 builds
|
||||||
|
# Dynamic Library builds
|
||||||
|
# LTS version of Qt, dll, 64bit, MSVC 2015, qmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: amd64
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "false"
|
||||||
|
use_cmake: "false"
|
||||||
|
# LTS version of Qt, dll, 64bit, MSVC 2015, cmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: amd64
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "false"
|
||||||
|
use_cmake: "true"
|
||||||
|
# end Dynamic Library builds
|
||||||
|
# Static Library builds
|
||||||
|
# LTS version of Qt, static, 64bit, MSVC 2015, qmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: amd64
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "true"
|
||||||
|
use_cmake: "false"
|
||||||
|
# LTS version of Qt, static, 64bit, MSVC 2015, cmake
|
||||||
|
- QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64
|
||||||
|
COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
|
||||||
|
targetPlatform: amd64
|
||||||
|
use_mingw: "false"
|
||||||
|
use_static: "true"
|
||||||
|
use_cmake: "true"
|
||||||
|
# end Static Library builds
|
||||||
|
# end MSVC 2015 builds
|
||||||
|
# end 64 bit builds
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
|
||||||
|
before_build:
|
||||||
|
- set PATH=%COMPILER%\bin;%QT5%\bin;%PATH%
|
||||||
|
- set originalWD=%CD%
|
||||||
|
- call "%QT5%\bin\qtenv2.bat"
|
||||||
|
- cd %originalWD%
|
||||||
|
- if %use_mingw%==false call "%COMPILER%\vcvarsall.bat" %targetPlatform%
|
||||||
|
- if %use_static%==true (set USESTATIC=ON) else (set USESTATIC=OFF)
|
||||||
|
- if %use_mingw%==true (set CMAKEGENERATOR="MinGW Makefiles") else (set CMAKEGENERATOR="NMake Makefiles")
|
||||||
|
- if %use_mingw%==true (set MAKEENGINE=mingw32-make) else (set MAKEENGINE=nmake)
|
||||||
|
- if %use_mingw%==true set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- if %use_cmake%==true mkdir .\build
|
||||||
|
- if %use_cmake%==true cd .\build
|
||||||
|
- if %use_cmake%==true cmake --version
|
||||||
|
- if %use_cmake%==true cmake -G %CMAKEGENERATOR% -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_EXAMPLES=ON -DCMAKE_DEBUG_POSTFIX=d -DBUILD_STATIC=%USESTATIC% -DCMAKE_INSTALL_PREFIX="./installed" ../
|
||||||
|
- if %use_cmake%==true cmake --build .
|
||||||
|
- if %use_cmake%==true cmake --build . --target install
|
||||||
|
- if %use_cmake%==true cmake -G %CMAKEGENERATOR% -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_EXAMPLES=ON -DBUILD_STATIC=%USESTATIC% -DCMAKE_INSTALL_PREFIX="./installed" ../
|
||||||
|
- if %use_cmake%==true cmake --build .
|
||||||
|
- if %use_cmake%==true cmake --build . --target install
|
||||||
|
- if %use_cmake%==false if %use_static%==true qmake "CONFIG+=adsBuildStatic"
|
||||||
|
- if %use_cmake%==false if %use_static%==false qmake
|
||||||
|
- if %use_cmake%==false %MAKEENGINE% debug
|
||||||
|
- if %use_cmake%==false %MAKEENGINE% install
|
||||||
|
- if %use_cmake%==false %MAKEENGINE% release
|
||||||
|
- if %use_cmake%==false %MAKEENGINE% install
|
||||||
|
|
||||||
|
after_build:
|
||||||
|
- if %use_mingw%==true set PATH=C:\Program Files\Git\usr\bin;%PATH%
|
||||||
50
.cproject
@@ -83,6 +83,7 @@
|
|||||||
</target>
|
</target>
|
||||||
<target name="Clean" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="Clean" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>make</buildCommand>
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
<buildTarget>clean</buildTarget>
|
<buildTarget>clean</buildTarget>
|
||||||
<stopOnError>false</stopOnError>
|
<stopOnError>false</stopOnError>
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
@@ -99,7 +100,6 @@
|
|||||||
<target name="qmake" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="qmake" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>qmake</buildCommand>
|
<buildCommand>qmake</buildCommand>
|
||||||
<buildArguments>-recursive ../ads.pro</buildArguments>
|
<buildArguments>-recursive ../ads.pro</buildArguments>
|
||||||
<buildTarget/>
|
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
<runAllBuilders>false</runAllBuilders>
|
<runAllBuilders>false</runAllBuilders>
|
||||||
@@ -122,7 +122,6 @@
|
|||||||
</target>
|
</target>
|
||||||
<target name="Clean" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="Clean" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>make</buildCommand>
|
<buildCommand>make</buildCommand>
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>clean</buildTarget>
|
<buildTarget>clean</buildTarget>
|
||||||
<stopOnError>false</stopOnError>
|
<stopOnError>false</stopOnError>
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
@@ -139,7 +138,6 @@
|
|||||||
<target name="qmake" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="qmake" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>qmake</buildCommand>
|
<buildCommand>qmake</buildCommand>
|
||||||
<buildArguments>-recursive ../../src/src.pro</buildArguments>
|
<buildArguments>-recursive ../../src/src.pro</buildArguments>
|
||||||
<buildTarget/>
|
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
<runAllBuilders>false</runAllBuilders>
|
<runAllBuilders>false</runAllBuilders>
|
||||||
@@ -152,6 +150,46 @@
|
|||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
<runAllBuilders>false</runAllBuilders>
|
<runAllBuilders>false</runAllBuilders>
|
||||||
</target>
|
</target>
|
||||||
|
<target name="Build all" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>mingw32-make</buildCommand>
|
||||||
|
<buildArguments>-j</buildArguments>
|
||||||
|
<buildTarget>all</buildTarget>
|
||||||
|
<stopOnError>false</stopOnError>
|
||||||
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
<runAllBuilders>false</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
<target name="Clean" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
|
<buildTarget>clean</buildTarget>
|
||||||
|
<stopOnError>false</stopOnError>
|
||||||
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
|
<runAllBuilders>false</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
<target name="Debug Build" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>mingw32-make</buildCommand>
|
||||||
|
<buildArguments>-j6</buildArguments>
|
||||||
|
<buildTarget>debug</buildTarget>
|
||||||
|
<stopOnError>false</stopOnError>
|
||||||
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
<runAllBuilders>false</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
<target name="qmake" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>qmake</buildCommand>
|
||||||
|
<buildArguments>-recursive ../../example/example.pro</buildArguments>
|
||||||
|
<buildTarget/>
|
||||||
|
<stopOnError>true</stopOnError>
|
||||||
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
<runAllBuilders>false</runAllBuilders>
|
||||||
|
</target>
|
||||||
|
<target name="Release Build" path=" build/example" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
|
<buildCommand>mingw32-make</buildCommand>
|
||||||
|
<buildArguments>-j4</buildArguments>
|
||||||
|
<buildTarget>release</buildTarget>
|
||||||
|
<stopOnError>false</stopOnError>
|
||||||
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
|
<runAllBuilders>false</runAllBuilders>
|
||||||
|
</target>
|
||||||
<target name="Build all" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="Build all" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>mingw32-make</buildCommand>
|
<buildCommand>mingw32-make</buildCommand>
|
||||||
<buildArguments>-j</buildArguments>
|
<buildArguments>-j</buildArguments>
|
||||||
@@ -162,7 +200,6 @@
|
|||||||
</target>
|
</target>
|
||||||
<target name="Clean" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="Clean" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>make</buildCommand>
|
<buildCommand>make</buildCommand>
|
||||||
<buildArguments/>
|
|
||||||
<buildTarget>clean</buildTarget>
|
<buildTarget>clean</buildTarget>
|
||||||
<stopOnError>false</stopOnError>
|
<stopOnError>false</stopOnError>
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
@@ -179,7 +216,6 @@
|
|||||||
<target name="qmake" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="qmake" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>qmake</buildCommand>
|
<buildCommand>qmake</buildCommand>
|
||||||
<buildArguments>-recursive ../../demo/demo.pro</buildArguments>
|
<buildArguments>-recursive ../../demo/demo.pro</buildArguments>
|
||||||
<buildTarget/>
|
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
<runAllBuilders>false</runAllBuilders>
|
<runAllBuilders>false</runAllBuilders>
|
||||||
@@ -202,6 +238,7 @@
|
|||||||
</target>
|
</target>
|
||||||
<target name="Clean" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="Clean" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>make</buildCommand>
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
<buildTarget>clean</buildTarget>
|
<buildTarget>clean</buildTarget>
|
||||||
<stopOnError>false</stopOnError>
|
<stopOnError>false</stopOnError>
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
@@ -240,6 +277,7 @@
|
|||||||
</target>
|
</target>
|
||||||
<target name="Clean" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="Clean" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>make</buildCommand>
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
<buildTarget>clean</buildTarget>
|
<buildTarget>clean</buildTarget>
|
||||||
<stopOnError>false</stopOnError>
|
<stopOnError>false</stopOnError>
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
@@ -278,6 +316,7 @@
|
|||||||
</target>
|
</target>
|
||||||
<target name="Clean" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="Clean" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>make</buildCommand>
|
<buildCommand>make</buildCommand>
|
||||||
|
<buildArguments/>
|
||||||
<buildTarget>clean</buildTarget>
|
<buildTarget>clean</buildTarget>
|
||||||
<stopOnError>false</stopOnError>
|
<stopOnError>false</stopOnError>
|
||||||
<useDefaultCommand>true</useDefaultCommand>
|
<useDefaultCommand>true</useDefaultCommand>
|
||||||
@@ -294,7 +333,6 @@
|
|||||||
<target name="qmake" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
<target name="qmake" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||||
<buildCommand>qmake</buildCommand>
|
<buildCommand>qmake</buildCommand>
|
||||||
<buildArguments>-recursive ../../AdvancedDockingSystem/src.pro</buildArguments>
|
<buildArguments>-recursive ../../AdvancedDockingSystem/src.pro</buildArguments>
|
||||||
<buildTarget/>
|
|
||||||
<stopOnError>true</stopOnError>
|
<stopOnError>true</stopOnError>
|
||||||
<useDefaultCommand>false</useDefaultCommand>
|
<useDefaultCommand>false</useDefaultCommand>
|
||||||
<runAllBuilders>false</runAllBuilders>
|
<runAllBuilders>false</runAllBuilders>
|
||||||
|
|||||||
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
PyQtAds/_version.py export-subst
|
||||||
22
.github/workflows/linux-builds.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: linux-builds
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, ubuntu-18.04, ubuntu-16.04]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: install qt
|
||||||
|
run: |
|
||||||
|
sudo apt-get update --fix-missing
|
||||||
|
sudo apt-get install qt5-default
|
||||||
|
- name: qmake
|
||||||
|
run: qmake
|
||||||
|
- name: make
|
||||||
|
run: make -j4
|
||||||
19
.gitignore
vendored
@@ -1,2 +1,19 @@
|
|||||||
*.pro.user
|
*.pro.user
|
||||||
/ build
|
/build
|
||||||
|
*.o
|
||||||
|
*.dylib
|
||||||
|
*.app
|
||||||
|
qrc_*
|
||||||
|
moc_*
|
||||||
|
ui_*
|
||||||
|
Makefile
|
||||||
|
|
||||||
|
# IDEs
|
||||||
|
.idea
|
||||||
|
|
||||||
|
# Python
|
||||||
|
.eggs
|
||||||
|
*.pyc
|
||||||
|
*.pyd
|
||||||
|
__pycache__
|
||||||
|
PyQtAds/rc.py
|
||||||
|
|||||||
155
.travis.yml
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
language: cpp
|
||||||
|
# gcc is clang on mac
|
||||||
|
compiler: gcc
|
||||||
|
|
||||||
|
git:
|
||||||
|
depth: 1
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
include:
|
||||||
|
- name: Ubuntu qmake Qt5.5.1
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
group: stable
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'ppa:beineri/opt-qt551-trusty'
|
||||||
|
update: true
|
||||||
|
packages:
|
||||||
|
- qt55base
|
||||||
|
- qt55tools
|
||||||
|
- gcc-6
|
||||||
|
- g++-6
|
||||||
|
- libc6-i386
|
||||||
|
script:
|
||||||
|
- PATH="/opt/qt55/bin:$PATH"
|
||||||
|
- CXX="g++-6"
|
||||||
|
- CC="gcc-6"
|
||||||
|
- qt55-env.sh
|
||||||
|
- qmake
|
||||||
|
- make
|
||||||
|
- make install
|
||||||
|
- name: Ubuntu qmake dll
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
group: stable
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'ppa:beineri/opt-qt-5.12.0-xenial'
|
||||||
|
update: true
|
||||||
|
packages:
|
||||||
|
- qt512base
|
||||||
|
- qt512tools
|
||||||
|
- gcc-6
|
||||||
|
- g++-6
|
||||||
|
- libc6-i386
|
||||||
|
- libgl-dev
|
||||||
|
- libgl1-mesa-dev
|
||||||
|
- mesa-common-dev
|
||||||
|
script:
|
||||||
|
- PATH="/opt/qt512/bin:$PATH"
|
||||||
|
- CXX="g++-6"
|
||||||
|
- CC="gcc-6"
|
||||||
|
- qt512-env.sh
|
||||||
|
- qmake
|
||||||
|
- make
|
||||||
|
- make install
|
||||||
|
- name: Ubuntu qmake static
|
||||||
|
os: linux
|
||||||
|
dist: xenial
|
||||||
|
group: stable
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- sourceline: 'ppa:beineri/opt-qt-5.12.0-xenial'
|
||||||
|
update: true
|
||||||
|
packages:
|
||||||
|
- qt512base
|
||||||
|
- qt512tools
|
||||||
|
- gcc-6
|
||||||
|
- g++-6
|
||||||
|
- libc6-i386
|
||||||
|
- libgl-dev
|
||||||
|
- libgl1-mesa-dev
|
||||||
|
- mesa-common-dev
|
||||||
|
script:
|
||||||
|
- PATH="/opt/qt512/bin:$PATH"
|
||||||
|
- CXX="g++-6"
|
||||||
|
- CC="gcc-6"
|
||||||
|
- qt512-env.sh
|
||||||
|
- qmake "CONFIG+=adsBuildStatic"
|
||||||
|
- make
|
||||||
|
- make install
|
||||||
|
- name: macOS CMake dll
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode10.1
|
||||||
|
addons:
|
||||||
|
homebrew:
|
||||||
|
packages:
|
||||||
|
- qt
|
||||||
|
update: true
|
||||||
|
script:
|
||||||
|
- PATH="/usr/local/opt/qt5/bin:$PATH"
|
||||||
|
- mkdir -p build
|
||||||
|
- cd build
|
||||||
|
- cmake --version
|
||||||
|
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_DEBUG_POSTFIX=_debug -DBUILD_EXAMPLES=ON -DBUILD_STATIC=OFF -DCMAKE_INSTALL_PREFIX="./installed" ../
|
||||||
|
- cmake --build .
|
||||||
|
- cmake --build . --target install
|
||||||
|
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_EXAMPLES=ON -DBUILD_STATIC=OFF -DCMAKE_INSTALL_PREFIX="./installed" ../
|
||||||
|
- cmake --build .
|
||||||
|
- cmake --build . --target install
|
||||||
|
- name: macOS CMake static
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode10.1
|
||||||
|
addons:
|
||||||
|
homebrew:
|
||||||
|
packages:
|
||||||
|
- qt
|
||||||
|
update: true
|
||||||
|
script:
|
||||||
|
- PATH="/usr/local/opt/qt5/bin:$PATH"
|
||||||
|
- mkdir -p build
|
||||||
|
- cd build
|
||||||
|
- cmake --version
|
||||||
|
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_DEBUG_POSTFIX=_debug -DBUILD_EXAMPLES=ON -DBUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX="./installed" ../
|
||||||
|
- cmake --build .
|
||||||
|
- cmake --build . --target install
|
||||||
|
- cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_EXAMPLES=ON -DBUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX="./installed" ../
|
||||||
|
- cmake --build .
|
||||||
|
- cmake --build . --target install
|
||||||
|
- name: macOS qmake dll
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode10.1
|
||||||
|
addons:
|
||||||
|
homebrew:
|
||||||
|
packages:
|
||||||
|
- qt
|
||||||
|
update: true
|
||||||
|
script:
|
||||||
|
- PATH="/usr/local/opt/qt5/bin:$PATH"
|
||||||
|
- qmake
|
||||||
|
- make
|
||||||
|
- make install
|
||||||
|
- name: macOS qmake static
|
||||||
|
os: osx
|
||||||
|
osx_image: xcode10.1
|
||||||
|
addons:
|
||||||
|
homebrew:
|
||||||
|
packages:
|
||||||
|
- qt
|
||||||
|
update: true
|
||||||
|
script:
|
||||||
|
- PATH="/usr/local/opt/qt5/bin:$PATH"
|
||||||
|
- qmake "CONFIG+=adsBuildStatic"
|
||||||
|
- make
|
||||||
|
- make install
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
|
||||||
127
CMakeLists.txt
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.3)
|
||||||
|
set(ads_VERSION "2.3.2")
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
project(QtAdvancedDockingSystem VERSION ${ads_VERSION})
|
||||||
|
option(BUILD_STATIC "Build the static library" OFF)
|
||||||
|
option(BUILD_EXAMPLES "Build the examples" ON)
|
||||||
|
set(REQUIRED_QT_VERSION 5.5.0)
|
||||||
|
find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
message(STATUS "Found Qt ${Qt5Core_VERSION}")
|
||||||
|
set(ads_INCLUDE ${ads_INCLUDE} ${Qt5Core_INCLUDE_DIRS})
|
||||||
|
set(ads_INCLUDE ${ads_INCLUDE} "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||||
|
set(ads_LIBS ${ads_LIBS} ${Qt5Core_LIBRARIES})
|
||||||
|
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ${Qt5Core_COMPILE_DEFINITIONS})
|
||||||
|
set(ads_LIBS ${ads_LIBS} ${Qt5Gui_LIBRARIES})
|
||||||
|
set(ads_INCLUDE ${ads_INCLUDE} ${Qt5Gui_INCLUDE_DIRS})
|
||||||
|
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ${Qt5Gui_COMPILE_DEFINITIONS})
|
||||||
|
set(ads_LIBS ${ads_LIBS} ${Qt5Widgets_LIBRARIES})
|
||||||
|
set(ads_INCLUDE ${ads_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS})
|
||||||
|
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
set(CMAKE_STATIC_LIBRARY_SUFFIX "_static${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||||
|
endif()
|
||||||
|
set(ads_SRCS
|
||||||
|
src/ads_globals.cpp
|
||||||
|
src/DockAreaTabBar.cpp
|
||||||
|
src/DockAreaTitleBar.cpp
|
||||||
|
src/DockAreaWidget.cpp
|
||||||
|
src/DockContainerWidget.cpp
|
||||||
|
src/DockManager.cpp
|
||||||
|
src/DockOverlay.cpp
|
||||||
|
src/DockSplitter.cpp
|
||||||
|
src/DockWidget.cpp
|
||||||
|
src/DockWidgetTab.cpp
|
||||||
|
src/DockingStateReader.cpp
|
||||||
|
src/ElidingLabel.cpp
|
||||||
|
src/FloatingDockContainer.cpp
|
||||||
|
src/FloatingDragPreview.cpp
|
||||||
|
src/IconProvider.cpp
|
||||||
|
src/ads.qrc
|
||||||
|
src/linux/FloatingWidgetTitleBar.cpp
|
||||||
|
)
|
||||||
|
set(ads_INSTALL_INCLUDE
|
||||||
|
src/ads_globals.h
|
||||||
|
src/DockAreaTabBar.h
|
||||||
|
src/DockAreaTitleBar.h
|
||||||
|
src/DockAreaWidget.h
|
||||||
|
src/DockContainerWidget.h
|
||||||
|
src/DockManager.h
|
||||||
|
src/DockOverlay.h
|
||||||
|
src/DockSplitter.h
|
||||||
|
src/DockWidget.h
|
||||||
|
src/DockWidgetTab.h
|
||||||
|
src/DockingStateReader.h
|
||||||
|
src/ElidingLabel.h
|
||||||
|
src/FloatingDockContainer.h
|
||||||
|
src/FloatingDragPreview.h
|
||||||
|
src/IconProvider.h
|
||||||
|
src/linux/FloatingWidgetTitleBar.h
|
||||||
|
)
|
||||||
|
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
|
||||||
|
set(ads_PlatformDir "x86")
|
||||||
|
else()
|
||||||
|
set(ads_PlatformDir "x64")
|
||||||
|
endif()
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
add_library(qtadvanceddocking STATIC ${ads_SRCS})
|
||||||
|
target_compile_definitions(qtadvanceddocking PUBLIC ADS_STATIC)
|
||||||
|
else()
|
||||||
|
add_library(qtadvanceddocking SHARED ${ads_SRCS})
|
||||||
|
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} ADS_SHARED_EXPORT)
|
||||||
|
endif()
|
||||||
|
install(FILES ${ads_INSTALL_INCLUDE}
|
||||||
|
DESTINATION include
|
||||||
|
COMPONENT headers
|
||||||
|
)
|
||||||
|
install(FILES
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/gnu-lgpl-v2.1.md"
|
||||||
|
DESTINATION license
|
||||||
|
COMPONENT license
|
||||||
|
)
|
||||||
|
install(TARGETS qtadvanceddocking
|
||||||
|
EXPORT adsTargets
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
INCLUDES DESTINATION include
|
||||||
|
)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file("adsConfigVersion.cmake"
|
||||||
|
VERSION ${ads_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
install(EXPORT adsTargets
|
||||||
|
FILE adsTargets.cmake
|
||||||
|
NAMESPACE ads::
|
||||||
|
DESTINATION lib/cmake/ads
|
||||||
|
)
|
||||||
|
install(FILES "adsConfig.cmake" "${CMAKE_BINARY_DIR}/adsConfigVersion.cmake"
|
||||||
|
DESTINATION lib/cmake/ads
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(qtadvanceddocking PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${ads_INCLUDE}>"
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
target_link_libraries(qtadvanceddocking PUBLIC ${ads_LIBS})
|
||||||
|
target_compile_definitions(qtadvanceddocking PRIVATE ${ads_COMPILE_DEFINE})
|
||||||
|
set_target_properties(qtadvanceddocking PROPERTIES
|
||||||
|
VERSION ${ads_VERSION}
|
||||||
|
EXPORT_NAME "QtAdvancedDockingSystem"
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
if(BUILD_EXAMPLES)
|
||||||
|
add_subdirectory(example)
|
||||||
|
add_subdirectory(demo)
|
||||||
|
endif()
|
||||||
|
|
||||||
2
MANIFEST.in
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
include versioneer.py
|
||||||
|
include PyQtAds/_version.py
|
||||||
10
PyQtAds/QtAds/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from .ads import ads
|
||||||
|
from .._version import *
|
||||||
|
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
for name, member in inspect.getmembers(ads):
|
||||||
|
if not name.startswith('_'):
|
||||||
|
globals()[name] = member
|
||||||
|
|
||||||
|
del ads
|
||||||
9
PyQtAds/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from .rc import *
|
||||||
|
from ._version import get_versions
|
||||||
|
__version__ = get_versions()['version']
|
||||||
|
short_version = __version__
|
||||||
|
version = __version__
|
||||||
|
full_version = __version__
|
||||||
|
git_revision = get_versions()['full-revisionid']
|
||||||
|
release = not get_versions()['dirty']
|
||||||
|
del get_versions
|
||||||
520
PyQtAds/_version.py
Normal file
@@ -0,0 +1,520 @@
|
|||||||
|
|
||||||
|
# This file helps to compute a version number in source trees obtained from
|
||||||
|
# git-archive tarball (such as those provided by githubs download-from-tag
|
||||||
|
# feature). Distribution tarballs (built by setup.py sdist) and build
|
||||||
|
# directories (produced by setup.py build) will contain a much shorter file
|
||||||
|
# that just contains the computed version number.
|
||||||
|
|
||||||
|
# This file is released into the public domain. Generated by
|
||||||
|
# versioneer-0.18 (https://github.com/warner/python-versioneer)
|
||||||
|
|
||||||
|
"""Git implementation of _version.py."""
|
||||||
|
|
||||||
|
import errno
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def get_keywords():
|
||||||
|
"""Get the keywords needed to look up the version information."""
|
||||||
|
# these strings will be replaced by git during git-archive.
|
||||||
|
# setup.py/versioneer.py will grep for the variable names, so they must
|
||||||
|
# each be defined on a line of their own. _version.py will just call
|
||||||
|
# get_keywords().
|
||||||
|
git_refnames = "$Format:%d$"
|
||||||
|
git_full = "$Format:%H$"
|
||||||
|
git_date = "$Format:%ci$"
|
||||||
|
keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
|
||||||
|
return keywords
|
||||||
|
|
||||||
|
|
||||||
|
class VersioneerConfig:
|
||||||
|
"""Container for Versioneer configuration parameters."""
|
||||||
|
|
||||||
|
|
||||||
|
def get_config():
|
||||||
|
"""Create, populate and return the VersioneerConfig() object."""
|
||||||
|
# these strings are filled in when 'setup.py versioneer' creates
|
||||||
|
# _version.py
|
||||||
|
cfg = VersioneerConfig()
|
||||||
|
cfg.VCS = "git"
|
||||||
|
cfg.style = "pep440"
|
||||||
|
cfg.tag_prefix = ""
|
||||||
|
cfg.parentdir_prefix = "None"
|
||||||
|
cfg.versionfile_source = "PyQtAds/_version.py"
|
||||||
|
cfg.verbose = False
|
||||||
|
return cfg
|
||||||
|
|
||||||
|
|
||||||
|
class NotThisMethod(Exception):
|
||||||
|
"""Exception raised if a method is not valid for the current scenario."""
|
||||||
|
|
||||||
|
|
||||||
|
LONG_VERSION_PY = {}
|
||||||
|
HANDLERS = {}
|
||||||
|
|
||||||
|
|
||||||
|
def register_vcs_handler(vcs, method): # decorator
|
||||||
|
"""Create decorator to mark a method as the handler of a VCS."""
|
||||||
|
def decorate(f):
|
||||||
|
"""Store f in HANDLERS[vcs][method]."""
|
||||||
|
if vcs not in HANDLERS:
|
||||||
|
HANDLERS[vcs] = {}
|
||||||
|
HANDLERS[vcs][method] = f
|
||||||
|
return f
|
||||||
|
return decorate
|
||||||
|
|
||||||
|
|
||||||
|
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
|
||||||
|
env=None):
|
||||||
|
"""Call the given command(s)."""
|
||||||
|
assert isinstance(commands, list)
|
||||||
|
p = None
|
||||||
|
for c in commands:
|
||||||
|
try:
|
||||||
|
dispcmd = str([c] + args)
|
||||||
|
# remember shell=False, so use git.cmd on windows, not just git
|
||||||
|
p = subprocess.Popen([c] + args, cwd=cwd, env=env,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=(subprocess.PIPE if hide_stderr
|
||||||
|
else None))
|
||||||
|
break
|
||||||
|
except EnvironmentError:
|
||||||
|
e = sys.exc_info()[1]
|
||||||
|
if e.errno == errno.ENOENT:
|
||||||
|
continue
|
||||||
|
if verbose:
|
||||||
|
print("unable to run %s" % dispcmd)
|
||||||
|
print(e)
|
||||||
|
return None, None
|
||||||
|
else:
|
||||||
|
if verbose:
|
||||||
|
print("unable to find command, tried %s" % (commands,))
|
||||||
|
return None, None
|
||||||
|
stdout = p.communicate()[0].strip()
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
stdout = stdout.decode()
|
||||||
|
if p.returncode != 0:
|
||||||
|
if verbose:
|
||||||
|
print("unable to run %s (error)" % dispcmd)
|
||||||
|
print("stdout was %s" % stdout)
|
||||||
|
return None, p.returncode
|
||||||
|
return stdout, p.returncode
|
||||||
|
|
||||||
|
|
||||||
|
def versions_from_parentdir(parentdir_prefix, root, verbose):
|
||||||
|
"""Try to determine the version from the parent directory name.
|
||||||
|
|
||||||
|
Source tarballs conventionally unpack into a directory that includes both
|
||||||
|
the project name and a version string. We will also support searching up
|
||||||
|
two directory levels for an appropriately named parent directory
|
||||||
|
"""
|
||||||
|
rootdirs = []
|
||||||
|
|
||||||
|
for i in range(3):
|
||||||
|
dirname = os.path.basename(root)
|
||||||
|
if dirname.startswith(parentdir_prefix):
|
||||||
|
return {"version": dirname[len(parentdir_prefix):],
|
||||||
|
"full-revisionid": None,
|
||||||
|
"dirty": False, "error": None, "date": None}
|
||||||
|
else:
|
||||||
|
rootdirs.append(root)
|
||||||
|
root = os.path.dirname(root) # up a level
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
print("Tried directories %s but none started with prefix %s" %
|
||||||
|
(str(rootdirs), parentdir_prefix))
|
||||||
|
raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
|
||||||
|
|
||||||
|
|
||||||
|
@register_vcs_handler("git", "get_keywords")
|
||||||
|
def git_get_keywords(versionfile_abs):
|
||||||
|
"""Extract version information from the given file."""
|
||||||
|
# the code embedded in _version.py can just fetch the value of these
|
||||||
|
# keywords. When used from setup.py, we don't want to import _version.py,
|
||||||
|
# so we do it with a regexp instead. This function is not used from
|
||||||
|
# _version.py.
|
||||||
|
keywords = {}
|
||||||
|
try:
|
||||||
|
f = open(versionfile_abs, "r")
|
||||||
|
for line in f.readlines():
|
||||||
|
if line.strip().startswith("git_refnames ="):
|
||||||
|
mo = re.search(r'=\s*"(.*)"', line)
|
||||||
|
if mo:
|
||||||
|
keywords["refnames"] = mo.group(1)
|
||||||
|
if line.strip().startswith("git_full ="):
|
||||||
|
mo = re.search(r'=\s*"(.*)"', line)
|
||||||
|
if mo:
|
||||||
|
keywords["full"] = mo.group(1)
|
||||||
|
if line.strip().startswith("git_date ="):
|
||||||
|
mo = re.search(r'=\s*"(.*)"', line)
|
||||||
|
if mo:
|
||||||
|
keywords["date"] = mo.group(1)
|
||||||
|
f.close()
|
||||||
|
except EnvironmentError:
|
||||||
|
pass
|
||||||
|
return keywords
|
||||||
|
|
||||||
|
|
||||||
|
@register_vcs_handler("git", "keywords")
|
||||||
|
def git_versions_from_keywords(keywords, tag_prefix, verbose):
|
||||||
|
"""Get version information from git keywords."""
|
||||||
|
if not keywords:
|
||||||
|
raise NotThisMethod("no keywords at all, weird")
|
||||||
|
date = keywords.get("date")
|
||||||
|
if date is not None:
|
||||||
|
# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
|
||||||
|
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
|
||||||
|
# -like" string, which we must then edit to make compliant), because
|
||||||
|
# it's been around since git-1.5.3, and it's too difficult to
|
||||||
|
# discover which version we're using, or to work around using an
|
||||||
|
# older one.
|
||||||
|
date = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
|
||||||
|
refnames = keywords["refnames"].strip()
|
||||||
|
if refnames.startswith("$Format"):
|
||||||
|
if verbose:
|
||||||
|
print("keywords are unexpanded, not using")
|
||||||
|
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
|
||||||
|
refs = set([r.strip() for r in refnames.strip("()").split(",")])
|
||||||
|
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
|
||||||
|
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
|
||||||
|
TAG = "tag: "
|
||||||
|
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
|
||||||
|
if not tags:
|
||||||
|
# Either we're using git < 1.8.3, or there really are no tags. We use
|
||||||
|
# a heuristic: assume all version tags have a digit. The old git %d
|
||||||
|
# expansion behaves like git log --decorate=short and strips out the
|
||||||
|
# refs/heads/ and refs/tags/ prefixes that would let us distinguish
|
||||||
|
# between branches and tags. By ignoring refnames without digits, we
|
||||||
|
# filter out many common branch names like "release" and
|
||||||
|
# "stabilization", as well as "HEAD" and "master".
|
||||||
|
tags = set([r for r in refs if re.search(r'\d', r)])
|
||||||
|
if verbose:
|
||||||
|
print("discarding '%s', no digits" % ",".join(refs - tags))
|
||||||
|
if verbose:
|
||||||
|
print("likely tags: %s" % ",".join(sorted(tags)))
|
||||||
|
for ref in sorted(tags):
|
||||||
|
# sorting will prefer e.g. "2.0" over "2.0rc1"
|
||||||
|
if ref.startswith(tag_prefix):
|
||||||
|
r = ref[len(tag_prefix):]
|
||||||
|
if verbose:
|
||||||
|
print("picking %s" % r)
|
||||||
|
return {"version": r,
|
||||||
|
"full-revisionid": keywords["full"].strip(),
|
||||||
|
"dirty": False, "error": None,
|
||||||
|
"date": date}
|
||||||
|
# no suitable tags, so version is "0+unknown", but full hex is still there
|
||||||
|
if verbose:
|
||||||
|
print("no suitable tags, using unknown + full revision id")
|
||||||
|
return {"version": "0+unknown",
|
||||||
|
"full-revisionid": keywords["full"].strip(),
|
||||||
|
"dirty": False, "error": "no suitable tags", "date": None}
|
||||||
|
|
||||||
|
|
||||||
|
@register_vcs_handler("git", "pieces_from_vcs")
|
||||||
|
def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
|
||||||
|
"""Get version from 'git describe' in the root of the source tree.
|
||||||
|
|
||||||
|
This only gets called if the git-archive 'subst' keywords were *not*
|
||||||
|
expanded, and _version.py hasn't already been rewritten with a short
|
||||||
|
version string, meaning we're inside a checked out source tree.
|
||||||
|
"""
|
||||||
|
GITS = ["git"]
|
||||||
|
if sys.platform == "win32":
|
||||||
|
GITS = ["git.cmd", "git.exe"]
|
||||||
|
|
||||||
|
out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root,
|
||||||
|
hide_stderr=True)
|
||||||
|
if rc != 0:
|
||||||
|
if verbose:
|
||||||
|
print("Directory %s not under git control" % root)
|
||||||
|
raise NotThisMethod("'git rev-parse --git-dir' returned error")
|
||||||
|
|
||||||
|
# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
|
||||||
|
# if there isn't one, this yields HEX[-dirty] (no NUM)
|
||||||
|
describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
|
||||||
|
"--always", "--long",
|
||||||
|
"--match", "%s*" % tag_prefix],
|
||||||
|
cwd=root)
|
||||||
|
# --long was added in git-1.5.5
|
||||||
|
if describe_out is None:
|
||||||
|
raise NotThisMethod("'git describe' failed")
|
||||||
|
describe_out = describe_out.strip()
|
||||||
|
full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
|
||||||
|
if full_out is None:
|
||||||
|
raise NotThisMethod("'git rev-parse' failed")
|
||||||
|
full_out = full_out.strip()
|
||||||
|
|
||||||
|
pieces = {}
|
||||||
|
pieces["long"] = full_out
|
||||||
|
pieces["short"] = full_out[:7] # maybe improved later
|
||||||
|
pieces["error"] = None
|
||||||
|
|
||||||
|
# parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]
|
||||||
|
# TAG might have hyphens.
|
||||||
|
git_describe = describe_out
|
||||||
|
|
||||||
|
# look for -dirty suffix
|
||||||
|
dirty = git_describe.endswith("-dirty")
|
||||||
|
pieces["dirty"] = dirty
|
||||||
|
if dirty:
|
||||||
|
git_describe = git_describe[:git_describe.rindex("-dirty")]
|
||||||
|
|
||||||
|
# now we have TAG-NUM-gHEX or HEX
|
||||||
|
|
||||||
|
if "-" in git_describe:
|
||||||
|
# TAG-NUM-gHEX
|
||||||
|
mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
|
||||||
|
if not mo:
|
||||||
|
# unparseable. Maybe git-describe is misbehaving?
|
||||||
|
pieces["error"] = ("unable to parse git-describe output: '%s'"
|
||||||
|
% describe_out)
|
||||||
|
return pieces
|
||||||
|
|
||||||
|
# tag
|
||||||
|
full_tag = mo.group(1)
|
||||||
|
if not full_tag.startswith(tag_prefix):
|
||||||
|
if verbose:
|
||||||
|
fmt = "tag '%s' doesn't start with prefix '%s'"
|
||||||
|
print(fmt % (full_tag, tag_prefix))
|
||||||
|
pieces["error"] = ("tag '%s' doesn't start with prefix '%s'"
|
||||||
|
% (full_tag, tag_prefix))
|
||||||
|
return pieces
|
||||||
|
pieces["closest-tag"] = full_tag[len(tag_prefix):]
|
||||||
|
|
||||||
|
# distance: number of commits since tag
|
||||||
|
pieces["distance"] = int(mo.group(2))
|
||||||
|
|
||||||
|
# commit: short hex revision ID
|
||||||
|
pieces["short"] = mo.group(3)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# HEX: no tags
|
||||||
|
pieces["closest-tag"] = None
|
||||||
|
count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"],
|
||||||
|
cwd=root)
|
||||||
|
pieces["distance"] = int(count_out) # total number of commits
|
||||||
|
|
||||||
|
# commit date: see ISO-8601 comment in git_versions_from_keywords()
|
||||||
|
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
|
||||||
|
cwd=root)[0].strip()
|
||||||
|
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
|
||||||
|
|
||||||
|
return pieces
|
||||||
|
|
||||||
|
|
||||||
|
def plus_or_dot(pieces):
|
||||||
|
"""Return a + if we don't already have one, else return a ."""
|
||||||
|
if "+" in pieces.get("closest-tag", ""):
|
||||||
|
return "."
|
||||||
|
return "+"
|
||||||
|
|
||||||
|
|
||||||
|
def render_pep440(pieces):
|
||||||
|
"""Build up version string, with post-release "local version identifier".
|
||||||
|
|
||||||
|
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
|
||||||
|
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
|
||||||
|
"""
|
||||||
|
if pieces["closest-tag"]:
|
||||||
|
rendered = pieces["closest-tag"]
|
||||||
|
if pieces["distance"] or pieces["dirty"]:
|
||||||
|
rendered += plus_or_dot(pieces)
|
||||||
|
rendered += "%d.g%s" % (pieces["distance"], pieces["short"])
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".dirty"
|
||||||
|
else:
|
||||||
|
# exception #1
|
||||||
|
rendered = "0+untagged.%d.g%s" % (pieces["distance"],
|
||||||
|
pieces["short"])
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".dirty"
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def render_pep440_pre(pieces):
|
||||||
|
"""TAG[.post.devDISTANCE] -- No -dirty.
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
1: no tags. 0.post.devDISTANCE
|
||||||
|
"""
|
||||||
|
if pieces["closest-tag"]:
|
||||||
|
rendered = pieces["closest-tag"]
|
||||||
|
if pieces["distance"]:
|
||||||
|
rendered += ".post.dev%d" % pieces["distance"]
|
||||||
|
else:
|
||||||
|
# exception #1
|
||||||
|
rendered = "0.post.dev%d" % pieces["distance"]
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def render_pep440_post(pieces):
|
||||||
|
"""TAG[.postDISTANCE[.dev0]+gHEX] .
|
||||||
|
|
||||||
|
The ".dev0" means dirty. Note that .dev0 sorts backwards
|
||||||
|
(a dirty tree will appear "older" than the corresponding clean one),
|
||||||
|
but you shouldn't be releasing software with -dirty anyways.
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
1: no tags. 0.postDISTANCE[.dev0]
|
||||||
|
"""
|
||||||
|
if pieces["closest-tag"]:
|
||||||
|
rendered = pieces["closest-tag"]
|
||||||
|
if pieces["distance"] or pieces["dirty"]:
|
||||||
|
rendered += ".post%d" % pieces["distance"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".dev0"
|
||||||
|
rendered += plus_or_dot(pieces)
|
||||||
|
rendered += "g%s" % pieces["short"]
|
||||||
|
else:
|
||||||
|
# exception #1
|
||||||
|
rendered = "0.post%d" % pieces["distance"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".dev0"
|
||||||
|
rendered += "+g%s" % pieces["short"]
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def render_pep440_old(pieces):
|
||||||
|
"""TAG[.postDISTANCE[.dev0]] .
|
||||||
|
|
||||||
|
The ".dev0" means dirty.
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
1: no tags. 0.postDISTANCE[.dev0]
|
||||||
|
"""
|
||||||
|
if pieces["closest-tag"]:
|
||||||
|
rendered = pieces["closest-tag"]
|
||||||
|
if pieces["distance"] or pieces["dirty"]:
|
||||||
|
rendered += ".post%d" % pieces["distance"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".dev0"
|
||||||
|
else:
|
||||||
|
# exception #1
|
||||||
|
rendered = "0.post%d" % pieces["distance"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += ".dev0"
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def render_git_describe(pieces):
|
||||||
|
"""TAG[-DISTANCE-gHEX][-dirty].
|
||||||
|
|
||||||
|
Like 'git describe --tags --dirty --always'.
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
1: no tags. HEX[-dirty] (note: no 'g' prefix)
|
||||||
|
"""
|
||||||
|
if pieces["closest-tag"]:
|
||||||
|
rendered = pieces["closest-tag"]
|
||||||
|
if pieces["distance"]:
|
||||||
|
rendered += "-%d-g%s" % (pieces["distance"], pieces["short"])
|
||||||
|
else:
|
||||||
|
# exception #1
|
||||||
|
rendered = pieces["short"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += "-dirty"
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def render_git_describe_long(pieces):
|
||||||
|
"""TAG-DISTANCE-gHEX[-dirty].
|
||||||
|
|
||||||
|
Like 'git describe --tags --dirty --always -long'.
|
||||||
|
The distance/hash is unconditional.
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
1: no tags. HEX[-dirty] (note: no 'g' prefix)
|
||||||
|
"""
|
||||||
|
if pieces["closest-tag"]:
|
||||||
|
rendered = pieces["closest-tag"]
|
||||||
|
rendered += "-%d-g%s" % (pieces["distance"], pieces["short"])
|
||||||
|
else:
|
||||||
|
# exception #1
|
||||||
|
rendered = pieces["short"]
|
||||||
|
if pieces["dirty"]:
|
||||||
|
rendered += "-dirty"
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
|
def render(pieces, style):
|
||||||
|
"""Render the given version pieces into the requested style."""
|
||||||
|
if pieces["error"]:
|
||||||
|
return {"version": "unknown",
|
||||||
|
"full-revisionid": pieces.get("long"),
|
||||||
|
"dirty": None,
|
||||||
|
"error": pieces["error"],
|
||||||
|
"date": None}
|
||||||
|
|
||||||
|
if not style or style == "default":
|
||||||
|
style = "pep440" # the default
|
||||||
|
|
||||||
|
if style == "pep440":
|
||||||
|
rendered = render_pep440(pieces)
|
||||||
|
elif style == "pep440-pre":
|
||||||
|
rendered = render_pep440_pre(pieces)
|
||||||
|
elif style == "pep440-post":
|
||||||
|
rendered = render_pep440_post(pieces)
|
||||||
|
elif style == "pep440-old":
|
||||||
|
rendered = render_pep440_old(pieces)
|
||||||
|
elif style == "git-describe":
|
||||||
|
rendered = render_git_describe(pieces)
|
||||||
|
elif style == "git-describe-long":
|
||||||
|
rendered = render_git_describe_long(pieces)
|
||||||
|
else:
|
||||||
|
raise ValueError("unknown style '%s'" % style)
|
||||||
|
|
||||||
|
return {"version": rendered, "full-revisionid": pieces["long"],
|
||||||
|
"dirty": pieces["dirty"], "error": None,
|
||||||
|
"date": pieces.get("date")}
|
||||||
|
|
||||||
|
|
||||||
|
def get_versions():
|
||||||
|
"""Get version information or return default if unable to do so."""
|
||||||
|
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
|
||||||
|
# __file__, we can work backwards from there to the root. Some
|
||||||
|
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
|
||||||
|
# case we can only use expanded keywords.
|
||||||
|
|
||||||
|
cfg = get_config()
|
||||||
|
verbose = cfg.verbose
|
||||||
|
|
||||||
|
try:
|
||||||
|
return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,
|
||||||
|
verbose)
|
||||||
|
except NotThisMethod:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
root = os.path.realpath(__file__)
|
||||||
|
# versionfile_source is the relative path from the top of the source
|
||||||
|
# tree (where the .git directory might live) to this file. Invert
|
||||||
|
# this to find the root from __file__.
|
||||||
|
for i in cfg.versionfile_source.split('/'):
|
||||||
|
root = os.path.dirname(root)
|
||||||
|
except NameError:
|
||||||
|
return {"version": "0+unknown", "full-revisionid": None,
|
||||||
|
"dirty": None,
|
||||||
|
"error": "unable to find root of source tree",
|
||||||
|
"date": None}
|
||||||
|
|
||||||
|
try:
|
||||||
|
pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
|
||||||
|
return render(pieces, cfg.style)
|
||||||
|
except NotThisMethod:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if cfg.parentdir_prefix:
|
||||||
|
return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)
|
||||||
|
except NotThisMethod:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return {"version": "0+unknown", "full-revisionid": None,
|
||||||
|
"dirty": None,
|
||||||
|
"error": "unable to compute version", "date": None}
|
||||||
166
README.md
@@ -1,10 +1,16 @@
|
|||||||
# Advanced Docking System for Qt
|
# Advanced Docking System for Qt
|
||||||
|
[](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
|
||||||
|
[](https://ci.appveyor.com/project/githubuser0xFFFF/qt-advanced-docking-system/branch/master)
|
||||||
|
[](gnu-lgpl-v2.1.md)
|
||||||
|
|
||||||
Qt Advanced Docking System lets you create customizable layouts using a full
|
Qt Advanced Docking System lets you create customizable layouts using a full
|
||||||
featured window docking system similar to what is found in many popular
|
featured window docking system similar to what is found in many popular
|
||||||
integrated development environements (IDEs) such as Visual Studio.
|
integrated development environments (IDEs) such as Visual Studio.
|
||||||
|
|
||||||
|
[](https://www.youtube.com/watch?v=7pdNfafg3Qc)
|
||||||
|
|
||||||
Everything is implemented with standard Qt functionality without any
|
Everything is implemented with standard Qt functionality without any
|
||||||
platform specific code. Basic usage of QWidgets an QLayouts and using basic
|
platform specific code. Basic usage of QWidgets and QLayouts and using basic
|
||||||
styles as much as possible.
|
styles as much as possible.
|
||||||
|
|
||||||
This work is based on and inspired by the
|
This work is based on and inspired by the
|
||||||
@@ -14,6 +20,17 @@ code quality, readibility and to fix all issues from the issue tracker
|
|||||||
of his docking system project.
|
of his docking system project.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
### Overview
|
||||||
|
- [Docking everywhere - no central widget](#docking-everywhere---no-central-widget)
|
||||||
|
- [Docking inside floating windows](#docking-inside-floating-windows)
|
||||||
|
- [Grouped dragging](#grouped-dragging)
|
||||||
|
- [Perspectives for fast switching of the complete main window layout](#perspectives-for-fast-switching-of-the-complete-main-window-layout)
|
||||||
|
- [Opaque and non-opaque splitter resizing](#opaque-and-non-opaque-splitter-resizing)
|
||||||
|
- [Opaque and non-opaque undocking](#opaque-and-non-opaque-undocking)
|
||||||
|
- [Tab-menu for easy handling of many tabbed dock widgets](#tab-menu-for-easy-handling-of-many-tabbed-dock-widgets)
|
||||||
|
- [Many different ways to detach dock widgets](#many-different-ways-to-detach-dock-widgets)
|
||||||
|
- [Supports deletion of dynamically created dock widgets](#supports-deletion-of-dynamically-created-dock-widgets)
|
||||||
|
|
||||||
### Docking everywhere - no central widget
|
### Docking everywhere - no central widget
|
||||||
There is no central widget like in the Qt docking system. You can dock on every
|
There is no central widget like in the Qt docking system. You can dock on every
|
||||||
border of the main window or you can dock into each dock area - so you are
|
border of the main window or you can dock into each dock area - so you are
|
||||||
@@ -51,17 +68,158 @@ main window layout.
|
|||||||
\
|
\
|
||||||

|

|
||||||
|
|
||||||
|
### Opaque and non-opaque splitter resizing
|
||||||
|
The advanced docking system uses standard QSplitters as resize separators and thus supports opaque and non-opaque resizing functionality of QSplitter. In some rare cases, for very complex widgets or on slow machines resizing via separator on the fly may cause flicking and glaring of rendered content inside a widget. The global dock manager flag `OpaqueSplitterResize` configures the resizing behaviour of the splitters. If this flag is set, then widgets are resized dynamically (opaquely) while interactively moving the splitters.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
If this flag is cleared, the widget resizing is deferred until the mouse button is released - this is some kind of lazy resizing separator.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Opaque and non-opaque undocking
|
||||||
|
By default, opaque undocking is active. That means, as soon as you drag a dock widget or a dock area with a number of dock widgets it will be undocked and moved into a floating widget and then the floating widget will be dragged around. That means undocking will take place immediatelly. You can compare this with opaque splitter resizing. If the flag `OpaqueUndocking` is cleared, then non-opaque undocking is active. In this mode, undocking is more like a standard drag and drop operation. That means, the dragged dock widget or dock area is not undocked immediatelly. Instead, a drag preview widget is created and dragged around to indicate the future position of the dock widget or dock area. The actual dock operation is only executed when the mouse button is released. That makes it possible, to cancel an active drag operation with the escape key.
|
||||||
|
|
||||||
|
The drag preview widget can be configured by a number of global dock manager flags:
|
||||||
|
- `DragPreviewIsDynamic`: if this flag is enabled, the preview will be adjusted dynamically to the drop area
|
||||||
|
- `DragPreviewShowsContentPixmap`: the created drag preview window shows a static copy of the content of the dock widget / dock are that is dragged
|
||||||
|
- `DragPreviewHasWindowFrame`: this flag configures if the drag preview is frameless like a QRubberBand or looks like a real window
|
||||||
|
|
||||||
|
The best way to test non-opaque undocking is to set the standard flags: `CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig)`.
|
||||||
|
|
||||||
|
### Tab-menu for easy handling of many tabbed dock widgets
|
||||||
|
Tabs are a good way to quickly switch between dockwidgets in a dockarea. However, if the number of dockwidgets in a dockarea is too large, this may affect the usability of the tab bar. To keep track in this situation, you can use the tab menu. The menu allows you to quickly select the dockwidget you want to activate from a drop down menu.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Many different ways to detach dock widgets
|
||||||
|
You can detach dock widgets and also dock areas in the following ways:
|
||||||
|
- by dragging the dock widget tab or the dock area title bar
|
||||||
|
- by double clicking the tab or title bar
|
||||||
|
- by using the detach menu entry from the tab and title bar drop down menu
|
||||||
|
|
||||||
|
### Supports deletion of dynamically created dock widgets
|
||||||
|
Normally clicking the close button of a dock widget will just hide the widget and the user can show it again using the toggleView() action of the dock widget. This is meant for user interfaces with a static amount of widgets. But the advanced docking system also supports dynamic dock widgets that will get deleted on close. If you set the dock widget flag `DockWidgetDeleteOnClose` for a certain dock widget, then it will be deleted as soon as you close this dock widget. This enables the implementation of user interfaces with dynamically created editors, like in word processing applications or source code development tools.
|
||||||
|
|
||||||
## Tested Compatible Environments
|
## Tested Compatible Environments
|
||||||
- Windows 10
|
### Windows
|
||||||
|
Windows 10 [](https://ci.appveyor.com/project/githubuser0xFFFF/qt-advanced-docking-system/branch/master)
|
||||||
|
|
||||||
|
The library was developed on and for Windows. It is used in a commercial Windows application and is therefore constantly tested.
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
macOS [](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
|
||||||
|
|
||||||
|
The application can be compiled for macOS. A user reported, that the library works on macOS. If have not tested it.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Linux
|
||||||
|
Ubuntu [](https://travis-ci.org/githubuser0xFFFF/Qt-Advanced-Docking-System)
|
||||||
|
[](https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System/actions?query=workflow%3Alinux-builds)
|
||||||
|
|
||||||
|
The application can be compiled for Linux and has been developed and tested with **Kubuntu 18.04** and **Kubuntu 19.10**.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
and with **Ubuntu 19.10**
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
Open the `ads.pro` with QtCreator and start the build, that's it.
|
Open the `ads.pro` with QtCreator and start the build, that's it.
|
||||||
You can run the demo project and test it yourself.
|
You can run the demo project and test it yourself.
|
||||||
|
|
||||||
|
## Getting started / Example
|
||||||
|
The following example shows the minimum code required to use the advanced Qt docking system.
|
||||||
|
|
||||||
|
*MainWindow.h*
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "DockManager.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
|
// The main container for docking
|
||||||
|
ads::CDockManager* m_DockManager;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
*MainWindow.cpp*
|
||||||
|
```cpp
|
||||||
|
#include "MainWindow.h"
|
||||||
|
#include "ui_MainWindow.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
QMainWindow(parent),
|
||||||
|
ui(new Ui::MainWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// Create the dock manager. Because the parent parameter is a QMainWindow
|
||||||
|
// the dock manager registers itself as the central widget.
|
||||||
|
m_DockManager = new ads::CDockManager(this);
|
||||||
|
|
||||||
|
// Create example content label - this can be any application specific
|
||||||
|
// widget
|
||||||
|
QLabel* l = new QLabel();
|
||||||
|
l->setWordWrap(true);
|
||||||
|
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||||
|
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
DockWidget->setWidget(l);
|
||||||
|
|
||||||
|
// Add the toggleViewAction of the dock widget to the menu to give
|
||||||
|
// the user the possibility to show the dock widget if it has been closed
|
||||||
|
ui->menuView->addAction(DockWidget->toggleViewAction());
|
||||||
|
|
||||||
|
// Add the dock widget to the top dock widget area
|
||||||
|
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Developers
|
## Developers
|
||||||
- Uwe Kindler, Project Maintainer
|
- Uwe Kindler, Project Maintainer
|
||||||
- Manuel Freiholz
|
- Manuel Freiholz
|
||||||
|
|
||||||
## License information
|
## License information
|
||||||
|
[](gnu-lgpl-v2.1.md)
|
||||||
This project uses the [LGPLv2.1 license](gnu-lgpl-v2.1.md)
|
This project uses the [LGPLv2.1 license](gnu-lgpl-v2.1.md)
|
||||||
|
|
||||||
|
## Alternative Docking System Implementations
|
||||||
|
If this Qt Advanced Docking System does not fit to your needs you may consider some of the alternative docking system solutions for Qt.
|
||||||
|
|
||||||
|
### KDDockWidgets
|
||||||
|
This is an advanced docking framework for Qt from [KDAB](https://www.kdab.com/). The interesting thing is, that they separated GUI code from logic, so they can easily provide a QtQuick backend in the future.
|
||||||
|
|
||||||
|
- [Blog post about KDDockWidgets](https://www.kdab.com/kddockwidgets/)
|
||||||
|
- [GitHub project](https://github.com/KDAB/KDDockWidgets)
|
||||||
|
|
||||||
|
|
||||||
|
### QtitanDocking
|
||||||
|
This is a commercial component from [Developer Machines](https://www.devmachines.com/) for Qt Framework that allows to create a Microsoft like dockable user interface. They also offer a lot of other interesting and useful components for Qt.
|
||||||
|
|
||||||
|
- [Product page](https://www.devmachines.com/qtitandocking-overview.html)
|
||||||
|
|||||||
7
ads.pro
@@ -1,6 +1,9 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
CONFIG += ordered
|
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
src \
|
src \
|
||||||
demo
|
demo \
|
||||||
|
example
|
||||||
|
|
||||||
|
demo.depends = src
|
||||||
|
example.depends = src
|
||||||
|
|||||||
5
adsConfig.cmake
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_dependency(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake")
|
||||||
316
demo.py
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
import datetime
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from PyQt5.QtCore import (QCoreApplication, QDir, Qt, QSettings, QSignalBlocker,
|
||||||
|
QRect)
|
||||||
|
from PyQt5.QtGui import QGuiApplication
|
||||||
|
from PyQt5.QtWidgets import (QCalendarWidget, QFileSystemModel, QFrame, QLabel,
|
||||||
|
QMenu, QTreeView, QAction, QWidgetAction,
|
||||||
|
QComboBox, QStyle, QSizePolicy, QInputDialog)
|
||||||
|
|
||||||
|
from PyQt5 import QtWidgets
|
||||||
|
|
||||||
|
from PyQtAds import QtAds
|
||||||
|
|
||||||
|
|
||||||
|
class _State:
|
||||||
|
label_count = 0
|
||||||
|
calendar_count = 0
|
||||||
|
file_system_count = 0
|
||||||
|
|
||||||
|
|
||||||
|
def create_long_text_label_dock_widget(view_menu: QMenu) -> QtAds.CDockWidget:
|
||||||
|
'''
|
||||||
|
Create long text label dock widget
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
view_menu : QMenu
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
value : QtAds.CDockWidget
|
||||||
|
'''
|
||||||
|
label = QLabel()
|
||||||
|
label.setWordWrap(True)
|
||||||
|
label.setAlignment(Qt.AlignTop | Qt.AlignLeft)
|
||||||
|
label.setText('''\
|
||||||
|
Label {} {} - Lorem ipsum dolor sit amet, consectetuer
|
||||||
|
adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum
|
||||||
|
sociis natoque penatibus et magnis dis parturient montes, nascetur
|
||||||
|
ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium
|
||||||
|
quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla
|
||||||
|
vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
|
||||||
|
imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis
|
||||||
|
pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi.
|
||||||
|
Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu,
|
||||||
|
consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra
|
||||||
|
quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet.
|
||||||
|
'''.format(_State.label_count, str(datetime.datetime.now())))
|
||||||
|
_State.label_count += 1
|
||||||
|
|
||||||
|
dock_widget = QtAds.CDockWidget("Label {}".format(_State.label_count))
|
||||||
|
dock_widget.setWidget(label)
|
||||||
|
|
||||||
|
view_menu.addAction(dock_widget.toggleViewAction())
|
||||||
|
return dock_widget
|
||||||
|
|
||||||
|
|
||||||
|
def create_calendar_dock_widget(view_menu: QMenu) -> QtAds.CDockWidget:
|
||||||
|
'''
|
||||||
|
Create calendar dock widget
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
view_menu : QMenu
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
value : QtAds.CDockWidget
|
||||||
|
'''
|
||||||
|
widget = QCalendarWidget()
|
||||||
|
|
||||||
|
dock_widget = QtAds.CDockWidget("Calendar {}".format(_State.calendar_count))
|
||||||
|
_State.calendar_count += 1
|
||||||
|
dock_widget.setWidget(widget)
|
||||||
|
dock_widget.setToggleViewActionMode(QtAds.CDockWidget.ActionModeShow)
|
||||||
|
view_menu.addAction(dock_widget.toggleViewAction())
|
||||||
|
return dock_widget
|
||||||
|
|
||||||
|
|
||||||
|
def create_file_system_tree_dock_widget(view_menu: QMenu) -> QtAds.CDockWidget:
|
||||||
|
'''
|
||||||
|
Create file system tree dock widget
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
view_menu : QMenu
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
value : QtAds.CDockWidget
|
||||||
|
'''
|
||||||
|
widget = QTreeView()
|
||||||
|
widget.setFrameShape(QFrame.NoFrame)
|
||||||
|
|
||||||
|
m = QFileSystemModel(widget)
|
||||||
|
m.setRootPath(QDir.currentPath())
|
||||||
|
widget.setModel(m)
|
||||||
|
|
||||||
|
dock_widget = QtAds.CDockWidget("Filesystem {}".format(_State.file_system_count))
|
||||||
|
_State.file_system_count += 1
|
||||||
|
dock_widget.setWidget(widget)
|
||||||
|
view_menu.addAction(dock_widget.toggleViewAction())
|
||||||
|
return dock_widget
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
|
save_perspective_action: QAction
|
||||||
|
perspective_list_action: QWidgetAction
|
||||||
|
perspective_combo_box: QComboBox
|
||||||
|
dock_manager: QtAds.CDockManager
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.save_perspective_action = None
|
||||||
|
self.perspective_list_action = None
|
||||||
|
self.perspective_combo_box = None
|
||||||
|
self.dock_manager = None
|
||||||
|
|
||||||
|
self.setup_ui()
|
||||||
|
|
||||||
|
self.dock_manager = QtAds.CDockManager(self)
|
||||||
|
self.perspective_combo_box.activated[str].connect(self.dock_manager.openPerspective)
|
||||||
|
self.create_content()
|
||||||
|
self.resize(800, 600)
|
||||||
|
self.restore_state()
|
||||||
|
self.restore_perspectives()
|
||||||
|
|
||||||
|
def setup_ui(self):
|
||||||
|
self.setObjectName("MainWindow")
|
||||||
|
self.resize(400, 300)
|
||||||
|
self.setDockOptions(QtWidgets.QMainWindow.AllowTabbedDocks)
|
||||||
|
self.centralWidget = QtWidgets.QWidget(self)
|
||||||
|
self.centralWidget.setObjectName("centralWidget")
|
||||||
|
self.setCentralWidget(self.centralWidget)
|
||||||
|
self.status_bar = QtWidgets.QStatusBar(self)
|
||||||
|
self.status_bar.setObjectName("statusBar")
|
||||||
|
self.setStatusBar(self.status_bar)
|
||||||
|
self.menu_bar = QtWidgets.QMenuBar(self)
|
||||||
|
self.menu_bar.setGeometry(QRect(0, 0, 400, 21))
|
||||||
|
self.menu_bar.setObjectName("menuBar")
|
||||||
|
self.menu_file = QtWidgets.QMenu(self.menu_bar)
|
||||||
|
self.menu_file.setObjectName("menuFile")
|
||||||
|
self.menu_view = QtWidgets.QMenu(self.menu_bar)
|
||||||
|
self.menu_view.setObjectName("menuView")
|
||||||
|
self.menu_about = QtWidgets.QMenu(self.menu_bar)
|
||||||
|
self.menu_about.setObjectName("menuAbout")
|
||||||
|
self.setMenuBar(self.menu_bar)
|
||||||
|
self.tool_bar = QtWidgets.QToolBar(self)
|
||||||
|
self.tool_bar.setObjectName("toolBar")
|
||||||
|
self.addToolBar(Qt.TopToolBarArea, self.tool_bar)
|
||||||
|
self.action_exit = QtWidgets.QAction(self)
|
||||||
|
self.action_exit.setObjectName("actionExit")
|
||||||
|
self.action_save_state = QtWidgets.QAction(self)
|
||||||
|
self.action_save_state.setObjectName("actionSaveState")
|
||||||
|
self.action_save_state.triggered.connect(self.saveState)
|
||||||
|
|
||||||
|
self.action_restore_state = QtWidgets.QAction(self)
|
||||||
|
self.action_restore_state.setObjectName("actionRestoreState")
|
||||||
|
self.action_restore_state.triggered.connect(self.restore_state)
|
||||||
|
|
||||||
|
self.menu_file.addAction(self.action_exit)
|
||||||
|
self.menu_file.addAction(self.action_save_state)
|
||||||
|
self.menu_file.addAction(self.action_restore_state)
|
||||||
|
self.menu_bar.addAction(self.menu_file.menuAction())
|
||||||
|
self.menu_bar.addAction(self.menu_view.menuAction())
|
||||||
|
self.menu_bar.addAction(self.menu_about.menuAction())
|
||||||
|
|
||||||
|
self.setWindowTitle("MainWindow")
|
||||||
|
self.menu_file.setTitle("File")
|
||||||
|
self.menu_view.setTitle("View")
|
||||||
|
self.menu_about.setTitle("About")
|
||||||
|
self.tool_bar.setWindowTitle("toolBar")
|
||||||
|
self.action_exit.setText("Exit")
|
||||||
|
self.action_save_state.setText("Save State")
|
||||||
|
self.action_restore_state.setText("Restore State")
|
||||||
|
self.create_actions()
|
||||||
|
|
||||||
|
def create_actions(self):
|
||||||
|
'''
|
||||||
|
Creates the toolbar actions
|
||||||
|
'''
|
||||||
|
self.tool_bar.addAction(self.action_save_state)
|
||||||
|
self.action_save_state.setIcon(self.style().standardIcon(QStyle.SP_DialogSaveButton))
|
||||||
|
self.tool_bar.addAction(self.action_restore_state)
|
||||||
|
self.action_restore_state.setIcon(self.style().standardIcon(QStyle.SP_DialogOpenButton))
|
||||||
|
self.save_perspective_action = QAction("Save Perspective", self)
|
||||||
|
self.save_perspective_action.triggered.connect(self.save_perspective)
|
||||||
|
|
||||||
|
self.perspective_list_action = QWidgetAction(self)
|
||||||
|
self.perspective_combo_box = QComboBox(self)
|
||||||
|
self.perspective_combo_box.setSizeAdjustPolicy(QComboBox.AdjustToContents)
|
||||||
|
self.perspective_combo_box.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||||
|
self.perspective_list_action.setDefaultWidget(self.perspective_combo_box)
|
||||||
|
self.tool_bar.addSeparator()
|
||||||
|
self.tool_bar.addAction(self.perspective_list_action)
|
||||||
|
self.tool_bar.addAction(self.save_perspective_action)
|
||||||
|
|
||||||
|
def create_content(self):
|
||||||
|
'''
|
||||||
|
Fill the dock manager with dock widgets
|
||||||
|
'''
|
||||||
|
# Test container docking
|
||||||
|
view_menu = self.menu_view
|
||||||
|
dock_widget = create_calendar_dock_widget(view_menu)
|
||||||
|
dock_widget.setIcon(self.style().standardIcon(QStyle.SP_DialogOpenButton))
|
||||||
|
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetClosable, False)
|
||||||
|
self.dock_manager.addDockWidget(QtAds.LeftDockWidgetArea, dock_widget)
|
||||||
|
self.dock_manager.addDockWidget(QtAds.LeftDockWidgetArea, create_long_text_label_dock_widget(view_menu))
|
||||||
|
file_system_widget = create_file_system_tree_dock_widget(view_menu)
|
||||||
|
tool_bar = file_system_widget.createDefaultToolBar()
|
||||||
|
tool_bar.addAction(self.action_save_state)
|
||||||
|
tool_bar.addAction(self.action_restore_state)
|
||||||
|
self.dock_manager.addDockWidget(QtAds.BottomDockWidgetArea, file_system_widget)
|
||||||
|
file_system_widget = create_file_system_tree_dock_widget(view_menu)
|
||||||
|
tool_bar = file_system_widget.createDefaultToolBar()
|
||||||
|
tool_bar.addAction(self.action_save_state)
|
||||||
|
tool_bar.addAction(self.action_restore_state)
|
||||||
|
file_system_widget.setFeature(QtAds.CDockWidget.DockWidgetMovable, False)
|
||||||
|
top_dock_area = self.dock_manager.addDockWidget(QtAds.TopDockWidgetArea, file_system_widget)
|
||||||
|
dock_widget = create_calendar_dock_widget(view_menu)
|
||||||
|
dock_widget.setFeature(QtAds.CDockWidget.DockWidgetClosable, False)
|
||||||
|
dock_widget.setTabToolTip("Tab ToolTip\nHodie est dies magna")
|
||||||
|
self.dock_manager.addDockWidget(QtAds.CenterDockWidgetArea, dock_widget, top_dock_area)
|
||||||
|
|
||||||
|
# Test dock area docking
|
||||||
|
right_dock_area = self.dock_manager.addDockWidget(
|
||||||
|
QtAds.RightDockWidgetArea,
|
||||||
|
create_long_text_label_dock_widget(view_menu), top_dock_area)
|
||||||
|
self.dock_manager.addDockWidget(
|
||||||
|
QtAds.TopDockWidgetArea,
|
||||||
|
create_long_text_label_dock_widget(view_menu), right_dock_area)
|
||||||
|
|
||||||
|
bottom_dock_area = self.dock_manager.addDockWidget(
|
||||||
|
QtAds.BottomDockWidgetArea,
|
||||||
|
create_long_text_label_dock_widget(view_menu), right_dock_area)
|
||||||
|
|
||||||
|
self.dock_manager.addDockWidget(
|
||||||
|
QtAds.RightDockWidgetArea,
|
||||||
|
create_long_text_label_dock_widget(view_menu), right_dock_area)
|
||||||
|
self.dock_manager.addDockWidget(
|
||||||
|
QtAds.CenterDockWidgetArea,
|
||||||
|
create_long_text_label_dock_widget(view_menu), bottom_dock_area)
|
||||||
|
|
||||||
|
def save_state(self):
|
||||||
|
'''
|
||||||
|
Saves the dock manager state and the main window geometry
|
||||||
|
'''
|
||||||
|
settings = QSettings("Settings.ini", QSettings.IniFormat)
|
||||||
|
settings.setValue("mainWindow/Geometry", self.saveGeometry())
|
||||||
|
settings.setValue("mainWindow/State", self.saveState())
|
||||||
|
settings.setValue("mainWindow/DockingState", self.dock_manager.saveState())
|
||||||
|
|
||||||
|
def save_perspectives(self):
|
||||||
|
'''
|
||||||
|
Save the list of perspectives
|
||||||
|
'''
|
||||||
|
settings = QSettings("Settings.ini", QSettings.IniFormat)
|
||||||
|
self.dock_manager.savePerspectives(settings)
|
||||||
|
|
||||||
|
def restore_state(self):
|
||||||
|
'''
|
||||||
|
Restores the dock manager state
|
||||||
|
'''
|
||||||
|
settings = QSettings("Settings.ini", QSettings.IniFormat)
|
||||||
|
geom = settings.value("mainWindow/Geometry")
|
||||||
|
if geom is not None:
|
||||||
|
self.restoreGeometry(geom)
|
||||||
|
|
||||||
|
state = settings.value("mainWindow/State")
|
||||||
|
if state is not None:
|
||||||
|
self.restoreState(state)
|
||||||
|
|
||||||
|
state = settings.value("mainWindow/DockingState")
|
||||||
|
if state is not None:
|
||||||
|
self.dock_manager.restore_state(state)
|
||||||
|
|
||||||
|
def restore_perspectives(self):
|
||||||
|
'''
|
||||||
|
Restore the perspective listo of the dock manager
|
||||||
|
'''
|
||||||
|
settings = QSettings("Settings.ini", QSettings.IniFormat)
|
||||||
|
self.dock_manager.loadPerspectives(settings)
|
||||||
|
self.perspective_combo_box.clear()
|
||||||
|
self.perspective_combo_box.addItems(self.dock_manager.perspectiveNames())
|
||||||
|
|
||||||
|
def save_perspective(self):
|
||||||
|
perspective_name, ok = QInputDialog.getText(self, 'Save perspective', 'Enter unique name:')
|
||||||
|
if ok and perspective_name:
|
||||||
|
self.dock_manager.addPerspective(perspective_name)
|
||||||
|
_ = QSignalBlocker(self.perspective_combo_box)
|
||||||
|
self.perspective_combo_box.clear()
|
||||||
|
self.perspective_combo_box.addItems(self.dock_manager.perspectiveNames())
|
||||||
|
self.perspective_combo_box.setCurrentText(perspective_name)
|
||||||
|
self.save_perspectives()
|
||||||
|
|
||||||
|
|
||||||
|
def main(app_):
|
||||||
|
main_window = MainWindow()
|
||||||
|
main_window.show()
|
||||||
|
state = main_window.dock_manager.saveState()
|
||||||
|
# print('This is what the saved state looks like in XML:')
|
||||||
|
# print(str(state, 'utf-8'))
|
||||||
|
# print()
|
||||||
|
# main_window.dock_manager.restore_state(state)
|
||||||
|
return main_window
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# logging.basicConfig(level='DEBUG')
|
||||||
|
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
||||||
|
QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
||||||
|
app = QtWidgets.QApplication([])
|
||||||
|
window = main(app)
|
||||||
|
window.show()
|
||||||
|
app.exec_()
|
||||||
48
demo/CMakeLists.txt
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.3)
|
||||||
|
set (CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
project(ads_demo VERSION "1.0")
|
||||||
|
set(REQUIRED_QT_VERSION 5.5.0)
|
||||||
|
find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Core_LIBRARIES})
|
||||||
|
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Core_INCLUDE_DIRS})
|
||||||
|
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Core_COMPILE_DEFINITIONS} )
|
||||||
|
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Gui_LIBRARIES})
|
||||||
|
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Gui_INCLUDE_DIRS})
|
||||||
|
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Gui_COMPILE_DEFINITIONS})
|
||||||
|
set(ads_demo_LIBS ${ads_demo_LIBS} ${Qt5Widgets_LIBRARIES})
|
||||||
|
set(ads_demo_INCLUDE ${ads_demo_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS})
|
||||||
|
set(ads_demo_COMPILE_DEFINE ${ads_demo_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
set(ads_demo_SRCS
|
||||||
|
main.cpp
|
||||||
|
MainWindow.cpp
|
||||||
|
mainwindow.ui
|
||||||
|
demo.qrc
|
||||||
|
)
|
||||||
|
add_executable(AdvancedDockingSystemDemo WIN32 ${ads_demo_SRCS})
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
set(ads_demo_DEFINE ${ads_demo_DEFINE} ADS_STATIC)
|
||||||
|
endif()
|
||||||
|
add_dependencies(AdvancedDockingSystemDemo qtadvanceddocking)
|
||||||
|
target_include_directories(AdvancedDockingSystemDemo PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${ads_demo_INCLUDE}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
target_include_directories(AdvancedDockingSystemDemo PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../src" ${ads_demo_INCLUDE})
|
||||||
|
target_link_libraries(AdvancedDockingSystemDemo PRIVATE qtadvanceddocking ${ads_demo_LIBS})
|
||||||
|
target_compile_definitions(AdvancedDockingSystemDemo PRIVATE ${ads_demo_DEFINE})
|
||||||
|
set_target_properties(AdvancedDockingSystemDemo PROPERTIES
|
||||||
|
VERSION "1.0"
|
||||||
|
SOVERSION 1
|
||||||
|
EXPORT_NAME "Qt Advanced Docking System Demo"
|
||||||
|
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"
|
||||||
|
)
|
||||||
@@ -50,6 +50,9 @@
|
|||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QRubberBand>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QTableWidget>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
@@ -57,7 +60,7 @@
|
|||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
#include "AnimatedLabel.h"
|
#include "FloatingDockContainer.h"
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@@ -89,6 +92,44 @@ static ads::CDockWidget* createLongTextLabelDockWidget(QMenu* ViewMenu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function returns a features string with closable (c), movable (m) and floatable (f)
|
||||||
|
* features. i.e. The following string is for a not closable but movable and floatable
|
||||||
|
* widget: c- m+ f+
|
||||||
|
*/
|
||||||
|
static QString featuresString(ads::CDockWidget* DockWidget)
|
||||||
|
{
|
||||||
|
auto f = DockWidget->features();
|
||||||
|
return QString("c%1 m%2 f%3")
|
||||||
|
.arg(f.testFlag(ads::CDockWidget::DockWidgetClosable) ? "+" : "-")
|
||||||
|
.arg(f.testFlag(ads::CDockWidget::DockWidgetMovable) ? "+" : "-")
|
||||||
|
.arg(f.testFlag(ads::CDockWidget::DockWidgetFloatable) ? "+" : "-");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the string returned by featuresString() to the window title of
|
||||||
|
* the given DockWidget
|
||||||
|
*/
|
||||||
|
static void appendFeaturStringToWindowTitle(ads::CDockWidget* DockWidget)
|
||||||
|
{
|
||||||
|
DockWidget->setWindowTitle(DockWidget->windowTitle()
|
||||||
|
+ QString(" (%1)").arg(featuresString(DockWidget)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to create an SVG icon
|
||||||
|
*/
|
||||||
|
static QIcon svgIcon(const QString& File)
|
||||||
|
{
|
||||||
|
// This is a workaround, because because in item views SVG icons are not
|
||||||
|
// properly scaled an look blurry or pixelate
|
||||||
|
QIcon SvgIcon(File);
|
||||||
|
SvgIcon.addPixmap(SvgIcon.pixmap(92));
|
||||||
|
return SvgIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
|
static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
|
||||||
{
|
{
|
||||||
@@ -97,6 +138,7 @@ static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
|
|||||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Calendar %1").arg(CalendarCount++));
|
||||||
DockWidget->setWidget(w);
|
DockWidget->setWidget(w);
|
||||||
DockWidget->setToggleViewActionMode(ads::CDockWidget::ActionModeShow);
|
DockWidget->setToggleViewActionMode(ads::CDockWidget::ActionModeShow);
|
||||||
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/date_range.svg"));
|
||||||
ViewMenu->addAction(DockWidget->toggleViewAction());
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
||||||
return DockWidget;
|
return DockWidget;
|
||||||
}
|
}
|
||||||
@@ -111,12 +153,52 @@ static ads::CDockWidget* createFileSystemTreeDockWidget(QMenu* ViewMenu)
|
|||||||
QFileSystemModel* m = new QFileSystemModel(w);
|
QFileSystemModel* m = new QFileSystemModel(w);
|
||||||
m->setRootPath(QDir::currentPath());
|
m->setRootPath(QDir::currentPath());
|
||||||
w->setModel(m);
|
w->setModel(m);
|
||||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1").arg(FileSystemCount++));
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1")
|
||||||
|
.arg(FileSystemCount++));
|
||||||
DockWidget->setWidget(w);
|
DockWidget->setWidget(w);
|
||||||
ViewMenu->addAction(DockWidget->toggleViewAction());
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
||||||
return DockWidget;
|
return DockWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
static ads::CDockWidget* createEditorWidget(QMenu* ViewMenu)
|
||||||
|
{
|
||||||
|
static int EditorCount = 0;
|
||||||
|
QPlainTextEdit* w = new QPlainTextEdit();
|
||||||
|
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++));
|
||||||
|
DockWidget->setWidget(w);
|
||||||
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/edit.svg"));
|
||||||
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
||||||
|
return DockWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
static ads::CDockWidget* createTableWidget(QMenu* ViewMenu)
|
||||||
|
{
|
||||||
|
static int TableCount = 0;
|
||||||
|
QTableWidget* w = new QTableWidget();
|
||||||
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Table %1").arg(TableCount++));
|
||||||
|
static int colCount = 5;
|
||||||
|
static int rowCount = 30;
|
||||||
|
w->setColumnCount(colCount);
|
||||||
|
w->setRowCount(rowCount);
|
||||||
|
for (int col = 0; col < colCount; ++col)
|
||||||
|
{
|
||||||
|
w->setHorizontalHeaderItem(col, new QTableWidgetItem(QString("Col %1").arg(col+1)));
|
||||||
|
for (int row = 0; row < rowCount; ++row)
|
||||||
|
{
|
||||||
|
w->setItem(row, col, new QTableWidgetItem(QString("T %1-%2").arg(row + 1).arg(col+1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DockWidget->setWidget(w);
|
||||||
|
DockWidget->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
||||||
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
||||||
|
return DockWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/**
|
/**
|
||||||
@@ -128,7 +210,7 @@ struct MainWindowPrivate
|
|||||||
Ui::MainWindow ui;
|
Ui::MainWindow ui;
|
||||||
QAction* SavePerspectiveAction = nullptr;
|
QAction* SavePerspectiveAction = nullptr;
|
||||||
QWidgetAction* PerspectiveListAction = nullptr;
|
QWidgetAction* PerspectiveListAction = nullptr;
|
||||||
QComboBox* PerspectiveComboBox = nullptr;;
|
QComboBox* PerspectiveComboBox = nullptr;
|
||||||
ads::CDockManager* DockManager = nullptr;
|
ads::CDockManager* DockManager = nullptr;
|
||||||
|
|
||||||
MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
|
MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
|
||||||
@@ -171,7 +253,6 @@ void MainWindowPrivate::createContent()
|
|||||||
// Test container docking
|
// Test container docking
|
||||||
QMenu* ViewMenu = ui.menuView;
|
QMenu* ViewMenu = ui.menuView;
|
||||||
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
auto DockWidget = createCalendarDockWidget(ViewMenu);
|
||||||
DockWidget->setIcon(_this->style()->standardIcon(QStyle::SP_DialogOpenButton));
|
|
||||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
||||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget);
|
||||||
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu));
|
||||||
@@ -186,9 +267,12 @@ void MainWindowPrivate::createContent()
|
|||||||
ToolBar->addAction(ui.actionSaveState);
|
ToolBar->addAction(ui.actionSaveState);
|
||||||
ToolBar->addAction(ui.actionRestoreState);
|
ToolBar->addAction(ui.actionRestoreState);
|
||||||
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
|
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
|
||||||
|
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
||||||
|
appendFeaturStringToWindowTitle(FileSystemWidget);
|
||||||
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
||||||
DockWidget = createCalendarDockWidget(ViewMenu);
|
DockWidget = createCalendarDockWidget(ViewMenu);
|
||||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
||||||
|
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
|
||||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
||||||
|
|
||||||
// Test dock area docking
|
// Test dock area docking
|
||||||
@@ -197,6 +281,14 @@ void MainWindowPrivate::createContent()
|
|||||||
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||||
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||||
|
|
||||||
|
auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle()));
|
||||||
|
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
|
||||||
|
|
||||||
|
for (auto DockWidget : DockManager->dockWidgetsMap())
|
||||||
|
{
|
||||||
|
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -204,11 +296,13 @@ void MainWindowPrivate::createContent()
|
|||||||
void MainWindowPrivate::createActions()
|
void MainWindowPrivate::createActions()
|
||||||
{
|
{
|
||||||
ui.toolBar->addAction(ui.actionSaveState);
|
ui.toolBar->addAction(ui.actionSaveState);
|
||||||
ui.actionSaveState->setIcon(_this->style()->standardIcon(QStyle::SP_DialogSaveButton));
|
ui.toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||||
|
ui.actionSaveState->setIcon(svgIcon(":/adsdemo/images/save.svg"));
|
||||||
ui.toolBar->addAction(ui.actionRestoreState);
|
ui.toolBar->addAction(ui.actionRestoreState);
|
||||||
ui.actionRestoreState->setIcon(_this->style()->standardIcon(QStyle::SP_DialogOpenButton));
|
ui.actionRestoreState->setIcon(svgIcon(":/adsdemo/images/restore.svg"));
|
||||||
|
|
||||||
SavePerspectiveAction = new QAction("Save Perspective", _this);
|
SavePerspectiveAction = new QAction("Create Perspective", _this);
|
||||||
|
SavePerspectiveAction->setIcon(svgIcon(":/adsdemo/images/picture_in_picture.svg"));
|
||||||
_this->connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
|
_this->connect(SavePerspectiveAction, SIGNAL(triggered()), SLOT(savePerspective()));
|
||||||
PerspectiveListAction = new QWidgetAction(_this);
|
PerspectiveListAction = new QWidgetAction(_this);
|
||||||
PerspectiveComboBox = new QComboBox(_this);
|
PerspectiveComboBox = new QComboBox(_this);
|
||||||
@@ -218,6 +312,16 @@ void MainWindowPrivate::createActions()
|
|||||||
ui.toolBar->addSeparator();
|
ui.toolBar->addSeparator();
|
||||||
ui.toolBar->addAction(PerspectiveListAction);
|
ui.toolBar->addAction(PerspectiveListAction);
|
||||||
ui.toolBar->addAction(SavePerspectiveAction);
|
ui.toolBar->addAction(SavePerspectiveAction);
|
||||||
|
|
||||||
|
QAction* a = ui.toolBar->addAction("Create Editor");
|
||||||
|
a->setToolTip("Creates floating dynamic dockable editor windows that are deleted on close");
|
||||||
|
a->setIcon(svgIcon(":/adsdemo/images/note_add.svg"));
|
||||||
|
_this->connect(a, SIGNAL(triggered()), SLOT(createEditor()));
|
||||||
|
|
||||||
|
a = ui.toolBar->addAction("Create Table");
|
||||||
|
a->setToolTip("Creates floating dynamic dockable table with millions of entries");
|
||||||
|
a->setIcon(svgIcon(":/adsdemo/images/grid_on.svg"));
|
||||||
|
_this->connect(a, SIGNAL(triggered()), SLOT(createTable()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -270,21 +374,33 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
|||||||
d->ui.setupUi(this);
|
d->ui.setupUi(this);
|
||||||
d->createActions();
|
d->createActions();
|
||||||
|
|
||||||
|
// uncomment the following line if the tab close button should be
|
||||||
|
// a QToolButton instead of a QPushButton
|
||||||
|
// CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton);
|
||||||
|
|
||||||
|
// uncomment the following line if you want a fixed tab width that does
|
||||||
|
// not change if the visibility of the close button changes
|
||||||
|
// CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true);
|
||||||
|
|
||||||
|
// uncomment the follwing line if you want to use non opaque undocking and splitter
|
||||||
|
// movements
|
||||||
|
// CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
|
||||||
|
|
||||||
// Now create the dock manager and its content
|
// Now create the dock manager and its content
|
||||||
d->DockManager = new CDockManager(this);
|
d->DockManager = new CDockManager(this);
|
||||||
|
|
||||||
// Uncomment the following line to have the old style where the dock
|
// Uncomment the following line to have the old style where the dock
|
||||||
// area close button closes the active tab
|
// area close button closes the active tab
|
||||||
//d->DockManager->setConfigFlags({
|
// CDockManager::setConfigFlags({CDockManager::DockAreaHasCloseButton
|
||||||
// CDockManager::DockAreaHasCloseButton | CDockManager::DockAreaCloseButtonClosesTab});
|
// | CDockManager::DockAreaCloseButtonClosesTab});
|
||||||
connect(d->PerspectiveComboBox, SIGNAL(activated(const QString&)),
|
connect(d->PerspectiveComboBox, SIGNAL(activated(const QString&)),
|
||||||
d->DockManager, SLOT(openPerspective(const QString&)));
|
d->DockManager, SLOT(openPerspective(const QString&)));
|
||||||
|
|
||||||
d->createContent();
|
d->createContent();
|
||||||
// Default window geometry
|
// Default window geometry
|
||||||
resize(800, 600);
|
resize(1280, 720);
|
||||||
|
|
||||||
d->restoreState();
|
//d->restoreState();
|
||||||
d->restorePerspectives();
|
d->restorePerspectives();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,3 +454,36 @@ void CMainWindow::savePerspective()
|
|||||||
d->savePerspectives();
|
d->savePerspectives();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::onViewToggled(bool Open)
|
||||||
|
{
|
||||||
|
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
|
||||||
|
if (!DockWidget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::createEditor()
|
||||||
|
{
|
||||||
|
auto DockWidget = createEditorWidget(d->ui.menuView);
|
||||||
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
|
||||||
|
auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget);
|
||||||
|
FloatingWidget->move(QPoint(20, 20));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CMainWindow::createTable()
|
||||||
|
{
|
||||||
|
auto DockWidget = createTableWidget(d->ui.menuView);
|
||||||
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
|
||||||
|
auto FloatingWidget = d->DockManager->addDockWidgetFloating(DockWidget);
|
||||||
|
FloatingWidget->move(QPoint(40, 40));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ private slots:
|
|||||||
void on_actionSaveState_triggered(bool);
|
void on_actionSaveState_triggered(bool);
|
||||||
void on_actionRestoreState_triggered(bool);
|
void on_actionRestoreState_triggered(bool);
|
||||||
void savePerspective();
|
void savePerspective();
|
||||||
|
void onViewToggled(bool Open);
|
||||||
|
void createEditor();
|
||||||
|
void createTable();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
@@ -1,31 +1,46 @@
|
|||||||
ADS_ROOT = $${PWD}/..
|
|
||||||
ADS_OUT_ROOT = $${OUT_PWD}/..
|
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||||
|
|
||||||
TARGET = AdvancedDockingSystemDemo
|
TARGET = AdvancedDockingSystemDemo
|
||||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||||
QT += core gui widgets
|
QT += core gui widgets
|
||||||
CONFIG *= c++14
|
CONFIG += c++14
|
||||||
|
CONFIG += debug_and_release
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
adsBuildStatic {
|
||||||
|
DEFINES += ADS_STATIC
|
||||||
|
}
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
MainWindow.h
|
MainWindow.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
RESOURCES += main.qrc
|
RESOURCES += demo.qrc
|
||||||
|
|
||||||
|
|
||||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||||
|
|
||||||
# Dependency: AdvancedDockingSystem (shared)
|
# Dependency: AdvancedDockingSystem (shared)
|
||||||
win32:CONFIG(release, debug|release): LIBS += -lqtadvanceddocking
|
CONFIG(debug, debug|release){
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -lqtadvanceddockingd
|
win32 {
|
||||||
else:unix: LIBS += -lAdvancedDockingSystem
|
LIBS += -lqtadvanceddockingd
|
||||||
|
}
|
||||||
|
else:mac {
|
||||||
|
LIBS += -lqtadvanceddocking_debug
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LIBS += -lqtadvanceddocking
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
LIBS += -lqtadvanceddocking
|
||||||
|
}
|
||||||
|
|
||||||
INCLUDEPATH += ../src
|
INCLUDEPATH += ../src
|
||||||
DEPENDPATH += ../src
|
DEPENDPATH += ../src
|
||||||
|
|||||||
13
demo/demo.qrc
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/adsdemo">
|
||||||
|
<file>images/folder.svg</file>
|
||||||
|
<file>images/folder_open.svg</file>
|
||||||
|
<file>images/note_add.svg</file>
|
||||||
|
<file>images/picture_in_picture.svg</file>
|
||||||
|
<file>images/restore.svg</file>
|
||||||
|
<file>images/save.svg</file>
|
||||||
|
<file>images/date_range.svg</file>
|
||||||
|
<file>images/edit.svg</file>
|
||||||
|
<file>images/grid_on.svg</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
6
demo/images/date_range.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>date_range icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M896,256v597.33c0,46.93 -38.4,85.34 -85.33,85.34h-597.34c-47.36,0 -85.33,-38.41 -85.33,-85.34l0.43,-597.33c0,-46.93 37.54,-85.33 84.9,-85.33h42.67v-85.34h85.33v85.34h341.34v-85.34h85.33v85.34h42.67c46.93,0 85.33,38.4 85.33,85.33zM810.67,384h-597.34v469.33h597.34zM384,554.67h-85.33v-85.34h85.33zM554.67,554.67h-85.34v-85.34h85.34zM725.33,554.67h-85.33v-85.34h85.33z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 783 B |
6
demo/images/edit.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>create icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M599.89,264.11l160,160l-471.89,471.89h-160v-160zM805.55,378.45l-160,-160l78.08,-78.08c16.64,-16.64 43.52,-16.64 60.16,0l99.84,99.84c16.64,16.64 16.64,43.52 0,60.16z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 578 B |
6
demo/images/folder.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>folder icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M512,256h341.33c46.93,0 85.34,38.4 85.34,85.33v426.67c0,46.93 -38.41,85.33 -85.34,85.33h-682.66c-46.93,0 -85.34,-38.4 -85.34,-85.33l0.43,-512c0,-46.93 37.98,-85.33 84.91,-85.33h256z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 595 B |
6
demo/images/folder_open.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>folder_open icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M938.67,341.33v426.67c0,46.93 -38.41,85.33 -85.34,85.33h-682.66c-46.93,0 -85.34,-38.4 -85.34,-85.33l0.43,-512c0,-46.93 37.98,-85.33 84.91,-85.33h256l85.33,85.33h341.33c46.93,0 85.34,38.4 85.34,85.33zM853.33,341.33h-682.66v426.67h682.66z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 655 B |
6
demo/images/grid_on.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>grid_on icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M938.67,170.67v682.66c0,46.93 -38.41,85.34 -85.34,85.34h-682.66c-46.93,0 -85.34,-38.41 -85.34,-85.34v-682.66c0,-46.93 38.41,-85.34 85.34,-85.34h682.66c46.93,0 85.34,38.41 85.34,85.34zM341.33,170.67h-170.66v170.66h170.66zM341.33,682.67h-170.66v170.66h170.66zM341.33,426.67h-170.66v170.66h170.66zM597.33,170.67h-170.66v170.66h170.66zM853.33,170.67h-170.66v170.66h170.66zM597.33,682.67h-170.66v170.66h170.66zM597.33,426.67h-170.66v170.66h170.66zM853.33,682.67h-170.66v170.66h170.66zM853.33,426.67h-170.66v170.66h170.66z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 931 B |
211
demo/images/material_icons_license.txt
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
The Google Material icons and modifications can be used free of charge for
|
||||||
|
commerical and non-commerical projects according to the Apache License 2.0.
|
||||||
|
|
||||||
|
An attribution to https://material.io/icons/ and/or https://iconfu.com on
|
||||||
|
your website or in your app's "about" screen would be wonderful.
|
||||||
|
|
||||||
|
Please do not re-sell the icons.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
6
demo/images/note_add.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>note_add icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M853.33,341.33v512c0,46.93 -38.4,85.34 -85.33,85.34h-512.43c-46.93,0 -84.9,-38.41 -84.9,-85.34l0.42,-682.66c0,-46.93 37.98,-85.34 84.91,-85.34h341.33zM682.67,597.33h-128v-128h-85.34v128h-128v85.34h128v128h85.34v-128h128zM789.33,384l-234.66,-234.67v234.67z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 671 B |
6
demo/images/picture_in_picture.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>picture_in_picture icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M981.33,213.33v597.34c0,46.93 -38.4,84.48 -85.33,84.48h-768c-46.93,0 -85.33,-37.55 -85.33,-84.48v-597.34c0,-46.93 38.4,-85.33 85.33,-85.33h768c46.93,0 85.33,38.4 85.33,85.33zM896,212.48h-768v598.61h768zM810.67,554.67h-341.34v-256h341.34z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 663 B |
6
demo/images/restore.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>restore icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M938.67,512c0,212.05 -171.95,384 -384,384c-106.24,0 -201.81,-43.09 -271.36,-112.64l60.58,-60.59c53.76,54.19 128.43,87.9 210.78,87.9c165.12,0 298.66,-133.55 298.66,-298.67c0,-165.12 -133.54,-298.67 -298.66,-298.67c-165.12,0 -298.67,133.55 -298.67,298.67h128l-172.37,171.95l-2.99,-5.98l-165.97,-165.97h128c0,-212.05 171.95,-384 384,-384c212.05,0 384,171.95 384,384zM576,341.33v181.34l149.33,88.74l-30.72,51.63l-182.61,-108.37v-213.34z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 847 B |
6
demo/images/save.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,1024,1024">
|
||||||
|
<desc>save icon - Licensed under Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0) - Created with Iconfu.com - Derivative work of Material icons (Copyright Google Inc.)</desc>
|
||||||
|
<g fill="#03b8e5" fill-rule="nonzero" style="mix-blend-mode: normal">
|
||||||
|
<path d="M896,298.67v512c0,46.93 -38.4,85.33 -85.33,85.33h-597.34c-47.36,0 -85.33,-38.4 -85.33,-85.33v-597.34c0,-46.93 37.97,-85.33 85.33,-85.33h512zM640,213.33h-426.67v170.67h426.67zM640,682.67c0,-70.83 -57.17,-128 -128,-128c-70.83,0 -128,57.17 -128,128c0,70.83 57.17,128 128,128c70.83,0 128,-57.17 128,-128z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 712 B |
@@ -1,5 +1,3 @@
|
|||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <MainWindow.h>
|
#include <MainWindow.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -38,7 +36,9 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
#if QT_VERSION >= 0x050600
|
||||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
#endif
|
||||||
std::shared_ptr<int> b;
|
std::shared_ptr<int> b;
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setQuitOnLastWindowClosed(true);
|
a.setQuitOnLastWindowClosed(true);
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/main">
|
|
||||||
<file>bricks.gif</file>
|
|
||||||
<file>bricks_orange.gif</file>
|
|
||||||
<file>bricks.apng</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
BIN
doc/advanced-docking_video.png
Normal file
|
After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 67 KiB |
BIN
doc/linux_kubuntu_1804.png
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
doc/linux_ubuntu_1910.png
Normal file
|
After Width: | Height: | Size: 212 KiB |
BIN
doc/macos.png
Normal file
|
After Width: | Height: | Size: 571 KiB |
BIN
doc/non_opaque_resizing.gif
Normal file
|
After Width: | Height: | Size: 414 KiB |
BIN
doc/opaque_resizing.gif
Normal file
|
After Width: | Height: | Size: 902 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 88 KiB |
BIN
doc/tab_menu.gif
Normal file
|
After Width: | Height: | Size: 311 KiB |
46
example/CMakeLists.txt
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.3)
|
||||||
|
set (CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
project(ads_example VERSION "1.0")
|
||||||
|
set(REQUIRED_QT_VERSION 5.5.0)
|
||||||
|
find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
set(ads_example_LIBS ${ads_example_LIBS} ${Qt5Core_LIBRARIES})
|
||||||
|
set(ads_example_INCLUDE ${ads_example_INCLUDE} ${Qt5Core_INCLUDE_DIRS})
|
||||||
|
set(ads_example_COMPILE_DEFINE ${ads_example_COMPILE_DEFINE} ${Qt5Core_COMPILE_DEFINITIONS} )
|
||||||
|
set(ads_example_LIBS ${ads_example_LIBS} ${Qt5Gui_LIBRARIES})
|
||||||
|
set(ads_example_INCLUDE ${ads_example_INCLUDE} ${Qt5Gui_INCLUDE_DIRS})
|
||||||
|
set(ads_example_COMPILE_DEFINE ${ads_example_COMPILE_DEFINE} ${Qt5Gui_COMPILE_DEFINITIONS})
|
||||||
|
set(ads_example_LIBS ${ads_example_LIBS} ${Qt5Widgets_LIBRARIES})
|
||||||
|
set(ads_example_INCLUDE ${ads_example_INCLUDE} ${Qt5Widgets_INCLUDE_DIRS})
|
||||||
|
set(ads_example_COMPILE_DEFINE ${ads_example_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
set(ads_example_SRCS
|
||||||
|
main.cpp
|
||||||
|
MainWindow.cpp
|
||||||
|
MainWindow.ui
|
||||||
|
)
|
||||||
|
add_executable(Example1 WIN32 ${ads_example_SRCS})
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
set(ads_example_DEFINE ${ads_example_DEFINE} ADS_STATIC)
|
||||||
|
endif()
|
||||||
|
add_dependencies(Example1 qtadvanceddocking)
|
||||||
|
target_include_directories(Example1 PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${ads_example_INCLUDE}>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
|
target_include_directories(Example1 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../src" ${ads_example_INCLUDE})
|
||||||
|
target_link_libraries(Example1 PRIVATE qtadvanceddocking ${ads_example_LIBS})
|
||||||
|
target_compile_definitions(Example1 PRIVATE ${ads_example_DEFINE})
|
||||||
|
set_target_properties(Example1 PROPERTIES
|
||||||
|
VERSION "1.0"
|
||||||
|
SOVERSION 1
|
||||||
|
EXPORT_NAME "Qt Advanced Docking System 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"
|
||||||
|
)
|
||||||
39
example/MainWindow.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#include "MainWindow.h"
|
||||||
|
#include "ui_MainWindow.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
|
QMainWindow(parent),
|
||||||
|
ui(new Ui::MainWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// Create the dock manager. Because the parent parameter is a QMainWindow
|
||||||
|
// the dock manager registers itself as the central widget.
|
||||||
|
m_DockManager = new ads::CDockManager(this);
|
||||||
|
|
||||||
|
// Create example content label - this can be any application specific
|
||||||
|
// widget
|
||||||
|
QLabel* l = new QLabel();
|
||||||
|
l->setWordWrap(true);
|
||||||
|
l->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||||
|
l->setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ");
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
DockWidget->setWidget(l);
|
||||||
|
|
||||||
|
// Add the toggleViewAction of the dock widget to the menu to give
|
||||||
|
// the user the possibility to show the dock widget if it has been closed
|
||||||
|
ui->menuView->addAction(DockWidget->toggleViewAction());
|
||||||
|
|
||||||
|
// Add the dock widget to the top dock widget area
|
||||||
|
m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
24
example/MainWindow.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "DockManager.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::MainWindow *ui;
|
||||||
|
ads::CDockManager* m_DockManager;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINWINDOW_H
|
||||||
38
example/MainWindow.ui
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</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>400</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="QStatusBar" name="statusBar"/>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
47
example/example.pro
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||||
|
|
||||||
|
QT += core gui widgets
|
||||||
|
|
||||||
|
TARGET = Example1
|
||||||
|
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||||
|
TEMPLATE = app
|
||||||
|
CONFIG += c++14
|
||||||
|
CONFIG += debug_and_release
|
||||||
|
adsBuildStatic {
|
||||||
|
DEFINES += ADS_STATIC
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
main.cpp \
|
||||||
|
MainWindow.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
MainWindow.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
MainWindow.ui
|
||||||
|
|
||||||
|
|
||||||
|
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||||
|
|
||||||
|
# Dependency: AdvancedDockingSystem (shared)
|
||||||
|
CONFIG(debug, debug|release){
|
||||||
|
win32 {
|
||||||
|
LIBS += -lqtadvanceddockingd
|
||||||
|
}
|
||||||
|
else:mac {
|
||||||
|
LIBS += -lqtadvanceddocking_debug
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LIBS += -lqtadvanceddocking
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
LIBS += -lqtadvanceddocking
|
||||||
|
}
|
||||||
|
|
||||||
|
INCLUDEPATH += ../src
|
||||||
|
DEPENDPATH += ../src
|
||||||
|
|
||||||
11
example/main.cpp
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#include "MainWindow.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
MainWindow w;
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
41
recipes/meta.yaml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
{% set data = load_setup_py_data() %}
|
||||||
|
|
||||||
|
package:
|
||||||
|
name: pyqtads
|
||||||
|
version: {{ data.get('version') }}
|
||||||
|
|
||||||
|
source:
|
||||||
|
path: ../
|
||||||
|
|
||||||
|
build:
|
||||||
|
number: 0
|
||||||
|
script: python setup.py install --single-version-externally-managed --record=record.txt --conda-recipe
|
||||||
|
|
||||||
|
requirements:
|
||||||
|
build:
|
||||||
|
- python
|
||||||
|
- setuptools
|
||||||
|
- pyqt>=5.9
|
||||||
|
- sip>=4.19
|
||||||
|
run:
|
||||||
|
- python
|
||||||
|
- pyqt>=5.9
|
||||||
|
- sip>=4.19
|
||||||
|
- pywin32 [win]
|
||||||
|
|
||||||
|
test:
|
||||||
|
imports:
|
||||||
|
- PyQtAds
|
||||||
|
|
||||||
|
about:
|
||||||
|
home: {{ data.get('url') }}
|
||||||
|
license: {{ data.get('license') }}
|
||||||
|
license_family: LGPL
|
||||||
|
license_file: 'LICENSE.md'
|
||||||
|
summary: {{ data.get('description') }}
|
||||||
|
description: {{ data.get('description') }}
|
||||||
|
doc_url: ''
|
||||||
|
dev_url: {{ data.get('url') }}
|
||||||
|
|
||||||
|
extra:
|
||||||
|
recipe-maintainers: 'nicolas.elie@cnrs.fr'
|
||||||
7
setup.cfg
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[versioneer]
|
||||||
|
VCS = git
|
||||||
|
style = pep440
|
||||||
|
versionfile_source = PyQtAds/_version.py
|
||||||
|
versionfile_build = PyQtAds/_version.py
|
||||||
|
tag_prefix =
|
||||||
|
|
||||||
294
setup.py
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import shlex
|
||||||
|
import subprocess
|
||||||
|
import glob
|
||||||
|
|
||||||
|
import versioneer
|
||||||
|
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
from setuptools.command.build_py import build_py
|
||||||
|
from setuptools.extension import Extension
|
||||||
|
from distutils import sysconfig, dir_util, spawn, log, cmd
|
||||||
|
from distutils.dep_util import newer
|
||||||
|
import sipdistutils
|
||||||
|
import sipconfig
|
||||||
|
from PyQt5.QtCore import PYQT_CONFIGURATION
|
||||||
|
from PyQt5.pyrcc_main import processResourceFile
|
||||||
|
|
||||||
|
MODULE_NAME = "ads"
|
||||||
|
SRC_PATH = "PyQtAds"
|
||||||
|
|
||||||
|
REQUIRE_PYQT = True
|
||||||
|
if "--conda-recipe" in sys.argv:
|
||||||
|
REQUIRE_PYQT = False
|
||||||
|
sys.argv.remove("--conda-recipe")
|
||||||
|
|
||||||
|
|
||||||
|
class HostPythonConfiguration(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.platform = sys.platform
|
||||||
|
self.version = sys.hexversion>>8
|
||||||
|
|
||||||
|
self.inc_dir = sysconfig.get_python_inc()
|
||||||
|
self.venv_inc_dir = sysconfig.get_python_inc(prefix=sys.prefix)
|
||||||
|
self.module_dir = sysconfig.get_python_lib(plat_specific=1)
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
self.data_dir = sys.prefix
|
||||||
|
self.lib_dir = sys.prefix +'\\libs'
|
||||||
|
else:
|
||||||
|
self.data_dir = sys.prefix + '/share'
|
||||||
|
self.lib_dir = sys.prefix + '/lib'
|
||||||
|
|
||||||
|
|
||||||
|
class TargetQtConfiguration(object):
|
||||||
|
def __init__(self, qmake):
|
||||||
|
pipe = os.popen(' '.join([qmake, '-query']))
|
||||||
|
|
||||||
|
for l in pipe:
|
||||||
|
l = l.strip()
|
||||||
|
|
||||||
|
tokens = l.split(':', 1)
|
||||||
|
if isinstance(tokens, list):
|
||||||
|
if len(tokens) != 2:
|
||||||
|
error("Unexpected output from qmake: '%s'\n" % l)
|
||||||
|
|
||||||
|
name, value = tokens
|
||||||
|
else:
|
||||||
|
name = tokens
|
||||||
|
value = None
|
||||||
|
|
||||||
|
name = name.replace('/', '_')
|
||||||
|
setattr(self, name, value)
|
||||||
|
|
||||||
|
pipe.close()
|
||||||
|
|
||||||
|
|
||||||
|
class build_ext(sipdistutils.build_ext):
|
||||||
|
|
||||||
|
description = "Builds the " + MODULE_NAME + " module."
|
||||||
|
|
||||||
|
user_options = sipdistutils.build_ext.user_options + [
|
||||||
|
('qmake-bin=', None, "Path to qmake binary"),
|
||||||
|
('sip-bin=', None, "Path to sip binary"),
|
||||||
|
('qt-include-dir=', None, "Path to Qt headers"),
|
||||||
|
('pyqt-sip-dir=', None, "Path to PyQt's SIP files"),
|
||||||
|
('pyqt-sip-flags=', None, "SIP flags used to generate PyQt bindings"),
|
||||||
|
('sip-dir=', None, "Path to module's SIP files"),
|
||||||
|
('inc-dir=', None, "Path to module's include files")
|
||||||
|
]
|
||||||
|
|
||||||
|
def initialize_options (self):
|
||||||
|
super().initialize_options()
|
||||||
|
self.qmake_bin = 'qmake'
|
||||||
|
self.sip_bin = None
|
||||||
|
self.qt_include_dir = None
|
||||||
|
self.qt_libinfix = ''
|
||||||
|
self.pyqt_sip_dir = None
|
||||||
|
self.pyqt_sip_flags = None
|
||||||
|
self.sip_files_dir = None
|
||||||
|
self.sip_inc_dir = None
|
||||||
|
self.inc_dir = None
|
||||||
|
self.pyconfig = HostPythonConfiguration()
|
||||||
|
self.qtconfig = TargetQtConfiguration(self.qmake_bin)
|
||||||
|
self.config = sipconfig.Configuration()
|
||||||
|
self.config.default_mod_dir = ("/usr/local/lib/python%i.%i/dist-packages" %
|
||||||
|
(sys.version_info.major, sys.version_info.minor))
|
||||||
|
|
||||||
|
def finalize_options (self):
|
||||||
|
super().finalize_options()
|
||||||
|
|
||||||
|
if not self.qt_include_dir:
|
||||||
|
self.qt_include_dir = self.qtconfig.QT_INSTALL_HEADERS
|
||||||
|
|
||||||
|
if not self.qt_libinfix:
|
||||||
|
try:
|
||||||
|
with open(os.path.join(self.qtconfig.QT_INSTALL_PREFIX, 'mkspecs', 'qconfig.pri'), 'r') as f:
|
||||||
|
for line in f.readlines():
|
||||||
|
if line.startswith('QT_LIBINFIX'):
|
||||||
|
self.qt_libinfix = line.split('=')[1].strip('\n').strip()
|
||||||
|
except (FileNotFoundError, IndexError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
if not self.pyqt_sip_dir:
|
||||||
|
self.pyqt_sip_dir = os.path.join(self.pyconfig.data_dir, 'sip', 'PyQt5')
|
||||||
|
|
||||||
|
if not self.pyqt_sip_flags:
|
||||||
|
self.pyqt_sip_flags = PYQT_CONFIGURATION.get('sip_flags', '')
|
||||||
|
|
||||||
|
if not self.sip_files_dir:
|
||||||
|
self.sip_files_dir = os.path.abspath(os.path.join(".", "sip"))
|
||||||
|
|
||||||
|
if not self.sip_inc_dir:
|
||||||
|
self.sip_inc_dir = self.pyconfig.venv_inc_dir
|
||||||
|
|
||||||
|
if not self.inc_dir:
|
||||||
|
self.inc_dir = os.path.abspath(os.path.join(".", "src"))
|
||||||
|
|
||||||
|
if not self.qt_include_dir:
|
||||||
|
raise SystemExit('Could not find Qt5 headers. '
|
||||||
|
'Please specify via --qt-include-dir=')
|
||||||
|
|
||||||
|
if not self.pyqt_sip_dir:
|
||||||
|
raise SystemExit('Could not find PyQt SIP files. '
|
||||||
|
'Please specify containing directory via '
|
||||||
|
'--pyqt-sip-dir=')
|
||||||
|
|
||||||
|
if not self.pyqt_sip_flags:
|
||||||
|
raise SystemExit('Could not find PyQt SIP flags. '
|
||||||
|
'Please specify via --pyqt-sip-flags=')
|
||||||
|
|
||||||
|
def _find_sip(self):
|
||||||
|
"""override _find_sip to allow for manually speficied sip path."""
|
||||||
|
return self.sip_bin or super()._find_sip()
|
||||||
|
|
||||||
|
def _sip_compile(self, sip_bin, source, sbf):
|
||||||
|
cmd = [sip_bin]
|
||||||
|
if hasattr(self, 'sip_opts'):
|
||||||
|
cmd += self.sip_opts
|
||||||
|
if hasattr(self, '_sip_sipfiles_dir'):
|
||||||
|
cmd += ['-I', self._sip_sipfiles_dir()]
|
||||||
|
cmd += [
|
||||||
|
"-I", self.sip_files_dir,
|
||||||
|
"-I", self.pyqt_sip_dir,
|
||||||
|
"-I", self.sip_inc_dir,
|
||||||
|
"-I", self.inc_dir,
|
||||||
|
"-c", self._sip_output_dir(),
|
||||||
|
"-b", sbf,
|
||||||
|
"-w", "-o"]
|
||||||
|
|
||||||
|
cmd += shlex.split(self.pyqt_sip_flags) # use same SIP flags as for PyQt5
|
||||||
|
cmd.append(source)
|
||||||
|
self.spawn(cmd)
|
||||||
|
|
||||||
|
def swig_sources (self, sources, extension=None):
|
||||||
|
if not self.extensions:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Add the local include directory to the include path
|
||||||
|
if extension is not None:
|
||||||
|
extension.extra_compile_args += ['-D', 'QT_CORE_LIB',
|
||||||
|
'-D', 'QT_GUI_LIB',
|
||||||
|
'-D', 'QT_WIDGETS_LIB',
|
||||||
|
'-D', 'ADS_SHARED_EXPORT']
|
||||||
|
extension.include_dirs += [self.qt_include_dir, self.inc_dir,
|
||||||
|
os.path.join(self.qt_include_dir, 'QtCore'),
|
||||||
|
os.path.join(self.qt_include_dir, 'QtGui'),
|
||||||
|
os.path.join(self.qt_include_dir, 'QtWidgets')]
|
||||||
|
extension.libraries += ['Qt5Core' + self.qt_libinfix,
|
||||||
|
'Qt5Gui' + self.qt_libinfix,
|
||||||
|
'Qt5Widgets' + self.qt_libinfix]
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
extension.library_dirs += [self.qtconfig.QT_INSTALL_LIBS,
|
||||||
|
self.inc_dir, self._sip_output_dir()]
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
extension.extra_compile_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS,
|
||||||
|
'-std=c++11', '-stdlib=libc++', '-mmacosx-version-min=10.9']
|
||||||
|
extension.extra_link_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS,
|
||||||
|
'-mmacosx-version-min=10.9']
|
||||||
|
elif sys.platform == 'linux':
|
||||||
|
extension.extra_compile_args += ['-std=c++11']
|
||||||
|
|
||||||
|
return super().swig_sources(sources, extension)
|
||||||
|
|
||||||
|
def build_extension(self, ext):
|
||||||
|
cppsources = [source for source in ext.sources if source.endswith(".cpp")]
|
||||||
|
|
||||||
|
dir_util.mkpath(self.build_temp, dry_run=self.dry_run)
|
||||||
|
|
||||||
|
# Run moc on all header files.
|
||||||
|
for source in cppsources:
|
||||||
|
header = source.replace(".cpp", ".h")
|
||||||
|
if os.path.exists(header):
|
||||||
|
moc_file = "moc_" + os.path.basename(header).replace(".h", ".cpp")
|
||||||
|
out_file = os.path.join(self.build_temp, moc_file)
|
||||||
|
|
||||||
|
if newer(header, out_file) or self.force:
|
||||||
|
call_arg = ["moc", "-o", out_file, header]
|
||||||
|
spawn.spawn(call_arg, dry_run=self.dry_run)
|
||||||
|
|
||||||
|
if os.path.getsize(out_file) > 0:
|
||||||
|
ext.sources.append(out_file)
|
||||||
|
|
||||||
|
# Add the temp build directory to include path, for compiler to find
|
||||||
|
# the created .moc files
|
||||||
|
ext.include_dirs += [self._sip_output_dir()]
|
||||||
|
|
||||||
|
sipdistutils.build_ext.build_extension(self, ext)
|
||||||
|
|
||||||
|
|
||||||
|
class ProcessResourceCommand(cmd.Command):
|
||||||
|
"""A custom command to compile the resource file into a Python file"""
|
||||||
|
|
||||||
|
description = "Compile the qrc file into a python file"
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
return
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
processResourceFile([os.path.join('src', 'ads.qrc')],
|
||||||
|
os.path.join(SRC_PATH, 'rc.py'), False)
|
||||||
|
|
||||||
|
|
||||||
|
class BuildPyCommand(build_py):
|
||||||
|
"""Custom build command to include ProcessResource command"""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.run_command("process_resource")
|
||||||
|
build_py.run(self)
|
||||||
|
|
||||||
|
|
||||||
|
setup_requires = ["PyQt5"] if REQUIRE_PYQT else []
|
||||||
|
cpp_sources = glob.glob(os.path.join('src', '*.cpp'))
|
||||||
|
sip_sources = [os.path.join('sip', MODULE_NAME + '.sip')]
|
||||||
|
if sys.platform == 'linux':
|
||||||
|
cpp_sources += glob.glob(os.path.join('src', 'linux', '*.cpp'))
|
||||||
|
ext_modules = [Extension('PyQtAds.QtAds.ads', cpp_sources + sip_sources)]
|
||||||
|
|
||||||
|
install_requires = ["PyQt5"]
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
install_requires.append("pywin32")
|
||||||
|
|
||||||
|
|
||||||
|
with open('README.md', 'r') as f:
|
||||||
|
LONG_DESCRIPTION = f.read()
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name = SRC_PATH,
|
||||||
|
author = "Nicolas Elie",
|
||||||
|
author_email = "nicolas.elie@cnrs.fr",
|
||||||
|
url = "https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System",
|
||||||
|
version = versioneer.get_version(),
|
||||||
|
description = "Advanced Docking System for Qt",
|
||||||
|
long_description = LONG_DESCRIPTION,
|
||||||
|
keywords = ["qt"],
|
||||||
|
license = "LGPLv2+",
|
||||||
|
classifiers = ["Development Status :: 4 - Beta",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
|
||||||
|
"Operating System :: OS Independent",
|
||||||
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
|
"Environment :: Win32 (MS Windows)",
|
||||||
|
"Environment :: MacOS X",
|
||||||
|
"Environment :: X11 Applications :: Qt",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.2",
|
||||||
|
"Programming Language :: Python :: 3.3",
|
||||||
|
"Programming Language :: Python :: 3.4",
|
||||||
|
"Programming Language :: Python :: 3.5",
|
||||||
|
"Programming Language :: Python :: 3.6",
|
||||||
|
"Programming Language :: Python :: 3.7"],
|
||||||
|
ext_modules = ext_modules,
|
||||||
|
cmdclass = versioneer.get_cmdclass({'process_resource': ProcessResourceCommand,
|
||||||
|
'build_py': BuildPyCommand,
|
||||||
|
'build_ext': build_ext}),
|
||||||
|
packages = find_packages(),
|
||||||
|
setup_requires = setup_requires,
|
||||||
|
install_requires = install_requires,
|
||||||
|
zip_safe=False
|
||||||
|
)
|
||||||
82
simple.py
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from PyQt5 import QtWidgets, QtCore
|
||||||
|
from PyQt5.QtCore import Qt
|
||||||
|
from PyQtAds import QtAds
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setup_ui()
|
||||||
|
self.dock_manager = QtAds.CDockManager(self)
|
||||||
|
|
||||||
|
self.dock_widgets = []
|
||||||
|
|
||||||
|
for label_text, area in (
|
||||||
|
('1 Top', QtAds.TopDockWidgetArea),
|
||||||
|
('2 Bottom', QtAds.BottomDockWidgetArea),
|
||||||
|
('3 Left', QtAds.LeftDockWidgetArea),
|
||||||
|
('4 Right', QtAds.RightDockWidgetArea),
|
||||||
|
):
|
||||||
|
# Create example content label - this can be any application specific
|
||||||
|
# widget
|
||||||
|
label = QtWidgets.QLabel()
|
||||||
|
label.setWordWrap(True)
|
||||||
|
label.setAlignment(Qt.AlignTop | Qt.AlignLeft)
|
||||||
|
label.setText(f"{label_text}: Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ")
|
||||||
|
|
||||||
|
# Create a dock widget with the title Label 1 and set the created label
|
||||||
|
# as the dock widget content
|
||||||
|
dock_widget = QtAds.CDockWidget(label_text)
|
||||||
|
dock_widget.setWidget(label)
|
||||||
|
self.dock_widgets.append(dock_widget)
|
||||||
|
|
||||||
|
# Add the toggleViewAction of the dock widget to the menu to give
|
||||||
|
# the user the possibility to show the dock widget if it has been closed
|
||||||
|
self.menu_view.addAction(dock_widget.toggleViewAction())
|
||||||
|
|
||||||
|
# Add the dock widget to the top dock widget area
|
||||||
|
self.dock_manager.addDockWidget(area, dock_widget)
|
||||||
|
|
||||||
|
def setup_ui(self):
|
||||||
|
self.setWindowTitle("MainWindow")
|
||||||
|
self.setObjectName("MainWindow")
|
||||||
|
self.resize(400, 300)
|
||||||
|
self.central_widget = QtWidgets.QWidget(self)
|
||||||
|
self.central_widget.setObjectName("central_widget")
|
||||||
|
self.setCentralWidget(self.central_widget)
|
||||||
|
|
||||||
|
self.menu_bar = QtWidgets.QMenuBar(self)
|
||||||
|
self.menu_bar.setGeometry(QtCore.QRect(0, 0, 400, 21))
|
||||||
|
self.menu_bar.setObjectName("menuBar")
|
||||||
|
|
||||||
|
self.menu_view = QtWidgets.QMenu(self.menu_bar)
|
||||||
|
self.menu_view.setObjectName("menu_view")
|
||||||
|
self.menu_view.setTitle("View")
|
||||||
|
self.setMenuBar(self.menu_bar)
|
||||||
|
|
||||||
|
self.status_bar = QtWidgets.QStatusBar(self)
|
||||||
|
self.status_bar.setObjectName("statusBar")
|
||||||
|
self.setStatusBar(self.status_bar)
|
||||||
|
self.menu_bar.addAction(self.menu_view.menuAction())
|
||||||
|
|
||||||
|
|
||||||
|
def main(app):
|
||||||
|
main = MainWindow()
|
||||||
|
main.show()
|
||||||
|
state = main.dock_manager.saveState()
|
||||||
|
print('This is what the saved state looks like in XML:')
|
||||||
|
print(state)
|
||||||
|
print()
|
||||||
|
main.dock_manager.restoreState(state)
|
||||||
|
return main
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
logging.basicConfig(level='DEBUG')
|
||||||
|
app = QtWidgets.QApplication([])
|
||||||
|
window = main(app)
|
||||||
|
window.show()
|
||||||
|
print('shown')
|
||||||
|
app.exec_()
|
||||||
57
sip/DockAreaTabBar.sip
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockAreaTabBar : QScrollArea
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockAreaTabBar.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void wheelEvent(QWheelEvent* Event);
|
||||||
|
virtual void mousePressEvent(QMouseEvent* ev);
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent* ev);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent* ev);
|
||||||
|
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
|
void startFloating(const QPoint& Offset);
|
||||||
|
ads::IFloatingWidget* makeAreaFloating(const QPoint& Offset,
|
||||||
|
ads::eDragState DragState);
|
||||||
|
ads::eDragState dragState() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDockAreaTabBar(ads::CDockAreaWidget* parent /TransferThis/);
|
||||||
|
virtual ~CDockAreaTabBar();
|
||||||
|
void insertTab(int Index, ads::CDockWidgetTab* Tab /Transfer/);
|
||||||
|
void removeTab(ads::CDockWidgetTab* Tab) /TransferBack/;
|
||||||
|
int count() const;
|
||||||
|
int currentIndex() const;
|
||||||
|
ads::CDockWidgetTab* currentTab() const;
|
||||||
|
ads::CDockWidgetTab* tab(int Index) const;
|
||||||
|
virtual bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
bool isTabOpen(int Index) const;
|
||||||
|
virtual QSize minimumSizeHint() const;
|
||||||
|
virtual QSize sizeHint() const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setCurrentIndex(int Index);
|
||||||
|
void closeTab(int Index);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void currentChanging(int Index);
|
||||||
|
void currentChanged(int Index);
|
||||||
|
void tabBarClicked(int index);
|
||||||
|
void tabCloseRequested(int index);
|
||||||
|
void tabClosed(int index);
|
||||||
|
void tabOpened(int index);
|
||||||
|
void tabMoved(int from, int to);
|
||||||
|
void removingTab(int index);
|
||||||
|
void tabInserted(int index);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
32
sip/DockAreaTitleBar.sip
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockAreaTitleBar : QFrame
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockAreaTitleBar.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void markTabsMenuOutdated();
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDockAreaTitleBar(ads::CDockAreaWidget* parent /TransferThis/);
|
||||||
|
virtual ~CDockAreaTitleBar();
|
||||||
|
ads::CDockAreaTabBar* tabBar() const;
|
||||||
|
QAbstractButton* button(ads::TitleBarButton which) const;
|
||||||
|
virtual void setVisible(bool Visible);
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void tabBarClicked(int index);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
65
sip/DockAreaWidget.sip
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockAreaWidget : QFrame
|
||||||
|
{
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockAreaWidget.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void insertDockWidget(int index, ads::CDockWidget* DockWidget /Transfer/, bool Activate = true);
|
||||||
|
void addDockWidget(ads::CDockWidget* DockWidget /Transfer/);
|
||||||
|
void removeDockWidget(ads::CDockWidget* DockWidget) /TransferBack/;
|
||||||
|
void toggleDockWidgetView(ads::CDockWidget* DockWidget, bool Open);
|
||||||
|
CDockWidget* nextOpenDockWidget(ads::CDockWidget* DockWidget) const;
|
||||||
|
int index(ads::CDockWidget* DockWidget);
|
||||||
|
void hideAreaWithNoVisibleContent();
|
||||||
|
void updateTitleBarVisibility();
|
||||||
|
void internalSetCurrentDockWidget(ads::CDockWidget* DockWidget /Transfer/);
|
||||||
|
void markTitleBarMenuOutdated();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void toggleView(bool Open);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDockAreaWidget(ads::CDockManager* DockManager /TransferThis/, ads::CDockContainerWidget* parent /TransferThis/);
|
||||||
|
virtual ~CDockAreaWidget();
|
||||||
|
ads::CDockManager* dockManager() const;
|
||||||
|
ads::CDockContainerWidget* dockContainer() const;
|
||||||
|
QRect titleBarGeometry() const;
|
||||||
|
QRect contentAreaGeometry() const;
|
||||||
|
int dockWidgetsCount() const;
|
||||||
|
QList<ads::CDockWidget*> dockWidgets() const;
|
||||||
|
int openDockWidgetsCount() const;
|
||||||
|
QList<ads::CDockWidget*> openedDockWidgets() const;
|
||||||
|
ads::CDockWidget* dockWidget(int Index) const;
|
||||||
|
int currentIndex() const;
|
||||||
|
int indexOfFirstOpenDockWidget() const;
|
||||||
|
ads::CDockWidget* currentDockWidget() const;
|
||||||
|
void setCurrentDockWidget(ads::CDockWidget* DockWidget /Transfer/);
|
||||||
|
void saveState(QXmlStreamWriter& Stream) const;
|
||||||
|
ads::CDockWidget::DockWidgetFeatures features() const;
|
||||||
|
QAbstractButton* titleBarButton(ads::TitleBarButton which) const;
|
||||||
|
virtual void setVisible(bool Visible);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setCurrentIndex(int index);
|
||||||
|
void closeArea();
|
||||||
|
void closeOtherAreas();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void tabBarClicked(int index);
|
||||||
|
void currentChanging(int index);
|
||||||
|
void currentChanged(int index);
|
||||||
|
void viewToggled(bool Open);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
155
sip/DockContainerWidget.sip
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container that manages a number of dock areas with single dock widgets
|
||||||
|
* or tabyfied dock widgets in each area.
|
||||||
|
* Each window that support docking has a DockContainerWidget. That means
|
||||||
|
* the main application window and all floating windows are ore contain
|
||||||
|
* an DockContainerWidget.
|
||||||
|
*/
|
||||||
|
class CDockContainerWidget : QFrame
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockContainerWidget.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool event(QEvent *e);
|
||||||
|
QSplitter* rootSplitter() const;
|
||||||
|
void createRootSplitter();
|
||||||
|
void dropFloatingWidget(ads::CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
|
||||||
|
void dropWidget(QWidget* widget, const QPoint& TargetPos);
|
||||||
|
void addDockArea(ads::CDockAreaWidget* DockAreaWidget /Transfer/, ads::DockWidgetArea area = ads::CenterDockWidgetArea);
|
||||||
|
void removeDockArea(ads::CDockAreaWidget* area /Transfer/);
|
||||||
|
void saveState(QXmlStreamWriter& Stream) const;
|
||||||
|
bool restoreState(CDockingStateReader& Stream, bool Testing);
|
||||||
|
ads::CDockAreaWidget* lastAddedDockAreaWidget(ads::DockWidgetArea area) const;
|
||||||
|
bool hasTopLevelDockWidget() const;
|
||||||
|
ads::CDockWidget* topLevelDockWidget() const;
|
||||||
|
ads::CDockAreaWidget* topLevelDockArea() const;
|
||||||
|
QList<ads::CDockWidget*> dockWidgets() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Default Constructor
|
||||||
|
*/
|
||||||
|
CDockContainerWidget(ads::CDockManager* DockManager /TransferThis/, QWidget* parent /TransferThis/ = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual Destructor
|
||||||
|
*/
|
||||||
|
virtual ~CDockContainerWidget();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds dockwidget into the given area.
|
||||||
|
* If DockAreaWidget is not null, then the area parameter indicates the area
|
||||||
|
* into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will
|
||||||
|
* be dropped into the container.
|
||||||
|
* \return Returns the dock area widget that contains the new DockWidget
|
||||||
|
*/
|
||||||
|
ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/,
|
||||||
|
ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes dockwidget
|
||||||
|
*/
|
||||||
|
void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current zOrderIndex
|
||||||
|
*/
|
||||||
|
virtual unsigned int zOrderIndex() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns true if this container widgets z order index is
|
||||||
|
* higher than the index of the container widget given in Other parameter
|
||||||
|
*/
|
||||||
|
bool isInFrontOf(ads::CDockContainerWidget* Other) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the dock area at teh given global position or 0 if there is no
|
||||||
|
* dock area at this position
|
||||||
|
*/
|
||||||
|
ads::CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the dock area at the given Index or 0 if the index is out of
|
||||||
|
* range
|
||||||
|
*/
|
||||||
|
ads::CDockAreaWidget* dockArea(int Index) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of dock areas that are not closed
|
||||||
|
* If all dock widgets in a dock area are closed, the dock area will be closed
|
||||||
|
*/
|
||||||
|
QList<ads::CDockAreaWidget*> openedDockAreas() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of dock areas in this container
|
||||||
|
*/
|
||||||
|
int dockAreaCount() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of visible dock areas
|
||||||
|
*/
|
||||||
|
int visibleDockAreaCount() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns true, if this container is in a floating widget
|
||||||
|
*/
|
||||||
|
bool isFloating() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps the layout for debugging purposes
|
||||||
|
*/
|
||||||
|
void dumpLayout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This functions returns the dock widget features of all dock widget in
|
||||||
|
* this container.
|
||||||
|
* A bitwise and is used to combine the flags of all dock widgets. That
|
||||||
|
* means, if only dock widget does not support a certain flag, the whole
|
||||||
|
* dock are does not support the flag.
|
||||||
|
*/
|
||||||
|
ads::CDockWidget::DockWidgetFeatures features() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this dock container is in a floating widget, this function returns
|
||||||
|
* the floating widget.
|
||||||
|
* Else, it returns a nullptr.
|
||||||
|
*/
|
||||||
|
ads::CFloatingDockContainer* floatingWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this function to close all dock areas except the KeepOpenArea
|
||||||
|
*/
|
||||||
|
void closeOtherAreas(ads::CDockAreaWidget* KeepOpenArea);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* This signal is emitted if one or multiple dock areas has been added to
|
||||||
|
* the internal list of dock areas.
|
||||||
|
* If multiple dock areas are inserted, this signal is emitted only once
|
||||||
|
*/
|
||||||
|
void dockAreasAdded();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted if one or multiple dock areas has been removed
|
||||||
|
*/
|
||||||
|
void dockAreasRemoved();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted if a dock area is opened or closed via
|
||||||
|
* toggleView() function
|
||||||
|
*/
|
||||||
|
void dockAreaViewToggled(ads::CDockAreaWidget* DockArea, bool Open);
|
||||||
|
}; // class DockContainerWidget
|
||||||
|
};
|
||||||
|
// namespace ads
|
||||||
|
|
||||||
|
%End
|
||||||
216
sip/DockManager.sip
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
%MappedType QMap<QString, ads::CDockWidget*>
|
||||||
|
/TypeHint="Dict[QString, CDockWidget*]", TypeHintValue="{}"/
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <qmap.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
%ConvertFromTypeCode
|
||||||
|
PyObject *d = PyDict_New();
|
||||||
|
|
||||||
|
if (!d)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
QMap<QString, ads::CDockWidget*>::const_iterator it = sipCpp->constBegin();
|
||||||
|
QMap<QString, ads::CDockWidget*>::const_iterator end = sipCpp->constEnd();
|
||||||
|
|
||||||
|
while (it != end)
|
||||||
|
{
|
||||||
|
QString *k = new QString(it.key());
|
||||||
|
PyObject *kobj = sipConvertFromType(k, sipType_QString,
|
||||||
|
sipTransferObj);
|
||||||
|
|
||||||
|
if (!kobj)
|
||||||
|
{
|
||||||
|
delete k;
|
||||||
|
Py_DECREF(d);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyObject *vobj = sipConvertFromType(it.value(), sipType_ads_CDockWidget,
|
||||||
|
sipTransferObj);
|
||||||
|
|
||||||
|
if (!vobj)
|
||||||
|
{
|
||||||
|
Py_DECREF(kobj);
|
||||||
|
Py_DECREF(d);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rc = PyDict_SetItem(d, kobj, vobj);
|
||||||
|
|
||||||
|
Py_DECREF(vobj);
|
||||||
|
Py_DECREF(kobj);
|
||||||
|
|
||||||
|
if (rc < 0)
|
||||||
|
{
|
||||||
|
Py_DECREF(d);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
%End
|
||||||
|
|
||||||
|
%ConvertToTypeCode
|
||||||
|
if (!sipIsErr)
|
||||||
|
return PyDict_Check(sipPy);
|
||||||
|
|
||||||
|
QMap<QString, ads::CDockWidget*> *qm = new QMap<QString, ads::CDockWidget*>;
|
||||||
|
|
||||||
|
Py_ssize_t pos = 0;
|
||||||
|
PyObject *kobj, *vobj;
|
||||||
|
while (PyDict_Next(sipPy, &pos, &kobj, &vobj))
|
||||||
|
{
|
||||||
|
int kstate;
|
||||||
|
QString *k = reinterpret_cast<QString *>(
|
||||||
|
sipForceConvertToType(kobj, sipType_QString, sipTransferObj,
|
||||||
|
SIP_NOT_NONE, &kstate, sipIsErr));
|
||||||
|
|
||||||
|
if (*sipIsErr)
|
||||||
|
{
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"a dict key has type '%s' but '_TYPE1_' is expected",
|
||||||
|
sipPyTypeName(Py_TYPE(kobj)));
|
||||||
|
|
||||||
|
delete qm;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vstate;
|
||||||
|
ads::CDockWidget *v = reinterpret_cast<ads::CDockWidget *>(
|
||||||
|
sipForceConvertToType(vobj, sipType_ads_CDockWidget, sipTransferObj,
|
||||||
|
SIP_NOT_NONE, &vstate, sipIsErr));
|
||||||
|
|
||||||
|
if (*sipIsErr)
|
||||||
|
{
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"a dict value has type '%s' but '_TYPE2_' is expected",
|
||||||
|
sipPyTypeName(Py_TYPE(vobj)));
|
||||||
|
|
||||||
|
sipReleaseType(k, sipType_QString, kstate);
|
||||||
|
delete qm;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qm->insert(*k, v);
|
||||||
|
|
||||||
|
sipReleaseType(v, sipType_ads_CDockWidget, vstate);
|
||||||
|
sipReleaseType(k, sipType_QString, kstate);
|
||||||
|
}
|
||||||
|
|
||||||
|
*sipCppPtr = qm;
|
||||||
|
|
||||||
|
return sipGetState(sipTransferObj);
|
||||||
|
%End
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockManager : ads::CDockContainerWidget
|
||||||
|
{
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockManager.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void registerFloatingWidget(ads::CFloatingDockContainer* FloatingWidget /Transfer/);
|
||||||
|
void removeFloatingWidget(ads::CFloatingDockContainer* FloatingWidget) /TransferBack/;
|
||||||
|
void registerDockContainer(ads::CDockContainerWidget* DockContainer /Transfer/);
|
||||||
|
void removeDockContainer(ads::CDockContainerWidget* DockContainer /TransferBack/);
|
||||||
|
ads::CDockOverlay* containerOverlay() const;
|
||||||
|
ads::CDockOverlay* dockAreaOverlay() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum eViewMenuInsertionOrder
|
||||||
|
{
|
||||||
|
MenuSortedByInsertion,
|
||||||
|
MenuAlphabeticallySorted
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eConfigFlag
|
||||||
|
{
|
||||||
|
ActiveTabHasCloseButton,
|
||||||
|
DockAreaHasCloseButton,
|
||||||
|
DockAreaCloseButtonClosesTab,
|
||||||
|
OpaqueSplitterResize,
|
||||||
|
XmlAutoFormattingEnabled,
|
||||||
|
XmlCompressionEnabled,
|
||||||
|
TabCloseButtonIsToolButton,
|
||||||
|
AllTabsHaveCloseButton,
|
||||||
|
RetainTabSizeWhenCloseButtonHidden,
|
||||||
|
OpaqueUndocking,
|
||||||
|
DragPreviewIsDynamic,
|
||||||
|
DragPreviewShowsContentPixmap,
|
||||||
|
DragPreviewHasWindowFrame,
|
||||||
|
DefaultConfig,
|
||||||
|
DefaultNonOpaqueConfig,
|
||||||
|
NonOpaqueWithWindowFrame,
|
||||||
|
};
|
||||||
|
typedef QFlags<ads::CDockManager::eConfigFlag> ConfigFlags;
|
||||||
|
|
||||||
|
CDockManager(QWidget* parent /TransferThis/ = 0);
|
||||||
|
virtual ~CDockManager();
|
||||||
|
static ads::CDockManager::ConfigFlags configFlags();
|
||||||
|
static void setConfigFlags(const ads::CDockManager::ConfigFlags Flags);
|
||||||
|
static void setConfigFlag(ads::CDockManager::eConfigFlag Flag, bool On = true);
|
||||||
|
static ads::CIconProvider& iconProvider();
|
||||||
|
ads::CDockAreaWidget* addDockWidget(ads::DockWidgetArea area, ads::CDockWidget* Dockwidget /Transfer/,
|
||||||
|
ads::CDockAreaWidget* DockAreaWidget /Transfer/ = 0);
|
||||||
|
ads::CDockAreaWidget* addDockWidgetTab(ads::DockWidgetArea area,
|
||||||
|
ads::CDockWidget* Dockwidget /Transfer/);
|
||||||
|
ads::CDockAreaWidget* addDockWidgetTabToArea(ads::CDockWidget* Dockwidget /Transfer/,
|
||||||
|
ads::CDockAreaWidget* DockAreaWidget /Transfer/);
|
||||||
|
ads::CFloatingDockContainer* addDockWidgetFloating(ads::CDockWidget* DockWidget /Transfer/);
|
||||||
|
ads::CDockWidget* findDockWidget(const QString& ObjectName) const;
|
||||||
|
void removeDockWidget(ads::CDockWidget* Dockwidget) /TransferBack/;
|
||||||
|
QMap<QString, ads::CDockWidget*> dockWidgetsMap() const;
|
||||||
|
const QList<ads::CDockContainerWidget*> dockContainers() const;
|
||||||
|
const QList<ads::CFloatingDockContainer*> floatingWidgets() const;
|
||||||
|
virtual unsigned int zOrderIndex() const;
|
||||||
|
QByteArray saveState(int version = 1) const;
|
||||||
|
bool restoreState(const QByteArray &state, int version = 1);
|
||||||
|
void addPerspective(const QString& UniquePrespectiveName);
|
||||||
|
void removePerspective(const QString& Name);
|
||||||
|
void removePerspectives(const QStringList& Names);
|
||||||
|
QStringList perspectiveNames() const;
|
||||||
|
void savePerspectives(QSettings& Settings) const;
|
||||||
|
void loadPerspectives(QSettings& Settings);
|
||||||
|
QAction* addToggleViewActionToMenu(QAction* ToggleViewAction /Transfer/,
|
||||||
|
const QString& Group = QString(), const QIcon& GroupIcon = QIcon());
|
||||||
|
QMenu* viewMenu() const;
|
||||||
|
void setViewMenuInsertionOrder(ads::CDockManager::eViewMenuInsertionOrder Order);
|
||||||
|
bool isRestoringState() const;
|
||||||
|
static int startDragDistance();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void openPerspective(const QString& PerspectiveName);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void perspectiveListChanged();
|
||||||
|
void perspectivesRemoved();
|
||||||
|
void restoringState();
|
||||||
|
void stateRestored();
|
||||||
|
void openingPerspective(const QString& PerspectiveName);
|
||||||
|
void perspectiveOpened(const QString& PerspectiveName);
|
||||||
|
void dockAreaCreated(ads::CDockAreaWidget* DockArea);
|
||||||
|
void dockWidgetAboutToBeRemoved(ads::CDockWidget* DockWidget);
|
||||||
|
void dockWidgetRemoved(ads::CDockWidget* DockWidget);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
77
sip/DockOverlay.sip
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockOverlay : public QFrame
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockOverlay.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum eMode
|
||||||
|
{
|
||||||
|
ModeDockAreaOverlay,
|
||||||
|
ModeContainerOverlay
|
||||||
|
};
|
||||||
|
|
||||||
|
CDockOverlay(QWidget* parent /TransferThis/, eMode Mode = ads::CDockOverlay::ModeDockAreaOverlay);
|
||||||
|
virtual ~CDockOverlay();
|
||||||
|
void setAllowedAreas(ads::DockWidgetAreas areas);
|
||||||
|
ads::DockWidgetAreas allowedAreas() const;
|
||||||
|
ads::DockWidgetArea dropAreaUnderCursor() const;
|
||||||
|
ads::DockWidgetArea showOverlay(QWidget* target);
|
||||||
|
void hideOverlay();
|
||||||
|
void enableDropPreview(bool Enable);
|
||||||
|
QRect dropOverlayRect() const;
|
||||||
|
virtual bool event(QEvent *e);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void paintEvent(QPaintEvent *e);
|
||||||
|
virtual void showEvent(QShowEvent* e);
|
||||||
|
virtual void hideEvent(QHideEvent* e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CDockOverlayCross : public QWidget
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum eIconColor
|
||||||
|
{
|
||||||
|
FrameColor,
|
||||||
|
WindowBackgroundColor,
|
||||||
|
OverlayColor,
|
||||||
|
ArrowColor,
|
||||||
|
ShadowColor
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString iconColors() const;
|
||||||
|
QColor iconColor() const;
|
||||||
|
void setIconFrameColor(const QColor& Color);
|
||||||
|
void setIconBackgroundColor(const QColor& Color);
|
||||||
|
void setIconOverlayColor(const QColor& Color);
|
||||||
|
void setIconArrowColor(const QColor& Color);
|
||||||
|
void setIconShadowColor(const QColor& Color);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDockOverlayCross(ads::CDockOverlay* overlay /TransferThis/);
|
||||||
|
virtual ~CDockOverlayCross();
|
||||||
|
void setIconColor(ads::CDockOverlayCross::eIconColor ColorIndex, const QColor& Color);
|
||||||
|
QColor iconColor(ads::CDockOverlayCross::eIconColor ColorIndex) const;
|
||||||
|
ads::DockWidgetArea cursorLocation() const;
|
||||||
|
void setupOverlayCross(ads::CDockOverlay::eMode Mode);
|
||||||
|
void updateOverlayIcons();
|
||||||
|
void reset();
|
||||||
|
void updatePosition();
|
||||||
|
void setIconColors(const QString& Colors);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
23
sip/DockSplitter.sip
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockSplitter : QSplitter
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockSplitter.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDockSplitter(QWidget *parent /TransferThis/ = 0);
|
||||||
|
CDockSplitter(Qt::Orientation orientation, QWidget *parent /TransferThis/ = 0);
|
||||||
|
virtual ~CDockSplitter();
|
||||||
|
bool hasVisibleContent() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
104
sip/DockWidget.sip
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockWidget : QFrame
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockWidget.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setDockManager(ads::CDockManager* DockManager /Transfer/);
|
||||||
|
void setDockArea(ads::CDockAreaWidget* DockArea /Transfer/);
|
||||||
|
void setToggleViewActionChecked(bool Checked);
|
||||||
|
void saveState(QXmlStreamWriter& Stream) const;
|
||||||
|
void flagAsUnassigned();
|
||||||
|
static void emitTopLevelEventForWidget(ads::CDockWidget* TopLevelDockWidget, bool Floating);
|
||||||
|
void emitTopLevelChanged(bool Floating);
|
||||||
|
void setClosedState(bool Closed);
|
||||||
|
void toggleViewInternal(bool Open);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DockWidgetFeature
|
||||||
|
{
|
||||||
|
DockWidgetClosable,
|
||||||
|
DockWidgetMovable,
|
||||||
|
DockWidgetFloatable,
|
||||||
|
DockWidgetDeleteOnClose,
|
||||||
|
AllDockWidgetFeatures,
|
||||||
|
NoDockWidgetFeatures
|
||||||
|
};
|
||||||
|
typedef QFlags<ads::CDockWidget::DockWidgetFeature> DockWidgetFeatures;
|
||||||
|
|
||||||
|
enum eState
|
||||||
|
{
|
||||||
|
StateHidden,
|
||||||
|
StateDocked,
|
||||||
|
StateFloating
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eInsertMode
|
||||||
|
{
|
||||||
|
AutoScrollArea,
|
||||||
|
ForceScrollArea,
|
||||||
|
ForceNoScrollArea
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eToggleViewActionMode
|
||||||
|
{
|
||||||
|
ActionModeToggle,
|
||||||
|
ActionModeShow
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
CDockWidget(const QString &title, QWidget* parent /TransferThis/ = 0);
|
||||||
|
virtual ~CDockWidget();
|
||||||
|
virtual QSize minimumSizeHint() const;
|
||||||
|
void setWidget(QWidget* widget /Transfer/, ads::CDockWidget::eInsertMode InsertMode = AutoScrollArea);
|
||||||
|
QWidget* takeWidget() /TransferBack/;
|
||||||
|
QWidget* widget() const;
|
||||||
|
ads::CDockWidgetTab* tabWidget() const;
|
||||||
|
void setFeatures(ads::CDockWidget::DockWidgetFeatures features);
|
||||||
|
void setFeature(ads::CDockWidget::DockWidgetFeature flag, bool on);
|
||||||
|
ads::CDockWidget::DockWidgetFeatures features() const;
|
||||||
|
ads::CDockManager* dockManager() const;
|
||||||
|
ads::CDockContainerWidget* dockContainer() const;
|
||||||
|
ads::CDockAreaWidget* dockAreaWidget() const;
|
||||||
|
bool isFloating() const;
|
||||||
|
bool isInFloatingContainer() const;
|
||||||
|
bool isClosed() const;
|
||||||
|
QAction* toggleViewAction() const;
|
||||||
|
void setToggleViewActionMode(ads::CDockWidget::eToggleViewActionMode Mode);
|
||||||
|
void setIcon(const QIcon& Icon);
|
||||||
|
QIcon icon() const;
|
||||||
|
QToolBar* toolBar() const;
|
||||||
|
QToolBar* createDefaultToolBar();
|
||||||
|
void setToolBar(QToolBar* ToolBar);
|
||||||
|
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);
|
||||||
|
QSize toolBarIconSize(eState State) const;
|
||||||
|
void setTabToolTip(const QString &text);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool event(QEvent *e);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void toggleView(bool Open = true);
|
||||||
|
void setFloating();
|
||||||
|
void deleteDockWidget();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void viewToggled(bool Open);
|
||||||
|
void closed();
|
||||||
|
void titleChanged(const QString& Title);
|
||||||
|
void topLevelChanged(bool topLevel);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
50
sip/DockWidgetTab.sip
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockWidgetTab : QFrame
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockWidgetTab.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void mousePressEvent(QMouseEvent* ev);
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent* ev);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent* ev);
|
||||||
|
virtual void contextMenuEvent(QContextMenuEvent* ev);
|
||||||
|
virtual void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDockWidgetTab(ads::CDockWidget* DockWidget /TransferThis/, QWidget* parent /TransferThis/ = 0);
|
||||||
|
virtual ~CDockWidgetTab();
|
||||||
|
bool isActiveTab() const;
|
||||||
|
void setActiveTab(bool active);
|
||||||
|
ads::CDockWidget* dockWidget() const;
|
||||||
|
void setDockAreaWidget(ads::CDockAreaWidget* DockArea /Transfer/);
|
||||||
|
ads::CDockAreaWidget* dockAreaWidget() const;
|
||||||
|
void setIcon(const QIcon& Icon);
|
||||||
|
const QIcon& icon() const;
|
||||||
|
QString text() const;
|
||||||
|
void setText(const QString& title);
|
||||||
|
bool isClosable() const;
|
||||||
|
virtual bool event(QEvent *e);
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void setVisible(bool visible);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void activeTabChanged();
|
||||||
|
void clicked();
|
||||||
|
void closeRequested();
|
||||||
|
void closeOtherTabsRequested();
|
||||||
|
void moved(const QPoint& GlobalPos);
|
||||||
|
}; // class DockWidgetTab
|
||||||
|
};
|
||||||
|
// namespace ads
|
||||||
|
|
||||||
|
%End
|
||||||
21
sip/DockingStateReader.sip
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDockingStateReader : QXmlStreamReader
|
||||||
|
{
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <DockingStateReader.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setFileVersion(int FileVersion);
|
||||||
|
int fileVersion() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
40
sip/ElidingLabel.sip
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CElidingLabel : QLabel
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <ElidingLabel.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent* event);
|
||||||
|
virtual void resizeEvent( QResizeEvent *event );
|
||||||
|
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);
|
||||||
|
virtual ~CElidingLabel();
|
||||||
|
Qt::TextElideMode elideMode() const;
|
||||||
|
void setElideMode(Qt::TextElideMode mode);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual QSize minimumSizeHint() const;
|
||||||
|
virtual QSize sizeHint() const;
|
||||||
|
void setText(const QString &text);
|
||||||
|
QString text() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void clicked();
|
||||||
|
void doubleClicked();
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
65
sip/FloatingDockContainer.sip
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class IFloatingWidget
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <FloatingDockContainer.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
|
ads::eDragState DragState, QWidget* MouseEventHandler) = 0;
|
||||||
|
|
||||||
|
virtual void moveFloating() = 0;
|
||||||
|
virtual void finishDragging() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CFloatingDockContainer : QWidget, ads::IFloatingWidget
|
||||||
|
{
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <FloatingDockContainer.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
|
ads::eDragState DragState, QWidget* MouseEventHandler);
|
||||||
|
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
|
QWidget* MouseEventHandler);
|
||||||
|
virtual void finishDragging();
|
||||||
|
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size);
|
||||||
|
void moveFloating();
|
||||||
|
bool restoreState(ads::CDockingStateReader& Stream, bool Testing);
|
||||||
|
void updateWindowTitle();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void changeEvent(QEvent *event);
|
||||||
|
virtual void moveEvent(QMoveEvent *event);
|
||||||
|
virtual bool event(QEvent *e);
|
||||||
|
virtual void closeEvent(QCloseEvent *event);
|
||||||
|
virtual void hideEvent(QHideEvent *event);
|
||||||
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
virtual bool eventFilter(QObject *watched, QEvent *event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CFloatingDockContainer(ads::CDockManager* DockManager /TransferThis/);
|
||||||
|
CFloatingDockContainer(ads::CDockAreaWidget* DockArea /TransferThis/);
|
||||||
|
CFloatingDockContainer(ads::CDockWidget* DockWidget /TransferThis/);
|
||||||
|
virtual ~CFloatingDockContainer();
|
||||||
|
ads::CDockContainerWidget* dockContainer() const;
|
||||||
|
bool isClosable() const;
|
||||||
|
bool hasTopLevelDockWidget() const;
|
||||||
|
ads::CDockWidget* topLevelDockWidget() const;
|
||||||
|
QList<ads::CDockWidget*> dockWidgets() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
38
sip/FloatingDragPreview.sip
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CFloatingDragPreview : QWidget, ads::IFloatingWidget
|
||||||
|
{
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <FloatingDragPreview.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
CFloatingDragPreview(ads::CDockWidget* Content /TransferThis/ );
|
||||||
|
CFloatingDragPreview(ads::CDockAreaWidget* Content /TransferThis/ );
|
||||||
|
|
||||||
|
virtual ~CFloatingDragPreview();
|
||||||
|
|
||||||
|
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||||
|
|
||||||
|
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
|
ads::eDragState DragState, QWidget* MouseEventHandler);
|
||||||
|
|
||||||
|
virtual void moveFloating();
|
||||||
|
|
||||||
|
virtual void finishDragging();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void draggingCanceled();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
28
sip/IconProvider.sip
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
class CIconProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <IconProvider.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
CIconProvider();
|
||||||
|
|
||||||
|
virtual ~CIconProvider();
|
||||||
|
|
||||||
|
QIcon customIcon(eIcon IconId);
|
||||||
|
|
||||||
|
void registerCustomIcon(eIcon IconId, const QIcon& icon /TransferThis/ );
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
23
sip/ads.sip
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
%Module(name=PyQtAds.QtAds.ads, call_super_init=True, keyword_arguments="Optional", use_limited_api=True)
|
||||||
|
%Import QtCore/QtCoremod.sip
|
||||||
|
%DefaultSupertype sip.simplewrapper
|
||||||
|
%Platforms {Linux macOS Windows}
|
||||||
|
|
||||||
|
%Include ads_globals.sip
|
||||||
|
%Include DockWidget.sip
|
||||||
|
%Include DockAreaTabBar.sip
|
||||||
|
%Include DockAreaTitleBar.sip
|
||||||
|
%Include DockAreaWidget.sip
|
||||||
|
%Include DockContainerWidget.sip
|
||||||
|
%Include DockingStateReader.sip
|
||||||
|
%Include DockManager.sip
|
||||||
|
%Include DockOverlay.sip
|
||||||
|
%Include DockSplitter.sip
|
||||||
|
%Include DockWidgetTab.sip
|
||||||
|
%Include ElidingLabel.sip
|
||||||
|
%Include FloatingDockContainer.sip
|
||||||
|
%Include FloatingDragPreview.sip
|
||||||
|
%Include IconProvider.sip
|
||||||
|
%If (Linux)
|
||||||
|
%Include linux/FloatingWidgetTitleBar.sip
|
||||||
|
%End
|
||||||
54
sip/ads_globals.sip
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <ads_globals.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
enum DockWidgetArea
|
||||||
|
{
|
||||||
|
NoDockWidgetArea,
|
||||||
|
LeftDockWidgetArea,
|
||||||
|
RightDockWidgetArea,
|
||||||
|
TopDockWidgetArea,
|
||||||
|
BottomDockWidgetArea,
|
||||||
|
CenterDockWidgetArea,
|
||||||
|
|
||||||
|
InvalidDockWidgetArea,
|
||||||
|
OuterDockAreas,
|
||||||
|
AllDockAreas
|
||||||
|
};
|
||||||
|
typedef QFlags<ads::DockWidgetArea> DockWidgetAreas;
|
||||||
|
|
||||||
|
|
||||||
|
enum TitleBarButton
|
||||||
|
{
|
||||||
|
TitleBarButtonTabsMenu,
|
||||||
|
TitleBarButtonUndock,
|
||||||
|
TitleBarButtonClose
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eDragState
|
||||||
|
{
|
||||||
|
DraggingInactive,
|
||||||
|
DraggingMousePressed,
|
||||||
|
DraggingTab,
|
||||||
|
DraggingFloatingWidget
|
||||||
|
};
|
||||||
|
|
||||||
|
enum eIcon
|
||||||
|
{
|
||||||
|
TabCloseIcon,
|
||||||
|
DockAreaMenuIcon,
|
||||||
|
DockAreaUndockIcon,
|
||||||
|
DockAreaCloseIcon,
|
||||||
|
|
||||||
|
IconCount,
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
31
sip/linux/FloatingWidgetTitleBar.sip
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
%Import QtWidgets/QtWidgetsmod.sip
|
||||||
|
|
||||||
|
%If (Qt_5_0_0 -)
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include <FloatingWidgetTitleBar.h>
|
||||||
|
%End
|
||||||
|
|
||||||
|
class CFloatingWidgetTitleBar : QWidget
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void mousePressEvent(QMouseEvent *ev);
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent *ev);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *ev);
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CFloatingWidgetTitleBar(CFloatingDockContainer *parent /TransferThis/ = 0);
|
||||||
|
virtual ~CFloatingWidgetTitleBar();
|
||||||
|
void enableCloseButton(bool Enable);
|
||||||
|
void setTitle(const QString &Text);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void closeRequested();
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%End
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
#include <FloatingDragPreview.h>
|
||||||
#include "DockAreaTabBar.h"
|
#include "DockAreaTabBar.h"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
@@ -55,10 +56,11 @@ struct DockAreaTabBarPrivate
|
|||||||
CDockAreaTabBar* _this;
|
CDockAreaTabBar* _this;
|
||||||
QPoint DragStartMousePos;
|
QPoint DragStartMousePos;
|
||||||
CDockAreaWidget* DockArea;
|
CDockAreaWidget* DockArea;
|
||||||
CFloatingDockContainer* FloatingWidget = nullptr;
|
IFloatingWidget* FloatingWidget = nullptr;
|
||||||
QWidget* TabsContainerWidget;
|
QWidget* TabsContainerWidget;
|
||||||
QBoxLayout* TabsLayout;
|
QBoxLayout* TabsLayout;
|
||||||
int CurrentIndex = -1;
|
int CurrentIndex = -1;
|
||||||
|
eDragState DragState = DraggingInactive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@@ -70,6 +72,14 @@ struct DockAreaTabBarPrivate
|
|||||||
* The function reassigns the stylesheet to update the tabs
|
* The function reassigns the stylesheet to update the tabs
|
||||||
*/
|
*/
|
||||||
void updateTabs();
|
void updateTabs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test function for current drag state
|
||||||
|
*/
|
||||||
|
bool isDraggingState(eDragState dragState) const
|
||||||
|
{
|
||||||
|
return this->DragState == dragState;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// struct DockAreaTabBarPrivate
|
// struct DockAreaTabBarPrivate
|
||||||
|
|
||||||
@@ -113,7 +123,7 @@ CDockAreaTabBar::CDockAreaTabBar(CDockAreaWidget* parent) :
|
|||||||
d(new DockAreaTabBarPrivate(this))
|
d(new DockAreaTabBarPrivate(this))
|
||||||
{
|
{
|
||||||
d->DockArea = parent;
|
d->DockArea = parent;
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
setFrameStyle(QFrame::NoFrame);
|
setFrameStyle(QFrame::NoFrame);
|
||||||
setWidgetResizable(true);
|
setWidgetResizable(true);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
@@ -160,9 +170,10 @@ void CDockAreaTabBar::mousePressEvent(QMouseEvent* ev)
|
|||||||
{
|
{
|
||||||
ev->accept();
|
ev->accept();
|
||||||
d->DragStartMousePos = ev->pos();
|
d->DragStartMousePos = ev->pos();
|
||||||
|
d->DragState = DraggingMousePressed;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QScrollArea::mousePressEvent(ev);
|
Super::mousePressEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -171,30 +182,37 @@ void CDockAreaTabBar::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
{
|
{
|
||||||
if (ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
qDebug() << "CTabsScrollArea::mouseReleaseEvent";
|
ADS_PRINT("CDockAreaTabBar::mouseReleaseEvent");
|
||||||
ev->accept();
|
ev->accept();
|
||||||
d->FloatingWidget = nullptr;
|
auto CurrentDragState = d->DragState;
|
||||||
d->DragStartMousePos = QPoint();
|
d->DragStartMousePos = QPoint();
|
||||||
|
d->DragState = DraggingInactive;
|
||||||
|
if (DraggingFloatingWidget == CurrentDragState)
|
||||||
|
{
|
||||||
|
d->FloatingWidget->finishDragging();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QScrollArea::mouseReleaseEvent(ev);
|
Super::mouseReleaseEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
QScrollArea::mouseMoveEvent(ev);
|
Super::mouseMoveEvent(ev);
|
||||||
if (ev->buttons() != Qt::LeftButton)
|
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||||
{
|
{
|
||||||
|
d->DragState = DraggingInactive;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->FloatingWidget)
|
// move floating window
|
||||||
{
|
if (d->isDraggingState(DraggingFloatingWidget))
|
||||||
d->FloatingWidget->moveFloating();
|
{
|
||||||
return;
|
d->FloatingWidget->moveFloating();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If this is the last dock area in a dock container it does not make
|
// 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
|
// sense to move it to a new floating widget and leave this one
|
||||||
@@ -205,10 +223,17 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If one single dock widget in this area is not floatable then the whole
|
||||||
|
// area is not floatable
|
||||||
|
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int DragDistance = (d->DragStartMousePos - ev->pos()).manhattanLength();
|
int DragDistance = (d->DragStartMousePos - ev->pos()).manhattanLength();
|
||||||
if (DragDistance >= CDockManager::startDragDistance())
|
if (DragDistance >= CDockManager::startDragDistance())
|
||||||
{
|
{
|
||||||
qDebug() << "CTabsScrollArea::startFloating";
|
ADS_PRINT("CTabsScrollArea::startFloating");
|
||||||
startFloating(d->DragStartMousePos);
|
startFloating(d->DragStartMousePos);
|
||||||
auto Overlay = d->DockArea->dockManager()->containerOverlay();
|
auto Overlay = d->DockArea->dockManager()->containerOverlay();
|
||||||
Overlay->setAllowedAreas(OuterDockAreas);
|
Overlay->setAllowedAreas(OuterDockAreas);
|
||||||
@@ -228,30 +253,56 @@ void CDockAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
startFloating(event->pos());
|
|
||||||
|
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
makeAreaFloating(event->pos(), DraggingInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer* CDockAreaTabBar::makeAreaFloating(const QPoint& Pos)
|
IFloatingWidget* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset, eDragState DragState)
|
||||||
{
|
{
|
||||||
QSize Size = d->DockArea->size();
|
QSize Size = d->DockArea->size();
|
||||||
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(d->DockArea);
|
d->DragState = DragState;
|
||||||
FloatingWidget->startFloating(Pos, Size);
|
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
|
||||||
auto TopLevelDockWidget = FloatingWidget->topLevelDockWidget();
|
(DraggingFloatingWidget != DragState);
|
||||||
if (TopLevelDockWidget)
|
CFloatingDockContainer* FloatingDockContainer = nullptr;
|
||||||
|
IFloatingWidget* FloatingWidget;
|
||||||
|
if (OpaqueUndocking)
|
||||||
{
|
{
|
||||||
TopLevelDockWidget->emitTopLevelChanged(true);
|
FloatingWidget = FloatingDockContainer = new CFloatingDockContainer(d->DockArea);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto w = new CFloatingDragPreview(d->DockArea);
|
||||||
|
connect(w, &CFloatingDragPreview::draggingCanceled, [=]()
|
||||||
|
{
|
||||||
|
d->DragState = DraggingInactive;
|
||||||
|
});
|
||||||
|
FloatingWidget = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
FloatingWidget->startFloating(Offset, Size, DragState, nullptr);
|
||||||
|
if (FloatingDockContainer)
|
||||||
|
{
|
||||||
|
auto TopLevelDockWidget = FloatingDockContainer->topLevelDockWidget();
|
||||||
|
if (TopLevelDockWidget)
|
||||||
|
{
|
||||||
|
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return FloatingWidget;
|
return FloatingWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTabBar::startFloating(const QPoint& Pos)
|
void CDockAreaTabBar::startFloating(const QPoint& Offset)
|
||||||
{
|
{
|
||||||
d->FloatingWidget = makeAreaFloating(Pos);
|
d->FloatingWidget = makeAreaFloating(Offset, DraggingFloatingWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -308,7 +359,7 @@ void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "CDockAreaTabBar::removeTab ";
|
ADS_PRINT("CDockAreaTabBar::removeTab ");
|
||||||
int NewCurrentIndex = currentIndex();
|
int NewCurrentIndex = currentIndex();
|
||||||
int RemoveIndex = d->TabsLayout->indexOf(Tab);
|
int RemoveIndex = d->TabsLayout->indexOf(Tab);
|
||||||
if (count() == 1)
|
if (count() == 1)
|
||||||
@@ -351,7 +402,7 @@ void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab)
|
|||||||
d->TabsLayout->removeWidget(Tab);
|
d->TabsLayout->removeWidget(Tab);
|
||||||
Tab->disconnect(this);
|
Tab->disconnect(this);
|
||||||
Tab->removeEventFilter(this);
|
Tab->removeEventFilter(this);
|
||||||
qDebug() << "NewCurrentIndex " << NewCurrentIndex;
|
ADS_PRINT("NewCurrentIndex " << NewCurrentIndex);
|
||||||
if (NewCurrentIndex != d->CurrentIndex)
|
if (NewCurrentIndex != d->CurrentIndex)
|
||||||
{
|
{
|
||||||
setCurrentIndex(NewCurrentIndex);
|
setCurrentIndex(NewCurrentIndex);
|
||||||
@@ -421,7 +472,13 @@ void CDockAreaTabBar::onCloseOtherTabsRequested()
|
|||||||
auto Tab = tab(i);
|
auto Tab = tab(i);
|
||||||
if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender)
|
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);
|
closeTab(i);
|
||||||
|
i -= Offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,7 +536,7 @@ void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos)
|
|||||||
{
|
{
|
||||||
if (MousePos.x() > tab(count() - 1)->geometry().right())
|
if (MousePos.x() > tab(count() - 1)->geometry().right())
|
||||||
{
|
{
|
||||||
qDebug() << "after all tabs";
|
ADS_PRINT("after all tabs");
|
||||||
toIndex = count() - 1;
|
toIndex = count() - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -492,7 +549,7 @@ void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos)
|
|||||||
d->TabsLayout->insertWidget(toIndex, MovingTab);
|
d->TabsLayout->insertWidget(toIndex, MovingTab);
|
||||||
if (toIndex >= 0)
|
if (toIndex >= 0)
|
||||||
{
|
{
|
||||||
qDebug() << "tabMoved from " << fromIndex << " to " << toIndex;
|
ADS_PRINT("tabMoved from " << fromIndex << " to " << toIndex);
|
||||||
emit tabMoved(fromIndex, toIndex);
|
emit tabMoved(fromIndex, toIndex);
|
||||||
setCurrentIndex(toIndex);
|
setCurrentIndex(toIndex);
|
||||||
}
|
}
|
||||||
@@ -512,8 +569,8 @@ void CDockAreaTabBar::closeTab(int Index)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit tabCloseRequested(Index);
|
|
||||||
Tab->hide();
|
Tab->hide();
|
||||||
|
emit tabCloseRequested(Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -552,6 +609,31 @@ bool CDockAreaTabBar::isTabOpen(int Index) const
|
|||||||
return !tab(Index)->isHidden();
|
return !tab(Index)->isHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
QSize CDockAreaTabBar::minimumSizeHint() const
|
||||||
|
{
|
||||||
|
QSize Size = sizeHint();
|
||||||
|
Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area
|
||||||
|
return Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
QSize CDockAreaTabBar::sizeHint() const
|
||||||
|
{
|
||||||
|
QSize Size = Super::sizeHint();
|
||||||
|
Size.setHeight(d->TabsContainerWidget->sizeHint().height());
|
||||||
|
return Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
eDragState CDockAreaTabBar::dragState() const
|
||||||
|
{
|
||||||
|
return d->DragState;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
#include "ads_globals.h"
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
@@ -38,18 +39,23 @@ class CDockWidgetTab;
|
|||||||
struct DockAreaTabBarPrivate;
|
struct DockAreaTabBarPrivate;
|
||||||
class CDockAreaTitleBar;
|
class CDockAreaTitleBar;
|
||||||
class CFloatingDockContainer;
|
class CFloatingDockContainer;
|
||||||
|
class IFloatingWidget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom tabbar implementation for tab area that is shown on top of a
|
* Custom tabbar implementation for tab area that is shown on top of a
|
||||||
* dock area widget.
|
* dock area widget.
|
||||||
* The tabbar displays the tab widgets of the contained dock widgets.
|
* The tabbar displays the tab widgets of the contained dock widgets.
|
||||||
|
* We cannot use QTabBar here because it does a lot of fancy animations
|
||||||
|
* that will crash the application if a tab is removed while the animation
|
||||||
|
* has not finished. And we need to remove a tab, if the user drags a
|
||||||
|
* a dock widget out of a group of tabbed widgets
|
||||||
*/
|
*/
|
||||||
class CDockAreaTabBar : public QScrollArea
|
class ADS_EXPORT CDockAreaTabBar : public QScrollArea
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
DockAreaTabBarPrivate* d; ///< private data (pimpl)
|
DockAreaTabBarPrivate* d; ///< private data (pimpl)
|
||||||
friend class DockAreaTabBarPrivate;
|
friend struct DockAreaTabBarPrivate;
|
||||||
friend class CDockAreaTitleBar;
|
friend class CDockAreaTitleBar;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -60,6 +66,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void wheelEvent(QWheelEvent* Event) override;
|
virtual void wheelEvent(QWheelEvent* Event) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores mouse position to detect dragging
|
* Stores mouse position to detect dragging
|
||||||
*/
|
*/
|
||||||
@@ -84,16 +91,22 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* Starts floating
|
* Starts floating
|
||||||
*/
|
*/
|
||||||
void startFloating(const QPoint& Pos);
|
void startFloating(const QPoint& Offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes the dock area loating
|
* Makes the dock area floating
|
||||||
*/
|
*/
|
||||||
CFloatingDockContainer* makeAreaFloating(const QPoint& Pos);
|
IFloatingWidget* makeAreaFloating(const QPoint& Offset, eDragState DragState);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current drag state
|
||||||
|
*/
|
||||||
|
eDragState dragState() const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Super = QScrollArea;
|
using Super = QScrollArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
@@ -148,6 +161,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isTabOpen(int Index) const;
|
bool isTabOpen(int Index) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overrides the minimumSizeHint() function of QScrollArea
|
||||||
|
* The minimumSizeHint() is bigger than the sizeHint () for the scroll
|
||||||
|
* area because even if the scrollbars are invisible, the required speace
|
||||||
|
* is reserved in the minimumSizeHint(). This override simply returns
|
||||||
|
* sizeHint();
|
||||||
|
*/
|
||||||
|
virtual QSize minimumSizeHint() const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function provides a sizeHint that matches the height of the
|
||||||
|
* internal viewport.
|
||||||
|
*/
|
||||||
|
virtual QSize sizeHint() const override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* This property sets the index of the tab bar's visible tab
|
* This property sets the index of the tab bar's visible tab
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "DockWidgetTab.h"
|
#include "DockWidgetTab.h"
|
||||||
#include "DockAreaTabBar.h"
|
#include "DockAreaTabBar.h"
|
||||||
|
#include "IconProvider.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
@@ -94,8 +96,36 @@ struct DockAreaTitleBarPrivate
|
|||||||
*/
|
*/
|
||||||
bool testConfigFlag(CDockManager::eConfigFlag Flag) const
|
bool testConfigFlag(CDockManager::eConfigFlag Flag) const
|
||||||
{
|
{
|
||||||
return DockArea->dockManager()->configFlags().testFlag(Flag);
|
return CDockManager::configFlags().testFlag(Flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to set title bar button icons depending on operating
|
||||||
|
* system and to avoid duplicated code. On windows the standard icons
|
||||||
|
* are blurry since Qt 5.11 so we need to do some additional steps.
|
||||||
|
* If the global IconPovider of the dockmanager provides a custom
|
||||||
|
* Icon for the given CustomIconId, the this icon will be used.
|
||||||
|
*/
|
||||||
|
void setTitleBarButtonIcon(tTileBarButton* Button, QStyle::StandardPixmap StandarPixmap,
|
||||||
|
ads::eIcon CustomIconId)
|
||||||
|
{
|
||||||
|
// First we try to use custom icons if available
|
||||||
|
QIcon Icon = CDockManager::iconProvider().customIcon(CustomIconId);
|
||||||
|
if (!Icon.isNull())
|
||||||
|
{
|
||||||
|
Button->setIcon(Icon);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
Button->setIcon(_this->style()->standardIcon(StandarPixmap));
|
||||||
|
#else
|
||||||
|
QPixmap normalPixmap = _this->style()->standardPixmap(StandarPixmap, 0, Button);
|
||||||
|
Icon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
|
||||||
|
Icon.addPixmap(normalPixmap, QIcon::Normal);
|
||||||
|
Button->setIcon(Icon);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
};// struct DockAreaTitleBarPrivate
|
};// struct DockAreaTitleBarPrivate
|
||||||
|
|
||||||
|
|
||||||
@@ -111,42 +141,47 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void DockAreaTitleBarPrivate::createButtons()
|
void DockAreaTitleBarPrivate::createButtons()
|
||||||
{
|
{
|
||||||
|
QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||||
|
// Tabs menu button
|
||||||
TabsMenuButton = new tTileBarButton();
|
TabsMenuButton = new tTileBarButton();
|
||||||
TabsMenuButton->setObjectName("tabsMenuButton");
|
TabsMenuButton->setObjectName("tabsMenuButton");
|
||||||
TabsMenuButton->setAutoRaise(true);
|
TabsMenuButton->setAutoRaise(true);
|
||||||
TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
|
TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
|
||||||
TabsMenuButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton));
|
setTitleBarButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton, ads::DockAreaMenuIcon);
|
||||||
|
|
||||||
QMenu* TabsMenu = new QMenu(TabsMenuButton);
|
QMenu* TabsMenu = new QMenu(TabsMenuButton);
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
|
TabsMenu->setToolTipsVisible(true);
|
||||||
|
#endif
|
||||||
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
|
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
|
||||||
TabsMenuButton->setMenu(TabsMenu);
|
TabsMenuButton->setMenu(TabsMenu);
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
TabsMenuButton->setToolTip(QObject::tr("List all tabs"));
|
TabsMenuButton->setToolTip(QObject::tr("List all tabs"));
|
||||||
TabsMenuButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
#endif
|
||||||
|
TabsMenuButton->setSizePolicy(ButtonSizePolicy);
|
||||||
TopLayout->addWidget(TabsMenuButton, 0);
|
TopLayout->addWidget(TabsMenuButton, 0);
|
||||||
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
|
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
|
||||||
SLOT(onTabsMenuActionTriggered(QAction*)));
|
SLOT(onTabsMenuActionTriggered(QAction*)));
|
||||||
|
|
||||||
|
|
||||||
// Undock button
|
// Undock button
|
||||||
UndockButton = new tTileBarButton();
|
UndockButton = new tTileBarButton();
|
||||||
UndockButton->setObjectName("undockButton");
|
UndockButton->setObjectName("undockButton");
|
||||||
UndockButton->setAutoRaise(true);
|
UndockButton->setAutoRaise(true);
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
UndockButton->setToolTip(QObject::tr("Detach Group"));
|
UndockButton->setToolTip(QObject::tr("Detach Group"));
|
||||||
UndockButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarNormalButton));
|
#endif
|
||||||
UndockButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton, ads::DockAreaUndockIcon);
|
||||||
|
UndockButton->setSizePolicy(ButtonSizePolicy);
|
||||||
TopLayout->addWidget(UndockButton, 0);
|
TopLayout->addWidget(UndockButton, 0);
|
||||||
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
|
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
|
||||||
|
|
||||||
|
|
||||||
|
// Close button
|
||||||
CloseButton = new tTileBarButton();
|
CloseButton = new tTileBarButton();
|
||||||
CloseButton->setObjectName("closeButton");
|
CloseButton->setObjectName("closeButton");
|
||||||
CloseButton->setAutoRaise(true);
|
CloseButton->setAutoRaise(true);
|
||||||
|
setTitleBarButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
|
||||||
// The standard icons do not look good on high DPI screens
|
#ifndef QT_NO_TOOLTIP
|
||||||
QIcon CloseIcon = _this->style()->standardIcon(QStyle::SP_TitleBarCloseButton);
|
|
||||||
QPixmap normalPixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, CloseButton);
|
|
||||||
QPixmap disabledPixmap = internal::createTransparentPixmap(normalPixmap, 0.25);
|
|
||||||
CloseIcon.addPixmap(disabledPixmap, QIcon::Disabled);
|
|
||||||
|
|
||||||
CloseButton->setIcon(CloseIcon);
|
|
||||||
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
||||||
{
|
{
|
||||||
CloseButton->setToolTip(QObject::tr("Close Active Tab"));
|
CloseButton->setToolTip(QObject::tr("Close Active Tab"));
|
||||||
@@ -155,8 +190,13 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
{
|
{
|
||||||
CloseButton->setToolTip(QObject::tr("Close Group"));
|
CloseButton->setToolTip(QObject::tr("Close Group"));
|
||||||
}
|
}
|
||||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
#endif
|
||||||
TopLayout->addWidget(CloseButton, 0);
|
CloseButton->setSizePolicy(ButtonSizePolicy);
|
||||||
|
CloseButton->setIconSize(QSize(16, 16));
|
||||||
|
if (testConfigFlag(CDockManager::DockAreaHasCloseButton))
|
||||||
|
{
|
||||||
|
TopLayout->addWidget(CloseButton, 0);
|
||||||
|
}
|
||||||
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
|
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +213,10 @@ void DockAreaTitleBarPrivate::createTabBar()
|
|||||||
_this->connect(TabBar, SIGNAL(tabMoved(int, int)), SLOT(markTabsMenuOutdated()));
|
_this->connect(TabBar, SIGNAL(tabMoved(int, int)), SLOT(markTabsMenuOutdated()));
|
||||||
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int)));
|
_this->connect(TabBar, SIGNAL(currentChanged(int)), SLOT(onCurrentTabChanged(int)));
|
||||||
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
|
_this->connect(TabBar, SIGNAL(tabBarClicked(int)), SIGNAL(tabBarClicked(int)));
|
||||||
|
|
||||||
|
TabBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
_this->connect(TabBar, SIGNAL(customContextMenuRequested(const QPoint&)),
|
||||||
|
SLOT(showContextMenu(const QPoint&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -235,6 +279,9 @@ void CDockAreaTitleBar::onTabsMenuAboutToShow()
|
|||||||
}
|
}
|
||||||
auto Tab = d->TabBar->tab(i);
|
auto Tab = d->TabBar->tab(i);
|
||||||
QAction* Action = menu->addAction(Tab->icon(), Tab->text());
|
QAction* Action = menu->addAction(Tab->icon(), Tab->text());
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
|
Action->setToolTip(Tab->toolTip());
|
||||||
|
#endif
|
||||||
Action->setData(i);
|
Action->setData(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +292,7 @@ void CDockAreaTitleBar::onTabsMenuAboutToShow()
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTitleBar::onCloseButtonClicked()
|
void CDockAreaTitleBar::onCloseButtonClicked()
|
||||||
{
|
{
|
||||||
qDebug() << "CDockAreaTitleBar::onCloseButtonClicked";
|
ADS_PRINT("CDockAreaTitleBar::onCloseButtonClicked");
|
||||||
if (d->testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
if (d->testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
||||||
{
|
{
|
||||||
d->TabBar->closeTab(d->TabBar->currentIndex());
|
d->TabBar->closeTab(d->TabBar->currentIndex());
|
||||||
@@ -260,7 +307,10 @@ void CDockAreaTitleBar::onCloseButtonClicked()
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTitleBar::onUndockButtonClicked()
|
void CDockAreaTitleBar::onUndockButtonClicked()
|
||||||
{
|
{
|
||||||
d->TabBar->makeAreaFloating(mapFromGlobal(QCursor::pos()));
|
if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
|
{
|
||||||
|
d->TabBar->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -307,6 +357,26 @@ QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const
|
|||||||
void CDockAreaTitleBar::setVisible(bool Visible)
|
void CDockAreaTitleBar::setVisible(bool Visible)
|
||||||
{
|
{
|
||||||
Super::setVisible(Visible);
|
Super::setVisible(Visible);
|
||||||
|
markTabsMenuOutdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
|
||||||
|
{
|
||||||
|
if (d->TabBar->dragState() == DraggingFloatingWidget)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu Menu(this);
|
||||||
|
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
|
||||||
|
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||||
|
Menu.addSeparator();
|
||||||
|
Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
|
||||||
|
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||||
|
Menu.addAction(tr("Close Other Areas"), d->DockArea, SLOT(closeOtherAreas()));
|
||||||
|
Menu.exec(mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,22 +43,32 @@ class CDockAreaWidget;
|
|||||||
struct DockAreaTitleBarPrivate;
|
struct DockAreaTitleBarPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title bar of a dock area
|
* Title bar of a dock area.
|
||||||
|
* The title bar contains a tabbar with all tabs for a dock widget group and
|
||||||
|
* with a tabs menu button, a undock button and a close button.
|
||||||
*/
|
*/
|
||||||
class CDockAreaTitleBar : public QFrame
|
class ADS_EXPORT CDockAreaTitleBar : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
DockAreaTitleBarPrivate* d; ///< private data (pimpl)
|
DockAreaTitleBarPrivate* d; ///< private data (pimpl)
|
||||||
friend class DockAreaTitleBarPrivate;
|
friend struct DockAreaTitleBarPrivate;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void markTabsMenuOutdated();
|
|
||||||
void onTabsMenuAboutToShow();
|
void onTabsMenuAboutToShow();
|
||||||
void onCloseButtonClicked();
|
void onCloseButtonClicked();
|
||||||
void onUndockButtonClicked();
|
void onUndockButtonClicked();
|
||||||
void onTabsMenuActionTriggered(QAction* Action);
|
void onTabsMenuActionTriggered(QAction* Action);
|
||||||
void onCurrentTabChanged(int Index);
|
void onCurrentTabChanged(int Index);
|
||||||
|
void showContextMenu(const QPoint& pos);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* Call this slot to tell the title bar that it should update the tabs menu
|
||||||
|
* the next time it is shown.
|
||||||
|
*/
|
||||||
|
void markTabsMenuOutdated();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Super = QFrame;
|
using Super = QFrame;
|
||||||
@@ -83,10 +93,12 @@ public:
|
|||||||
QAbstractButton* button(TitleBarButton which) const;
|
QAbstractButton* button(TitleBarButton which) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is here for debug reasons
|
* Marks the tabs menu outdated before it calls its base class
|
||||||
|
* implementation
|
||||||
*/
|
*/
|
||||||
virtual void setVisible(bool Visible) override;
|
virtual void setVisible(bool Visible) override;
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if a tab in the tab bar is clicked by the user
|
* This signal is emitted if a tab in the tab bar is clicked by the user
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Qt Advanced Docking System
|
** Qt Advanced Docking System
|
||||||
** Copyright (C) 2017 Uwe Kindler
|
** Copyright (C) 2017 Uwe Kindler
|
||||||
**
|
**
|
||||||
** This library is free software; you can redistribute it and/or
|
** This library is free software; you can redistribute it and/or
|
||||||
** modify it under the terms of the GNU Lesser General Public
|
** modify it under the terms of the GNU Lesser General Public
|
||||||
** License as published by the Free Software Foundation; either
|
** License as published by the Free Software Foundation; either
|
||||||
** version 2.1 of the License, or (at your option) any later version.
|
** 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,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
** You should have received a copy of the GNU Lesser General Public
|
** 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/>.
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <DockWidgetTab.h>
|
#include "DockWidgetTab.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
|
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
@@ -61,13 +61,13 @@ namespace ads
|
|||||||
{
|
{
|
||||||
static const char* const INDEX_PROPERTY = "index";
|
static const char* const INDEX_PROPERTY = "index";
|
||||||
static const char* const ACTION_PROPERTY = "action";
|
static const char* const ACTION_PROPERTY = "action";
|
||||||
static const char* const DOCKWIDGET_PROPERTY = "dockwidget";
|
|
||||||
static const int APPEND = -1;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New dock area layout mimics stack layout but only inserts the current
|
* Internal dock area layout mimics stack layout but only inserts the current
|
||||||
* widget into the internal QLayout object
|
* widget into the internal QLayout object.
|
||||||
|
* \warning Only the current widget has a parent. All other widgets
|
||||||
|
* do not have a parent. That means, a widget that is in this layout may
|
||||||
|
* return nullptr for its parent() function if it is not the current widget.
|
||||||
*/
|
*/
|
||||||
class CDockAreaLayout
|
class CDockAreaLayout
|
||||||
{
|
{
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void insertWidget(int index, QWidget* Widget)
|
void insertWidget(int index, QWidget* Widget)
|
||||||
{
|
{
|
||||||
Widget->setParent(0);
|
Widget->setParent(nullptr);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
index = m_Widgets.count();
|
index = m_Widgets.count();
|
||||||
@@ -121,7 +121,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given widget from the lyout
|
* Removes the given widget from the layout
|
||||||
*/
|
*/
|
||||||
void removeWidget(QWidget* Widget)
|
void removeWidget(QWidget* Widget)
|
||||||
{
|
{
|
||||||
@@ -130,7 +130,7 @@ public:
|
|||||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
auto LayoutItem = m_ParentLayout->takeAt(1);
|
||||||
if (LayoutItem)
|
if (LayoutItem)
|
||||||
{
|
{
|
||||||
LayoutItem->widget()->setParent(0);
|
LayoutItem->widget()->setParent(nullptr);
|
||||||
}
|
}
|
||||||
m_CurrentWidget = nullptr;
|
m_CurrentWidget = nullptr;
|
||||||
m_CurrentIndex = -1;
|
m_CurrentIndex = -1;
|
||||||
@@ -170,7 +170,7 @@ public:
|
|||||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
auto LayoutItem = m_ParentLayout->takeAt(1);
|
||||||
if (LayoutItem)
|
if (LayoutItem)
|
||||||
{
|
{
|
||||||
LayoutItem->widget()->setParent(0);
|
LayoutItem->widget()->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ParentLayout->addWidget(next);
|
m_ParentLayout->addWidget(next);
|
||||||
@@ -239,12 +239,12 @@ using DockAreaLayout = CDockAreaLayout;
|
|||||||
*/
|
*/
|
||||||
struct DockAreaWidgetPrivate
|
struct DockAreaWidgetPrivate
|
||||||
{
|
{
|
||||||
CDockAreaWidget* _this;
|
CDockAreaWidget* _this = nullptr;
|
||||||
QBoxLayout* Layout;
|
QBoxLayout* Layout = nullptr;
|
||||||
DockAreaLayout* ContentsLayout;
|
DockAreaLayout* ContentsLayout = nullptr;
|
||||||
CDockAreaTitleBar* TitleBar;
|
CDockAreaTitleBar* TitleBar = nullptr;
|
||||||
CDockManager* DockManager = nullptr;
|
CDockManager* DockManager = nullptr;
|
||||||
bool UpdateCloseButton = false;
|
bool UpdateTitleBarButtons = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@@ -298,9 +298,9 @@ struct DockAreaWidgetPrivate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Udpates the enable state of the close button
|
* Udpates the enable state of the close and detach button
|
||||||
*/
|
*/
|
||||||
void updateCloseButtonState();
|
void updateTitleBarButtonStates();
|
||||||
};
|
};
|
||||||
// struct DockAreaWidgetPrivate
|
// struct DockAreaWidgetPrivate
|
||||||
|
|
||||||
@@ -318,27 +318,26 @@ void DockAreaWidgetPrivate::createTitleBar()
|
|||||||
{
|
{
|
||||||
TitleBar = new CDockAreaTitleBar(_this);
|
TitleBar = new CDockAreaTitleBar(_this);
|
||||||
Layout->addWidget(TitleBar);
|
Layout->addWidget(TitleBar);
|
||||||
_this->connect(tabBar(), SIGNAL(tabCloseRequested(int)),
|
QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
|
||||||
SLOT(onTabCloseRequested(int)));
|
QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
|
||||||
_this->connect(TitleBar, SIGNAL(tabBarClicked(int)),
|
QObject::connect(tabBar(), &CDockAreaTabBar::tabMoved, _this, &CDockAreaWidget::reorderDockWidget);
|
||||||
SLOT(setCurrentIndex(int)));
|
|
||||||
_this->connect(tabBar(), SIGNAL(tabMoved(int, int)),
|
|
||||||
SLOT(reorderDockWidget(int, int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void DockAreaWidgetPrivate::updateCloseButtonState()
|
void DockAreaWidgetPrivate::updateTitleBarButtonStates()
|
||||||
{
|
{
|
||||||
if (_this->isHidden())
|
if (_this->isHidden())
|
||||||
{
|
{
|
||||||
UpdateCloseButton = true;
|
UpdateTitleBarButtons = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleBar->button(TitleBarButtonClose)->setEnabled(
|
TitleBar->button(TitleBarButtonClose)->setEnabled(
|
||||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||||
UpdateCloseButton = false;
|
TitleBar->button(TitleBarButtonUndock)->setEnabled(
|
||||||
|
_this->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||||
|
UpdateTitleBarButtons = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -355,12 +354,16 @@ CDockAreaWidget::CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget
|
|||||||
|
|
||||||
d->createTitleBar();
|
d->createTitleBar();
|
||||||
d->ContentsLayout = new DockAreaLayout(d->Layout);
|
d->ContentsLayout = new DockAreaLayout(d->Layout);
|
||||||
|
if (d->DockManager)
|
||||||
|
{
|
||||||
|
emit d->DockManager->dockAreaCreated(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget::~CDockAreaWidget()
|
CDockAreaWidget::~CDockAreaWidget()
|
||||||
{
|
{
|
||||||
qDebug() << "~CDockAreaWidget()";
|
ADS_PRINT("~CDockAreaWidget()");
|
||||||
delete d->ContentsLayout;
|
delete d->ContentsLayout;
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
@@ -406,28 +409,29 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
|||||||
setCurrentIndex(index);
|
setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
DockWidget->setDockArea(this);
|
DockWidget->setDockArea(this);
|
||||||
d->updateCloseButtonState();
|
d->updateTitleBarButtonStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockAreaWidget::removeDockWidget";
|
ADS_PRINT("CDockAreaWidget::removeDockWidget");
|
||||||
auto NextOpenDockWidget = nextOpenDockWidget(DockWidget);
|
auto NextOpenDockWidget = nextOpenDockWidget(DockWidget);
|
||||||
|
|
||||||
d->ContentsLayout->removeWidget(DockWidget);
|
d->ContentsLayout->removeWidget(DockWidget);
|
||||||
auto TabWidget = DockWidget->tabWidget();
|
auto TabWidget = DockWidget->tabWidget();
|
||||||
TabWidget->hide();
|
TabWidget->hide();
|
||||||
d->tabBar()->removeTab(TabWidget);
|
d->tabBar()->removeTab(TabWidget);
|
||||||
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
if (NextOpenDockWidget)
|
if (NextOpenDockWidget)
|
||||||
{
|
{
|
||||||
setCurrentDockWidget(NextOpenDockWidget);
|
setCurrentDockWidget(NextOpenDockWidget);
|
||||||
}
|
}
|
||||||
else if (d->ContentsLayout->isEmpty())
|
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() > 1)
|
||||||
{
|
{
|
||||||
qDebug() << "Dock Area empty";
|
ADS_PRINT("Dock Area empty");
|
||||||
dockContainer()->removeDockArea(this);
|
DockContainer->removeDockArea(this);
|
||||||
this->deleteLater();
|
this->deleteLater();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -438,16 +442,15 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
hideAreaWithNoVisibleContent();
|
hideAreaWithNoVisibleContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->updateCloseButtonState();
|
d->updateTitleBarButtonStates();
|
||||||
updateTitleBarVisibility();
|
updateTitleBarVisibility();
|
||||||
auto TopLevelDockWidget = dockContainer()->topLevelDockWidget();
|
auto TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
||||||
if (TopLevelDockWidget)
|
if (TopLevelDockWidget)
|
||||||
{
|
{
|
||||||
TopLevelDockWidget->emitTopLevelChanged(true);
|
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (ADS_DEBUG_LEVEL > 0)
|
#if (ADS_DEBUG_LEVEL > 0)
|
||||||
CDockContainerWidget* DockContainer = dockContainer();
|
|
||||||
DockContainer->dumpLayout();
|
DockContainer->dumpLayout();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -487,8 +490,16 @@ void CDockAreaWidget::hideAreaWithNoVisibleContent()
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::onTabCloseRequested(int Index)
|
void CDockAreaWidget::onTabCloseRequested(int Index)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockAreaWidget::onTabCloseRequested " << Index;
|
ADS_PRINT("CDockAreaWidget::onTabCloseRequested " << Index);
|
||||||
dockWidget(Index)->toggleView(false);
|
auto* DockWidget = dockWidget(Index);
|
||||||
|
if (DockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
|
||||||
|
{
|
||||||
|
DockWidget->deleteDockWidget();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DockWidget->toggleView(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -650,11 +661,11 @@ CDockWidget* CDockAreaWidget::dockWidget(int Index) const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::reorderDockWidget(int fromIndex, int toIndex)
|
void CDockAreaWidget::reorderDockWidget(int fromIndex, int toIndex)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockAreaWidget::reorderDockWidget";
|
ADS_PRINT("CDockAreaWidget::reorderDockWidget");
|
||||||
if (fromIndex >= d->ContentsLayout->count() || fromIndex < 0
|
if (fromIndex >= d->ContentsLayout->count() || fromIndex < 0
|
||||||
|| toIndex >= d->ContentsLayout->count() || toIndex < 0 || fromIndex == toIndex)
|
|| toIndex >= d->ContentsLayout->count() || toIndex < 0 || fromIndex == toIndex)
|
||||||
{
|
{
|
||||||
qDebug() << "Invalid index for tab movement" << fromIndex << toIndex;
|
ADS_PRINT("Invalid index for tab movement" << fromIndex << toIndex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,10 +694,24 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget());
|
if (d->TitleBar)
|
||||||
|
{
|
||||||
|
d->TitleBar->setVisible(!Container->isFloating() || !Container->hasTopLevelDockWidget());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaWidget::markTitleBarMenuOutdated()
|
||||||
|
{
|
||||||
|
if (d->TitleBar)
|
||||||
|
{
|
||||||
|
d->TitleBar->markTabsMenuOutdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
||||||
{
|
{
|
||||||
@@ -695,8 +720,8 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
|||||||
auto CurrentDockWidget = currentDockWidget();
|
auto CurrentDockWidget = currentDockWidget();
|
||||||
QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : "";
|
QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : "";
|
||||||
s.writeAttribute("Current", Name);
|
s.writeAttribute("Current", Name);
|
||||||
qDebug() << "CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
|
ADS_PRINT("CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
|
||||||
<< " Current: " << Name;
|
<< " Current: " << Name);
|
||||||
for (int i = 0; i < d->ContentsLayout->count(); ++i)
|
for (int i = 0; i < d->ContentsLayout->count(); ++i)
|
||||||
{
|
{
|
||||||
dockWidget(i)->saveState(s);
|
dockWidget(i)->saveState(s);
|
||||||
@@ -757,9 +782,9 @@ void CDockAreaWidget::toggleView(bool Open)
|
|||||||
void CDockAreaWidget::setVisible(bool Visible)
|
void CDockAreaWidget::setVisible(bool Visible)
|
||||||
{
|
{
|
||||||
Super::setVisible(Visible);
|
Super::setVisible(Visible);
|
||||||
if (d->UpdateCloseButton)
|
if (d->UpdateTitleBarButtons)
|
||||||
{
|
{
|
||||||
d->updateCloseButtonState();
|
d->updateTitleBarButtonStates();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -774,10 +799,27 @@ QAbstractButton* CDockAreaWidget::titleBarButton(TitleBarButton which) const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::closeArea()
|
void CDockAreaWidget::closeArea()
|
||||||
{
|
{
|
||||||
for (auto DockWidget : openedDockWidgets())
|
// If there is only one single dock widget and this widget has the
|
||||||
|
// DeleteOnClose feature, then we delete the dock widget now
|
||||||
|
auto OpenDockWidgets = openedDockWidgets();
|
||||||
|
if (OpenDockWidgets.count() == 1 && OpenDockWidgets[0]->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
|
||||||
{
|
{
|
||||||
DockWidget->toggleView(false);
|
OpenDockWidgets[0]->deleteDockWidget();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto DockWidget : openedDockWidgets())
|
||||||
|
{
|
||||||
|
DockWidget->toggleView(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaWidget::closeOtherAreas()
|
||||||
|
{
|
||||||
|
dockContainer()->closeOtherAreas(this);
|
||||||
}
|
}
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace ads
|
|||||||
struct DockAreaWidgetPrivate;
|
struct DockAreaWidgetPrivate;
|
||||||
class CDockManager;
|
class CDockManager;
|
||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
struct DockContainerWidgetPrivate;
|
class DockContainerWidgetPrivate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,11 +58,12 @@ private:
|
|||||||
DockAreaWidgetPrivate* d; ///< private data (pimpl)
|
DockAreaWidgetPrivate* d; ///< private data (pimpl)
|
||||||
friend struct DockAreaWidgetPrivate;
|
friend struct DockAreaWidgetPrivate;
|
||||||
friend class CDockContainerWidget;
|
friend class CDockContainerWidget;
|
||||||
friend struct DockContainerWidgetPrivate;
|
friend class DockContainerWidgetPrivate;
|
||||||
friend class CDockWidgetTab;
|
friend class CDockWidgetTab;
|
||||||
friend struct DockWidgetPrivate;
|
friend struct DockWidgetPrivate;
|
||||||
friend class CDockWidget;
|
friend class CDockWidget;
|
||||||
friend struct DockManagerPrivate;
|
friend struct DockManagerPrivate;
|
||||||
|
friend class CDockManager;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTabCloseRequested(int Index);
|
void onTabCloseRequested(int Index);
|
||||||
@@ -130,6 +131,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void internalSetCurrentDockWidget(CDockWidget* DockWidget);
|
void internalSetCurrentDockWidget(CDockWidget* DockWidget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks tabs menu to update
|
||||||
|
*/
|
||||||
|
void markTitleBarMenuOutdated();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void toggleView(bool Open);
|
void toggleView(bool Open);
|
||||||
|
|
||||||
@@ -179,12 +185,12 @@ public:
|
|||||||
QList<CDockWidget*> dockWidgets() const;
|
QList<CDockWidget*> dockWidgets() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of dock widgets in this area
|
* Returns the number of open dock widgets in this area
|
||||||
*/
|
*/
|
||||||
int openDockWidgetsCount() const;
|
int openDockWidgetsCount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of dock widgets that are not closed
|
* Returns a list of dock widgets that are not closed.
|
||||||
*/
|
*/
|
||||||
QList<CDockWidget*> openedDockWidgets() const;
|
QList<CDockWidget*> openedDockWidgets() const;
|
||||||
|
|
||||||
@@ -230,8 +236,10 @@ public:
|
|||||||
* This functions returns the dock widget features of all dock widget in
|
* This functions returns the dock widget features of all dock widget in
|
||||||
* this area.
|
* this area.
|
||||||
* A bitwise and is used to combine the flags of all dock widgets. That
|
* A bitwise and is used to combine the flags of all dock widgets. That
|
||||||
* means, if only dock widget does not support a certain flag, the whole
|
* means, if only one single dock widget does not support a certain flag,
|
||||||
* dock are does not support the flag.
|
* the whole dock are does not support the flag. I.e. if one single
|
||||||
|
* dock widget in this area is not closabe, the whole dock are is not
|
||||||
|
* closable.
|
||||||
*/
|
*/
|
||||||
CDockWidget::DockWidgetFeatures features() const;
|
CDockWidget::DockWidgetFeatures features() const;
|
||||||
|
|
||||||
@@ -259,6 +267,11 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void closeArea();
|
void closeArea();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function closes all other areas except of this area
|
||||||
|
*/
|
||||||
|
void closeOtherAreas();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted when user clicks on a tab at an index.
|
* This signal is emitted when user clicks on a tab at an index.
|
||||||
|
|||||||
@@ -42,18 +42,52 @@
|
|||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
#include "DockingStateReader.h"
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "DockOverlay.h"
|
#include "DockOverlay.h"
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
#include "DockSplitter.h"
|
#include "DockSplitter.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#if QT_VERSION < 0x050900
|
||||||
|
|
||||||
|
inline char toHexLower(uint value)
|
||||||
|
{
|
||||||
|
return "0123456789abcdef"[value & 0xF];
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray qByteArrayToHex(const QByteArray& src, char separator)
|
||||||
|
{
|
||||||
|
if(src.size() == 0)
|
||||||
|
return QByteArray();
|
||||||
|
|
||||||
|
const int length = separator ? (src.size() * 3 - 1) : (src.size() * 2);
|
||||||
|
QByteArray hex(length, Qt::Uninitialized);
|
||||||
|
char *hexData = hex.data();
|
||||||
|
const uchar *data = reinterpret_cast<const uchar *>(src.data());
|
||||||
|
for (int i = 0, o = 0; i < src.size(); ++i) {
|
||||||
|
hexData[o++] = toHexLower(data[i] >> 4);
|
||||||
|
hexData[o++] = toHexLower(data[i] & 0xf);
|
||||||
|
|
||||||
|
if ((separator) && (o < length))
|
||||||
|
hexData[o++] = separator;
|
||||||
|
}
|
||||||
|
return hex;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
static unsigned int zOrderCounter = 0;
|
static unsigned int zOrderCounter = 0;
|
||||||
|
|
||||||
|
enum eDropMode
|
||||||
|
{
|
||||||
|
DropModeIntoArea,///< drop widget into a dock area
|
||||||
|
DropModeIntoContainer,///< drop into container
|
||||||
|
DropModeInvalid///< invalid mode - do not drop
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts dock area ID to an index for array access
|
* Converts dock area ID to an index for array access
|
||||||
@@ -70,8 +104,6 @@ static int areaIdToIndex(DockWidgetArea area)
|
|||||||
default:
|
default:
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,7 +134,7 @@ public:
|
|||||||
QGridLayout* Layout = nullptr;
|
QGridLayout* Layout = nullptr;
|
||||||
QSplitter* RootSplitter = nullptr;
|
QSplitter* RootSplitter = nullptr;
|
||||||
bool isFloating = false;
|
bool isFloating = false;
|
||||||
CDockAreaWidget* LastAddedAreaCache[5]{0, 0, 0, 0, 0};
|
CDockAreaWidget* LastAddedAreaCache[5];
|
||||||
int VisibleDockAreaCount = -1;
|
int VisibleDockAreaCount = -1;
|
||||||
CDockAreaWidget* TopLevelDockArea = nullptr;
|
CDockAreaWidget* TopLevelDockArea = nullptr;
|
||||||
|
|
||||||
@@ -139,6 +171,30 @@ public:
|
|||||||
void dropIntoSection(CFloatingDockContainer* FloatingWidget,
|
void dropIntoSection(CFloatingDockContainer* FloatingWidget,
|
||||||
CDockAreaWidget* TargetArea, DockWidgetArea area);
|
CDockAreaWidget* TargetArea, DockWidgetArea area);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the dock widget or dock area given in Widget parameter to a
|
||||||
|
* new dock widget area
|
||||||
|
*/
|
||||||
|
void moveToNewSection(QWidget* Widget, CDockAreaWidget* TargetArea, DockWidgetArea area);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the dock widget or dock area given in Widget parameter to a
|
||||||
|
* a dock area in container
|
||||||
|
*/
|
||||||
|
void moveToContainer(QWidget* Widgett, DockWidgetArea area);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new tab for a widget dropped into the center of a section
|
||||||
|
*/
|
||||||
|
void dropIntoCenterOfSection(CFloatingDockContainer* FloatingWidget,
|
||||||
|
CDockAreaWidget* TargetArea);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new tab for a widget dropped into the center of a section
|
||||||
|
*/
|
||||||
|
void moveIntoCenterOfSection(QWidget* Widget, CDockAreaWidget* TargetArea);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new dock areas to the internal dock area list
|
* Adds new dock areas to the internal dock area list
|
||||||
*/
|
*/
|
||||||
@@ -163,21 +219,21 @@ public:
|
|||||||
* \param[in] Testing If Testing is true, only the stream data is
|
* \param[in] Testing If Testing is true, only the stream data is
|
||||||
* parsed without modifiying anything.
|
* parsed without modifiying anything.
|
||||||
*/
|
*/
|
||||||
bool restoreChildNodes(QXmlStreamReader& Stream, QWidget*& CreatedWidget,
|
bool restoreChildNodes(CDockingStateReader& Stream, QWidget*& CreatedWidget,
|
||||||
bool Testing);
|
bool Testing);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores a splitter.
|
* Restores a splitter.
|
||||||
* \see restoreChildNodes() for details
|
* \see restoreChildNodes() for details
|
||||||
*/
|
*/
|
||||||
bool restoreSplitter(QXmlStreamReader& Stream, QWidget*& CreatedWidget,
|
bool restoreSplitter(CDockingStateReader& Stream, QWidget*& CreatedWidget,
|
||||||
bool Testing);
|
bool Testing);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores a dock area.
|
* Restores a dock area.
|
||||||
* \see restoreChildNodes() for details
|
* \see restoreChildNodes() for details
|
||||||
*/
|
*/
|
||||||
bool restoreDockArea(QXmlStreamReader& Stream, QWidget*& CreatedWidget,
|
bool restoreDockArea(CDockingStateReader& Stream, QWidget*& CreatedWidget,
|
||||||
bool Testing);
|
bool Testing);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,6 +241,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void dumpRecursive(int level, QWidget* widget);
|
void dumpRecursive(int level, QWidget* widget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the drop mode from the given target position
|
||||||
|
*/
|
||||||
|
eDropMode getDropMode(const QPoint& TargetPos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the visible dock area count variable if it is not initialized
|
* Initializes the visible dock area count variable if it is not initialized
|
||||||
* yet
|
* yet
|
||||||
@@ -235,10 +296,10 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Helper function for creation of new splitter
|
* Helper function for creation of new splitter
|
||||||
*/
|
*/
|
||||||
CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = 0)
|
CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = nullptr)
|
||||||
{
|
{
|
||||||
CDockSplitter* s = new CDockSplitter(orientation, parent);
|
CDockSplitter* s = new CDockSplitter(orientation, parent);
|
||||||
s->setOpaqueResize(DockManager->configFlags().testFlag(CDockManager::OpaqueSplitterResize));
|
s->setOpaqueResize(CDockManager::configFlags().testFlag(CDockManager::OpaqueSplitterResize));
|
||||||
s->setChildrenCollapsible(false);
|
s->setChildrenCollapsible(false);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -259,7 +320,47 @@ public:
|
|||||||
DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) :
|
DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) :
|
||||||
_this(_public)
|
_this(_public)
|
||||||
{
|
{
|
||||||
|
std::fill(std::begin(LastAddedAreaCache),std::end(LastAddedAreaCache), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
eDropMode DockContainerWidgetPrivate::getDropMode(const QPoint& TargetPos)
|
||||||
|
{
|
||||||
|
CDockAreaWidget* DockArea = _this->dockAreaAt(TargetPos);
|
||||||
|
auto dropArea = InvalidDockWidgetArea;
|
||||||
|
auto ContainerDropArea = DockManager->containerOverlay()->dropAreaUnderCursor();
|
||||||
|
|
||||||
|
if (DockArea)
|
||||||
|
{
|
||||||
|
auto dropOverlay = DockManager->dockAreaOverlay();
|
||||||
|
dropOverlay->setAllowedAreas(AllDockAreas);
|
||||||
|
dropArea = dropOverlay->showOverlay(DockArea);
|
||||||
|
if (ContainerDropArea != InvalidDockWidgetArea &&
|
||||||
|
ContainerDropArea != dropArea)
|
||||||
|
{
|
||||||
|
dropArea = InvalidDockWidgetArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropArea != InvalidDockWidgetArea)
|
||||||
|
{
|
||||||
|
ADS_PRINT("Dock Area Drop Content: " << dropArea);
|
||||||
|
return DropModeIntoArea;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mouse is over container
|
||||||
|
if (InvalidDockWidgetArea == dropArea)
|
||||||
|
{
|
||||||
|
dropArea = ContainerDropArea;
|
||||||
|
ADS_PRINT("Container Drop Content: " << dropArea);
|
||||||
|
if (dropArea != InvalidDockWidgetArea)
|
||||||
|
{
|
||||||
|
return DropModeIntoContainer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DropModeInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -291,8 +392,6 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
CDockContainerWidget* FloatingDockContainer = FloatingWidget->dockContainer();
|
CDockContainerWidget* FloatingDockContainer = FloatingWidget->dockContainer();
|
||||||
auto NewDockAreas = FloatingDockContainer->findChildren<CDockAreaWidget*>(
|
auto NewDockAreas = FloatingDockContainer->findChildren<CDockAreaWidget*>(
|
||||||
QString(), Qt::FindChildrenRecursively);
|
QString(), Qt::FindChildrenRecursively);
|
||||||
CDockWidget* SingleDroppedDockWidget = FloatingDockContainer->topLevelDockWidget();
|
|
||||||
CDockWidget* SingleDockWidget = _this->topLevelDockWidget();
|
|
||||||
QSplitter* Splitter = RootSplitter;
|
QSplitter* Splitter = RootSplitter;
|
||||||
|
|
||||||
if (DockAreas.count() <= 1)
|
if (DockAreas.count() <= 1)
|
||||||
@@ -328,9 +427,6 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
|
|
||||||
RootSplitter = Splitter;
|
RootSplitter = Splitter;
|
||||||
addDockAreasToList(NewDockAreas);
|
addDockAreasToList(NewDockAreas);
|
||||||
FloatingWidget->deleteLater();
|
|
||||||
CDockWidget::emitTopLevelEventForWidget(SingleDroppedDockWidget, false);
|
|
||||||
CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false);
|
|
||||||
|
|
||||||
// If we dropped the floating widget into the main dock container that does
|
// If we dropped the floating widget into the main dock container that does
|
||||||
// not contain any dock widgets, then splitter is invisible and we need to
|
// not contain any dock widgets, then splitter is invisible and we need to
|
||||||
@@ -343,42 +439,50 @@ void DockContainerWidgetPrivate::dropIntoContainer(CFloatingDockContainer* Float
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void DockContainerWidgetPrivate::dropIntoCenterOfSection(
|
||||||
|
CFloatingDockContainer* FloatingWidget, CDockAreaWidget* TargetArea)
|
||||||
|
{
|
||||||
|
CDockContainerWidget* FloatingContainer = FloatingWidget->dockContainer();
|
||||||
|
auto NewDockWidgets = FloatingContainer->dockWidgets();
|
||||||
|
auto TopLevelDockArea = FloatingContainer->topLevelDockArea();
|
||||||
|
int NewCurrentIndex = -1;
|
||||||
|
|
||||||
|
// If the floating widget contains only one single dock are, then the
|
||||||
|
// current dock widget of the dock area will also be the future current
|
||||||
|
// dock widget in the drop area.
|
||||||
|
if (TopLevelDockArea)
|
||||||
|
{
|
||||||
|
NewCurrentIndex = TopLevelDockArea->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < NewDockWidgets.count(); ++i)
|
||||||
|
{
|
||||||
|
CDockWidget* DockWidget = NewDockWidgets[i];
|
||||||
|
TargetArea->insertDockWidget(i, DockWidget, false);
|
||||||
|
// If the floating widget contains multiple visible dock areas, then we
|
||||||
|
// simply pick the first visible open dock widget and make it
|
||||||
|
// the current one.
|
||||||
|
if (NewCurrentIndex < 0 && !DockWidget->isClosed())
|
||||||
|
{
|
||||||
|
NewCurrentIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TargetArea->setCurrentIndex(NewCurrentIndex);
|
||||||
|
TargetArea->updateTitleBarVisibility();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* FloatingWidget,
|
void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* FloatingWidget,
|
||||||
CDockAreaWidget* TargetArea, DockWidgetArea area)
|
CDockAreaWidget* TargetArea, DockWidgetArea area)
|
||||||
{
|
{
|
||||||
CDockContainerWidget* FloatingContainer = FloatingWidget->dockContainer();
|
|
||||||
// Dropping into center means all dock widgets in the dropped floating
|
// Dropping into center means all dock widgets in the dropped floating
|
||||||
// widget will become tabs of the drop area
|
// widget will become tabs of the drop area
|
||||||
if (CenterDockWidgetArea == area)
|
if (CenterDockWidgetArea == area)
|
||||||
{
|
{
|
||||||
auto NewDockWidgets = FloatingContainer->dockWidgets();
|
dropIntoCenterOfSection(FloatingWidget, TargetArea);
|
||||||
auto TopLevelDockArea = FloatingContainer->topLevelDockArea();
|
|
||||||
int NewCurrentIndex = -1;
|
|
||||||
|
|
||||||
// If the floating widget contains only one single dock are, then the
|
|
||||||
// current dock widget of the dock area will also be the future current
|
|
||||||
// dock widget in the drop area.
|
|
||||||
if (TopLevelDockArea)
|
|
||||||
{
|
|
||||||
NewCurrentIndex = TopLevelDockArea->currentIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < NewDockWidgets.count(); ++i)
|
|
||||||
{
|
|
||||||
CDockWidget* DockWidget = NewDockWidgets[i];
|
|
||||||
TargetArea->insertDockWidget(i, DockWidget, false);
|
|
||||||
// If the floating widget contains multiple visible dock areas, then we
|
|
||||||
// simply pick the first visible open dock widget and make it
|
|
||||||
// the current one.
|
|
||||||
if (NewCurrentIndex < 0 && !DockWidget->isClosed())
|
|
||||||
{
|
|
||||||
NewCurrentIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TargetArea->setCurrentIndex(NewCurrentIndex);
|
|
||||||
FloatingWidget->deleteLater();
|
|
||||||
TargetArea->updateTitleBarVisibility();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,48 +500,194 @@ void DockContainerWidgetPrivate::dropIntoSection(CFloatingDockContainer* Floatin
|
|||||||
}
|
}
|
||||||
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
|
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
|
||||||
auto Widget = FloatingWidget->dockContainer()->findChild<QWidget*>(QString(), Qt::FindDirectChildrenOnly);
|
auto Widget = FloatingWidget->dockContainer()->findChild<QWidget*>(QString(), Qt::FindDirectChildrenOnly);
|
||||||
auto FloatingSplitter = dynamic_cast<QSplitter*>(Widget);
|
auto FloatingSplitter = qobject_cast<QSplitter*>(Widget);
|
||||||
|
|
||||||
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
||||||
{
|
{
|
||||||
|
auto Sizes = TargetAreaSplitter->sizes();
|
||||||
|
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
|
||||||
|
bool AdjustSplitterSizes = true;
|
||||||
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
||||||
{
|
{
|
||||||
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), Widget);
|
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), Widget);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
AdjustSplitterSizes = (FloatingSplitter->count() == 1);
|
||||||
int InsertIndex = AreaIndex + InsertParam.insertOffset();
|
int InsertIndex = AreaIndex + InsertParam.insertOffset();
|
||||||
while (FloatingSplitter->count())
|
while (FloatingSplitter->count())
|
||||||
{
|
{
|
||||||
TargetAreaSplitter->insertWidget(InsertIndex++, FloatingSplitter->widget(0));
|
TargetAreaSplitter->insertWidget(InsertIndex++, FloatingSplitter->widget(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AdjustSplitterSizes)
|
||||||
|
{
|
||||||
|
int Size = (TargetAreaSize - TargetAreaSplitter->handleWidth()) / 2;
|
||||||
|
Sizes[AreaIndex] = Size;
|
||||||
|
Sizes.insert(AreaIndex, Size);
|
||||||
|
TargetAreaSplitter->setSizes(Sizes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
QList<int> NewSplitterSizes;
|
||||||
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
||||||
|
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
|
||||||
|
bool AdjustSplitterSizes = true;
|
||||||
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
if ((FloatingSplitter->orientation() != InsertParam.orientation()) && FloatingSplitter->count() > 1)
|
||||||
{
|
{
|
||||||
NewSplitter->addWidget(Widget);
|
NewSplitter->addWidget(Widget);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
AdjustSplitterSizes = (FloatingSplitter->count() == 1);
|
||||||
while (FloatingSplitter->count())
|
while (FloatingSplitter->count())
|
||||||
{
|
{
|
||||||
NewSplitter->addWidget(FloatingSplitter->widget(0));
|
NewSplitter->addWidget(FloatingSplitter->widget(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
|
// Save the sizes before insertion and restore it later to prevent
|
||||||
|
// shrinking of existing area
|
||||||
|
auto Sizes = TargetAreaSplitter->sizes();
|
||||||
insertWidgetIntoSplitter(NewSplitter, TargetArea, !InsertParam.append());
|
insertWidgetIntoSplitter(NewSplitter, TargetArea, !InsertParam.append());
|
||||||
|
if (AdjustSplitterSizes)
|
||||||
|
{
|
||||||
|
int Size = TargetAreaSize / 2;
|
||||||
|
NewSplitter->setSizes({Size, Size});
|
||||||
|
}
|
||||||
|
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
|
||||||
|
TargetAreaSplitter->setSizes(Sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatingWidget->deleteLater();
|
|
||||||
addDockAreasToList(NewDockAreas);
|
addDockAreasToList(NewDockAreas);
|
||||||
_this->dumpLayout();
|
_this->dumpLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void DockContainerWidgetPrivate::moveIntoCenterOfSection(QWidget* Widget, CDockAreaWidget* TargetArea)
|
||||||
|
{
|
||||||
|
auto DroppedDockWidget = qobject_cast<CDockWidget*>(Widget);
|
||||||
|
auto DroppedArea = qobject_cast<CDockAreaWidget*>(Widget);
|
||||||
|
|
||||||
|
if (DroppedDockWidget)
|
||||||
|
{
|
||||||
|
CDockAreaWidget* OldDockArea = DroppedDockWidget->dockAreaWidget();
|
||||||
|
if (OldDockArea)
|
||||||
|
{
|
||||||
|
OldDockArea->removeDockWidget(DroppedDockWidget);
|
||||||
|
}
|
||||||
|
TargetArea->insertDockWidget(0, DroppedDockWidget, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QList<CDockWidget*> NewDockWidgets = DroppedArea->dockWidgets();
|
||||||
|
int NewCurrentIndex = DroppedArea->currentIndex();
|
||||||
|
for (int i = 0; i < NewDockWidgets.count(); ++i)
|
||||||
|
{
|
||||||
|
CDockWidget* DockWidget = NewDockWidgets[i];
|
||||||
|
TargetArea->insertDockWidget(i, DockWidget, false);
|
||||||
|
}
|
||||||
|
TargetArea->setCurrentIndex(NewCurrentIndex);
|
||||||
|
DroppedArea->dockContainer()->removeDockArea(DroppedArea);
|
||||||
|
DroppedArea->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetArea->updateTitleBarVisibility();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void DockContainerWidgetPrivate::moveToNewSection(QWidget* Widget, CDockAreaWidget* TargetArea, DockWidgetArea area)
|
||||||
|
{
|
||||||
|
// Dropping into center means all dock widgets in the dropped floating
|
||||||
|
// widget will become tabs of the drop area
|
||||||
|
if (CenterDockWidgetArea == area)
|
||||||
|
{
|
||||||
|
moveIntoCenterOfSection(Widget, TargetArea);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDockWidget* DroppedDockWidget = qobject_cast<CDockWidget*>(Widget);
|
||||||
|
CDockAreaWidget* DroppedDockArea = qobject_cast<CDockAreaWidget*>(Widget);
|
||||||
|
CDockAreaWidget* NewDockArea;
|
||||||
|
if (DroppedDockWidget)
|
||||||
|
{
|
||||||
|
NewDockArea = new CDockAreaWidget(DockManager, _this);
|
||||||
|
CDockAreaWidget* OldDockArea = DroppedDockWidget->dockAreaWidget();
|
||||||
|
if (OldDockArea)
|
||||||
|
{
|
||||||
|
OldDockArea->removeDockWidget(DroppedDockWidget);
|
||||||
|
}
|
||||||
|
NewDockArea->addDockWidget(DroppedDockWidget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DroppedDockArea->dockContainer()->removeDockArea(DroppedDockArea);
|
||||||
|
NewDockArea = DroppedDockArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto InsertParam = internal::dockAreaInsertParameters(area);
|
||||||
|
QSplitter* TargetAreaSplitter = internal::findParent<QSplitter*>(TargetArea);
|
||||||
|
int AreaIndex = TargetAreaSplitter->indexOf(TargetArea);
|
||||||
|
auto Sizes = TargetAreaSplitter->sizes();
|
||||||
|
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
||||||
|
{
|
||||||
|
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
|
||||||
|
TargetAreaSplitter->insertWidget(AreaIndex + InsertParam.insertOffset(), NewDockArea);
|
||||||
|
int Size = (TargetAreaSize - TargetAreaSplitter->handleWidth()) / 2;
|
||||||
|
Sizes[AreaIndex] = Size;
|
||||||
|
Sizes.insert(AreaIndex, Size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto Sizes = TargetAreaSplitter->sizes();
|
||||||
|
int TargetAreaSize = (InsertParam.orientation() == Qt::Horizontal) ? TargetArea->width() : TargetArea->height();
|
||||||
|
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
||||||
|
NewSplitter->addWidget(TargetArea);
|
||||||
|
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
||||||
|
int Size = TargetAreaSize / 2;
|
||||||
|
NewSplitter->setSizes({Size, Size});
|
||||||
|
TargetAreaSplitter->insertWidget(AreaIndex, NewSplitter);
|
||||||
|
}
|
||||||
|
TargetAreaSplitter->setSizes(Sizes);
|
||||||
|
|
||||||
|
addDockAreasToList({NewDockArea});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void DockContainerWidgetPrivate::moveToContainer(QWidget* Widget, DockWidgetArea area)
|
||||||
|
{
|
||||||
|
CDockWidget* DroppedDockWidget = qobject_cast<CDockWidget*>(Widget);
|
||||||
|
CDockAreaWidget* DroppedDockArea = qobject_cast<CDockAreaWidget*>(Widget);
|
||||||
|
CDockAreaWidget* NewDockArea;
|
||||||
|
|
||||||
|
if (DroppedDockWidget)
|
||||||
|
{
|
||||||
|
NewDockArea = new CDockAreaWidget(DockManager, _this);
|
||||||
|
CDockAreaWidget* OldDockArea = DroppedDockWidget->dockAreaWidget();
|
||||||
|
if (OldDockArea)
|
||||||
|
{
|
||||||
|
OldDockArea->removeDockWidget(DroppedDockWidget);
|
||||||
|
}
|
||||||
|
NewDockArea->addDockWidget(DroppedDockWidget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DroppedDockArea->dockContainer()->removeDockArea(DroppedDockArea);
|
||||||
|
NewDockArea = DroppedDockArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
addDockArea(NewDockArea, area);
|
||||||
|
LastAddedAreaCache[areaIdToIndex(area)] = NewDockArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*> NewDockAreas)
|
void DockContainerWidgetPrivate::addDockAreasToList(const QList<CDockAreaWidget*> NewDockAreas)
|
||||||
{
|
{
|
||||||
@@ -475,7 +725,10 @@ void DockContainerWidgetPrivate::appendDockAreas(const QList<CDockAreaWidget*> N
|
|||||||
DockAreas.append(NewDockAreas);
|
DockAreas.append(NewDockAreas);
|
||||||
for (auto DockArea : NewDockAreas)
|
for (auto DockArea : NewDockAreas)
|
||||||
{
|
{
|
||||||
_this->connect(DockArea, SIGNAL(viewToggled(bool)), SLOT(onDockAreaViewToggled(bool)));
|
QObject::connect(DockArea,
|
||||||
|
&CDockAreaWidget::viewToggled,
|
||||||
|
_this,
|
||||||
|
std::bind(&DockContainerWidgetPrivate::onDockAreaViewToggled, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,10 +740,10 @@ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidge
|
|||||||
if (Splitter)
|
if (Splitter)
|
||||||
{
|
{
|
||||||
s.writeStartElement("Splitter");
|
s.writeStartElement("Splitter");
|
||||||
s.writeAttribute("Orientation", (Splitter->orientation() == Qt::Horizontal) ? "-" : "|");
|
s.writeAttribute("Orientation", (Splitter->orientation() == Qt::Horizontal) ? "|" : "-");
|
||||||
s.writeAttribute("Count", QString::number(Splitter->count()));
|
s.writeAttribute("Count", QString::number(Splitter->count()));
|
||||||
qDebug() << "NodeSplitter orient: " << Splitter->orientation()
|
ADS_PRINT("NodeSplitter orient: " << Splitter->orientation()
|
||||||
<< " WidgetCont: " << Splitter->count();
|
<< " WidgetCont: " << Splitter->count());
|
||||||
for (int i = 0; i < Splitter->count(); ++i)
|
for (int i = 0; i < Splitter->count(); ++i)
|
||||||
{
|
{
|
||||||
saveChildNodesState(s, Splitter->widget(i));
|
saveChildNodesState(s, Splitter->widget(i));
|
||||||
@@ -516,36 +769,41 @@ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidge
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s,
|
bool DockContainerWidgetPrivate::restoreSplitter(CDockingStateReader& s,
|
||||||
QWidget*& CreatedWidget, bool Testing)
|
QWidget*& CreatedWidget, bool Testing)
|
||||||
{
|
{
|
||||||
bool Ok;
|
bool Ok;
|
||||||
QString OrientationStr = s.attributes().value("Orientation").toString();
|
QString OrientationStr = s.attributes().value("Orientation").toString();
|
||||||
int Orientation;
|
|
||||||
if (OrientationStr.startsWith("-"))
|
// Check if the orientation string is right
|
||||||
{
|
if (!OrientationStr.startsWith("|") && !OrientationStr.startsWith("-"))
|
||||||
Orientation = Qt::Horizontal;
|
|
||||||
}
|
|
||||||
else if (OrientationStr.startsWith("|"))
|
|
||||||
{
|
|
||||||
Orientation = Qt::Vertical;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The "|" shall indicate a vertical splitter handle which in turn means
|
||||||
|
// a Horizontal orientation of the splitter layout.
|
||||||
|
bool HorizontalSplitter = OrientationStr.startsWith("|");
|
||||||
|
// In version 0 we had a small bug. The "|" indicated a vertical orientation,
|
||||||
|
// but this is wrong, because only the splitter handle is vertical, the
|
||||||
|
// layout of the splitter is a horizontal layout. We fix this here
|
||||||
|
if (s.fileVersion() == 0)
|
||||||
|
{
|
||||||
|
HorizontalSplitter = !HorizontalSplitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Orientation = HorizontalSplitter ? Qt::Horizontal : Qt::Vertical;
|
||||||
int WidgetCount = s.attributes().value("Count").toInt(&Ok);
|
int WidgetCount = s.attributes().value("Count").toInt(&Ok);
|
||||||
if (!Ok)
|
if (!Ok)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qDebug() << "Restore NodeSplitter Orientation: " << Orientation <<
|
ADS_PRINT("Restore NodeSplitter Orientation: " << Orientation <<
|
||||||
" WidgetCount: " << WidgetCount;
|
" WidgetCount: " << WidgetCount);
|
||||||
QSplitter* Splitter = nullptr;
|
QSplitter* Splitter = nullptr;
|
||||||
if (!Testing)
|
if (!Testing)
|
||||||
{
|
{
|
||||||
Splitter = newSplitter((Qt::Orientation)Orientation);
|
Splitter = newSplitter(static_cast<Qt::Orientation>(Orientation));
|
||||||
}
|
}
|
||||||
bool Visible = false;
|
bool Visible = false;
|
||||||
QList<int> Sizes;
|
QList<int> Sizes;
|
||||||
@@ -564,7 +822,7 @@ bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s,
|
|||||||
else if (s.name() == "Sizes")
|
else if (s.name() == "Sizes")
|
||||||
{
|
{
|
||||||
QString sSizes = s.readElementText().trimmed();
|
QString sSizes = s.readElementText().trimmed();
|
||||||
qDebug() << "Sizes: " << sSizes;
|
ADS_PRINT("Sizes: " << sSizes);
|
||||||
QTextStream TextStream(&sSizes);
|
QTextStream TextStream(&sSizes);
|
||||||
while (!TextStream.atEnd())
|
while (!TextStream.atEnd())
|
||||||
{
|
{
|
||||||
@@ -588,8 +846,8 @@ bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "ChildNode isVisible " << ChildNode->isVisible()
|
ADS_PRINT("ChildNode isVisible " << ChildNode->isVisible()
|
||||||
<< " isVisibleTo " << ChildNode->isVisibleTo(Splitter);
|
<< " isVisibleTo " << ChildNode->isVisibleTo(Splitter));
|
||||||
Splitter->addWidget(ChildNode);
|
Splitter->addWidget(ChildNode);
|
||||||
Visible |= ChildNode->isVisibleTo(Splitter);
|
Visible |= ChildNode->isVisibleTo(Splitter);
|
||||||
}
|
}
|
||||||
@@ -623,20 +881,21 @@ bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s,
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockContainerWidgetPrivate::restoreDockArea(QXmlStreamReader& s,
|
bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
|
||||||
QWidget*& CreatedWidget, bool Testing)
|
QWidget*& CreatedWidget, bool Testing)
|
||||||
{
|
{
|
||||||
bool Ok;
|
bool Ok;
|
||||||
|
#ifdef ADS_DEBUG_PRINT
|
||||||
int Tabs = s.attributes().value("Tabs").toInt(&Ok);
|
int Tabs = s.attributes().value("Tabs").toInt(&Ok);
|
||||||
if (!Ok)
|
if (!Ok)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QString CurrentDockWidget = s.attributes().value("Current").toString();
|
QString CurrentDockWidget = s.attributes().value("Current").toString();
|
||||||
qDebug() << "Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
||||||
<< CurrentDockWidget;
|
<< CurrentDockWidget);
|
||||||
|
|
||||||
CDockAreaWidget* DockArea = nullptr;
|
CDockAreaWidget* DockArea = nullptr;
|
||||||
if (!Testing)
|
if (!Testing)
|
||||||
@@ -670,15 +929,15 @@ bool DockContainerWidgetPrivate::restoreDockArea(QXmlStreamReader& s,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Dock Widget found - parent " << DockWidget->parent();
|
ADS_PRINT("Dock Widget found - parent " << DockWidget->parent());
|
||||||
// We hide the DockArea here to prevent the short display (the flashing)
|
// We hide the DockArea here to prevent the short display (the flashing)
|
||||||
// of the dock areas during application startup
|
// of the dock areas during application startup
|
||||||
DockArea->hide();
|
DockArea->hide();
|
||||||
DockArea->addDockWidget(DockWidget);
|
DockArea->addDockWidget(DockWidget);
|
||||||
DockWidget->setToggleViewActionChecked(!Closed);
|
DockWidget->setToggleViewActionChecked(!Closed);
|
||||||
DockWidget->setClosedState(Closed);
|
DockWidget->setClosedState(Closed);
|
||||||
DockWidget->setProperty("closed", Closed);
|
DockWidget->setProperty(internal::ClosedProperty, Closed);
|
||||||
DockWidget->setProperty("dirty", false);
|
DockWidget->setProperty(internal::DirtyProperty, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Testing)
|
if (Testing)
|
||||||
@@ -703,7 +962,7 @@ bool DockContainerWidgetPrivate::restoreDockArea(QXmlStreamReader& s,
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockContainerWidgetPrivate::restoreChildNodes(QXmlStreamReader& s,
|
bool DockContainerWidgetPrivate::restoreChildNodes(CDockingStateReader& s,
|
||||||
QWidget*& CreatedWidget, bool Testing)
|
QWidget*& CreatedWidget, bool Testing)
|
||||||
{
|
{
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
@@ -712,17 +971,17 @@ bool DockContainerWidgetPrivate::restoreChildNodes(QXmlStreamReader& s,
|
|||||||
if (s.name() == "Splitter")
|
if (s.name() == "Splitter")
|
||||||
{
|
{
|
||||||
Result = restoreSplitter(s, CreatedWidget, Testing);
|
Result = restoreSplitter(s, CreatedWidget, Testing);
|
||||||
qDebug() << "Splitter";
|
ADS_PRINT("Splitter");
|
||||||
}
|
}
|
||||||
else if (s.name() == "Area")
|
else if (s.name() == "Area")
|
||||||
{
|
{
|
||||||
Result = restoreDockArea(s, CreatedWidget, Testing);
|
Result = restoreDockArea(s, CreatedWidget, Testing);
|
||||||
qDebug() << "DockAreaWidget";
|
ADS_PRINT("DockAreaWidget");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s.skipCurrentElement();
|
s.skipCurrentElement();
|
||||||
qDebug() << "Unknown element";
|
ADS_PRINT("Unknown element");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,9 +1038,7 @@ void DockContainerWidgetPrivate::addDockArea(CDockAreaWidget* NewDockArea, DockW
|
|||||||
RootSplitter = NewSplitter;
|
RootSplitter = NewSplitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
appendDockAreas({NewDockArea});
|
addDockAreasToList({NewDockArea});
|
||||||
NewDockArea->updateTitleBarVisibility();
|
|
||||||
emitDockAreasAdded();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -794,15 +1051,17 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
|||||||
buf.fill(' ', level * 4);
|
buf.fill(' ', level * 4);
|
||||||
if (Splitter)
|
if (Splitter)
|
||||||
{
|
{
|
||||||
|
#ifdef ADS_DEBUG_PRINT
|
||||||
qDebug("%sSplitter %s v: %s c: %s",
|
qDebug("%sSplitter %s v: %s c: %s",
|
||||||
(const char*)buf,
|
(const char*)buf,
|
||||||
(Splitter->orientation() == Qt::Vertical) ? "--" : "|",
|
(Splitter->orientation() == Qt::Vertical) ? "--" : "|",
|
||||||
Splitter->isHidden() ? " " : "v",
|
Splitter->isHidden() ? " " : "v",
|
||||||
QString::number(Splitter->count()).toStdString().c_str());
|
QString::number(Splitter->count()).toStdString().c_str());
|
||||||
std::cout << (const char*)buf << "Splitter "
|
std::cout << (const char*)buf << "Splitter "
|
||||||
<< ((Splitter->orientation() == Qt::Vertical) ? "--" : "|") << " "
|
<< ((Splitter->orientation() == Qt::Vertical) ? "--" : "|") << " "
|
||||||
<< (Splitter->isHidden() ? " " : "v") << " "
|
<< (Splitter->isHidden() ? " " : "v") << " "
|
||||||
<< QString::number(Splitter->count()).toStdString() << std::endl;
|
<< QString::number(Splitter->count()).toStdString() << std::endl;
|
||||||
|
#endif
|
||||||
for (int i = 0; i < Splitter->count(); ++i)
|
for (int i = 0; i < Splitter->count(); ++i)
|
||||||
{
|
{
|
||||||
dumpRecursive(level + 1, Splitter->widget(i));
|
dumpRecursive(level + 1, Splitter->widget(i));
|
||||||
@@ -815,6 +1074,7 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef ADS_DEBUG_PRINT
|
||||||
qDebug("%sDockArea", (const char*)buf);
|
qDebug("%sDockArea", (const char*)buf);
|
||||||
std::cout << (const char*)buf
|
std::cout << (const char*)buf
|
||||||
<< (DockArea->isHidden() ? " " : "v")
|
<< (DockArea->isHidden() ? " " : "v")
|
||||||
@@ -828,7 +1088,8 @@ void DockContainerWidgetPrivate::dumpRecursive(int level, QWidget* widget)
|
|||||||
std::cout << (DockWidget->isHidden() ? " " : "v");
|
std::cout << (DockWidget->isHidden() ? " " : "v");
|
||||||
std::cout << (DockWidget->isClosed() ? "c" : " ") << " ";
|
std::cout << (DockWidget->isClosed() ? "c" : " ") << " ";
|
||||||
std::cout << DockWidget->windowTitle().toStdString() << std::endl;
|
std::cout << DockWidget->windowTitle().toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(level);
|
Q_UNUSED(level);
|
||||||
@@ -844,6 +1105,7 @@ CDockAreaWidget* DockContainerWidgetPrivate::dockWidgetIntoDockArea(DockWidgetAr
|
|||||||
if (CenterDockWidgetArea == area)
|
if (CenterDockWidgetArea == area)
|
||||||
{
|
{
|
||||||
TargetDockArea->addDockWidget(Dockwidget);
|
TargetDockArea->addDockWidget(Dockwidget);
|
||||||
|
TargetDockArea->updateTitleBarVisibility();
|
||||||
return TargetDockArea;
|
return TargetDockArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,12 +1117,12 @@ CDockAreaWidget* DockContainerWidgetPrivate::dockWidgetIntoDockArea(DockWidgetAr
|
|||||||
int index = TargetAreaSplitter ->indexOf(TargetDockArea);
|
int index = TargetAreaSplitter ->indexOf(TargetDockArea);
|
||||||
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
if (TargetAreaSplitter->orientation() == InsertParam.orientation())
|
||||||
{
|
{
|
||||||
qDebug() << "TargetAreaSplitter->orientation() == InsertParam.orientation()";
|
ADS_PRINT("TargetAreaSplitter->orientation() == InsertParam.orientation()");
|
||||||
TargetAreaSplitter->insertWidget(index + InsertParam.insertOffset(), NewDockArea);
|
TargetAreaSplitter->insertWidget(index + InsertParam.insertOffset(), NewDockArea);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "TargetAreaSplitter->orientation() != InsertParam.orientation()";
|
ADS_PRINT("TargetAreaSplitter->orientation() != InsertParam.orientation()");
|
||||||
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
QSplitter* NewSplitter = newSplitter(InsertParam.orientation());
|
||||||
NewSplitter->addWidget(TargetDockArea);
|
NewSplitter->addWidget(TargetDockArea);
|
||||||
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
insertWidgetIntoSplitter(NewSplitter, NewDockArea, InsertParam.append());
|
||||||
@@ -930,6 +1192,15 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockContainerWidget::removeDockWidget(CDockWidget* Dockwidget)
|
||||||
|
{
|
||||||
|
CDockAreaWidget* Area = Dockwidget->dockAreaWidget();
|
||||||
|
if (Area)
|
||||||
|
{
|
||||||
|
Area->removeDockWidget(Dockwidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
unsigned int CDockContainerWidget::zOrderIndex() const
|
unsigned int CDockContainerWidget::zOrderIndex() const
|
||||||
@@ -979,16 +1250,22 @@ void CDockContainerWidget::addDockArea(CDockAreaWidget* DockAreaWidget,
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockContainerWidget::removeDockArea";
|
ADS_PRINT("CDockContainerWidget::removeDockArea");
|
||||||
area->disconnect(this);
|
area->disconnect(this);
|
||||||
d->DockAreas.removeAll(area);
|
d->DockAreas.removeAll(area);
|
||||||
CDockSplitter* Splitter = internal::findParent<CDockSplitter*>(area);
|
CDockSplitter* Splitter = internal::findParent<CDockSplitter*>(area);
|
||||||
|
|
||||||
// Remove are from parent splitter and recursively hide tree of parent
|
// Remove are from parent splitter and recursively hide tree of parent
|
||||||
// splitters if it has no visible content
|
// splitters if it has no visible content
|
||||||
area->setParent(0);
|
area->setParent(nullptr);
|
||||||
internal::hideEmptyParentSplitters(Splitter);
|
internal::hideEmptyParentSplitters(Splitter);
|
||||||
|
|
||||||
|
// Remove this area from cached areas
|
||||||
|
const auto& cache = d->LastAddedAreaCache;
|
||||||
|
if (auto p = std::find(cache, cache+sizeof(cache)/sizeof(cache[0]), area)) {
|
||||||
|
d->LastAddedAreaCache[std::distance(cache, p)] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// If splitter has more than 1 widgets, we are finished and can leave
|
// If splitter has more than 1 widgets, we are finished and can leave
|
||||||
if (Splitter->count() > 1)
|
if (Splitter->count() > 1)
|
||||||
{
|
{
|
||||||
@@ -999,7 +1276,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
// avoid too many empty splitters
|
// avoid too many empty splitters
|
||||||
if (Splitter == d->RootSplitter)
|
if (Splitter == d->RootSplitter)
|
||||||
{
|
{
|
||||||
qDebug() << "Removed from RootSplitter";
|
ADS_PRINT("Removed from RootSplitter");
|
||||||
// If splitter is empty, we are finished
|
// If splitter is empty, we are finished
|
||||||
if (!Splitter->count())
|
if (!Splitter->count())
|
||||||
{
|
{
|
||||||
@@ -1017,19 +1294,21 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We replace the superfluous RootSplitter with the ChildSplitter
|
// We replace the superfluous RootSplitter with the ChildSplitter
|
||||||
ChildSplitter->setParent(0);
|
ChildSplitter->setParent(nullptr);
|
||||||
QLayoutItem* li = d->Layout->replaceWidget(Splitter, ChildSplitter);
|
QLayoutItem* li = d->Layout->replaceWidget(Splitter, ChildSplitter);
|
||||||
d->RootSplitter = ChildSplitter;
|
d->RootSplitter = ChildSplitter;
|
||||||
delete li;
|
delete li;
|
||||||
qDebug() << "RootSplitter replaced by child splitter";
|
ADS_PRINT("RootSplitter replaced by child splitter");
|
||||||
}
|
}
|
||||||
else if (Splitter->count() == 1)
|
else if (Splitter->count() == 1)
|
||||||
{
|
{
|
||||||
qDebug() << "Replacing splitter with content";
|
ADS_PRINT("Replacing splitter with content");
|
||||||
|
QSplitter* ParentSplitter = internal::findParent<QSplitter*>(Splitter);
|
||||||
|
auto Sizes = ParentSplitter->sizes();
|
||||||
QWidget* widget = Splitter->widget(0);
|
QWidget* widget = Splitter->widget(0);
|
||||||
widget->setParent(this);
|
widget->setParent(this);
|
||||||
QSplitter* ParentSplitter = internal::findParent<QSplitter*>(Splitter);
|
|
||||||
internal::replaceSplitterWidget(ParentSplitter, Splitter, widget);
|
internal::replaceSplitterWidget(ParentSplitter, Splitter, widget);
|
||||||
|
ParentSplitter->setSizes(Sizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete Splitter;
|
delete Splitter;
|
||||||
@@ -1056,14 +1335,14 @@ CDockAreaWidget* CDockContainerWidget::dockAreaAt(const QPoint& GlobalPos) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* CDockContainerWidget::dockArea(int Index) const
|
CDockAreaWidget* CDockContainerWidget::dockArea(int Index) const
|
||||||
{
|
{
|
||||||
return (Index < dockAreaCount()) ? d->DockAreas[Index] : 0;
|
return (Index < dockAreaCount()) ? d->DockAreas[Index] : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1102,12 +1381,13 @@ int CDockContainerWidget::visibleDockAreaCount() const
|
|||||||
void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWidget,
|
void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWidget,
|
||||||
const QPoint& TargetPos)
|
const QPoint& TargetPos)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockContainerWidget::dropFloatingWidget";
|
ADS_PRINT("CDockContainerWidget::dropFloatingWidget");
|
||||||
|
CDockWidget* SingleDroppedDockWidget = FloatingWidget->topLevelDockWidget();
|
||||||
|
CDockWidget* SingleDockWidget = topLevelDockWidget();
|
||||||
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
|
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
|
||||||
auto dropArea = InvalidDockWidgetArea;
|
auto dropArea = InvalidDockWidgetArea;
|
||||||
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
|
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
|
||||||
CDockWidget* FloatingTopLevelDockWidget = FloatingWidget->topLevelDockWidget();
|
bool Dropped = false;
|
||||||
CDockWidget* TopLevelDockWidget = topLevelDockWidget();
|
|
||||||
|
|
||||||
if (DockArea)
|
if (DockArea)
|
||||||
{
|
{
|
||||||
@@ -1122,8 +1402,9 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
|
|||||||
|
|
||||||
if (dropArea != InvalidDockWidgetArea)
|
if (dropArea != InvalidDockWidgetArea)
|
||||||
{
|
{
|
||||||
qDebug() << "Dock Area Drop Content: " << dropArea;
|
ADS_PRINT("Dock Area Drop Content: " << dropArea);
|
||||||
d->dropIntoSection(FloatingWidget, DockArea, dropArea);
|
d->dropIntoSection(FloatingWidget, DockArea, dropArea);
|
||||||
|
Dropped = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1131,26 +1412,70 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
|
|||||||
if (InvalidDockWidgetArea == dropArea)
|
if (InvalidDockWidgetArea == dropArea)
|
||||||
{
|
{
|
||||||
dropArea = ContainerDropArea;
|
dropArea = ContainerDropArea;
|
||||||
qDebug() << "Container Drop Content: " << dropArea;
|
ADS_PRINT("Container Drop Content: " << dropArea);
|
||||||
if (dropArea != InvalidDockWidgetArea)
|
if (dropArea != InvalidDockWidgetArea)
|
||||||
{
|
{
|
||||||
d->dropIntoContainer(FloatingWidget, dropArea);
|
d->dropIntoContainer(FloatingWidget, dropArea);
|
||||||
|
Dropped = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Dropped)
|
||||||
|
{
|
||||||
|
FloatingWidget->deleteLater();
|
||||||
|
|
||||||
|
// If we dropped a floating widget with only one single dock widget, then we
|
||||||
|
// drop a top level widget that changes from floating to docked now
|
||||||
|
CDockWidget::emitTopLevelEventForWidget(SingleDroppedDockWidget, false);
|
||||||
|
|
||||||
|
// If there was a top level widget before the drop, then it is not top
|
||||||
|
// level widget anymore
|
||||||
|
CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockContainerWidget::dropWidget(QWidget* Widget, const QPoint& TargetPos)
|
||||||
|
{
|
||||||
|
ADS_PRINT("CDockContainerWidget::dropFloatingWidget");
|
||||||
|
CDockWidget* SingleDockWidget = topLevelDockWidget();
|
||||||
|
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
|
||||||
|
auto dropArea = InvalidDockWidgetArea;
|
||||||
|
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
|
||||||
|
|
||||||
|
if (DockArea)
|
||||||
|
{
|
||||||
|
auto dropOverlay = d->DockManager->dockAreaOverlay();
|
||||||
|
dropOverlay->setAllowedAreas(AllDockAreas);
|
||||||
|
dropArea = dropOverlay->showOverlay(DockArea);
|
||||||
|
if (ContainerDropArea != InvalidDockWidgetArea &&
|
||||||
|
ContainerDropArea != dropArea)
|
||||||
|
{
|
||||||
|
dropArea = InvalidDockWidgetArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropArea != InvalidDockWidgetArea)
|
||||||
|
{
|
||||||
|
ADS_PRINT("Dock Area Drop Content: " << dropArea);
|
||||||
|
d->moveToNewSection(Widget, DockArea, dropArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mouse is over container
|
||||||
|
if (InvalidDockWidgetArea == dropArea)
|
||||||
|
{
|
||||||
|
dropArea = ContainerDropArea;
|
||||||
|
ADS_PRINT("Container Drop Content: " << dropArea);
|
||||||
|
if (dropArea != InvalidDockWidgetArea)
|
||||||
|
{
|
||||||
|
d->moveToContainer(Widget, dropArea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there was a top level widget before the drop, then it is not top
|
// If there was a top level widget before the drop, then it is not top
|
||||||
// level widget anymore
|
// level widget anymore
|
||||||
if (TopLevelDockWidget)
|
CDockWidget::emitTopLevelEventForWidget(SingleDockWidget, false);
|
||||||
{
|
|
||||||
TopLevelDockWidget->emitTopLevelChanged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we drop a floating widget with only one single dock widget, then we
|
|
||||||
// drop a top level widget that changes from floating to docked now
|
|
||||||
if (FloatingTopLevelDockWidget)
|
|
||||||
{
|
|
||||||
FloatingTopLevelDockWidget->emitTopLevelChanged(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1173,8 +1498,8 @@ QList<CDockAreaWidget*> CDockContainerWidget::openedDockAreas() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
|
void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
|
||||||
{
|
{
|
||||||
qDebug() << "CDockContainerWidget::saveState isFloating "
|
ADS_PRINT("CDockContainerWidget::saveState isFloating "
|
||||||
<< isFloating();
|
<< isFloating());
|
||||||
|
|
||||||
s.writeStartElement("Container");
|
s.writeStartElement("Container");
|
||||||
s.writeAttribute("Floating", QString::number(isFloating() ? 1 : 0));
|
s.writeAttribute("Floating", QString::number(isFloating() ? 1 : 0));
|
||||||
@@ -1182,7 +1507,11 @@ void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
|
|||||||
{
|
{
|
||||||
CFloatingDockContainer* FloatingWidget = floatingWidget();
|
CFloatingDockContainer* FloatingWidget = floatingWidget();
|
||||||
QByteArray Geometry = FloatingWidget->saveGeometry();
|
QByteArray Geometry = FloatingWidget->saveGeometry();
|
||||||
|
#if QT_VERSION < 0x050900
|
||||||
|
s.writeTextElement("Geometry", qByteArrayToHex(Geometry, ' '));
|
||||||
|
#else
|
||||||
s.writeTextElement("Geometry", Geometry.toHex(' '));
|
s.writeTextElement("Geometry", Geometry.toHex(' '));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
d->saveChildNodesState(s, d->RootSplitter);
|
d->saveChildNodesState(s, d->RootSplitter);
|
||||||
s.writeEndElement();
|
s.writeEndElement();
|
||||||
@@ -1190,27 +1519,28 @@ void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
|
bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
|
||||||
{
|
{
|
||||||
bool IsFloating = s.attributes().value("Floating").toInt();
|
bool IsFloating = s.attributes().value("Floating").toInt();
|
||||||
qDebug() << "Restore CDockContainerWidget Floating" << IsFloating;
|
ADS_PRINT("Restore CDockContainerWidget Floating" << IsFloating);
|
||||||
|
|
||||||
QWidget*NewRootSplitter {};
|
QWidget*NewRootSplitter {};
|
||||||
if (!Testing)
|
if (!Testing)
|
||||||
{
|
{
|
||||||
d->VisibleDockAreaCount = -1;// invalidate the dock area count
|
d->VisibleDockAreaCount = -1;// invalidate the dock area count
|
||||||
d->DockAreas.clear();
|
d->DockAreas.clear();
|
||||||
|
std::fill(std::begin(d->LastAddedAreaCache),std::end(d->LastAddedAreaCache), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsFloating)
|
if (IsFloating)
|
||||||
{
|
{
|
||||||
qDebug() << "Restore floating widget";
|
ADS_PRINT("Restore floating widget");
|
||||||
if (!s.readNextStartElement() || s.name() != "Geometry")
|
if (!s.readNextStartElement() || s.name() != "Geometry")
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray GeometryString = s.readElementText(QXmlStreamReader::ErrorOnUnexpectedElement).toLocal8Bit();
|
QByteArray GeometryString = s.readElementText(CDockingStateReader::ErrorOnUnexpectedElement).toLocal8Bit();
|
||||||
QByteArray Geometry = QByteArray::fromHex(GeometryString);
|
QByteArray Geometry = QByteArray::fromHex(GeometryString);
|
||||||
if (Geometry.isEmpty())
|
if (Geometry.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -1378,8 +1708,20 @@ CFloatingDockContainer* CDockContainerWidget::floatingWidget() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockContainerWidget::closeOtherAreas(CDockAreaWidget* KeepOpenArea)
|
||||||
|
{
|
||||||
|
for (const auto DockArea : d->DockAreas)
|
||||||
|
{
|
||||||
|
if (DockArea != KeepOpenArea && DockArea->features().testFlag(CDockWidget::DockWidgetClosable))
|
||||||
|
{
|
||||||
|
DockArea->closeArea();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
#include "moc_DockContainerWidget.cpp"
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// EOF DockContainerWidget.cpp
|
// EOF DockContainerWidget.cpp
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
|
||||||
class QXmlStreamWriter;
|
class QXmlStreamWriter;
|
||||||
class QXmlStreamReader;
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
@@ -47,17 +47,23 @@ class CDockManager;
|
|||||||
struct DockManagerPrivate;
|
struct DockManagerPrivate;
|
||||||
class CFloatingDockContainer;
|
class CFloatingDockContainer;
|
||||||
struct FloatingDockContainerPrivate;
|
struct FloatingDockContainerPrivate;
|
||||||
|
class CFloatingDragPreview;
|
||||||
|
struct FloatingDragPreviewPrivate;
|
||||||
|
class CDockingStateReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container that manages a number of dock areas with single dock widgets
|
* Container that manages a number of dock areas with single dock widgets
|
||||||
* or tabyfied dock widgets in each area
|
* or tabyfied dock widgets in each area.
|
||||||
|
* Each window that support docking has a DockContainerWidget. That means
|
||||||
|
* the main application window and all floating windows are ore contain
|
||||||
|
* an DockContainerWidget.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CDockContainerWidget : public QFrame
|
class ADS_EXPORT CDockContainerWidget : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
DockContainerWidgetPrivate* d; ///< private data (pimpl)
|
DockContainerWidgetPrivate* d; ///< private data (pimpl)
|
||||||
friend struct DockContainerWidgetPrivate;
|
friend class DockContainerWidgetPrivate;
|
||||||
friend class CDockManager;
|
friend class CDockManager;
|
||||||
friend struct DockManagerPrivate;
|
friend struct DockManagerPrivate;
|
||||||
friend class CDockAreaWidget;
|
friend class CDockAreaWidget;
|
||||||
@@ -65,7 +71,8 @@ private:
|
|||||||
friend class CFloatingDockContainer;
|
friend class CFloatingDockContainer;
|
||||||
friend struct FloatingDockContainerPrivate;
|
friend struct FloatingDockContainerPrivate;
|
||||||
friend class CDockWidget;
|
friend class CDockWidget;
|
||||||
Q_PRIVATE_SLOT(d, void onDockAreaViewToggled(bool Visible))
|
friend class CFloatingDragPreview;
|
||||||
|
friend struct FloatingDragPreviewPrivate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
@@ -88,6 +95,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void dropFloatingWidget(CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
|
void dropFloatingWidget(CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop a dock area or a dock widget given in widget parameter
|
||||||
|
*/
|
||||||
|
void dropWidget(QWidget* Widget, const QPoint& TargetPos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given dock area to this container widget
|
* Adds the given dock area to this container widget
|
||||||
*/
|
*/
|
||||||
@@ -109,7 +121,7 @@ protected:
|
|||||||
* stream but does not restore anything. You can use this check for
|
* stream but does not restore anything. You can use this check for
|
||||||
* faulty files before you start restoring the state
|
* faulty files before you start restoring the state
|
||||||
*/
|
*/
|
||||||
bool restoreState(QXmlStreamReader& Stream, bool Testing);
|
bool restoreState(CDockingStateReader& Stream, bool Testing);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns the last added dock area widget for the given
|
* This function returns the last added dock area widget for the given
|
||||||
@@ -168,6 +180,11 @@ public:
|
|||||||
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget = nullptr);
|
CDockAreaWidget* DockAreaWidget = nullptr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes dockwidget
|
||||||
|
*/
|
||||||
|
void removeDockWidget(CDockWidget* Dockwidget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current zOrderIndex
|
* Returns the current zOrderIndex
|
||||||
*/
|
*/
|
||||||
@@ -233,6 +250,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
CFloatingDockContainer* floatingWidget() const;
|
CFloatingDockContainer* floatingWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this function to close all dock areas except the KeepOpenArea
|
||||||
|
*/
|
||||||
|
void closeOtherAreas(CDockAreaWidget* KeepOpenArea);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if one or multiple dock areas has been added to
|
* This signal is emitted if one or multiple dock areas has been added to
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <DockWidgetTab.h>
|
#include "DockWidgetTab.h"
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -42,7 +42,6 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
#include <QXmlStreamReader>
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -52,10 +51,15 @@
|
|||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
|
#include "IconProvider.h"
|
||||||
|
#include "DockingStateReader.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
|
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data class of CDockManager class (pimpl)
|
* Private data class of CDockManager class (pimpl)
|
||||||
*/
|
*/
|
||||||
@@ -72,7 +76,7 @@ struct DockManagerPrivate
|
|||||||
QMenu* ViewMenu;
|
QMenu* ViewMenu;
|
||||||
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
|
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
|
||||||
bool RestoringState = false;
|
bool RestoringState = false;
|
||||||
CDockManager::ConfigFlags ConfigFlags{CDockManager::DefaultConfig};
|
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@@ -101,7 +105,7 @@ struct DockManagerPrivate
|
|||||||
|
|
||||||
void hideFloatingWidgets()
|
void hideFloatingWidgets()
|
||||||
{
|
{
|
||||||
// Hide updates of floating widgets from use
|
// Hide updates of floating widgets from user
|
||||||
for (auto FloatingWidget : FloatingWidgets)
|
for (auto FloatingWidget : FloatingWidgets)
|
||||||
{
|
{
|
||||||
FloatingWidget->hide();
|
FloatingWidget->hide();
|
||||||
@@ -119,7 +123,7 @@ struct DockManagerPrivate
|
|||||||
/**
|
/**
|
||||||
* Restores the container with the given index
|
* Restores the container with the given index
|
||||||
*/
|
*/
|
||||||
bool restoreContainer(int Index, QXmlStreamReader& stream, bool Testing);
|
bool restoreContainer(int Index, CDockingStateReader& stream, bool Testing);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the stylesheet
|
* Loads the stylesheet
|
||||||
@@ -145,7 +149,11 @@ DockManagerPrivate::DockManagerPrivate(CDockManager* _public) :
|
|||||||
void DockManagerPrivate::loadStylesheet()
|
void DockManagerPrivate::loadStylesheet()
|
||||||
{
|
{
|
||||||
QString Result;
|
QString Result;
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QFile StyleSheetFile(":ads/stylesheets/default_linux.css");
|
||||||
|
#else
|
||||||
QFile StyleSheetFile(":ads/stylesheets/default.css");
|
QFile StyleSheetFile(":ads/stylesheets/default.css");
|
||||||
|
#endif
|
||||||
StyleSheetFile.open(QIODevice::ReadOnly);
|
StyleSheetFile.open(QIODevice::ReadOnly);
|
||||||
QTextStream StyleSheetStream(&StyleSheetFile);
|
QTextStream StyleSheetStream(&StyleSheetFile);
|
||||||
Result = StyleSheetStream.readAll();
|
Result = StyleSheetStream.readAll();
|
||||||
@@ -155,7 +163,7 @@ void DockManagerPrivate::loadStylesheet()
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockManagerPrivate::restoreContainer(int Index, QXmlStreamReader& stream, bool Testing)
|
bool DockManagerPrivate::restoreContainer(int Index, CDockingStateReader& stream, bool Testing)
|
||||||
{
|
{
|
||||||
if (Testing)
|
if (Testing)
|
||||||
{
|
{
|
||||||
@@ -170,7 +178,7 @@ bool DockManagerPrivate::restoreContainer(int Index, QXmlStreamReader& stream, b
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "d->Containers[i]->restoreState ";
|
ADS_PRINT("d->Containers[i]->restoreState ");
|
||||||
auto Container = Containers[Index];
|
auto Container = Containers[Index];
|
||||||
if (Container->isFloating())
|
if (Container->isFloating())
|
||||||
{
|
{
|
||||||
@@ -197,27 +205,32 @@ bool DockManagerPrivate::checkFormat(const QByteArray &state, int version)
|
|||||||
bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int version,
|
bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int version,
|
||||||
bool Testing)
|
bool Testing)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(version);
|
||||||
|
|
||||||
if (state.isEmpty())
|
if (state.isEmpty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QXmlStreamReader s(state);
|
CDockingStateReader s(state);
|
||||||
s.readNextStartElement();
|
s.readNextStartElement();
|
||||||
if (s.name() != "QtAdvancedDockingSystem")
|
if (s.name() != "QtAdvancedDockingSystem")
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qDebug() << s.attributes().value("Version");
|
ADS_PRINT(s.attributes().value("Version"));
|
||||||
bool ok;
|
bool ok;
|
||||||
int v = s.attributes().value("Version").toInt(&ok);
|
int v = s.attributes().value("Version").toInt(&ok);
|
||||||
if (!ok || v != version)
|
if (!ok || v > CurrentVersion)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.setFileVersion(v);
|
||||||
bool Result = true;
|
bool Result = true;
|
||||||
|
#ifdef ADS_DEBUG_PRINT
|
||||||
int DockContainers = s.attributes().value("Containers").toInt();
|
int DockContainers = s.attributes().value("Containers").toInt();
|
||||||
qDebug() << DockContainers;
|
#endif
|
||||||
|
ADS_PRINT(DockContainers);
|
||||||
int DockContainerCount = 0;
|
int DockContainerCount = 0;
|
||||||
while (s.readNextStartElement())
|
while (s.readNextStartElement())
|
||||||
{
|
{
|
||||||
@@ -257,13 +270,14 @@ void DockManagerPrivate::restoreDockWidgetsOpenState()
|
|||||||
// toggle view action the next time
|
// toggle view action the next time
|
||||||
for (auto DockWidget : DockWidgetsMap)
|
for (auto DockWidget : DockWidgetsMap)
|
||||||
{
|
{
|
||||||
if (DockWidget->property("dirty").toBool())
|
if (DockWidget->property(internal::DirtyProperty).toBool())
|
||||||
{
|
{
|
||||||
DockWidget->flagAsUnassigned();
|
DockWidget->flagAsUnassigned();
|
||||||
|
emit DockWidget->viewToggled(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DockWidget->toggleViewInternal(!DockWidget->property("closed").toBool());
|
DockWidget->toggleViewInternal(!DockWidget->property(internal::ClosedProperty).toBool());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,11 +350,12 @@ void DockManagerPrivate::emitTopLevelEvents()
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
|
bool DockManagerPrivate::restoreState(const QByteArray& State, int version)
|
||||||
{
|
{
|
||||||
|
QByteArray state = State.startsWith("<?xml") ? State : qUncompress(State);
|
||||||
if (!checkFormat(state, version))
|
if (!checkFormat(state, version))
|
||||||
{
|
{
|
||||||
qDebug() << "checkFormat: Error checking format!!!!!!!";
|
ADS_PRINT("checkFormat: Error checking format!!!!!!!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +365,7 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
|
|||||||
|
|
||||||
if (!restoreStateFromXml(state, version))
|
if (!restoreStateFromXml(state, version))
|
||||||
{
|
{
|
||||||
qDebug() << "restoreState: Error restoring state!!!!!!!";
|
ADS_PRINT("restoreState: Error restoring state!!!!!!!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +440,7 @@ CDockManager::~CDockManager()
|
|||||||
void CDockManager::registerFloatingWidget(CFloatingDockContainer* FloatingWidget)
|
void CDockManager::registerFloatingWidget(CFloatingDockContainer* FloatingWidget)
|
||||||
{
|
{
|
||||||
d->FloatingWidgets.append(FloatingWidget);
|
d->FloatingWidgets.append(FloatingWidget);
|
||||||
qDebug() << "d->FloatingWidgets.count() " << d->FloatingWidgets.count();
|
ADS_PRINT("d->FloatingWidgets.count() " << d->FloatingWidgets.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -489,11 +504,12 @@ unsigned int CDockManager::zOrderIndex() const
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
|
QByteArray CDockManager::saveState(int version) const
|
||||||
{
|
{
|
||||||
QByteArray xmldata;
|
QByteArray xmldata;
|
||||||
QXmlStreamWriter s(&xmldata);
|
QXmlStreamWriter s(&xmldata);
|
||||||
s.setAutoFormatting(XmlAutoFormattingEnabled == XmlMode);
|
auto ConfigFlags = CDockManager::configFlags();
|
||||||
|
s.setAutoFormatting(ConfigFlags.testFlag(XmlAutoFormattingEnabled));
|
||||||
s.writeStartDocument();
|
s.writeStartDocument();
|
||||||
s.writeStartElement("QtAdvancedDockingSystem");
|
s.writeStartElement("QtAdvancedDockingSystem");
|
||||||
s.writeAttribute("Version", QString::number(version));
|
s.writeAttribute("Version", QString::number(version));
|
||||||
@@ -506,7 +522,8 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
|
|||||||
s.writeEndElement();
|
s.writeEndElement();
|
||||||
s.writeEndDocument();
|
s.writeEndDocument();
|
||||||
|
|
||||||
return xmldata;
|
return ConfigFlags.testFlag(XmlCompressionEnabled)
|
||||||
|
? qCompress(xmldata, 9) : xmldata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -547,6 +564,48 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CFloatingDockContainer* CDockManager::addDockWidgetFloating(CDockWidget* Dockwidget)
|
||||||
|
{
|
||||||
|
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
|
||||||
|
CDockAreaWidget* OldDockArea = Dockwidget->dockAreaWidget();
|
||||||
|
if (OldDockArea)
|
||||||
|
{
|
||||||
|
OldDockArea->removeDockWidget(Dockwidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dockwidget->setDockManager(this);
|
||||||
|
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(Dockwidget);
|
||||||
|
FloatingWidget->resize(Dockwidget->size());
|
||||||
|
if (isVisible())
|
||||||
|
{
|
||||||
|
FloatingWidget->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d->UninitializedFloatingWidgets.append(FloatingWidget);
|
||||||
|
}
|
||||||
|
return FloatingWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockManager::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
Super::showEvent(event);
|
||||||
|
if (d->UninitializedFloatingWidgets.empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto FloatingWidget : d->UninitializedFloatingWidgets)
|
||||||
|
{
|
||||||
|
FloatingWidget->show();
|
||||||
|
}
|
||||||
|
d->UninitializedFloatingWidgets.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
|
CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
|
||||||
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
|
CDockWidget* Dockwidget, CDockAreaWidget* DockAreaWidget)
|
||||||
@@ -565,9 +624,13 @@ CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
|
|||||||
{
|
{
|
||||||
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, AreaWidget);
|
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, AreaWidget);
|
||||||
}
|
}
|
||||||
|
else if (!openedDockAreas().isEmpty())
|
||||||
|
{
|
||||||
|
return addDockWidget(area, Dockwidget, openedDockAreas().last());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return addDockWidget(area, Dockwidget, AreaWidget);
|
return addDockWidget(area, Dockwidget, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,6 +649,14 @@ CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
|
|||||||
return d->DockWidgetsMap.value(ObjectName, nullptr);
|
return d->DockWidgetsMap.value(ObjectName, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockManager::removeDockWidget(CDockWidget* Dockwidget)
|
||||||
|
{
|
||||||
|
emit dockWidgetAboutToBeRemoved(Dockwidget);
|
||||||
|
d->DockWidgetsMap.remove(Dockwidget->objectName());
|
||||||
|
CDockContainerWidget::removeDockWidget(Dockwidget);
|
||||||
|
emit dockWidgetRemoved(Dockwidget);
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
|
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
|
||||||
@@ -747,18 +818,34 @@ int CDockManager::startDragDistance()
|
|||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
CDockManager::ConfigFlags CDockManager::configFlags() const
|
CDockManager::ConfigFlags CDockManager::configFlags()
|
||||||
{
|
{
|
||||||
return d->ConfigFlags;
|
return StaticConfigFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CDockManager::setConfigFlags(const ConfigFlags Flags)
|
void CDockManager::setConfigFlags(const ConfigFlags Flags)
|
||||||
{
|
{
|
||||||
d->ConfigFlags = Flags;
|
StaticConfigFlags = Flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CDockManager::setConfigFlag(eConfigFlag Flag, bool On)
|
||||||
|
{
|
||||||
|
internal::setFlag(StaticConfigFlags, Flag, On);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
CIconProvider& CDockManager::iconProvider()
|
||||||
|
{
|
||||||
|
static CIconProvider Instance;
|
||||||
|
return Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,10 +30,18 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include "DockContainerWidget.h"
|
#include <ads_globals.h>
|
||||||
#include <QIcon>
|
#include <DockContainerWidget.h>
|
||||||
|
#include <DockWidget.h>
|
||||||
#include "ads_globals.h"
|
#include <FloatingDockContainer.h>
|
||||||
|
#include <qbytearray.h>
|
||||||
|
#include <qflags.h>
|
||||||
|
#include <qlist.h>
|
||||||
|
#include <qmap.h>
|
||||||
|
#include <qobjectdefs.h>
|
||||||
|
#include <qstring.h>
|
||||||
|
#include <qstringlist.h>
|
||||||
|
#include <QtGui/qicon.h>
|
||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class QMenu;
|
class QMenu;
|
||||||
@@ -44,14 +52,25 @@ struct DockManagerPrivate;
|
|||||||
class CFloatingDockContainer;
|
class CFloatingDockContainer;
|
||||||
struct FloatingDockContainerPrivate;
|
struct FloatingDockContainerPrivate;
|
||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
|
class DockContainerWidgetPrivate;
|
||||||
class CDockOverlay;
|
class CDockOverlay;
|
||||||
class CDockAreaTabBar;
|
class CDockAreaTabBar;
|
||||||
class CDockWidgetTab;
|
class CDockWidgetTab;
|
||||||
struct DockWidgetTabPrivate;
|
struct DockWidgetTabPrivate;
|
||||||
struct DockAreaWidgetPrivate;
|
struct DockAreaWidgetPrivate;
|
||||||
|
class CIconProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The central dock manager that maintains the complete docking system
|
* The central dock manager that maintains the complete docking system.
|
||||||
|
* With the configuration flags you can globally control the functionality
|
||||||
|
* of the docking system. The dock manager uses an internal stylesheet to
|
||||||
|
* style its components like splitters, tabs and buttons. If you want to
|
||||||
|
* disable this stylesheet because your application uses its own,
|
||||||
|
* just call the function for settings the stylesheet with an empty
|
||||||
|
* string.
|
||||||
|
* \code
|
||||||
|
* DockManager->setStyleSheet("");
|
||||||
|
* \endcode
|
||||||
**/
|
**/
|
||||||
class ADS_EXPORT CDockManager : public CDockContainerWidget
|
class ADS_EXPORT CDockManager : public CDockContainerWidget
|
||||||
{
|
{
|
||||||
@@ -62,10 +81,13 @@ private:
|
|||||||
friend class CFloatingDockContainer;
|
friend class CFloatingDockContainer;
|
||||||
friend struct FloatingDockContainerPrivate;
|
friend struct FloatingDockContainerPrivate;
|
||||||
friend class CDockContainerWidget;
|
friend class CDockContainerWidget;
|
||||||
|
friend class DockContainerWidgetPrivate;
|
||||||
friend class CDockAreaTabBar;
|
friend class CDockAreaTabBar;
|
||||||
friend class CDockWidgetTab;
|
friend class CDockWidgetTab;
|
||||||
friend struct DockAreaWidgetPrivate;
|
friend struct DockAreaWidgetPrivate;
|
||||||
friend struct DockWidgetTabPrivate;
|
friend struct DockWidgetTabPrivate;
|
||||||
|
friend class CFloatingDragPreview;
|
||||||
|
friend struct FloatingDragPreviewPrivate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
@@ -101,30 +123,53 @@ protected:
|
|||||||
*/
|
*/
|
||||||
CDockOverlay* dockAreaOverlay() const;
|
CDockOverlay* dockAreaOverlay() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the floating widgets that has been created floating
|
||||||
|
*/
|
||||||
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using Super = CDockContainerWidget;
|
||||||
|
|
||||||
enum eViewMenuInsertionOrder
|
enum eViewMenuInsertionOrder
|
||||||
{
|
{
|
||||||
MenuSortedByInsertion,
|
MenuSortedByInsertion,
|
||||||
MenuAlphabeticallySorted
|
MenuAlphabeticallySorted
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eXmlMode
|
|
||||||
{
|
|
||||||
XmlAutoFormattingDisabled,
|
|
||||||
XmlAutoFormattingEnabled
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These global configuration flags configure some global dock manager
|
* These global configuration flags configure some global dock manager
|
||||||
* settings.
|
* settings.
|
||||||
*/
|
*/
|
||||||
enum eConfigFlag
|
enum eConfigFlag
|
||||||
{
|
{
|
||||||
ActiveTabHasCloseButton = 0x01, //!< If this flag is set, the active tab in a tab area has a close button
|
ActiveTabHasCloseButton = 0x0001, //!< If this flag is set, the active tab in a tab area has a close button
|
||||||
DockAreaHasCloseButton = 0x02, //!< If the flag is set each dock area has a close button
|
DockAreaHasCloseButton = 0x0002, //!< If the flag is set each dock area has a close button
|
||||||
DockAreaCloseButtonClosesTab = 0x04,//!< If the flag is set, the dock area close button closes the active tab, if not set, it closes the complete cock area
|
DockAreaCloseButtonClosesTab = 0x0004,//!< If the flag is set, the dock area close button closes the active tab, if not set, it closes the complete cock area
|
||||||
OpaqueSplitterResize = 0x08, //!< See QSplitter::setOpaqueResize() documentation
|
OpaqueSplitterResize = 0x0008, //!< See QSplitter::setOpaqueResize() documentation
|
||||||
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize, ///< the default configuration
|
XmlAutoFormattingEnabled = 0x0010,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace).
|
||||||
|
XmlCompressionEnabled = 0x0020,//!< If enabled, the XML output will be compressed and is not human readable anymore
|
||||||
|
TabCloseButtonIsToolButton = 0x0040,//! If enabled the tab close buttons will be QToolButtons instead of QPushButtons - disabled by default
|
||||||
|
AllTabsHaveCloseButton = 0x0080, //!< if this flag is set, then all tabs that are closable show a close button
|
||||||
|
RetainTabSizeWhenCloseButtonHidden = 0x0100, //!< if this flag is set, the space for the close button is reserved even if the close button is not visible
|
||||||
|
OpaqueUndocking = 0x0200,///< If enabled, the widgets are immediately undocked into floating widgets, if disabled, only a draw preview is undocked and the real undocking is deferred until the mouse is released
|
||||||
|
DragPreviewIsDynamic = 0x0400,///< If opaque undocking is disabled, this flag defines the behavior of the drag preview window, if this flag is enabled, the preview will be adjusted dynamically to the drop area
|
||||||
|
DragPreviewShowsContentPixmap = 0x0800,///< If opaque undocking is disabled, the created drag preview window shows a copy of the content of the dock widget / dock are that is dragged
|
||||||
|
DragPreviewHasWindowFrame = 0x1000,///< If opaque undocking is disabled, then this flag configures if the drag preview is frameless or looks like a real window
|
||||||
|
DefaultConfig = ActiveTabHasCloseButton
|
||||||
|
| DockAreaHasCloseButton
|
||||||
|
| OpaqueSplitterResize
|
||||||
|
| XmlCompressionEnabled
|
||||||
|
| OpaqueUndocking, ///< the default configuration
|
||||||
|
DefaultNonOpaqueConfig = ActiveTabHasCloseButton
|
||||||
|
| DockAreaHasCloseButton
|
||||||
|
| XmlCompressionEnabled
|
||||||
|
| DragPreviewShowsContentPixmap, ///< the default configuration for non opaque operations
|
||||||
|
NonOpaqueWithWindowFrame = ActiveTabHasCloseButton
|
||||||
|
| DockAreaHasCloseButton
|
||||||
|
| XmlCompressionEnabled
|
||||||
|
| DragPreviewShowsContentPixmap
|
||||||
|
| DragPreviewHasWindowFrame ///< the default configuration for non opaque operations that show a real window with frame
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
|
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
|
||||||
|
|
||||||
@@ -133,7 +178,7 @@ public:
|
|||||||
* If the given parent is a QMainWindow, the dock manager sets itself as the
|
* If the given parent is a QMainWindow, the dock manager sets itself as the
|
||||||
* central widget.
|
* central widget.
|
||||||
* Before you create any dock widgets, you should properly setup the
|
* Before you create any dock widgets, you should properly setup the
|
||||||
* configuration flags via setConfigFlags()
|
* configuration flags via setConfigFlags().
|
||||||
*/
|
*/
|
||||||
CDockManager(QWidget* parent = 0);
|
CDockManager(QWidget* parent = 0);
|
||||||
|
|
||||||
@@ -145,13 +190,25 @@ public:
|
|||||||
/**
|
/**
|
||||||
* This function returns the global configuration flags
|
* This function returns the global configuration flags
|
||||||
*/
|
*/
|
||||||
ConfigFlags configFlags() const;
|
static ConfigFlags configFlags();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the global configuration flags for the whole docking system.
|
* Sets the global configuration flags for the whole docking system.
|
||||||
* Call this function before you create your first dock widget.
|
* Call this function before you create your first dock widget.
|
||||||
*/
|
*/
|
||||||
void setConfigFlags(const ConfigFlags Flags);
|
static void setConfigFlags(const ConfigFlags Flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a certain config flag
|
||||||
|
*/
|
||||||
|
static void setConfigFlag(eConfigFlag Flag, bool On = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the global icon provider.
|
||||||
|
* The icon provider enables the use of custom icons in case using
|
||||||
|
* styleheets for icons is not an option.
|
||||||
|
*/
|
||||||
|
static CIconProvider& iconProvider();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds dockwidget into the given area.
|
* Adds dockwidget into the given area.
|
||||||
@@ -185,6 +242,12 @@ public:
|
|||||||
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
|
||||||
CDockAreaWidget* DockAreaWidget);
|
CDockAreaWidget* DockAreaWidget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given DockWidget floating and returns the created
|
||||||
|
* CFloatingDockContainer instance.
|
||||||
|
*/
|
||||||
|
CFloatingDockContainer* addDockWidgetFloating(CDockWidget* Dockwidget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for a registered doc widget with the given ObjectName
|
* Searches for a registered doc widget with the given ObjectName
|
||||||
* \return Return the found dock widget or nullptr if a dock widget with the
|
* \return Return the found dock widget or nullptr if a dock widget with the
|
||||||
@@ -192,6 +255,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
CDockWidget* findDockWidget(const QString& ObjectName) const;
|
CDockWidget* findDockWidget(const QString& ObjectName) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the given Dock from the dock manager
|
||||||
|
*/
|
||||||
|
void removeDockWidget(CDockWidget* Dockwidget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns a readable reference to the internal dock
|
* This function returns a readable reference to the internal dock
|
||||||
* widgets map so that it is possible to iterate over all dock widgets
|
* widgets map so that it is possible to iterate over all dock widgets
|
||||||
@@ -223,7 +291,7 @@ public:
|
|||||||
* The XmlMode XmlAutoFormattingDisabled is better if you would like to have
|
* The XmlMode XmlAutoFormattingDisabled is better if you would like to have
|
||||||
* a more compact XML output - i.e. for storage in ini files.
|
* a more compact XML output - i.e. for storage in ini files.
|
||||||
*/
|
*/
|
||||||
QByteArray saveState(eXmlMode XmlMode = XmlAutoFormattingDisabled, int version = 0) const;
|
QByteArray saveState(int version = Version1) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores the state of this dockmanagers dockwidgets.
|
* Restores the state of this dockmanagers dockwidgets.
|
||||||
@@ -232,7 +300,7 @@ public:
|
|||||||
* returns false; otherwise, the state is restored, and this function
|
* returns false; otherwise, the state is restored, and this function
|
||||||
* returns true.
|
* returns true.
|
||||||
*/
|
*/
|
||||||
bool restoreState(const QByteArray &state, int version = 0);
|
bool restoreState(const QByteArray &state, int version = Version1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current perspective to the internal list of perspectives.
|
* Saves the current perspective to the internal list of perspectives.
|
||||||
@@ -365,6 +433,27 @@ signals:
|
|||||||
* perspective
|
* perspective
|
||||||
*/
|
*/
|
||||||
void perspectiveOpened(const QString& PerspectiveName);
|
void perspectiveOpened(const QString& PerspectiveName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted, if a new DockArea has been created.
|
||||||
|
* An application can use this signal to set custom icons or custom
|
||||||
|
* tooltips for the DockArea buttons.
|
||||||
|
*/
|
||||||
|
void dockAreaCreated(CDockAreaWidget* DockArea);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted just before the given dock widget is removed
|
||||||
|
* from the
|
||||||
|
*/
|
||||||
|
void dockWidgetAboutToBeRemoved(CDockWidget* DockWidget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted if a dock widget has been removed with the remove
|
||||||
|
* removeDockWidget() function.
|
||||||
|
* If this signal is emitted, the dock widget has been removed from the
|
||||||
|
* docking system but it is not deleted yet.
|
||||||
|
*/
|
||||||
|
void dockWidgetRemoved(CDockWidget* DockWidget);
|
||||||
}; // class DockManager
|
}; // class DockManager
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ struct DockOverlayPrivate
|
|||||||
DockWidgetAreas AllowedAreas = InvalidDockWidgetArea;
|
DockWidgetAreas AllowedAreas = InvalidDockWidgetArea;
|
||||||
CDockOverlayCross* Cross;
|
CDockOverlayCross* Cross;
|
||||||
QPointer<QWidget> TargetWidget;
|
QPointer<QWidget> TargetWidget;
|
||||||
QRect TargetRect;
|
|
||||||
DockWidgetArea LastLocation = InvalidDockWidgetArea;
|
DockWidgetArea LastLocation = InvalidDockWidgetArea;
|
||||||
bool DropPreviewEnabled = true;
|
bool DropPreviewEnabled = true;
|
||||||
CDockOverlay::eMode Mode = CDockOverlay::ModeDockAreaOverlay;
|
CDockOverlay::eMode Mode = CDockOverlay::ModeDockAreaOverlay;
|
||||||
@@ -132,6 +131,21 @@ struct DockOverlayCrossPrivate
|
|||||||
return Color;
|
return Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
/**
|
||||||
|
* Helper function that returns the drop indicator width depending on the
|
||||||
|
* operating system
|
||||||
|
*/
|
||||||
|
qreal dropIndicatiorWidth(QLabel* l) const
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
Q_UNUSED(l)
|
||||||
|
return 40;
|
||||||
|
#else
|
||||||
|
return static_cast<qreal>(l->fontMetrics().height()) * 3.f;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QWidget* createDropIndicatorWidget(DockWidgetArea DockWidgetArea,
|
QWidget* createDropIndicatorWidget(DockWidgetArea DockWidgetArea,
|
||||||
@@ -140,7 +154,7 @@ struct DockOverlayCrossPrivate
|
|||||||
QLabel* l = new QLabel();
|
QLabel* l = new QLabel();
|
||||||
l->setObjectName("DockWidgetAreaLabel");
|
l->setObjectName("DockWidgetAreaLabel");
|
||||||
|
|
||||||
const qreal metric = static_cast<qreal>(l->fontMetrics().height()) * 3.f;
|
const qreal metric = dropIndicatiorWidth(l);
|
||||||
const QSizeF size(metric, metric);
|
const QSizeF size(metric, metric);
|
||||||
|
|
||||||
l->setPixmap(createHighDpiDropIndicatorPixmap(size, DockWidgetArea, Mode));
|
l->setPixmap(createHighDpiDropIndicatorPixmap(size, DockWidgetArea, Mode));
|
||||||
@@ -154,7 +168,7 @@ struct DockOverlayCrossPrivate
|
|||||||
void updateDropIndicatorIcon(QWidget* DropIndicatorWidget)
|
void updateDropIndicatorIcon(QWidget* DropIndicatorWidget)
|
||||||
{
|
{
|
||||||
QLabel* l = qobject_cast<QLabel*>(DropIndicatorWidget);
|
QLabel* l = qobject_cast<QLabel*>(DropIndicatorWidget);
|
||||||
const qreal metric = static_cast<qreal>(l->fontMetrics().height()) * 3.f;
|
const qreal metric = dropIndicatiorWidth(l);
|
||||||
const QSizeF size(metric, metric);
|
const QSizeF size(metric, metric);
|
||||||
|
|
||||||
int Area = l->property("dockWidgetArea").toInt();
|
int Area = l->property("dockWidgetArea").toInt();
|
||||||
@@ -168,7 +182,11 @@ struct DockOverlayCrossPrivate
|
|||||||
QColor borderColor = iconColor(CDockOverlayCross::FrameColor);
|
QColor borderColor = iconColor(CDockOverlayCross::FrameColor);
|
||||||
QColor backgroundColor = iconColor(CDockOverlayCross::WindowBackgroundColor);
|
QColor backgroundColor = iconColor(CDockOverlayCross::WindowBackgroundColor);
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050600
|
||||||
double DevicePixelRatio = _this->window()->devicePixelRatioF();
|
double DevicePixelRatio = _this->window()->devicePixelRatioF();
|
||||||
|
#else
|
||||||
|
double DevicePixelRatio = _this->window()->devicePixelRatio();
|
||||||
|
#endif
|
||||||
QSizeF PixmapSize = size * DevicePixelRatio;
|
QSizeF PixmapSize = size * DevicePixelRatio;
|
||||||
QPixmap pm(PixmapSize.toSize());
|
QPixmap pm(PixmapSize.toSize());
|
||||||
pm.fill(QColor(0, 0, 0, 0));
|
pm.fill(QColor(0, 0, 0, 0));
|
||||||
@@ -314,7 +332,11 @@ CDockOverlay::CDockOverlay(QWidget* parent, eMode Mode) :
|
|||||||
{
|
{
|
||||||
d->Mode = Mode;
|
d->Mode = Mode;
|
||||||
d->Cross = new CDockOverlayCross(this);
|
d->Cross = new CDockOverlayCross(this);
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
||||||
|
#else
|
||||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||||
|
#endif
|
||||||
setWindowOpacity(1);
|
setWindowOpacity(1);
|
||||||
setWindowTitle("DockOverlay");
|
setWindowTitle("DockOverlay");
|
||||||
setAttribute(Qt::WA_NoSystemBackground);
|
setAttribute(Qt::WA_NoSystemBackground);
|
||||||
@@ -389,7 +411,6 @@ DockWidgetArea CDockOverlay::showOverlay(QWidget* target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->TargetWidget = target;
|
d->TargetWidget = target;
|
||||||
d->TargetRect = QRect();
|
|
||||||
d->LastLocation = InvalidDockWidgetArea;
|
d->LastLocation = InvalidDockWidgetArea;
|
||||||
|
|
||||||
// Move it over the target.
|
// Move it over the target.
|
||||||
@@ -408,8 +429,8 @@ void CDockOverlay::hideOverlay()
|
|||||||
{
|
{
|
||||||
hide();
|
hide();
|
||||||
d->TargetWidget.clear();
|
d->TargetWidget.clear();
|
||||||
d->TargetRect = QRect();
|
|
||||||
d->LastLocation = InvalidDockWidgetArea;
|
d->LastLocation = InvalidDockWidgetArea;
|
||||||
|
d->DropAreaRect = QRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -421,6 +442,13 @@ void CDockOverlay::enableDropPreview(bool Enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockOverlay::dropPreviewEnabled() const
|
||||||
|
{
|
||||||
|
return d->DropPreviewEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockOverlay::paintEvent(QPaintEvent* event)
|
void CDockOverlay::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
@@ -549,7 +577,11 @@ CDockOverlayCross::CDockOverlayCross(CDockOverlay* overlay) :
|
|||||||
d(new DockOverlayCrossPrivate(this))
|
d(new DockOverlayCrossPrivate(this))
|
||||||
{
|
{
|
||||||
d->DockOverlay = overlay;
|
d->DockOverlay = overlay;
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint);
|
||||||
|
#else
|
||||||
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||||
|
#endif
|
||||||
setWindowTitle("DockOverlayCross");
|
setWindowTitle("DockOverlayCross");
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
|
||||||
@@ -577,8 +609,11 @@ void CDockOverlayCross::setupOverlayCross(CDockOverlay::eMode Mode)
|
|||||||
areaWidgets.insert(BottomDockWidgetArea, d->createDropIndicatorWidget(BottomDockWidgetArea, Mode));
|
areaWidgets.insert(BottomDockWidgetArea, d->createDropIndicatorWidget(BottomDockWidgetArea, Mode));
|
||||||
areaWidgets.insert(LeftDockWidgetArea, d->createDropIndicatorWidget(LeftDockWidgetArea, Mode));
|
areaWidgets.insert(LeftDockWidgetArea, d->createDropIndicatorWidget(LeftDockWidgetArea, Mode));
|
||||||
areaWidgets.insert(CenterDockWidgetArea, d->createDropIndicatorWidget(CenterDockWidgetArea, Mode));
|
areaWidgets.insert(CenterDockWidgetArea, d->createDropIndicatorWidget(CenterDockWidgetArea, Mode));
|
||||||
|
#if QT_VERSION >= 0x050600
|
||||||
d->LastDevicePixelRatio = devicePixelRatioF();
|
d->LastDevicePixelRatio = devicePixelRatioF();
|
||||||
|
#else
|
||||||
|
d->LastDevicePixelRatio = devicePixelRatio();
|
||||||
|
#endif
|
||||||
setAreaWidgets(areaWidgets);
|
setAreaWidgets(areaWidgets);
|
||||||
d->UpdateRequired = false;
|
d->UpdateRequired = false;
|
||||||
}
|
}
|
||||||
@@ -596,7 +631,11 @@ void CDockOverlayCross::updateOverlayIcons()
|
|||||||
{
|
{
|
||||||
d->updateDropIndicatorIcon(Widget);
|
d->updateDropIndicatorIcon(Widget);
|
||||||
}
|
}
|
||||||
|
#if QT_VESION >= 0x050600
|
||||||
d->LastDevicePixelRatio = devicePixelRatioF();
|
d->LastDevicePixelRatio = devicePixelRatioF();
|
||||||
|
#else
|
||||||
|
d->LastDevicePixelRatio = devicePixelRatio();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void enableDropPreview(bool Enable);
|
void enableDropPreview(bool Enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if drop preview is enabled
|
||||||
|
*/
|
||||||
|
bool dropPreviewEnabled() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The drop overlay rectangle for the target area
|
* The drop overlay rectangle for the target area
|
||||||
*/
|
*/
|
||||||
@@ -245,9 +250,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent* e) override;
|
virtual void showEvent(QShowEvent* e) override;
|
||||||
void setAreaWidgets(const QHash<DockWidgetArea, QWidget*>& widgets);
|
void setAreaWidgets(const QHash<DockWidgetArea, QWidget*>& widgets);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
}; // CDockOverlayCross
|
}; // CDockOverlayCross
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ CDockSplitter::CDockSplitter(Qt::Orientation orientation, QWidget *parent)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
CDockSplitter::~CDockSplitter()
|
CDockSplitter::~CDockSplitter()
|
||||||
{
|
{
|
||||||
qDebug() << "~CDockSplitter";
|
ADS_PRINT("~CDockSplitter");
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ namespace ads
|
|||||||
struct DockSplitterPrivate;
|
struct DockSplitterPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splitter used internally instead of QSplitter
|
* Splitter used internally instead of QSplitter with some additional
|
||||||
|
* fuctionality.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CDockSplitter : public QSplitter
|
class ADS_EXPORT CDockSplitter : public QSplitter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <DockWidgetTab.h>
|
#include "DockWidgetTab.h"
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
@@ -58,14 +58,14 @@ namespace ads
|
|||||||
*/
|
*/
|
||||||
struct DockWidgetPrivate
|
struct DockWidgetPrivate
|
||||||
{
|
{
|
||||||
CDockWidget* _this;
|
CDockWidget* _this = nullptr;
|
||||||
QBoxLayout* Layout;
|
QBoxLayout* Layout = nullptr;
|
||||||
QWidget* Widget = nullptr;
|
QWidget* Widget = nullptr;
|
||||||
CDockWidgetTab* TabWidget;
|
CDockWidgetTab* TabWidget = nullptr;
|
||||||
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
|
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
|
||||||
CDockManager* DockManager = nullptr;
|
CDockManager* DockManager = nullptr;
|
||||||
CDockAreaWidget* DockArea = nullptr;
|
CDockAreaWidget* DockArea = nullptr;
|
||||||
QAction* ToggleViewAction;
|
QAction* ToggleViewAction = nullptr;
|
||||||
bool Closed = false;
|
bool Closed = false;
|
||||||
QScrollArea* ScrollArea = nullptr;
|
QScrollArea* ScrollArea = nullptr;
|
||||||
QToolBar* ToolBar = nullptr;
|
QToolBar* ToolBar = nullptr;
|
||||||
@@ -214,7 +214,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
setObjectName(title);
|
setObjectName(title);
|
||||||
|
|
||||||
d->TabWidget = new CDockWidgetTab(this);
|
d->TabWidget = new CDockWidgetTab(this);
|
||||||
d->ToggleViewAction = new QAction(title);
|
d->ToggleViewAction = new QAction(title, this);
|
||||||
d->ToggleViewAction->setCheckable(true);
|
d->ToggleViewAction->setCheckable(true);
|
||||||
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(toggleView(bool)));
|
SLOT(toggleView(bool)));
|
||||||
@@ -224,7 +224,7 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget::~CDockWidget()
|
CDockWidget::~CDockWidget()
|
||||||
{
|
{
|
||||||
qDebug() << "~CDockWidget()";
|
ADS_PRINT("~CDockWidget()");
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,21 +243,35 @@ void CDockWidget::setToggleViewActionChecked(bool Checked)
|
|||||||
void CDockWidget::setWidget(QWidget* widget, eInsertMode InsertMode)
|
void CDockWidget::setWidget(QWidget* widget, eInsertMode InsertMode)
|
||||||
{
|
{
|
||||||
QScrollArea* ScrollAreaWidget = qobject_cast<QScrollArea*>(widget);
|
QScrollArea* ScrollAreaWidget = qobject_cast<QScrollArea*>(widget);
|
||||||
if (ScrollAreaWidget || ForceNoScrollArea != InsertMode)
|
if (ScrollAreaWidget || ForceNoScrollArea == InsertMode)
|
||||||
|
{
|
||||||
|
d->Layout->addWidget(widget);
|
||||||
|
if (ScrollAreaWidget && ScrollAreaWidget->viewport())
|
||||||
|
{
|
||||||
|
ScrollAreaWidget->viewport()->setProperty("dockWidgetContent", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
d->setupScrollArea();
|
d->setupScrollArea();
|
||||||
d->ScrollArea->setWidget(widget);
|
d->ScrollArea->setWidget(widget);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
d->Layout->addWidget(widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
d->Widget = widget;
|
d->Widget = widget;
|
||||||
d->Widget->setProperty("dockWidgetContent", true);
|
d->Widget->setProperty("dockWidgetContent", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
QWidget* CDockWidget::takeWidget()
|
||||||
|
{
|
||||||
|
d->ScrollArea->takeWidget();
|
||||||
|
d->Layout->removeWidget(d->Widget);
|
||||||
|
d->Widget->setParent(nullptr);
|
||||||
|
return d->Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QWidget* CDockWidget::widget() const
|
QWidget* CDockWidget::widget() const
|
||||||
{
|
{
|
||||||
@@ -275,14 +289,21 @@ CDockWidgetTab* CDockWidget::tabWidget() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidget::setFeatures(DockWidgetFeatures features)
|
void CDockWidget::setFeatures(DockWidgetFeatures features)
|
||||||
{
|
{
|
||||||
|
if (d->Features == features)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
d->Features = features;
|
d->Features = features;
|
||||||
|
d->TabWidget->onDockWidgetFeaturesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidget::setFeature(DockWidgetFeature flag, bool on)
|
void CDockWidget::setFeature(DockWidgetFeature flag, bool on)
|
||||||
{
|
{
|
||||||
d->Features.setFlag(flag, on);
|
auto Features = features();
|
||||||
|
internal::setFlag(Features, flag, on);
|
||||||
|
setFeatures(Features);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -496,12 +517,45 @@ bool CDockWidget::event(QEvent *e)
|
|||||||
{
|
{
|
||||||
if (e->type() == QEvent::WindowTitleChange)
|
if (e->type() == QEvent::WindowTitleChange)
|
||||||
{
|
{
|
||||||
emit titleChanged(windowTitle());
|
const auto title = windowTitle();
|
||||||
|
if (d->TabWidget)
|
||||||
|
{
|
||||||
|
d->TabWidget->setText(title);
|
||||||
|
}
|
||||||
|
if (d->ToggleViewAction)
|
||||||
|
{
|
||||||
|
d->ToggleViewAction->setText(title);
|
||||||
|
}
|
||||||
|
if (d->DockArea)
|
||||||
|
{
|
||||||
|
d->DockArea->markTitleBarMenuOutdated();//update tabs menu
|
||||||
|
}
|
||||||
|
emit titleChanged(title);
|
||||||
}
|
}
|
||||||
return QFrame::event(e);
|
return Super::event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidget::setTabToolTip(const QString &text)
|
||||||
|
{
|
||||||
|
if (d->TabWidget)
|
||||||
|
{
|
||||||
|
d->TabWidget->setToolTip(text);
|
||||||
|
}
|
||||||
|
if (d->ToggleViewAction)
|
||||||
|
{
|
||||||
|
d->ToggleViewAction->setToolTip(text);
|
||||||
|
}
|
||||||
|
if (d->DockArea)
|
||||||
|
{
|
||||||
|
d->DockArea->markTitleBarMenuOutdated();//update tabs menu
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidget::setIcon(const QIcon& Icon)
|
void CDockWidget::setIcon(const QIcon& Icon)
|
||||||
{
|
{
|
||||||
@@ -671,6 +725,26 @@ QSize CDockWidget::minimumSizeHint() const
|
|||||||
return QSize(60, 40);
|
return QSize(60, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidget::setFloating()
|
||||||
|
{
|
||||||
|
if (isClosed())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
d->TabWidget->detachDockWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidget::deleteDockWidget()
|
||||||
|
{
|
||||||
|
dockManager()->removeDockWidget(this);
|
||||||
|
deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class CDockWidgetTab;
|
|||||||
class CDockManager;
|
class CDockManager;
|
||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
class CDockAreaWidget;
|
class CDockAreaWidget;
|
||||||
struct DockContainerWidgetPrivate;
|
class DockContainerWidgetPrivate;
|
||||||
|
class CFloatingDockContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The QDockWidget class provides a widget that can be docked inside a
|
* The QDockWidget class provides a widget that can be docked inside a
|
||||||
@@ -69,7 +70,7 @@ protected:
|
|||||||
friend class CFloatingDockContainer;
|
friend class CFloatingDockContainer;
|
||||||
friend class CDockManager;
|
friend class CDockManager;
|
||||||
friend struct DockManagerPrivate;
|
friend struct DockManagerPrivate;
|
||||||
friend struct DockContainerWidgetPrivate;
|
friend class DockContainerWidgetPrivate;
|
||||||
friend class CDockAreaTabBar;
|
friend class CDockAreaTabBar;
|
||||||
friend class CDockWidgetTab;
|
friend class CDockWidgetTab;
|
||||||
friend struct DockWidgetTabPrivate;
|
friend struct DockWidgetTabPrivate;
|
||||||
@@ -135,11 +136,14 @@ protected:
|
|||||||
void toggleViewInternal(bool Open);
|
void toggleViewInternal(bool Open);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using Super = QFrame;
|
||||||
|
|
||||||
enum DockWidgetFeature
|
enum DockWidgetFeature
|
||||||
{
|
{
|
||||||
DockWidgetClosable = 0x01,
|
DockWidgetClosable = 0x01,
|
||||||
DockWidgetMovable = 0x02,
|
DockWidgetMovable = 0x02,///< this feature is not properly implemented yet and is ignored
|
||||||
DockWidgetFloatable = 0x04,
|
DockWidgetFloatable = 0x04,
|
||||||
|
DockWidgetDeleteOnClose = 0x08, ///< deletes the dock widget when it is closed
|
||||||
AllDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable,
|
AllDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable,
|
||||||
NoDockWidgetFeatures = 0x00
|
NoDockWidgetFeatures = 0x00
|
||||||
};
|
};
|
||||||
@@ -235,6 +239,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea);
|
void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the widget from the dock and give ownership back to the caller
|
||||||
|
*/
|
||||||
|
QWidget* takeWidget();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the widget for the dock widget. This function returns zero if
|
* Returns the widget for the dock widget. This function returns zero if
|
||||||
* the widget has not been set.
|
* the widget has not been set.
|
||||||
@@ -242,7 +251,8 @@ public:
|
|||||||
QWidget* widget() const;
|
QWidget* widget() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the title bar widget of this dock widget
|
* Returns the tab widget of this dock widget that is shown in the dock
|
||||||
|
* area title bar
|
||||||
*/
|
*/
|
||||||
CDockWidgetTab* tabWidget() const;
|
CDockWidgetTab* tabWidget() const;
|
||||||
|
|
||||||
@@ -384,6 +394,14 @@ public:
|
|||||||
QSize toolBarIconSize(eState State) const;
|
QSize toolBarIconSize(eState State) const;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
|
/**
|
||||||
|
* This is function sets text tooltip for title bar widget
|
||||||
|
* and tooltip for toggle view action
|
||||||
|
*/
|
||||||
|
void setTabToolTip(const QString &text);
|
||||||
|
#endif
|
||||||
|
|
||||||
public: // reimplements QFrame -----------------------------------------------
|
public: // reimplements QFrame -----------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Emits titleChanged signal if title change event occurs
|
* Emits titleChanged signal if title change event occurs
|
||||||
@@ -397,6 +415,17 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void toggleView(bool Open = true);
|
void toggleView(bool Open = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will make a docked widget floating
|
||||||
|
*/
|
||||||
|
void setFloating();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will delete the dock widget and its content from the
|
||||||
|
* docking system
|
||||||
|
*/
|
||||||
|
void deleteDockWidget();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if the dock widget is opened or closed
|
* This signal is emitted if the dock widget is opened or closed
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <ElidingLabel.h>
|
#include <FloatingDragPreview.h>
|
||||||
|
#include "ElidingLabel.h"
|
||||||
#include "DockWidgetTab.h"
|
#include "DockWidgetTab.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
@@ -48,24 +49,14 @@
|
|||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "DockOverlay.h"
|
#include "DockOverlay.h"
|
||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
|
#include "IconProvider.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The different dragging states
|
|
||||||
*/
|
|
||||||
enum eDragState
|
|
||||||
{
|
|
||||||
DraggingInactive, //!< DraggingInactive
|
|
||||||
DraggingMousePressed, //!< DraggingMousePressed
|
|
||||||
DraggingTab, //!< DraggingTab
|
|
||||||
DraggingFloatingWidget//!< DraggingFloatingWidget
|
|
||||||
};
|
|
||||||
|
|
||||||
using tTabLabel = CElidingLabel;
|
using tTabLabel = CElidingLabel;
|
||||||
using tCloseButton = QPushButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data class of CDockWidgetTab class (pimpl)
|
* Private data class of CDockWidgetTab class (pimpl)
|
||||||
@@ -80,10 +71,11 @@ struct DockWidgetTabPrivate
|
|||||||
bool IsActiveTab = false;
|
bool IsActiveTab = false;
|
||||||
CDockAreaWidget* DockArea = nullptr;
|
CDockAreaWidget* DockArea = nullptr;
|
||||||
eDragState DragState = DraggingInactive;
|
eDragState DragState = DraggingInactive;
|
||||||
CFloatingDockContainer* FloatingWidget = nullptr;
|
IFloatingWidget* FloatingWidget = nullptr;
|
||||||
QIcon Icon;
|
QIcon Icon;
|
||||||
tCloseButton* CloseButton = nullptr;
|
QAbstractButton* CloseButton = nullptr;
|
||||||
QSpacerItem* IconTextSpacer;
|
QSpacerItem* IconTextSpacer;
|
||||||
|
QPoint TabDragStartPosition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@@ -103,7 +95,7 @@ struct DockWidgetTabPrivate
|
|||||||
/**
|
/**
|
||||||
* Test function for current drag state
|
* Test function for current drag state
|
||||||
*/
|
*/
|
||||||
bool isDraggingState(eDragState dragState)
|
bool isDraggingState(eDragState dragState) const
|
||||||
{
|
{
|
||||||
return this->DragState == dragState;
|
return this->DragState == dragState;
|
||||||
}
|
}
|
||||||
@@ -123,14 +115,49 @@ struct DockWidgetTabPrivate
|
|||||||
* Returns true, if floating has been started and false if floating
|
* Returns true, if floating has been started and false if floating
|
||||||
* is not possible for any reason
|
* is not possible for any reason
|
||||||
*/
|
*/
|
||||||
bool startFloating();
|
bool startFloating(eDragState DraggingState = DraggingFloatingWidget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the given config flag is set
|
* Returns true if the given config flag is set
|
||||||
*/
|
*/
|
||||||
bool testConfigFlag(CDockManager::eConfigFlag Flag) const
|
bool testConfigFlag(CDockManager::eConfigFlag Flag) const
|
||||||
{
|
{
|
||||||
return DockArea->dockManager()->configFlags().testFlag(Flag);
|
return CDockManager::configFlags().testFlag(Flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the close button as QPushButton or as QToolButton
|
||||||
|
*/
|
||||||
|
QAbstractButton* createCloseButton() const
|
||||||
|
{
|
||||||
|
if (testConfigFlag(CDockManager::TabCloseButtonIsToolButton))
|
||||||
|
{
|
||||||
|
auto Button = new QToolButton();
|
||||||
|
Button->setAutoRaise(true);
|
||||||
|
return Button;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new QPushButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
IFloatingWidget* createFloatingWidget(T* Widget, bool OpaqueUndocking)
|
||||||
|
{
|
||||||
|
if (OpaqueUndocking)
|
||||||
|
{
|
||||||
|
return new CFloatingDockContainer(Widget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto w = new CFloatingDragPreview(Widget);
|
||||||
|
_this->connect(w, &CFloatingDragPreview::draggingCanceled, [=]()
|
||||||
|
{
|
||||||
|
DragState = DraggingInactive;
|
||||||
|
});
|
||||||
|
return w;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// struct DockWidgetTabPrivate
|
// struct DockWidgetTabPrivate
|
||||||
@@ -153,17 +180,22 @@ void DockWidgetTabPrivate::createLayout()
|
|||||||
TitleLabel->setObjectName("dockWidgetTabLabel");
|
TitleLabel->setObjectName("dockWidgetTabLabel");
|
||||||
TitleLabel->setAlignment(Qt::AlignCenter);
|
TitleLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
CloseButton = new tCloseButton();
|
CloseButton = createCloseButton();
|
||||||
CloseButton->setObjectName("tabCloseButton");
|
CloseButton->setObjectName("tabCloseButton");
|
||||||
// The standard icons do does not look good on high DPI screens
|
QIcon CloseIcon = CDockManager::iconProvider().customIcon(TabCloseIcon);
|
||||||
QIcon CloseIcon = _this->style()->standardIcon(QStyle::SP_TitleBarCloseButton);
|
if (CloseIcon.isNull())
|
||||||
QPixmap normalPixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, CloseButton);
|
{
|
||||||
QPixmap disabledPixmap = internal::createTransparentPixmap(normalPixmap, 0.25);
|
// The standard icons do does not look good on high DPI screens
|
||||||
CloseIcon.addPixmap(disabledPixmap, QIcon::Disabled);
|
QPixmap normalPixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, CloseButton);
|
||||||
|
CloseIcon.addPixmap(normalPixmap, QIcon::Normal);
|
||||||
|
CloseIcon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
|
||||||
|
}
|
||||||
CloseButton->setIcon(CloseIcon);
|
CloseButton->setIcon(CloseIcon);
|
||||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
CloseButton->setVisible(false);
|
_this->onDockWidgetFeaturesChanged();
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
CloseButton->setToolTip(QObject::tr("Close Tab"));
|
CloseButton->setToolTip(QObject::tr("Close Tab"));
|
||||||
|
#endif
|
||||||
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
|
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
|
||||||
|
|
||||||
QFontMetrics fm(TitleLabel->font());
|
QFontMetrics fm(TitleLabel->font());
|
||||||
@@ -197,12 +229,12 @@ void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool DockWidgetTabPrivate::startFloating()
|
bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
|
||||||
{
|
{
|
||||||
auto dockContainer = DockWidget->dockContainer();
|
auto dockContainer = DockWidget->dockContainer();
|
||||||
qDebug() << "isFloating " << dockContainer->isFloating();
|
ADS_PRINT("isFloating " << dockContainer->isFloating());
|
||||||
qDebug() << "areaCount " << dockContainer->dockAreaCount();
|
ADS_PRINT("areaCount " << dockContainer->dockAreaCount());
|
||||||
qDebug() << "widgetCount " << DockWidget->dockAreaWidget()->dockWidgetsCount();
|
ADS_PRINT("widgetCount " << DockWidget->dockAreaWidget()->dockWidgetsCount());
|
||||||
// if this is the last dock widget inside of this floating widget,
|
// if this is the last dock widget inside of this floating widget,
|
||||||
// then it does not make any sense, to make it floating because
|
// then it does not make any sense, to make it floating because
|
||||||
// it is already floating
|
// it is already floating
|
||||||
@@ -213,27 +245,37 @@ bool DockWidgetTabPrivate::startFloating()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "startFloating";
|
ADS_PRINT("startFloating");
|
||||||
DragState = DraggingFloatingWidget;
|
DragState = DraggingState;
|
||||||
QSize Size = DockArea->size();
|
QSize Size = DockArea->size();
|
||||||
CFloatingDockContainer* FloatingWidget = nullptr;
|
IFloatingWidget* FloatingWidget = nullptr;
|
||||||
|
bool OpaqueUndocking = CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking) ||
|
||||||
|
(DraggingFloatingWidget != DraggingState);
|
||||||
|
|
||||||
|
// If section widget has multiple tabs, we take only one tab
|
||||||
|
// If it has only one single tab, we can move the complete
|
||||||
|
// dock area into floating widget
|
||||||
if (DockArea->dockWidgetsCount() > 1)
|
if (DockArea->dockWidgetsCount() > 1)
|
||||||
{
|
{
|
||||||
// If section widget has multiple tabs, we take only one tab
|
FloatingWidget = createFloatingWidget(DockWidget, OpaqueUndocking);
|
||||||
FloatingWidget = new CFloatingDockContainer(DockWidget);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If section widget has only one content widget, we can move the complete
|
FloatingWidget = createFloatingWidget(DockArea, OpaqueUndocking);
|
||||||
// dock area into floating widget
|
|
||||||
FloatingWidget = new CFloatingDockContainer(DockArea);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatingWidget->startFloating(DragStartMousePosition, Size);
|
if (DraggingFloatingWidget == DraggingState)
|
||||||
auto Overlay = DockWidget->dockManager()->containerOverlay();
|
{
|
||||||
Overlay->setAllowedAreas(OuterDockAreas);
|
FloatingWidget->startFloating(DragStartMousePosition, Size, DraggingFloatingWidget, _this);
|
||||||
this->FloatingWidget = FloatingWidget;
|
auto Overlay = DockWidget->dockManager()->containerOverlay();
|
||||||
DockWidget->emitTopLevelChanged(true);
|
Overlay->setAllowedAreas(OuterDockAreas);
|
||||||
|
this->FloatingWidget = FloatingWidget;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FloatingWidget->startFloating(DragStartMousePosition, Size, DraggingInactive, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +293,7 @@ CDockWidgetTab::CDockWidgetTab(CDockWidget* DockWidget, QWidget *parent) :
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidgetTab::~CDockWidgetTab()
|
CDockWidgetTab::~CDockWidgetTab()
|
||||||
{
|
{
|
||||||
qDebug() << "~CDockWidgetTab()";
|
ADS_PRINT("~CDockWidgetTab()");
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +309,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
|
|||||||
emit clicked();
|
emit clicked();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QFrame::mousePressEvent(ev);
|
Super::mousePressEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -275,15 +317,31 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
|
void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
// End of tab moving, emit signal
|
if (ev->button() == Qt::LeftButton)
|
||||||
if (d->isDraggingState(DraggingTab) && d->DockArea)
|
|
||||||
{
|
{
|
||||||
emit moved(ev->globalPos());
|
auto CurrentDragState = d->DragState;
|
||||||
|
d->DragStartMousePosition = QPoint();
|
||||||
|
d->DragState = DraggingInactive;
|
||||||
|
|
||||||
|
switch (CurrentDragState)
|
||||||
|
{
|
||||||
|
case DraggingTab:
|
||||||
|
// End of tab moving, emit signal
|
||||||
|
if (d->DockArea)
|
||||||
|
{
|
||||||
|
emit moved(ev->globalPos());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DraggingFloatingWidget:
|
||||||
|
d->FloatingWidget->finishDragging();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:; // do nothing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->DragStartMousePosition = QPoint();
|
Super::mouseReleaseEvent(ev);
|
||||||
d->DragState = DraggingInactive;
|
|
||||||
QFrame::mouseReleaseEvent(ev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -293,7 +351,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||||
{
|
{
|
||||||
d->DragState = DraggingInactive;
|
d->DragState = DraggingInactive;
|
||||||
QFrame::mouseMoveEvent(ev);
|
Super::mouseMoveEvent(ev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +359,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
if (d->isDraggingState(DraggingFloatingWidget))
|
if (d->isDraggingState(DraggingFloatingWidget))
|
||||||
{
|
{
|
||||||
d->FloatingWidget->moveFloating();
|
d->FloatingWidget->moveFloating();
|
||||||
QFrame::mouseMoveEvent(ev);
|
Super::mouseMoveEvent(ev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,8 +386,14 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Floating is only allowed for widgets that are movable
|
// Floating is only allowed for widgets that are movable
|
||||||
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetMovable))
|
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
{
|
{
|
||||||
|
// If we undock, we need to restore the initial position of this
|
||||||
|
// tab because it looks strange if it remains on its dragged position
|
||||||
|
if (d->isDraggingState(DraggingTab) && !CDockManager::configFlags().testFlag(CDockManager::OpaqueUndocking))
|
||||||
|
{
|
||||||
|
this->move(d->TabDragStartPosition);
|
||||||
|
}
|
||||||
d->startFloating();
|
d->startFloating();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -337,11 +401,17 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
else if (d->DockArea->openDockWidgetsCount() > 1
|
else if (d->DockArea->openDockWidgetsCount() > 1
|
||||||
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
|
&& (ev->pos() - d->DragStartMousePosition).manhattanLength() >= QApplication::startDragDistance()) // Wait a few pixels before start moving
|
||||||
{
|
{
|
||||||
|
// If we start dragging the tab, we save its inital position to
|
||||||
|
// restore it later
|
||||||
|
if (DraggingTab != d->DragState)
|
||||||
|
{
|
||||||
|
d->TabDragStartPosition = this->pos();
|
||||||
|
}
|
||||||
d->DragState = DraggingTab;
|
d->DragState = DraggingTab;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFrame::mouseMoveEvent(ev);
|
Super::mouseMoveEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -349,13 +419,17 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||||
{
|
{
|
||||||
ev->accept();
|
ev->accept();
|
||||||
std::cout << "CDockAreaTabBar::onTabContextMenuRequested" << std::endl;
|
if (d->isDraggingState(DraggingFloatingWidget))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
d->DragStartMousePosition = ev->pos();
|
d->DragStartMousePosition = ev->pos();
|
||||||
QMenu Menu(this);
|
QMenu Menu(this);
|
||||||
Menu.addAction(tr("Detach"), this, SLOT(onDetachActionTriggered()));
|
auto Action = Menu.addAction(tr("Detach"), this, SLOT(detachDockWidget()));
|
||||||
|
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||||
Menu.addSeparator();
|
Menu.addSeparator();
|
||||||
auto Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||||
Action->setEnabled(isClosable());
|
Action->setEnabled(isClosable());
|
||||||
Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
||||||
Menu.exec(mapToGlobal(ev->pos()));
|
Menu.exec(mapToGlobal(ev->pos()));
|
||||||
@@ -373,8 +447,10 @@ bool CDockWidgetTab::isActiveTab() const
|
|||||||
void CDockWidgetTab::setActiveTab(bool active)
|
void CDockWidgetTab::setActiveTab(bool active)
|
||||||
{
|
{
|
||||||
bool DockWidgetClosable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable);
|
bool DockWidgetClosable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetClosable);
|
||||||
bool TabHasCloseButton = d->testConfigFlag(CDockManager::ActiveTabHasCloseButton);
|
bool ActiveTabHasCloseButton = d->testConfigFlag(CDockManager::ActiveTabHasCloseButton);
|
||||||
d->CloseButton->setVisible(active && DockWidgetClosable && TabHasCloseButton);
|
bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton);
|
||||||
|
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
|
||||||
|
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
||||||
if (d->IsActiveTab == active)
|
if (d->IsActiveTab == active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -426,7 +502,9 @@ void CDockWidgetTab::setIcon(const QIcon& Icon)
|
|||||||
d->IconLabel = new QLabel();
|
d->IconLabel = new QLabel();
|
||||||
d->IconLabel->setAlignment(Qt::AlignVCenter);
|
d->IconLabel->setAlignment(Qt::AlignVCenter);
|
||||||
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
d->IconLabel->setToolTip(d->TitleLabel->toolTip());
|
d->IconLabel->setToolTip(d->TitleLabel->toolTip());
|
||||||
|
#endif
|
||||||
Layout->insertWidget(0, d->IconLabel, Qt::AlignVCenter);
|
Layout->insertWidget(0, d->IconLabel, Qt::AlignVCenter);
|
||||||
Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0));
|
Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0));
|
||||||
}
|
}
|
||||||
@@ -442,7 +520,7 @@ void CDockWidgetTab::setIcon(const QIcon& Icon)
|
|||||||
d->Icon = Icon;
|
d->Icon = Icon;
|
||||||
if (d->IconLabel)
|
if (d->IconLabel)
|
||||||
{
|
{
|
||||||
d->IconLabel->setPixmap(Icon.pixmap(this->windowHandle(), QSize(16, 16)));
|
d->IconLabel->setPixmap(Icon.pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this)));
|
||||||
d->IconLabel->setVisible(true);
|
d->IconLabel->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,10 +546,11 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
// If this is the last dock area in a dock container it does not make
|
// 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
|
// sense to move it to a new floating widget and leave this one
|
||||||
// empty
|
// empty
|
||||||
if (!d->DockArea->dockContainer()->isFloating() || d->DockArea->dockWidgetsCount() > 1)
|
if ((!d->DockArea->dockContainer()->isFloating() || d->DockArea->dockWidgetsCount() > 1)
|
||||||
|
&& d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
{
|
{
|
||||||
d->DragStartMousePosition = event->pos();
|
d->DragStartMousePosition = event->pos();
|
||||||
d->startFloating();
|
d->startFloating(DraggingInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
Super::mouseDoubleClickEvent(event);
|
Super::mouseDoubleClickEvent(event);
|
||||||
@@ -486,6 +565,14 @@ void CDockWidgetTab::setVisible(bool visible)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidgetTab::setText(const QString& title)
|
||||||
|
{
|
||||||
|
d->TitleLabel->setText(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockWidgetTab::isClosable() const
|
bool CDockWidgetTab::isClosable() const
|
||||||
{
|
{
|
||||||
@@ -494,13 +581,44 @@ bool CDockWidgetTab::isClosable() const
|
|||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CDockWidgetTab::onDetachActionTriggered()
|
void CDockWidgetTab::detachDockWidget()
|
||||||
{
|
{
|
||||||
|
if (!d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
d->DragStartMousePosition = mapFromGlobal(QCursor::pos());
|
d->DragStartMousePosition = mapFromGlobal(QCursor::pos());
|
||||||
d->startFloating();
|
d->startFloating(DraggingInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ads
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CDockWidgetTab::event(QEvent *e)
|
||||||
|
{
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
|
if (e->type() == QEvent::ToolTipChange)
|
||||||
|
{
|
||||||
|
const auto text = toolTip();
|
||||||
|
d->TitleLabel->setToolTip(text);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return Super::event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidgetTab::onDockWidgetFeaturesChanged()
|
||||||
|
{
|
||||||
|
auto Features = d->DockWidget->features();
|
||||||
|
auto SizePolicy = d->CloseButton->sizePolicy();
|
||||||
|
SizePolicy.setRetainSizeWhenHidden(Features.testFlag(CDockWidget::DockWidgetClosable)
|
||||||
|
&& d->testConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden));
|
||||||
|
d->CloseButton->setSizePolicy(SizePolicy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace ads
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// EOF DockWidgetTab.cpp
|
// EOF DockWidgetTab.cpp
|
||||||
|
|||||||
@@ -53,9 +53,11 @@ class ADS_EXPORT CDockWidgetTab : public QFrame
|
|||||||
private:
|
private:
|
||||||
DockWidgetTabPrivate* d; ///< private data (pimpl)
|
DockWidgetTabPrivate* d; ///< private data (pimpl)
|
||||||
friend struct DockWidgetTabPrivate;
|
friend struct DockWidgetTabPrivate;
|
||||||
|
friend class CDockWidget;
|
||||||
|
void onDockWidgetFeaturesChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDetachActionTriggered();
|
void detachDockWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QMouseEvent* ev) override;
|
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||||
@@ -125,13 +127,24 @@ public:
|
|||||||
*/
|
*/
|
||||||
QString text() const;
|
QString text() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the tab text
|
||||||
|
*/
|
||||||
|
void setText(const QString& title);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns true if the assigned dock widget is closeable
|
* This function returns true if the assigned dock widget is closeable
|
||||||
*/
|
*/
|
||||||
bool isClosable() const;
|
bool isClosable() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track event ToolTipChange and set child ToolTip
|
||||||
|
*/
|
||||||
|
virtual bool event(QEvent *e) override;
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setVisible(bool visible);
|
virtual void setVisible(bool visible) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activeTabChanged();
|
void activeTabChanged();
|
||||||
|
|||||||
30
src/DockingStateReader.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
//============================================================================
|
||||||
|
/// \file DockingStateReader.cpp
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 29.11.2019
|
||||||
|
/// \brief Implementation of CDockingStateReader
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include "DockingStateReader.h"
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockingStateReader::setFileVersion(int FileVersion)
|
||||||
|
{
|
||||||
|
m_FileVersion = FileVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
int CDockingStateReader::fileVersion() const
|
||||||
|
{
|
||||||
|
return m_FileVersion;
|
||||||
|
}
|
||||||
|
} // namespace ads
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// EOF DockingStateReader.cpp
|
||||||
43
src/DockingStateReader.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#ifndef DockingStateReaderH
|
||||||
|
#define DockingStateReaderH
|
||||||
|
//============================================================================
|
||||||
|
/// \file DockingStateReader.h
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 29.11.2019
|
||||||
|
/// \brief Declaration of CDockingStateReader
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends QXmlStreamReader with file version information
|
||||||
|
*/
|
||||||
|
class CDockingStateReader : public QXmlStreamReader
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int m_FileVersion;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using QXmlStreamReader::QXmlStreamReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the file version for this state reader
|
||||||
|
*/
|
||||||
|
void setFileVersion(int FileVersion);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the file version set via setFileVersion
|
||||||
|
*/
|
||||||
|
int fileVersion() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ads
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
#endif // DockingStateReaderH
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <ElidingLabel.h>
|
#include "ElidingLabel.h"
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
|
||||||
@@ -88,7 +88,9 @@ CElidingLabel::CElidingLabel(const QString& text, QWidget* parent, Qt::WindowFla
|
|||||||
d(new ElidingLabelPrivate(this))
|
d(new ElidingLabelPrivate(this))
|
||||||
{
|
{
|
||||||
d->Text = text;
|
d->Text = text;
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
setToolTip(text);
|
setToolTip(text);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -155,7 +157,11 @@ QSize CElidingLabel::minimumSizeHint() const
|
|||||||
return QLabel::minimumSizeHint();
|
return QLabel::minimumSizeHint();
|
||||||
}
|
}
|
||||||
const QFontMetrics &fm = fontMetrics();
|
const QFontMetrics &fm = fontMetrics();
|
||||||
QSize size(fm.width(d->Text.left(2) + "…"), fm.height());
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
|
QSize size(fm.horizontalAdvance(d->Text.left(2) + "…"), fm.height());
|
||||||
|
#else
|
||||||
|
QSize size(fm.width(d->Text.left(2) + "…"), fm.height());
|
||||||
|
#endif
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +174,11 @@ QSize CElidingLabel::sizeHint() const
|
|||||||
return QLabel::sizeHint();
|
return QLabel::sizeHint();
|
||||||
}
|
}
|
||||||
const QFontMetrics& fm = fontMetrics();
|
const QFontMetrics& fm = fontMetrics();
|
||||||
QSize size(fm.width(d->Text), QLabel::sizeHint().height());
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
|
QSize size(fm.horizontalAdvance(d->Text), QLabel::sizeHint().height());
|
||||||
|
#else
|
||||||
|
QSize size(fm.width(d->Text), QLabel::sizeHint().height());
|
||||||
|
#endif
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +193,9 @@ void CElidingLabel::setText(const QString &text)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
d->Text = text;
|
d->Text = text;
|
||||||
|
#ifndef QT_NO_TOOLTIP
|
||||||
setToolTip( text );
|
setToolTip( text );
|
||||||
|
#endif
|
||||||
d->elideText(this->size().width());
|
d->elideText(this->size().width());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "ads_globals.h"
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
struct ElidingLabelPrivate;
|
struct ElidingLabelPrivate;
|
||||||
@@ -41,12 +43,12 @@ struct ElidingLabelPrivate;
|
|||||||
* and reading the text via a pointer to the base class QLabel does not work
|
* and reading the text via a pointer to the base class QLabel does not work
|
||||||
* properly
|
* properly
|
||||||
*/
|
*/
|
||||||
class CElidingLabel : public QLabel
|
class ADS_EXPORT CElidingLabel : public QLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
ElidingLabelPrivate* d;
|
ElidingLabelPrivate* d;
|
||||||
friend class ElidingLabelPrivate;
|
friend struct ElidingLabelPrivate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseReleaseEvent(QMouseEvent* event) override;
|
virtual void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Qt Advanced Docking System
|
** Qt Advanced Docking System
|
||||||
** Copyright (C) 2017 Uwe Kindler
|
** Copyright (C) 2017 Uwe Kindler
|
||||||
**
|
**
|
||||||
** This library is free software; you can redistribute it and/or
|
** This library is free software; you can redistribute it and/or
|
||||||
** modify it under the terms of the GNU Lesser General Public
|
** modify it under the terms of the GNU Lesser General Public
|
||||||
** License as published by the Free Software Foundation; either
|
** License as published by the Free Software Foundation; either
|
||||||
** version 2.1 of the License, or (at your option) any later version.
|
** 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,
|
** This library is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
** Lesser General Public License for more details.
|
** Lesser General Public License for more details.
|
||||||
**
|
**
|
||||||
** You should have received a copy of the GNU Lesser General Public
|
** 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/>.
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/// \file FloatingDockContainer.cpp
|
/// \file FloatingDockContainer.cpp
|
||||||
@@ -24,7 +23,6 @@
|
|||||||
/// \brief Implementation of CFloatingDockContainer class
|
/// \brief Implementation of CFloatingDockContainer class
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@@ -45,42 +43,39 @@
|
|||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "DockOverlay.h"
|
#include "DockOverlay.h"
|
||||||
|
|
||||||
#include <iostream>
|
#ifdef Q_OS_LINUX
|
||||||
|
#include "linux/FloatingWidgetTitleBar.h"
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
static unsigned int zOrderCounter = 0;
|
static unsigned int zOrderCounter = 0;
|
||||||
/**
|
|
||||||
* The different dragging states
|
|
||||||
*/
|
|
||||||
enum eDragState
|
|
||||||
{
|
|
||||||
StateInactive, //!< DraggingInactive
|
|
||||||
StateMousePressed, //!< DraggingMousePressed
|
|
||||||
StateDraggingActive//!< DraggingFloatingWidget
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data class of CFloatingDockContainer class (pimpl)
|
* Private data class of CFloatingDockContainer class (pimpl)
|
||||||
*/
|
*/
|
||||||
struct FloatingDockContainerPrivate
|
struct FloatingDockContainerPrivate
|
||||||
{
|
{
|
||||||
CFloatingDockContainer* _this;
|
CFloatingDockContainer *_this;
|
||||||
CDockContainerWidget* DockContainer;
|
CDockContainerWidget *DockContainer;
|
||||||
unsigned int zOrderIndex = ++zOrderCounter;
|
unsigned int zOrderIndex = ++zOrderCounter;
|
||||||
QPointer<CDockManager> DockManager;
|
QPointer<CDockManager> DockManager;
|
||||||
eDragState DraggingState = StateInactive;
|
eDragState DraggingState = DraggingInactive;
|
||||||
QPoint DragStartMousePosition;
|
QPoint DragStartMousePosition;
|
||||||
CDockContainerWidget* DropContainer = nullptr;
|
CDockContainerWidget *DropContainer = nullptr;
|
||||||
CDockAreaWidget* SingleDockArea = nullptr;
|
CDockAreaWidget *SingleDockArea = nullptr;
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QWidget* MouseEventHandler = nullptr;
|
||||||
|
CFloatingWidgetTitleBar* TitleBar = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
*/
|
*/
|
||||||
FloatingDockContainerPrivate(CFloatingDockContainer* _public);
|
FloatingDockContainerPrivate(CFloatingDockContainer *_public);
|
||||||
|
|
||||||
void titleMouseReleaseEvent();
|
void titleMouseReleaseEvent();
|
||||||
void updateDropOverlays(const QPoint& GlobalPos);
|
void updateDropOverlays(const QPoint &GlobalPos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests is a certain state is active
|
* Tests is a certain state is active
|
||||||
@@ -94,48 +89,60 @@ struct FloatingDockContainerPrivate
|
|||||||
{
|
{
|
||||||
DraggingState = StateId;
|
DraggingState = StateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setWindowTitle(const QString &Text)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
TitleBar->setTitle(Text);
|
||||||
|
#else
|
||||||
|
_this->setWindowTitle(Text);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// struct FloatingDockContainerPrivate
|
// struct FloatingDockContainerPrivate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
FloatingDockContainerPrivate::FloatingDockContainerPrivate(CFloatingDockContainer* _public) :
|
FloatingDockContainerPrivate::FloatingDockContainerPrivate(
|
||||||
|
CFloatingDockContainer *_public) :
|
||||||
_this(_public)
|
_this(_public)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
||||||
{
|
{
|
||||||
setState(StateInactive);
|
setState(DraggingInactive);
|
||||||
if (!DropContainer)
|
if (!DropContainer)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DockManager->dockAreaOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea
|
if (DockManager->dockAreaOverlay()->dropAreaUnderCursor()
|
||||||
|| DockManager->containerOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea)
|
!= InvalidDockWidgetArea
|
||||||
|
|| DockManager->containerOverlay()->dropAreaUnderCursor()
|
||||||
|
!= InvalidDockWidgetArea)
|
||||||
{
|
{
|
||||||
// Resize the floating widget to the size of the highlighted drop area
|
// Resize the floating widget to the size of the highlighted drop area
|
||||||
// rectangle
|
// rectangle
|
||||||
CDockOverlay* Overlay = DockManager->containerOverlay();
|
CDockOverlay *Overlay = DockManager->containerOverlay();
|
||||||
if (!Overlay->dropOverlayRect().isValid())
|
if (!Overlay->dropOverlayRect().isValid())
|
||||||
{
|
{
|
||||||
Overlay = DockManager->dockAreaOverlay();
|
Overlay = DockManager->dockAreaOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect Rect = Overlay->dropOverlayRect();
|
QRect Rect = Overlay->dropOverlayRect();
|
||||||
int FrameWidth = (_this->frameSize().width() - _this->rect().width()) / 2;
|
int FrameWidth = (_this->frameSize().width() - _this->rect().width())
|
||||||
int TitleBarHeight = _this->frameSize().height() - _this->rect().height() - FrameWidth;
|
/ 2;
|
||||||
|
int TitleBarHeight = _this->frameSize().height()
|
||||||
|
- _this->rect().height() - FrameWidth;
|
||||||
if (Rect.isValid())
|
if (Rect.isValid())
|
||||||
{
|
{
|
||||||
QPoint TopLeft = Overlay->mapToGlobal(Rect.topLeft());
|
QPoint TopLeft = Overlay->mapToGlobal(Rect.topLeft());
|
||||||
TopLeft.ry() += TitleBarHeight;
|
TopLeft.ry() += TitleBarHeight;
|
||||||
_this->setGeometry(QRect(TopLeft, QSize(Rect.width(), Rect.height() - TitleBarHeight)));
|
_this->setGeometry(
|
||||||
|
QRect(TopLeft,
|
||||||
|
QSize(Rect.width(), Rect.height() - TitleBarHeight)));
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
DropContainer->dropFloatingWidget(_this, QCursor::pos());
|
DropContainer->dropFloatingWidget(_this, QCursor::pos());
|
||||||
@@ -145,128 +152,150 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
|||||||
DockManager->dockAreaOverlay()->hideOverlay();
|
DockManager->dockAreaOverlay()->hideOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
|
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
|
||||||
{
|
{
|
||||||
if (!_this->isVisible() || !DockManager)
|
if (!_this->isVisible() || !DockManager)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Containers = DockManager->dockContainers();
|
auto Containers = DockManager->dockContainers();
|
||||||
CDockContainerWidget* TopContainer = nullptr;
|
CDockContainerWidget *TopContainer = nullptr;
|
||||||
for (auto ContainerWidget : Containers)
|
for (auto ContainerWidget : Containers)
|
||||||
{
|
{
|
||||||
if (!ContainerWidget->isVisible())
|
if (!ContainerWidget->isVisible())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DockContainer == ContainerWidget)
|
if (DockContainer == ContainerWidget)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
|
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
|
||||||
if (ContainerWidget->rect().contains(MappedPos))
|
if (ContainerWidget->rect().contains(MappedPos))
|
||||||
{
|
{
|
||||||
if (!TopContainer || ContainerWidget->isInFrontOf(TopContainer))
|
if (!TopContainer || ContainerWidget->isInFrontOf(TopContainer))
|
||||||
{
|
{
|
||||||
TopContainer = ContainerWidget;
|
TopContainer = ContainerWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DropContainer = TopContainer;
|
DropContainer = TopContainer;
|
||||||
auto ContainerOverlay = DockManager->containerOverlay();
|
auto ContainerOverlay = DockManager->containerOverlay();
|
||||||
auto DockAreaOverlay = DockManager->dockAreaOverlay();
|
auto DockAreaOverlay = DockManager->dockAreaOverlay();
|
||||||
|
|
||||||
if (!TopContainer)
|
if (!TopContainer)
|
||||||
{
|
{
|
||||||
ContainerOverlay->hideOverlay();
|
ContainerOverlay->hideOverlay();
|
||||||
DockAreaOverlay->hideOverlay();
|
DockAreaOverlay->hideOverlay();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
|
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
|
||||||
ContainerOverlay->setAllowedAreas(VisibleDockAreas > 1 ?
|
ContainerOverlay->setAllowedAreas(
|
||||||
OuterDockAreas : AllDockAreas);
|
VisibleDockAreas > 1 ? OuterDockAreas : AllDockAreas);
|
||||||
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
|
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
|
||||||
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);
|
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);
|
||||||
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
|
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
|
||||||
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0)
|
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0)
|
||||||
{
|
{
|
||||||
DockAreaOverlay->enableDropPreview(true);
|
DockAreaOverlay->enableDropPreview(true);
|
||||||
DockAreaOverlay->setAllowedAreas((VisibleDockAreas == 1) ?
|
DockAreaOverlay->setAllowedAreas(
|
||||||
NoDockWidgetArea : AllDockAreas);
|
(VisibleDockAreas == 1) ? NoDockWidgetArea : AllDockAreas);
|
||||||
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
|
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
|
||||||
|
|
||||||
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that
|
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that
|
||||||
// the mouse is in the title bar. If the ContainerArea is valid
|
// the mouse is in the title bar. If the ContainerArea is valid
|
||||||
// then we ignore the dock area of the dockAreaOverlay() and disable
|
// then we ignore the dock area of the dockAreaOverlay() and disable
|
||||||
// the drop preview
|
// the drop preview
|
||||||
if ((Area == CenterDockWidgetArea) && (ContainerArea != InvalidDockWidgetArea))
|
if ((Area == CenterDockWidgetArea)
|
||||||
{
|
&& (ContainerArea != InvalidDockWidgetArea))
|
||||||
DockAreaOverlay->enableDropPreview(false);
|
{
|
||||||
ContainerOverlay->enableDropPreview(true);
|
DockAreaOverlay->enableDropPreview(false);
|
||||||
}
|
ContainerOverlay->enableDropPreview(true);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
ContainerOverlay->enableDropPreview(InvalidDockWidgetArea == Area);
|
{
|
||||||
}
|
ContainerOverlay->enableDropPreview(InvalidDockWidgetArea == Area);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
DockAreaOverlay->hideOverlay();
|
{
|
||||||
}
|
DockAreaOverlay->hideOverlay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
|
CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
|
||||||
QWidget(DockManager, Qt::Window),
|
tFloatingWidgetBase(DockManager),
|
||||||
d(new FloatingDockContainerPrivate(this))
|
d(new FloatingDockContainerPrivate(this))
|
||||||
{
|
{
|
||||||
d->DockManager = DockManager;
|
d->DockManager = DockManager;
|
||||||
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
|
d->DockContainer = new CDockContainerWidget(DockManager, this);
|
||||||
l->setContentsMargins(0, 0, 0, 0);
|
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this,
|
||||||
l->setSpacing(0);
|
SLOT(onDockAreasAddedOrRemoved()));
|
||||||
setLayout(l);
|
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this,
|
||||||
|
SLOT(onDockAreasAddedOrRemoved()));
|
||||||
|
|
||||||
d->DockContainer = new CDockContainerWidget(DockManager, this);
|
#ifdef Q_OS_LINUX
|
||||||
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this, SLOT(onDockAreasAddedOrRemoved()));
|
d->TitleBar = new CFloatingWidgetTitleBar(this);
|
||||||
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved()));
|
setWindowFlags(windowFlags() | Qt::Tool);
|
||||||
|
QDockWidget::setWidget(d->DockContainer);
|
||||||
|
QDockWidget::setFloating(true);
|
||||||
|
QDockWidget::setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||||
|
setTitleBarWidget(d->TitleBar);
|
||||||
|
connect(d->TitleBar, SIGNAL(closeRequested()), SLOT(close()));
|
||||||
|
#else
|
||||||
|
setWindowFlags(
|
||||||
|
Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
|
||||||
|
QBoxLayout *l = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
|
l->setContentsMargins(0, 0, 0, 0);
|
||||||
|
l->setSpacing(0);
|
||||||
|
setLayout(l);
|
||||||
l->addWidget(d->DockContainer);
|
l->addWidget(d->DockContainer);
|
||||||
DockManager->registerFloatingWidget(this);
|
#endif
|
||||||
|
|
||||||
// We install an event filter to detect mouse release events because we
|
DockManager->registerFloatingWidget(this);
|
||||||
// do not receive mouse release event if the floating widget is behind
|
|
||||||
// the drop overlay cross
|
|
||||||
qApp->installEventFilter(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) :
|
CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget *DockArea) :
|
||||||
CFloatingDockContainer(DockArea->dockManager())
|
CFloatingDockContainer(DockArea->dockManager())
|
||||||
{
|
{
|
||||||
d->DockContainer->addDockArea(DockArea);
|
d->DockContainer->addDockArea(DockArea);
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
d->TitleBar->enableCloseButton(isClosable());
|
||||||
|
#endif
|
||||||
|
auto TopLevelDockWidget = topLevelDockWidget();
|
||||||
|
if (TopLevelDockWidget)
|
||||||
|
{
|
||||||
|
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer::CFloatingDockContainer(CDockWidget* DockWidget) :
|
CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
|
||||||
CFloatingDockContainer(DockWidget->dockManager())
|
CFloatingDockContainer(DockWidget->dockManager())
|
||||||
{
|
{
|
||||||
d->DockContainer->addDockWidget(CenterDockWidgetArea, DockWidget);
|
d->DockContainer->addDockWidget(CenterDockWidgetArea, DockWidget);
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
d->TitleBar->enableCloseButton(isClosable());
|
||||||
|
#endif
|
||||||
|
auto TopLevelDockWidget = topLevelDockWidget();
|
||||||
|
if (TopLevelDockWidget)
|
||||||
|
{
|
||||||
|
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer::~CFloatingDockContainer()
|
CFloatingDockContainer::~CFloatingDockContainer()
|
||||||
{
|
{
|
||||||
qDebug() << "~CFloatingDockContainer";
|
ADS_PRINT("~CFloatingDockContainer");
|
||||||
if (d->DockManager)
|
if (d->DockManager)
|
||||||
{
|
{
|
||||||
d->DockManager->removeFloatingWidget(this);
|
d->DockManager->removeFloatingWidget(this);
|
||||||
@@ -274,68 +303,106 @@ CFloatingDockContainer::~CFloatingDockContainer()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockContainerWidget* CFloatingDockContainer::dockContainer() const
|
CDockContainerWidget* CFloatingDockContainer::dockContainer() const
|
||||||
{
|
{
|
||||||
return d->DockContainer;
|
return d->DockContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::changeEvent(QEvent *event)
|
void CFloatingDockContainer::changeEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::changeEvent(event);
|
QWidget::changeEvent(event);
|
||||||
if ((event->type() == QEvent::ActivationChange) && isActiveWindow())
|
if ((event->type() == QEvent::ActivationChange) && isActiveWindow())
|
||||||
{
|
{
|
||||||
qDebug() << "FloatingWidget::changeEvent QEvent::ActivationChange ";
|
ADS_PRINT("FloatingWidget::changeEvent QEvent::ActivationChange ");
|
||||||
d->zOrderIndex = ++zOrderCounter;
|
d->zOrderIndex = ++zOrderCounter;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
||||||
{
|
{
|
||||||
QWidget::moveEvent(event);
|
QWidget::moveEvent(event);
|
||||||
switch (d->DraggingState)
|
switch (d->DraggingState)
|
||||||
{
|
{
|
||||||
case StateMousePressed:
|
case DraggingMousePressed:
|
||||||
d->setState(StateDraggingActive);
|
d->setState(DraggingFloatingWidget);
|
||||||
d->updateDropOverlays(QCursor::pos());
|
d->updateDropOverlays(QCursor::pos());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case StateDraggingActive:
|
case DraggingFloatingWidget:
|
||||||
d->updateDropOverlays(QCursor::pos());
|
d->updateDropOverlays(QCursor::pos());
|
||||||
break;
|
#ifdef Q_OS_MACOS
|
||||||
|
// In OSX when hiding the DockAreaOverlay the application would set
|
||||||
|
// the main window as the active window for some reason. This fixes
|
||||||
|
// that by resetting the active window to the floating widget after
|
||||||
|
// updating the overlays.
|
||||||
|
QApplication::setActiveWindow(this);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
qDebug() << "CFloatingDockContainer closeEvent";
|
ADS_PRINT("CFloatingDockContainer closeEvent");
|
||||||
d->setState(StateInactive);
|
d->setState(DraggingInactive);
|
||||||
|
|
||||||
if (isClosable())
|
if (isClosable())
|
||||||
{
|
{
|
||||||
QWidget::closeEvent(event);
|
auto TopLevelDockWidget = topLevelDockWidget();
|
||||||
}
|
if (TopLevelDockWidget && TopLevelDockWidget->features().testFlag(CDockWidget::DockWidgetDeleteOnClose))
|
||||||
else
|
{
|
||||||
{
|
TopLevelDockWidget->deleteDockWidget();
|
||||||
|
this->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
// In Qt version after 5.9.2 there seems to be a bug that causes the
|
||||||
|
// QWidget::event() function to not receive any NonClientArea mouse
|
||||||
|
// events anymore after a close/show cycle. The bug is reported here:
|
||||||
|
// https://bugreports.qt.io/browse/QTBUG-73295
|
||||||
|
// The following code is a workaround for Qt versions > 5.9.2 that seems
|
||||||
|
// to work
|
||||||
|
// Starting from Qt version 5.12.2 this seems to work again. But
|
||||||
|
// now the QEvent::NonClientAreaMouseButtonPress function returns always
|
||||||
|
// Qt::RightButton even if the left button was pressed
|
||||||
|
#ifndef Q_OS_LINUX
|
||||||
|
#if (QT_VERSION > QT_VERSION_CHECK(5, 9, 2) && QT_VERSION < QT_VERSION_CHECK(5, 12, 2))
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
this->hide();
|
||||||
|
#else
|
||||||
|
Super::closeEvent(event);
|
||||||
|
#endif
|
||||||
|
#else // Q_OS_LINUX
|
||||||
|
Super::closeEvent(event);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
Super::hideEvent(event);
|
Super::hideEvent(event);
|
||||||
|
if (event->spontaneous())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent toogleView() events during restore state
|
||||||
|
if (d->DockManager->isRestoringState())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto DockArea : d->DockContainer->openedDockAreas())
|
for (auto DockArea : d->DockContainer->openedDockAreas())
|
||||||
{
|
{
|
||||||
for (auto DockWidget : DockArea->openedDockWidgets())
|
for (auto DockWidget : DockArea->openedDockWidgets())
|
||||||
@@ -345,69 +412,78 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::showEvent(QShowEvent *event)
|
void CFloatingDockContainer::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
Super::showEvent(event);
|
Super::showEvent(event);
|
||||||
/*for (auto DockArea : d->DockContainer->openedDockAreas())
|
|
||||||
{
|
|
||||||
for (auto DockWidget : DockArea->openedDockWidgets())
|
|
||||||
{
|
|
||||||
DockWidget->setToggleViewActionChecked(true);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::event(QEvent *e)
|
bool CFloatingDockContainer::event(QEvent *e)
|
||||||
{
|
{
|
||||||
switch (d->DraggingState)
|
switch (d->DraggingState)
|
||||||
{
|
{
|
||||||
case StateInactive:
|
case DraggingInactive:
|
||||||
if (e->type() == QEvent::NonClientAreaMouseButtonPress && QGuiApplication::mouseButtons() == Qt::LeftButton)
|
{
|
||||||
|
// Normally we would check here, if the left mouse button is pressed.
|
||||||
|
// But from QT version 5.12.2 on the mouse events from
|
||||||
|
// QEvent::NonClientAreaMouseButtonPress return the wrong mouse button
|
||||||
|
// The event always returns Qt::RightButton even if the left button
|
||||||
|
// is clicked.
|
||||||
|
// It is really great to work around the whole NonClientMouseArea
|
||||||
|
// bugs
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 2))
|
||||||
|
if (e->type()
|
||||||
|
== QEvent::NonClientAreaMouseButtonPress /*&& QGuiApplication::mouseButtons().testFlag(Qt::LeftButton)*/)
|
||||||
{
|
{
|
||||||
qDebug() << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type();
|
ADS_PRINT("FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type());
|
||||||
d->setState(StateMousePressed);
|
d->setState(DraggingMousePressed);
|
||||||
}
|
}
|
||||||
break;
|
#else
|
||||||
|
if (e->type() == QEvent::NonClientAreaMouseButtonPress && QGuiApplication::mouseButtons().testFlag(Qt::LeftButton))
|
||||||
|
{
|
||||||
|
ADS_PRINT("FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type());
|
||||||
|
d->setState(DraggingMousePressed);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case StateMousePressed:
|
case DraggingMousePressed:
|
||||||
switch (e->type())
|
switch (e->type())
|
||||||
{
|
{
|
||||||
case QEvent::NonClientAreaMouseButtonDblClick:
|
case QEvent::NonClientAreaMouseButtonDblClick:
|
||||||
qDebug() << "FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick";
|
ADS_PRINT("FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick");
|
||||||
d->setState(StateInactive);
|
d->setState(DraggingInactive);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::Resize:
|
case QEvent::Resize:
|
||||||
// If the first event after the mouse press is a resize event, then
|
// If the first event after the mouse press is a resize event, then
|
||||||
// the user resizes the window instead of dragging it around.
|
// the user resizes the window instead of dragging it around.
|
||||||
// But there is one exception. If the window is maximized,
|
// But there is one exception. If the window is maximized,
|
||||||
// then dragging the window via title bar will cause the widget to
|
// then dragging the window via title bar will cause the widget to
|
||||||
// leave the maximized state. This in turn will trigger a resize event.
|
// leave the maximized state. This in turn will trigger a resize event.
|
||||||
// To know, if the resize event was triggered by user via moving a
|
// To know, if the resize event was triggered by user via moving a
|
||||||
// corner of the window frame or if it was caused by a windows state
|
// corner of the window frame or if it was caused by a windows state
|
||||||
// change, we check, if we are not in maximized state.
|
// change, we check, if we are not in maximized state.
|
||||||
if (!isMaximized())
|
if (!isMaximized())
|
||||||
{
|
{
|
||||||
d->setState(StateInactive);
|
d->setState(DraggingInactive);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case StateDraggingActive:
|
case DraggingFloatingWidget:
|
||||||
if (e->type() == QEvent::NonClientAreaMouseButtonRelease)
|
if (e->type() == QEvent::NonClientAreaMouseButtonRelease)
|
||||||
{
|
{
|
||||||
qDebug() << "FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease";
|
ADS_PRINT("FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease");
|
||||||
d->titleMouseReleaseEvent();
|
d->titleMouseReleaseEvent();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -421,97 +497,95 @@ bool CFloatingDockContainer::event(QEvent *e)
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
|
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
|
||||||
{
|
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
|
||||||
Q_UNUSED(watched);
|
|
||||||
if (event->type() == QEvent::MouseButtonRelease && d->isState(StateDraggingActive))
|
|
||||||
{
|
|
||||||
qDebug() << "FloatingWidget::eventFilter QEvent::MouseButtonRelease";
|
|
||||||
d->titleMouseReleaseEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
|
||||||
void CFloatingDockContainer::startFloating(const QPoint& Pos, const QSize& Size)
|
|
||||||
{
|
{
|
||||||
|
#ifndef Q_OS_LINUX
|
||||||
|
Q_UNUSED(MouseEventHandler)
|
||||||
|
#endif
|
||||||
resize(Size);
|
resize(Size);
|
||||||
d->setState(StateDraggingActive);
|
d->setState(DragState);
|
||||||
QPoint TargetPos = QCursor::pos() - Pos;
|
d->DragStartMousePosition = DragStartMousePos;
|
||||||
move(TargetPos);
|
#ifdef Q_OS_LINUX
|
||||||
show();
|
if (DraggingFloatingWidget == DragState)
|
||||||
d->DragStartMousePosition = Pos;
|
{
|
||||||
|
setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
|
||||||
|
d->MouseEventHandler = MouseEventHandler;
|
||||||
|
if (d->MouseEventHandler)
|
||||||
|
{
|
||||||
|
d->MouseEventHandler->grabMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
moveFloating();
|
||||||
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::moveFloating()
|
void CFloatingDockContainer::moveFloating()
|
||||||
{
|
{
|
||||||
int BorderSize = (frameSize().width() - size().width()) / 2;
|
int BorderSize = (frameSize().width() - size().width()) / 2;
|
||||||
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition - QPoint(BorderSize, 0);
|
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition
|
||||||
|
- QPoint(BorderSize, 0);
|
||||||
move(moveToPos);
|
move(moveToPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::isClosable() const
|
bool CFloatingDockContainer::isClosable() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->features().testFlag(CDockWidget::DockWidgetClosable);
|
return d->DockContainer->features().testFlag(
|
||||||
|
CDockWidget::DockWidgetClosable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
||||||
{
|
{
|
||||||
qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()";
|
ADS_PRINT("CFloatingDockContainer::onDockAreasAddedOrRemoved()");
|
||||||
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
|
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
|
||||||
if (TopLevelDockArea)
|
if (TopLevelDockArea)
|
||||||
{
|
{
|
||||||
d->SingleDockArea = TopLevelDockArea;
|
d->SingleDockArea = TopLevelDockArea;
|
||||||
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
d->setWindowTitle(
|
||||||
|
d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||||
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
||||||
SLOT(onDockAreaCurrentChanged(int)));
|
SLOT(onDockAreaCurrentChanged(int)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (d->SingleDockArea)
|
if (d->SingleDockArea)
|
||||||
{
|
{
|
||||||
disconnect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
disconnect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
||||||
SLOT(onDockAreaCurrentChanged(int)));
|
SLOT(onDockAreaCurrentChanged(int)));
|
||||||
d->SingleDockArea = nullptr;
|
d->SingleDockArea = nullptr;
|
||||||
}
|
}
|
||||||
this->setWindowTitle(qApp->applicationDisplayName());
|
d->setWindowTitle(qApp->applicationDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::updateWindowTitle()
|
void CFloatingDockContainer::updateWindowTitle()
|
||||||
{
|
{
|
||||||
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
|
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
|
||||||
if (TopLevelDockArea)
|
if (TopLevelDockArea)
|
||||||
{
|
{
|
||||||
this->setWindowTitle(TopLevelDockArea->currentDockWidget()->windowTitle());
|
d->setWindowTitle(TopLevelDockArea->currentDockWidget()->windowTitle());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setWindowTitle(qApp->applicationDisplayName());
|
d->setWindowTitle(qApp->applicationDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
||||||
{
|
{
|
||||||
Q_UNUSED(Index);
|
Q_UNUSED(Index);
|
||||||
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::restoreState(QXmlStreamReader& Stream, bool Testing)
|
bool CFloatingDockContainer::restoreState(CDockingStateReader &Stream,
|
||||||
|
bool Testing)
|
||||||
{
|
{
|
||||||
if (!d->DockContainer->restoreState(Stream, Testing))
|
if (!d->DockContainer->restoreState(Stream, Testing))
|
||||||
{
|
{
|
||||||
@@ -522,27 +596,40 @@ bool CFloatingDockContainer::restoreState(QXmlStreamReader& Stream, bool Testing
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::hasTopLevelDockWidget() const
|
bool CFloatingDockContainer::hasTopLevelDockWidget() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->hasTopLevelDockWidget();
|
return d->DockContainer->hasTopLevelDockWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget* CFloatingDockContainer::topLevelDockWidget() const
|
CDockWidget* CFloatingDockContainer::topLevelDockWidget() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->topLevelDockWidget();
|
return d->DockContainer->topLevelDockWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->dockWidgets();
|
return d->DockContainer->dockWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDockContainer::finishDragging()
|
||||||
|
{
|
||||||
|
ADS_PRINT("CFloatingDockContainer::finishDragging");
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
setAttribute(Qt::WA_X11NetWmWindowTypeDock, false);
|
||||||
|
setWindowOpacity(1);
|
||||||
|
activateWindow();
|
||||||
|
if (d->MouseEventHandler)
|
||||||
|
{
|
||||||
|
d->MouseEventHandler->releaseMouse();
|
||||||
|
d->MouseEventHandler = nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
d->titleMouseReleaseEvent();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,19 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
|
|
||||||
class QXmlStreamReader;
|
#include <QRubberBand>
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
#include <QDockWidget>
|
||||||
|
#define tFloatingWidgetBase QDockWidget
|
||||||
|
#else
|
||||||
|
#include <QWidget>
|
||||||
|
#define tFloatingWidgetBase QWidget
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CDockingStateReader;
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
@@ -49,13 +57,49 @@ class CDockWidgetTab;
|
|||||||
struct DockWidgetTabPrivate;
|
struct DockWidgetTabPrivate;
|
||||||
class CDockAreaTitleBar;
|
class CDockAreaTitleBar;
|
||||||
struct DockAreaTitleBarPrivate;
|
struct DockAreaTitleBarPrivate;
|
||||||
|
class CFloatingWidgetTitleBar;
|
||||||
|
class CDockingStateReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pure virtual interface for floating widgets.
|
||||||
|
* This interface is used for opaque and non-opaque undocking. If opaque
|
||||||
|
* undocking is used, the a real CFloatingDockContainer widget will be created
|
||||||
|
*/
|
||||||
|
class IFloatingWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Starts floating.
|
||||||
|
* This function should get called typically from a mouse press event
|
||||||
|
* handler
|
||||||
|
*/
|
||||||
|
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
|
eDragState DragState, QWidget* MouseEventHandler) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the widget to a new position relative to the position given when
|
||||||
|
* startFloating() was called.
|
||||||
|
* This function should be called from a mouse mouve event handler to
|
||||||
|
* move the floating widget on mouse move events.
|
||||||
|
*/
|
||||||
|
virtual void moveFloating() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the widget that to finish dragging if the mouse is released.
|
||||||
|
* This function should be called from a mouse release event handler
|
||||||
|
* to finish the dragging
|
||||||
|
*/
|
||||||
|
virtual void finishDragging() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implements a floating widget that is a dock container that accepts
|
* This implements a floating widget that is a dock container that accepts
|
||||||
* docking of dock widgets like the main window and that can be docked into
|
* docking of dock widgets like the main window and that can be docked into
|
||||||
* another dock container
|
* another dock container.
|
||||||
|
* Every floating window of the docking system is a FloatingDockContainer.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CFloatingDockContainer : public QWidget
|
class ADS_EXPORT CFloatingDockContainer : public tFloatingWidgetBase, public IFloatingWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
@@ -70,6 +114,7 @@ private:
|
|||||||
friend struct DockAreaTitleBarPrivate;
|
friend struct DockAreaTitleBarPrivate;
|
||||||
friend class CDockWidget;
|
friend class CDockWidget;
|
||||||
friend class CDockAreaWidget;
|
friend class CDockAreaWidget;
|
||||||
|
friend class CFloatingWidgetTitleBar;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDockAreasAddedOrRemoved();
|
void onDockAreasAddedOrRemoved();
|
||||||
@@ -81,7 +126,32 @@ protected:
|
|||||||
* Use moveToGlobalPos() to move the widget to a new position
|
* Use moveToGlobalPos() to move the widget to a new position
|
||||||
* depending on the start position given in Pos parameter
|
* depending on the start position given in Pos parameter
|
||||||
*/
|
*/
|
||||||
void startFloating(const QPoint& Pos, const QSize& Size = QSize());
|
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
|
||||||
|
*/
|
||||||
|
virtual void finishDragging() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this function if you just want to initialize the position
|
||||||
|
* and size of the floating widget
|
||||||
|
*/
|
||||||
|
void initFloatingGeometry(const QPoint& DragStartMousePos, const QSize& Size)
|
||||||
|
{
|
||||||
|
startFloating(DragStartMousePos, Size, DraggingInactive, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the widget to a new position relative to the position given when
|
* Moves the widget to a new position relative to the position given when
|
||||||
@@ -95,7 +165,7 @@ protected:
|
|||||||
* stream but does not restore anything. You can use this check for
|
* stream but does not restore anything. You can use this check for
|
||||||
* faulty files before you start restoring the state
|
* faulty files before you start restoring the state
|
||||||
*/
|
*/
|
||||||
bool restoreState(QXmlStreamReader& Stream, bool Testing);
|
bool restoreState(CDockingStateReader& Stream, bool Testing);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this function to update the window title
|
* Call this function to update the window title
|
||||||
@@ -110,13 +180,12 @@ protected: // reimplements QWidget
|
|||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual void hideEvent(QHideEvent *event) override;
|
virtual void hideEvent(QHideEvent *event) override;
|
||||||
virtual void showEvent(QShowEvent *event) override;
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Super = QWidget;
|
using Super = QWidget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create empty flatingb widget - required for restore state
|
* Create empty floating widget - required for restore state
|
||||||
*/
|
*/
|
||||||
CFloatingDockContainer(CDockManager* DockManager);
|
CFloatingDockContainer(CDockManager* DockManager);
|
||||||
|
|
||||||
|
|||||||
405
src/FloatingDragPreview.cpp
Normal file
@@ -0,0 +1,405 @@
|
|||||||
|
//============================================================================
|
||||||
|
/// \file FloatingDragPreview.cpp
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 26.11.2019
|
||||||
|
/// \brief Implementation of CFloatingDragPreview
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include "FloatingDragPreview.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
#include "DockWidget.h"
|
||||||
|
#include "DockAreaWidget.h"
|
||||||
|
#include "DockManager.h"
|
||||||
|
#include "DockContainerWidget.h"
|
||||||
|
#include "DockOverlay.h"
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data class (pimpl)
|
||||||
|
*/
|
||||||
|
struct FloatingDragPreviewPrivate
|
||||||
|
{
|
||||||
|
CFloatingDragPreview *_this;
|
||||||
|
QWidget* Content;
|
||||||
|
CDockAreaWidget* ContentSourceArea = nullptr;
|
||||||
|
CDockContainerWidget* ContenSourceContainer = nullptr;
|
||||||
|
QPoint DragStartMousePosition;
|
||||||
|
CDockManager* DockManager;
|
||||||
|
CDockContainerWidget *DropContainer = nullptr;
|
||||||
|
qreal WindowOpacity;
|
||||||
|
bool Hidden = false;
|
||||||
|
QPixmap ContentPreviewPixmap;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data constructor
|
||||||
|
*/
|
||||||
|
FloatingDragPreviewPrivate(CFloatingDragPreview *_public);
|
||||||
|
void updateDropOverlays(const QPoint &GlobalPos);
|
||||||
|
|
||||||
|
void setHidden(bool Value)
|
||||||
|
{
|
||||||
|
Hidden = Value;
|
||||||
|
_this->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel dragging and emit the draggingCanceled event
|
||||||
|
*/
|
||||||
|
void cancelDragging()
|
||||||
|
{
|
||||||
|
emit _this->draggingCanceled();
|
||||||
|
DockManager->containerOverlay()->hideOverlay();
|
||||||
|
DockManager->dockAreaOverlay()->hideOverlay();
|
||||||
|
_this->close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// struct LedArrayPanelPrivate
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
|
||||||
|
{
|
||||||
|
if (!_this->isVisible() || !DockManager)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Containers = DockManager->dockContainers();
|
||||||
|
CDockContainerWidget *TopContainer = nullptr;
|
||||||
|
for (auto ContainerWidget : Containers)
|
||||||
|
{
|
||||||
|
if (!ContainerWidget->isVisible())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (DockContainer == ContainerWidget)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
|
||||||
|
if (ContainerWidget->rect().contains(MappedPos))
|
||||||
|
{
|
||||||
|
if (!TopContainer || ContainerWidget->isInFrontOf(TopContainer))
|
||||||
|
{
|
||||||
|
TopContainer = ContainerWidget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DropContainer = TopContainer;
|
||||||
|
auto ContainerOverlay = DockManager->containerOverlay();
|
||||||
|
auto DockAreaOverlay = DockManager->dockAreaOverlay();
|
||||||
|
auto DockDropArea = DockAreaOverlay->dropAreaUnderCursor();
|
||||||
|
auto ContainerDropArea = ContainerOverlay->dropAreaUnderCursor();
|
||||||
|
|
||||||
|
if (!TopContainer)
|
||||||
|
{
|
||||||
|
ContainerOverlay->hideOverlay();
|
||||||
|
DockAreaOverlay->hideOverlay();
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewIsDynamic))
|
||||||
|
{
|
||||||
|
setHidden(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
|
||||||
|
ContainerOverlay->setAllowedAreas(
|
||||||
|
VisibleDockAreas > 1 ? OuterDockAreas : AllDockAreas);
|
||||||
|
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
|
||||||
|
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);
|
||||||
|
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
|
||||||
|
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0 && DockArea != ContentSourceArea)
|
||||||
|
{
|
||||||
|
DockAreaOverlay->enableDropPreview(true);
|
||||||
|
DockAreaOverlay->setAllowedAreas(
|
||||||
|
(VisibleDockAreas == 1) ? NoDockWidgetArea : AllDockAreas);
|
||||||
|
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
|
||||||
|
|
||||||
|
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that
|
||||||
|
// the mouse is in the title bar. If the ContainerArea is valid
|
||||||
|
// then we ignore the dock area of the dockAreaOverlay() and disable
|
||||||
|
// the drop preview
|
||||||
|
if ((Area == CenterDockWidgetArea)
|
||||||
|
&& (ContainerArea != InvalidDockWidgetArea))
|
||||||
|
{
|
||||||
|
DockAreaOverlay->enableDropPreview(false);
|
||||||
|
ContainerOverlay->enableDropPreview(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ContainerOverlay->enableDropPreview(InvalidDockWidgetArea == Area);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DockAreaOverlay->hideOverlay();
|
||||||
|
if (DockArea == ContentSourceArea && InvalidDockWidgetArea == ContainerDropArea)
|
||||||
|
{
|
||||||
|
DropContainer = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewIsDynamic))
|
||||||
|
{
|
||||||
|
setHidden(DockDropArea != InvalidDockWidgetArea || ContainerDropArea != InvalidDockWidgetArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
FloatingDragPreviewPrivate::FloatingDragPreviewPrivate(CFloatingDragPreview *_public) :
|
||||||
|
_this(_public)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
d(new FloatingDragPreviewPrivate(this))
|
||||||
|
{
|
||||||
|
d->Content = Content;
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
|
||||||
|
{
|
||||||
|
setWindowFlags(
|
||||||
|
Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
||||||
|
setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
auto Flags = windowFlags();
|
||||||
|
Flags |= Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
|
||||||
|
setWindowFlags(Flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setWindowOpacity(0.6);
|
||||||
|
|
||||||
|
// Create a static image of the widget that should get undocked
|
||||||
|
// This is like some kind preview image like it is uses in drag and drop
|
||||||
|
// operations
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewShowsContentPixmap))
|
||||||
|
{
|
||||||
|
d->ContentPreviewPixmap = QPixmap(Content->size());
|
||||||
|
Content->render(&d->ContentPreviewPixmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
||||||
|
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
// In Windows this widget directly receives the escape key press events
|
||||||
|
// in Linux we need to install an event filter for the given Content
|
||||||
|
// widget to receive the escape key press
|
||||||
|
Content->installEventFilter(this);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
|
||||||
|
: CFloatingDragPreview((QWidget*)Content, Content->dockManager())
|
||||||
|
{
|
||||||
|
d->DockManager = Content->dockManager();
|
||||||
|
if (Content->dockAreaWidget()->openDockWidgetsCount() == 1)
|
||||||
|
{
|
||||||
|
d->ContentSourceArea = Content->dockAreaWidget();
|
||||||
|
d->ContenSourceContainer = Content->dockContainer();
|
||||||
|
}
|
||||||
|
setWindowTitle(Content->windowTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
|
||||||
|
: CFloatingDragPreview((QWidget*)Content, Content->dockManager())
|
||||||
|
{
|
||||||
|
d->DockManager = Content->dockManager();
|
||||||
|
d->ContentSourceArea = Content;
|
||||||
|
d->ContenSourceContainer = Content->dockContainer();
|
||||||
|
setWindowTitle(Content->currentDockWidget()->windowTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CFloatingDragPreview::~CFloatingDragPreview()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDragPreview::moveFloating()
|
||||||
|
{
|
||||||
|
int BorderSize = (frameSize().width() - size().width()) / 2;
|
||||||
|
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition
|
||||||
|
- QPoint(BorderSize, 0);
|
||||||
|
move(moveToPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDragPreview::startFloating(const QPoint &DragStartMousePos,
|
||||||
|
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
|
||||||
|
{
|
||||||
|
Q_UNUSED(MouseEventHandler)
|
||||||
|
Q_UNUSED(DragState)
|
||||||
|
resize(Size);
|
||||||
|
d->DragStartMousePosition = DragStartMousePos;
|
||||||
|
moveFloating();
|
||||||
|
show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDragPreview::moveEvent(QMoveEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::moveEvent(event);
|
||||||
|
d->updateDropOverlays(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDragPreview::finishDragging()
|
||||||
|
{
|
||||||
|
ADS_PRINT("CFloatingDragPreview::finishDragging");
|
||||||
|
auto DockDropArea = d->DockManager->dockAreaOverlay()->dropAreaUnderCursor();
|
||||||
|
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
|
||||||
|
bool DropPossible = (DockDropArea != InvalidDockWidgetArea) || (ContainerDropArea != InvalidDockWidgetArea);
|
||||||
|
if (d->DropContainer && DropPossible)
|
||||||
|
{
|
||||||
|
d->DropContainer->dropWidget(d->Content, QCursor::pos());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(d->Content);
|
||||||
|
CFloatingDockContainer* FloatingWidget;
|
||||||
|
if (DockWidget)
|
||||||
|
{
|
||||||
|
FloatingWidget = new CFloatingDockContainer(DockWidget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(d->Content);
|
||||||
|
FloatingWidget = new CFloatingDockContainer(DockArea);
|
||||||
|
}
|
||||||
|
FloatingWidget->setGeometry(this->geometry());
|
||||||
|
FloatingWidget->show();
|
||||||
|
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
|
||||||
|
{
|
||||||
|
QApplication::processEvents();
|
||||||
|
int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height();
|
||||||
|
QRect FixedGeometry = this->geometry();
|
||||||
|
FixedGeometry.adjust(0, FrameHeight, 0, 0);
|
||||||
|
FloatingWidget->setGeometry(FixedGeometry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->close();
|
||||||
|
d->DockManager->containerOverlay()->hideOverlay();
|
||||||
|
d->DockManager->dockAreaOverlay()->hideOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDragPreview::paintEvent(QPaintEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
if (d->Hidden)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::DragPreviewShowsContentPixmap))
|
||||||
|
{
|
||||||
|
painter.drawPixmap(QPoint(0, 0), d->ContentPreviewPixmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we do not have a window frame then we paint a QRubberBand like
|
||||||
|
// frameless window
|
||||||
|
if (!CDockManager::configFlags().testFlag(CDockManager::DragPreviewHasWindowFrame))
|
||||||
|
{
|
||||||
|
QColor Color = palette().color(QPalette::Active, QPalette::Highlight);
|
||||||
|
QPen Pen = painter.pen();
|
||||||
|
Pen.setColor(Color.darker(120));
|
||||||
|
Pen.setStyle(Qt::SolidLine);
|
||||||
|
Pen.setWidth(1);
|
||||||
|
Pen.setCosmetic(true);
|
||||||
|
painter.setPen(Pen);
|
||||||
|
Color = Color.lighter(130);
|
||||||
|
Color.setAlpha(64);
|
||||||
|
painter.setBrush(Color);
|
||||||
|
painter.drawRect(rect().adjusted(0, 0, -1, -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDragPreview::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
Super::keyPressEvent(event);
|
||||||
|
if (event->key() == Qt::Key_Escape)
|
||||||
|
{
|
||||||
|
d->cancelDragging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
|
||||||
|
{
|
||||||
|
if (state != Qt::ApplicationActive)
|
||||||
|
{
|
||||||
|
disconnect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
||||||
|
this, SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
||||||
|
d->cancelDragging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(watched);
|
||||||
|
if (event->type() == QEvent::KeyPress)
|
||||||
|
{
|
||||||
|
QKeyEvent* e = static_cast<QKeyEvent*>(event);
|
||||||
|
if (e->key() == Qt::Key_Escape)
|
||||||
|
{
|
||||||
|
d->Content->removeEventFilter(this);
|
||||||
|
d->cancelDragging();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace ads
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// EOF FloatingDragPreview.cpp
|
||||||
118
src/FloatingDragPreview.h
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
#ifndef FloatingDragPreviewH
|
||||||
|
#define FloatingDragPreviewH
|
||||||
|
//============================================================================
|
||||||
|
/// \file FloatingDragPreview.h
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 26.11.2019
|
||||||
|
/// \brief Declaration of CFloatingDragPreview
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include <QWidget>
|
||||||
|
#include "FloatingDockContainer.h"
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
class CDockWidget;
|
||||||
|
class CDockAreaWidget;
|
||||||
|
struct FloatingDragPreviewPrivate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A floating overlay is a temporary floating widget that is just used to
|
||||||
|
* indicate the floating widget movement.
|
||||||
|
* This widget is used as a placeholder for drag operations for non-opaque
|
||||||
|
* docking
|
||||||
|
*/
|
||||||
|
class CFloatingDragPreview : public QWidget, public IFloatingWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
FloatingDragPreviewPrivate* d;
|
||||||
|
friend class FloatingDragPreviewPrivate;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
/**
|
||||||
|
* Cancel non opaque undocking if application becomes inactive
|
||||||
|
*/
|
||||||
|
void onApplicationStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Updates the drop overlays
|
||||||
|
*/
|
||||||
|
virtual void moveEvent(QMoveEvent *event) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cares about painting the
|
||||||
|
*/
|
||||||
|
virtual void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel non opaque undocking with escape key
|
||||||
|
*/
|
||||||
|
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The content is a DockArea or a DockWidget
|
||||||
|
*/
|
||||||
|
CFloatingDragPreview(QWidget* Content, QWidget* parent);
|
||||||
|
|
||||||
|
public:
|
||||||
|
using Super = QWidget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance for undocking the DockWidget in Content parameter
|
||||||
|
*/
|
||||||
|
CFloatingDragPreview(CDockWidget* Content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance for undocking the DockArea given in Content
|
||||||
|
* parameters
|
||||||
|
*/
|
||||||
|
CFloatingDragPreview(CDockAreaWidget* Content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete private data
|
||||||
|
*/
|
||||||
|
~CFloatingDragPreview();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We filter the events of the assigned content widget to receive
|
||||||
|
* escape key presses for canceling the drag operation
|
||||||
|
*/
|
||||||
|
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
|
|
||||||
|
public: // implements IFloatingWidget -----------------------------------------
|
||||||
|
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||||
|
eDragState DragState, QWidget* MouseEventHandler) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the widget to a new position relative to the position given when
|
||||||
|
* startFloating() was called
|
||||||
|
*/
|
||||||
|
virtual void moveFloating() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finishes dragging.
|
||||||
|
* Hides the dock overlays and executes the real undocking and docking
|
||||||
|
* of the assigned Content widget
|
||||||
|
*/
|
||||||
|
virtual void finishDragging() override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* This signal is emitted, if dragging has been canceled by escape key
|
||||||
|
* or by active application switching via task manager
|
||||||
|
*/
|
||||||
|
void draggingCanceled();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace ads
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
#endif // FloatingDragPreviewH
|
||||||
|
|
||||||
73
src/IconProvider.cpp
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
//============================================================================
|
||||||
|
/// \file IconProvider.cpp
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 18.10.2019
|
||||||
|
/// \brief Implementation of CIconProvider
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include "IconProvider.h"
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Private data class (pimpl)
|
||||||
|
*/
|
||||||
|
struct IconProviderPrivate
|
||||||
|
{
|
||||||
|
CIconProvider *_this;
|
||||||
|
QVector<QIcon> UserIcons{IconCount, QIcon()};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private data constructor
|
||||||
|
*/
|
||||||
|
IconProviderPrivate(CIconProvider *_public);
|
||||||
|
};
|
||||||
|
// struct LedArrayPanelPrivate
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
IconProviderPrivate::IconProviderPrivate(CIconProvider *_public) :
|
||||||
|
_this(_public)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CIconProvider::CIconProvider() :
|
||||||
|
d(new IconProviderPrivate(this))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CIconProvider::~CIconProvider()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
QIcon CIconProvider::customIcon(eIcon IconId) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(IconId < d->UserIcons.size());
|
||||||
|
return d->UserIcons[IconId];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CIconProvider::registerCustomIcon(eIcon IconId, const QIcon &icon)
|
||||||
|
{
|
||||||
|
Q_ASSERT(IconId < d->UserIcons.size());
|
||||||
|
d->UserIcons[IconId] = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ads
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// EOF IconProvider.cpp
|
||||||
61
src/IconProvider.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#ifndef IconProviderH
|
||||||
|
#define IconProviderH
|
||||||
|
//============================================================================
|
||||||
|
/// \file IconProvider.h
|
||||||
|
/// \author Uwe Kindler
|
||||||
|
/// \date 18.10.2019
|
||||||
|
/// \brief Declaration of CIconProvider
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
// INCLUDES
|
||||||
|
//============================================================================
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include "ads_globals.h"
|
||||||
|
|
||||||
|
namespace ads
|
||||||
|
{
|
||||||
|
|
||||||
|
struct IconProviderPrivate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This object provides all icons that are required by the advanced docking
|
||||||
|
* system.
|
||||||
|
* The IconProvider enables the user to register custom icons in case using
|
||||||
|
* stylesheets is not an option.
|
||||||
|
*/
|
||||||
|
class ADS_EXPORT CIconProvider
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
IconProviderPrivate* d; ///< private data (pimpl)
|
||||||
|
friend class IconProviderPrivate;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Default Constructor
|
||||||
|
*/
|
||||||
|
CIconProvider();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual Destructor
|
||||||
|
*/
|
||||||
|
virtual ~CIconProvider();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function returns a custom icon if one is registered and a null Icon
|
||||||
|
* if no custom icon is registered
|
||||||
|
*/
|
||||||
|
QIcon customIcon(eIcon IconId) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a custom icon for the given IconId
|
||||||
|
*/
|
||||||
|
void registerCustomIcon(eIcon IconId, const QIcon &icon);
|
||||||
|
}; // class IconProvider
|
||||||
|
|
||||||
|
} // namespace ads
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
#endif // IconProviderH
|
||||||
@@ -3,5 +3,6 @@
|
|||||||
<file>stylesheets/default.css</file>
|
<file>stylesheets/default.css</file>
|
||||||
<file>images/close-button.svg</file>
|
<file>images/close-button.svg</file>
|
||||||
<file>images/close-button-disabled.svg</file>
|
<file>images/close-button-disabled.svg</file>
|
||||||
|
<file>stylesheets/default_linux.css</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace internal
|
|||||||
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To)
|
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To)
|
||||||
{
|
{
|
||||||
int index = Splitter->indexOf(From);
|
int index = Splitter->indexOf(From);
|
||||||
From->setParent(0);
|
From->setParent(nullptr);
|
||||||
Splitter->insertWidget(index, To);
|
Splitter->insertWidget(index, To);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +90,6 @@ void hideEmptyParentSplitters(CDockSplitter* Splitter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
|||||||
@@ -34,19 +34,40 @@
|
|||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#ifndef ADS_STATIC
|
||||||
#ifdef ADS_SHARED_EXPORT
|
#ifdef ADS_SHARED_EXPORT
|
||||||
#define ADS_EXPORT Q_DECL_EXPORT
|
#define ADS_EXPORT Q_DECL_EXPORT
|
||||||
#else
|
#else
|
||||||
#define ADS_EXPORT Q_DECL_IMPORT
|
#define ADS_EXPORT Q_DECL_IMPORT
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#define ADS_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Define ADS_DEBUG_PRINT to enable a lot of debug output
|
||||||
|
#ifdef ADS_DEBUG_PRINT
|
||||||
|
#define ADS_PRINT(s) qDebug() << s
|
||||||
|
#else
|
||||||
|
#define ADS_PRINT(s)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Set ADS_DEBUG_LEVEL to enable additional debug output and to enable layout
|
||||||
|
// dumps to qDebug and std::cout after layout changes
|
||||||
#define ADS_DEBUG_LEVEL 0
|
#define ADS_DEBUG_LEVEL 0
|
||||||
|
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
|
enum eStateFileVersion
|
||||||
|
{
|
||||||
|
InitialVerison = 0,
|
||||||
|
Version1 = 1,
|
||||||
|
CurrentVersion = Version1
|
||||||
|
};
|
||||||
|
|
||||||
class CDockSplitter;
|
class CDockSplitter;
|
||||||
|
|
||||||
enum DockWidgetArea
|
enum DockWidgetArea
|
||||||
@@ -72,10 +93,36 @@ enum TitleBarButton
|
|||||||
TitleBarButtonClose
|
TitleBarButtonClose
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The different dragging states
|
||||||
|
*/
|
||||||
|
enum eDragState
|
||||||
|
{
|
||||||
|
DraggingInactive, //!< DraggingInactive
|
||||||
|
DraggingMousePressed, //!< DraggingMousePressed
|
||||||
|
DraggingTab, //!< DraggingTab
|
||||||
|
DraggingFloatingWidget//!< DraggingFloatingWidget
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The different icons used in the UI
|
||||||
|
*/
|
||||||
|
enum eIcon
|
||||||
|
{
|
||||||
|
TabCloseIcon, //!< TabCloseIcon
|
||||||
|
DockAreaMenuIcon, //!< DockAreaMenuIcon
|
||||||
|
DockAreaUndockIcon,//!< DockAreaUndockIcon
|
||||||
|
DockAreaCloseIcon, //!< DockAreaCloseIcon
|
||||||
|
|
||||||
|
IconCount, //!< just a delimiter for range checks
|
||||||
|
};
|
||||||
|
|
||||||
namespace internal
|
namespace internal
|
||||||
{
|
{
|
||||||
static const bool RestoreTesting = true;
|
static const bool RestoreTesting = true;
|
||||||
static const bool Restore = false;
|
static const bool Restore = false;
|
||||||
|
static const char* const ClosedProperty = "close";
|
||||||
|
static const char* const DirtyProperty = "dirty";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace the from widget in the given splitter with the To widget
|
* Replace the from widget in the given splitter with the To widget
|
||||||
@@ -138,6 +185,27 @@ T findParent(const QWidget* w)
|
|||||||
*/
|
*/
|
||||||
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
|
QPixmap createTransparentPixmap(const QPixmap& Source, qreal Opacity);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function for settings flags in a QFlags instance.
|
||||||
|
*/
|
||||||
|
template <class T>
|
||||||
|
void setFlag(T& Flags, typename T::enum_type flag, bool on = true)
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x050700
|
||||||
|
Flags.setFlag(flag, on);
|
||||||
|
#else
|
||||||
|
if(on)
|
||||||
|
{
|
||||||
|
Flags |= flag;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Flags &= ~flag;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
|||||||