mirror of
https://github.com/lubosz/overte.git
synced 2025-04-13 06:42:10 +02:00
Use OffscreenUI icon enum instead of QMessageBox icon enum
This commit is contained in:
parent
03fb6b1444
commit
10e4e5e3a7
7 changed files with 58 additions and 48 deletions
|
@ -55,22 +55,7 @@ ModalWindow {
|
|||
if (!root) {
|
||||
return;
|
||||
}
|
||||
switch (root.icon) {
|
||||
case OriginalDialogs.StandardIcon.Information:
|
||||
iconText = hifi.glyphs.info;
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Question:
|
||||
iconText = hifi.glyphs.question;
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Warning:
|
||||
iconText = hifi.glyphs.alert;
|
||||
break;
|
||||
case OriginalDialogs.StandardIcon.Critical:
|
||||
iconText = hifi.glyphs.critical;
|
||||
break;
|
||||
default:
|
||||
iconText = hifi.glyphs.noIcon;
|
||||
}
|
||||
iconText = hifi.glyphForIcon(root.icon);
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
@ -47,14 +47,7 @@ ModalWindow {
|
|||
if (!root) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (root.icon) {
|
||||
case hifi.icons.placemark:
|
||||
iconText = hifi.glyphs.placemark;
|
||||
break;
|
||||
default:
|
||||
iconText = "";
|
||||
}
|
||||
iconText = hifi.glyphForIcon(root.icon);
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
@ -21,6 +21,31 @@ Item {
|
|||
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:
|
||||
ch = hifi.glyphs.noIcon;
|
||||
}
|
||||
return glyph;
|
||||
}
|
||||
|
||||
Item {
|
||||
id: colors
|
||||
|
||||
|
@ -163,7 +188,11 @@ Item {
|
|||
id: icons
|
||||
// Values per OffscreenUi::Icon
|
||||
readonly property int none: 0
|
||||
readonly property int placemark: 1
|
||||
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 {
|
||||
|
|
|
@ -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?");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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,11 +103,6 @@ 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
|
||||
};
|
||||
|
||||
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);
|
||||
|
|
|
@ -102,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
|
||||
});
|
||||
|
@ -121,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)
|
||||
|
@ -135,7 +135,7 @@ 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"
|
||||
});
|
||||
}
|
||||
|
@ -169,7 +169,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