expose thickness
This commit is contained in:
parent
a2c5a76eff
commit
5796ed1527
@ -57,6 +57,8 @@ PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *pa
|
|||||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||||
setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui")));
|
setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui")));
|
||||||
syncGeometry();
|
syncGeometry();
|
||||||
|
connect(containment, &Plasma::Containment::formFactorChanged,
|
||||||
|
this, &PanelConfigView::syncGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
PanelConfigView::~PanelConfigView()
|
PanelConfigView::~PanelConfigView()
|
||||||
@ -73,18 +75,18 @@ void PanelConfigView::syncGeometry()
|
|||||||
resize(128, screen()->size().height());
|
resize(128, screen()->size().height());
|
||||||
|
|
||||||
if (m_containment->location() == Plasma::LeftEdge) {
|
if (m_containment->location() == Plasma::LeftEdge) {
|
||||||
setPosition(m_panelView->width(), 0);
|
setPosition(screen()->geometry().left() + m_panelView->thickness(), 0);
|
||||||
} else if (m_containment->location() == Plasma::RightEdge) {
|
} else if (m_containment->location() == Plasma::RightEdge) {
|
||||||
setPosition(screen()->size().width() - m_panelView->width(), 0);
|
setPosition(screen()->geometry().right() - 128 - m_panelView->thickness(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
resize(screen()->size().width(), 128);
|
resize(screen()->size().width(), 128);
|
||||||
|
|
||||||
if (m_containment->location() == Plasma::TopEdge) {
|
if (m_containment->location() == Plasma::TopEdge) {
|
||||||
setPosition(0, m_panelView->height());
|
setPosition(0, screen()->geometry().top() + m_panelView->thickness());
|
||||||
} else if (m_containment->location() == Plasma::BottomEdge) {
|
} else if (m_containment->location() == Plasma::BottomEdge) {
|
||||||
setPosition(0, screen()->size().width() - m_panelView->height());
|
setPosition(0, screen()->geometry().bottom() - 128 - m_panelView->thickness());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,27 @@ void PanelView::setOffset(int offset)
|
|||||||
emit offsetChanged();
|
emit offsetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PanelView::thickness() const
|
||||||
|
{
|
||||||
|
return config().readEntry<int>("thickness", 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PanelView::setThickness(int value)
|
||||||
|
{
|
||||||
|
if (value == thickness()) {
|
||||||
|
value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formFactor() == Plasma::Vertical) {
|
||||||
|
return setWidth(value);
|
||||||
|
} else {
|
||||||
|
return setHeight(value);
|
||||||
|
}
|
||||||
|
config().writeEntry("thickness", value);
|
||||||
|
emit thicknessChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PanelView::manageNewContainment()
|
void PanelView::manageNewContainment()
|
||||||
{
|
{
|
||||||
connect(containment()->actions()->action("configure"), &QAction::triggered,
|
connect(containment()->actions()->action("configure"), &QAction::triggered,
|
||||||
@ -157,6 +178,7 @@ void PanelView::positionPanel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QScreen *s = screen();
|
QScreen *s = screen();
|
||||||
|
const int oldThickness = thickness();
|
||||||
|
|
||||||
switch (containment()->location()) {
|
switch (containment()->location()) {
|
||||||
case Plasma::TopEdge:
|
case Plasma::TopEdge:
|
||||||
@ -223,6 +245,9 @@ void PanelView::positionPanel()
|
|||||||
setPosition(s->virtualGeometry().bottomLeft() - QPoint(0, height()) + QPoint(m_offset, 0));
|
setPosition(s->virtualGeometry().bottomLeft() - QPoint(0, height()) + QPoint(m_offset, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (thickness() != oldThickness) {
|
||||||
|
emit thicknessChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelView::restore()
|
void PanelView::restore()
|
||||||
|
@ -30,6 +30,7 @@ class PanelView : public View
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
|
||||||
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
|
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
|
||||||
|
Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0);
|
explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0);
|
||||||
@ -45,10 +46,14 @@ public:
|
|||||||
int offset() const;
|
int offset() const;
|
||||||
void setOffset(int offset);
|
void setOffset(int offset);
|
||||||
|
|
||||||
|
int thickness() const;
|
||||||
|
void setThickness(int thickness);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void alignmentChanged();
|
void alignmentChanged();
|
||||||
void offsetChanged();
|
void offsetChanged();
|
||||||
void screenGeometryChanged();
|
void screenGeometryChanged();
|
||||||
|
void thicknessChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void manageNewContainment();
|
void manageNewContainment();
|
||||||
|
@ -129,21 +129,12 @@ Rectangle {
|
|||||||
newLocation = 5; //FIXME: Plasma::LeftEdge;
|
newLocation = 5; //FIXME: Plasma::LeftEdge;
|
||||||
}
|
}
|
||||||
} else if(panel.location == 4) {
|
} else if(panel.location == 4) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
newLocation = 4; //FIXME: Plasma::BottomEdge;
|
newLocation = 4; //FIXME: Plasma::BottomEdge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panel.location = newLocation
|
panel.location = newLocation
|
||||||
if (panel.location == 5 || panel.location == 6) {
|
|
||||||
configDialog.y = panel.screenGeometry.y
|
|
||||||
root.width = 100
|
|
||||||
root.height = panel.screenGeometry.height
|
|
||||||
} else {
|
|
||||||
configDialog.x = panel.screenGeometry.x
|
|
||||||
root.height = 100
|
|
||||||
root.width = panel.screenGeometry.width
|
|
||||||
}
|
|
||||||
print("New Location: " + newLocation);
|
print("New Location: " + newLocation);
|
||||||
}
|
}
|
||||||
onReleased: panelResetAnimation.running = true
|
onReleased: panelResetAnimation.running = true
|
||||||
@ -166,19 +157,19 @@ Rectangle {
|
|||||||
break;
|
break;
|
||||||
//RightEdge
|
//RightEdge
|
||||||
case 6:
|
case 6:
|
||||||
return panel.screenGeometry.y + panel.screenGeometry.height - panel.height
|
return panel.screenGeometry.x + panel.screenGeometry.width - panel.width
|
||||||
break;
|
break;
|
||||||
//BottomEdge
|
//BottomEdge
|
||||||
case 4:
|
case 4:
|
||||||
default:
|
default:
|
||||||
return panel.screenGeometry.x + panel.screenGeometry.width - panel.width
|
return panel.screenGeometry.y + panel.screenGeometry.height - panel.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
duration: 150
|
duration: 150
|
||||||
}
|
}
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
target: configDialog
|
target: configDialog
|
||||||
properties: "y"
|
properties: (panel.location == 5 || panel.location == 6) ? "x" : "y"
|
||||||
to: {
|
to: {
|
||||||
panel.height
|
panel.height
|
||||||
switch (panel.location) {
|
switch (panel.location) {
|
||||||
@ -192,12 +183,12 @@ Rectangle {
|
|||||||
break;
|
break;
|
||||||
//RightEdge
|
//RightEdge
|
||||||
case 6:
|
case 6:
|
||||||
return panel.x - configDialog.width
|
return panel.screenGeometry.x + panel.screenGeometry.width - panel.width - configDialog.width
|
||||||
break;
|
break;
|
||||||
//BottomEdge
|
//BottomEdge
|
||||||
case 4:
|
case 4:
|
||||||
default:
|
default:
|
||||||
return panel.y - configDialog.height
|
return panel.screenGeometry.y + panel.screenGeometry.height - panel.height - configDialog.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
duration: 150
|
duration: 150
|
||||||
|
@ -127,7 +127,7 @@ Plasma::Containment *View::containment() const
|
|||||||
//FIXME: wrong types
|
//FIXME: wrong types
|
||||||
void View::setLocation(int location)
|
void View::setLocation(int location)
|
||||||
{
|
{
|
||||||
return m_containment.data()->setLocation((Plasma::Location)location);
|
m_containment.data()->setLocation((Plasma::Location)location);
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: wrong types
|
//FIXME: wrong types
|
||||||
@ -139,7 +139,7 @@ int View::location() const
|
|||||||
return m_containment.data()->location();
|
return m_containment.data()->location();
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::FormFactor View::formFactor()
|
Plasma::FormFactor View::formFactor() const
|
||||||
{
|
{
|
||||||
if (!m_containment) {
|
if (!m_containment) {
|
||||||
return Plasma::Planar;
|
return Plasma::Planar;
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
int location() const;
|
int location() const;
|
||||||
void setLocation(int location);
|
void setLocation(int location);
|
||||||
|
|
||||||
Plasma::FormFactor formFactor();
|
Plasma::FormFactor formFactor() const;
|
||||||
|
|
||||||
QRectF screenGeometry();
|
QRectF screenGeometry();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user