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 <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);
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
FancyToolButtonSelectedColor,
|
||||
FutureProgressBackgroundColor,
|
||||
InfoBarBackground,
|
||||
InfoBarText,
|
||||
InfoBarText, // TODO: Deprecate. Unused.
|
||||
MenuBarEmptyAreaBackgroundColor,
|
||||
MenuBarItemBackgroundColor,
|
||||
MenuBarItemTextColorDisabled,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user