forked from qt-creator/qt-creator
Utils: Improve InfoBar border
Replace 80s 3d frame with a slim separator line. Task-number: QTCREATORBUG-23176 Change-Id: If50d35f500323bf4b963cb2222b5f947a307a5bc Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPaintEngine>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
|
||||||
@@ -43,7 +44,38 @@ namespace Utils {
|
|||||||
|
|
||||||
QSet<Id> InfoBar::globallySuppressed;
|
QSet<Id> InfoBar::globallySuppressed;
|
||||||
QSettings *InfoBar::m_settings = nullptr;
|
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)
|
InfoBarEntry::InfoBarEntry(Id _id, const QString &_infoText, GlobalSuppression _globalSuppression)
|
||||||
: m_id(_id)
|
: m_id(_id)
|
||||||
@@ -146,10 +178,9 @@ void InfoBar::globallyUnsuppressInfo(Id id)
|
|||||||
writeGloballySuppressedToSettings();
|
writeGloballySuppressedToSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoBar::initialize(QSettings *settings, Theme *theme)
|
void InfoBar::initialize(QSettings *settings)
|
||||||
{
|
{
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
m_theme = theme;
|
|
||||||
|
|
||||||
if (QTC_GUARD(m_settings)) {
|
if (QTC_GUARD(m_settings)) {
|
||||||
const QStringList list = m_settings->value(QLatin1String(C_SUPPRESSED_WARNINGS)).toStringList();
|
const QStringList list = m_settings->value(QLatin1String(C_SUPPRESSED_WARNINGS)).toStringList();
|
||||||
@@ -204,9 +235,9 @@ void InfoBarDisplay::setInfoBar(InfoBar *infoBar)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoBarDisplay::setStyle(QFrame::Shadow style)
|
void InfoBarDisplay::setEdge(Qt::Edge edge)
|
||||||
{
|
{
|
||||||
m_style = style;
|
m_edge = edge;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,18 +266,7 @@ void InfoBarDisplay::update()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (const InfoBarEntry &info : m_infoBar->m_infoBarEntries) {
|
for (const InfoBarEntry &info : m_infoBar->m_infoBarEntries) {
|
||||||
QFrame *infoWidget = new QFrame;
|
auto infoWidget = new InfoBarWidget(m_edge);
|
||||||
|
|
||||||
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 hbox = new QHBoxLayout;
|
auto hbox = new QHBoxLayout;
|
||||||
hbox->setContentsMargins(2, 2, 2, 2);
|
hbox->setContentsMargins(2, 2, 2, 2);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
static void clearGloballySuppressed();
|
static void clearGloballySuppressed();
|
||||||
static bool anyGloballySuppressed();
|
static bool anyGloballySuppressed();
|
||||||
|
|
||||||
static void initialize(QSettings *settings, Theme *theme);
|
static void initialize(QSettings *settings);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
@@ -114,7 +114,6 @@ private:
|
|||||||
|
|
||||||
static QSet<Id> globallySuppressed;
|
static QSet<Id> globallySuppressed;
|
||||||
static QSettings *m_settings;
|
static QSettings *m_settings;
|
||||||
static Theme *m_theme;
|
|
||||||
|
|
||||||
friend class InfoBarDisplay;
|
friend class InfoBarDisplay;
|
||||||
};
|
};
|
||||||
@@ -127,7 +126,7 @@ public:
|
|||||||
InfoBarDisplay(QObject *parent = nullptr);
|
InfoBarDisplay(QObject *parent = nullptr);
|
||||||
void setTarget(QBoxLayout *layout, int index);
|
void setTarget(QBoxLayout *layout, int index);
|
||||||
void setInfoBar(InfoBar *infoBar);
|
void setInfoBar(InfoBar *infoBar);
|
||||||
void setStyle(QFrame::Shadow style);
|
void setEdge(Qt::Edge edge);
|
||||||
|
|
||||||
InfoBar *infoBar() const;
|
InfoBar *infoBar() const;
|
||||||
|
|
||||||
@@ -139,7 +138,7 @@ private:
|
|||||||
QList<QWidget *> m_infoWidgets;
|
QList<QWidget *> m_infoWidgets;
|
||||||
InfoBar *m_infoBar = nullptr;
|
InfoBar *m_infoBar = nullptr;
|
||||||
QBoxLayout *m_boxLayout = nullptr;
|
QBoxLayout *m_boxLayout = nullptr;
|
||||||
QFrame::Shadow m_style = QFrame::Raised;
|
Qt::Edge m_edge = Qt::TopEdge;
|
||||||
int m_boxIndex = 0;
|
int m_boxIndex = 0;
|
||||||
bool m_isShowingDetailsWidget = false;
|
bool m_isShowingDetailsWidget = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public:
|
|||||||
FancyToolButtonSelectedColor,
|
FancyToolButtonSelectedColor,
|
||||||
FutureProgressBackgroundColor,
|
FutureProgressBackgroundColor,
|
||||||
InfoBarBackground,
|
InfoBarBackground,
|
||||||
InfoBarText,
|
InfoBarText, // TODO: Deprecate. Unused.
|
||||||
MenuBarEmptyAreaBackgroundColor,
|
MenuBarEmptyAreaBackgroundColor,
|
||||||
MenuBarItemBackgroundColor,
|
MenuBarItemBackgroundColor,
|
||||||
MenuBarItemTextColorDisabled,
|
MenuBarItemTextColorDisabled,
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
Theme *themeFromArg = ThemeEntry::createTheme(args.themeId);
|
Theme *themeFromArg = ThemeEntry::createTheme(args.themeId);
|
||||||
setCreatorTheme(themeFromArg ? themeFromArg
|
setCreatorTheme(themeFromArg ? themeFromArg
|
||||||
: ThemeEntry::createTheme(ThemeEntry::themeSetting()));
|
: ThemeEntry::createTheme(ThemeEntry::themeSetting()));
|
||||||
InfoBar::initialize(ICore::settings(), creatorTheme());
|
InfoBar::initialize(ICore::settings());
|
||||||
new ActionManager(this);
|
new ActionManager(this);
|
||||||
ActionManager::setPresentationModeEnabled(args.presentationMode);
|
ActionManager::setPresentationModeEnabled(args.presentationMode);
|
||||||
m_mainWindow = new MainWindow;
|
m_mainWindow = new MainWindow;
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ FancyTabWidget::FancyTabWidget(QWidget *parent)
|
|||||||
vlayout->addWidget(m_statusBar);
|
vlayout->addWidget(m_statusBar);
|
||||||
|
|
||||||
m_infoBarDisplay.setTarget(vlayout, 1);
|
m_infoBarDisplay.setTarget(vlayout, 1);
|
||||||
m_infoBarDisplay.setStyle(QFrame::Sunken);
|
m_infoBarDisplay.setEdge(Qt::BottomEdge);
|
||||||
|
|
||||||
auto mainLayout = new QHBoxLayout;
|
auto mainLayout = new QHBoxLayout;
|
||||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user