Implemented proper hiding and showing of dock widgets

This commit is contained in:
Uwe Kindler 2017-03-23 10:23:53 +01:00
parent b6ee26adc2
commit 16bd1a3bd2
13 changed files with 3130 additions and 2690 deletions

313
.cproject Normal file
View File

@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795.1949777584" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base.88699815" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.PE" id="cdt.managedbuild.target.gnu.platform.mingw.base.519267520" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.mingw.base"/>
<builder id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795.1200539104" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.base.1438677059" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.base">
<option id="gnu.both.asm.option.include.paths.403127333" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/demo}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QTDIR}/include&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1249325593" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.933824900" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.1947822681" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base">
<option id="gnu.cpp.compiler.option.include.paths.349616932" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/demo}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QTDIR}/include&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1318830536" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.base.389117097" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.base">
<option id="gnu.c.compiler.option.include.paths.1871729602" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/demo}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/QtAdvancedDockingSystem/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QTDIR}/include&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1568363924" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.1734874312" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.985493173" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base">
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.266071128" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="QtAdvancedDockingSystem.null.1346550114" name="QtAdvancedDockingSystem"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
<buildTargets>
<target name="Build all" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Clean" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Debug Build" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j6</buildArguments>
<buildTarget>debug</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="qmake" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../ads.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Release Build" path=" build" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j4</buildArguments>
<buildTarget>release</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Build all" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Clean" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Debug Build" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j6</buildArguments>
<buildTarget>debug</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="qmake" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../src/src.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Release Build" path=" build/src" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j4</buildArguments>
<buildTarget>release</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Build all" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Clean" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Debug Build" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j6</buildArguments>
<buildTarget>debug</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="qmake" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../demo/demo.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Release Build" path=" build/demo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j4</buildArguments>
<buildTarget>release</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Build all" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Clean" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Debug Build" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j6</buildArguments>
<buildTarget>debug</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="qmake" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../AdvancedDockingSystemDemo/AdvancedDockingSystemDemo.pro</buildArguments>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Release Build" path=" build/AdvancedDockingSystemDemo" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j4</buildArguments>
<buildTarget>release</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Build all" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Clean" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Debug Build" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j6</buildArguments>
<buildTarget>debug</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="qmake" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../AdvancedDockingSystemDemo_v2/AdvancedDockingSystemDemo_v2.pro</buildArguments>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Release Build" path=" build/AdvancedDockingSystemDemo_v2" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j4</buildArguments>
<buildTarget>release</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Build all" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j</buildArguments>
<buildTarget>all</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Clean" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>clean</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Debug Build" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j6</buildArguments>
<buildTarget>debug</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="qmake" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>qmake</buildCommand>
<buildArguments>-recursive ../../AdvancedDockingSystem/src.pro</buildArguments>
<buildTarget/>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
<target name="Release Build" path=" build/AdvancedDockingSystem" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>mingw32-make</buildCommand>
<buildArguments>-j4</buildArguments>
<buildTarget>release</buildTarget>
<stopOnError>false</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>false</runAllBuilders>
</target>
</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>

27
.project Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>QtAdvancedDockingSystem</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.mingw.base.1119687795" name="Default">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(g?cc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorMinGW" console="false" env-hash="-797032510223863550" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorMinGW" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings MinGW" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
</project>

BIN
ContainerWidget.dat Normal file

Binary file not shown.

BIN
MainWindow.dat Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,202 +1,198 @@
#ifndef DockAreaWidgetH #ifndef DockAreaWidgetH
#define DockAreaWidgetH #define DockAreaWidgetH
/******************************************************************************* /*******************************************************************************
** QtAdcancedDockingSystem ** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler ** Copyright (C) 2017 Uwe Kindler
** **
** This program is free software: you can redistribute it and/or modify ** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** This program is distributed in the hope that it will be useful, ** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
//============================================================================ //============================================================================
/// \file DockAreaWidget.h /// \file DockAreaWidget.h
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 24.02.2017 /// \date 24.02.2017
/// \brief Declaration of CDockAreaWidget class /// \brief Declaration of CDockAreaWidget class
//============================================================================ //============================================================================
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <QFrame> #include <QFrame>
namespace ads namespace ads
{ {
struct DockAreaWidgetPrivate; struct DockAreaWidgetPrivate;
class CDockManager; class CDockManager;
class CDockContainerWidget; class CDockContainerWidget;
class CDockWidget; class CDockWidget;
/** /**
* DockAreaWidget manages multiple instances of DckWidgets. * DockAreaWidget manages multiple instances of DckWidgets.
* It displays a title tab, which is clickable and will switch to * It displays a title tab, which is clickable and will switch to
* the contents associated to the title when clicked. * the contents associated to the title when clicked.
*/ */
class CDockAreaWidget : public QFrame class CDockAreaWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
private: private:
DockAreaWidgetPrivate* d; ///< private data (pimpl) DockAreaWidgetPrivate* d; ///< private data (pimpl)
friend class DockAreaWidgetPrivate; friend class DockAreaWidgetPrivate;
private slots: private slots:
void onDockWidgetTitleClicked(); void onDockWidgetTitleClicked();
void onTabsMenuActionTriggered(QAction* Action); void onTabsMenuActionTriggered(QAction* Action);
void onCloseButtonClicked(); void onCloseButtonClicked();
void onDockWidgetViewToggled(bool Open);
protected:
virtual void hideEvent(QHideEvent *) override; public:
virtual void showEvent(QShowEvent *) override; /**
* Default Constructor
public: */
/** CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent);
* Default Constructor
*/ /**
CDockAreaWidget(CDockManager* DockManager, CDockContainerWidget* parent); * Virtual Destructor
*/
/** virtual ~CDockAreaWidget();
* Virtual Destructor
*/ /**
virtual ~CDockAreaWidget(); * Returns the dock manager object this dock area belongs to
*/
/** CDockManager* dockManager() const;
* Returns the dock manager object this dock area belongs to
*/ /**
CDockManager* dockManager() const; * Returns the dock container widget this dock area widget belongs to or 0
* if there is no
/** */
* Returns the dock container widget this dock area widget belongs to or 0 CDockContainerWidget* dockContainer() const;
* if there is no
*/ /**
CDockContainerWidget* dockContainer() const; * Inserts a dock widget into dock area.
* All dockwidgets in the dock area tabified in a stacked layout with tabs.
/** * The index indicates the index of the new dockwidget in the tabbar and
* Inserts a dock widget into dock area. * in the stacked layout. If the Activate parameter is true, the new
* All dockwidgets in the dock area tabified in a stacked layout with tabs. * DockWidget will be the active one in the stacked layout
* The index indicates the index of the new dockwidget in the tabbar and */
* in the stacked layout. If the Activate parameter is true, the new void insertDockWidget(int index, CDockWidget* DockWidget, bool Activate = true);
* DockWidget will be the active one in the stacked layout
*/ /**
void insertDockWidget(int index, CDockWidget* DockWidget, bool Activate = true); * Add a new dock widget to dock area.
* All dockwidgets in the dock area tabified in a stacked layout with tabs
/** */
* Add a new dock widget to dock area. void addDockWidget(CDockWidget* DockWidget);
* All dockwidgets in the dock area tabified in a stacked layout with tabs
*/ /**
void addDockWidget(CDockWidget* DockWidget); * Removes the given dock widget from the dock area
*/
/** void removeDockWidget(CDockWidget* DockWidget);
* Removes the given dock widget from the dock area
*/ /**
void removeDockWidget(CDockWidget* DockWidget); * Returns the rectangle of the title area
*/
/** QRect titleAreaGeometry() const;
* Returns the rectangle of the title area
*/ /**
QRect titleAreaGeometry() const; * Returns the rectangle of the content
*/
/** QRect contentAreaGeometry() const;
* Returns the rectangle of the content
*/ /**
QRect contentAreaGeometry() const; * Returns the tab index of the given DockWidget
*/
/** int tabIndex(CDockWidget* DockWidget);
* Returns the tab index of the given DockWidget
*/ /**
int tabIndex(CDockWidget* DockWidget); * Returns the index of contents of the title widget that is located at
* mouse position pos
/** */
* Returns the index of contents of the title widget that is located at int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = nullptr) const;
* mouse position pos
*/ /**
int indexOfContentByTitlePos(const QPoint& pos, QWidget* exclude = nullptr) const; * Returns a list of all dock widgets in this dock area.
* This list contains open and closed dock widgets.
/** */
* Returns a list of all dock widgets in this dock area. QList<CDockWidget*> dockWidgets() const;
* This list contains open and closed dock widgets.
*/ /**
QList<CDockWidget*> dockWidgets() const; * Returns a list of dock widgets that are not closed
*/
/** QList<CDockWidget*> openedDockWidgets() const;
* Returns a list of dock widgets that are not closed
*/ /**
QList<CDockWidget*> openDockWidgets() const; * Returns the number of dock widgets in this area
*/
/** int count() const;
* Returns the number of dock widgets in this area
*/ /**
int count() const; * Returns a dock widget by its index
*/
/** CDockWidget* dockWidget(int Index) const;
* Returns a dock widget by its index
*/ /**
CDockWidget* dockWidget(int Index) const; * Reorder the index position of DockWidget at fromIndx to toIndex.
*/
/** void reorderDockWidget(int fromIndex, int toIndex);
* Reorder the index position of DockWidget at fromIndx to toIndex.
*/ /**
void reorderDockWidget(int fromIndex, int toIndex); * Returns the index of the current active dock widget
*/
/** int currentIndex() const;
* Returns the index of the current active dock widget
*/ /**
int currentIndex() const; * Returns the current active dock widget
*/
/** CDockWidget* currentDockWidget() const;
* Returns the current active dock widget
*/ /**
CDockWidget* currentDockWidget() const; * Shows the tab with tghe given dock widget
*/
/** void setCurrentDockWidget(CDockWidget* DockWidget);
* Shows the tab with tghe given dock widget
*/ public slots:
void setCurrentDockWidget(CDockWidget* DockWidget); /**
* This sets the index position of the current tab page.
public slots: */
/** void setCurrentIndex(int index);
* This sets the index position of the current tab page.
*/ /**
void setCurrentIndex(int index); * Updates the dock area layout and components visibility
*/
/** void updateDockArea();
* Updates the dock area layout and components visibility
*/ signals:
void updateDockArea(); /**
* This signal is emitted when user clicks on a tab at an index.
signals: */
/** void tabBarClicked(int index);
* This signal is emitted when user clicks on a tab at an index.
*/ /**
void tabBarClicked(int index); * This signal is emitted when the tab bar's current tab changes. The new
* current has the given index, or -1 if there isn't a new one
/** * @param index
* This signal is emitted when the tab bar's current tab changes. The new */
* current has the given index, or -1 if there isn't a new one void currentChanged(int index);
* @param index
*/ /**
void currentChanged(int index); * This signal is emitted if the dock area is closed or opened.
* The dock area will be closed, if all dock widgets in the dock area are
/** * closed and will be opened, when the first dock widget is opened
* This signal is emitted if a dock areas visibility changed. */
* The visibility changes, if the last dock widget in a dock area is closed void viewToggled(bool Open);
* or if one dock widget in a dock area with only closed dock widgets }; // class DockAreaWidget
* becomes visible }
*/ // namespace ads
void visibilityChanged(bool Visible); //-----------------------------------------------------------------------------
}; // class DockAreaWidget #endif // DockAreaWidgetH
}
// namespace ads
//-----------------------------------------------------------------------------
#endif // DockAreaWidgetH

File diff suppressed because it is too large Load Diff

View File

@ -1,146 +1,152 @@
#ifndef DockContainerWidgetH #ifndef DockContainerWidgetH
#define DockContainerWidgetH #define DockContainerWidgetH
/******************************************************************************* /*******************************************************************************
** QtAdcancedDockingSystem ** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler ** Copyright (C) 2017 Uwe Kindler
** **
** This program is free software: you can redistribute it and/or modify ** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** This program is distributed in the hope that it will be useful, ** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
//============================================================================ //============================================================================
/// \file DockContainerWidget.h /// \file DockContainerWidget.h
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 24.02.2017 /// \date 24.02.2017
/// \brief Declaration of CDockContainerWidget class /// \brief Declaration of CDockContainerWidget class
//============================================================================ //============================================================================
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <QFrame> #include <QFrame>
#include "ads_globals.h" #include "ads_globals.h"
namespace ads namespace ads
{ {
struct DockContainerWidgetPrivate; struct DockContainerWidgetPrivate;
class CDockAreaWidget; class CDockAreaWidget;
class CDockWidget; class CDockWidget;
class CDockManager; class CDockManager;
class CFloatingDockContainer; class CFloatingDockContainer;
/** /**
* Container that manages a number of dock areas with single dock widgets * Container that manages a number of dock areas with single dock widgets
* or tabyfied dock widgets in each area * or tabyfied dock widgets in each area
*/ */
class CDockContainerWidget : public QFrame class CDockContainerWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
private: private:
DockContainerWidgetPrivate* d; ///< private data (pimpl) DockContainerWidgetPrivate* d; ///< private data (pimpl)
friend class DockContainerWidgetPrivate; friend class DockContainerWidgetPrivate;
protected: protected:
/** /**
* Handles activation events to update zOrderIndex * Handles activation events to update zOrderIndex
*/ */
virtual bool event(QEvent *e) override; virtual bool event(QEvent *e) override;
public: public:
/** /**
* Default Constructor * Default Constructor
*/ */
CDockContainerWidget(CDockManager* DockManager, QWidget* parent = 0); CDockContainerWidget(CDockManager* DockManager, QWidget* parent = 0);
/** /**
* Virtual Destructor * Virtual Destructor
*/ */
virtual ~CDockContainerWidget(); virtual ~CDockContainerWidget();
/** /**
* Drop floating widget into the container * Drop floating widget into the container
*/ */
void dropFloatingWidget(CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos); void dropFloatingWidget(CFloatingDockContainer* FloatingWidget, const QPoint& TargetPos);
/** /**
* Adds dockwidget into the given area. * Adds dockwidget into the given area.
* If DockAreaWidget is not null, then the area parameter indicates the area * If DockAreaWidget is not null, then the area parameter indicates the area
* into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will * into the DockAreaWidget. If DockAreaWidget is null, the Dockwidget will
* be dropped into the container. * be dropped into the container.
* \return Returns the dock area widget that contains the new DockWidget * \return Returns the dock area widget that contains the new DockWidget
*/ */
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget, CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget = nullptr); CDockAreaWidget* DockAreaWidget = nullptr);
/** /**
* Adds the given dock area to this container widget * Adds the given dock area to this container widget
*/ */
void addDockArea(CDockAreaWidget* DockAreaWidget, DockWidgetArea area = CenterDockWidgetArea); void addDockArea(CDockAreaWidget* DockAreaWidget, DockWidgetArea area = CenterDockWidgetArea);
/** /**
* Removes the given dock area from this container * Removes the given dock area from this container
*/ */
void removeDockArea(CDockAreaWidget* area); void removeDockArea(CDockAreaWidget* area);
/** /**
* Returns the current zOrderIndex * Returns the current zOrderIndex
*/ */
virtual unsigned int zOrderIndex() const; virtual unsigned int zOrderIndex() const;
/** /**
* This function returns true if this container widgets z order index is * This function returns true if this container widgets z order index is
* higher than the index of the container widget given in Other parameter * higher than the index of the container widget given in Other parameter
*/ */
bool isInFrontOf(CDockContainerWidget* Other) const; bool isInFrontOf(CDockContainerWidget* Other) const;
/** /**
* Returns the dock area at teh given global position or 0 if there is no * Returns the dock area at teh given global position or 0 if there is no
* dock area at this position * dock area at this position
*/ */
CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const; CDockAreaWidget* dockAreaAt(const QPoint& GlobalPos) const;
/** /**
* Returns the dock area at the given Index or 0 if the index is out of * Returns the dock area at the given Index or 0 if the index is out of
* range * range
*/ */
CDockAreaWidget* dockArea(int Index) const; CDockAreaWidget* dockArea(int Index) const;
/** /**
* Returns the number of dock areas in this container * Returns the list of dock areas that are not closed
*/ * If all dock widgets in a dock area are closed, the dock area will be closed
int dockAreaCount() const; */
QList<CDockAreaWidget*> openedDockAreas() const;
/**
* This function returns true, if this container is in a floating widget /**
*/ * Returns the number of dock areas in this container
bool isFloating() const; */
int dockAreaCount() const;
signals:
/** /**
* This signal is emitted if one or multiple dock areas has been added to * This function returns true, if this container is in a floating widget
* the internal list of dock areas. */
* If multiple dock areas are inserted, this signal is emitted only once bool isFloating() const;
*/
void dockAreasAdded(); signals:
/**
/** * This signal is emitted if one or multiple dock areas has been added to
* This signal is emitted if one or multiple dock areas has been removed * the internal list of dock areas.
*/ * If multiple dock areas are inserted, this signal is emitted only once
void dockAreasRemoved(); */
}; // class DockContainerWidget void dockAreasAdded();
} // namespace ads
//----------------------------------------------------------------------------- /**
#endif // DockContainerWidgetH * This signal is emitted if one or multiple dock areas has been removed
*/
void dockAreasRemoved();
}; // class DockContainerWidget
} // namespace ads
//-----------------------------------------------------------------------------
#endif // DockContainerWidgetH

View File

@ -1,358 +1,404 @@
/******************************************************************************* /*******************************************************************************
** QtAdcancedDockingSystem ** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler ** Copyright (C) 2017 Uwe Kindler
** **
** This program is free software: you can redistribute it and/or modify ** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** This program is distributed in the hope that it will be useful, ** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
//============================================================================ //============================================================================
/// \file DockWidget.cpp /// \file DockWidget.cpp
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 26.02.2017 /// \date 26.02.2017
/// \brief Implementation of CDockWidget class /// \brief Implementation of CDockWidget class
//============================================================================ //============================================================================
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include "DockWidget.h" #include "DockWidget.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <QAction> #include <QAction>
#include <QSplitter> #include <QSplitter>
#include <QStack> #include <QStack>
#include <QTextStream> #include <QTextStream>
#include <QPointer> #include <QPointer>
#include <iostream> #include <iostream>
#include "DockWidgetTitleBar.h" #include "DockWidgetTitleBar.h"
#include "DockContainerWidget.h" #include "DockContainerWidget.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockManager.h" #include "DockManager.h"
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include "ads_globals.h" #include "ads_globals.h"
namespace ads namespace ads
{ {
/** /**
* Private data class of CDockWidget class (pimpl) * Private data class of CDockWidget class (pimpl)
*/ */
struct DockWidgetPrivate struct DockWidgetPrivate
{ {
CDockWidget* _this; CDockWidget* _this;
QBoxLayout* Layout; QBoxLayout* Layout;
QWidget* Widget = nullptr; QWidget* Widget = nullptr;
CDockWidgetTitleBar* TitleWidget; CDockWidgetTitleBar* TitleWidget;
CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures; CDockWidget::DockWidgetFeatures Features = CDockWidget::AllDockWidgetFeatures;
CDockManager* DockManager = nullptr; CDockManager* DockManager = nullptr;
CDockAreaWidget* DockArea = nullptr; CDockAreaWidget* DockArea = nullptr;
QAction* ToggleViewAction; QAction* ToggleViewAction;
bool Closed = false; bool Closed = false;
struct CapturedState struct CapturedState
{ {
QString DockTreePosition; QString DockTreePosition;
QRect GlobalGeometry; QRect GlobalGeometry;
QPointer<CDockContainerWidget> DockContainer; QPointer<CDockContainerWidget> DockContainer;
} CapturedState; } CapturedState;
/** /**
* Private data constructor * Private data constructor
*/ */
DockWidgetPrivate(CDockWidget* _public); DockWidgetPrivate(CDockWidget* _public);
/** /**
* Saves the current state into CapturedState variable * Saves the current state into CapturedState variable
*/ */
void capturedState(); void capturedState();
/** /**
* Show dock widget * Show dock widget
*/ */
void showDockWidget(); void showDockWidget();
/** /**
* Hides a parent splitter if all dock widgets in the splitter are closed * Hide dock widget.
*/ */
void hideEmptyParentSplitter(); void hideDockWidget();
/** /**
* Hides a dock area if all dock widgets in the area are closed * Hides a parent splitter if all dock widgets in the splitter are closed
*/ */
void hideEmptyParentDockArea(); void hideEmptyParentSplitter();
};
// struct DockWidgetPrivate /**
* Hides a dock area if all dock widgets in the area are closed
//============================================================================ */
DockWidgetPrivate::DockWidgetPrivate(CDockWidget* _public) : void hideEmptyParentDockArea();
_this(_public)
{ /**
* Hides a floating widget if all dock areas are empty - that means,
} * if all dock widgets in all dock areas are closed
*/
void hideEmptyFloatingWidget();
//============================================================================ };
void DockWidgetPrivate::capturedState() // struct DockWidgetPrivate
{
QString DockTreePosition; //============================================================================
QTextStream stream(&DockTreePosition); DockWidgetPrivate::DockWidgetPrivate(CDockWidget* _public) :
_this(_public)
QPoint GlobalTopLeft = _this->mapToGlobal(_this->geometry().topLeft()); {
QRect Rect(GlobalTopLeft, _this->geometry().size());
CapturedState.GlobalGeometry = Rect; }
CapturedState.DockContainer = _this->dockContainer();
QWidget* Widget = DockArea; //============================================================================
QSplitter* splitter = internal::findParent<QSplitter*>(Widget); void DockWidgetPrivate::capturedState()
QStack<QString> SplitterData; {
while (splitter) QString DockTreePosition;
{ QTextStream stream(&DockTreePosition);
SplitterData.push(QString("%1%2")
.arg((splitter->orientation() == Qt::Horizontal) ? "H" : "V") QPoint GlobalTopLeft = _this->mapToGlobal(_this->geometry().topLeft());
.arg(splitter->indexOf(Widget))); QRect Rect(GlobalTopLeft, _this->geometry().size());
Widget = splitter; CapturedState.GlobalGeometry = Rect;
splitter = internal::findParent<QSplitter*>(Widget); CapturedState.DockContainer = _this->dockContainer();
}
QWidget* Widget = DockArea;
QString Separator; QSplitter* splitter = internal::findParent<QSplitter*>(Widget);
while (!SplitterData.isEmpty()) QStack<QString> SplitterData;
{ while (splitter)
stream << Separator << SplitterData.pop(); {
Separator = " "; SplitterData.push(QString("%1%2")
} .arg((splitter->orientation() == Qt::Horizontal) ? "H" : "V")
this->CapturedState.DockTreePosition = DockTreePosition; .arg(splitter->indexOf(Widget)));
std::cout << "SerializedPosition: " << DockTreePosition.toStdString() << std::endl; Widget = splitter;
} splitter = internal::findParent<QSplitter*>(Widget);
}
//============================================================================ QString Separator;
void DockWidgetPrivate::showDockWidget() while (!SplitterData.isEmpty())
{ {
DockArea->show(); stream << Separator << SplitterData.pop();
DockArea->setCurrentIndex(DockArea->tabIndex(_this)); Separator = " ";
QSplitter* Splitter = internal::findParent<QSplitter*>(_this); }
if (Splitter) this->CapturedState.DockTreePosition = DockTreePosition;
{ std::cout << "SerializedPosition: " << DockTreePosition.toStdString() << std::endl;
Splitter->show(); }
}
}
//============================================================================
void DockWidgetPrivate::showDockWidget()
//============================================================================ {
void DockWidgetPrivate::hideEmptyParentSplitter() DockArea->show();
{ DockArea->setCurrentIndex(DockArea->tabIndex(_this));
QSplitter* Splitter = internal::findParent<QSplitter*>(_this); QSplitter* Splitter = internal::findParent<QSplitter*>(_this);
if (!Splitter) if (Splitter)
{ {
return; Splitter->show();
} }
for (int i = 0; i < Splitter->count(); ++i) CDockContainerWidget* Container = DockArea->dockContainer();
{ if (Container->isFloating())
if (Splitter->widget(i)->isVisible()) {
{ CFloatingDockContainer* FloatingWidget = internal::findParent<
return; CFloatingDockContainer*>(Container);
} FloatingWidget->show();
} }
}
Splitter->hide();
}
//============================================================================
void DockWidgetPrivate::hideDockWidget()
//============================================================================ {
void DockWidgetPrivate::hideEmptyParentDockArea() ToggleViewAction->setChecked(false);
{ TitleWidget->hide();
auto OpenDockWidgets = DockArea->openDockWidgets(); hideEmptyParentDockArea();
if (OpenDockWidgets.count() > 1) hideEmptyParentSplitter();
{ hideEmptyFloatingWidget();
CDockWidget* NextDockWidget; }
if (OpenDockWidgets.last() == _this)
{
NextDockWidget = OpenDockWidgets[OpenDockWidgets.count() - 2]; //============================================================================
} void DockWidgetPrivate::hideEmptyParentSplitter()
else {
{ QSplitter* Splitter = internal::findParent<QSplitter*>(_this);
int NextIndex = OpenDockWidgets.indexOf(_this) + 1; if (!Splitter)
NextDockWidget = OpenDockWidgets[NextIndex]; {
} return;
}
DockArea->setCurrentDockWidget(NextDockWidget);
} for (int i = 0; i < Splitter->count(); ++i)
else {
{ if (Splitter->widget(i)->isVisible())
DockArea->hide(); {
} return;
} }
}
//============================================================================ Splitter->hide();
CDockWidget::CDockWidget(const QString &title, QWidget *parent) : }
QFrame(parent),
d(new DockWidgetPrivate(this))
{ //============================================================================
d->Layout = new QBoxLayout(QBoxLayout::TopToBottom); void DockWidgetPrivate::hideEmptyParentDockArea()
d->Layout->setContentsMargins(0, 0, 0, 0); {
d->Layout->setSpacing(0); auto OpenDockWidgets = DockArea->openedDockWidgets();
setLayout(d->Layout); if (OpenDockWidgets.count() > 1)
setWindowTitle(title); {
CDockWidget* NextDockWidget;
d->TitleWidget = new CDockWidgetTitleBar(this); if (OpenDockWidgets.last() == _this)
d->ToggleViewAction = new QAction(title); {
d->ToggleViewAction->setCheckable(true); NextDockWidget = OpenDockWidgets[OpenDockWidgets.count() - 2];
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this, }
SLOT(toggleView(bool))); else
} {
int NextIndex = OpenDockWidgets.indexOf(_this) + 1;
//============================================================================ NextDockWidget = OpenDockWidgets[NextIndex];
CDockWidget::~CDockWidget() }
{
std::cout << "~CDockWidget()" << std::endl; DockArea->setCurrentDockWidget(NextDockWidget);
delete d; }
} else
{
DockArea->hide();
//============================================================================ }
void CDockWidget::setWidget(QWidget* widget) }
{
if (d->Widget)
{ //============================================================================
d->Layout->replaceWidget(d->Widget, widget); void DockWidgetPrivate::hideEmptyFloatingWidget()
} {
else CDockContainerWidget* Container = _this->dockContainer();
{ if (Container->isFloating() && Container->openedDockAreas().isEmpty())
d->Layout->addWidget(widget); {
} CFloatingDockContainer* FloatingWidget = internal::findParent<CFloatingDockContainer*>(Container);
FloatingWidget->hide();
d->Widget = widget; }
} }
//============================================================================ //============================================================================
QWidget* CDockWidget::widget() const CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
{ QFrame(parent),
return d->Widget; d(new DockWidgetPrivate(this))
} {
d->Layout = new QBoxLayout(QBoxLayout::TopToBottom);
d->Layout->setContentsMargins(0, 0, 0, 0);
//============================================================================ d->Layout->setSpacing(0);
CDockWidgetTitleBar* CDockWidget::titleBar() const setLayout(d->Layout);
{ setWindowTitle(title);
return d->TitleWidget;
} d->TitleWidget = new CDockWidgetTitleBar(this);
d->ToggleViewAction = new QAction(title);
d->ToggleViewAction->setCheckable(true);
//============================================================================ connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
void CDockWidget::setFeatures(DockWidgetFeatures features) SLOT(toggleView(bool)));
{ }
d->Features = features;
} //============================================================================
CDockWidget::~CDockWidget()
{
//============================================================================ std::cout << "~CDockWidget()" << std::endl;
CDockWidget::DockWidgetFeatures CDockWidget::features() const delete d;
{ }
return d->Features;
}
//============================================================================
void CDockWidget::setToggleViewActionChecked(bool Checked)
//============================================================================ {
CDockManager* CDockWidget::dockManager() const QAction* Action = d->ToggleViewAction;
{ Action->blockSignals(true);
return d->DockManager; Action->setChecked(Checked);
} Action->blockSignals(false);
}
//============================================================================
void CDockWidget::setDockManager(CDockManager* DockManager) //============================================================================
{ void CDockWidget::setWidget(QWidget* widget)
d->DockManager = DockManager; {
} if (d->Widget)
{
d->Layout->replaceWidget(d->Widget, widget);
//============================================================================ }
CDockContainerWidget* CDockWidget::dockContainer() const else
{ {
return internal::findParent<CDockContainerWidget*>(this); d->Layout->addWidget(widget);
} }
d->Widget = widget;
//============================================================================ }
CDockAreaWidget* CDockWidget::dockAreaWidget() const
{
return internal::findParent<CDockAreaWidget*>(this); //============================================================================
} QWidget* CDockWidget::widget() const
{
return d->Widget;
//============================================================================ }
bool CDockWidget::isFloating() const
{
return dockContainer() ? dockContainer()->isFloating() : false; //============================================================================
} CDockWidgetTitleBar* CDockWidget::titleBar() const
{
return d->TitleWidget;
//============================================================================ }
bool CDockWidget::isClosed() const
{
return d->Closed; //============================================================================
} void CDockWidget::setFeatures(DockWidgetFeatures features)
{
d->Features = features;
//============================================================================ }
QAction* CDockWidget::toggleViewAction() const
{
return d->ToggleViewAction; //============================================================================
} CDockWidget::DockWidgetFeatures CDockWidget::features() const
{
return d->Features;
//============================================================================ }
void CDockWidget::toggleView(bool Open)
{
if (Open) //============================================================================
{ CDockManager* CDockWidget::dockManager() const
d->showDockWidget(); {
} return d->DockManager;
else }
{
hideDockWidget();
} //============================================================================
d->Closed = !Open; void CDockWidget::setDockManager(CDockManager* DockManager)
} {
d->DockManager = DockManager;
}
//============================================================================
void CDockWidget::setDockArea(CDockAreaWidget* DockArea)
{ //============================================================================
d->DockArea = DockArea; CDockContainerWidget* CDockWidget::dockContainer() const
d->ToggleViewAction->setChecked(DockArea != nullptr); {
} return internal::findParent<CDockContainerWidget*>(this);
}
//============================================================================ //============================================================================
void CDockWidget::hideDockWidget() CDockAreaWidget* CDockWidget::dockAreaWidget() const
{ {
CDockAreaWidget* DockArea = d->DockArea; return internal::findParent<CDockAreaWidget*>(this);
d->ToggleViewAction->setChecked(false); }
d->TitleWidget->hide();
d->hideEmptyParentDockArea();
d->hideEmptyParentSplitter(); //============================================================================
} bool CDockWidget::isFloating() const
{
} // namespace ads return dockContainer() ? dockContainer()->isFloating() : false;
}
//---------------------------------------------------------------------------
// EOF DockWidget.cpp
//============================================================================
bool CDockWidget::isClosed() const
{
return d->Closed;
}
//============================================================================
QAction* CDockWidget::toggleViewAction() const
{
return d->ToggleViewAction;
}
//============================================================================
void CDockWidget::toggleView(bool Open)
{
if (Open)
{
d->showDockWidget();
}
else
{
d->hideDockWidget();
}
d->Closed = !Open;
if (!Open)
{
emit closed();
}
emit viewToggled(Open);
}
//============================================================================
void CDockWidget::setDockArea(CDockAreaWidget* DockArea)
{
d->DockArea = DockArea;
d->ToggleViewAction->setChecked(DockArea != nullptr);
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockWidget.cpp

View File

@ -1,180 +1,192 @@
#ifndef DockWidgetH #ifndef DockWidgetH
#define DockWidgetH #define DockWidgetH
/******************************************************************************* /*******************************************************************************
** QtAdcancedDockingSystem ** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler ** Copyright (C) 2017 Uwe Kindler
** **
** This program is free software: you can redistribute it and/or modify ** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** This program is distributed in the hope that it will be useful, ** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
//============================================================================ //============================================================================
/// \file DockWidget.h /// \file DockWidget.h
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 26.02.2017 /// \date 26.02.2017
/// \brief Declaration of CDockWidget class /// \brief Declaration of CDockWidget class
//============================================================================ //============================================================================
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <QFrame> #include <QFrame>
namespace ads namespace ads
{ {
struct DockWidgetPrivate; struct DockWidgetPrivate;
class CDockWidgetTitleBar; class CDockWidgetTitleBar;
class CDockManager; class CDockManager;
class CDockContainerWidget; class CDockContainerWidget;
class CDockAreaWidget; class CDockAreaWidget;
/** /**
* The QDockWidget class provides a widget that can be docked inside a * The QDockWidget class provides a widget that can be docked inside a
* CDockManager or floated as a top-level window on the desktop. * CDockManager or floated as a top-level window on the desktop.
*/ */
class CDockWidget : public QFrame class CDockWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
private: private:
DockWidgetPrivate* d; ///< private data (pimpl) DockWidgetPrivate* d; ///< private data (pimpl)
friend class DockWidgetPrivate; friend class DockWidgetPrivate;
protected: protected:
friend class CDockContainerWidget; friend class CDockContainerWidget;
friend class CDockAreaWidget; friend class CDockAreaWidget;
friend class CFloatingDockContainer; friend class CFloatingDockContainer;
/** /**
* Assigns the dock manager that manages this dock widget * Assigns the dock manager that manages this dock widget
*/ */
void setDockManager(CDockManager* DockManager); void setDockManager(CDockManager* DockManager);
/** /**
* If this dock widget is inserted into a dock area, the dock area will * If this dock widget is inserted into a dock area, the dock area will
* be registered on this widget via this function. If a dock widget is * be registered on this widget via this function. If a dock widget is
* removed from a dock area, this function will be called with nullptr * removed from a dock area, this function will be called with nullptr
* value. * value.
*/ */
void setDockArea(CDockAreaWidget* DockArea); void setDockArea(CDockAreaWidget* DockArea);
/** /**
* Hide dock widget. * This function changes the toggle view action without emitting any
*/ * signal
void hideDockWidget(); */
void setToggleViewActionChecked(bool Checked);
public:
enum DockWidgetFeature public:
{ enum DockWidgetFeature
DockWidgetClosable = 0x01, {
DockWidgetMovable = 0x02, DockWidgetClosable = 0x01,
DockWidgetFloatable = 0x04, DockWidgetMovable = 0x02,
AllDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable, DockWidgetFloatable = 0x04,
NoDockWidgetFeatures = 0x00 AllDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable,
}; NoDockWidgetFeatures = 0x00
Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature) };
Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
enum eState
{ enum eState
StateHidden, {
StateDocked, StateHidden,
StateFloating StateDocked,
}; StateFloating
};
/**
* Default Constructor /**
*/ * Default Constructor
CDockWidget(const QString &title, QWidget* parent = 0); */
CDockWidget(const QString &title, QWidget* parent = 0);
/**
* Virtual Destructor /**
*/ * Virtual Destructor
virtual ~CDockWidget(); */
virtual ~CDockWidget();
/**
* Sets the widget for the dock widget to widget. /**
*/ * Sets the widget for the dock widget to widget.
void setWidget(QWidget* widget); */
void setWidget(QWidget* widget);
/**
* Returns the widget for the dock widget. This function returns zero if /**
* the widget has not been set. * Returns the widget for the dock widget. This function returns zero if
*/ * the widget has not been set.
QWidget* widget() const; */
QWidget* widget() const;
/**
* Returns the title bar widget of this dock widget /**
*/ * Returns the title bar widget of this dock widget
CDockWidgetTitleBar* titleBar() const; */
CDockWidgetTitleBar* titleBar() const;
/**
* Sets, whether the dock widget is movable, closable, and floatable. /**
*/ * Sets, whether the dock widget is movable, closable, and floatable.
void setFeatures(DockWidgetFeatures features); */
void setFeatures(DockWidgetFeatures features);
/**
* This property holds whether the dock widget is movable, closable, and /**
* floatable. * This property holds whether the dock widget is movable, closable, and
* By default, this property is set to a combination of DockWidgetClosable, * floatable.
* DockWidgetMovable and DockWidgetFloatable. * By default, this property is set to a combination of DockWidgetClosable,
*/ * DockWidgetMovable and DockWidgetFloatable.
DockWidgetFeatures features() const; */
DockWidgetFeatures features() const;
/**
* Returns the dock manager that manages the dock widget or 0 if the widget /**
* has not been assigned to any dock manager yet * Returns the dock manager that manages the dock widget or 0 if the widget
*/ * has not been assigned to any dock manager yet
CDockManager* dockManager() const; */
CDockManager* dockManager() const;
/**
* Returns the dock container widget this dock area widget belongs to or 0 /**
* if this dock widget has nt been docked yet * Returns the dock container widget this dock area widget belongs to or 0
*/ * if this dock widget has nt been docked yet
CDockContainerWidget* dockContainer() const; */
CDockContainerWidget* dockContainer() const;
/**
* Returns the dock area widget this dock widget belongs to or 0 /**
* if this dock widget has not been docked yet * Returns the dock area widget this dock widget belongs to or 0
*/ * if this dock widget has not been docked yet
CDockAreaWidget* dockAreaWidget() const; */
CDockAreaWidget* dockAreaWidget() const;
/**
* This property holds whether the dock widget is floating. /**
*/ * This property holds whether the dock widget is floating.
bool isFloating() const; */
bool isFloating() const;
/**
* Returns true, if this dock widget is closed. /**
*/ * Returns true, if this dock widget is closed.
bool isClosed() const; */
bool isClosed() const;
/**
* Returns a checkable action that can be used to show or close this dock widget. /**
* The action's text is set to the dock widget's window title. * Returns a checkable action that can be used to show or close this dock widget.
*/ * The action's text is set to the dock widget's window title.
QAction* toggleViewAction() const; */
QAction* toggleViewAction() const;
public slots:
/** public slots:
* This property controls whether the dock widget is open or closed. /**
* The toogleViewAction triggers this slot * This property controls whether the dock widget is open or closed.
*/ * The toogleViewAction triggers this slot
void toggleView(bool Open); */
}; // class DockWidget void toggleView(bool Open);
}
// namespace ads signals:
//----------------------------------------------------------------------------- /**
#endif // DockWidgetH * This signal is emitted if the dock widget is opened or closed
*/
void viewToggled(bool Open);
/**
* This signal is emitted if the dock widget is closed
*/
void closed();
}; // class DockWidget
}
// namespace ads
//-----------------------------------------------------------------------------
#endif // DockWidgetH

View File

@ -1,385 +1,397 @@
/******************************************************************************* /*******************************************************************************
** QtAdcancedDockingSystem ** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler ** Copyright (C) 2017 Uwe Kindler
** **
** This program is free software: you can redistribute it and/or modify ** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** This program is distributed in the hope that it will be useful, ** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
//============================================================================ //============================================================================
/// \file FloatingDockContainer.cpp /// \file FloatingDockContainer.cpp
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 01.03.2017 /// \date 01.03.2017
/// \brief Implementation of CFloatingDockContainer class /// \brief Implementation of CFloatingDockContainer class
//============================================================================ //============================================================================
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <QApplication> #include <QApplication>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPointer> #include <QPointer>
#include <QAction>
#include <iostream>
#include <iostream>
#include "DockContainerWidget.h"
#include "DockAreaWidget.h" #include "DockContainerWidget.h"
#include "DockManager.h" #include "DockAreaWidget.h"
#include "DockWidget.h" #include "DockManager.h"
#include "DockOverlay.h" #include "DockWidget.h"
#include "DockOverlay.h"
namespace ads
{ namespace ads
static unsigned int zOrderCounter = 0; {
static unsigned int zOrderCounter = 0;
/**
* Private data class of CFloatingDockContainer class (pimpl) /**
*/ * Private data class of CFloatingDockContainer class (pimpl)
struct FloatingDockContainerPrivate */
{ struct FloatingDockContainerPrivate
CFloatingDockContainer* _this; {
CDockContainerWidget* DockContainer; CFloatingDockContainer* _this;
unsigned int zOrderIndex = ++zOrderCounter; CDockContainerWidget* DockContainer;
QPointer<CDockManager> DockManager; unsigned int zOrderIndex = ++zOrderCounter;
bool DraggingActive = false; QPointer<CDockManager> DockManager;
QPoint DragStartMousePosition; bool DraggingActive = false;
CDockContainerWidget* DropContainer = nullptr; QPoint DragStartMousePosition;
CDockAreaWidget* SingleDockArea = nullptr; CDockContainerWidget* DropContainer = nullptr;
CDockAreaWidget* SingleDockArea = nullptr;
/**
* Private data constructor /**
*/ * Private data constructor
FloatingDockContainerPrivate(CFloatingDockContainer* _public); */
FloatingDockContainerPrivate(CFloatingDockContainer* _public);
void titleMouseReleaseEvent();
void updateDropOverlays(const QPoint& GlobalPos); void titleMouseReleaseEvent();
void setDraggingActive(bool Active); void updateDropOverlays(const QPoint& GlobalPos);
}; void setDraggingActive(bool Active);
// struct FloatingDockContainerPrivate };
// struct FloatingDockContainerPrivate
//============================================================================
FloatingDockContainerPrivate::FloatingDockContainerPrivate(CFloatingDockContainer* _public) : //============================================================================
_this(_public) FloatingDockContainerPrivate::FloatingDockContainerPrivate(CFloatingDockContainer* _public) :
{ _this(_public)
{
}
}
//============================================================================
void FloatingDockContainerPrivate::titleMouseReleaseEvent() //============================================================================
{ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
setDraggingActive(false); {
if (!DropContainer) setDraggingActive(false);
{ if (!DropContainer)
return; {
} return;
}
std::cout << "Dropped" << std::endl;
DropContainer->dropFloatingWidget(_this, QCursor::pos()); std::cout << "Dropped" << std::endl;
DockManager->containerOverlay()->hideOverlay(); DropContainer->dropFloatingWidget(_this, QCursor::pos());
DockManager->dockAreaOverlay()->hideOverlay(); DockManager->containerOverlay()->hideOverlay();
} DockManager->dockAreaOverlay()->hideOverlay();
}
//============================================================================
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos) //============================================================================
{ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
if (!_this->isVisible() || !DockManager) {
{ if (!_this->isVisible() || !DockManager)
return; {
} return;
}
auto Containers = DockManager->dockContainers();
CDockContainerWidget* TopContainer = nullptr; auto Containers = DockManager->dockContainers();
for (auto ContainerWidget : Containers) CDockContainerWidget* TopContainer = nullptr;
{ for (auto ContainerWidget : Containers)
if (!ContainerWidget->isVisible()) {
{ if (!ContainerWidget->isVisible())
continue; {
} continue;
}
if (DockContainer == ContainerWidget)
{ if (DockContainer == ContainerWidget)
continue; {
} continue;
}
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
if (ContainerWidget->rect().contains(MappedPos)) QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
{ if (ContainerWidget->rect().contains(MappedPos))
if (!TopContainer || ContainerWidget->isInFrontOf(TopContainer)) {
{ if (!TopContainer || ContainerWidget->isInFrontOf(TopContainer))
TopContainer = ContainerWidget; {
} TopContainer = ContainerWidget;
} }
} }
}
DropContainer = TopContainer;
auto ContainerOverlay = DockManager->containerOverlay(); DropContainer = TopContainer;
auto DockAreaOverlay = DockManager->dockAreaOverlay(); auto ContainerOverlay = DockManager->containerOverlay();
auto DockAreaOverlay = DockManager->dockAreaOverlay();
if (!TopContainer)
{ if (!TopContainer)
ContainerOverlay->hideOverlay(); {
DockAreaOverlay->hideOverlay(); ContainerOverlay->hideOverlay();
return; DockAreaOverlay->hideOverlay();
} return;
}
ContainerOverlay->setAllowedAreas(TopContainer->dockAreaCount() > 1 ?
OuterDockAreas : AllDockAreas); ContainerOverlay->setAllowedAreas(TopContainer->dockAreaCount() > 1 ?
ContainerOverlay->showOverlay(TopContainer); OuterDockAreas : AllDockAreas);
ContainerOverlay->raise(); ContainerOverlay->showOverlay(TopContainer);
ContainerOverlay->raise();
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
if (DockArea && TopContainer->dockAreaCount() > 1) auto DockArea = TopContainer->dockAreaAt(GlobalPos);
{ if (DockArea && TopContainer->dockAreaCount() > 1)
DockAreaOverlay->setAllowedAreas(AllDockAreas); {
DockAreaOverlay->showOverlay(DockArea); DockAreaOverlay->setAllowedAreas(AllDockAreas);
} DockAreaOverlay->showOverlay(DockArea);
else }
{ else
DockAreaOverlay->hideOverlay(); {
} DockAreaOverlay->hideOverlay();
} }
}
//============================================================================
void FloatingDockContainerPrivate::setDraggingActive(bool Active) //============================================================================
{ void FloatingDockContainerPrivate::setDraggingActive(bool Active)
DraggingActive = Active; {
} DraggingActive = Active;
}
//============================================================================
CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) : //============================================================================
QWidget(DockManager, Qt::Window), CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
d(new FloatingDockContainerPrivate(this)) QWidget(DockManager, Qt::Window),
{ d(new FloatingDockContainerPrivate(this))
//setAttribute(Qt::WA_DeleteOnClose); {
d->DockManager = DockManager; //setAttribute(Qt::WA_DeleteOnClose);
QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom); d->DockManager = DockManager;
l->setContentsMargins(0, 0, 0, 0); QBoxLayout* l = new QBoxLayout(QBoxLayout::TopToBottom);
l->setSpacing(0); l->setContentsMargins(0, 0, 0, 0);
setLayout(l); l->setSpacing(0);
setLayout(l);
d->DockContainer = new CDockContainerWidget(DockManager, this);
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this, SLOT(onDockAreasAddedOrRemoved())); d->DockContainer = new CDockContainerWidget(DockManager, this);
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved())); connect(d->DockContainer, SIGNAL(dockAreasAdded()), this, SLOT(onDockAreasAddedOrRemoved()));
l->addWidget(d->DockContainer); connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved()));
DockManager->registerFloatingWidget(this); 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 // We install an event filter to detect mouse release events because we
// the drop overlay cross // do not receive mouse release event if the floating widget is behind
qApp->installEventFilter(this); // the drop overlay cross
} qApp->installEventFilter(this);
}
//============================================================================
CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) : //============================================================================
CFloatingDockContainer(DockArea->dockManager()) CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) :
{ CFloatingDockContainer(DockArea->dockManager())
d->DockContainer->addDockArea(DockArea); {
} d->DockContainer->addDockArea(DockArea);
}
//============================================================================
CFloatingDockContainer::CFloatingDockContainer(CDockWidget* DockWidget) : //============================================================================
CFloatingDockContainer(DockWidget->dockManager()) CFloatingDockContainer::CFloatingDockContainer(CDockWidget* DockWidget) :
{ CFloatingDockContainer(DockWidget->dockManager())
d->DockContainer->addDockWidget(CenterDockWidgetArea, DockWidget); {
} d->DockContainer->addDockWidget(CenterDockWidgetArea, DockWidget);
}
//============================================================================
CFloatingDockContainer::~CFloatingDockContainer() //============================================================================
{ CFloatingDockContainer::~CFloatingDockContainer()
std::cout << "~CFloatingDockContainer" << std::endl; {
if (d->DockManager) std::cout << "~CFloatingDockContainer" << std::endl;
{ if (d->DockManager)
d->DockManager->removeFloatingWidget(this); {
} d->DockManager->removeFloatingWidget(this);
delete d; }
} delete d;
}
//============================================================================
CDockContainerWidget* CFloatingDockContainer::dockContainer() const //============================================================================
{ CDockContainerWidget* CFloatingDockContainer::dockContainer() const
return d->DockContainer; {
} return d->DockContainer;
}
//============================================================================
void CFloatingDockContainer::changeEvent(QEvent *event) //============================================================================
{ void CFloatingDockContainer::changeEvent(QEvent *event)
QWidget::changeEvent(event); {
if ((event->type() == QEvent::ActivationChange) && isActiveWindow()) QWidget::changeEvent(event);
{ if ((event->type() == QEvent::ActivationChange) && isActiveWindow())
std::cout << "FloatingWidget::changeEvent QEvent::ActivationChange " << std::endl; {
d->zOrderIndex = ++zOrderCounter; std::cout << "FloatingWidget::changeEvent QEvent::ActivationChange " << std::endl;
return; d->zOrderIndex = ++zOrderCounter;
} return;
} }
}
//============================================================================
void CFloatingDockContainer::moveEvent(QMoveEvent *event) //============================================================================
{ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
QWidget::moveEvent(event); {
if (!qApp->mouseButtons().testFlag(Qt::LeftButton)) QWidget::moveEvent(event);
{ if (!qApp->mouseButtons().testFlag(Qt::LeftButton))
if (d->DraggingActive) {
{ if (d->DraggingActive)
d->setDraggingActive(false); {
} d->setDraggingActive(false);
return; }
} return;
}
if (d->DraggingActive)
{ if (d->DraggingActive)
d->updateDropOverlays(QCursor::pos()); {
} d->updateDropOverlays(QCursor::pos());
} }
}
//============================================================================
void CFloatingDockContainer::closeEvent(QCloseEvent *event) //============================================================================
{ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
d->setDraggingActive(false); {
if (dockContainer()->dockAreaCount() > 1 || dockContainer()->dockArea(0)->count() == 1) d->setDraggingActive(false);
{ QWidget::closeEvent(event);
for (int i = 0; i < dockContainer()->dockAreaCount(); ++i)
{ }
auto DockWidgets = dockContainer()->dockArea(i)->dockWidgets();
for (auto DockWidget : DockWidgets)
{ //============================================================================
DockWidget->hideDockWidget(); void CFloatingDockContainer::hideEvent(QHideEvent *event)
} {
} QWidget::hideEvent(event);
QWidget::closeEvent(event); auto OpenDockAreas = d->DockContainer->openedDockAreas();
} for (auto DockArea : OpenDockAreas)
else {
{ auto OpenDockWidgets = DockArea->openedDockWidgets();
auto DockArea = dockContainer()->dockArea(0); for (auto DockWidget : OpenDockWidgets)
DockArea->currentDockWidget()->hideDockWidget(); {
// As long as there are open dock widgets, we do not close the floating DockWidget->setToggleViewActionChecked(false);
// window }
if (DockArea->openDockWidgets().count()) }
{ }
event->ignore();
}
} //============================================================================
} void CFloatingDockContainer::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
//============================================================================ CDockContainerWidget* DockContainer = dockContainer();
bool CFloatingDockContainer::event(QEvent *e) for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
{ {
if ((e->type() == QEvent::NonClientAreaMouseButtonPress)) auto DockArea = DockContainer->dockArea(i);
{ for (auto DockWidget : DockArea->openedDockWidgets())
if (QGuiApplication::mouseButtons() == Qt::LeftButton) {
{ DockWidget->setToggleViewActionChecked(true);
std::cout << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type() << std::endl; }
d->setDraggingActive(true); }
} }
}
else if (e->type() == QEvent::NonClientAreaMouseButtonDblClick)
{ //============================================================================
std::cout << "FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick" << std::endl; bool CFloatingDockContainer::event(QEvent *e)
d->setDraggingActive(false); {
} if ((e->type() == QEvent::NonClientAreaMouseButtonPress))
else if ((e->type() == QEvent::NonClientAreaMouseButtonRelease) && d->DraggingActive) {
{ if (QGuiApplication::mouseButtons() == Qt::LeftButton)
std::cout << "FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease" << std::endl; {
d->titleMouseReleaseEvent(); std::cout << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type() << std::endl;
} d->setDraggingActive(true);
}
return QWidget::event(e); }
} else if (e->type() == QEvent::NonClientAreaMouseButtonDblClick)
{
std::cout << "FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick" << std::endl;
//============================================================================ d->setDraggingActive(false);
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event) }
{ else if ((e->type() == QEvent::NonClientAreaMouseButtonRelease) && d->DraggingActive)
if (event->type() == QEvent::MouseButtonRelease && d->DraggingActive) {
{ std::cout << "FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease" << std::endl;
std::cout << "FloatingWidget::eventFilter QEvent::MouseButtonRelease" << std::endl; d->titleMouseReleaseEvent();
d->titleMouseReleaseEvent(); }
}
return QWidget::event(e);
return false; }
}
//============================================================================
//============================================================================ bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
void CFloatingDockContainer::startFloating(const QPoint& Pos, const QSize& Size) {
{ if (event->type() == QEvent::MouseButtonRelease && d->DraggingActive)
resize(Size); {
d->setDraggingActive(true); std::cout << "FloatingWidget::eventFilter QEvent::MouseButtonRelease" << std::endl;
QPoint TargetPos = QCursor::pos() - Pos; d->titleMouseReleaseEvent();
move(TargetPos); }
show();
d->DragStartMousePosition = Pos; return false;
} }
//============================================================================ //============================================================================
void CFloatingDockContainer::moveFloating() void CFloatingDockContainer::startFloating(const QPoint& Pos, const QSize& Size)
{ {
int BorderSize = (frameSize().width() - size().width()) / 2; resize(Size);
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition - QPoint(BorderSize, 0); d->setDraggingActive(true);
move(moveToPos); QPoint TargetPos = QCursor::pos() - Pos;
} move(TargetPos);
show();
d->DragStartMousePosition = Pos;
//============================================================================ }
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
{
if (d->DockContainer->dockAreaCount() == 1) //============================================================================
{ void CFloatingDockContainer::moveFloating()
d->SingleDockArea = d->DockContainer->dockArea(0); {
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle()); int BorderSize = (frameSize().width() - size().width()) / 2;
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this, const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition - QPoint(BorderSize, 0);
SLOT(onDockAreaCurrentChanged(int))); move(moveToPos);
} }
else
{
if (d->SingleDockArea) //============================================================================
{ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
disconnect(d->SingleDockArea, SIGNAL(currentChanged(int)), this, {
SLOT(onDockAreaCurrentChanged(int))); if (d->DockContainer->dockAreaCount() == 1)
d->SingleDockArea = nullptr; {
} d->SingleDockArea = d->DockContainer->dockArea(0);
this->setWindowTitle(qApp->applicationDisplayName()); this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
} connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
} SLOT(onDockAreaCurrentChanged(int)));
}
else
//============================================================================ {
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index) if (d->SingleDockArea)
{ {
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle()); disconnect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
} SLOT(onDockAreaCurrentChanged(int)));
d->SingleDockArea = nullptr;
}
} // namespace ads this->setWindowTitle(qApp->applicationDisplayName());
}
//--------------------------------------------------------------------------- }
// EOF FloatingDockContainer.cpp
//============================================================================
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
{
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF FloatingDockContainer.cpp

View File

@ -1,108 +1,110 @@
#ifndef FloatingDockContainerH #ifndef FloatingDockContainerH
#define FloatingDockContainerH #define FloatingDockContainerH
/******************************************************************************* /*******************************************************************************
** QtAdcancedDockingSystem ** QtAdcancedDockingSystem
** Copyright (C) 2017 Uwe Kindler ** Copyright (C) 2017 Uwe Kindler
** **
** This program is free software: you can redistribute it and/or modify ** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or ** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** This program is distributed in the hope that it will be useful, ** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
//============================================================================ //============================================================================
/// \file FloatingDockContainer.h /// \file FloatingDockContainer.h
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 01.03.2017 /// \date 01.03.2017
/// \brief Declaration of CFloatingDockContainer class /// \brief Declaration of CFloatingDockContainer class
//============================================================================ //============================================================================
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <QWidget> #include <QWidget>
namespace ads namespace ads
{ {
struct FloatingDockContainerPrivate; struct FloatingDockContainerPrivate;
class CDockAreaWidget; class CDockAreaWidget;
class CDockContainerWidget; class CDockContainerWidget;
class CDockWidget; class CDockWidget;
class CDockManager; class CDockManager;
/** /**
* This implements a floating widget that is a dock container that accepts * This implements a floating widget that is a dock container that accepts
* docking of dock widgets like the main window and that can be docked into * docking of dock widgets like the main window and that can be docked into
* another dock container * another dock container
*/ */
class CFloatingDockContainer : public QWidget class CFloatingDockContainer : public QWidget
{ {
Q_OBJECT Q_OBJECT
private: private:
FloatingDockContainerPrivate* d; ///< private data (pimpl) FloatingDockContainerPrivate* d; ///< private data (pimpl)
friend class FloatingDockContainerPrivate; friend class FloatingDockContainerPrivate;
private slots: private slots:
void onDockAreasAddedOrRemoved(); void onDockAreasAddedOrRemoved();
void onDockAreaCurrentChanged(int Index); void onDockAreaCurrentChanged(int Index);
protected: protected:
/** /**
* Private constructor that is called from public constructors * Private constructor that is called from public constructors
*/ */
CFloatingDockContainer(CDockManager* DockManager); CFloatingDockContainer(CDockManager* DockManager);
protected: // reimplements QWidget protected: // reimplements QWidget
virtual void changeEvent(QEvent *event) override; virtual void changeEvent(QEvent *event) override;
virtual void moveEvent(QMoveEvent *event) override; virtual void moveEvent(QMoveEvent *event) override;
virtual bool event(QEvent *e) override; virtual bool event(QEvent *e) override;
virtual void closeEvent(QCloseEvent *event) override; virtual void closeEvent(QCloseEvent *event) override;
virtual bool eventFilter(QObject *watched, QEvent *event) override; virtual void hideEvent(QHideEvent *event) override;
virtual void showEvent(QShowEvent *event) override;
public: virtual bool eventFilter(QObject *watched, QEvent *event) override;
/**
* Create floating widget with the given dock area public:
*/ /**
CFloatingDockContainer(CDockAreaWidget* DockArea); * Create floating widget with the given dock area
*/
/** CFloatingDockContainer(CDockAreaWidget* DockArea);
* Create floating widget with the given dock widget
*/ /**
CFloatingDockContainer(CDockWidget* DockWidget); * Create floating widget with the given dock widget
*/
/** CFloatingDockContainer(CDockWidget* DockWidget);
* Virtual Destructor
*/ /**
virtual ~CFloatingDockContainer(); * Virtual Destructor
*/
/** virtual ~CFloatingDockContainer();
* Access function for the internal dock container
*/ /**
CDockContainerWidget* dockContainer() const; * Access function for the internal dock container
*/
/** CDockContainerWidget* dockContainer() const;
* Starts floating at the given global position.
* Use moveToGlobalPos() to move the widget to a new position /**
* depending on the start position given in Pos parameter * Starts floating at the given global position.
*/ * Use moveToGlobalPos() to move the widget to a new position
void startFloating(const QPoint& Pos, const QSize& Size = QSize()); * depending on the start position given in Pos parameter
*/
/** void startFloating(const QPoint& Pos, const QSize& Size = QSize());
* Moves the widget to a new position relative to the position given when
* startFloating() was called /**
*/ * Moves the widget to a new position relative to the position given when
void moveFloating(); * startFloating() was called
}; // class FloatingDockContainer */
} void moveFloating();
// namespace ads }; // class FloatingDockContainer
//----------------------------------------------------------------------------- }
#endif // FloatingDockContainerH // namespace ads
//-----------------------------------------------------------------------------
#endif // FloatingDockContainerH