mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:42:53 +02:00
Add ability to have icons in query dialogs
Add icon to bookmark dialogs' titles.
This commit is contained in:
parent
2aaf9ff0d0
commit
03fb6b1444
8 changed files with 82 additions and 26 deletions
|
@ -45,6 +45,7 @@ ModalWindow {
|
||||||
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();
|
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;
|
||||||
|
@ -56,16 +57,16 @@ ModalWindow {
|
||||||
}
|
}
|
||||||
switch (root.icon) {
|
switch (root.icon) {
|
||||||
case OriginalDialogs.StandardIcon.Information:
|
case OriginalDialogs.StandardIcon.Information:
|
||||||
iconText = hifi.glyphs.informatonIcon;
|
iconText = hifi.glyphs.info;
|
||||||
break;
|
break;
|
||||||
case OriginalDialogs.StandardIcon.Question:
|
case OriginalDialogs.StandardIcon.Question:
|
||||||
iconText = hifi.glyphs.questionIcon;
|
iconText = hifi.glyphs.question;
|
||||||
break;
|
break;
|
||||||
case OriginalDialogs.StandardIcon.Warning:
|
case OriginalDialogs.StandardIcon.Warning:
|
||||||
iconText = hifi.glyphs.warningIcon;
|
iconText = hifi.glyphs.alert;
|
||||||
break;
|
break;
|
||||||
case OriginalDialogs.StandardIcon.Critical:
|
case OriginalDialogs.StandardIcon.Critical:
|
||||||
iconText = hifi.glyphs.criticalIcon;
|
iconText = hifi.glyphs.critical;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
iconText = hifi.glyphs.noIcon;
|
iconText = hifi.glyphs.noIcon;
|
||||||
|
|
|
@ -26,6 +26,11 @@ 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 string label
|
property string label
|
||||||
property var result;
|
property var result;
|
||||||
|
@ -38,6 +43,20 @@ ModalWindow {
|
||||||
// For combo boxes
|
// For combo boxes
|
||||||
property bool editable: true;
|
property bool editable: true;
|
||||||
|
|
||||||
|
function updateIcon() {
|
||||||
|
if (!root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (root.icon) {
|
||||||
|
case hifi.icons.placemark:
|
||||||
|
iconText = hifi.glyphs.placemark;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
iconText = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
clip: true
|
clip: true
|
||||||
width: pane.width
|
width: pane.width
|
||||||
|
@ -153,5 +172,9 @@ ModalWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: { d.resize(); textResult.forceActiveFocus(); }
|
Component.onCompleted: {
|
||||||
|
updateIcon();
|
||||||
|
d.resize();
|
||||||
|
textResult.forceActiveFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ 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
|
||||||
|
|
||||||
|
@ -134,6 +135,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,20 +143,27 @@ 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 criticalIcon: "="
|
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 informatonIcon: "["
|
readonly property string info: "["
|
||||||
readonly property string noIcon: ""
|
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 questionIcon: "]"
|
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"
|
||||||
readonly property string warningIcon: "+"
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: icons
|
||||||
|
// Values per OffscreenUi::Icon
|
||||||
|
readonly property int none: 0
|
||||||
|
readonly property int placemark: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
|
@ -53,7 +53,7 @@ Frame {
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
id: icon
|
id: icon
|
||||||
text: window.iconText ? window.iconText : ""
|
text: window.iconText ? window.iconText : ""
|
||||||
size: 50
|
size: window.iconSize ? window.iconSize : 30
|
||||||
color: hifi.colors.lightGray
|
color: hifi.colors.lightGray
|
||||||
visible: text != ""
|
visible: text != ""
|
||||||
anchors.verticalCenter: title.verticalCenter
|
anchors.verticalCenter: title.verticalCenter
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -95,16 +95,30 @@ 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);
|
||||||
|
|
||||||
|
enum Icon {
|
||||||
|
ICON_NONE = 0,
|
||||||
|
ICON_PLACEMARK
|
||||||
|
};
|
||||||
|
|
||||||
// input dialog compatibility
|
Q_INVOKABLE QVariant inputDialog(const Icon icon, const QString& title, const QString& label = QString(), const QVariant& current = QVariant());
|
||||||
Q_INVOKABLE QVariant inputDialog(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);
|
||||||
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();
|
||||||
|
|
|
@ -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
|
||||||
|
@ -142,6 +145,7 @@ ApplicationWindow {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
desktop.inputDialog({
|
desktop.inputDialog({
|
||||||
title: "Bookmark Location",
|
title: "Bookmark Location",
|
||||||
|
icon: hifi.icons.placemark,
|
||||||
label: "Name"
|
label: "Name"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -151,6 +155,7 @@ ApplicationWindow {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
desktop.inputDialog({
|
desktop.inputDialog({
|
||||||
title: "Delete Bookmark",
|
title: "Delete Bookmark",
|
||||||
|
icon: hifi.icons.placemark,
|
||||||
label: "Select the bookmark to delete",
|
label: "Select the bookmark to delete",
|
||||||
items: ["Bookmark A", "Bookmark B", "Bookmark C"]
|
items: ["Bookmark A", "Bookmark B", "Bookmark C"]
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue