From 067cf211b3b6987ab44c24646c094663f12a331e Mon Sep 17 00:00:00 2001 From: johanneshilden Date: Wed, 11 Oct 2017 23:16:13 +0300 Subject: [PATCH] Build out AppBar layout --- components/qtmaterialappbar.cpp | 1 - components/qtmaterialappbar.h | 8 ++++++++ components/qtmaterialiconbutton.cpp | 4 ++++ examples/appbarsettingseditor.cpp | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/qtmaterialappbar.cpp b/components/qtmaterialappbar.cpp index 45492f9..2170ca4 100644 --- a/components/qtmaterialappbar.cpp +++ b/components/qtmaterialappbar.cpp @@ -1,7 +1,6 @@ #include "qtmaterialappbar.h" #include "qtmaterialappbar_p.h" #include -#include #include #include "lib/qtmaterialstyle.h" diff --git a/components/qtmaterialappbar.h b/components/qtmaterialappbar.h index 6558ccf..4c60564 100644 --- a/components/qtmaterialappbar.h +++ b/components/qtmaterialappbar.h @@ -2,6 +2,7 @@ #define QTMATERIALAPPBAR_H #include +#include class QtMaterialAppBarPrivate; @@ -27,6 +28,8 @@ public: void setBackgroundColor(const QColor &color); QColor backgroundColor() const; + inline QHBoxLayout *appBarLayout() const; + protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; @@ -37,4 +40,9 @@ private: Q_DECLARE_PRIVATE(QtMaterialAppBar) }; +inline QHBoxLayout *QtMaterialAppBar::appBarLayout() const +{ + return static_cast(layout()); +} + #endif // QTMATERIALAPPBAR_H diff --git a/components/qtmaterialiconbutton.cpp b/components/qtmaterialiconbutton.cpp index f42ea3e..bb8d6fb 100644 --- a/components/qtmaterialiconbutton.cpp +++ b/components/qtmaterialiconbutton.cpp @@ -94,6 +94,8 @@ void QtMaterialIconButton::setColor(const QColor &color) Q_D(QtMaterialIconButton); d->color = color; + + MATERIAL_DISABLE_THEME_COLORS update(); } @@ -112,6 +114,8 @@ void QtMaterialIconButton::setDisabledColor(const QColor &color) Q_D(QtMaterialIconButton); d->disabledColor = color; + + MATERIAL_DISABLE_THEME_COLORS update(); } diff --git a/examples/appbarsettingseditor.cpp b/examples/appbarsettingseditor.cpp index 6548efd..0fd37df 100644 --- a/examples/appbarsettingseditor.cpp +++ b/examples/appbarsettingseditor.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include AppBarSettingsEditor::AppBarSettingsEditor(QWidget *parent) @@ -9,6 +10,12 @@ AppBarSettingsEditor::AppBarSettingsEditor(QWidget *parent) ui(new Ui::AppBarSettingsForm), m_appBar(new QtMaterialAppBar) { + QtMaterialIconButton *button = new QtMaterialIconButton(QtMaterialTheme::icon("navigation", "menu")); + button->setIconSize(QSize(24, 24)); + m_appBar->appBarLayout()->addWidget(button); + m_appBar->appBarLayout()->addStretch(1); + button->setColor(Qt::white); + QVBoxLayout *layout = new QVBoxLayout; setLayout(layout);