Show previews for URLs in clipboard items

We create a Listview inside the delegate which shows previews of the
images. This is pretty rough right now, but able to show previews. Needs
more polishing, specifically:

- limit preview items (4?)
- nicer image painting, probably cropping
- proper height for delegates (through childrenRect)
- icons for non-image filetypes
wilder-5.14
Sebastian Kügler 12 years ago
parent 2b521bdbe9
commit 6e1b7cc727
  1. 79
      applets/clipboard/contents/ui/ClipboardItemDelegate.qml
  2. 2
      applets/clipboard/contents/ui/clipboard.qml

@ -56,17 +56,94 @@ PlasmaComponents.ListItem {
PlasmaComponents.Label {
height: implicitHeight
width: parent.width
maximumLineCount: 3
text: DisplayRole
visible: TypeRole != 1 // TypeRole: 0: Text, 1: Image, 2: Url
visible: TypeRole == 0 // TypeRole: 0: Text, 1: Image, 2: Url
textFormat: Text.PlainText
}
KQuickControlsAddons.QPixmapItem {
id: previewPixmap
width: parent.width
height: width * (nativeHeight/nativeWidth)
pixmap: DecorationRole
visible: TypeRole == 1
fillMode: KQuickControlsAddons.QPixmapItem.PreserveAspectFit
}
Item {
visible: TypeRole == 2
height: units.gridUnit * 4
width: parent.width
Component.onCompleted: {
if (TypeRole == 2) {
print("DisplayRole: " + DisplayRole);
print(" sliced: " + DisplayRole.slice(7, DisplayRole.length));
var urls = DisplayRole.slice(7, DisplayRole.length).split("file://");
print("Model data inside delegate: " + urls);
for (var k in urls) {
print("_____________ KEY: " + k + " " + urls[k]);
}
previewList.model = urls
}
}
GridView {
id: previewList
// model: DisplayRole.split(" ")
property int itemWidth: units.gridUnit * 4
//orientation: Qt.Horizontal
anchors.fill: parent
//columns: parent.width / itemWidth
cellWidth: itemWidth
cellHeight: itemHeight
delegate: KQuickControlsAddons.QPixmapItem {
id: previewPixmap
// width: parent.width
// height: width * (nativeHeight/nativeWidth)
//pixmap: DecorationRole
width: previewList.itemWidth
height: previewList.itemWidth
//visible: TypeRole == 1 || TypeRole == 2
fillMode: KQuickControlsAddons.QPixmapItem.PreserveAspectFit
Component.onCompleted: {
var service = clipboardSource.serviceForSource(UuidRole)
var operation = "preview";
function result(job) {
//print("result!..");
if (!job.error) {
print("Cool!");
print(" res: " + job.result["url"]);
pixmap = job.result["preview"];
} else {
print("Job failed");
}
//spixmap = job.result;
//print("ServiceJob error: " + job.error + " result: " + job.result + " op: " + job.operationName);
}
var operation = service.operationDescription(operation);
operation.urls = modelData;
//operation.password = password;
var serviceJob = service.startOperationCall(operation);
serviceJob.finished.connect(result);
print("JOb started: " + modelData);
}
Rectangle {
border.width: 2
border.color: "black"
color: "transparent"
anchors.fill: parent
}
}
}
}
}
RowLayout {

@ -65,7 +65,7 @@ Item {
Plasmoid.fullRepresentation: Item {
id: dialogItem
Layout.minimumWidth: units.iconSizes.medium * 9
Layout.minimumHeight: units.gridUnit * 13
Layout.minimumHeight: units.gridUnit * 26
focus: true

Loading…
Cancel
Save