summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2017-10-27 14:56:06 +0200
committerEike Ziller <eike.ziller@qt.io>2017-11-01 14:51:57 +0000
commit58942de965f9f0c906ea8deb39425ad02f6c87d6 (patch)
tree8db78e968c2c2488469933ab513620de3edd39e2 /src/plugins/coreplugin
parent89de112b6fdeaadc83ad19a618a49ef7235abfa9 (diff)
downloadqt-creator-58942de965f9f0c906ea8deb39425ad02f6c87d6.tar.gz
Remove use of global state from InfoBar
It is initialized by the core plugin anyhow, so give it enough information there to avoid accessing the global state later. Change-Id: I39e7a9f32ef5c7930faf9ba751e75bebf57b507e Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/coreplugin')
-rw-r--r--src/plugins/coreplugin/coreplugin.cpp2
-rw-r--r--src/plugins/coreplugin/infobar.cpp32
-rw-r--r--src/plugins/coreplugin/infobar.h10
3 files changed, 32 insertions, 12 deletions
diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp
index b644906cd7..65fba9709f 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 5738789b79..5a3381d3e2 100644
--- a/src/plugins/coreplugin/infobar.cpp
+++ b/src/plugins/coreplugin/infobar.cpp
@@ -25,13 +25,13 @@
#include "infobar.h"
-#include "icore.h"
-
+#include <utils/qtcassert.h>
#include <utils/theme/theme.h>
#include <utils/utilsicons.h>
#include <QFrame>
#include <QHBoxLayout>
+#include <QSettings>
#include <QVBoxLayout>
#include <QLabel>
#include <QToolButton>
@@ -43,6 +43,8 @@ using namespace Utils;
namespace Core {
QSet<Id> 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 a11c1e0d3a..53c040c39f 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<InfoBarEntry> m_infoBarEntries;
QSet<Id> m_suppressed;
+
static QSet<Id> globallySuppressed;
+ static QSettings *m_settings;
+ static Utils::Theme *m_theme;
+
friend class InfoBarDisplay;
};