mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 21:25:44 +08:00
Added support for focus styling of CFloatingWidgetTitleBra
This commit is contained in:
parent
ba94ef3493
commit
25eb02d07c
@ -57,6 +57,10 @@
|
||||
#include "DockingStateReader.h"
|
||||
#include "DockAreaTitleBar.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include "linux/FloatingWidgetTitleBar.h"
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the resources specified by the .qrc file with the specified base
|
||||
@ -96,6 +100,7 @@ struct DockManagerPrivate
|
||||
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
|
||||
QPointer<CDockWidget> FocusedDockWidget = nullptr;
|
||||
QPointer<CDockAreaWidget> FocusedArea = nullptr;
|
||||
QPointer<CFloatingDockContainer> FloatingWidget = nullptr;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@ -450,6 +455,19 @@ void updateDockAreaFocusStyle(CDockAreaWidget* DockArea, bool Focused)
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
void updateFloatingWidgetFocusStyle(CFloatingDockContainer* FloatingWidget, bool Focused)
|
||||
{
|
||||
auto TitleBar = qobject_cast<CFloatingWidgetTitleBar*>(FloatingWidget->titleBarWidget());
|
||||
if (!TitleBar)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TitleBar->setProperty("focused", Focused);
|
||||
TitleBar->updateStyle();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
|
||||
{
|
||||
@ -476,6 +494,24 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
|
||||
FocusedArea = NewFocusedDockArea;
|
||||
updateDockAreaFocusStyle(FocusedArea, true);
|
||||
QObject::connect(FocusedArea, SIGNAL(viewToggled(bool)), _this, SLOT(onFocusedDockAreaViewToggled(bool)));
|
||||
|
||||
// Linux specific focus stuff
|
||||
auto NewFloatingWidget = FocusedDockWidget->dockContainer()->floatingWidget();
|
||||
if (FloatingWidget == NewFloatingWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (FloatingWidget)
|
||||
{
|
||||
updateFloatingWidgetFocusStyle(FloatingWidget, false);
|
||||
}
|
||||
FloatingWidget = NewFloatingWidget;
|
||||
|
||||
if (FloatingWidget)
|
||||
{
|
||||
updateFloatingWidgetFocusStyle(FloatingWidget, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -954,7 +990,7 @@ void CDockManager::onFocusChanged(QWidget* focusedOld, QWidget* focusedNow)
|
||||
DockWidget = internal::findParent<CDockWidget*>(focusedNow);
|
||||
}
|
||||
|
||||
if (!DockWidget || !DockWidget->tabWidget()->isVisible())
|
||||
if (!DockWidget /*|| !DockWidget->tabWidget()->isVisible()*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -172,8 +172,7 @@ protected:
|
||||
/**
|
||||
* Call this function to update the window title
|
||||
*/
|
||||
void updateWindowTitle();
|
||||
|
||||
void updateWindowTitle();
|
||||
|
||||
protected: // reimplements QWidget
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
|
@ -115,7 +115,7 @@ void FloatingWidgetTitleBarPrivate::createLayout()
|
||||
|
||||
//============================================================================
|
||||
CFloatingWidgetTitleBar::CFloatingWidgetTitleBar(CFloatingDockContainer *parent) :
|
||||
QWidget(parent),
|
||||
QFrame(parent),
|
||||
d(new FloatingWidgetTitleBarPrivate(this))
|
||||
{
|
||||
d->FloatingWidget = parent;
|
||||
@ -172,16 +172,26 @@ void CFloatingWidgetTitleBar::mouseMoveEvent(QMouseEvent *ev)
|
||||
Super::mouseMoveEvent(ev);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::enableCloseButton(bool Enable)
|
||||
{
|
||||
d->CloseButton->setEnabled(Enable);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::setTitle(const QString &Text)
|
||||
{
|
||||
d->TitleLabel->setText(Text);
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CFloatingWidgetTitleBar::updateStyle()
|
||||
{
|
||||
internal::repolishStyle(this);
|
||||
internal::repolishStyle(d->TitleLabel);
|
||||
}
|
||||
|
||||
} // namespace ads
|
||||
|
@ -29,7 +29,7 @@
|
||||
//============================================================================
|
||||
// INCLUDES
|
||||
//============================================================================
|
||||
#include <QWidget>
|
||||
#include <QFrame>
|
||||
|
||||
namespace ads
|
||||
{
|
||||
@ -45,7 +45,7 @@ struct FloatingWidgetTitleBarPrivate;
|
||||
* 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 QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
@ -75,6 +75,11 @@ public:
|
||||
*/
|
||||
void setTitle(const QString &Text);
|
||||
|
||||
/**
|
||||
* Update stylesheet style if a property changes
|
||||
*/
|
||||
void updateStyle();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* This signal is emitted, if the close button is clicked.
|
||||
|
@ -97,7 +97,7 @@ ads--CDockSplitter::handle
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Focus related styling */
|
||||
ads--CDockWidgetTab[focused="true"]
|
||||
{
|
||||
background: palette(highlight);
|
||||
@ -123,8 +123,3 @@ ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar
|
||||
border-bottom: 2px solid palette(highlight);
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -93,4 +93,41 @@ QScrollArea#dockWidgetScrollArea
|
||||
background: rgba(0, 0, 0, 32);
|
||||
}
|
||||
|
||||
/* Focus related styling */
|
||||
ads--CDockWidgetTab[focused="true"]
|
||||
{
|
||||
background: palette(highlight);
|
||||
border-color: palette(highlight);
|
||||
}
|
||||
|
||||
ads--CDockWidgetTab[focused="true"] QLabel
|
||||
{
|
||||
color: palette(light);
|
||||
}
|
||||
|
||||
|
||||
ads--CDockAreaTitleBar
|
||||
{
|
||||
background: transparent;
|
||||
border-bottom: 2px solid palette(light);
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar
|
||||
{
|
||||
background: transparent;
|
||||
border-bottom: 2px solid palette(highlight);
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
|
||||
ads--CFloatingDockContainer[isActiveWindow="true"] ads--CFloatingWidgetTitleBar
|
||||
{
|
||||
background: palette(highlight);
|
||||
}
|
||||
|
||||
|
||||
ads--CFloatingDockContainer[isActiveWindow="true"] ads--CFloatingWidgetTitleBar > QLabel
|
||||
{
|
||||
color: palette(light);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user