diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index b644906cd79..65fba9709f9 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -159,7 +159,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) addObject(m_editMode); ModeManager::activateMode(m_editMode->id()); m_designMode = new DesignMode; - InfoBar::initializeGloballySuppressed(); + InfoBar::initialize(ICore::settings(), creatorTheme()); } IWizardFactory::initialize(); diff --git a/src/plugins/coreplugin/infobar.cpp b/src/plugins/coreplugin/infobar.cpp index 5738789b792..5a3381d3e2c 100644 --- a/src/plugins/coreplugin/infobar.cpp +++ b/src/plugins/coreplugin/infobar.cpp @@ -25,13 +25,13 @@ #include "infobar.h" -#include "icore.h" - +#include #include #include #include #include +#include #include #include #include @@ -43,6 +43,8 @@ using namespace Utils; namespace Core { QSet InfoBar::globallySuppressed; +QSettings *InfoBar::m_settings = nullptr; +Utils::Theme *InfoBar::m_theme = nullptr; InfoBarEntry::InfoBarEntry(Id _id, const QString &_infoText, GlobalSuppressionMode _globalSuppression) : id(_id) @@ -147,17 +149,23 @@ void InfoBar::globallyUnsuppressInfo(Id id) writeGloballySuppressedToSettings(); } -void InfoBar::initializeGloballySuppressed() +void InfoBar::initialize(QSettings *settings, Theme *theme) { - QStringList list = ICore::settings()->value(QLatin1String(C_SUPPRESSED_WARNINGS)).toStringList(); - foreach (const QString &id, list) - globallySuppressed.insert(Id::fromString(id)); + m_settings = settings; + m_theme = theme; + + if (QTC_GUARD(m_settings)) { + QStringList list = m_settings->value(QLatin1String(C_SUPPRESSED_WARNINGS)).toStringList(); + foreach (const QString &id, list) + globallySuppressed.insert(Id::fromString(id)); + } } void InfoBar::clearGloballySuppressed() { globallySuppressed.clear(); - ICore::settings()->setValue(QLatin1String(C_SUPPRESSED_WARNINGS), QStringList()); + if (m_settings) + m_settings->setValue(QLatin1String(C_SUPPRESSED_WARNINGS), QStringList()); } bool InfoBar::anyGloballySuppressed() @@ -167,10 +175,12 @@ bool InfoBar::anyGloballySuppressed() void InfoBar::writeGloballySuppressedToSettings() { + if (!m_settings) + return; QStringList list; foreach (Id i, globallySuppressed) list << QLatin1String(i.name()); - ICore::settings()->setValue(QLatin1String(C_SUPPRESSED_WARNINGS), list); + m_settings->setValue(QLatin1String(C_SUPPRESSED_WARNINGS), list); } @@ -223,8 +233,10 @@ void InfoBarDisplay::update() QFrame *infoWidget = new QFrame; QPalette pal; - pal.setColor(QPalette::Window, creatorTheme()->color(Theme::InfoBarBackground)); - pal.setColor(QPalette::WindowText, creatorTheme()->color(Theme::InfoBarText)); + if (QTC_GUARD(InfoBar::m_theme)) { + pal.setColor(QPalette::Window, InfoBar::m_theme->color(Theme::InfoBarBackground)); + pal.setColor(QPalette::WindowText, InfoBar::m_theme->color(Theme::InfoBarText)); + } infoWidget->setPalette(pal); infoWidget->setFrameStyle(QFrame::Panel | QFrame::Raised); diff --git a/src/plugins/coreplugin/infobar.h b/src/plugins/coreplugin/infobar.h index a11c1e0d3a4..53c040c39f3 100644 --- a/src/plugins/coreplugin/infobar.h +++ b/src/plugins/coreplugin/infobar.h @@ -35,8 +35,11 @@ QT_BEGIN_NAMESPACE class QBoxLayout; +class QSettings; QT_END_NAMESPACE +namespace Utils { class Theme; } + namespace Core { class InfoBar; @@ -91,10 +94,11 @@ public: void clear(); static void globallySuppressInfo(Id id); static void globallyUnsuppressInfo(Id id); - static void initializeGloballySuppressed(); static void clearGloballySuppressed(); static bool anyGloballySuppressed(); + static void initialize(QSettings *settings, Utils::Theme *theme); + signals: void changed(); @@ -104,7 +108,11 @@ private: private: QList m_infoBarEntries; QSet m_suppressed; + static QSet globallySuppressed; + static QSettings *m_settings; + static Utils::Theme *m_theme; + friend class InfoBarDisplay; };