Added support for focus styling of CFloatingWidgetTitleBra

This commit is contained in:
Uwe Kindler 2020-05-19 22:53:52 +02:00
parent ba94ef3493
commit 819f1effc5
6 changed files with 94 additions and 12 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -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;
}

View File

@ -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);
}