forked from qt-creator/qt-creator
Move Utils::AsynchronousMessageBox to Core::AsynchronousMessageBox
The MainWindow was not always the first window and active has to returned instead of a nullptr. Using dialogParent should fix it. Change-Id: If78edb5e9567111aa998bbe5da70b3f148a3fd16 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -93,8 +93,7 @@ SOURCES += $$PWD/environment.cpp \
|
|||||||
$$PWD/treeviewcombobox.cpp \
|
$$PWD/treeviewcombobox.cpp \
|
||||||
$$PWD/proxycredentialsdialog.cpp \
|
$$PWD/proxycredentialsdialog.cpp \
|
||||||
$$PWD/macroexpander.cpp \
|
$$PWD/macroexpander.cpp \
|
||||||
$$PWD/theme/theme.cpp \
|
$$PWD/theme/theme.cpp
|
||||||
$$PWD/messagebox.cpp
|
|
||||||
|
|
||||||
win32:SOURCES += $$PWD/consoleprocess_win.cpp
|
win32:SOURCES += $$PWD/consoleprocess_win.cpp
|
||||||
else:SOURCES += $$PWD/consoleprocess_unix.cpp
|
else:SOURCES += $$PWD/consoleprocess_unix.cpp
|
||||||
@@ -193,8 +192,7 @@ HEADERS += \
|
|||||||
$$PWD/proxycredentialsdialog.h \
|
$$PWD/proxycredentialsdialog.h \
|
||||||
$$PWD/macroexpander.h \
|
$$PWD/macroexpander.h \
|
||||||
$$PWD/theme/theme.h \
|
$$PWD/theme/theme.h \
|
||||||
$$PWD/theme/theme_p.h \
|
$$PWD/theme/theme_p.h
|
||||||
$$PWD/ messagebox.h
|
|
||||||
|
|
||||||
FORMS += $$PWD/filewizardpage.ui \
|
FORMS += $$PWD/filewizardpage.ui \
|
||||||
$$PWD/projectintropage.ui \
|
$$PWD/projectintropage.ui \
|
||||||
|
|||||||
@@ -106,8 +106,6 @@ QtcLibrary {
|
|||||||
"listutils.h",
|
"listutils.h",
|
||||||
"macroexpander.cpp",
|
"macroexpander.cpp",
|
||||||
"macroexpander.h",
|
"macroexpander.h",
|
||||||
"messagebox.cpp",
|
|
||||||
"messagebox.h",
|
|
||||||
"multitask.h",
|
"multitask.h",
|
||||||
"navigationtreeview.cpp",
|
"navigationtreeview.cpp",
|
||||||
"navigationtreeview.h",
|
"navigationtreeview.h",
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ SOURCES += corejsextensions.cpp \
|
|||||||
themeeditor/colorrole.cpp \
|
themeeditor/colorrole.cpp \
|
||||||
themeeditor/themesettingstablemodel.cpp \
|
themeeditor/themesettingstablemodel.cpp \
|
||||||
themeeditor/sectionedtablemodel.cpp \
|
themeeditor/sectionedtablemodel.cpp \
|
||||||
themeeditor/themesettingsitemdelegate.cpp
|
themeeditor/themesettingsitemdelegate.cpp \
|
||||||
|
messagebox.cpp
|
||||||
|
|
||||||
HEADERS += corejsextensions.h \
|
HEADERS += corejsextensions.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
@@ -226,6 +227,7 @@ HEADERS += corejsextensions.h \
|
|||||||
themeeditor/themesettingstablemodel.h \
|
themeeditor/themesettingstablemodel.h \
|
||||||
themeeditor/sectionedtablemodel.h \
|
themeeditor/sectionedtablemodel.h \
|
||||||
themeeditor/themesettingsitemdelegate.h \
|
themeeditor/themesettingsitemdelegate.h \
|
||||||
|
messagebox.h
|
||||||
|
|
||||||
FORMS += dialogs/newdialog.ui \
|
FORMS += dialogs/newdialog.ui \
|
||||||
dialogs/saveitemsdialog.ui \
|
dialogs/saveitemsdialog.ui \
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ QtcPlugin {
|
|||||||
"jsexpander.cpp", "jsexpander.h",
|
"jsexpander.cpp", "jsexpander.h",
|
||||||
"mainwindow.cpp", "mainwindow.h",
|
"mainwindow.cpp", "mainwindow.h",
|
||||||
"manhattanstyle.cpp", "manhattanstyle.h",
|
"manhattanstyle.cpp", "manhattanstyle.h",
|
||||||
|
"messagebox.cpp", "messagebox.h",
|
||||||
"messagemanager.cpp", "messagemanager.h",
|
"messagemanager.cpp", "messagemanager.h",
|
||||||
"messageoutputwindow.cpp", "messageoutputwindow.h",
|
"messageoutputwindow.cpp", "messageoutputwindow.h",
|
||||||
"mimedatabase.cpp", "mimedatabase.h",
|
"mimedatabase.cpp", "mimedatabase.h",
|
||||||
|
|||||||
@@ -31,37 +31,42 @@
|
|||||||
#include "messagebox.h"
|
#include "messagebox.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
namespace Utils {
|
#include "icore.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
namespace AsynchronousMessageBox {
|
namespace AsynchronousMessageBox {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
QWidget *dialogParent()
|
|
||||||
{
|
|
||||||
QWidget *active = QApplication::activeModalWidget();
|
|
||||||
|
|
||||||
if (!active) {
|
void message(QMessageBox::Icon icon, const QString &title, const QString &desciption)
|
||||||
QList<QWidget*> topLevelWidgets = QApplication::topLevelWidgets();
|
|
||||||
if (!topLevelWidgets.isEmpty())
|
|
||||||
return topLevelWidgets.first();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void warning(const QString &title, const QString &desciption)
|
|
||||||
{
|
{
|
||||||
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
|
QMessageBox *messageBox = new QMessageBox(icon,
|
||||||
title,
|
title,
|
||||||
desciption,
|
desciption,
|
||||||
QMessageBox::Ok,
|
QMessageBox::Ok,
|
||||||
dialogParent());
|
Core::ICore::dialogParent());
|
||||||
|
|
||||||
messageBox->setAttribute(Qt::WA_DeleteOnClose);
|
messageBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
messageBox->setModal(true);
|
messageBox->setModal(true);
|
||||||
messageBox->show();
|
messageBox->show();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void warning(const QString &title, const QString &desciption)
|
||||||
|
{
|
||||||
|
message(QMessageBox::Warning, title, desciption);
|
||||||
|
}
|
||||||
|
|
||||||
|
void information(const QString &title, const QString &desciption)
|
||||||
|
{
|
||||||
|
message(QMessageBox::Information, title, desciption);
|
||||||
|
}
|
||||||
|
|
||||||
|
void critical(const QString &title, const QString &desciption)
|
||||||
|
{
|
||||||
|
message(QMessageBox::Critical, title, desciption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -31,16 +31,18 @@
|
|||||||
#ifndef MESSAGEBOX_H
|
#ifndef MESSAGEBOX_H
|
||||||
#define MESSAGEBOX_H
|
#define MESSAGEBOX_H
|
||||||
|
|
||||||
#include "utils_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QString;
|
class QString;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils {
|
namespace Core {
|
||||||
namespace AsynchronousMessageBox {
|
namespace AsynchronousMessageBox {
|
||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT void warning(const QString &title, const QString &desciption);
|
CORE_EXPORT void warning(const QString &title, const QString &desciption);
|
||||||
|
CORE_EXPORT void information(const QString &title, const QString &desciption);
|
||||||
|
CORE_EXPORT void critical(const QString &title, const QString &desciption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user