Commit e5c16c79 authored by Marco Bubke's avatar Marco Bubke

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: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 2efc022b
......@@ -93,8 +93,7 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/treeviewcombobox.cpp \
$$PWD/proxycredentialsdialog.cpp \
$$PWD/macroexpander.cpp \
$$PWD/theme/theme.cpp \
$$PWD/messagebox.cpp
$$PWD/theme/theme.cpp
win32:SOURCES += $$PWD/consoleprocess_win.cpp
else:SOURCES += $$PWD/consoleprocess_unix.cpp
......@@ -193,8 +192,7 @@ HEADERS += \
$$PWD/proxycredentialsdialog.h \
$$PWD/macroexpander.h \
$$PWD/theme/theme.h \
$$PWD/theme/theme_p.h \
$$PWD/ messagebox.h
$$PWD/theme/theme_p.h
FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \
......
......@@ -106,8 +106,6 @@ QtcLibrary {
"listutils.h",
"macroexpander.cpp",
"macroexpander.h",
"messagebox.cpp",
"messagebox.h",
"multitask.h",
"navigationtreeview.cpp",
"navigationtreeview.h",
......
......@@ -110,7 +110,8 @@ SOURCES += corejsextensions.cpp \
themeeditor/colorrole.cpp \
themeeditor/themesettingstablemodel.cpp \
themeeditor/sectionedtablemodel.cpp \
themeeditor/themesettingsitemdelegate.cpp
themeeditor/themesettingsitemdelegate.cpp \
messagebox.cpp
HEADERS += corejsextensions.h \
mainwindow.h \
......@@ -226,6 +227,7 @@ HEADERS += corejsextensions.h \
themeeditor/themesettingstablemodel.h \
themeeditor/sectionedtablemodel.h \
themeeditor/themesettingsitemdelegate.h \
messagebox.h
FORMS += dialogs/newdialog.ui \
dialogs/saveitemsdialog.ui \
......
......@@ -71,6 +71,7 @@ QtcPlugin {
"jsexpander.cpp", "jsexpander.h",
"mainwindow.cpp", "mainwindow.h",
"manhattanstyle.cpp", "manhattanstyle.h",
"messagebox.cpp", "messagebox.h",
"messagemanager.cpp", "messagemanager.h",
"messageoutputwindow.cpp", "messageoutputwindow.h",
"mimedatabase.cpp", "mimedatabase.h",
......
......@@ -31,37 +31,42 @@
#include "messagebox.h"
#include <QMessageBox>
#include <QApplication>
namespace Utils {
#include "icore.h"
namespace Core {
namespace AsynchronousMessageBox {
namespace {
QWidget *dialogParent()
{
QWidget *active = QApplication::activeModalWidget();
if (!active) {
QList<QWidget*> topLevelWidgets = QApplication::topLevelWidgets();
if (!topLevelWidgets.isEmpty())
return topLevelWidgets.first();
}
return nullptr;
}
}
void warning(const QString &title, const QString &desciption)
void message(QMessageBox::Icon icon, const QString &title, const QString &desciption)
{
QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
QMessageBox *messageBox = new QMessageBox(icon,
title,
desciption,
QMessageBox::Ok,
dialogParent());
Core::ICore::dialogParent());
messageBox->setAttribute(Qt::WA_DeleteOnClose);
messageBox->setModal(true);
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
#define MESSAGEBOX_H
#include "utils_global.h"
#include "core_global.h"
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace Utils {
namespace Core {
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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment