2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Uwe Kindler
|
2023-01-04 08:19:47 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-2.1-or-later OR GPL-3.0-or-later
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "ads_globals.h"
|
|
|
|
|
|
|
|
|
|
#include <QFrame>
|
2021-03-02 13:35:07 +01:00
|
|
|
#include <QToolButton>
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
namespace ADS {
|
|
|
|
|
|
|
|
|
|
class DockWidget;
|
|
|
|
|
class DockAreaWidget;
|
2020-03-02 10:50:36 +01:00
|
|
|
class DockWidgetTabPrivate;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
2021-03-02 13:35:07 +01:00
|
|
|
using TabButtonType = QToolButton;
|
|
|
|
|
|
|
|
|
|
class TabButton : public TabButtonType
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
using Super = TabButtonType;
|
|
|
|
|
TabButton(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
void setActive(bool value);
|
|
|
|
|
void setFocus(bool value);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool m_active;
|
|
|
|
|
bool m_focus;
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-24 17:13:32 +01:00
|
|
|
/**
|
|
|
|
|
* A dock widget tab that shows a title and an icon.
|
2023-06-23 19:58:25 +02:00
|
|
|
* The dock widget tab is shown in the dock area title bar to switch between tabbed dock widgets.
|
2020-01-24 17:13:32 +01:00
|
|
|
*/
|
|
|
|
|
class ADS_EXPORT DockWidgetTab : public QFrame
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_PROPERTY(bool activeTab READ isActiveTab WRITE setActiveTab NOTIFY activeTabChanged)
|
2023-06-23 19:58:25 +02:00
|
|
|
Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
DockWidgetTabPrivate *d; ///< private data (pimpl)
|
2020-03-02 10:50:36 +01:00
|
|
|
friend class DockWidgetTabPrivate;
|
2020-01-24 17:13:32 +01:00
|
|
|
friend class DockWidget;
|
2020-06-22 16:46:25 +02:00
|
|
|
friend class DockManager;
|
2023-06-23 19:58:25 +02:00
|
|
|
friend class AutoHideDockContainer;
|
|
|
|
|
|
2020-01-24 17:13:32 +01:00
|
|
|
void onDockWidgetFeaturesChanged();
|
|
|
|
|
void detachDockWidget();
|
2023-06-23 19:58:25 +02:00
|
|
|
void autoHideDockWidget();
|
|
|
|
|
void onAutoHideToActionClicked();
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
protected:
|
2020-06-14 14:41:00 +02:00
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Double clicking the tab widget makes the assigned dock widget floating
|
|
|
|
|
*/
|
2020-06-14 14:41:00 +02:00
|
|
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
using Super = QFrame;
|
|
|
|
|
/**
|
|
|
|
|
* Default Constructor
|
|
|
|
|
* param[in] DockWidget The dock widget this title bar belongs to
|
|
|
|
|
* param[in] parent The parent widget of this title bar
|
|
|
|
|
*/
|
|
|
|
|
DockWidgetTab(DockWidget *DockWidget, QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Virtual Destructor
|
|
|
|
|
*/
|
2020-06-14 14:41:00 +02:00
|
|
|
~DockWidgetTab() override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true, if this is the active tab
|
|
|
|
|
*/
|
|
|
|
|
bool isActiveTab() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set this true to make this tab the active tab
|
|
|
|
|
*/
|
|
|
|
|
void setActiveTab(bool active);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the dock widget this title widget belongs to
|
|
|
|
|
*/
|
|
|
|
|
DockWidget *dockWidget() const;
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-23 19:58:25 +02:00
|
|
|
* Sets the dock area widget the dockWidget returned by dockWidget() function belongs to.
|
2020-01-24 17:13:32 +01:00
|
|
|
*/
|
|
|
|
|
void setDockAreaWidget(DockAreaWidget *dockArea);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the dock area widget this title bar belongs to.
|
|
|
|
|
* \return This function returns 0 if the dock widget that owns this title
|
|
|
|
|
* bar widget has not been added to any dock area yet.
|
|
|
|
|
*/
|
|
|
|
|
DockAreaWidget *dockAreaWidget() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the icon to show in title bar
|
|
|
|
|
*/
|
|
|
|
|
void setIcon(const QIcon &icon);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the icon
|
|
|
|
|
*/
|
|
|
|
|
const QIcon &icon() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the tab text
|
|
|
|
|
*/
|
|
|
|
|
QString text() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the tab text
|
|
|
|
|
*/
|
|
|
|
|
void setText(const QString &title);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if text is elided on the tab's title
|
|
|
|
|
*/
|
|
|
|
|
bool isTitleElided() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This function returns true if the assigned dock widget is closable
|
|
|
|
|
*/
|
|
|
|
|
bool isClosable() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Track event ToolTipChange and set child ToolTip
|
|
|
|
|
*/
|
2020-06-14 14:41:00 +02:00
|
|
|
bool event(QEvent *event) override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
2020-06-22 16:46:25 +02:00
|
|
|
/**
|
|
|
|
|
* Sets the text elide mode
|
|
|
|
|
*/
|
|
|
|
|
void setElideMode(Qt::TextElideMode mode);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update stylesheet style if a property changes
|
|
|
|
|
*/
|
|
|
|
|
void updateStyle();
|
|
|
|
|
|
2023-06-23 19:58:25 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the icon size.
|
|
|
|
|
* If no explicit icon size has been set, the function returns an invalid QSize.
|
|
|
|
|
*/
|
|
|
|
|
QSize iconSize() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set an explicit icon size.
|
|
|
|
|
* If no icon size has been set explicitly, than the tab sets the icon size depending
|
|
|
|
|
* on the style.
|
|
|
|
|
*/
|
|
|
|
|
void setIconSize(const QSize &size);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true, if the tab has been clicked and the mouse is currently pressed.
|
|
|
|
|
*/
|
|
|
|
|
bool mousePressed() const;
|
|
|
|
|
|
2020-06-14 14:41:00 +02:00
|
|
|
void setVisible(bool visible) override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void activeTabChanged();
|
|
|
|
|
void clicked();
|
|
|
|
|
void closeRequested();
|
|
|
|
|
void closeOtherTabsRequested();
|
|
|
|
|
void moved(const QPoint &globalPosition);
|
|
|
|
|
void elidedChanged(bool elided);
|
2023-06-23 19:58:25 +02:00
|
|
|
void iconSizeChanged();
|
2020-01-24 17:13:32 +01:00
|
|
|
}; // class DockWidgetTab
|
|
|
|
|
|
|
|
|
|
} // namespace ADS
|