3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 12:55:27 +02:00

More progress on ComboDialog

This commit is contained in:
Zach Fox 2017-03-31 16:27:37 -07:00
parent 8a96969471
commit f148bca1c0
2 changed files with 46 additions and 24 deletions
interface/resources/qml/hifi

View file

@ -19,6 +19,7 @@ Item {
property var optionBodyText;
property var optionValues;
property var selectedOptionIndex;
property var callbackFunction;
property int dialogWidth;
property int dialogHeight;
property int comboOptionTextSize: 18;
@ -31,6 +32,14 @@ Item {
populateComboListViewModel();
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
combo.visible = false;
}
}
Rectangle {
id: dialogBackground;
anchors.fill: parent;
@ -69,6 +78,7 @@ Item {
anchors.bottom: parent.bottom;
anchors.left: parent.left;
anchors.right: parent.right;
clip: true;
model: comboListViewModel;
delegate: comboListViewDelegate;
@ -77,7 +87,7 @@ Item {
Rectangle {
id: comboListViewItemContainer;
// Size
height: childrenRect.height + 10;
height: optionTitle.height + optionBody.height + 20;
width: dialogContainer.width;
color: selectedOptionIndex === index ? '#cee6ff' : 'white';
Rectangle {
@ -100,9 +110,11 @@ Item {
id: optionTitle;
text: titleText;
anchors.top: parent.top;
anchors.topMargin: 7;
anchors.left: comboOptionSelected.right;
anchors.leftMargin: 20;
anchors.leftMargin: 10;
anchors.right: parent.right;
anchors.rightMargin: 10;
height: 30;
size: comboOptionTextSize;
wrapMode: Text.WordWrap;
@ -112,10 +124,10 @@ Item {
id: optionBody;
text: bodyText;
anchors.top: optionTitle.bottom;
anchors.bottom: parent.bottom;
anchors.left: comboOptionSelected.right;
anchors.leftMargin: 25;
anchors.right: parent.right;
anchors.rightMargin: 10;
size: comboOptionTextSize;
wrapMode: Text.WordWrap;
}
@ -127,9 +139,8 @@ Item {
onEntered: comboListViewItemContainer.color = hifi.colors.blueHighlight
onExited: comboListViewItemContainer.color = selectedOptionIndex === index ? '#cee6ff' : 'white';
onClicked: {
GlobalServices.findableBy = optionValue;
UserActivityLogger.palAction("set_availability", optionValue);
print('Setting availability:', optionValue);
callbackFunction(optionValue);
combo.visible = false;
}
}
}
@ -137,14 +148,6 @@ Item {
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
combo.visible = false;
}
}
function populateComboListViewModel() {
comboListViewModel.clear();
optionTitleText.forEach(function(titleText, index) {

View file

@ -56,7 +56,7 @@ Rectangle {
ComboDialog {
id: comboDialog;
z: 999; // Force the ComboDialog on top of everything else
dialogWidth: parent.width - 100;
dialogWidth: parent.width - 50;
dialogHeight: parent.height - 100;
}
function letterbox(headerGlyph, headerText, message) {
@ -66,7 +66,13 @@ Rectangle {
letterboxMessage.visible = true;
letterboxMessage.popupRadius = 0;
}
function popupComboDialogCallback(availability) {
GlobalServices.findableBy = availability;
UserActivityLogger.palAction("set_availability", availability);
print('Setting availability:', JSON.stringify(GlobalServices.findableBy));
}
function popupComboDialog(dialogTitleText, optionTitleText, optionBodyText, optionValues) {
comboDialog.callbackFunction = popupComboDialogCallback;
comboDialog.dialogTitleText = dialogTitleText;
comboDialog.optionTitleText = optionTitleText;
comboDialog.optionBodyText = optionBodyText;
@ -961,29 +967,42 @@ Rectangle {
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignTop;
}
/*Rectangle {
Rectangle {
property var availabilityStrings: ["Everyone", "Friends and Connections", "Friends Only", "Appear Offline"];
id: availabilityComboBox;
color: hifi.colors.textFieldLightBackground
// Anchors
anchors.top: parent.top;
anchors.horizontalCenter: parent.horizontalCenter;
// Size
width: parent.width;
height: 40;
RalewayRegular {
text: myData.userName === "Unknown user" ? "Login to Set" : availabilityStrings[GlobalServices.findableBy];
anchors.fill: parent;
anchors.leftMargin: 10;
horizontalAlignment: Text.AlignLeft;
size: 16;
}
MouseArea {
anchors.fill: parent
anchors.fill: parent;
enabled: myData.userName ==! "Unknown user";
hoverEnabled: true;
onClicked: {
popupComboDialog("Set your list visibility",
["Everyone", "Friends and Connections", "Friends Only", "Appear Offline"],
["You will be invisible in everyone's 'People' list.\nAnyone will be able to jump to your location if the domain allows.",
popupComboDialog("Set your availability:",
availabilityComboBox.availabilityStrings,
["Your username will be visible in everyone's 'Nearby' list.\nAnyone will be able to jump to your location from within the 'Nearby' list.",
"You will be visible in the 'People' list only for those with whom you are connected or friends.\nThey will be able to jump to your location if the domain allows.",
"You will be visible in the 'People' list only for those with whom you are friends.\nThey will be able to jump to your location if the domain allows.",
"You will not be visible in the 'People' list of any other users."],
"You will not be visible in the 'People' list of any other users. Only domain admins will be able to see your username in the 'Nearby' list."],
["all", "connections", "friends", "none"]);
}
onEntered: availabilityComboBox.color = hifi.colors.lightGrayText;
onExited: availabilityComboBox.color = hifi.colors.textFieldLightBackground;
}
}*/
}
HifiControlsUit.ComboBox {
/*HifiControlsUit.ComboBox {
function determineAvailabilityIndex() {
return ['all', 'connections', 'friends', 'none'].indexOf(GlobalServices.findableBy)
}
@ -1007,7 +1026,7 @@ Rectangle {
UserActivityLogger.palAction("set_availability", availabilityComboBoxListItems.get(currentIndex).value);
print('Setting availability:', JSON.stringify(GlobalServices.findableBy));
}
}
}*/
}
}