support behaveAsPlasmaPanel in the dockview

pull/1/head
Michail Vourlakos 8 years ago
parent 9e969d22dc
commit 7d3458d45c

@ -296,7 +296,7 @@ QRegion DockCorona::availableScreenRegion(int id) const
// because the left and right are those who dodge others docks
switch (view->location()) {
case Plasma::Types::TopEdge:
if (view->drawShadows()) {
if (view->behaveAsPlasmaPanel()) {
available -= view->geometry();
} else {
QRect realGeometry;
@ -326,7 +326,7 @@ QRegion DockCorona::availableScreenRegion(int id) const
break;
case Plasma::Types::BottomEdge:
if (view->drawShadows()) {
if (view->behaveAsPlasmaPanel()) {
available -= view->geometry();
} else {
QRect realGeometry;

@ -163,7 +163,7 @@ void DockView::init()
if (formFactor() == Plasma::Types::Vertical)
syncGeometry();
});
connect(this, &DockView::drawShadowsChanged, this, &DockView::syncGeometry);
connect(this, &DockView::behaveAsPlasmaPanelChanged, this, &DockView::syncGeometry);
connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry);
connect(this, &DockView::offsetChanged, this, &DockView::syncGeometry);
connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders);
@ -492,7 +492,7 @@ void DockView::resizeWindow(QRect availableScreenRect)
//qDebug() << "MAXIMUM RECT :: " << maximumRect << " - AVAILABLE RECT :: " << availableRect;
QSize size{maxThickness(), availableScreenRect.height()};
if (m_drawShadows) {
if (m_behaveAsPlasmaPanel) {
size.setWidth(normalThickness());
size.setHeight(static_cast<int>(maxLength() * availableScreenRect.height()));
}
@ -504,7 +504,7 @@ void DockView::resizeWindow(QRect availableScreenRect)
QSize screenSize = this->screen()->size();
QSize size{screenSize.width(), maxThickness()};
if (m_drawShadows) {
if (m_behaveAsPlasmaPanel) {
size.setWidth(static_cast<int>(maxLength() * screenSize.width()));
size.setHeight(normalThickness());
}
@ -563,7 +563,7 @@ void DockView::updatePosition(QRect availableScreenRect)
case Plasma::Types::TopEdge:
screenGeometry = this->screen()->geometry();
if (m_drawShadows) {
if (m_behaveAsPlasmaPanel) {
position = {screenGeometry.x() + length(screenGeometry.width()), screenGeometry.y()};
} else {
position = {screenGeometry.x(), screenGeometry.y()};
@ -574,7 +574,7 @@ void DockView::updatePosition(QRect availableScreenRect)
case Plasma::Types::BottomEdge:
screenGeometry = this->screen()->geometry();
if (m_drawShadows) {
if (m_behaveAsPlasmaPanel) {
position = {screenGeometry.x() + length(screenGeometry.width()),
screenGeometry.y() + screenGeometry.height() - cleanThickness
};
@ -585,7 +585,7 @@ void DockView::updatePosition(QRect availableScreenRect)
break;
case Plasma::Types::RightEdge:
if (m_drawShadows && !mask().isNull()) {
if (m_behaveAsPlasmaPanel && !mask().isNull()) {
position = {availableScreenRect.right() - cleanThickness + 1,
availableScreenRect.y() + length(availableScreenRect.height())
};
@ -596,7 +596,7 @@ void DockView::updatePosition(QRect availableScreenRect)
break;
case Plasma::Types::LeftEdge:
if (m_drawShadows && !mask().isNull()) {
if (m_behaveAsPlasmaPanel && !mask().isNull()) {
position = {availableScreenRect.x(), availableScreenRect.y() + length(availableScreenRect.height())};
} else {
position = {availableScreenRect.x(), availableScreenRect.y()};
@ -659,7 +659,7 @@ inline void DockView::syncGeometry()
}
}
if (availableRegion.rectCount() > 1 && m_drawShadows)
if (availableRegion.rectCount() > 1 && m_behaveAsPlasmaPanel)
m_forceDrawCenteredBorders = true;
else
m_forceDrawCenteredBorders = false;
@ -767,20 +767,20 @@ void DockView::setDockWinBehavior(bool dock)
emit dockWinBehaviorChanged();
}
bool DockView::drawShadows() const
bool DockView::behaveAsPlasmaPanel() const
{
return m_drawShadows;
return m_behaveAsPlasmaPanel;
}
void DockView::setDrawShadows(bool draw)
void DockView::setBehaveAsPlasmaPanel(bool behavior)
{
if (m_drawShadows == draw) {
if (m_behaveAsPlasmaPanel == behavior) {
return;
}
m_drawShadows = draw;
m_behaveAsPlasmaPanel = behavior;
if (m_drawShadows) {
if (m_behaveAsPlasmaPanel) {
PanelShadows::self()->addWindow(this, enabledBorders());
} else {
PanelShadows::self()->removeWindow(this);
@ -789,6 +789,22 @@ void DockView::setDrawShadows(bool draw)
}
updateEffects();
emit behaveAsPlasmaPanelChanged();
}
bool DockView::drawShadows() const
{
return m_drawShadows;
}
void DockView::setDrawShadows(bool draw)
{
if (m_drawShadows == draw) {
return;
}
m_drawShadows = draw;
emit drawShadowsChanged();
}
@ -986,7 +1002,7 @@ void DockView::setShadow(int shadow)
m_shadow = shadow;
if (m_drawShadows) {
if (m_behaveAsPlasmaPanel) {
syncGeometry();
}
@ -995,7 +1011,7 @@ void DockView::setShadow(int shadow)
void DockView::updateEffects()
{
if (!m_drawShadows) {
if (!m_behaveAsPlasmaPanel) {
if (m_drawEffects && !m_effectsArea.isNull() && !m_effectsArea.isEmpty()) {
//! this is used when compositing is disabled and provides
//! the correct way for the mask to be painted in order for
@ -1028,7 +1044,7 @@ void DockView::updateEffects()
KWindowEffects::enableBlurBehind(winId(), false);
KWindowEffects::enableBackgroundContrast(winId(), false);
}
} else if (m_drawShadows && m_drawEffects) {
} else if (m_behaveAsPlasmaPanel && m_drawEffects) {
KWindowEffects::enableBlurBehind(winId(), true);
KWindowEffects::enableBackgroundContrast(winId(), m_theme.backgroundContrastEnabled(),
m_theme.backgroundContrast(),
@ -1555,7 +1571,6 @@ Plasma::FrameSvg::EnabledBorders DockView::enabledBorders() const
void DockView::updateEnabledBorders()
{
// qDebug() << "draw shadow!!!! :" << m_drawShadows;
if (!this->screen()) {
return;
}
@ -1618,7 +1633,7 @@ void DockView::updateEnabledBorders()
emit enabledBordersChanged();
}
if (!m_drawShadows) {
if (!m_behaveAsPlasmaPanel) {
PanelShadows::self()->removeWindow(this);
} else {
PanelShadows::self()->setEnabledBorders(this, borders);

@ -45,6 +45,7 @@ namespace Latte {
class DockView : public PlasmaQuick::ContainmentView {
Q_OBJECT
Q_PROPERTY(bool behaveAsPlasmaPanel READ behaveAsPlasmaPanel WRITE setBehaveAsPlasmaPanel NOTIFY behaveAsPlasmaPanelChanged)
Q_PROPERTY(bool dockWinBehavior READ dockWinBehavior WRITE setDockWinBehavior NOTIFY dockWinBehaviorChanged)
Q_PROPERTY(bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged)
Q_PROPERTY(bool drawEffects READ drawEffects WRITE setDrawEffects NOTIFY drawEffectsChanged)
@ -95,6 +96,9 @@ public:
int docksCount() const;
bool behaveAsPlasmaPanel() const;
void setBehaveAsPlasmaPanel(bool behavior);
bool dockWinBehavior() const;
void setDockWinBehavior(bool dock);
@ -179,6 +183,7 @@ signals:
void eventTriggered(QEvent *ev);
void alignmentChanged();
void behaveAsPlasmaPanelChanged();
void currentScreenChanged();
void dockLocationChanged();
void docksCountChanged();
@ -226,9 +231,10 @@ private:
private:
Plasma::Containment *containmentById(uint id);
bool m_behaveAsPlasmaPanel{false};
bool m_forceDrawCenteredBorders{false};
bool m_dockWinBehavior{false};
bool m_drawShadows{false};
bool m_drawShadows{true};
bool m_drawEffects{false};
bool m_onPrimary{true};
int m_maxThickness{24};

@ -77,11 +77,18 @@ Item{
Binding{
target: dock
property: "drawShadows"
property: "behaveAsPlasmaPanel"
when: dock
value: root.behaveAsPlasmaPanel
}
Binding{
target: dock
property: "drawShadows"
when: dock
value: root.drawShadowsExternal
}
Binding{
target: dock
property: "drawEffects"
@ -330,7 +337,7 @@ Item{
newMaskArea.height = tempLength;
}
if (dock.drawShadows) {
if (dock.behaveAsPlasmaPanel) {
dock.maskArea = Qt.rect(0,0,root.width,root.height);
} else {
dock.maskArea = newMaskArea;
@ -343,7 +350,7 @@ Item{
//the shadows size must be removed from the maskArea
//before updating the localDockGeometry
if (!dock.drawShadows) {
if (!dock.behaveAsPlasmaPanel) {
var fixedThickness = root.realPanelThickness;
if (plasmoid.formFactor === PlasmaCore.Types.Vertical) {

Loading…
Cancel
Save