mirror of
https://github.com/lubosz/overte.git
synced 2025-04-13 06:42:10 +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 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;
|
||||
|
@ -56,16 +57,16 @@ ModalWindow {
|
|||
}
|
||||
switch (root.icon) {
|
||||
case OriginalDialogs.StandardIcon.Information:
|
||||
iconText = hifi.glyphs.informatonIcon;
|
||||
iconText = hifi.glyphs.info;
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Question:
|
||||
iconText = hifi.glyphs.questionIcon;
|
||||
iconText = hifi.glyphs.question;
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Warning:
|
||||
iconText = hifi.glyphs.warningIcon;
|
||||
iconText = hifi.glyphs.alert;
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Critical:
|
||||
iconText = hifi.glyphs.criticalIcon;
|
||||
iconText = hifi.glyphs.critical;
|
||||
break;
|
||||
default:
|
||||
iconText = hifi.glyphs.noIcon;
|
||||
|
|
|
@ -26,6 +26,11 @@ 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 string label
|
||||
property var result;
|
||||
|
@ -38,6 +43,20 @@ ModalWindow {
|
|||
// For combo boxes
|
||||
property bool editable: true;
|
||||
|
||||
function updateIcon() {
|
||||
if (!root) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (root.icon) {
|
||||
case hifi.icons.placemark:
|
||||
iconText = hifi.glyphs.placemark;
|
||||
break;
|
||||
default:
|
||||
iconText = "";
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
clip: true
|
||||
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 fontSizes: fontSizes
|
||||
readonly property alias glyphs: glyphs
|
||||
readonly property alias icons: icons
|
||||
readonly property alias buttons: buttons
|
||||
readonly property alias effects: effects
|
||||
|
||||
|
@ -134,6 +135,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,20 +143,27 @@ Item {
|
|||
readonly property string close: "w"
|
||||
readonly property string closeInverted: "x"
|
||||
readonly property string closeSmall: "C"
|
||||
readonly property string criticalIcon: "="
|
||||
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 informatonIcon: "["
|
||||
readonly property string info: "["
|
||||
readonly property string noIcon: ""
|
||||
readonly property string pin: "y"
|
||||
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 resizeHandle: "A"
|
||||
readonly property string warningIcon: "+"
|
||||
}
|
||||
|
||||
Item {
|
||||
id: icons
|
||||
// Values per OffscreenUi::Icon
|
||||
readonly property int none: 0
|
||||
readonly property int placemark: 1
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
@ -53,7 +53,7 @@ Frame {
|
|||
HiFiGlyphs {
|
||||
id: icon
|
||||
text: window.iconText ? window.iconText : ""
|
||||
size: 50
|
||||
size: window.iconSize ? window.iconSize : 30
|
||||
color: hifi.colors.lightGray
|
||||
visible: text != ""
|
||||
anchors.verticalCenter: title.verticalCenter
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -95,16 +95,30 @@ 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);
|
||||
|
||||
enum Icon {
|
||||
ICON_NONE = 0,
|
||||
ICON_PLACEMARK
|
||||
};
|
||||
|
||||
// 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
|
||||
|
@ -142,6 +145,7 @@ ApplicationWindow {
|
|||
onClicked: {
|
||||
desktop.inputDialog({
|
||||
title: "Bookmark Location",
|
||||
icon: hifi.icons.placemark,
|
||||
label: "Name"
|
||||
});
|
||||
}
|
||||
|
@ -151,6 +155,7 @@ ApplicationWindow {
|
|||
onClicked: {
|
||||
desktop.inputDialog({
|
||||
title: "Delete Bookmark",
|
||||
icon: hifi.icons.placemark,
|
||||
label: "Select the bookmark to delete",
|
||||
items: ["Bookmark A", "Bookmark B", "Bookmark C"]
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue