Merge pull request #9268 from zfox23/PalRefresh

Add PAL refresh button
This commit is contained in:
Zach Fox 2016-12-23 15:16:51 -08:00 committed by GitHub
commit 72da05bb30
2 changed files with 48 additions and 4 deletions

View file

@ -47,7 +47,7 @@ Item {
id: myInfo
// Size
width: pal.width
height: myCardHeight
height: myCardHeight + 20
// Anchors
anchors.top: pal.top
// Properties
@ -217,6 +217,46 @@ Item {
}
}
}
// Refresh button
Rectangle {
// Size
width: hifi.dimensions.tableHeaderHeight-1
height: hifi.dimensions.tableHeaderHeight-1
// Anchors
anchors.left: table.left
anchors.leftMargin: 4
anchors.top: table.top
// Style
color: hifi.colors.tableBackgroundLight
// Actual refresh icon
HiFiGlyphs {
id: reloadButton
text: hifi.glyphs.reloadSmall
// Size
size: parent.width*1.5
// Anchors
anchors.fill: parent
// Style
horizontalAlignment: Text.AlignHCenter
color: hifi.colors.darkGray
}
MouseArea {
id: reloadButtonArea
// Anchors
anchors.fill: parent
hoverEnabled: true
// Everyone likes a responsive refresh button!
// So use onPressed instead of onClicked
onPressed: {
reloadButton.color = hifi.colors.lightGrayText
pal.sendToScript({method: 'refresh'})
}
onReleased: reloadButton.color = (containsMouse ? hifi.colors.baseGrayHighlight : hifi.colors.darkGray)
onEntered: reloadButton.color = hifi.colors.baseGrayHighlight
onExited: reloadButton.color = (pressed ? hifi.colors.lightGrayText: hifi.colors.darkGray)
}
}
// Separator between user and admin functions
Rectangle {
// Size

View file

@ -94,6 +94,10 @@ pal.fromQml.connect(function (message) { // messages are {method, params}, like
overlay.select(selected);
});
break;
case 'refresh':
removeOverlays();
populateUserList();
break;
default:
print('Unrecognized message from Pal.qml:', JSON.stringify(message));
}
@ -313,13 +317,13 @@ Script.setInterval(function () {
//
// Button state.
//
function onVisibileChanged() {
function onVisibleChanged() {
button.writeProperty('buttonState', pal.visible ? 0 : 1);
button.writeProperty('defaultState', pal.visible ? 0 : 1);
button.writeProperty('hoverState', pal.visible ? 2 : 3);
}
button.clicked.connect(onClicked);
pal.visibleChanged.connect(onVisibileChanged);
pal.visibleChanged.connect(onVisibleChanged);
pal.closed.connect(off);
Users.usernameFromIDReply.connect(usernameFromIDReply);
@ -329,7 +333,7 @@ Users.usernameFromIDReply.connect(usernameFromIDReply);
Script.scriptEnding.connect(function () {
button.clicked.disconnect(onClicked);
toolBar.removeButton(buttonName);
pal.visibleChanged.disconnect(onVisibileChanged);
pal.visibleChanged.disconnect(onVisibleChanged);
pal.closed.disconnect(off);
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
off();