Merge pull request #7269 from ctrlaltdavid/20822

Restyle bookmark dialogs
This commit is contained in:
Seth Alves 2016-03-09 07:31:15 -08:00
commit efdef52081
9 changed files with 228 additions and 99 deletions

View file

@ -160,6 +160,7 @@ FocusScope {
ScrollView { ScrollView {
id: scrollView id: scrollView
height: 480 height: 480
width: root.width + 4
ListView { ListView {
id: listView id: listView

View file

@ -1,8 +1,8 @@
// //
// Desktop.qml // MessageDialog.qml
// //
// Created by Bradley Austin Davis on 25 Apr 2015 // Created by Bradley Austin Davis on 15 Jan 2016
// Copyright 2015 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // 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 detailedText: detailedText.text
property alias text: mainTextContainer.text property alias text: mainTextContainer.text
property alias informativeText: informativeTextContainer.text property alias informativeText: informativeTextContainer.text
onIconChanged: updateIcon();
property int buttons: OriginalDialogs.StandardButton.Ok property int buttons: OriginalDialogs.StandardButton.Ok
property int icon: OriginalDialogs.StandardIcon.NoIcon property int icon: OriginalDialogs.StandardIcon.NoIcon
property string iconText: "" property string iconText: ""
property int iconSize: 50
onIconChanged: updateIcon();
property int defaultButton: OriginalDialogs.StandardButton.NoButton; property int defaultButton: OriginalDialogs.StandardButton.NoButton;
property int clickedButton: OriginalDialogs.StandardButton.NoButton; property int clickedButton: OriginalDialogs.StandardButton.NoButton;
focus: defaultButton === OriginalDialogs.StandardButton.NoButton focus: defaultButton === OriginalDialogs.StandardButton.NoButton
@ -54,22 +55,7 @@ ModalWindow {
if (!root) { if (!root) {
return; return;
} }
switch (root.icon) { iconText = hifi.glyphForIcon(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 = ""
}
} }
Item { Item {
@ -80,8 +66,6 @@ ModalWindow {
QtObject { QtObject {
id: d 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 minWidth: 480
readonly property int maxWdith: 1280 readonly property int maxWdith: 1280
readonly property int minHeight: 120 readonly property int minHeight: 120
@ -100,7 +84,7 @@ ModalWindow {
RalewaySemiBold { RalewaySemiBold {
id: mainTextContainer id: mainTextContainer
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onTextChanged: d.resize();
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
size: hifi.fontSizes.menuItem size: hifi.fontSizes.menuItem
color: hifi.colors.baseGrayHighlight color: hifi.colors.baseGrayHighlight
@ -116,7 +100,7 @@ ModalWindow {
RalewaySemiBold { RalewaySemiBold {
id: informativeTextContainer id: informativeTextContainer
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onTextChanged: d.resize();
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
size: hifi.fontSizes.menuItem size: hifi.fontSizes.menuItem
color: hifi.colors.baseGrayHighlight color: hifi.colors.baseGrayHighlight
@ -132,7 +116,7 @@ ModalWindow {
Flow { Flow {
id: buttons id: buttons
focus: true focus: true
spacing: d.spacing spacing: hifi.dimensions.contentSpacing.x
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onHeightChanged: d.resize(); onWidthChanged: d.resize();
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft
anchors { anchors {
@ -186,8 +170,8 @@ ModalWindow {
id: flickable id: flickable
contentHeight: detailedText.height contentHeight: detailedText.height
anchors.fill: parent anchors.fill: parent
anchors.topMargin: root.spacing anchors.topMargin: hifi.dimensions.contentSpacing.x
anchors.bottomMargin: root.outerSpacing anchors.bottomMargin: hifi.dimensions.contentSpacing.y
TextEdit { TextEdit {
id: detailedText id: detailedText
size: hifi.fontSizes.menuItem size: hifi.fontSizes.menuItem
@ -210,7 +194,10 @@ ModalWindow {
} }
] ]
Component.onCompleted: updateIcon(); Component.onCompleted: {
updateIcon();
d.resize();
}
onStateChanged: d.resize() onStateChanged: d.resize()
} }

View file

@ -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 2.5
import QtQuick.Controls 1.2 import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2 as OriginalDialogs import QtQuick.Dialogs 1.2 as OriginalDialogs
import "../controls" as VrControls import "../controls-uit"
import "../styles" import "../styles-uit"
import "../windows" import "../windows-uit"
ModalWindow { ModalWindow {
id: root id: root
@ -16,8 +26,13 @@ ModalWindow {
signal selected(var result); signal selected(var result);
signal canceled(); signal canceled();
property int icon: hifi.icons.none
property string iconText: ""
property int iconSize: 35
onIconChanged: updateIcon();
property var items; property var items;
property alias label: mainTextContainer.text property string label
property var result; property var result;
// FIXME not current honored // FIXME not current honored
property var current; property var current;
@ -28,66 +43,85 @@ ModalWindow {
// For combo boxes // For combo boxes
property bool editable: true; property bool editable: true;
Rectangle { function updateIcon() {
if (!root) {
return;
}
iconText = hifi.glyphForIcon(root.icon);
}
Item {
clip: true clip: true
anchors.fill: parent width: pane.width
radius: 4 height: pane.height
color: "white" anchors.margins: 0
QtObject { QtObject {
id: d 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 minWidth: 480
readonly property int maxWdith: 1280 readonly property int maxWdith: 1280
readonly property int minHeight: 120 readonly property int minHeight: 120
readonly property int maxHeight: 720 readonly property int maxHeight: 720
function resize() { function resize() {
var targetWidth = mainTextContainer.width + d.spacing * 6 var targetWidth = pane.width
var targetHeight = mainTextContainer.implicitHeight + textResult.height + d.spacing + buttons.height 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.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) 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 { 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 // FIXME make a text field type that can be bound to a history for autocompletion
VrControls.TextField { TextField {
id: textResult id: textResult
label: root.label
focus: items ? false : true focus: items ? false : true
visible: 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 id: comboBox
label: root.label
focus: true focus: true
visible: items ? true : false 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 : [] model: items ? items : []
} }
} }
Flow { Flow {
id: buttons id: buttons
focus: true focus: true
spacing: d.spacing spacing: hifi.dimensions.contentSpacing.x
onHeightChanged: d.resize(); onWidthChanged: d.resize(); onHeightChanged: d.resize(); onWidthChanged: d.resize();
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft
anchors { bottom: parent.bottom; right: parent.right; margins: d.spacing; } anchors {
Button { action: acceptAction } bottom: parent.bottom
right: parent.right
margins: 0
bottomMargin: hifi.dimensions.contentSpacing.y
}
Button { action: cancelAction } Button { action: cancelAction }
Button { action: acceptAction }
} }
Action { Action {
@ -130,4 +164,10 @@ ModalWindow {
break; break;
} }
} }
Component.onCompleted: {
updateIcon();
d.resize();
textResult.forceActiveFocus();
}
} }

View file

@ -17,9 +17,35 @@ Item {
readonly property alias dimensions: dimensions readonly property alias dimensions: dimensions
readonly property alias fontSizes: fontSizes readonly property alias fontSizes: fontSizes
readonly property alias glyphs: glyphs readonly property alias glyphs: glyphs
readonly property alias icons: icons
readonly property alias buttons: buttons readonly property alias buttons: buttons
readonly property alias effects: effects 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 { Item {
id: colors id: colors
@ -134,6 +160,7 @@ Item {
Item { Item {
id: glyphs id: glyphs
readonly property string alert: "+"
readonly property string backward: "E" readonly property string backward: "E"
readonly property string caratDn: "5" readonly property string caratDn: "5"
readonly property string caratR: "3" readonly property string caratR: "3"
@ -141,17 +168,33 @@ Item {
readonly property string close: "w" readonly property string close: "w"
readonly property string closeInverted: "x" readonly property string closeInverted: "x"
readonly property string closeSmall: "C" readonly property string closeSmall: "C"
readonly property string critical: "="
readonly property string disclosureButtonCollapse: "M" readonly property string disclosureButtonCollapse: "M"
readonly property string disclosureButtonExpand: "L" readonly property string disclosureButtonExpand: "L"
readonly property string disclosureCollapse: "Z" readonly property string disclosureCollapse: "Z"
readonly property string disclosureExpand: "B" readonly property string disclosureExpand: "B"
readonly property string forward: "D" readonly property string forward: "D"
readonly property string info: "["
readonly property string noIcon: ""
readonly property string pin: "y" readonly property string pin: "y"
readonly property string pinInverted: "z" readonly property string pinInverted: "z"
readonly property string placemark: "U"
readonly property string question: "]"
readonly property string reloadSmall: "a" readonly property string reloadSmall: "a"
readonly property string resizeHandle: "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 { Item {
id: buttons id: buttons
readonly property int white: 0 readonly property int white: 0

View file

@ -47,16 +47,16 @@ Frame {
} }
Item { 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 x: (parent.width - width) / 2
FontAwesome { HiFiGlyphs {
id: icon id: icon
text: window.iconText text: window.iconText ? window.iconText : ""
size: 30 size: window.iconSize ? window.iconSize : 30
color: hifi.colors.lightGrayText color: hifi.colors.lightGray
visible: text != "" visible: text != ""
y: -hifi.dimensions.modalDialogTitleHeight - 5 anchors.verticalCenter: title.verticalCenter
anchors.left: parent.left anchors.left: parent.left
} }
RalewayRegular { RalewayRegular {

View file

@ -107,7 +107,7 @@ void Bookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
void Bookmarks::bookmarkLocation() { void Bookmarks::bookmarkLocation() {
bool ok = false; 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) { if (!ok) {
return; return;
} }
@ -123,7 +123,7 @@ void Bookmarks::bookmarkLocation() {
Menu* menubar = Menu::getInstance(); Menu* menubar = Menu::getInstance();
if (contains(bookmarkName)) { if (contains(bookmarkName)) {
auto offscreenUi = DependencyManager::get<OffscreenUi>(); 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.", "The bookmark name you entered already exists in your list.",
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
duplicateBookmarkMessage->setProperty("informativeText", "Would you like to overwrite it?"); duplicateBookmarkMessage->setProperty("informativeText", "Would you like to overwrite it?");
@ -156,7 +156,7 @@ void Bookmarks::deleteBookmark() {
} }
bool ok = false; 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) { if (!ok) {
return; return;
} }

View file

@ -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; QVariantMap map;
map.insert("title", title); map.insert("title", title);
map.insert("text", text); 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()) { if (QThread::currentThread() != thread()) {
QMessageBox::StandardButton result = QMessageBox::StandardButton::NoButton; QMessageBox::StandardButton result = QMessageBox::StandardButton::NoButton;
QMetaObject::invokeMethod(this, "messageBox", Qt::BlockingQueuedConnection, QMetaObject::invokeMethod(this, "messageBox", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QMessageBox::StandardButton, result), Q_RETURN_ARG(QMessageBox::StandardButton, result),
Q_ARG(QMessageBox::Icon, icon), Q_ARG(Icon, icon),
Q_ARG(QString, title), Q_ARG(QString, title),
Q_ARG(QString, text), Q_ARG(QString, text),
Q_ARG(QMessageBox::StandardButtons, buttons), 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::StandardButton OffscreenUi::critical(const QString& title, const QString& text,
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { 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::StandardButton OffscreenUi::information(const QString& title, const QString& text,
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { 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::StandardButton OffscreenUi::question(const QString& title, const QString& text,
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { 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::StandardButton OffscreenUi::warning(const QString& title, const QString& text,
QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton) { 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(const Icon icon, const QString& title, const QString& label, const QString& text, bool* ok) {
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) {
if (ok) { *ok = false; } 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()) { if (ok && result.isValid()) {
*ok = true; *ok = true;
} }
return result.toString(); return result.toString();
} }
// FIXME many input parameters currently ignored QString OffscreenUi::getItem(const Icon icon, const QString& title, const QString& label, const QStringList& items,
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) { int current, bool editable, bool* ok) {
if (ok) { if (ok) {
*ok = false; *ok = false;
} }
auto offscreenUi = DependencyManager::get<OffscreenUi>(); auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto inputDialog = offscreenUi->createInputDialog(title, label, current); auto inputDialog = offscreenUi->createInputDialog(icon, title, label, current);
if (!inputDialog) { if (!inputDialog) {
return QString(); return QString();
} }
@ -321,24 +321,28 @@ QString OffscreenUi::getItem(void *ignored, const QString & title, const QString
return result.toString(); 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()) { if (QThread::currentThread() != thread()) {
QVariant result; QVariant result;
QMetaObject::invokeMethod(this, "inputDialog", Qt::BlockingQueuedConnection, QMetaObject::invokeMethod(this, "inputDialog", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(QVariant, result), Q_RETURN_ARG(QVariant, result),
Q_ARG(QString, title), Q_ARG(QString, title),
Q_ARG(Icon, icon),
Q_ARG(QString, label), Q_ARG(QString, label),
Q_ARG(QVariant, current)); Q_ARG(QVariant, current));
return result; 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; QVariantMap map;
map.insert("title", title); map.insert("title", title);
map.insert("icon", icon);
map.insert("label", label); map.insert("label", label);
map.insert("current", current); map.insert("current", current);
QVariant result; QVariant result;

View file

@ -41,11 +41,19 @@ public:
QQuickItem* getDesktop(); QQuickItem* getDesktop();
QQuickItem* getToolWindow(); QQuickItem* getToolWindow();
enum Icon {
ICON_NONE = 0,
ICON_QUESTION,
ICON_INFORMATION,
ICON_WARNING,
ICON_CRITICAL,
ICON_PLACEMARK
};
// Message box compatibility // 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 // 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 // Must be called from the main thread
Q_INVOKABLE int waitForMessageBoxResult(QQuickItem* messageBox); Q_INVOKABLE int waitForMessageBoxResult(QQuickItem* messageBox);
@ -95,16 +103,25 @@ public:
// Compatibility with QFileDialog::getSaveFileName // 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); static QString getSaveFileName(void* ignored, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
Q_INVOKABLE QVariant inputDialog(const Icon icon, const QString& title, const QString& label = QString(), const QVariant& current = QVariant());
// input dialog compatibility QQuickItem* createInputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current);
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);
QVariant waitForInputDialogResult(QQuickItem* inputDialog); QVariant waitForInputDialogResult(QQuickItem* inputDialog);
// Compatibility with QInputDialog::getText // 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 // 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: signals:
void showDesktop(); void showDesktop();

View file

@ -9,6 +9,7 @@ import "../../../interface/resources/qml/windows-uit"
import "../../../interface/resources/qml/dialogs" import "../../../interface/resources/qml/dialogs"
import "../../../interface/resources/qml/hifi" import "../../../interface/resources/qml/hifi"
import "../../../interface/resources/qml/hifi/dialogs" import "../../../interface/resources/qml/hifi/dialogs"
import "../../../interface/resources/qml/styles-uit"
ApplicationWindow { ApplicationWindow {
id: appWindow id: appWindow
@ -17,6 +18,8 @@ ApplicationWindow {
height: 800 height: 800
title: qsTr("Scratch App") title: qsTr("Scratch App")
HifiConstants { id: hifi }
Desktop { Desktop {
id: desktop id: desktop
anchors.fill: parent anchors.fill: parent
@ -99,11 +102,11 @@ ApplicationWindow {
var messageBox = desktop.messageBox({ var messageBox = desktop.messageBox({
title: "Set Avatar", title: "Set Avatar",
text: "Would you like to use 'Albert' for your avatar?", text: "Would you like to use 'Albert' for your avatar?",
icon: OriginalDialogs.StandardIcon.Question, // Test question icon icon: hifi.icons.question, // Test question icon
//icon: OriginalDialogs.StandardIcon.Information, // Test informaton icon //icon: hifi.icons.information, // Test informaton icon
//icon: OriginalDialogs.StandardIcon.Warning, // Test warning icon //icon: hifi.icons.warning, // Test warning icon
//icon: OriginalDialogs.StandardIcon.Critical, // Test critical icon //icon: hifi.icons.critical, // Test critical icon
//icon: OriginalDialogs.StandardIcon.NoIcon, // Test no icon //icon: hifi.icons.none, // Test no icon
buttons: OriginalDialogs.StandardButton.Ok + OriginalDialogs.StandardButton.Cancel, buttons: OriginalDialogs.StandardButton.Ok + OriginalDialogs.StandardButton.Cancel,
defaultButton: OriginalDialogs.StandardButton.Ok defaultButton: OriginalDialogs.StandardButton.Ok
}); });
@ -118,7 +121,7 @@ ApplicationWindow {
onClicked: { onClicked: {
var messageBox = desktop.messageBox({ var messageBox = desktop.messageBox({
text: "Diagnostic cycle will be complete in 30 seconds", text: "Diagnostic cycle will be complete in 30 seconds",
icon: OriginalDialogs.StandardIcon.Critical, icon: hifi.icons.critical,
}); });
messageBox.selected.connect(function(button) { messageBox.selected.connect(function(button) {
console.log("You clicked " + button) console.log("You clicked " + button)
@ -132,11 +135,45 @@ ApplicationWindow {
desktop.messageBox({ 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 ", 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", 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" 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? // There is no such desktop.queryBox() function; may need to update test to cover QueryDialog.qml?
Button { Button {
@ -145,7 +182,7 @@ ApplicationWindow {
var queryBox = desktop.queryBox({ var queryBox = desktop.queryBox({
text: "Have you stopped beating your wife?", text: "Have you stopped beating your wife?",
placeholderText: "Are you sure?", placeholderText: "Are you sure?",
// icon: OriginalDialogs.StandardIcon.Critical, // icon: hifi.icons.critical,
}); });
queryBox.selected.connect(function(result) { queryBox.selected.connect(function(result) {
console.log("User responded with " + result); console.log("User responded with " + result);