expose thickness

This commit is contained in:
Marco Martin 2013-03-22 16:13:12 +01:00
parent a2c5a76eff
commit 5796ed1527
6 changed files with 45 additions and 22 deletions

View File

@ -57,6 +57,8 @@ PanelConfigView::PanelConfigView(Plasma::Containment *containment, PanelView *pa
engine()->rootContext()->setContextProperty("configDialog", this);
setSource(QUrl::fromLocalFile(panelView->corona()->package().filePath("panelconfigurationui")));
syncGeometry();
connect(containment, &Plasma::Containment::formFactorChanged,
this, &PanelConfigView::syncGeometry);
}
PanelConfigView::~PanelConfigView()
@ -73,18 +75,18 @@ void PanelConfigView::syncGeometry()
resize(128, screen()->size().height());
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) {
setPosition(screen()->size().width() - m_panelView->width(), 0);
setPosition(screen()->geometry().right() - 128 - m_panelView->thickness(), 0);
}
} else {
resize(screen()->size().width(), 128);
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) {
setPosition(0, screen()->size().width() - m_panelView->height());
setPosition(0, screen()->geometry().bottom() - 128 - m_panelView->thickness());
}
}
}

View File

@ -136,6 +136,27 @@ void PanelView::setOffset(int offset)
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()
{
connect(containment()->actions()->action("configure"), &QAction::triggered,
@ -157,6 +178,7 @@ void PanelView::positionPanel()
}
QScreen *s = screen();
const int oldThickness = thickness();
switch (containment()->location()) {
case Plasma::TopEdge:
@ -223,6 +245,9 @@ void PanelView::positionPanel()
setPosition(s->virtualGeometry().bottomLeft() - QPoint(0, height()) + QPoint(m_offset, 0));
}
}
if (thickness() != oldThickness) {
emit thicknessChanged();
}
}
void PanelView::restore()

View File

@ -30,6 +30,7 @@ class PanelView : public View
Q_OBJECT
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged)
public:
explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0);
@ -45,10 +46,14 @@ public:
int offset() const;
void setOffset(int offset);
int thickness() const;
void setThickness(int thickness);
Q_SIGNALS:
void alignmentChanged();
void offsetChanged();
void screenGeometryChanged();
void thicknessChanged();
private Q_SLOTS:
void manageNewContainment();

View File

@ -129,21 +129,12 @@ Rectangle {
newLocation = 5; //FIXME: Plasma::LeftEdge;
}
} else if(panel.location == 4) {
return;
return;
} else {
newLocation = 4; //FIXME: Plasma::BottomEdge;
}
}
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);
}
onReleased: panelResetAnimation.running = true
@ -166,19 +157,19 @@ Rectangle {
break;
//RightEdge
case 6:
return panel.screenGeometry.y + panel.screenGeometry.height - panel.height
return panel.screenGeometry.x + panel.screenGeometry.width - panel.width
break;
//BottomEdge
case 4:
default:
return panel.screenGeometry.x + panel.screenGeometry.width - panel.width
return panel.screenGeometry.y + panel.screenGeometry.height - panel.height
}
}
duration: 150
}
NumberAnimation {
target: configDialog
properties: "y"
properties: (panel.location == 5 || panel.location == 6) ? "x" : "y"
to: {
panel.height
switch (panel.location) {
@ -192,12 +183,12 @@ Rectangle {
break;
//RightEdge
case 6:
return panel.x - configDialog.width
return panel.screenGeometry.x + panel.screenGeometry.width - panel.width - configDialog.width
break;
//BottomEdge
case 4:
default:
return panel.y - configDialog.height
return panel.screenGeometry.y + panel.screenGeometry.height - panel.height - configDialog.height
}
}
duration: 150

View File

@ -127,7 +127,7 @@ Plasma::Containment *View::containment() const
//FIXME: wrong types
void View::setLocation(int location)
{
return m_containment.data()->setLocation((Plasma::Location)location);
m_containment.data()->setLocation((Plasma::Location)location);
}
//FIXME: wrong types
@ -139,7 +139,7 @@ int View::location() const
return m_containment.data()->location();
}
Plasma::FormFactor View::formFactor()
Plasma::FormFactor View::formFactor() const
{
if (!m_containment) {
return Plasma::Planar;

View File

@ -50,7 +50,7 @@ public:
int location() const;
void setLocation(int location);
Plasma::FormFactor formFactor();
Plasma::FormFactor formFactor() const;
QRectF screenGeometry();