mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:24:00 +02:00
some modal clean up
This commit is contained in:
parent
89f5e5112f
commit
835b23832f
9 changed files with 91 additions and 28 deletions
|
@ -101,9 +101,13 @@ TabletModalWindow {
|
|||
|
||||
TabletModalFrame {
|
||||
id: fileDialogItem
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
anchors.margins: 0
|
||||
width: parent.width - 6
|
||||
height: parent.height - 6
|
||||
|
||||
anchors {
|
||||
horizontalCenter: root.horizontalCenter
|
||||
verticalCenter: root.verticalCenter
|
||||
}
|
||||
|
||||
property bool keyboardEnabled: false
|
||||
property bool keyboardRaised: false
|
||||
|
@ -123,6 +127,7 @@ TabletModalWindow {
|
|||
top: parent.top
|
||||
topMargin: (fileDialogItem.hasTitle ? (fileDialogItem.frameMarginTop + hifi.dimensions.modalDialogMargin.y) : hifi.dimension.modalDialogMargin.y)
|
||||
left: parent.left
|
||||
leftMargin: hifi.dimensions.contentSpacing.x
|
||||
}
|
||||
spacing: hifi.dimensions.contentSpacing.x
|
||||
|
||||
|
@ -623,7 +628,8 @@ TabletModalWindow {
|
|||
anchors {
|
||||
left: parent.left
|
||||
right: selectionType.visible ? selectionType.left: parent.right
|
||||
rightMargin: selectionType.visible ? hifi.dimensions.contentSpacing.x : 0
|
||||
rightMargin: hifi.dimensions.contentSpacing.x
|
||||
leftMargin: hifi.dimensions.contentSpacing.x
|
||||
bottom: keyboard.top
|
||||
bottomMargin: hifi.dimensions.contentSpacing.y
|
||||
}
|
||||
|
|
|
@ -66,7 +66,8 @@ TabletModalWindow {
|
|||
id: messageBox
|
||||
clip: true
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width - 6
|
||||
height: 300
|
||||
|
||||
QtObject {
|
||||
|
@ -77,15 +78,11 @@ TabletModalWindow {
|
|||
readonly property int maxHeight: 720
|
||||
|
||||
function resize() {
|
||||
console.log("[DR]-> setting the target height");
|
||||
var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth)
|
||||
var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y
|
||||
+ (informativeTextContainer.text != "" ? informativeTextContainer.contentHeight + 3 * hifi.dimensions.contentSpacing.y : 0)
|
||||
+ buttons.height
|
||||
+ (details.implicitHeight + hifi.dimensions.contentSpacing.y) + messageBox.frameMarginTop
|
||||
//messageBox.width = (targetWidth < d.minWidth) ? d.minWidth : ((targetWidth > d.maxWidth) ? d.maxWidth : targetWidth)
|
||||
|
||||
console.log("[DR} -> about to set the height");
|
||||
messageBox.height = (targetHeight < d.minHeight) ? d.minHeight: ((targetHeight > d.maxHeight) ? d.maxHeight : targetHeight)
|
||||
}
|
||||
}
|
||||
|
@ -93,24 +90,28 @@ TabletModalWindow {
|
|||
RalewaySemiBold {
|
||||
id: mainTextContainer
|
||||
onTextChanged: d.resize();
|
||||
wrapMode: Text.WrapAnywhere
|
||||
wrapMode: Text.WordWrap
|
||||
size: hifi.fontSizes.sectionName
|
||||
color: hifi.colors.baseGrayHighlight
|
||||
width: parent.width - 6
|
||||
anchors {
|
||||
top: parent.top
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
margins: 0
|
||||
topMargin: hifi.dimensions.contentSpacing.y + messageBox.frameMarginTop
|
||||
}
|
||||
maximumLineCount: 30
|
||||
elide: Text.ElideLeft
|
||||
lineHeight: 2
|
||||
lineHeightMode: Text.ProportionalHeight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
RalewaySemiBold {
|
||||
id: informativeTextContainer
|
||||
onTextChanged: d.resize();
|
||||
wrapMode: Text.WrapAnywhere
|
||||
wrapMode: Text.WordWrap
|
||||
size: hifi.fontSizes.sectionName
|
||||
color: hifi.colors.baseGrayHighlight
|
||||
anchors {
|
||||
|
|
|
@ -63,9 +63,8 @@ TabletModalWindow {
|
|||
|
||||
TabletModalFrame {
|
||||
id: modalWindowItem
|
||||
width: parent.width
|
||||
width: parent.width - 12
|
||||
height: 240
|
||||
anchors.margins: 0
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
|
@ -73,13 +72,13 @@ TabletModalWindow {
|
|||
|
||||
QtObject {
|
||||
id: d
|
||||
readonly property int minWidth: 480
|
||||
readonly property int maxWdith: 480
|
||||
readonly property int minWidth: 470
|
||||
readonly property int maxWidth: 470
|
||||
readonly property int minHeight: 120
|
||||
readonly property int maxHeight: 720
|
||||
|
||||
function resize() {
|
||||
var targetWidth = Math.max(titleWidth, 480)
|
||||
var targetWidth = Math.max(titleWidth, 470)
|
||||
var targetHeight = (items ? comboBox.controlHeight : textResult.controlHeight) + 5 * hifi.dimensions.contentSpacing.y + buttons.height
|
||||
modalWindowItem.width = (targetWidth < d.minWidth) ? d.minWidth : ((targetWidth > d.maxWdith) ? d.maxWidth : targetWidth);
|
||||
modalWindowItem.height = ((targetHeight < d.minHeight) ? d.minHeight : ((targetHeight > d.maxHeight) ? d.maxHeight : targetHeight)) + ((keyboardEnabled && keyboardRaised) ? (keyboard.raisedHeight + 2 * hifi.dimensions.contentSpacing.y) : 0) + modalWindowItem.frameMarginTop
|
||||
|
@ -106,6 +105,7 @@ TabletModalWindow {
|
|||
left: parent.left;
|
||||
right: parent.right;
|
||||
bottom: parent.bottom
|
||||
leftMargin: 5
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,7 @@ TabletModalWindow {
|
|||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
rightMargin: 5
|
||||
}
|
||||
model: items ? items : []
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ Item {
|
|||
|
||||
property var rootMenu;
|
||||
property var openModal: null;
|
||||
property var openMessage: null;
|
||||
property string subMenu: ""
|
||||
signal showDesktop();
|
||||
|
||||
|
@ -24,7 +25,7 @@ Item {
|
|||
}
|
||||
Component { id: messageBoxBuilder; TabletMessageBox { } }
|
||||
function messageBox(properties) {
|
||||
openModal = messageBoxBuilder.createObject(tabletRoot, properties);
|
||||
openMessage = messageBoxBuilder.createObject(tabletRoot, properties);
|
||||
return openModal;
|
||||
}
|
||||
|
||||
|
@ -42,6 +43,14 @@ Item {
|
|||
tabletRoot.subMenu = subMenu;
|
||||
}
|
||||
|
||||
function isDialogOpen() {
|
||||
if (openMessage !== null || openModal !== null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadSource(url) {
|
||||
loader.source = ""; // make sure we load the qml fresh each time.
|
||||
loader.source = url;
|
||||
|
|
|
@ -39,6 +39,8 @@ Rectangle {
|
|||
visible: frameContent.hasTitle
|
||||
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
verticalCenter: parent.verticalCenter
|
||||
fill: parent
|
||||
topMargin: frameMarginTop
|
||||
leftMargin: frameMarginLeft
|
||||
|
@ -71,6 +73,7 @@ Rectangle {
|
|||
y: -hifi.dimensions.modalDialogTitleHeight
|
||||
anchors.rightMargin: -50
|
||||
anchors.right: parent.right
|
||||
//anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1617,9 +1617,13 @@ void Application::toggleTabletUI() const {
|
|||
return;
|
||||
}
|
||||
lastTabletUIToggle = now;
|
||||
|
||||
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
||||
HMD->toggleShouldShowTablet();
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
bool messageOpen = tablet->isMessageDialogOpen();
|
||||
if (!messageOpen) {
|
||||
auto HMD = DependencyManager::get<HMDScriptingInterface>();
|
||||
HMD->toggleShouldShowTablet();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::checkChangeCursor() {
|
||||
|
@ -5776,8 +5780,14 @@ void Application::toggleRunningScriptsWidget() const {
|
|||
static const QUrl url("hifi/dialogs/RunningScripts.qml");
|
||||
DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
|
||||
} else {
|
||||
static const QUrl url("../../hifi/dialogs/TabletRunningScripts.qml");
|
||||
tablet->pushOntoStack(url);
|
||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
||||
if (!tabletRoot && !isHMDMode()) {
|
||||
static const QUrl url("hifi/dialogs/RunningScripts.qml");
|
||||
DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
|
||||
} else {
|
||||
static const QUrl url("../../hifi/dialogs/TabletRunningScripts.qml");
|
||||
tablet->pushOntoStack(url);
|
||||
}
|
||||
}
|
||||
//DependencyManager::get<OffscreenUi>()->show(url, "RunningScripts");
|
||||
//if (_runningScriptsWidget->isVisible()) {
|
||||
|
|
|
@ -250,6 +250,18 @@ static QString getUsername() {
|
|||
}
|
||||
}
|
||||
|
||||
bool TabletProxy::isMessageDialogOpen() {
|
||||
if (_qmlTabletRoot) {
|
||||
QVariant result;
|
||||
QMetaObject::invokeMethod(_qmlTabletRoot, "isDialogOpen",Qt::DirectConnection,
|
||||
Q_RETURN_ARG(QVariant, result));
|
||||
|
||||
return result.toBool();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
|
||||
std::lock_guard<std::mutex> guard(_mutex);
|
||||
_qmlOffscreenSurface = qmlOffscreenSurface;
|
||||
|
|
|
@ -109,6 +109,12 @@ public:
|
|||
Q_INVOKABLE void pushOntoStack(const QVariant& path);
|
||||
Q_INVOKABLE void popFromStack();
|
||||
|
||||
/** jsdoc
|
||||
* Check if the tablet has a message dialog open
|
||||
* @function TabletProxy#isMessageDialogOpen
|
||||
*/
|
||||
Q_INVOKABLE bool isMessageDialogOpen();
|
||||
|
||||
/**jsdoc
|
||||
* Creates a new button, adds it to this and returns it.
|
||||
* @function TabletProxy#addButton
|
||||
|
@ -152,6 +158,10 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void sendToQml(QVariant msg);
|
||||
|
||||
/**jsdoc
|
||||
* Check if the tablet is on the homescreen
|
||||
* @function TabletProxy#onHomeScreen()
|
||||
*/
|
||||
Q_INVOKABLE bool onHomeScreen();
|
||||
|
||||
QQuickItem* getTabletRoot() const { return _qmlTabletRoot; }
|
||||
|
|
|
@ -169,10 +169,16 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var onHomeScreen = tablet.onHomeScreen();
|
||||
if (onHomeScreen) {
|
||||
HMD.closeTablet();
|
||||
var isMessageOpen = tablet.isMessageDialogOpen();
|
||||
if (isMessageOpen === false) {
|
||||
HMD.closeTablet();
|
||||
}
|
||||
} else {
|
||||
tablet.gotoHomeScreen();
|
||||
_this.setHomeButtonTexture();
|
||||
var isMessageOpen = tablet.isMessageDialogOpen();
|
||||
if (isMessageOpen === false) {
|
||||
tablet.gotoHomeScreen();
|
||||
_this.setHomeButtonTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -432,11 +438,16 @@ WebTablet.prototype.mousePressEvent = function (event) {
|
|||
if (overlayPickResults.intersects && overlayPickResults.overlayID === HMD.homeButtonID) {
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var onHomeScreen = tablet.onHomeScreen();
|
||||
var isMessageOpen = tablet.isMessageDialogOpen();
|
||||
if (onHomeScreen) {
|
||||
HMD.closeTablet();
|
||||
if (isMessageOpen === false) {
|
||||
HMD.closeTablet();
|
||||
}
|
||||
} else {
|
||||
tablet.gotoHomeScreen();
|
||||
this.setHomeButtonTexture();
|
||||
if (isMessageOpen === false) {
|
||||
tablet.gotoHomeScreen();
|
||||
this.setHomeButtonTexture();
|
||||
}
|
||||
}
|
||||
} else if (!HMD.active && (!overlayPickResults.intersects || !overlayPickResults.overlayID === this.webOverlayID)) {
|
||||
this.dragging = true;
|
||||
|
|
Loading…
Reference in a new issue