crude controls for panel geometry
This commit is contained in:
parent
67c901db1a
commit
37cfe4a023
@ -47,9 +47,6 @@ PanelView::PanelView(Plasma::Corona *corona, QWindow *parent)
|
|||||||
//TODO: how to take the shape from the framesvg?
|
//TODO: how to take the shape from the framesvg?
|
||||||
KWindowEffects::enableBlurBehind(winId(), true);
|
KWindowEffects::enableBlurBehind(winId(), true);
|
||||||
|
|
||||||
connect(this, &View::containmentChanged,
|
|
||||||
this, &PanelView::manageNewContainment);
|
|
||||||
|
|
||||||
//Screen management
|
//Screen management
|
||||||
connect(screen(), &QScreen::virtualGeometryChanged,
|
connect(screen(), &QScreen::virtualGeometryChanged,
|
||||||
this, &PanelView::positionPanel);
|
this, &PanelView::positionPanel);
|
||||||
@ -156,20 +153,54 @@ void PanelView::setThickness(int value)
|
|||||||
emit thicknessChanged();
|
emit thicknessChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PanelView::maximumLength() const
|
||||||
void PanelView::manageNewContainment()
|
|
||||||
{
|
{
|
||||||
connect(containment()->actions()->action("configure"), &QAction::triggered,
|
return m_maxLength;
|
||||||
this, &PanelView::showPanelController);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelView::showPanelController()
|
void PanelView::setMaximumLength(int length)
|
||||||
{
|
{
|
||||||
if (!m_panelConfigView) {
|
if (length == m_maxLength) {
|
||||||
m_panelConfigView = new PanelConfigView(containment(), this);
|
return;
|
||||||
m_panelConfigView->init();
|
|
||||||
}
|
}
|
||||||
m_panelConfigView->show();
|
|
||||||
|
if (m_minLength > length) {
|
||||||
|
setMinimumLength(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formFactor() == Plasma::Vertical) {
|
||||||
|
setMaximumHeight(length);
|
||||||
|
} else {
|
||||||
|
setMaximumWidth(length);
|
||||||
|
}
|
||||||
|
config().writeEntry("maxLength", length);
|
||||||
|
m_maxLength = length;
|
||||||
|
emit maximumLengthChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
int PanelView::minimumLength() const
|
||||||
|
{
|
||||||
|
return m_minLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PanelView::setMinimumLength(int length)
|
||||||
|
{
|
||||||
|
if (length == m_minLength) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_maxLength < length) {
|
||||||
|
setMaximumLength(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formFactor() == Plasma::Vertical) {
|
||||||
|
setMinimumHeight(length);
|
||||||
|
} else {
|
||||||
|
setMinimumWidth(length);
|
||||||
|
}
|
||||||
|
config().writeEntry("minLength", length);
|
||||||
|
m_minLength = length;
|
||||||
|
emit minimumLengthChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelView::positionPanel()
|
void PanelView::positionPanel()
|
||||||
@ -286,8 +317,11 @@ void PanelView::restore()
|
|||||||
}
|
}
|
||||||
resize(config().readEntry<int>("length", screen()->size().width()),
|
resize(config().readEntry<int>("length", screen()->size().width()),
|
||||||
config().readEntry<int>("thickness", 32));
|
config().readEntry<int>("thickness", 32));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit maximumLengthChanged();
|
||||||
|
emit minimumLengthChanged();
|
||||||
|
emit offsetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_panelview.cpp"
|
#include "moc_panelview.cpp"
|
||||||
|
@ -31,6 +31,8 @@ class PanelView : public View
|
|||||||
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)
|
Q_PROPERTY(int thickness READ thickness WRITE setThickness NOTIFY thicknessChanged)
|
||||||
|
Q_PROPERTY(int maximumLength READ maximumLength WRITE setMaximumLength NOTIFY maximumLengthChanged)
|
||||||
|
Q_PROPERTY(int minimumLength READ minimumLength WRITE setMinimumLength NOTIFY minimumLengthChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0);
|
explicit PanelView(Plasma::Corona *corona, QWindow *parent = 0);
|
||||||
@ -49,15 +51,21 @@ public:
|
|||||||
int thickness() const;
|
int thickness() const;
|
||||||
void setThickness(int thickness);
|
void setThickness(int thickness);
|
||||||
|
|
||||||
|
int maximumLength() const;
|
||||||
|
void setMaximumLength(int length);
|
||||||
|
|
||||||
|
int minimumLength() const;
|
||||||
|
void setMinimumLength(int length);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void alignmentChanged();
|
void alignmentChanged();
|
||||||
void offsetChanged();
|
void offsetChanged();
|
||||||
void screenGeometryChanged();
|
void screenGeometryChanged();
|
||||||
void thicknessChanged();
|
void thicknessChanged();
|
||||||
|
void maximumLengthChanged();
|
||||||
|
void minimumLengthChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void manageNewContainment();
|
|
||||||
void showPanelController();
|
|
||||||
void positionPanel();
|
void positionPanel();
|
||||||
void restore();
|
void restore();
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ Rectangle {
|
|||||||
//END properties
|
//END properties
|
||||||
|
|
||||||
//BEGIN UI components
|
//BEGIN UI components
|
||||||
|
// Offset
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 32
|
width: 32
|
||||||
height: 32
|
height: 32
|
||||||
@ -52,20 +53,76 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (panel.location == 5 || panel.location == 6) {
|
if (panel.location == 5 || panel.location == 6) {
|
||||||
panel.offset = parent.y
|
parent.y = panel.offset
|
||||||
} else {
|
} else {
|
||||||
panel.offset = parent.x
|
parent.x = panel.offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Minimum length
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 100
|
width: 32
|
||||||
height: 32
|
height: 32
|
||||||
|
MouseArea {
|
||||||
|
drag {
|
||||||
|
target: parent
|
||||||
|
axis: (panel.location == 5 || panel.location == 6) ? Drag.YAxis : Drag.XAxis
|
||||||
|
}
|
||||||
|
anchors.fill: parent
|
||||||
|
onPositionChanged: {
|
||||||
|
if (panel.location == 5 || panel.location == 6) {
|
||||||
|
panel.minimumLength = parent.y
|
||||||
|
} else {
|
||||||
|
panel.minimumLength = parent.x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (panel.location == 5 || panel.location == 6) {
|
||||||
|
parent.y = panel.minimumLength
|
||||||
|
} else {
|
||||||
|
parent.x = panel.minimumLength
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Maximum length
|
||||||
|
Rectangle {
|
||||||
|
width: 32
|
||||||
|
height: 32
|
||||||
|
MouseArea {
|
||||||
|
drag {
|
||||||
|
target: parent
|
||||||
|
axis: (panel.location == 5 || panel.location == 6) ? Drag.YAxis : Drag.XAxis
|
||||||
|
}
|
||||||
|
anchors.fill: parent
|
||||||
|
onPositionChanged: {
|
||||||
|
if (panel.location == 5 || panel.location == 6) {
|
||||||
|
panel.maximumLength = parent.y
|
||||||
|
} else {
|
||||||
|
panel.maximumLength = parent.x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (panel.location == 5 || panel.location == 6) {
|
||||||
|
parent.y = panel.maximumLength
|
||||||
|
} else {
|
||||||
|
parent.x = panel.maximumLength
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
anchors {
|
anchors {
|
||||||
centerIn: parent
|
centerIn: parent
|
||||||
}
|
}
|
||||||
|
Rectangle {
|
||||||
|
width: 100
|
||||||
|
height: 32
|
||||||
|
|
||||||
QtExtras.MouseEventListener {
|
QtExtras.MouseEventListener {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property int lastX
|
property int lastX
|
||||||
@ -138,6 +195,47 @@ Rectangle {
|
|||||||
print("New Location: " + newLocation);
|
print("New Location: " + newLocation);
|
||||||
}
|
}
|
||||||
onReleased: panelResetAnimation.running = true
|
onReleased: panelResetAnimation.running = true
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
text: "Position"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
width: 100
|
||||||
|
height: 32
|
||||||
|
QtExtras.MouseEventListener {
|
||||||
|
anchors.fill: parent
|
||||||
|
property int startMouseX
|
||||||
|
property int startMouseY
|
||||||
|
onPressed: {
|
||||||
|
startMouseX = mouse.x
|
||||||
|
startMouseY = mouse.y
|
||||||
|
}
|
||||||
|
onPositionChanged: {
|
||||||
|
switch (panel.location) {
|
||||||
|
//TopEdge
|
||||||
|
case 3:
|
||||||
|
configDialog.y = mouse.screenY - mapToItem(root, 0, startMouseY).y
|
||||||
|
panel.thickness = configDialog.y - panel.y
|
||||||
|
//LeftEdge
|
||||||
|
case 5:
|
||||||
|
configDialog.x = mouse.screenX - mapToItem(root, startMouseX, 0).x
|
||||||
|
panel.thickness = configDialog.x - panel.x
|
||||||
|
//RightEdge
|
||||||
|
case 6:
|
||||||
|
configDialog.x = mouse.screenX - mapToItem(root, startMouseX, 0).x
|
||||||
|
panel.thickness = (panel.x + panel.width) - (configDialog.x + configDialog.width)
|
||||||
|
//BottomEdge
|
||||||
|
case 4:
|
||||||
|
default:
|
||||||
|
configDialog.y = mouse.screenY - mapToItem(root, 0, startMouseY).y
|
||||||
|
panel.thickness = (panel.y + panel.height) - (configDialog.y + configDialog.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
text: "Height"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ParallelAnimation {
|
ParallelAnimation {
|
||||||
|
Loading…
Reference in New Issue
Block a user