Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
9bd06401d9 | ||
|
|
b44a7e75ca | ||
|
|
c9645ef85b | ||
|
|
fd09a681c4 | ||
|
|
e113790bbe | ||
|
|
e352ce559b | ||
|
|
0c3ef64d3e | ||
|
|
f72e2ce058 | ||
|
|
befdcce343 | ||
|
|
6fc8964ffc | ||
|
|
6cb1f33451 | ||
|
|
ee616c2541 | ||
|
|
7dd2a3c83c | ||
|
|
9db502e652 | ||
|
|
1ad6caeb8a | ||
|
|
4dde545c8f | ||
|
|
b7a5918974 | ||
|
|
ddfa6c2a43 | ||
|
|
275520ae29 | ||
|
|
1078387f5d | ||
|
|
c33dddbd47 | ||
|
|
2570a880af | ||
|
|
40a8d9e6b4 |
160
.appveyor.yml
Normal file
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%
|
||||
18
.cproject
18
.cproject
@@ -71,15 +71,6 @@
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795;cdt.managedbuild.toolchain.gnu.mingw.base.1119687795.1949777584;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.1947822681;cdt.managedbuild.tool.gnu.cpp.compiler.input.1318830536">
|
||||
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795;cdt.managedbuild.toolchain.gnu.mingw.base.1119687795.1949777584;cdt.managedbuild.tool.gnu.c.compiler.mingw.base.389117097;cdt.managedbuild.tool.gnu.c.compiler.input.1568363924">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
|
||||
<buildTargets>
|
||||
<target name="Build all" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
@@ -356,4 +347,13 @@
|
||||
</target>
|
||||
</buildTargets>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795;cdt.managedbuild.toolchain.gnu.mingw.base.1119687795.1949777584;cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.1947822681;cdt.managedbuild.tool.gnu.cpp.compiler.input.1318830536">
|
||||
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795;cdt.managedbuild.toolchain.gnu.mingw.base.1119687795.1949777584;cdt.managedbuild.tool.gnu.c.compiler.mingw.base.389117097;cdt.managedbuild.tool.gnu.c.compiler.input.1568363924">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
|
||||
155
.travis.yml
Normal file
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
|
||||
|
||||
105
CMakeLists.txt
Normal file
105
CMakeLists.txt
Normal file
@@ -0,0 +1,105 @@
|
||||
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/ElidingLabel.cpp
|
||||
src/FloatingDockContainer.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/ElidingLabel.h
|
||||
src/FloatingDockContainer.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})
|
||||
set(ads_COMPILE_DEFINE ${ads_COMPILE_DEFINE} 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 adsBinary
|
||||
RUNTIME DESTINATION bin COMPONENT library
|
||||
LIBRARY DESTINATION lib COMPONENT library
|
||||
ARCHIVE DESTINATION lib COMPONENT library
|
||||
)
|
||||
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 "Qt Advanced Docking System"
|
||||
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()
|
||||
|
||||
25
README.md
25
README.md
@@ -1,4 +1,9 @@
|
||||
# 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
|
||||
featured window docking system similar to what is found in many popular
|
||||
@@ -56,7 +61,22 @@ main window layout.
|
||||

|
||||
|
||||
## 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)
|
||||
|
||||
The application can be compiled for Linux and has been developed and tested with **Kubuntu 18.04**.
|
||||
|
||||

|
||||
|
||||
## Build
|
||||
Open the `ads.pro` with QtCreator and start the build, that's it.
|
||||
@@ -138,5 +158,6 @@ MainWindow::~MainWindow()
|
||||
- Manuel Freiholz
|
||||
|
||||
## License information
|
||||
[](gnu-lgpl-v2.1.md)
|
||||
This project uses the [LGPLv2.1 license](gnu-lgpl-v2.1.md)
|
||||
|
||||
|
||||
48
demo/CMakeLists.txt
Normal file
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
|
||||
main.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"
|
||||
)
|
||||
@@ -88,6 +88,32 @@ 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)));
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
static ads::CDockWidget* createCalendarDockWidget(QMenu* ViewMenu)
|
||||
{
|
||||
@@ -110,7 +136,8 @@ static ads::CDockWidget* createFileSystemTreeDockWidget(QMenu* ViewMenu)
|
||||
QFileSystemModel* m = new QFileSystemModel(w);
|
||||
m->setRootPath(QDir::currentPath());
|
||||
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);
|
||||
ViewMenu->addAction(DockWidget->toggleViewAction());
|
||||
return DockWidget;
|
||||
@@ -127,7 +154,7 @@ struct MainWindowPrivate
|
||||
Ui::MainWindow ui;
|
||||
QAction* SavePerspectiveAction = nullptr;
|
||||
QWidgetAction* PerspectiveListAction = nullptr;
|
||||
QComboBox* PerspectiveComboBox = nullptr;;
|
||||
QComboBox* PerspectiveComboBox = nullptr;
|
||||
ads::CDockManager* DockManager = nullptr;
|
||||
|
||||
MainWindowPrivate(CMainWindow* _public) : _this(_public) {}
|
||||
@@ -185,9 +212,12 @@ void MainWindowPrivate::createContent()
|
||||
ToolBar->addAction(ui.actionSaveState);
|
||||
ToolBar->addAction(ui.actionRestoreState);
|
||||
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
|
||||
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
||||
appendFeaturStringToWindowTitle(FileSystemWidget);
|
||||
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
||||
DockWidget = createCalendarDockWidget(ViewMenu);
|
||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
||||
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
|
||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
||||
|
||||
// Test dock area docking
|
||||
@@ -281,7 +311,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
|
||||
d->createContent();
|
||||
// Default window geometry
|
||||
resize(800, 600);
|
||||
resize(1280, 720);
|
||||
|
||||
d->restoreState();
|
||||
d->restorePerspectives();
|
||||
|
||||
@@ -1,31 +1,45 @@
|
||||
ADS_ROOT = $${PWD}/..
|
||||
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||
|
||||
TARGET = AdvancedDockingSystemDemo
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
QT += core gui widgets
|
||||
CONFIG *= c++14
|
||||
CONFIG += c++14
|
||||
CONFIG += debug_and_release
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
adsBuildStatic {
|
||||
DEFINES += ADS_STATIC
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
MainWindow.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
MainWindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
|
||||
RESOURCES += main.qrc
|
||||
|
||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||
|
||||
# Dependency: AdvancedDockingSystem (shared)
|
||||
win32:CONFIG(release, debug|release): LIBS += -lqtadvanceddocking
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -lqtadvanceddockingd
|
||||
else:unix: LIBS += -lqtadvanceddocking
|
||||
CONFIG(debug, debug|release){
|
||||
win32 {
|
||||
LIBS += -lqtadvanceddockingd
|
||||
}
|
||||
else:mac {
|
||||
LIBS += -lqtadvanceddocking_debug
|
||||
}
|
||||
else {
|
||||
LIBS += -lqtadvanceddocking
|
||||
}
|
||||
}
|
||||
else{
|
||||
LIBS += -lqtadvanceddocking
|
||||
}
|
||||
|
||||
INCLUDEPATH += ../src
|
||||
DEPENDPATH += ../src
|
||||
|
||||
BIN
doc/linux_kubuntu_1804.png
Normal file
BIN
doc/linux_kubuntu_1804.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 232 KiB |
46
example/CMakeLists.txt
Normal file
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"
|
||||
)
|
||||
@@ -1,32 +1,18 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2018-12-14T22:42:14
|
||||
#
|
||||
#-------------------------------------------------
|
||||
ADS_ROOT = $${PWD}/..
|
||||
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||
|
||||
QT += core gui widgets
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
QT += core gui widgets
|
||||
|
||||
TARGET = Example1
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
TEMPLATE = app
|
||||
CONFIG *= c++14
|
||||
CONFIG += c++14
|
||||
CONFIG += debug_and_release
|
||||
adsBuildStatic {
|
||||
DEFINES += ADS_STATIC
|
||||
}
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
MainWindow.cpp
|
||||
@@ -42,9 +28,20 @@ FORMS += \
|
||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||
|
||||
# Dependency: AdvancedDockingSystem (shared)
|
||||
win32:CONFIG(release, debug|release): LIBS += -lqtadvanceddocking
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -lqtadvanceddockingd
|
||||
else:unix: LIBS += -lqtadvanceddocking
|
||||
CONFIG(debug, debug|release){
|
||||
win32 {
|
||||
LIBS += -lqtadvanceddockingd
|
||||
}
|
||||
else:mac {
|
||||
LIBS += -lqtadvanceddocking_debug
|
||||
}
|
||||
else {
|
||||
LIBS += -lqtadvanceddocking
|
||||
}
|
||||
}
|
||||
else{
|
||||
LIBS += -lqtadvanceddocking
|
||||
}
|
||||
|
||||
INCLUDEPATH += ../src
|
||||
DEPENDPATH += ../src
|
||||
|
||||
@@ -205,6 +205,13 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
|
||||
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();
|
||||
if (DragDistance >= CDockManager::startDragDistance())
|
||||
{
|
||||
@@ -228,6 +235,11 @@ void CDockAreaTabBar::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||
{
|
||||
return;
|
||||
}
|
||||
makeAreaFloating(event->pos(), DraggingInactive);
|
||||
}
|
||||
|
||||
@@ -238,7 +250,7 @@ CFloatingDockContainer* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset,
|
||||
{
|
||||
QSize Size = d->DockArea->size();
|
||||
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(d->DockArea);
|
||||
FloatingWidget->startFloating(Offset, Size, DragState);
|
||||
FloatingWidget->startFloating(Offset, Size, DragState, nullptr);
|
||||
auto TopLevelDockWidget = FloatingWidget->topLevelDockWidget();
|
||||
if (TopLevelDockWidget)
|
||||
{
|
||||
|
||||
@@ -97,6 +97,23 @@ struct DockAreaTitleBarPrivate
|
||||
{
|
||||
return DockArea->dockManager()->configFlags().testFlag(Flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to set title bar button icons depending on operating system
|
||||
* and to avoid duplicated code
|
||||
*/
|
||||
void setTitleBarButtonIcon(tTileBarButton* Button, QStyle::StandardPixmap StandarPixmap)
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
Button->setIcon(_this->style()->standardIcon(StandarPixmap));
|
||||
#else
|
||||
QIcon Icon;
|
||||
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
|
||||
|
||||
|
||||
@@ -112,42 +129,46 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
||||
//============================================================================
|
||||
void DockAreaTitleBarPrivate::createButtons()
|
||||
{
|
||||
// Tabs menu button
|
||||
TabsMenuButton = new tTileBarButton();
|
||||
TabsMenuButton->setObjectName("tabsMenuButton");
|
||||
TabsMenuButton->setAutoRaise(true);
|
||||
TabsMenuButton->setPopupMode(QToolButton::InstantPopup);
|
||||
TabsMenuButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarUnshadeButton));
|
||||
|
||||
setTitleBarButtonIcon(TabsMenuButton, QStyle::SP_TitleBarUnshadeButton);
|
||||
QMenu* TabsMenu = new QMenu(TabsMenuButton);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
TabsMenu->setToolTipsVisible(true);
|
||||
#endif
|
||||
_this->connect(TabsMenu, SIGNAL(aboutToShow()), SLOT(onTabsMenuAboutToShow()));
|
||||
TabsMenuButton->setMenu(TabsMenu);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
TabsMenuButton->setToolTip(QObject::tr("List all tabs"));
|
||||
#endif
|
||||
TabsMenuButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
TopLayout->addWidget(TabsMenuButton, 0);
|
||||
_this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)),
|
||||
SLOT(onTabsMenuActionTriggered(QAction*)));
|
||||
|
||||
|
||||
// Undock button
|
||||
UndockButton = new tTileBarButton();
|
||||
UndockButton->setObjectName("undockButton");
|
||||
UndockButton->setAutoRaise(true);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
UndockButton->setToolTip(QObject::tr("Detach Group"));
|
||||
UndockButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarNormalButton));
|
||||
UndockButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
#endif
|
||||
setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton);
|
||||
UndockButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
TopLayout->addWidget(UndockButton, 0);
|
||||
_this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked()));
|
||||
|
||||
|
||||
// Close button
|
||||
CloseButton = new tTileBarButton();
|
||||
CloseButton->setObjectName("closeButton");
|
||||
CloseButton->setAutoRaise(true);
|
||||
|
||||
// The standard icons do not look good on high DPI screens
|
||||
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);
|
||||
setTitleBarButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
||||
{
|
||||
CloseButton->setToolTip(QObject::tr("Close Active Tab"));
|
||||
@@ -156,7 +177,9 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
{
|
||||
CloseButton->setToolTip(QObject::tr("Close Group"));
|
||||
}
|
||||
#endif
|
||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
CloseButton->setIconSize(QSize(16, 16));
|
||||
TopLayout->addWidget(CloseButton, 0);
|
||||
_this->connect(CloseButton, SIGNAL(clicked()), SLOT(onCloseButtonClicked()));
|
||||
}
|
||||
@@ -240,6 +263,9 @@ void CDockAreaTitleBar::onTabsMenuAboutToShow()
|
||||
}
|
||||
auto Tab = d->TabBar->tab(i);
|
||||
QAction* Action = menu->addAction(Tab->icon(), Tab->text());
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
Action->setToolTip(Tab->toolTip());
|
||||
#endif
|
||||
Action->setData(i);
|
||||
}
|
||||
|
||||
@@ -265,7 +291,10 @@ void CDockAreaTitleBar::onCloseButtonClicked()
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onUndockButtonClicked()
|
||||
{
|
||||
d->TabBar->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
|
||||
if (d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||
{
|
||||
d->TabBar->makeAreaFloating(mapFromGlobal(QCursor::pos()), DraggingInactive);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -312,6 +341,7 @@ QAbstractButton* CDockAreaTitleBar::button(TitleBarButton which) const
|
||||
void CDockAreaTitleBar::setVisible(bool Visible)
|
||||
{
|
||||
Super::setVisible(Visible);
|
||||
markTabsMenuOutdated();
|
||||
}
|
||||
|
||||
|
||||
@@ -319,9 +349,10 @@ void CDockAreaTitleBar::setVisible(bool Visible)
|
||||
void CDockAreaTitleBar::showContextMenu(const QPoint& pos)
|
||||
{
|
||||
QMenu Menu(this);
|
||||
Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
|
||||
auto Action = Menu.addAction(tr("Detach Area"), this, SLOT(onUndockButtonClicked()));
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
Menu.addSeparator();
|
||||
auto Action = Menu.addAction(tr("Close Area"), this, SLOT(onCloseButtonClicked()));
|
||||
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));
|
||||
|
||||
@@ -53,7 +53,6 @@ private:
|
||||
friend struct DockAreaTitleBarPrivate;
|
||||
|
||||
private slots:
|
||||
void markTabsMenuOutdated();
|
||||
void onTabsMenuAboutToShow();
|
||||
void onCloseButtonClicked();
|
||||
void onUndockButtonClicked();
|
||||
@@ -61,6 +60,10 @@ private slots:
|
||||
void onCurrentTabChanged(int Index);
|
||||
void showContextMenu(const QPoint& pos);
|
||||
|
||||
public slots:
|
||||
void markTabsMenuOutdated();
|
||||
|
||||
|
||||
public:
|
||||
using Super = QFrame;
|
||||
/**
|
||||
@@ -88,6 +91,7 @@ public:
|
||||
*/
|
||||
virtual void setVisible(bool Visible) override;
|
||||
|
||||
|
||||
signals:
|
||||
/**
|
||||
* This signal is emitted if a tab in the tab bar is clicked by the user
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
*/
|
||||
void insertWidget(int index, QWidget* Widget)
|
||||
{
|
||||
Widget->setParent(0);
|
||||
Widget->setParent(nullptr);
|
||||
if (index < 0)
|
||||
{
|
||||
index = m_Widgets.count();
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
||||
if (LayoutItem)
|
||||
{
|
||||
LayoutItem->widget()->setParent(0);
|
||||
LayoutItem->widget()->setParent(nullptr);
|
||||
}
|
||||
m_CurrentWidget = nullptr;
|
||||
m_CurrentIndex = -1;
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
auto LayoutItem = m_ParentLayout->takeAt(1);
|
||||
if (LayoutItem)
|
||||
{
|
||||
LayoutItem->widget()->setParent(0);
|
||||
LayoutItem->widget()->setParent(nullptr);
|
||||
}
|
||||
|
||||
m_ParentLayout->addWidget(next);
|
||||
@@ -236,12 +236,12 @@ using DockAreaLayout = CDockAreaLayout;
|
||||
*/
|
||||
struct DockAreaWidgetPrivate
|
||||
{
|
||||
CDockAreaWidget* _this;
|
||||
QBoxLayout* Layout;
|
||||
DockAreaLayout* ContentsLayout;
|
||||
CDockAreaTitleBar* TitleBar;
|
||||
CDockManager* DockManager = nullptr;
|
||||
bool UpdateCloseButton = false;
|
||||
CDockAreaWidget* _this = nullptr;
|
||||
QBoxLayout* Layout = nullptr;
|
||||
DockAreaLayout* ContentsLayout = nullptr;
|
||||
CDockAreaTitleBar* TitleBar = nullptr;
|
||||
CDockManager* DockManager = nullptr;
|
||||
bool UpdateTitleBarButtons = false;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@@ -295,9 +295,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
|
||||
|
||||
@@ -315,27 +315,26 @@ void DockAreaWidgetPrivate::createTitleBar()
|
||||
{
|
||||
TitleBar = new CDockAreaTitleBar(_this);
|
||||
Layout->addWidget(TitleBar);
|
||||
_this->connect(tabBar(), SIGNAL(tabCloseRequested(int)),
|
||||
SLOT(onTabCloseRequested(int)));
|
||||
_this->connect(TitleBar, SIGNAL(tabBarClicked(int)),
|
||||
SLOT(setCurrentIndex(int)));
|
||||
_this->connect(tabBar(), SIGNAL(tabMoved(int, int)),
|
||||
SLOT(reorderDockWidget(int, int)));
|
||||
QObject::connect(tabBar(), &CDockAreaTabBar::tabCloseRequested, _this, &CDockAreaWidget::onTabCloseRequested);
|
||||
QObject::connect(TitleBar, &CDockAreaTitleBar::tabBarClicked, _this, &CDockAreaWidget::setCurrentIndex);
|
||||
QObject::connect(tabBar(), &CDockAreaTabBar::tabMoved, _this, &CDockAreaWidget::reorderDockWidget);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void DockAreaWidgetPrivate::updateCloseButtonState()
|
||||
void DockAreaWidgetPrivate::updateTitleBarButtonStates()
|
||||
{
|
||||
if (_this->isHidden())
|
||||
{
|
||||
UpdateCloseButton = true;
|
||||
UpdateTitleBarButtons = true;
|
||||
return;
|
||||
}
|
||||
|
||||
TitleBar->button(TitleBarButtonClose)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetClosable));
|
||||
UpdateCloseButton = false;
|
||||
TitleBar->button(TitleBarButtonUndock)->setEnabled(
|
||||
_this->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
UpdateTitleBarButtons = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -403,7 +402,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
DockWidget->setDockArea(this);
|
||||
d->updateCloseButtonState();
|
||||
d->updateTitleBarButtonStates();
|
||||
}
|
||||
|
||||
|
||||
@@ -417,14 +416,15 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||
auto TabWidget = DockWidget->tabWidget();
|
||||
TabWidget->hide();
|
||||
d->tabBar()->removeTab(TabWidget);
|
||||
CDockContainerWidget* DockContainer = dockContainer();
|
||||
if (NextOpenDockWidget)
|
||||
{
|
||||
setCurrentDockWidget(NextOpenDockWidget);
|
||||
}
|
||||
else if (d->ContentsLayout->isEmpty())
|
||||
else if (d->ContentsLayout->isEmpty() && DockContainer->dockAreaCount() > 1)
|
||||
{
|
||||
qDebug() << "Dock Area empty";
|
||||
dockContainer()->removeDockArea(this);
|
||||
DockContainer->removeDockArea(this);
|
||||
this->deleteLater();
|
||||
}
|
||||
else
|
||||
@@ -435,16 +435,15 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||
hideAreaWithNoVisibleContent();
|
||||
}
|
||||
|
||||
d->updateCloseButtonState();
|
||||
d->updateTitleBarButtonStates();
|
||||
updateTitleBarVisibility();
|
||||
auto TopLevelDockWidget = dockContainer()->topLevelDockWidget();
|
||||
auto TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
||||
if (TopLevelDockWidget)
|
||||
{
|
||||
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||
}
|
||||
|
||||
#if (ADS_DEBUG_LEVEL > 0)
|
||||
CDockContainerWidget* DockContainer = dockContainer();
|
||||
DockContainer->dumpLayout();
|
||||
#endif
|
||||
}
|
||||
@@ -680,10 +679,24 @@ void CDockAreaWidget::updateTitleBarVisibility()
|
||||
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
|
||||
{
|
||||
@@ -754,9 +767,9 @@ void CDockAreaWidget::toggleView(bool Open)
|
||||
void CDockAreaWidget::setVisible(bool Visible)
|
||||
{
|
||||
Super::setVisible(Visible);
|
||||
if (d->UpdateCloseButton)
|
||||
if (d->UpdateTitleBarButtons)
|
||||
{
|
||||
d->updateCloseButtonState();
|
||||
d->updateTitleBarButtonStates();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,12 @@ protected:
|
||||
*/
|
||||
void internalSetCurrentDockWidget(CDockWidget* DockWidget);
|
||||
|
||||
|
||||
/**
|
||||
* Marks tabs menu to update
|
||||
*/
|
||||
void markTitleBarMenuOutdated();
|
||||
|
||||
protected slots:
|
||||
void toggleView(bool Open);
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "ads_globals.h"
|
||||
#include "DockSplitter.h"
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
|
||||
#if QT_VERSION < 0x050900
|
||||
@@ -64,7 +65,7 @@ QByteArray qByteArrayToHex(const QByteArray& src, char separator)
|
||||
const int length = separator ? (src.size() * 3 - 1) : (src.size() * 2);
|
||||
QByteArray hex(length, Qt::Uninitialized);
|
||||
char *hexData = hex.data();
|
||||
const uchar *data = (const uchar *)src.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);
|
||||
@@ -96,8 +97,6 @@ static int areaIdToIndex(DockWidgetArea area)
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +127,7 @@ public:
|
||||
QGridLayout* Layout = nullptr;
|
||||
QSplitter* RootSplitter = nullptr;
|
||||
bool isFloating = false;
|
||||
CDockAreaWidget* LastAddedAreaCache[5]{0, 0, 0, 0, 0};
|
||||
CDockAreaWidget* LastAddedAreaCache[5];
|
||||
int VisibleDockAreaCount = -1;
|
||||
CDockAreaWidget* TopLevelDockArea = nullptr;
|
||||
|
||||
@@ -267,7 +266,7 @@ public:
|
||||
/**
|
||||
* 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);
|
||||
s->setOpaqueResize(DockManager->configFlags().testFlag(CDockManager::OpaqueSplitterResize));
|
||||
@@ -291,7 +290,7 @@ public:
|
||||
DockContainerWidgetPrivate::DockContainerWidgetPrivate(CDockContainerWidget* _public) :
|
||||
_this(_public)
|
||||
{
|
||||
|
||||
std::fill(std::begin(LastAddedAreaCache),std::end(LastAddedAreaCache), nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -541,7 +540,10 @@ void DockContainerWidgetPrivate::appendDockAreas(const QList<CDockAreaWidget*> N
|
||||
DockAreas.append(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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,7 +613,7 @@ bool DockContainerWidgetPrivate::restoreSplitter(QXmlStreamReader& s,
|
||||
QSplitter* Splitter = nullptr;
|
||||
if (!Testing)
|
||||
{
|
||||
Splitter = newSplitter((Qt::Orientation)Orientation);
|
||||
Splitter = newSplitter(static_cast<Qt::Orientation>(Orientation));
|
||||
}
|
||||
bool Visible = false;
|
||||
QList<int> Sizes;
|
||||
@@ -996,6 +998,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
|
||||
@@ -1052,9 +1063,15 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
||||
|
||||
// Remove are from parent splitter and recursively hide tree of parent
|
||||
// splitters if it has no visible content
|
||||
area->setParent(0);
|
||||
area->setParent(nullptr);
|
||||
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->count() > 1)
|
||||
{
|
||||
@@ -1083,7 +1100,7 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
||||
}
|
||||
|
||||
// We replace the superfluous RootSplitter with the ChildSplitter
|
||||
ChildSplitter->setParent(0);
|
||||
ChildSplitter->setParent(nullptr);
|
||||
QLayoutItem* li = d->Layout->replaceWidget(Splitter, ChildSplitter);
|
||||
d->RootSplitter = ChildSplitter;
|
||||
delete li;
|
||||
@@ -1124,14 +1141,14 @@ CDockAreaWidget* CDockContainerWidget::dockAreaAt(const QPoint& GlobalPos) const
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockAreaWidget* CDockContainerWidget::dockArea(int Index) const
|
||||
{
|
||||
return (Index < dockAreaCount()) ? d->DockAreas[Index] : 0;
|
||||
return (Index < dockAreaCount()) ? d->DockAreas[Index] : nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1272,6 +1289,7 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
|
||||
{
|
||||
d->VisibleDockAreaCount = -1;// invalidate the dock area count
|
||||
d->DockAreas.clear();
|
||||
std::fill(std::begin(d->LastAddedAreaCache),std::end(d->LastAddedAreaCache), nullptr);
|
||||
}
|
||||
|
||||
if (IsFloating)
|
||||
@@ -1465,6 +1483,5 @@ void CDockContainerWidget::closeOtherAreas(CDockAreaWidget* KeepOpenArea)
|
||||
|
||||
} // namespace ads
|
||||
|
||||
#include "moc_DockContainerWidget.cpp"
|
||||
//---------------------------------------------------------------------------
|
||||
// EOF DockContainerWidget.cpp
|
||||
|
||||
@@ -65,8 +65,6 @@ private:
|
||||
friend class CFloatingDockContainer;
|
||||
friend struct FloatingDockContainerPrivate;
|
||||
friend class CDockWidget;
|
||||
Q_PRIVATE_SLOT(d, void onDockAreaViewToggled(bool Visible))
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Handles activation events to update zOrderIndex
|
||||
@@ -168,6 +166,11 @@ public:
|
||||
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
|
||||
CDockAreaWidget* DockAreaWidget = nullptr);
|
||||
|
||||
/**
|
||||
* Removes dockwidget
|
||||
*/
|
||||
void removeDockWidget(CDockWidget* Dockwidget);
|
||||
|
||||
/**
|
||||
* Returns the current zOrderIndex
|
||||
*/
|
||||
|
||||
@@ -72,7 +72,7 @@ struct DockManagerPrivate
|
||||
QMenu* ViewMenu;
|
||||
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
|
||||
bool RestoringState = false;
|
||||
CDockManager::ConfigFlags ConfigFlags{CDockManager::DefaultConfig};
|
||||
CDockManager::ConfigFlags ConfigFlags = CDockManager::DefaultConfig;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@@ -145,7 +145,11 @@ DockManagerPrivate::DockManagerPrivate(CDockManager* _public) :
|
||||
void DockManagerPrivate::loadStylesheet()
|
||||
{
|
||||
QString Result;
|
||||
#ifdef Q_OS_LINUX
|
||||
QFile StyleSheetFile(":ads/stylesheets/default_linux.css");
|
||||
#else
|
||||
QFile StyleSheetFile(":ads/stylesheets/default.css");
|
||||
#endif
|
||||
StyleSheetFile.open(QIODevice::ReadOnly);
|
||||
QTextStream StyleSheetStream(&StyleSheetFile);
|
||||
Result = StyleSheetStream.readAll();
|
||||
@@ -336,8 +340,9 @@ 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))
|
||||
{
|
||||
qDebug() << "checkFormat: Error checking format!!!!!!!";
|
||||
@@ -489,11 +494,11 @@ unsigned int CDockManager::zOrderIndex() const
|
||||
|
||||
|
||||
//============================================================================
|
||||
QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
|
||||
QByteArray CDockManager::saveState(int version) const
|
||||
{
|
||||
QByteArray xmldata;
|
||||
QXmlStreamWriter s(&xmldata);
|
||||
s.setAutoFormatting(XmlAutoFormattingEnabled == XmlMode);
|
||||
s.setAutoFormatting(d->ConfigFlags.testFlag(XmlAutoFormattingEnabled));
|
||||
s.writeStartDocument();
|
||||
s.writeStartElement("QtAdvancedDockingSystem");
|
||||
s.writeAttribute("Version", QString::number(version));
|
||||
@@ -506,7 +511,7 @@ QByteArray CDockManager::saveState(eXmlMode XmlMode, int version) const
|
||||
s.writeEndElement();
|
||||
s.writeEndDocument();
|
||||
|
||||
return xmldata;
|
||||
return d->ConfigFlags.testFlag(XmlCompressionEnabled) ? qCompress(xmldata, 9) : xmldata;
|
||||
}
|
||||
|
||||
|
||||
@@ -565,9 +570,13 @@ CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,
|
||||
{
|
||||
return addDockWidget(ads::CenterDockWidgetArea, Dockwidget, AreaWidget);
|
||||
}
|
||||
else if (!openedDockAreas().isEmpty())
|
||||
{
|
||||
return addDockWidget(area, Dockwidget, openedDockAreas().last());
|
||||
}
|
||||
else
|
||||
{
|
||||
return addDockWidget(area, Dockwidget, AreaWidget);
|
||||
return addDockWidget(area, Dockwidget, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,6 +595,12 @@ CDockWidget* CDockManager::findDockWidget(const QString& ObjectName) const
|
||||
return d->DockWidgetsMap.value(ObjectName, nullptr);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
void CDockManager::removeDockWidget(CDockWidget* Dockwidget)
|
||||
{
|
||||
d->DockWidgetsMap.remove(Dockwidget->objectName());
|
||||
CDockContainerWidget::removeDockWidget(Dockwidget);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
QMap<QString, CDockWidget*> CDockManager::dockWidgetsMap() const
|
||||
|
||||
@@ -51,7 +51,9 @@ struct DockWidgetTabPrivate;
|
||||
struct DockAreaWidgetPrivate;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
class ADS_EXPORT CDockManager : public CDockContainerWidget
|
||||
{
|
||||
@@ -108,12 +110,6 @@ public:
|
||||
MenuAlphabeticallySorted
|
||||
};
|
||||
|
||||
enum eXmlMode
|
||||
{
|
||||
XmlAutoFormattingDisabled,
|
||||
XmlAutoFormattingEnabled
|
||||
};
|
||||
|
||||
/**
|
||||
* These global configuration flags configure some global dock manager
|
||||
* settings.
|
||||
@@ -124,7 +120,9 @@ public:
|
||||
DockAreaHasCloseButton = 0x02, //!< 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
|
||||
OpaqueSplitterResize = 0x08, //!< See QSplitter::setOpaqueResize() documentation
|
||||
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize, ///< the default configuration
|
||||
XmlAutoFormattingEnabled = 0x10,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace).
|
||||
XmlCompressionEnabled = 0x20,//!< If enabled, the XML output will be compressed and is not human readable anymore
|
||||
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize | XmlCompressionEnabled, ///< the default configuration
|
||||
};
|
||||
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
|
||||
|
||||
@@ -192,6 +190,11 @@ public:
|
||||
*/
|
||||
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
|
||||
* widgets map so that it is possible to iterate over all dock widgets
|
||||
@@ -223,7 +226,7 @@ public:
|
||||
* The XmlMode XmlAutoFormattingDisabled is better if you would like to have
|
||||
* 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 = 0) const;
|
||||
|
||||
/**
|
||||
* Restores the state of this dockmanagers dockwidgets.
|
||||
|
||||
@@ -132,6 +132,21 @@ struct DockOverlayCrossPrivate
|
||||
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,
|
||||
@@ -140,7 +155,7 @@ struct DockOverlayCrossPrivate
|
||||
QLabel* l = new QLabel();
|
||||
l->setObjectName("DockWidgetAreaLabel");
|
||||
|
||||
const qreal metric = static_cast<qreal>(l->fontMetrics().height()) * 3.f;
|
||||
const qreal metric = dropIndicatiorWidth(l);
|
||||
const QSizeF size(metric, metric);
|
||||
|
||||
l->setPixmap(createHighDpiDropIndicatorPixmap(size, DockWidgetArea, Mode));
|
||||
@@ -154,7 +169,7 @@ struct DockOverlayCrossPrivate
|
||||
void updateDropIndicatorIcon(QWidget* 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);
|
||||
|
||||
int Area = l->property("dockWidgetArea").toInt();
|
||||
|
||||
@@ -58,14 +58,14 @@ namespace ads
|
||||
*/
|
||||
struct DockWidgetPrivate
|
||||
{
|
||||
CDockWidget* _this;
|
||||
QBoxLayout* Layout;
|
||||
CDockWidget* _this = nullptr;
|
||||
QBoxLayout* Layout = nullptr;
|
||||
QWidget* Widget = nullptr;
|
||||
CDockWidgetTab* TabWidget;
|
||||
CDockWidgetTab* TabWidget = nullptr;
|
||||
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
|
||||
CDockManager* DockManager = nullptr;
|
||||
CDockAreaWidget* DockArea = nullptr;
|
||||
QAction* ToggleViewAction;
|
||||
QAction* ToggleViewAction = nullptr;
|
||||
bool Closed = false;
|
||||
QScrollArea* ScrollArea = nullptr;
|
||||
QToolBar* ToolBar = nullptr;
|
||||
@@ -243,21 +243,35 @@ void CDockWidget::setToggleViewActionChecked(bool Checked)
|
||||
void CDockWidget::setWidget(QWidget* widget, eInsertMode InsertMode)
|
||||
{
|
||||
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->ScrollArea->setWidget(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
d->Layout->addWidget(widget);
|
||||
}
|
||||
|
||||
d->Widget = widget;
|
||||
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
|
||||
{
|
||||
@@ -507,12 +521,45 @@ bool CDockWidget::event(QEvent *e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -136,10 +136,12 @@ protected:
|
||||
void toggleViewInternal(bool Open);
|
||||
|
||||
public:
|
||||
using Super = QFrame;
|
||||
|
||||
enum DockWidgetFeature
|
||||
{
|
||||
DockWidgetClosable = 0x01,
|
||||
DockWidgetMovable = 0x02,
|
||||
DockWidgetMovable = 0x02,///< this feature is not properly implemented yet and is ignored
|
||||
DockWidgetFloatable = 0x04,
|
||||
AllDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable,
|
||||
NoDockWidgetFeatures = 0x00
|
||||
@@ -236,6 +238,11 @@ public:
|
||||
*/
|
||||
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
|
||||
* the widget has not been set.
|
||||
@@ -385,6 +392,14 @@ public:
|
||||
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 -----------------------------------------------
|
||||
/**
|
||||
* Emits titleChanged signal if title change event occurs
|
||||
|
||||
@@ -146,14 +146,17 @@ void DockWidgetTabPrivate::createLayout()
|
||||
CloseButton = new tCloseButton();
|
||||
CloseButton->setObjectName("tabCloseButton");
|
||||
// The standard icons do does not look good on high DPI screens
|
||||
QIcon CloseIcon = _this->style()->standardIcon(QStyle::SP_TitleBarCloseButton);
|
||||
QIcon CloseIcon;
|
||||
QPixmap normalPixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, CloseButton);
|
||||
QPixmap disabledPixmap = internal::createTransparentPixmap(normalPixmap, 0.25);
|
||||
CloseIcon.addPixmap(disabledPixmap, QIcon::Disabled);
|
||||
CloseIcon.addPixmap(normalPixmap, QIcon::Normal);
|
||||
CloseIcon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
|
||||
CloseButton->setIcon(CloseIcon);
|
||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
CloseButton->setVisible(false);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
CloseButton->setToolTip(QObject::tr("Close Tab"));
|
||||
#endif
|
||||
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
|
||||
|
||||
QFontMetrics fm(TitleLabel->font());
|
||||
@@ -221,7 +224,7 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
|
||||
|
||||
if (DraggingFloatingWidget == DraggingState)
|
||||
{
|
||||
FloatingWidget->startDragging(DragStartMousePosition, Size);
|
||||
FloatingWidget->startDragging(DragStartMousePosition, Size, _this);
|
||||
auto Overlay = DockWidget->dockManager()->containerOverlay();
|
||||
Overlay->setAllowedAreas(OuterDockAreas);
|
||||
this->FloatingWidget = FloatingWidget;
|
||||
@@ -264,7 +267,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
|
||||
emit clicked();
|
||||
return;
|
||||
}
|
||||
QFrame::mousePressEvent(ev);
|
||||
Super::mousePressEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +283,7 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
|
||||
|
||||
d->DragStartMousePosition = QPoint();
|
||||
d->DragState = DraggingInactive;
|
||||
QFrame::mouseReleaseEvent(ev);
|
||||
Super::mouseReleaseEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +293,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
||||
if (!(ev->buttons() & Qt::LeftButton) || d->isDraggingState(DraggingInactive))
|
||||
{
|
||||
d->DragState = DraggingInactive;
|
||||
QFrame::mouseMoveEvent(ev);
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -298,7 +301,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
||||
if (d->isDraggingState(DraggingFloatingWidget))
|
||||
{
|
||||
d->FloatingWidget->moveFloating();
|
||||
QFrame::mouseMoveEvent(ev);
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,7 +328,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
||||
}
|
||||
|
||||
// Floating is only allowed for widgets that are movable
|
||||
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetMovable))
|
||||
if (d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||
{
|
||||
d->startFloating();
|
||||
}
|
||||
@@ -338,7 +341,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
||||
return;
|
||||
}
|
||||
|
||||
QFrame::mouseMoveEvent(ev);
|
||||
Super::mouseMoveEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -349,9 +352,10 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||
|
||||
d->DragStartMousePosition = ev->pos();
|
||||
QMenu Menu(this);
|
||||
Menu.addAction(tr("Detach"), this, SLOT(onDetachActionTriggered()));
|
||||
auto Action = Menu.addAction(tr("Detach"), this, SLOT(onDetachActionTriggered()));
|
||||
Action->setEnabled(d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
Menu.addSeparator();
|
||||
auto Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||
Action = Menu.addAction(tr("Close"), this, SIGNAL(closeRequested()));
|
||||
Action->setEnabled(isClosable());
|
||||
Menu.addAction(tr("Close Others"), this, SIGNAL(closeOtherTabsRequested()));
|
||||
Menu.exec(mapToGlobal(ev->pos()));
|
||||
@@ -422,7 +426,9 @@ void CDockWidgetTab::setIcon(const QIcon& Icon)
|
||||
d->IconLabel = new QLabel();
|
||||
d->IconLabel->setAlignment(Qt::AlignVCenter);
|
||||
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
d->IconLabel->setToolTip(d->TitleLabel->toolTip());
|
||||
#endif
|
||||
Layout->insertWidget(0, d->IconLabel, Qt::AlignVCenter);
|
||||
Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0));
|
||||
}
|
||||
@@ -464,7 +470,8 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
// 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
|
||||
// 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->startFloating(DraggingInactive);
|
||||
@@ -482,6 +489,14 @@ void CDockWidgetTab::setVisible(bool visible)
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidgetTab::setText(const QString& title)
|
||||
{
|
||||
d->TitleLabel->setText(title);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CDockWidgetTab::isClosable() const
|
||||
{
|
||||
@@ -492,11 +507,31 @@ bool CDockWidgetTab::isClosable() const
|
||||
//===========================================================================
|
||||
void CDockWidgetTab::onDetachActionTriggered()
|
||||
{
|
||||
if (!d->DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
||||
{
|
||||
return;
|
||||
}
|
||||
d->DragStartMousePosition = mapFromGlobal(QCursor::pos());
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace ads
|
||||
//---------------------------------------------------------------------------
|
||||
// EOF DockWidgetTab.cpp
|
||||
|
||||
@@ -125,13 +125,27 @@ public:
|
||||
*/
|
||||
QString text() const;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the tab text
|
||||
*/
|
||||
void setText(const QString& title);
|
||||
|
||||
/**
|
||||
* This function returns true if the assigned dock widget is closeable
|
||||
*/
|
||||
bool isClosable() const;
|
||||
|
||||
|
||||
/**
|
||||
* Track event ToolTipChange and set child ToolTip
|
||||
*/
|
||||
virtual bool event(QEvent *e) override;
|
||||
|
||||
public slots:
|
||||
virtual void setVisible(bool visible) override;
|
||||
|
||||
virtual void setVisible(bool visible) override;
|
||||
|
||||
|
||||
signals:
|
||||
void activeTabChanged();
|
||||
|
||||
@@ -88,7 +88,9 @@ CElidingLabel::CElidingLabel(const QString& text, QWidget* parent, Qt::WindowFla
|
||||
d(new ElidingLabelPrivate(this))
|
||||
{
|
||||
d->Text = text;
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
setToolTip(text);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +185,9 @@ void CElidingLabel::setText(const QString &text)
|
||||
else
|
||||
{
|
||||
d->Text = text;
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
setToolTip( text );
|
||||
#endif
|
||||
d->elideText(this->size().width());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,11 @@
|
||||
#include "DockWidget.h"
|
||||
#include "DockOverlay.h"
|
||||
|
||||
#include <iostream>
|
||||
#ifdef Q_OS_LINUX
|
||||
#include "linux/FloatingWidgetTitleBar.h"
|
||||
#include <xcb/xcb.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace ads
|
||||
{
|
||||
@@ -63,6 +67,10 @@ struct FloatingDockContainerPrivate
|
||||
QPoint DragStartMousePosition;
|
||||
CDockContainerWidget* DropContainer = nullptr;
|
||||
CDockAreaWidget* SingleDockArea = nullptr;
|
||||
#ifdef Q_OS_LINUX
|
||||
QWidget* MouseEventHandler = nullptr;
|
||||
CFloatingWidgetTitleBar* TitleBar = nullptr;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@@ -84,6 +92,15 @@ struct FloatingDockContainerPrivate
|
||||
{
|
||||
DraggingState = StateId;
|
||||
}
|
||||
|
||||
void setWindowTitle(const QString& Text)
|
||||
{
|
||||
#ifdef Q_OS_LINUX
|
||||
TitleBar->setTitle(Text);
|
||||
#else
|
||||
_this->setWindowTitle(Text);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
// struct FloatingDockContainerPrivate
|
||||
|
||||
@@ -216,25 +233,38 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
|
||||
|
||||
//============================================================================
|
||||
CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
|
||||
QWidget(DockManager, Qt::Window),
|
||||
tFloatingWidgetBase(DockManager),
|
||||
d(new FloatingDockContainerPrivate(this))
|
||||
{
|
||||
d->DockManager = DockManager;
|
||||
d->DockManager = DockManager;
|
||||
d->DockContainer = new CDockContainerWidget(DockManager, this);
|
||||
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this, SLOT(onDockAreasAddedOrRemoved()));
|
||||
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved()));
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
d->TitleBar = new CFloatingWidgetTitleBar(this);
|
||||
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);
|
||||
#endif
|
||||
|
||||
d->DockContainer = new CDockContainerWidget(DockManager, this);
|
||||
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this, SLOT(onDockAreasAddedOrRemoved()));
|
||||
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved()));
|
||||
l->addWidget(d->DockContainer);
|
||||
DockManager->registerFloatingWidget(this);
|
||||
|
||||
|
||||
// We install an event filter to detect mouse release events because we
|
||||
// do not receive mouse release event if the floating widget is behind
|
||||
// the drop overlay cross
|
||||
qApp->installEventFilter(this);
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -243,14 +273,20 @@ CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) :
|
||||
CFloatingDockContainer(DockArea->dockManager())
|
||||
{
|
||||
d->DockContainer->addDockArea(DockArea);
|
||||
#ifdef Q_OS_LINUX
|
||||
d->TitleBar->enableCloseButton(isClosable());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
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
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
@@ -289,7 +325,7 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
|
||||
void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
||||
{
|
||||
QWidget::moveEvent(event);
|
||||
switch (d->DraggingState)
|
||||
switch (d->DraggingState)
|
||||
{
|
||||
case DraggingMousePressed:
|
||||
d->setState(DraggingFloatingWidget);
|
||||
@@ -301,7 +337,7 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +349,25 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||
|
||||
if (isClosable())
|
||||
{
|
||||
QWidget::closeEvent(event);
|
||||
// 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();
|
||||
this->hide();
|
||||
#else
|
||||
Super::closeEvent(event);
|
||||
#endif
|
||||
#else // Q_OS_LINUX
|
||||
Super::closeEvent(event);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -340,13 +394,6 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
||||
void CFloatingDockContainer::showEvent(QShowEvent *event)
|
||||
{
|
||||
Super::showEvent(event);
|
||||
/*for (auto DockArea : d->DockContainer->openedDockAreas())
|
||||
{
|
||||
for (auto DockWidget : DockArea->openedDockWidgets())
|
||||
{
|
||||
DockWidget->setToggleViewActionChecked(true);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@@ -356,11 +403,28 @@ bool CFloatingDockContainer::event(QEvent *e)
|
||||
switch (d->DraggingState)
|
||||
{
|
||||
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();
|
||||
d->setState(DraggingMousePressed);
|
||||
}
|
||||
#else
|
||||
if (e->type() == QEvent::NonClientAreaMouseButtonPress && QGuiApplication::mouseButtons().testFlag(Qt::LeftButton))
|
||||
{
|
||||
qDebug() << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type();
|
||||
d->setState(DraggingMousePressed);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case DraggingMousePressed:
|
||||
@@ -413,12 +477,13 @@ bool CFloatingDockContainer::event(QEvent *e)
|
||||
//============================================================================
|
||||
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
Q_UNUSED(watched);
|
||||
if (event->type() == QEvent::MouseButtonRelease && d->isState(DraggingFloatingWidget))
|
||||
Q_UNUSED(watched);
|
||||
if (event->type() == QEvent::MouseButtonRelease && d->isState(DraggingFloatingWidget))
|
||||
{
|
||||
qDebug() << "FloatingWidget::eventFilter QEvent::MouseButtonRelease";
|
||||
finishDragging();
|
||||
d->titleMouseReleaseEvent();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -426,11 +491,26 @@ bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
|
||||
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
eDragState DragState)
|
||||
eDragState DragState, QWidget* MouseEventHandler)
|
||||
{
|
||||
#ifndef Q_OS_LINUX
|
||||
Q_UNUSED(MouseEventHandler)
|
||||
#endif
|
||||
resize(Size);
|
||||
d->setState(DragState);
|
||||
d->DragStartMousePosition = DragStartMousePos;
|
||||
#ifdef Q_OS_LINUX
|
||||
if (DraggingFloatingWidget == DragState)
|
||||
{
|
||||
setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
|
||||
setWindowOpacity(0.6);
|
||||
d->MouseEventHandler = MouseEventHandler;
|
||||
if (d->MouseEventHandler)
|
||||
{
|
||||
d->MouseEventHandler->grabMouse();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
moveFloating();
|
||||
show();
|
||||
|
||||
@@ -442,7 +522,7 @@ void CFloatingDockContainer::moveFloating()
|
||||
{
|
||||
int BorderSize = (frameSize().width() - size().width()) / 2;
|
||||
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition - QPoint(BorderSize, 0);
|
||||
move(moveToPos);
|
||||
move(moveToPos);
|
||||
}
|
||||
|
||||
|
||||
@@ -461,7 +541,7 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
||||
if (TopLevelDockArea)
|
||||
{
|
||||
d->SingleDockArea = TopLevelDockArea;
|
||||
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||
d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
||||
SLOT(onDockAreaCurrentChanged(int)));
|
||||
}
|
||||
@@ -473,7 +553,7 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
||||
SLOT(onDockAreaCurrentChanged(int)));
|
||||
d->SingleDockArea = nullptr;
|
||||
}
|
||||
this->setWindowTitle(qApp->applicationDisplayName());
|
||||
d->setWindowTitle(qApp->applicationDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,11 +564,11 @@ void CFloatingDockContainer::updateWindowTitle()
|
||||
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
|
||||
if (TopLevelDockArea)
|
||||
{
|
||||
this->setWindowTitle(TopLevelDockArea->currentDockWidget()->windowTitle());
|
||||
d->setWindowTitle(TopLevelDockArea->currentDockWidget()->windowTitle());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setWindowTitle(qApp->applicationDisplayName());
|
||||
d->setWindowTitle(qApp->applicationDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +577,7 @@ void CFloatingDockContainer::updateWindowTitle()
|
||||
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
||||
{
|
||||
Q_UNUSED(Index);
|
||||
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||
d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||
}
|
||||
|
||||
|
||||
@@ -535,6 +615,24 @@ QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingDockContainer::finishDragging()
|
||||
{
|
||||
qDebug() << "CFloatingDockContainer::finishDragging";
|
||||
#ifdef Q_OS_LINUX
|
||||
setAttribute(Qt::WA_X11NetWmWindowTypeDock, false);
|
||||
setWindowOpacity(1);
|
||||
activateWindow();
|
||||
if (d->MouseEventHandler)
|
||||
{
|
||||
d->MouseEventHandler->releaseMouse();
|
||||
d->MouseEventHandler = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -29,10 +29,16 @@
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QWidget>
|
||||
|
||||
#include "ads_globals.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <QDockWidget>
|
||||
#define tFloatingWidgetBase QDockWidget
|
||||
#else
|
||||
#include <QWidget>
|
||||
#define tFloatingWidgetBase QWidget
|
||||
#endif
|
||||
|
||||
class QXmlStreamReader;
|
||||
|
||||
namespace ads
|
||||
@@ -49,13 +55,14 @@ class CDockWidgetTab;
|
||||
struct DockWidgetTabPrivate;
|
||||
class CDockAreaTitleBar;
|
||||
struct DockAreaTitleBarPrivate;
|
||||
class CFloatingWidgetTitleBar;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* another dock container
|
||||
*/
|
||||
class ADS_EXPORT CFloatingDockContainer : public QWidget
|
||||
class ADS_EXPORT CFloatingDockContainer : public tFloatingWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
@@ -70,6 +77,7 @@ private:
|
||||
friend struct DockAreaTitleBarPrivate;
|
||||
friend class CDockWidget;
|
||||
friend class CDockAreaWidget;
|
||||
friend class CFloatingWidgetTitleBar;
|
||||
|
||||
private slots:
|
||||
void onDockAreasAddedOrRemoved();
|
||||
@@ -82,23 +90,30 @@ protected:
|
||||
* depending on the start position given in Pos parameter
|
||||
*/
|
||||
void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
eDragState DragState);
|
||||
eDragState DragState, QWidget* MouseEventHandler);
|
||||
|
||||
/**
|
||||
* Call this function to start dragging the floating widget
|
||||
*/
|
||||
void startDragging(const QPoint& DragStartMousePos, const QSize& Size)
|
||||
void startDragging(const QPoint& DragStartMousePos, const QSize& Size,
|
||||
QWidget* MouseEventHandler)
|
||||
{
|
||||
startFloating(DragStartMousePos, Size, DraggingFloatingWidget);
|
||||
startFloating(DragStartMousePos, Size, DraggingFloatingWidget, MouseEventHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this function if you explecitely want to signal that dragging has
|
||||
* finished
|
||||
*/
|
||||
void finishDragging();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
startFloating(DragStartMousePos, Size, DraggingInactive, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
<file>stylesheets/default.css</file>
|
||||
<file>images/close-button.svg</file>
|
||||
<file>images/close-button-disabled.svg</file>
|
||||
<file>stylesheets/default_linux.css</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace internal
|
||||
void replaceSplitterWidget(QSplitter* Splitter, QWidget* From, QWidget* To)
|
||||
{
|
||||
int index = Splitter->indexOf(From);
|
||||
From->setParent(0);
|
||||
From->setParent(nullptr);
|
||||
Splitter->insertWidget(index, To);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@ void hideEmptyParentSplitters(CDockSplitter* Splitter)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace internal
|
||||
} // namespace ads
|
||||
|
||||
|
||||
@@ -35,11 +35,15 @@
|
||||
#include <QPixmap>
|
||||
#include <QWidget>
|
||||
|
||||
#ifndef ADS_STATIC
|
||||
#ifdef ADS_SHARED_EXPORT
|
||||
#define ADS_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
#define ADS_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
#else
|
||||
#define ADS_EXPORT
|
||||
#endif
|
||||
|
||||
#define ADS_DEBUG_LEVEL 0
|
||||
|
||||
|
||||
187
src/linux/FloatingWidgetTitleBar.cpp
Normal file
187
src/linux/FloatingWidgetTitleBar.cpp
Normal file
@@ -0,0 +1,187 @@
|
||||
/*******************************************************************************
|
||||
** Qt Advanced Docking System
|
||||
** Copyright (C) 2017 Uwe Kindler
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//============================================================================
|
||||
/// \file FloatingWidgetTitleBar.cpp
|
||||
/// \author Uwe Kindler
|
||||
/// \date 13.05.2019
|
||||
/// \brief Implementation of CFloatingWidgetTitleBar class
|
||||
//============================================================================
|
||||
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include "FloatingWidgetTitleBar.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QPixmap>
|
||||
#include <QStyle>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "ads_globals.h"
|
||||
#include "ElidingLabel.h"
|
||||
#include "FloatingDockContainer.h"
|
||||
|
||||
namespace ads
|
||||
{
|
||||
|
||||
using tTabLabel = CElidingLabel;
|
||||
using tCloseButton = QPushButton;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Private data class of public interface CFloatingWidgetTitleBar
|
||||
*/
|
||||
struct FloatingWidgetTitleBarPrivate
|
||||
{
|
||||
CFloatingWidgetTitleBar* _this; ///< public interface class
|
||||
QLabel* IconLabel = nullptr;
|
||||
tTabLabel* TitleLabel;
|
||||
tCloseButton* CloseButton = nullptr;
|
||||
CFloatingDockContainer* FloatingWidget = nullptr;
|
||||
eDragState DragState = DraggingInactive;
|
||||
|
||||
FloatingWidgetTitleBarPrivate(CFloatingWidgetTitleBar* _public) : _this(_public) {}
|
||||
|
||||
/**
|
||||
* Creates the complete layout including all controls
|
||||
*/
|
||||
void createLayout();
|
||||
};
|
||||
|
||||
|
||||
//============================================================================
|
||||
void FloatingWidgetTitleBarPrivate::createLayout()
|
||||
{
|
||||
TitleLabel = new tTabLabel();
|
||||
TitleLabel->setElideMode(Qt::ElideRight);
|
||||
TitleLabel->setText("DockWidget->windowTitle()");
|
||||
TitleLabel->setObjectName("floatingTitleLabel");
|
||||
TitleLabel->setAlignment(Qt::AlignLeft);
|
||||
|
||||
CloseButton = new tCloseButton();
|
||||
CloseButton->setObjectName("floatingTitleCloseButton");
|
||||
CloseButton->setFlat(true);
|
||||
//CloseButton->setAutoRaise(true);
|
||||
// The standard icons do does not look good on high DPI screens
|
||||
QIcon CloseIcon;
|
||||
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(_this->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
|
||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
CloseButton->setVisible(true);
|
||||
CloseButton->setFocusPolicy(Qt::NoFocus);
|
||||
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
|
||||
|
||||
QFontMetrics fm(TitleLabel->font());
|
||||
int Spacing = qRound(fm.height() / 4.0);
|
||||
|
||||
// Fill the layout
|
||||
QBoxLayout* Layout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
Layout->setContentsMargins(6,0,0,0);
|
||||
Layout->setSpacing(0);
|
||||
_this->setLayout(Layout);
|
||||
Layout->addWidget(TitleLabel, 1);
|
||||
Layout->addSpacing(Spacing);
|
||||
Layout->addWidget(CloseButton);
|
||||
Layout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
TitleLabel->setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CFloatingWidgetTitleBar::CFloatingWidgetTitleBar(CFloatingDockContainer *parent)
|
||||
: QWidget(parent),
|
||||
d(new FloatingWidgetTitleBarPrivate(this))
|
||||
{
|
||||
d->FloatingWidget = parent;
|
||||
d->createLayout();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CFloatingWidgetTitleBar::~CFloatingWidgetTitleBar()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
if (ev->button() == Qt::LeftButton)
|
||||
{
|
||||
d->DragState = DraggingFloatingWidget;
|
||||
d->FloatingWidget->startDragging(ev->pos(), d->FloatingWidget->size(), this);
|
||||
return;
|
||||
}
|
||||
Super::mousePressEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
||||
{
|
||||
d->DragState = DraggingInactive;
|
||||
Super::mouseReleaseEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
||||
{
|
||||
if (!(ev->buttons() & Qt::LeftButton) || DraggingInactive == d->DragState)
|
||||
{
|
||||
d->DragState = DraggingInactive;
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
// move floating window
|
||||
if (DraggingFloatingWidget == d->DragState)
|
||||
{
|
||||
d->FloatingWidget->moveFloating();
|
||||
Super::mouseMoveEvent(ev);
|
||||
return;
|
||||
}
|
||||
Super::mouseMoveEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::enableCloseButton(bool Enable)
|
||||
{
|
||||
d->CloseButton->setEnabled(Enable);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::setTitle(const QString& Text)
|
||||
{
|
||||
d->TitleLabel->setText(Text);
|
||||
}
|
||||
|
||||
|
||||
} // namespace ads
|
||||
68
src/linux/FloatingWidgetTitleBar.h
Normal file
68
src/linux/FloatingWidgetTitleBar.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef FLOATINGWIDGETTITLEBAR_H
|
||||
#define FLOATINGWIDGETTITLEBAR_H
|
||||
/*******************************************************************************
|
||||
** Qt Advanced Docking System
|
||||
** Copyright (C) 2017 Uwe Kindler
|
||||
**
|
||||
** This library is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU Lesser General Public
|
||||
** License as published by the Free Software Foundation; either
|
||||
** version 2.1 of the License, or (at your option) any later version.
|
||||
**
|
||||
** This library is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
** Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public
|
||||
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
//============================================================================
|
||||
/// \file FloatingWidgetTitleBar.h
|
||||
/// \author Uwe Kindler
|
||||
/// \date 13.05.2019
|
||||
/// \brief Declaration of CFloatingWidgetTitleBar class
|
||||
//============================================================================
|
||||
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QWidget>
|
||||
|
||||
namespace ads
|
||||
{
|
||||
class CFloatingDockContainer;
|
||||
|
||||
struct FloatingWidgetTitleBarPrivate;
|
||||
|
||||
class CFloatingWidgetTitleBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
FloatingWidgetTitleBarPrivate* d; ///< private data (pimpl)
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent* ev) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* ev) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent* ev) override;
|
||||
|
||||
public:
|
||||
using Super = QWidget;
|
||||
explicit CFloatingWidgetTitleBar (CFloatingDockContainer *parent = nullptr);
|
||||
|
||||
/**
|
||||
* Virtual Destructor
|
||||
*/
|
||||
virtual ~CFloatingWidgetTitleBar();
|
||||
|
||||
void enableCloseButton(bool Enable);
|
||||
|
||||
void setTitle(const QString& Text);
|
||||
|
||||
signals:
|
||||
void closeRequested();
|
||||
};
|
||||
} // namespace ads
|
||||
#endif // FLOATINGWIDGETTITLEBAR_H
|
||||
40
src/src.pro
40
src/src.pro
@@ -1,26 +1,24 @@
|
||||
ADS_ROOT = $${PWD}/..
|
||||
ADS_OUT_ROOT = $${OUT_PWD}/..
|
||||
|
||||
CONFIG += c++14
|
||||
CONFIG += debug_and_release
|
||||
TARGET = $$qtLibraryTarget(qtadvanceddocking)
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
TEMPLATE = lib
|
||||
DESTDIR = $${ADS_OUT_ROOT}/lib
|
||||
QT += core gui widgets
|
||||
|
||||
CONFIG += adsBuildShared
|
||||
|
||||
|
||||
adsBuildShared {
|
||||
!adsBuildStatic {
|
||||
CONFIG += shared
|
||||
DEFINES += ADS_SHARED_EXPORT
|
||||
}
|
||||
!adsBuildShared {
|
||||
adsBuildStatic {
|
||||
CONFIG += staticlib
|
||||
DEFINES += ADS_STATIC
|
||||
}
|
||||
|
||||
windows {
|
||||
# MinGW
|
||||
*-g++* {
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
QMAKE_CXXFLAGS += -Wall -Wextra -pedantic
|
||||
}
|
||||
# MSVC
|
||||
@@ -28,10 +26,6 @@ windows {
|
||||
}
|
||||
}
|
||||
|
||||
unix {
|
||||
CONFIG += c++11
|
||||
}
|
||||
|
||||
RESOURCES += ads.qrc
|
||||
|
||||
HEADERS += \
|
||||
@@ -47,9 +41,8 @@ HEADERS += \
|
||||
DockSplitter.h \
|
||||
DockAreaTitleBar.h \
|
||||
ElidingLabel.h
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SOURCES += \
|
||||
ads_globals.cpp \
|
||||
DockAreaWidget.cpp \
|
||||
@@ -63,3 +56,20 @@ SOURCES += \
|
||||
DockSplitter.cpp \
|
||||
DockAreaTitleBar.cpp \
|
||||
ElidingLabel.cpp
|
||||
|
||||
|
||||
unix {
|
||||
HEADERS += linux/FloatingWidgetTitleBar.h
|
||||
SOURCES += linux/FloatingWidgetTitleBar.cpp
|
||||
}
|
||||
|
||||
isEmpty(PREFIX){
|
||||
PREFIX=..\installed
|
||||
warning("Install Prefix not set")
|
||||
}
|
||||
headers.path=$$PREFIX/include
|
||||
headers.files=$$HEADERS
|
||||
target.path=$$PREFIX/lib
|
||||
INSTALLS += headers target
|
||||
|
||||
DISTFILES +=
|
||||
|
||||
@@ -63,7 +63,7 @@ ads--CDockWidget
|
||||
#closeButton,
|
||||
#undockButton
|
||||
{
|
||||
padding: 0 -2px;
|
||||
padding: 0px -2px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
96
src/stylesheets/default_linux.css
Normal file
96
src/stylesheets/default_linux.css
Normal file
@@ -0,0 +1,96 @@
|
||||
|
||||
/*
|
||||
* Default style sheet on Windows Platforms
|
||||
* Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5
|
||||
*/
|
||||
|
||||
ads--CDockContainerWidget
|
||||
{
|
||||
background: palette(dark);
|
||||
}
|
||||
|
||||
ads--CDockContainerWidget QSplitter::handle
|
||||
{
|
||||
background: palette(dark);
|
||||
}
|
||||
|
||||
ads--CDockAreaWidget
|
||||
{
|
||||
background: palette(window);
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
ads--CDockAreaWidget #tabsMenuButton::menu-indicator
|
||||
{
|
||||
image: none;
|
||||
}
|
||||
|
||||
|
||||
ads--CDockWidgetTab
|
||||
{
|
||||
background: palette(window);
|
||||
border-color: palette(light);
|
||||
border-style: solid;
|
||||
border-width: 0 1px 0 0;
|
||||
padding: 0 0px;
|
||||
}
|
||||
|
||||
ads--CDockWidgetTab[activeTab="true"]
|
||||
{
|
||||
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
|
||||
/*background: palette(highlight);*/
|
||||
}
|
||||
|
||||
ads--CDockWidgetTab QLabel
|
||||
{
|
||||
color: palette(dark);
|
||||
}
|
||||
|
||||
ads--CDockWidgetTab[activeTab="true"] QLabel
|
||||
{
|
||||
color: palette(foreground);
|
||||
}
|
||||
|
||||
ads--CDockWidget
|
||||
{
|
||||
background: palette(light);
|
||||
border-color: palette(light);
|
||||
border-style: solid;
|
||||
border-width: 1px 0 0 0;
|
||||
}
|
||||
|
||||
#tabsMenuButton,
|
||||
#closeButton,
|
||||
#undockButton
|
||||
{
|
||||
padding: 0px -2px;
|
||||
}
|
||||
|
||||
|
||||
QScrollArea#dockWidgetScrollArea
|
||||
{
|
||||
padding: 0px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
#tabCloseButton
|
||||
{
|
||||
margin-top: 2px;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0px -2px;
|
||||
}
|
||||
|
||||
#tabCloseButton:hover
|
||||
{
|
||||
border: 1px solid rgba(0, 0, 0, 32);
|
||||
background: rgba(0, 0, 0, 16);
|
||||
}
|
||||
|
||||
#tabCloseButton:pressed
|
||||
{
|
||||
background: rgba(0, 0, 0, 32);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user