mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Added support for QToolButton tab close buttons
This commit is contained in:
parent
a05078c947
commit
dae677e479
@ -129,6 +129,7 @@ public:
|
|||||||
OpaqueSplitterResize = 0x08, //!< See QSplitter::setOpaqueResize() documentation
|
OpaqueSplitterResize = 0x08, //!< See QSplitter::setOpaqueResize() documentation
|
||||||
XmlAutoFormattingEnabled = 0x10,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace).
|
XmlAutoFormattingEnabled = 0x10,//!< If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between elements (ignorable whitespace).
|
||||||
XmlCompressionEnabled = 0x20,//!< If enabled, the XML output will be compressed and is not human readable anymore
|
XmlCompressionEnabled = 0x20,//!< If enabled, the XML output will be compressed and is not human readable anymore
|
||||||
|
TabCloseButtonIsToolButton = 0x40,//! If enabled the tab close buttons will be QToolButtons instead of QPushButtons - disabled by default
|
||||||
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize | XmlCompressionEnabled, ///< the default configuration
|
DefaultConfig = ActiveTabHasCloseButton | DockAreaHasCloseButton | OpaqueSplitterResize | XmlCompressionEnabled, ///< the default configuration
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
|
Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
|
||||||
|
@ -55,7 +55,6 @@ namespace ads
|
|||||||
{
|
{
|
||||||
|
|
||||||
using tTabLabel = CElidingLabel;
|
using tTabLabel = CElidingLabel;
|
||||||
using tCloseButton = QPushButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data class of CDockWidgetTab class (pimpl)
|
* Private data class of CDockWidgetTab class (pimpl)
|
||||||
@ -72,7 +71,7 @@ struct DockWidgetTabPrivate
|
|||||||
eDragState DragState = DraggingInactive;
|
eDragState DragState = DraggingInactive;
|
||||||
CFloatingDockContainer* FloatingWidget = nullptr;
|
CFloatingDockContainer* FloatingWidget = nullptr;
|
||||||
QIcon Icon;
|
QIcon Icon;
|
||||||
tCloseButton* CloseButton = nullptr;
|
QAbstractButton* CloseButton = nullptr;
|
||||||
QSpacerItem* IconTextSpacer;
|
QSpacerItem* IconTextSpacer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,6 +121,21 @@ struct DockWidgetTabPrivate
|
|||||||
{
|
{
|
||||||
return DockArea->dockManager()->configFlags().testFlag(Flag);
|
return DockArea->dockManager()->configFlags().testFlag(Flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the close button as QPushButton or as QToolButton
|
||||||
|
*/
|
||||||
|
QAbstractButton* createCloseButton() const
|
||||||
|
{
|
||||||
|
if (testConfigFlag(CDockManager::TabCloseButtonIsToolButton))
|
||||||
|
{
|
||||||
|
return new QToolButton();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new QPushButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// struct DockWidgetTabPrivate
|
// struct DockWidgetTabPrivate
|
||||||
|
|
||||||
@ -143,7 +157,7 @@ void DockWidgetTabPrivate::createLayout()
|
|||||||
TitleLabel->setObjectName("dockWidgetTabLabel");
|
TitleLabel->setObjectName("dockWidgetTabLabel");
|
||||||
TitleLabel->setAlignment(Qt::AlignCenter);
|
TitleLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
CloseButton = new tCloseButton();
|
CloseButton = createCloseButton();
|
||||||
CloseButton->setObjectName("tabCloseButton");
|
CloseButton->setObjectName("tabCloseButton");
|
||||||
// The standard icons do does not look good on high DPI screens
|
// The standard icons do does not look good on high DPI screens
|
||||||
QIcon CloseIcon;
|
QIcon CloseIcon;
|
||||||
@ -154,9 +168,9 @@ void DockWidgetTabPrivate::createLayout()
|
|||||||
|
|
||||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
CloseButton->setVisible(false);
|
CloseButton->setVisible(false);
|
||||||
#ifndef QT_NO_TOOLTIP
|
#ifndef QT_NO_TOOLTIP
|
||||||
CloseButton->setToolTip(QObject::tr("Close Tab"));
|
CloseButton->setToolTip(QObject::tr("Close Tab"));
|
||||||
#endif
|
#endif
|
||||||
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
|
_this->connect(CloseButton, SIGNAL(clicked()), SIGNAL(closeRequested()));
|
||||||
|
|
||||||
QFontMetrics fm(TitleLabel->font());
|
QFontMetrics fm(TitleLabel->font());
|
||||||
|
Loading…
Reference in New Issue
Block a user