2022-10-13 14:26:54 +08:00
|
|
|
#ifndef AutoHideDockContainerH
|
|
|
|
#define AutoHideDockContainerH
|
2022-09-05 17:29:42 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
** Qt Advanced Docking System
|
|
|
|
** Copyright (C) 2017 Uwe Kindler
|
|
|
|
**
|
|
|
|
** This library is free software; you can redistribute it and/or
|
|
|
|
** modify it under the terms of the GNU Lesser General Public
|
|
|
|
** License as published by the Free Software Foundation; either
|
|
|
|
** version 2.1 of the License, or (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This library is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
** Lesser General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU Lesser General Public
|
|
|
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2024-10-05 04:23:40 +08:00
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
//============================================================================
|
2022-10-13 15:41:15 +08:00
|
|
|
/// \file AutoHideDockContainer.h
|
2022-09-05 17:29:42 +08:00
|
|
|
/// \author Syarif Fakhri
|
|
|
|
/// \date 05.09.2022
|
2022-10-13 14:26:54 +08:00
|
|
|
/// \brief Declaration of CAutoHideDockContainer class
|
2022-09-05 17:29:42 +08:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
2024-10-05 04:23:40 +08:00
|
|
|
#include "ads_globals.h"
|
2024-10-05 04:17:42 +08:00
|
|
|
|
2024-10-05 04:23:40 +08:00
|
|
|
#include <QSplitter>
|
2022-11-01 19:06:59 +08:00
|
|
|
#include "AutoHideTab.h"
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2024-02-28 00:34:42 +08:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter)
|
2022-09-05 17:29:42 +08:00
|
|
|
|
|
|
|
namespace ads
|
|
|
|
{
|
2022-10-12 17:17:54 +08:00
|
|
|
struct AutoHideDockContainerPrivate;
|
2022-09-05 17:29:42 +08:00
|
|
|
class CDockManager;
|
|
|
|
class CDockWidget;
|
|
|
|
class CDockContainerWidget;
|
2022-11-01 19:06:59 +08:00
|
|
|
class CAutoHideSideBar;
|
2022-09-05 17:29:42 +08:00
|
|
|
class CDockAreaWidget;
|
|
|
|
class CDockingStateReader;
|
2022-11-01 18:02:01 +08:00
|
|
|
struct SideTabBarPrivate;
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2022-10-25 22:05:08 +08:00
|
|
|
/**
|
|
|
|
* Auto hide container for hosting an auto hide dock widget
|
|
|
|
*/
|
2022-10-23 22:42:14 +08:00
|
|
|
class ADS_EXPORT CAutoHideDockContainer : public QFrame
|
2022-09-05 17:29:42 +08:00
|
|
|
{
|
2024-10-05 04:23:40 +08:00
|
|
|
Q_OBJECT
|
2022-11-01 20:34:08 +08:00
|
|
|
Q_PROPERTY(int sideBarLocation READ sideBarLocation)
|
2022-09-05 17:29:42 +08:00
|
|
|
private:
|
2024-10-05 04:23:40 +08:00
|
|
|
AutoHideDockContainerPrivate* d; ///< private data (pimpl)
|
|
|
|
friend struct AutoHideDockContainerPrivate;
|
|
|
|
friend CAutoHideSideBar;
|
|
|
|
friend SideTabBarPrivate;
|
2022-09-05 17:29:42 +08:00
|
|
|
|
|
|
|
protected:
|
2024-10-05 04:23:40 +08:00
|
|
|
virtual bool eventFilter(QObject* watched, QEvent* event) override;
|
|
|
|
virtual void resizeEvent(QResizeEvent* event) override;
|
|
|
|
virtual void leaveEvent(QEvent *event) override;
|
|
|
|
virtual bool event(QEvent* event) override;
|
2024-10-05 04:17:42 +08:00
|
|
|
virtual void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
2022-11-04 15:51:17 +08:00
|
|
|
|
2024-10-05 04:23:40 +08:00
|
|
|
/**
|
|
|
|
* Updates the size considering the size limits and the resize margins
|
|
|
|
*/
|
|
|
|
void updateSize();
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2024-10-05 04:23:40 +08:00
|
|
|
/*
|
|
|
|
* Saves the state and size
|
|
|
|
*/
|
|
|
|
void saveState(QXmlStreamWriter& Stream);
|
2022-09-08 11:30:56 +08:00
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
public:
|
2024-10-05 04:23:40 +08:00
|
|
|
using Super = QFrame;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create Auto Hide widget with the given dock widget
|
|
|
|
*/
|
|
|
|
CAutoHideDockContainer(CDockWidget* DockWidget, SideBarLocation area,
|
|
|
|
CDockContainerWidget* parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual Destructor
|
|
|
|
*/
|
|
|
|
virtual ~CAutoHideDockContainer();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the side tab bar
|
|
|
|
*/
|
|
|
|
CAutoHideSideBar* autoHideSideBar() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the side tab
|
|
|
|
*/
|
|
|
|
CAutoHideTab* autoHideTab() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the dock widget in this dock container
|
|
|
|
*/
|
|
|
|
CDockWidget* dockWidget() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the index of this container in the sidebar
|
|
|
|
*/
|
|
|
|
int tabIndex() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a dock widget and removes the previous dock widget
|
|
|
|
*/
|
|
|
|
void addDockWidget(CDockWidget* DockWidget);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the side tab bar area of this Auto Hide dock container
|
|
|
|
*/
|
|
|
|
SideBarLocation sideBarLocation() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a new SideBarLocation.
|
|
|
|
* If a new side bar location is set, the auto hide dock container needs
|
|
|
|
* to update its resize handle position
|
|
|
|
*/
|
|
|
|
void setSideBarLocation(SideBarLocation SideBarLocation);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the dock area widget of this Auto Hide dock container
|
|
|
|
*/
|
|
|
|
CDockAreaWidget* dockAreaWidget() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the parent container that hosts this auto hide container
|
|
|
|
*/
|
|
|
|
CDockContainerWidget* dockContainer() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves the contents to the parent container widget
|
|
|
|
* Used before removing this Auto Hide dock container
|
|
|
|
*/
|
2022-09-05 17:29:42 +08:00
|
|
|
void moveContentsToParent();
|
|
|
|
|
2024-10-05 04:23:40 +08:00
|
|
|
/**
|
|
|
|
* Cleanups up the side tab widget and then deletes itself
|
|
|
|
*/
|
|
|
|
void cleanupAndDelete();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Toggles the auto Hide dock container widget
|
|
|
|
* This will also hide the side tab widget
|
|
|
|
*/
|
|
|
|
void toggleView(bool Enable);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Collapses the auto hide dock container widget
|
|
|
|
* Does not hide the side tab widget
|
|
|
|
*/
|
|
|
|
void collapseView(bool Enable);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles the current collapse state
|
|
|
|
*/
|
|
|
|
void toggleCollapseState();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Use this instead of resize.
|
|
|
|
* Depending on the sidebar location this will set the width or height
|
|
|
|
* of this auto hide container.
|
|
|
|
*/
|
|
|
|
void setSize(int Size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the width or height to the initial dock widget size dependinng on
|
|
|
|
* the orientation.
|
|
|
|
* If the orientation is Qt::Horizontal, then the height is reset to
|
|
|
|
* the initial size and if orientation is Qt::Vertical, then the width is
|
|
|
|
* reset to the initial size
|
|
|
|
*/
|
|
|
|
void resetToInitialDockWidgetSize();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns orientation of this container.
|
|
|
|
* Left and right containers have a Qt::Vertical orientation and top / bottom
|
|
|
|
* containers have a Qt::Horizontal orientation.
|
|
|
|
* The function returns the orientation of the corresponding auto hide
|
|
|
|
* side bar.
|
|
|
|
*/
|
|
|
|
Qt::Orientation orientation() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the AutoHide container from the current side bar and adds
|
|
|
|
* it to the new side bar given in SideBarLocation
|
|
|
|
*/
|
|
|
|
void moveToNewSideBarLocation(SideBarLocation SideBarLocation, int TabIndex = -1);
|
2022-09-05 17:29:42 +08:00
|
|
|
};
|
2024-10-05 04:23:40 +08:00
|
|
|
} // namespace ads
|
2022-09-05 17:29:42 +08:00
|
|
|
|
2022-11-01 18:02:01 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
2022-09-05 17:29:42 +08:00
|
|
|
#endif
|