diff options
-rw-r--r-- | src/libs/utils/infobar.cpp | 54 | ||||
-rw-r--r-- | src/libs/utils/infobar.h | 7 | ||||
-rw-r--r-- | src/libs/utils/theme/theme.h | 2 | ||||
-rw-r--r-- | src/plugins/coreplugin/coreplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/coreplugin/fancytabwidget.cpp | 2 |
5 files changed, 43 insertions, 24 deletions
diff --git a/src/libs/utils/infobar.cpp b/src/libs/utils/infobar.cpp index 554cab1ac1..d3be41e478 100644 --- a/src/libs/utils/infobar.cpp +++ b/src/libs/utils/infobar.cpp @@ -34,6 +34,7 @@ #include <QSettings> #include <QVBoxLayout> #include <QLabel> +#include <QPaintEngine> #include <QToolButton> #include <QComboBox> @@ -43,7 +44,38 @@ namespace Utils { QSet<Id> InfoBar::globallySuppressed; QSettings *InfoBar::m_settings = nullptr; -Utils::Theme *InfoBar::m_theme = nullptr; + +class InfoBarWidget : public QWidget +{ +public: + InfoBarWidget(Qt::Edge edge, QWidget *parent = nullptr); + +protected: + void paintEvent(QPaintEvent *event) override; + +private: + const Qt::Edge m_edge; +}; + +InfoBarWidget::InfoBarWidget(Qt::Edge edge, QWidget *parent) + : QWidget(parent) + , m_edge(edge) +{ + const bool topEdge = m_edge == Qt::TopEdge; + setContentsMargins(2, topEdge ? 0 : 1, 0, topEdge ? 1 : 0); +} + +void InfoBarWidget::paintEvent(QPaintEvent *event) +{ + QWidget::paintEvent(event); + QPainter p(this); + p.fillRect(rect(), creatorTheme()->color(Theme::InfoBarBackground)); + const QRectF adjustedRect = QRectF(rect()).adjusted(0.5, 0.5, -0.5, -0.5); + const bool topEdge = m_edge == Qt::TopEdge; + p.setPen(creatorTheme()->color(Theme::FancyToolBarSeparatorColor)); + p.drawLine(QLineF(topEdge ? adjustedRect.bottomLeft() : adjustedRect.topLeft(), + topEdge ? adjustedRect.bottomRight() : adjustedRect.topRight())); +} InfoBarEntry::InfoBarEntry(Id _id, const QString &_infoText, GlobalSuppression _globalSuppression) : m_id(_id) @@ -146,10 +178,9 @@ void InfoBar::globallyUnsuppressInfo(Id id) writeGloballySuppressedToSettings(); } -void InfoBar::initialize(QSettings *settings, Theme *theme) +void InfoBar::initialize(QSettings *settings) { m_settings = settings; - m_theme = theme; if (QTC_GUARD(m_settings)) { const QStringList list = m_settings->value(QLatin1String(C_SUPPRESSED_WARNINGS)).toStringList(); @@ -204,9 +235,9 @@ void InfoBarDisplay::setInfoBar(InfoBar *infoBar) update(); } -void InfoBarDisplay::setStyle(QFrame::Shadow style) +void InfoBarDisplay::setEdge(Qt::Edge edge) { - m_style = style; + m_edge = edge; update(); } @@ -235,18 +266,7 @@ void InfoBarDisplay::update() return; for (const InfoBarEntry &info : m_infoBar->m_infoBarEntries) { - QFrame *infoWidget = new QFrame; - - QPalette pal; - 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 | m_style); - infoWidget->setLineWidth(1); - infoWidget->setAutoFillBackground(true); + auto infoWidget = new InfoBarWidget(m_edge); auto hbox = new QHBoxLayout; hbox->setContentsMargins(2, 2, 2, 2); diff --git a/src/libs/utils/infobar.h b/src/libs/utils/infobar.h index 8b7090fb53..2d168ed712 100644 --- a/src/libs/utils/infobar.h +++ b/src/libs/utils/infobar.h @@ -100,7 +100,7 @@ public: static void clearGloballySuppressed(); static bool anyGloballySuppressed(); - static void initialize(QSettings *settings, Theme *theme); + static void initialize(QSettings *settings); signals: void changed(); @@ -114,7 +114,6 @@ private: static QSet<Id> globallySuppressed; static QSettings *m_settings; - static Theme *m_theme; friend class InfoBarDisplay; }; @@ -127,7 +126,7 @@ public: InfoBarDisplay(QObject *parent = nullptr); void setTarget(QBoxLayout *layout, int index); void setInfoBar(InfoBar *infoBar); - void setStyle(QFrame::Shadow style); + void setEdge(Qt::Edge edge); InfoBar *infoBar() const; @@ -139,7 +138,7 @@ private: QList<QWidget *> m_infoWidgets; InfoBar *m_infoBar = nullptr; QBoxLayout *m_boxLayout = nullptr; - QFrame::Shadow m_style = QFrame::Raised; + Qt::Edge m_edge = Qt::TopEdge; int m_boxIndex = 0; bool m_isShowingDetailsWidget = false; }; diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index 21ecc007c5..d0c1f869db 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -89,7 +89,7 @@ public: FancyToolButtonSelectedColor, FutureProgressBackgroundColor, InfoBarBackground, - InfoBarText, + InfoBarText, // TODO: Deprecate. Unused. MenuBarEmptyAreaBackgroundColor, MenuBarItemBackgroundColor, MenuBarItemTextColorDisabled, diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index b2a6155077..1b621a9979 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -150,7 +150,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) Theme *themeFromArg = ThemeEntry::createTheme(args.themeId); setCreatorTheme(themeFromArg ? themeFromArg : ThemeEntry::createTheme(ThemeEntry::themeSetting())); - InfoBar::initialize(ICore::settings(), creatorTheme()); + InfoBar::initialize(ICore::settings()); new ActionManager(this); ActionManager::setPresentationModeEnabled(args.presentationMode); m_mainWindow = new MainWindow; diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp index ea2cc88e4a..cd62339d80 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -519,7 +519,7 @@ FancyTabWidget::FancyTabWidget(QWidget *parent) vlayout->addWidget(m_statusBar); m_infoBarDisplay.setTarget(vlayout, 1); - m_infoBarDisplay.setStyle(QFrame::Sunken); + m_infoBarDisplay.setEdge(Qt::BottomEdge); auto mainLayout = new QHBoxLayout; mainLayout->setContentsMargins(0, 0, 0, 0); |