reparent to flickable if possible

This commit is contained in:
Marco Martin 2015-09-02 11:43:27 +02:00
parent e688b3d483
commit b2bfd6cdf5
2 changed files with 10 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 by Marco MArtin <mart@kde.org> * Copyright (C) 2015 by Marco Martin <mart@kde.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as

View File

@ -36,9 +36,12 @@ Item {
z: 9999 z: 9999
Component.onCompleted: { Component.onCompleted: {
var par = control var par = control
while (par.parent) { //heuristic: if a flickable is found in the parents,
//reparent to it, so it scrolls together
while (par.parent && par.parent.contentY === undefined) {
par = par.parent par = par.parent
} }
popup.parent = par popup.parent = par
} }
@ -46,11 +49,9 @@ Item {
popup.x = pos.x; popup.x = pos.x;
popup.y = pos.y; popup.y = pos.y;
popup.visible = true; popup.visible = true;
popup.z = 9999
} }
function dismiss() { function dismiss() {
popup.visible = false; popup.visible = false;
input.z = 0
} }
Row { Row {
x: parent.margins.left x: parent.margins.left
@ -59,18 +60,18 @@ Item {
PlasmaComponents.ToolButton { PlasmaComponents.ToolButton {
iconSource: "edit-cut" iconSource: "edit-cut"
flat: false flat: false
enabled: input.selectedText != "" visible: input.selectedText != ""
onClicked: { onClicked: {
cut(); control.cut();
select(input.cursorPosition, input.cursorPosition); select(input.cursorPosition, input.cursorPosition);
} }
} }
PlasmaComponents.ToolButton { PlasmaComponents.ToolButton {
iconSource: "edit-copy" iconSource: "edit-copy"
enabled: input.selectedText != "" visible: input.selectedText != ""
flat: false flat: false
onClicked: { onClicked: {
copy(); control.copy();
select(input.cursorPosition, input.cursorPosition); select(input.cursorPosition, input.cursorPosition);
} }
} }
@ -79,7 +80,7 @@ Item {
enabled: input.canPaste enabled: input.canPaste
flat: false flat: false
onClicked: { onClicked: {
paste(); control.paste();
} }
} }
} }