mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 17:55:29 +02:00
Merge pull request #7269 from ctrlaltdavid/20822
Restyle bookmark dialogs
This commit is contained in:
commit
efdef52081
9 changed files with 228 additions and 99 deletions
interface
resources/qml
controls-uit
dialogs
styles-uit
windows-uit
src
libraries/ui/src
tests/ui/qml
|
@ -160,6 +160,7 @@ FocusScope {
|
|||
ScrollView {
|
||||
id: scrollView
|
||||
height: 480
|
||||
width: root.width + 4
|
||||
|
||||
ListView {
|
||||
id: listView
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//
|
||||
// Desktop.qml
|
||||
// MessageDialog.qml
|
||||
//
|
||||
// Created by Bradley Austin Davis on 25 Apr 2015
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
// Created by Bradley Austin Davis on 15 Jan 2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -42,10 +42,11 @@ ModalWindow {
|
|||
property alias detailedText: detailedText.text
|
||||
property alias text: mainTextContainer.text
|
||||
property alias informativeText: informativeTextContainer.text
|
||||
onIconChanged: updateIcon();
|
||||
property int buttons: OriginalDialogs.StandardButton.Ok
|
||||
property int icon: OriginalDialogs.StandardIcon.NoIcon
|
||||
property string iconText: ""
|
||||
property int iconSize: 50
|
||||
onIconChanged: updateIcon();
|
||||
property int defaultButton: OriginalDialogs.StandardButton.NoButton;
|
||||
property int clickedButton: OriginalDialogs.StandardButton.NoButton;
|
||||
focus: defaultButton === OriginalDialogs.StandardButton.NoButton
|
||||
|
@ -54,22 +55,7 @@ ModalWindow {
|
|||
if (!root) {
|
||||
return;
|
||||
}
|
||||
switch (root.icon) {
|
||||
case OriginalDialogs.StandardIcon.Information:
|
||||
iconText = "\uF05A";
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Question:
|
||||
iconText = "\uF059"
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Warning:
|
||||
iconText = "\uF071"
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Critical:
|
||||
iconText = "\uF057"
|
||||
break;
|
||||
default:
|
||||
iconText = ""
|
||||
}
|
||||
iconText = hifi.glyphForIcon(root.icon);
|
||||
}
|
||||
|
||||
Item {
|
||||
|
@ -80,8 +66,6 @@ ModalWindow {
|
|||
|
||||
QtObject {
|
||||
id: d
|
||||
readonly property real spacing: hifi.dimensions.contentSpacing.x
|
||||
readonly property real outerSpacing: hifi.dimensions.contentSpacing.y
|
||||
readonly property int minWidth: 480
|
||||
readonly property int maxWdith: 1280
|
||||
readonly property int minHeight: 120
|
||||
|
@ -100,7 +84,7 @@ ModalWindow {
|
|||
|
||||
RalewaySemiBold {
|
||||
id: mainTextContainer
|
||||
onHeightChanged: d.resize(); onWidthChanged: d.resize();
|
||||
onTextChanged: d.resize();
|
||||
wrapMode: Text.WordWrap
|
||||
size: hifi.fontSizes.menuItem
|
||||
color: hifi.colors.baseGrayHighlight
|
||||
|
@ -116,7 +100,7 @@ ModalWindow {
|
|||
|
||||
RalewaySemiBold {
|
||||
id: informativeTextContainer
|
||||
onHeightChanged: d.resize(); onWidthChanged: d.resize();
|
||||
onTextChanged: d.resize();
|
||||
wrapMode: Text.WordWrap
|
||||
size: hifi.fontSizes.menuItem
|
||||
color: hifi.colors.baseGrayHighlight
|
||||
|
@ -132,7 +116,7 @@ ModalWindow {
|
|||
Flow {
|
||||
id: buttons
|
||||
focus: true
|
||||
spacing: d.spacing
|
||||
spacing: hifi.dimensions.contentSpacing.x
|
||||
onHeightChanged: d.resize(); onWidthChanged: d.resize();
|
||||
layoutDirection: Qt.RightToLeft
|
||||
anchors {
|
||||
|
@ -186,8 +170,8 @@ ModalWindow {
|
|||
id: flickable
|
||||
contentHeight: detailedText.height
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: root.spacing
|
||||
anchors.bottomMargin: root.outerSpacing
|
||||
anchors.topMargin: hifi.dimensions.contentSpacing.x
|
||||
anchors.bottomMargin: hifi.dimensions.contentSpacing.y
|
||||
TextEdit {
|
||||
id: detailedText
|
||||
size: hifi.fontSizes.menuItem
|
||||
|
@ -210,7 +194,10 @@ ModalWindow {
|
|||
}
|
||||
]
|
||||
|
||||
Component.onCompleted: updateIcon();
|
||||
Component.onCompleted: {
|
||||
updateIcon();
|
||||
d.resize();
|
||||
}
|
||||
onStateChanged: d.resize()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
//
|
||||
// QueryDialog.qml
|
||||
//
|
||||
// Created by Bradley Austin Davis on 22 Jan 2016
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Dialogs 1.2 as OriginalDialogs
|
||||
|
||||
import "../controls" as VrControls
|
||||
import "../styles"
|
||||
import "../windows"
|
||||
import "../controls-uit"
|
||||
import "../styles-uit"
|
||||
import "../windows-uit"
|
||||
|
||||
ModalWindow {
|
||||
id: root
|
||||
|
@ -16,8 +26,13 @@ ModalWindow {
|
|||
signal selected(var result);
|
||||
signal canceled();
|
||||
|
||||
property int icon: hifi.icons.none
|
||||
property string iconText: ""
|
||||
property int iconSize: 35
|
||||
onIconChanged: updateIcon();
|
||||
|
||||
property var items;
|
||||
property alias label: mainTextContainer.text
|
||||
property string label
|
||||
property var result;
|
||||
// FIXME not current honored
|
||||
property var current;
|
||||
|
@ -28,66 +43,85 @@ ModalWindow {
|
|||
// For combo boxes
|
||||
property bool editable: true;
|
||||
|
||||
Rectangle {
|
||||
function updateIcon() {
|
||||
if (!root) {
|
||||
return;
|
||||
}
|
||||
iconText = hifi.glyphForIcon(root.icon);
|
||||
}
|
||||
|
||||
Item {
|
||||
clip: true
|
||||
anchors.fill: parent
|
||||
radius: 4
|
||||
color: "white"
|
||||
width: pane.width
|
||||
height: pane.height
|
||||
anchors.margins: 0
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
readonly property real spacing: hifi.layout.spacing
|
||||
readonly property real outerSpacing: hifi.layout.spacing * 2
|
||||
readonly property int minWidth: 480
|
||||
readonly property int maxWdith: 1280
|
||||
readonly property int minHeight: 120
|
||||
readonly property int maxHeight: 720
|
||||
|
||||
function resize() {
|
||||
var targetWidth = mainTextContainer.width + d.spacing * 6
|
||||
var targetHeight = mainTextContainer.implicitHeight + textResult.height + d.spacing + buttons.height
|
||||
var targetWidth = pane.width
|
||||
var targetHeight = (items ? comboBox.controlHeight : textResult.controlHeight) + 5 * hifi.dimensions.contentSpacing.y + buttons.height
|
||||
root.width = (targetWidth < d.minWidth) ? d.minWidth : ((targetWidth > d.maxWdith) ? d.maxWidth : targetWidth)
|
||||
root.height = (targetHeight < d.minHeight) ? d.minHeight: ((targetHeight > d.maxHeight) ? d.maxHeight : targetHeight)
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: mainTextContainer
|
||||
onHeightChanged: d.resize(); onWidthChanged: d.resize();
|
||||
wrapMode: Text.WordWrap
|
||||
font { pointSize: 14; weight: Font.Bold }
|
||||
anchors { left: parent.left; top: parent.top; margins: d.spacing }
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors { top: mainTextContainer.bottom; bottom: buttons.top; left: parent.left; right: parent.right; margins: d.spacing }
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: buttons.top;
|
||||
left: parent.left;
|
||||
right: parent.right;
|
||||
margins: 0
|
||||
bottomMargin: 2 * hifi.dimensions.contentSpacing.y
|
||||
}
|
||||
|
||||
// FIXME make a text field type that can be bound to a history for autocompletion
|
||||
VrControls.TextField {
|
||||
TextField {
|
||||
id: textResult
|
||||
label: root.label
|
||||
focus: items ? false : true
|
||||
visible: items ? false : true
|
||||
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter }
|
||||
anchors {
|
||||
left: parent.left;
|
||||
right: parent.right;
|
||||
bottom: parent.bottom
|
||||
}
|
||||
}
|
||||
|
||||
VrControls.ComboBox {
|
||||
ComboBox {
|
||||
id: comboBox
|
||||
label: root.label
|
||||
focus: true
|
||||
visible: items ? true : false
|
||||
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter }
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
model: items ? items : []
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Flow {
|
||||
id: buttons
|
||||
focus: true
|
||||
spacing: d.spacing
|
||||
spacing: hifi.dimensions.contentSpacing.x
|
||||
onHeightChanged: d.resize(); onWidthChanged: d.resize();
|
||||
layoutDirection: Qt.RightToLeft
|
||||
anchors { bottom: parent.bottom; right: parent.right; margins: d.spacing; }
|
||||
Button { action: acceptAction }
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
right: parent.right
|
||||
margins: 0
|
||||
bottomMargin: hifi.dimensions.contentSpacing.y
|
||||
}
|
||||
Button { action: cancelAction }
|
||||
Button { action: acceptAction }
|
||||
}
|
||||
|
||||
Action {
|
||||
|
@ -130,4 +164,10 @@ ModalWindow {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
updateIcon();
|
||||
d.resize();
|
||||
textResult.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,35 @@ Item {
|
|||
readonly property alias dimensions: dimensions
|
||||
readonly property alias fontSizes: fontSizes
|
||||
readonly property alias glyphs: glyphs
|
||||
readonly property alias icons: icons
|
||||
readonly property alias buttons: buttons
|
||||
readonly property alias effects: effects
|
||||
|
||||
function glyphForIcon(icon) {
|
||||
// Translates icon enum to glyph char.
|
||||
var glyph;
|
||||
switch (icon) {
|
||||
case hifi.icons.information:
|
||||
glyph = hifi.glyphs.info;
|
||||
break;
|
||||
case hifi.icons.question:
|
||||
glyph = hifi.glyphs.question;
|
||||
break;
|
||||
case hifi.icons.warning:
|
||||
glyph = hifi.glyphs.alert;
|
||||
break;
|
||||
case hifi.icons.critical:
|
||||
glyph = hifi.glyphs.critical;
|
||||
break;
|
||||
case hifi.icons.placemark:
|
||||
glyph = hifi.glyphs.placemark;
|
||||
break;
|
||||
default:
|
||||
glyph = hifi.glyphs.noIcon;
|
||||
}
|
||||
return glyph;
|
||||
}
|
||||
|
||||
Item {
|
||||
id: colors
|
||||
|
||||
|
@ -134,6 +160,7 @@ Item {
|
|||
|
||||
Item {
|
||||
id: glyphs
|
||||
readonly property string alert: "+"
|
||||
readonly property string backward: "E"
|
||||
readonly property string caratDn: "5"
|
||||
readonly property string caratR: "3"
|
||||
|
@ -141,17 +168,33 @@ Item {
|
|||
readonly property string close: "w"
|
||||
readonly property string closeInverted: "x"
|
||||
readonly property string closeSmall: "C"
|
||||
readonly property string critical: "="
|
||||
readonly property string disclosureButtonCollapse: "M"
|
||||
readonly property string disclosureButtonExpand: "L"
|
||||
readonly property string disclosureCollapse: "Z"
|
||||
readonly property string disclosureExpand: "B"
|
||||
readonly property string forward: "D"
|
||||
readonly property string info: "["
|
||||
readonly property string noIcon: ""
|
||||
readonly property string pin: "y"
|
||||
readonly property string pinInverted: "z"
|
||||
readonly property string placemark: "U"
|
||||
readonly property string question: "]"
|
||||
readonly property string reloadSmall: "a"
|
||||
readonly property string resizeHandle: "A"
|
||||
}
|
||||
|
||||
Item {
|
||||
id: icons
|
||||
// Values per OffscreenUi::Icon
|
||||
readonly property int none: 0
|
||||
readonly property int question: 1
|
||||
readonly property int information: 2
|
||||
readonly property int warning: 3
|
||||
readonly property int critical: 4
|
||||
readonly property int placemark: 5
|
||||
}
|
||||
|
||||
Item {
|
||||
id: buttons
|
||||
readonly property int white: 0
|
||||
|
|
|
@ -47,16 +47,16 @@ Frame {
|
|||
}
|
||||
|
||||
Item {
|
||||
width: title.width + (window.iconText !== "" ? icon.width + hifi.dimensions.contentSpacing.x : 0)
|
||||
width: title.width + (icon.text !== "" ? icon.width + hifi.dimensions.contentSpacing.x : 0)
|
||||
x: (parent.width - width) / 2
|
||||
|
||||
FontAwesome {
|
||||
HiFiGlyphs {
|
||||
id: icon
|
||||
text: window.iconText
|
||||
size: 30
|
||||
color: hifi.colors.lightGrayText
|
||||
text: window.iconText ? window.iconText : ""
|
||||
size: window.iconSize ? window.iconSize : 30
|
||||
color: hifi.colors.lightGray
|
||||
visible: text != ""
|
||||
y: -hifi.dimensions.modalDialogTitleHeight - 5
|
||||
anchors.verticalCenter: title.verticalCenter
|
||||
anchors.left: parent.left
|
||||
}
|
||||
RalewayRegular {
|
||||
|
|
|
@ -107,7 +107,7 @@ void Bookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
|
|||
|
||||
void Bookmarks::bookmarkLocation() {
|
||||
bool ok = false;
|
||||
auto bookmarkName = OffscreenUi::getText(nullptr, "Bookmark Location", "Name:", QLineEdit::Normal, QString(), &ok);
|
||||
auto bookmarkName = OffscreenUi::getText(OffscreenUi::ICON_PLACEMARK, "Bookmark Location", "Name", QString(), &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void Bookmarks::bookmarkLocation() {
|
|||
Menu* menubar = Menu::getInstance();
|
||||
if (contains(bookmarkName)) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
auto duplicateBookmarkMessage = offscreenUi->createMessageBox(QMessageBox::Warning, "Duplicate Bookmark",
|
||||
auto duplicateBookmarkMessage = offscreenUi->createMessageBox(OffscreenUi::ICON_WARNING, "Duplicate Bookmark",
|
||||
"The bookmark name you entered already exists in your list.",
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
duplicateBookmarkMessage->setProperty("informativeText", "Would you like to overwrite it?");
|
||||
|
@ -156,7 +156,7 @@ void Bookmarks::deleteBookmark() {
|
|||
}
|
||||
|
||||
bool ok = false;
|
||||
auto bookmarkName = OffscreenUi::getItem(nullptr, "Delete Bookmark", "Select the bookmark to delete", bookmarkList, 0, false, &ok);
|
||||
auto bookmarkName = OffscreenUi::getItem(OffscreenUi::ICON_PLACEMARK, "Delete Bookmark", "Select the bookmark to delete", bookmarkList, 0, false, &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
QQuickItem* OffscreenUi::createMessageBox(QMessageBox::Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
QQuickItem* OffscreenUi::createMessageBox(Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
QVariantMap map;
|
||||
map.insert("title", title);
|
||||
map.insert("text", text);
|
||||
|
@ -232,12 +232,12 @@ int OffscreenUi::waitForMessageBoxResult(QQuickItem* messageBox) {
|
|||
}
|
||||
|
||||
|
||||
QMessageBox::StandardButton OffscreenUi::messageBox(QMessageBox::Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
QMessageBox::StandardButton OffscreenUi::messageBox(Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMessageBox::StandardButton result = QMessageBox::StandardButton::NoButton;
|
||||
QMetaObject::invokeMethod(this, "messageBox", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(QMessageBox::StandardButton, result),
|
||||
Q_ARG(QMessageBox::Icon, icon),
|
||||
Q_ARG(Icon, icon),
|
||||
Q_ARG(QString, title),
|
||||
Q_ARG(QString, text),
|
||||
Q_ARG(QMessageBox::StandardButtons, buttons),
|
||||
|
@ -250,19 +250,19 @@ QMessageBox::StandardButton OffscreenUi::messageBox(QMessageBox::Icon icon, cons
|
|||
|
||||
QMessageBox::StandardButton OffscreenUi::critical(const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(QMessageBox::Icon::Critical, title, text, buttons, defaultButton);
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(OffscreenUi::Icon::ICON_CRITICAL, title, text, buttons, defaultButton);
|
||||
}
|
||||
QMessageBox::StandardButton OffscreenUi::information(const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(QMessageBox::Icon::Information, title, text, buttons, defaultButton);
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(OffscreenUi::Icon::ICON_INFORMATION, title, text, buttons, defaultButton);
|
||||
}
|
||||
QMessageBox::StandardButton OffscreenUi::question(const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(QMessageBox::Icon::Question, title, text, buttons, defaultButton);
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(OffscreenUi::Icon::ICON_QUESTION, title, text, buttons, defaultButton);
|
||||
}
|
||||
QMessageBox::StandardButton OffscreenUi::warning(const QString& title, const QString& text,
|
||||
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) {
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(QMessageBox::Icon::Warning, title, text, buttons, defaultButton);
|
||||
return DependencyManager::get<OffscreenUi>()->messageBox(OffscreenUi::Icon::ICON_WARNING, title, text, buttons, defaultButton);
|
||||
}
|
||||
|
||||
|
||||
|
@ -286,24 +286,24 @@ private slots:
|
|||
}
|
||||
};
|
||||
|
||||
// FIXME many input parameters currently ignored
|
||||
QString OffscreenUi::getText(void* ignored, const QString & title, const QString & label, QLineEdit::EchoMode mode, const QString & text, bool * ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) {
|
||||
QString OffscreenUi::getText(const Icon icon, const QString& title, const QString& label, const QString& text, bool* ok) {
|
||||
if (ok) { *ok = false; }
|
||||
QVariant result = DependencyManager::get<OffscreenUi>()->inputDialog(title, label, text).toString();
|
||||
QVariant result = DependencyManager::get<OffscreenUi>()->inputDialog(icon, title, label, text).toString();
|
||||
if (ok && result.isValid()) {
|
||||
*ok = true;
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
// FIXME many input parameters currently ignored
|
||||
QString OffscreenUi::getItem(void *ignored, const QString & title, const QString & label, const QStringList & items, int current, bool editable, bool * ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) {
|
||||
QString OffscreenUi::getItem(const Icon icon, const QString& title, const QString& label, const QStringList& items,
|
||||
int current, bool editable, bool* ok) {
|
||||
|
||||
if (ok) {
|
||||
*ok = false;
|
||||
}
|
||||
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
auto inputDialog = offscreenUi->createInputDialog(title, label, current);
|
||||
auto inputDialog = offscreenUi->createInputDialog(icon, title, label, current);
|
||||
if (!inputDialog) {
|
||||
return QString();
|
||||
}
|
||||
|
@ -321,24 +321,28 @@ QString OffscreenUi::getItem(void *ignored, const QString & title, const QString
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
QVariant OffscreenUi::inputDialog(const QString& title, const QString& label, const QVariant& current) {
|
||||
QVariant OffscreenUi::inputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QVariant result;
|
||||
QMetaObject::invokeMethod(this, "inputDialog", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(QVariant, result),
|
||||
Q_ARG(QString, title),
|
||||
Q_ARG(Icon, icon),
|
||||
Q_ARG(QString, label),
|
||||
Q_ARG(QVariant, current));
|
||||
return result;
|
||||
}
|
||||
|
||||
return waitForInputDialogResult(createInputDialog(title, label, current));
|
||||
return waitForInputDialogResult(createInputDialog(icon, title, label, current));
|
||||
}
|
||||
|
||||
|
||||
QQuickItem* OffscreenUi::createInputDialog(const QString& title, const QString& label, const QVariant& current) {
|
||||
QQuickItem* OffscreenUi::createInputDialog(const Icon icon, const QString& title, const QString& label,
|
||||
const QVariant& current) {
|
||||
|
||||
QVariantMap map;
|
||||
map.insert("title", title);
|
||||
map.insert("icon", icon);
|
||||
map.insert("label", label);
|
||||
map.insert("current", current);
|
||||
QVariant result;
|
||||
|
|
|
@ -41,11 +41,19 @@ public:
|
|||
QQuickItem* getDesktop();
|
||||
QQuickItem* getToolWindow();
|
||||
|
||||
enum Icon {
|
||||
ICON_NONE = 0,
|
||||
ICON_QUESTION,
|
||||
ICON_INFORMATION,
|
||||
ICON_WARNING,
|
||||
ICON_CRITICAL,
|
||||
ICON_PLACEMARK
|
||||
};
|
||||
|
||||
// Message box compatibility
|
||||
Q_INVOKABLE QMessageBox::StandardButton messageBox(QMessageBox::Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
|
||||
Q_INVOKABLE QMessageBox::StandardButton messageBox(Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
|
||||
// Must be called from the main thread
|
||||
QQuickItem* createMessageBox(QMessageBox::Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
|
||||
QQuickItem* createMessageBox(Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
|
||||
// Must be called from the main thread
|
||||
Q_INVOKABLE int waitForMessageBoxResult(QQuickItem* messageBox);
|
||||
|
||||
|
@ -95,16 +103,25 @@ public:
|
|||
// Compatibility with QFileDialog::getSaveFileName
|
||||
static QString getSaveFileName(void* ignored, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
|
||||
|
||||
// input dialog compatibility
|
||||
Q_INVOKABLE QVariant inputDialog(const QString& title, const QString& label = QString(), const QVariant& current = QVariant());
|
||||
QQuickItem* createInputDialog(const QString& title, const QString& label, const QVariant& current);
|
||||
Q_INVOKABLE QVariant inputDialog(const Icon icon, const QString& title, const QString& label = QString(), const QVariant& current = QVariant());
|
||||
QQuickItem* createInputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current);
|
||||
QVariant waitForInputDialogResult(QQuickItem* inputDialog);
|
||||
|
||||
// Compatibility with QInputDialog::getText
|
||||
static QString getText(void* ignored, const QString & title, const QString & label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString(), bool * ok = 0, Qt::WindowFlags flags = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
|
||||
static QString getText(void* ignored, const QString & title, const QString & label,
|
||||
QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString(), bool * ok = 0,
|
||||
Qt::WindowFlags flags = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone) {
|
||||
return getText(OffscreenUi::ICON_NONE, title, label, text, ok);
|
||||
}
|
||||
// Compatibility with QInputDialog::getItem
|
||||
static QString getItem(void *ignored, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true, bool * ok = 0, Qt::WindowFlags flags = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
|
||||
static QString getItem(void *ignored, const QString & title, const QString & label, const QStringList & items,
|
||||
int current = 0, bool editable = true, bool * ok = 0, Qt::WindowFlags flags = 0,
|
||||
Qt::InputMethodHints inputMethodHints = Qt::ImhNone) {
|
||||
return getItem(OffscreenUi::ICON_NONE, title, label, items, current, editable, ok);
|
||||
}
|
||||
|
||||
static QString getText(const Icon icon, const QString & title, const QString & label, const QString & text = QString(), bool * ok = 0);
|
||||
static QString getItem(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true, bool * ok = 0);
|
||||
|
||||
signals:
|
||||
void showDesktop();
|
||||
|
|
|
@ -9,6 +9,7 @@ import "../../../interface/resources/qml/windows-uit"
|
|||
import "../../../interface/resources/qml/dialogs"
|
||||
import "../../../interface/resources/qml/hifi"
|
||||
import "../../../interface/resources/qml/hifi/dialogs"
|
||||
import "../../../interface/resources/qml/styles-uit"
|
||||
|
||||
ApplicationWindow {
|
||||
id: appWindow
|
||||
|
@ -17,6 +18,8 @@ ApplicationWindow {
|
|||
height: 800
|
||||
title: qsTr("Scratch App")
|
||||
|
||||
HifiConstants { id: hifi }
|
||||
|
||||
Desktop {
|
||||
id: desktop
|
||||
anchors.fill: parent
|
||||
|
@ -99,11 +102,11 @@ ApplicationWindow {
|
|||
var messageBox = desktop.messageBox({
|
||||
title: "Set Avatar",
|
||||
text: "Would you like to use 'Albert' for your avatar?",
|
||||
icon: OriginalDialogs.StandardIcon.Question, // Test question icon
|
||||
//icon: OriginalDialogs.StandardIcon.Information, // Test informaton icon
|
||||
//icon: OriginalDialogs.StandardIcon.Warning, // Test warning icon
|
||||
//icon: OriginalDialogs.StandardIcon.Critical, // Test critical icon
|
||||
//icon: OriginalDialogs.StandardIcon.NoIcon, // Test no icon
|
||||
icon: hifi.icons.question, // Test question icon
|
||||
//icon: hifi.icons.information, // Test informaton icon
|
||||
//icon: hifi.icons.warning, // Test warning icon
|
||||
//icon: hifi.icons.critical, // Test critical icon
|
||||
//icon: hifi.icons.none, // Test no icon
|
||||
buttons: OriginalDialogs.StandardButton.Ok + OriginalDialogs.StandardButton.Cancel,
|
||||
defaultButton: OriginalDialogs.StandardButton.Ok
|
||||
});
|
||||
|
@ -118,7 +121,7 @@ ApplicationWindow {
|
|||
onClicked: {
|
||||
var messageBox = desktop.messageBox({
|
||||
text: "Diagnostic cycle will be complete in 30 seconds",
|
||||
icon: OriginalDialogs.StandardIcon.Critical,
|
||||
icon: hifi.icons.critical,
|
||||
});
|
||||
messageBox.selected.connect(function(button) {
|
||||
console.log("You clicked " + button)
|
||||
|
@ -132,11 +135,45 @@ ApplicationWindow {
|
|||
desktop.messageBox({
|
||||
informativeText: "Diagnostic cycle will be complete in 30 seconds Diagnostic cycle will be complete in 30 seconds Diagnostic cycle will be complete in 30 seconds Diagnostic cycle will be complete in 30 seconds Diagnostic cycle will be complete in 30 seconds Diagnostic cycle will be complete in 30 seconds Diagnostic cycle will be complete in 30 seconds Diagnostic cycle will be complete in 30 seconds ",
|
||||
text: "Baloney",
|
||||
icon: OriginalDialogs.StandardIcon.Warning,
|
||||
icon: hifi.icons.warning,
|
||||
detailedText: "sakjd;laskj dksa;dl jka;lsd j;lkjas ;dlkaj s;dlakjd ;alkjda; slkjda; lkjda;lksjd ;alksjd; alksjd ;alksjd; alksjd; alksdjas;ldkjas;lkdja ;kj ;lkasjd; lkj as;dlka jsd;lka jsd;laksjd a"
|
||||
});
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: "Bookmark Location"
|
||||
onClicked: {
|
||||
desktop.inputDialog({
|
||||
title: "Bookmark Location",
|
||||
icon: hifi.icons.placemark,
|
||||
label: "Name"
|
||||
});
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: "Delete Bookmark"
|
||||
onClicked: {
|
||||
desktop.inputDialog({
|
||||
title: "Delete Bookmark",
|
||||
icon: hifi.icons.placemark,
|
||||
label: "Select the bookmark to delete",
|
||||
items: ["Bookmark A", "Bookmark B", "Bookmark C"]
|
||||
});
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: "Duplicate Bookmark"
|
||||
onClicked: {
|
||||
desktop.messageBox({
|
||||
title: "Duplicate Bookmark",
|
||||
icon: hifi.icons.warning,
|
||||
text: "The bookmark name you entered alread exists in yoru list.",
|
||||
informativeText: "Would you like to overwrite it?",
|
||||
buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No,
|
||||
defaultButton: OriginalDialogs.StandardButton.Yes
|
||||
});
|
||||
}
|
||||
}
|
||||
/*
|
||||
// There is no such desktop.queryBox() function; may need to update test to cover QueryDialog.qml?
|
||||
Button {
|
||||
|
@ -145,7 +182,7 @@ ApplicationWindow {
|
|||
var queryBox = desktop.queryBox({
|
||||
text: "Have you stopped beating your wife?",
|
||||
placeholderText: "Are you sure?",
|
||||
// icon: OriginalDialogs.StandardIcon.Critical,
|
||||
// icon: hifi.icons.critical,
|
||||
});
|
||||
queryBox.selected.connect(function(result) {
|
||||
console.log("User responded with " + result);
|
||||
|
|
Loading…
Reference in a new issue