From 31a4a59a3fb7aeafc9e30f7112add6e995f9ab46 Mon Sep 17 00:00:00 2001 From: Achraf k Date: Thu, 17 Feb 2022 01:29:18 +0100 Subject: [PATCH] AppBar -> md namespace. Shorten the long, boring classes names. --- components/qtmaterialappbar.cpp | 45 ++++++++++++++++++--------------- components/qtmaterialappbar.h | 21 +++++++++------ components/qtmaterialappbar_p.h | 21 +++++++++------ 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/components/qtmaterialappbar.cpp b/components/qtmaterialappbar.cpp index 2170ca4..ac625ab 100644 --- a/components/qtmaterialappbar.cpp +++ b/components/qtmaterialappbar.cpp @@ -4,6 +4,7 @@ #include #include "lib/qtmaterialstyle.h" +namespace md { /*! * \class QtMaterialAppBarPrivate * \internal @@ -12,7 +13,7 @@ /*! * \internal */ -QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q) +AppBarPrivate::AppBarPrivate(AppBar *q) : q_ptr(q) { } @@ -20,16 +21,16 @@ QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q) /*! * \internal */ -QtMaterialAppBarPrivate::~QtMaterialAppBarPrivate() +AppBarPrivate::~AppBarPrivate() { } /*! * \internal */ -void QtMaterialAppBarPrivate::init() +void AppBarPrivate::init() { - Q_Q(QtMaterialAppBar); + Q_Q(AppBar); useThemeColors = true; @@ -48,23 +49,23 @@ void QtMaterialAppBarPrivate::init() * \class QtMaterialAppBar */ -QtMaterialAppBar::QtMaterialAppBar(QWidget *parent) +AppBar::AppBar(QWidget *parent) : QWidget(parent), - d_ptr(new QtMaterialAppBarPrivate(this)) + d_ptr(new AppBarPrivate(this)) { d_func()->init(); } -QtMaterialAppBar::~QtMaterialAppBar() +AppBar::~AppBar() { } -QSize QtMaterialAppBar::sizeHint() const +QSize AppBar::sizeHint() const { return QSize(-1, 64); } -void QtMaterialAppBar::paintEvent(QPaintEvent *event) +void AppBar::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -73,9 +74,9 @@ void QtMaterialAppBar::paintEvent(QPaintEvent *event) painter.fillRect(rect(), backgroundColor()); } -void QtMaterialAppBar::setUseThemeColors(bool value) +void AppBar::setUseThemeColors(bool value) { - Q_D(QtMaterialAppBar); + Q_D(AppBar); if (d->useThemeColors == value) { return; @@ -85,16 +86,16 @@ void QtMaterialAppBar::setUseThemeColors(bool value) update(); } -bool QtMaterialAppBar::useThemeColors() const +bool AppBar::useThemeColors() const { - Q_D(const QtMaterialAppBar); + Q_D(const AppBar); return d->useThemeColors; } -void QtMaterialAppBar::setForegroundColor(const QColor &color) +void AppBar::setForegroundColor(const QColor &color) { - Q_D(QtMaterialAppBar); + Q_D(AppBar); d->foregroundColor = color; @@ -104,9 +105,9 @@ void QtMaterialAppBar::setForegroundColor(const QColor &color) update(); } -QColor QtMaterialAppBar::foregroundColor() const +QColor AppBar::foregroundColor() const { - Q_D(const QtMaterialAppBar); + Q_D(const AppBar); if (d->useThemeColors || !d->foregroundColor.isValid()) { return QtMaterialStyle::instance().themeColor("primary1"); @@ -115,9 +116,9 @@ QColor QtMaterialAppBar::foregroundColor() const } } -void QtMaterialAppBar::setBackgroundColor(const QColor &color) +void AppBar::setBackgroundColor(const QColor &color) { - Q_D(QtMaterialAppBar); + Q_D(AppBar); d->backgroundColor = color; @@ -127,9 +128,9 @@ void QtMaterialAppBar::setBackgroundColor(const QColor &color) update(); } -QColor QtMaterialAppBar::backgroundColor() const +QColor AppBar::backgroundColor() const { - Q_D(const QtMaterialAppBar); + Q_D(const AppBar); if (d->useThemeColors || !d->backgroundColor.isValid()) { return QtMaterialStyle::instance().themeColor("primary1"); @@ -137,3 +138,5 @@ QColor QtMaterialAppBar::backgroundColor() const return d->backgroundColor; } } + +} diff --git a/components/qtmaterialappbar.h b/components/qtmaterialappbar.h index 4c60564..8e7fb14 100644 --- a/components/qtmaterialappbar.h +++ b/components/qtmaterialappbar.h @@ -4,9 +4,12 @@ #include #include -class QtMaterialAppBarPrivate; +namespace md +{ -class QtMaterialAppBar : public QWidget +class AppBarPrivate; + +class AppBar : public QWidget { Q_OBJECT @@ -14,8 +17,8 @@ class QtMaterialAppBar : public QWidget Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) public: - explicit QtMaterialAppBar(QWidget *parent = 0); - ~QtMaterialAppBar(); + explicit AppBar(QWidget *parent = 0); + ~AppBar(); QSize sizeHint() const Q_DECL_OVERRIDE; @@ -33,16 +36,18 @@ public: protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - const QScopedPointer d_ptr; + const QScopedPointer d_ptr; private: - Q_DISABLE_COPY(QtMaterialAppBar) - Q_DECLARE_PRIVATE(QtMaterialAppBar) + Q_DISABLE_COPY(AppBar) + Q_DECLARE_PRIVATE(AppBar) }; -inline QHBoxLayout *QtMaterialAppBar::appBarLayout() const +inline QHBoxLayout *AppBar::appBarLayout() const { return static_cast(layout()); } +} + #endif // QTMATERIALAPPBAR_H diff --git a/components/qtmaterialappbar_p.h b/components/qtmaterialappbar_p.h index 0586556..cd344cd 100644 --- a/components/qtmaterialappbar_p.h +++ b/components/qtmaterialappbar_p.h @@ -4,23 +4,28 @@ #include #include -class QtMaterialAppBar; - -class QtMaterialAppBarPrivate +namespace md { - Q_DISABLE_COPY(QtMaterialAppBarPrivate) - Q_DECLARE_PUBLIC(QtMaterialAppBar) + +class AppBar; + +class AppBarPrivate +{ + Q_DISABLE_COPY(AppBarPrivate) + Q_DECLARE_PUBLIC(AppBar) public: - QtMaterialAppBarPrivate(QtMaterialAppBar *q); - ~QtMaterialAppBarPrivate(); + AppBarPrivate(AppBar *q); + ~AppBarPrivate(); void init(); - QtMaterialAppBar *const q_ptr; + AppBar *const q_ptr; bool useThemeColors; QColor foregroundColor; QColor backgroundColor; }; +} + #endif // QTMATERIALAPPBAR_P_H