mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-27 14:59:06 +08:00
Merge pull request #1 from XenotriX1337/deprecated_function
Replace deprecated function
This commit is contained in:
commit
cdca8c2ac0
@ -86,7 +86,7 @@ install(TARGETS qtadvanceddocking
|
|||||||
ARCHIVE DESTINATION lib COMPONENT library
|
ARCHIVE DESTINATION lib COMPONENT library
|
||||||
)
|
)
|
||||||
target_include_directories(qtadvanceddocking PUBLIC
|
target_include_directories(qtadvanceddocking PUBLIC
|
||||||
$<BUILD_INTERFACE:${ads_INCLUDE}>
|
"$<BUILD_INTERFACE:${ads_INCLUDE}>"
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
target_link_libraries(qtadvanceddocking PUBLIC ${ads_LIBS})
|
target_link_libraries(qtadvanceddocking PUBLIC ${ads_LIBS})
|
||||||
|
@ -9,7 +9,7 @@ Qt Advanced Docking System lets you create customizable layouts using a full
|
|||||||
featured window docking system similar to what is found in many popular
|
featured window docking system similar to what is found in many popular
|
||||||
integrated development environements (IDEs) such as Visual Studio.
|
integrated development environements (IDEs) such as Visual Studio.
|
||||||
Everything is implemented with standard Qt functionality without any
|
Everything is implemented with standard Qt functionality without any
|
||||||
platform specific code. Basic usage of QWidgets an QLayouts and using basic
|
platform specific code. Basic usage of QWidgets and QLayouts and using basic
|
||||||
styles as much as possible.
|
styles as much as possible.
|
||||||
|
|
||||||
This work is based on and inspired by the
|
This work is based on and inspired by the
|
||||||
|
@ -24,7 +24,6 @@ set(ads_demo_SRCS
|
|||||||
main.cpp
|
main.cpp
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
main.qrc
|
|
||||||
)
|
)
|
||||||
add_executable(AdvancedDockingSystemDemo WIN32 ${ads_demo_SRCS})
|
add_executable(AdvancedDockingSystemDemo WIN32 ${ads_demo_SRCS})
|
||||||
if(BUILD_STATIC)
|
if(BUILD_STATIC)
|
||||||
|
@ -21,7 +21,6 @@ HEADERS += \
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
RESOURCES += main.qrc
|
|
||||||
|
|
||||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/main"/>
|
|
||||||
</RCC>
|
|
@ -23,7 +23,6 @@ HEADERS += \
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
MainWindow.ui
|
MainWindow.ui
|
||||||
|
|
||||||
#RESOURCES += main.qrc
|
|
||||||
|
|
||||||
LIBS += -L$${ADS_OUT_ROOT}/lib
|
LIBS += -L$${ADS_OUT_ROOT}/lib
|
||||||
|
|
||||||
|
@ -44,6 +44,10 @@ class CFloatingDockContainer;
|
|||||||
* Custom tabbar implementation for tab area that is shown on top of a
|
* Custom tabbar implementation for tab area that is shown on top of a
|
||||||
* dock area widget.
|
* dock area widget.
|
||||||
* The tabbar displays the tab widgets of the contained dock widgets.
|
* The tabbar displays the tab widgets of the contained dock widgets.
|
||||||
|
* We cannot use QTabBar here because it does a lot of fancy animations
|
||||||
|
* that will crash the application if a tab is removed while the animation
|
||||||
|
* has not finished. And we need to remove a tab, if the user drags a
|
||||||
|
* a dock widget out of a group of tabbed widgets
|
||||||
*/
|
*/
|
||||||
class CDockAreaTabBar : public QScrollArea
|
class CDockAreaTabBar : public QScrollArea
|
||||||
{
|
{
|
||||||
@ -61,6 +65,7 @@ private slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void wheelEvent(QWheelEvent* Event) override;
|
virtual void wheelEvent(QWheelEvent* Event) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores mouse position to detect dragging
|
* Stores mouse position to detect dragging
|
||||||
*/
|
*/
|
||||||
@ -96,6 +101,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
using Super = QScrollArea;
|
using Super = QScrollArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -99,8 +99,9 @@ struct DockAreaTitleBarPrivate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to set title bar button icons depending on operating system
|
* Helper function to set title bar button icons depending on operating
|
||||||
* and to avoid duplicated code
|
* system and to avoid duplicated code. On windows the standard icons
|
||||||
|
* are blurry since Qt 5.11 so we need to do some additional steps
|
||||||
*/
|
*/
|
||||||
void setTitleBarButtonIcon(tTileBarButton* Button, QStyle::StandardPixmap StandarPixmap)
|
void setTitleBarButtonIcon(tTileBarButton* Button, QStyle::StandardPixmap StandarPixmap)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,9 @@ class CDockAreaWidget;
|
|||||||
struct DockAreaTitleBarPrivate;
|
struct DockAreaTitleBarPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title bar of a dock area
|
* Title bar of a dock area.
|
||||||
|
* The title bar contains a tabbar with all tabs for a dock widget group and
|
||||||
|
* with a tabs menu button, a undock button and a close button.
|
||||||
*/
|
*/
|
||||||
class CDockAreaTitleBar : public QFrame
|
class CDockAreaTitleBar : public QFrame
|
||||||
{
|
{
|
||||||
@ -61,6 +63,10 @@ private slots:
|
|||||||
void showContextMenu(const QPoint& pos);
|
void showContextMenu(const QPoint& pos);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
/**
|
||||||
|
* Call this slot to tell the title bar that it should update the tabs menu
|
||||||
|
* the next time it is shown.
|
||||||
|
*/
|
||||||
void markTabsMenuOutdated();
|
void markTabsMenuOutdated();
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +93,8 @@ public:
|
|||||||
QAbstractButton* button(TitleBarButton which) const;
|
QAbstractButton* button(TitleBarButton which) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is here for debug reasons
|
* Marks the tabs menu outdated before it calls its base class
|
||||||
|
* implementation
|
||||||
*/
|
*/
|
||||||
virtual void setVisible(bool Visible) override;
|
virtual void setVisible(bool Visible) override;
|
||||||
|
|
||||||
|
@ -63,8 +63,11 @@ static const char* const INDEX_PROPERTY = "index";
|
|||||||
static const char* const ACTION_PROPERTY = "action";
|
static const char* const ACTION_PROPERTY = "action";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New dock area layout mimics stack layout but only inserts the current
|
* Internal dock area layout mimics stack layout but only inserts the current
|
||||||
* widget into the internal QLayout object
|
* widget into the internal QLayout object.
|
||||||
|
* \warning Only the current widget has a parent. All other widgets
|
||||||
|
* do not have a parent. That means, a widget that is in this layout may
|
||||||
|
* return nullptr for its parent() function if it is not the current widget.
|
||||||
*/
|
*/
|
||||||
class CDockAreaLayout
|
class CDockAreaLayout
|
||||||
{
|
{
|
||||||
@ -118,7 +121,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given widget from the lyout
|
* Removes the given widget from the layout
|
||||||
*/
|
*/
|
||||||
void removeWidget(QWidget* Widget)
|
void removeWidget(QWidget* Widget)
|
||||||
{
|
{
|
||||||
|
@ -185,12 +185,12 @@ public:
|
|||||||
QList<CDockWidget*> dockWidgets() const;
|
QList<CDockWidget*> dockWidgets() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of dock widgets in this area
|
* Returns the number of open dock widgets in this area
|
||||||
*/
|
*/
|
||||||
int openDockWidgetsCount() const;
|
int openDockWidgetsCount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of dock widgets that are not closed
|
* Returns a list of dock widgets that are not closed.
|
||||||
*/
|
*/
|
||||||
QList<CDockWidget*> openedDockWidgets() const;
|
QList<CDockWidget*> openedDockWidgets() const;
|
||||||
|
|
||||||
@ -236,8 +236,10 @@ public:
|
|||||||
* This functions returns the dock widget features of all dock widget in
|
* This functions returns the dock widget features of all dock widget in
|
||||||
* this area.
|
* this area.
|
||||||
* A bitwise and is used to combine the flags of all dock widgets. That
|
* A bitwise and is used to combine the flags of all dock widgets. That
|
||||||
* means, if only dock widget does not support a certain flag, the whole
|
* means, if only one single dock widget does not support a certain flag,
|
||||||
* dock are does not support the flag.
|
* the whole dock are does not support the flag. I.e. if one single
|
||||||
|
* dock widget in this area is not closabe, the whole dock are is not
|
||||||
|
* closable.
|
||||||
*/
|
*/
|
||||||
CDockWidget::DockWidgetFeatures features() const;
|
CDockWidget::DockWidgetFeatures features() const;
|
||||||
|
|
||||||
|
@ -50,7 +50,10 @@ struct FloatingDockContainerPrivate;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
* Each window that support docking has a DockContainerWidget. That means
|
||||||
|
* the main application window and all floating windows are ore contain
|
||||||
|
* an DockContainerWidget.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CDockContainerWidget : public QFrame
|
class ADS_EXPORT CDockContainerWidget : public QFrame
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ public:
|
|||||||
* If the given parent is a QMainWindow, the dock manager sets itself as the
|
* If the given parent is a QMainWindow, the dock manager sets itself as the
|
||||||
* central widget.
|
* central widget.
|
||||||
* Before you create any dock widgets, you should properly setup the
|
* Before you create any dock widgets, you should properly setup the
|
||||||
* configuration flags via setConfigFlags()
|
* configuration flags via setConfigFlags().
|
||||||
*/
|
*/
|
||||||
CDockManager(QWidget* parent = 0);
|
CDockManager(QWidget* parent = 0);
|
||||||
|
|
||||||
|
@ -245,9 +245,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent* e) override;
|
virtual void showEvent(QShowEvent* e) override;
|
||||||
void setAreaWidgets(const QHash<DockWidgetArea, QWidget*>& widgets);
|
void setAreaWidgets(const QHash<DockWidgetArea, QWidget*>& widgets);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
}; // CDockOverlayCross
|
}; // CDockOverlayCross
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
@ -38,7 +38,8 @@ namespace ads
|
|||||||
struct DockSplitterPrivate;
|
struct DockSplitterPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splitter used internally instead of QSplitter
|
* Splitter used internally instead of QSplitter with some additional
|
||||||
|
* fuctionality.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CDockSplitter : public QSplitter
|
class ADS_EXPORT CDockSplitter : public QSplitter
|
||||||
{
|
{
|
||||||
|
@ -444,7 +444,7 @@ void CDockWidgetTab::setIcon(const QIcon& Icon)
|
|||||||
d->Icon = Icon;
|
d->Icon = Icon;
|
||||||
if (d->IconLabel)
|
if (d->IconLabel)
|
||||||
{
|
{
|
||||||
d->IconLabel->setPixmap(Icon.pixmap(this->windowHandle(), QSize(16, 16)));
|
d->IconLabel->setPixmap(Icon.pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this)));
|
||||||
d->IconLabel->setVisible(true);
|
d->IconLabel->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,6 @@ public:
|
|||||||
virtual bool event(QEvent *e) override;
|
virtual bool event(QEvent *e) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
virtual void setVisible(bool visible) override;
|
virtual void setVisible(bool visible) override;
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,9 +158,9 @@ QSize CElidingLabel::minimumSizeHint() const
|
|||||||
}
|
}
|
||||||
const QFontMetrics &fm = fontMetrics();
|
const QFontMetrics &fm = fontMetrics();
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
QSize size(fm.horizontalAdvance(d->Text), QLabel::sizeHint().height());
|
QSize size(fm.horizontalAdvance(d->Text.left(2) + "…"), fm.height());
|
||||||
#else
|
#else
|
||||||
QSize size(fm.width(d->Text), QLabel::sizeHint().height());
|
QSize size(fm.width(d->Text.left(2) + "…"), fm.height());
|
||||||
#endif
|
#endif
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/// \file FloatingDockContainer.cpp
|
/// \file FloatingDockContainer.cpp
|
||||||
/// \author Uwe Kindler
|
/// \author Uwe Kindler
|
||||||
@ -24,7 +23,6 @@
|
|||||||
/// \brief Implementation of CFloatingDockContainer class
|
/// \brief Implementation of CFloatingDockContainer class
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
// INCLUDES
|
// INCLUDES
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@ -50,7 +48,6 @@
|
|||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace ads
|
namespace ads
|
||||||
{
|
{
|
||||||
static unsigned int zOrderCounter = 0;
|
static unsigned int zOrderCounter = 0;
|
||||||
@ -104,17 +101,14 @@ struct FloatingDockContainerPrivate
|
|||||||
};
|
};
|
||||||
// struct FloatingDockContainerPrivate
|
// struct FloatingDockContainerPrivate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
FloatingDockContainerPrivate::FloatingDockContainerPrivate(CFloatingDockContainer* _public) :
|
FloatingDockContainerPrivate::FloatingDockContainerPrivate(
|
||||||
|
CFloatingDockContainer *_public) :
|
||||||
_this(_public)
|
_this(_public)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
||||||
{
|
{
|
||||||
@ -124,8 +118,10 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DockManager->dockAreaOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea
|
if (DockManager->dockAreaOverlay()->dropAreaUnderCursor()
|
||||||
|| DockManager->containerOverlay()->dropAreaUnderCursor() != InvalidDockWidgetArea)
|
!= InvalidDockWidgetArea
|
||||||
|
|| DockManager->containerOverlay()->dropAreaUnderCursor()
|
||||||
|
!= InvalidDockWidgetArea)
|
||||||
{
|
{
|
||||||
// Resize the floating widget to the size of the highlighted drop area
|
// Resize the floating widget to the size of the highlighted drop area
|
||||||
// rectangle
|
// rectangle
|
||||||
@ -136,13 +132,17 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRect Rect = Overlay->dropOverlayRect();
|
QRect Rect = Overlay->dropOverlayRect();
|
||||||
int FrameWidth = (_this->frameSize().width() - _this->rect().width()) / 2;
|
int FrameWidth = (_this->frameSize().width() - _this->rect().width())
|
||||||
int TitleBarHeight = _this->frameSize().height() - _this->rect().height() - FrameWidth;
|
/ 2;
|
||||||
|
int TitleBarHeight = _this->frameSize().height()
|
||||||
|
- _this->rect().height() - FrameWidth;
|
||||||
if (Rect.isValid())
|
if (Rect.isValid())
|
||||||
{
|
{
|
||||||
QPoint TopLeft = Overlay->mapToGlobal(Rect.topLeft());
|
QPoint TopLeft = Overlay->mapToGlobal(Rect.topLeft());
|
||||||
TopLeft.ry() += TitleBarHeight;
|
TopLeft.ry() += TitleBarHeight;
|
||||||
_this->setGeometry(QRect(TopLeft, QSize(Rect.width(), Rect.height() - TitleBarHeight)));
|
_this->setGeometry(
|
||||||
|
QRect(TopLeft,
|
||||||
|
QSize(Rect.width(), Rect.height() - TitleBarHeight)));
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
}
|
}
|
||||||
DropContainer->dropFloatingWidget(_this, QCursor::pos());
|
DropContainer->dropFloatingWidget(_this, QCursor::pos());
|
||||||
@ -152,8 +152,6 @@ void FloatingDockContainerPrivate::titleMouseReleaseEvent()
|
|||||||
DockManager->dockAreaOverlay()->hideOverlay();
|
DockManager->dockAreaOverlay()->hideOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
|
void FloatingDockContainerPrivate::updateDropOverlays(const QPoint &GlobalPos)
|
||||||
{
|
{
|
||||||
@ -198,23 +196,24 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
|
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
|
||||||
ContainerOverlay->setAllowedAreas(VisibleDockAreas > 1 ?
|
ContainerOverlay->setAllowedAreas(
|
||||||
OuterDockAreas : AllDockAreas);
|
VisibleDockAreas > 1 ? OuterDockAreas : AllDockAreas);
|
||||||
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
|
DockWidgetArea ContainerArea = ContainerOverlay->showOverlay(TopContainer);
|
||||||
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);
|
ContainerOverlay->enableDropPreview(ContainerArea != InvalidDockWidgetArea);
|
||||||
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
|
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
|
||||||
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0)
|
if (DockArea && DockArea->isVisible() && VisibleDockAreas > 0)
|
||||||
{
|
{
|
||||||
DockAreaOverlay->enableDropPreview(true);
|
DockAreaOverlay->enableDropPreview(true);
|
||||||
DockAreaOverlay->setAllowedAreas((VisibleDockAreas == 1) ?
|
DockAreaOverlay->setAllowedAreas(
|
||||||
NoDockWidgetArea : AllDockAreas);
|
(VisibleDockAreas == 1) ? NoDockWidgetArea : AllDockAreas);
|
||||||
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
|
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
|
||||||
|
|
||||||
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that
|
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that
|
||||||
// the mouse is in the title bar. If the ContainerArea is valid
|
// the mouse is in the title bar. If the ContainerArea is valid
|
||||||
// then we ignore the dock area of the dockAreaOverlay() and disable
|
// then we ignore the dock area of the dockAreaOverlay() and disable
|
||||||
// the drop preview
|
// the drop preview
|
||||||
if ((Area == CenterDockWidgetArea) && (ContainerArea != InvalidDockWidgetArea))
|
if ((Area == CenterDockWidgetArea)
|
||||||
|
&& (ContainerArea != InvalidDockWidgetArea))
|
||||||
{
|
{
|
||||||
DockAreaOverlay->enableDropPreview(false);
|
DockAreaOverlay->enableDropPreview(false);
|
||||||
ContainerOverlay->enableDropPreview(true);
|
ContainerOverlay->enableDropPreview(true);
|
||||||
@ -230,7 +229,6 @@ void FloatingDockContainerPrivate::updateDropOverlays(const QPoint& GlobalPos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
|
CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
|
||||||
tFloatingWidgetBase(DockManager),
|
tFloatingWidgetBase(DockManager),
|
||||||
@ -238,8 +236,10 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
|
|||||||
{
|
{
|
||||||
d->DockManager = DockManager;
|
d->DockManager = DockManager;
|
||||||
d->DockContainer = new CDockContainerWidget(DockManager, this);
|
d->DockContainer = new CDockContainerWidget(DockManager, this);
|
||||||
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this, SLOT(onDockAreasAddedOrRemoved()));
|
connect(d->DockContainer, SIGNAL(dockAreasAdded()), this,
|
||||||
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this, SLOT(onDockAreasAddedOrRemoved()));
|
SLOT(onDockAreasAddedOrRemoved()));
|
||||||
|
connect(d->DockContainer, SIGNAL(dockAreasRemoved()), this,
|
||||||
|
SLOT(onDockAreasAddedOrRemoved()));
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
d->TitleBar = new CFloatingWidgetTitleBar(this);
|
d->TitleBar = new CFloatingWidgetTitleBar(this);
|
||||||
@ -250,7 +250,8 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
|
|||||||
setTitleBarWidget(d->TitleBar);
|
setTitleBarWidget(d->TitleBar);
|
||||||
connect(d->TitleBar, SIGNAL(closeRequested()), SLOT(close()));
|
connect(d->TitleBar, SIGNAL(closeRequested()), SLOT(close()));
|
||||||
#else
|
#else
|
||||||
setWindowFlags(Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
|
setWindowFlags(
|
||||||
|
Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
|
||||||
QBoxLayout *l = new QBoxLayout(QBoxLayout::TopToBottom);
|
QBoxLayout *l = new QBoxLayout(QBoxLayout::TopToBottom);
|
||||||
l->setContentsMargins(0, 0, 0, 0);
|
l->setContentsMargins(0, 0, 0, 0);
|
||||||
l->setSpacing(0);
|
l->setSpacing(0);
|
||||||
@ -260,14 +261,12 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager* DockManager) :
|
|||||||
|
|
||||||
DockManager->registerFloatingWidget(this);
|
DockManager->registerFloatingWidget(this);
|
||||||
|
|
||||||
|
|
||||||
// We install an event filter to detect mouse release events because we
|
// We install an event filter to detect mouse release events because we
|
||||||
// do not receive mouse release event if the floating widget is behind
|
// do not receive mouse release event if the floating widget is behind
|
||||||
// the drop overlay cross
|
// the drop overlay cross
|
||||||
qApp->installEventFilter(this);
|
qApp->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget *DockArea) :
|
CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget *DockArea) :
|
||||||
CFloatingDockContainer(DockArea->dockManager())
|
CFloatingDockContainer(DockArea->dockManager())
|
||||||
@ -278,7 +277,6 @@ CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) :
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
|
CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
|
||||||
CFloatingDockContainer(DockWidget->dockManager())
|
CFloatingDockContainer(DockWidget->dockManager())
|
||||||
@ -300,14 +298,12 @@ CFloatingDockContainer::~CFloatingDockContainer()
|
|||||||
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)
|
||||||
{
|
{
|
||||||
@ -320,7 +316,6 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
||||||
{
|
{
|
||||||
@ -340,7 +335,6 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
@ -375,7 +369,6 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
@ -389,14 +382,12 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::showEvent(QShowEvent *event)
|
void CFloatingDockContainer::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
Super::showEvent(event);
|
Super::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::event(QEvent *e)
|
bool CFloatingDockContainer::event(QEvent *e)
|
||||||
{
|
{
|
||||||
@ -412,7 +403,8 @@ bool CFloatingDockContainer::event(QEvent *e)
|
|||||||
// It is really great to work around the whole NonClientMouseArea
|
// It is really great to work around the whole NonClientMouseArea
|
||||||
// bugs
|
// bugs
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 2))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 2))
|
||||||
if (e->type() == QEvent::NonClientAreaMouseButtonPress /*&& QGuiApplication::mouseButtons().testFlag(Qt::LeftButton)*/)
|
if (e->type()
|
||||||
|
== QEvent::NonClientAreaMouseButtonPress /*&& QGuiApplication::mouseButtons().testFlag(Qt::LeftButton)*/)
|
||||||
{
|
{
|
||||||
ADS_PRINT("FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type());
|
ADS_PRINT("FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type());
|
||||||
d->setState(DraggingMousePressed);
|
d->setState(DraggingMousePressed);
|
||||||
@ -473,12 +465,12 @@ bool CFloatingDockContainer::event(QEvent *e)
|
|||||||
return QWidget::event(e);
|
return QWidget::event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
|
bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(watched);
|
Q_UNUSED(watched);
|
||||||
if (event->type() == QEvent::MouseButtonRelease && d->isState(DraggingFloatingWidget))
|
if (event->type() == QEvent::MouseButtonRelease
|
||||||
|
&& d->isState(DraggingFloatingWidget))
|
||||||
{
|
{
|
||||||
ADS_PRINT("FloatingWidget::eventFilter QEvent::MouseButtonRelease");
|
ADS_PRINT("FloatingWidget::eventFilter QEvent::MouseButtonRelease");
|
||||||
finishDragging();
|
finishDragging();
|
||||||
@ -488,10 +480,9 @@ bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *event)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
|
||||||
eDragState DragState, QWidget* MouseEventHandler)
|
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_LINUX
|
#ifndef Q_OS_LINUX
|
||||||
Q_UNUSED(MouseEventHandler)
|
Q_UNUSED(MouseEventHandler)
|
||||||
@ -500,6 +491,13 @@ void CFloatingDockContainer::startFloating(const QPoint& DragStartMousePos, cons
|
|||||||
d->setState(DragState);
|
d->setState(DragState);
|
||||||
d->DragStartMousePosition = DragStartMousePos;
|
d->DragStartMousePosition = DragStartMousePos;
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
|
// I have not found a way on Linux to display the floating widget behind the
|
||||||
|
// dock overlay. That means if the user drags this floating widget around,
|
||||||
|
// it is always painted in front of the dock overlay and dock overlay cross.
|
||||||
|
// and the user will not see the dock overlay. To work around this issue,
|
||||||
|
// the window opacity is set to 0.6 to make the dock overlay visible
|
||||||
|
// again. If someone has an idea, how to place the dragged floating widget
|
||||||
|
// behind the dock overlay, then a pull request would be welcome.
|
||||||
if (DraggingFloatingWidget == DragState)
|
if (DraggingFloatingWidget == DragState)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
|
setAttribute(Qt::WA_X11NetWmWindowTypeDock, true);
|
||||||
@ -516,23 +514,22 @@ void CFloatingDockContainer::startFloating(const QPoint& DragStartMousePos, cons
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::moveFloating()
|
void CFloatingDockContainer::moveFloating()
|
||||||
{
|
{
|
||||||
int BorderSize = (frameSize().width() - size().width()) / 2;
|
int BorderSize = (frameSize().width() - size().width()) / 2;
|
||||||
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition - QPoint(BorderSize, 0);
|
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition
|
||||||
|
- QPoint(BorderSize, 0);
|
||||||
move(moveToPos);
|
move(moveToPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::isClosable() const
|
bool CFloatingDockContainer::isClosable() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->features().testFlag(CDockWidget::DockWidgetClosable);
|
return d->DockContainer->features().testFlag(
|
||||||
|
CDockWidget::DockWidgetClosable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
||||||
{
|
{
|
||||||
@ -541,7 +538,8 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
|||||||
if (TopLevelDockArea)
|
if (TopLevelDockArea)
|
||||||
{
|
{
|
||||||
d->SingleDockArea = TopLevelDockArea;
|
d->SingleDockArea = TopLevelDockArea;
|
||||||
d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
d->setWindowTitle(
|
||||||
|
d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||||
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
||||||
SLOT(onDockAreaCurrentChanged(int)));
|
SLOT(onDockAreaCurrentChanged(int)));
|
||||||
}
|
}
|
||||||
@ -557,7 +555,6 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::updateWindowTitle()
|
void CFloatingDockContainer::updateWindowTitle()
|
||||||
{
|
{
|
||||||
@ -572,7 +569,6 @@ void CFloatingDockContainer::updateWindowTitle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
||||||
{
|
{
|
||||||
@ -580,9 +576,9 @@ void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
|||||||
d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
d->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::restoreState(QXmlStreamReader& Stream, bool Testing)
|
bool CFloatingDockContainer::restoreState(QXmlStreamReader &Stream,
|
||||||
|
bool Testing)
|
||||||
{
|
{
|
||||||
if (!d->DockContainer->restoreState(Stream, Testing))
|
if (!d->DockContainer->restoreState(Stream, Testing))
|
||||||
{
|
{
|
||||||
@ -593,29 +589,24 @@ bool CFloatingDockContainer::restoreState(QXmlStreamReader& Stream, bool Testing
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
bool CFloatingDockContainer::hasTopLevelDockWidget() const
|
bool CFloatingDockContainer::hasTopLevelDockWidget() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->hasTopLevelDockWidget();
|
return d->DockContainer->hasTopLevelDockWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget* CFloatingDockContainer::topLevelDockWidget() const
|
CDockWidget* CFloatingDockContainer::topLevelDockWidget() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->topLevelDockWidget();
|
return d->DockContainer->topLevelDockWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
||||||
{
|
{
|
||||||
return d->DockContainer->dockWidgets();
|
return d->DockContainer->dockWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::finishDragging()
|
void CFloatingDockContainer::finishDragging()
|
||||||
{
|
{
|
||||||
@ -632,7 +623,6 @@ void CFloatingDockContainer::finishDragging()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -60,7 +60,8 @@ class CFloatingWidgetTitleBar;
|
|||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
* Every floating window of the docking system is a FloatingDockContainer.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT CFloatingDockContainer : public tFloatingWidgetBase
|
class ADS_EXPORT CFloatingDockContainer : public tFloatingWidgetBase
|
||||||
{
|
{
|
||||||
|
@ -45,12 +45,15 @@
|
|||||||
#define ADS_EXPORT
|
#define ADS_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Define ADS_DEBUG_PRINT to enable a lot of debug output
|
||||||
#ifdef ADS_DEBUG_PRINT
|
#ifdef ADS_DEBUG_PRINT
|
||||||
#define ADS_PRINT(s) qDebug() << s
|
#define ADS_PRINT(s) qDebug() << s
|
||||||
#else
|
#else
|
||||||
#define ADS_PRINT(s)
|
#define ADS_PRINT(s)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Set ADS_DEBUG_LEVEL to enable additional debug output and to enable layout
|
||||||
|
// dumps to qDebug and std::cout after layout changes
|
||||||
#define ADS_DEBUG_LEVEL 0
|
#define ADS_DEBUG_LEVEL 0
|
||||||
|
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
** License along with this library; If not, see <http://www.gnu.org/licenses/>.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
/// \file FloatingWidgetTitleBar.cpp
|
/// \file FloatingWidgetTitleBar.cpp
|
||||||
/// \author Uwe Kindler
|
/// \author Uwe Kindler
|
||||||
@ -48,7 +47,6 @@ namespace ads
|
|||||||
using tTabLabel = CElidingLabel;
|
using tTabLabel = CElidingLabel;
|
||||||
using tCloseButton = QPushButton;
|
using tCloseButton = QPushButton;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Private data class of public interface CFloatingWidgetTitleBar
|
* @brief Private data class of public interface CFloatingWidgetTitleBar
|
||||||
*/
|
*/
|
||||||
@ -61,7 +59,10 @@ struct FloatingWidgetTitleBarPrivate
|
|||||||
CFloatingDockContainer *FloatingWidget = nullptr;
|
CFloatingDockContainer *FloatingWidget = nullptr;
|
||||||
eDragState DragState = DraggingInactive;
|
eDragState DragState = DraggingInactive;
|
||||||
|
|
||||||
FloatingWidgetTitleBarPrivate(CFloatingWidgetTitleBar* _public) : _this(_public) {}
|
FloatingWidgetTitleBarPrivate(CFloatingWidgetTitleBar *_public) :
|
||||||
|
_this(_public)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the complete layout including all controls
|
* Creates the complete layout including all controls
|
||||||
@ -69,7 +70,6 @@ struct FloatingWidgetTitleBarPrivate
|
|||||||
void createLayout();
|
void createLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void FloatingWidgetTitleBarPrivate::createLayout()
|
void FloatingWidgetTitleBarPrivate::createLayout()
|
||||||
{
|
{
|
||||||
@ -82,13 +82,16 @@ void FloatingWidgetTitleBarPrivate::createLayout()
|
|||||||
CloseButton = new tCloseButton();
|
CloseButton = new tCloseButton();
|
||||||
CloseButton->setObjectName("floatingTitleCloseButton");
|
CloseButton->setObjectName("floatingTitleCloseButton");
|
||||||
CloseButton->setFlat(true);
|
CloseButton->setFlat(true);
|
||||||
//CloseButton->setAutoRaise(true);
|
|
||||||
// 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;
|
||||||
QPixmap normalPixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, CloseButton);
|
QPixmap normalPixmap = _this->style()->standardPixmap(
|
||||||
|
QStyle::SP_TitleBarCloseButton, 0, CloseButton);
|
||||||
CloseIcon.addPixmap(normalPixmap, QIcon::Normal);
|
CloseIcon.addPixmap(normalPixmap, QIcon::Normal);
|
||||||
CloseIcon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25), QIcon::Disabled);
|
CloseIcon.addPixmap(internal::createTransparentPixmap(normalPixmap, 0.25),
|
||||||
CloseButton->setIcon(_this->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
|
QIcon::Disabled);
|
||||||
|
CloseButton->setIcon(
|
||||||
|
_this->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
|
||||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
CloseButton->setVisible(true);
|
CloseButton->setVisible(true);
|
||||||
CloseButton->setFocusPolicy(Qt::NoFocus);
|
CloseButton->setFocusPolicy(Qt::NoFocus);
|
||||||
@ -110,37 +113,34 @@ void FloatingWidgetTitleBarPrivate::createLayout()
|
|||||||
TitleLabel->setVisible(true);
|
TitleLabel->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingWidgetTitleBar::CFloatingWidgetTitleBar(CFloatingDockContainer *parent)
|
CFloatingWidgetTitleBar::CFloatingWidgetTitleBar(CFloatingDockContainer *parent) :
|
||||||
: QWidget(parent),
|
QWidget(parent),
|
||||||
d(new FloatingWidgetTitleBarPrivate(this))
|
d(new FloatingWidgetTitleBarPrivate(this))
|
||||||
{
|
{
|
||||||
d->FloatingWidget = parent;
|
d->FloatingWidget = parent;
|
||||||
d->createLayout();
|
d->createLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CFloatingWidgetTitleBar::~CFloatingWidgetTitleBar()
|
CFloatingWidgetTitleBar::~CFloatingWidgetTitleBar()
|
||||||
{
|
{
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingWidgetTitleBar::mousePressEvent(QMouseEvent *ev)
|
void CFloatingWidgetTitleBar::mousePressEvent(QMouseEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
d->DragState = DraggingFloatingWidget;
|
d->DragState = DraggingFloatingWidget;
|
||||||
d->FloatingWidget->startDragging(ev->pos(), d->FloatingWidget->size(), this);
|
d->FloatingWidget->startDragging(ev->pos(), d->FloatingWidget->size(),
|
||||||
|
this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Super::mousePressEvent(ev);
|
Super::mousePressEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingWidgetTitleBar::mouseReleaseEvent(QMouseEvent *ev)
|
void CFloatingWidgetTitleBar::mouseReleaseEvent(QMouseEvent *ev)
|
||||||
{
|
{
|
||||||
@ -148,7 +148,6 @@ void CFloatingWidgetTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
Super::mouseReleaseEvent(ev);
|
Super::mouseReleaseEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingWidgetTitleBar::mouseMoveEvent(QMouseEvent *ev)
|
void CFloatingWidgetTitleBar::mouseMoveEvent(QMouseEvent *ev)
|
||||||
{
|
{
|
||||||
@ -169,19 +168,16 @@ void CFloatingWidgetTitleBar::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
Super::mouseMoveEvent(ev);
|
Super::mouseMoveEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingWidgetTitleBar::enableCloseButton(bool Enable)
|
void CFloatingWidgetTitleBar::enableCloseButton(bool Enable)
|
||||||
{
|
{
|
||||||
d->CloseButton->setEnabled(Enable);
|
d->CloseButton->setEnabled(Enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingWidgetTitleBar::setTitle(const QString &Text)
|
void CFloatingWidgetTitleBar::setTitle(const QString &Text)
|
||||||
{
|
{
|
||||||
d->TitleLabel->setText(Text);
|
d->TitleLabel->setText(Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
@ -37,6 +37,14 @@ class CFloatingDockContainer;
|
|||||||
|
|
||||||
struct FloatingWidgetTitleBarPrivate;
|
struct FloatingWidgetTitleBarPrivate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Titlebar for floating widgets to capture non client are mouse events.
|
||||||
|
* Linux does not support NonClieantArea mouse events like
|
||||||
|
* QEvent::NonClientAreaMouseButtonPress. Because these events are required
|
||||||
|
* for the docking system to work properly, we use our own titlebar here to
|
||||||
|
* capture the required mouse events.
|
||||||
|
*/
|
||||||
class CFloatingWidgetTitleBar : public QWidget
|
class CFloatingWidgetTitleBar : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -57,11 +65,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ~CFloatingWidgetTitleBar();
|
virtual ~CFloatingWidgetTitleBar();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables / disables the window close button.
|
||||||
|
*/
|
||||||
void enableCloseButton(bool Enable);
|
void enableCloseButton(bool Enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the window title, that means, the text of the internal tile label.
|
||||||
|
*/
|
||||||
void setTitle(const QString &Text);
|
void setTitle(const QString &Text);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
/**
|
||||||
|
* This signal is emitted, if the close button is clicked.
|
||||||
|
*/
|
||||||
void closeRequested();
|
void closeRequested();
|
||||||
};
|
};
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
Loading…
Reference in New Issue
Block a user