AppBar -> md namespace.

Shorten the long, boring classes names.
This commit is contained in:
Achraf k 2022-02-17 01:29:18 +01:00
parent b752e8a3ae
commit 31a4a59a3f
3 changed files with 50 additions and 37 deletions

View File

@ -4,6 +4,7 @@
#include <QPainter> #include <QPainter>
#include "lib/qtmaterialstyle.h" #include "lib/qtmaterialstyle.h"
namespace md {
/*! /*!
* \class QtMaterialAppBarPrivate * \class QtMaterialAppBarPrivate
* \internal * \internal
@ -12,7 +13,7 @@
/*! /*!
* \internal * \internal
*/ */
QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q) AppBarPrivate::AppBarPrivate(AppBar *q)
: q_ptr(q) : q_ptr(q)
{ {
} }
@ -20,16 +21,16 @@ QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q)
/*! /*!
* \internal * \internal
*/ */
QtMaterialAppBarPrivate::~QtMaterialAppBarPrivate() AppBarPrivate::~AppBarPrivate()
{ {
} }
/*! /*!
* \internal * \internal
*/ */
void QtMaterialAppBarPrivate::init() void AppBarPrivate::init()
{ {
Q_Q(QtMaterialAppBar); Q_Q(AppBar);
useThemeColors = true; useThemeColors = true;
@ -48,23 +49,23 @@ void QtMaterialAppBarPrivate::init()
* \class QtMaterialAppBar * \class QtMaterialAppBar
*/ */
QtMaterialAppBar::QtMaterialAppBar(QWidget *parent) AppBar::AppBar(QWidget *parent)
: QWidget(parent), : QWidget(parent),
d_ptr(new QtMaterialAppBarPrivate(this)) d_ptr(new AppBarPrivate(this))
{ {
d_func()->init(); d_func()->init();
} }
QtMaterialAppBar::~QtMaterialAppBar() AppBar::~AppBar()
{ {
} }
QSize QtMaterialAppBar::sizeHint() const QSize AppBar::sizeHint() const
{ {
return QSize(-1, 64); return QSize(-1, 64);
} }
void QtMaterialAppBar::paintEvent(QPaintEvent *event) void AppBar::paintEvent(QPaintEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
@ -73,9 +74,9 @@ void QtMaterialAppBar::paintEvent(QPaintEvent *event)
painter.fillRect(rect(), backgroundColor()); painter.fillRect(rect(), backgroundColor());
} }
void QtMaterialAppBar::setUseThemeColors(bool value) void AppBar::setUseThemeColors(bool value)
{ {
Q_D(QtMaterialAppBar); Q_D(AppBar);
if (d->useThemeColors == value) { if (d->useThemeColors == value) {
return; return;
@ -85,16 +86,16 @@ void QtMaterialAppBar::setUseThemeColors(bool value)
update(); update();
} }
bool QtMaterialAppBar::useThemeColors() const bool AppBar::useThemeColors() const
{ {
Q_D(const QtMaterialAppBar); Q_D(const AppBar);
return d->useThemeColors; return d->useThemeColors;
} }
void QtMaterialAppBar::setForegroundColor(const QColor &color) void AppBar::setForegroundColor(const QColor &color)
{ {
Q_D(QtMaterialAppBar); Q_D(AppBar);
d->foregroundColor = color; d->foregroundColor = color;
@ -104,9 +105,9 @@ void QtMaterialAppBar::setForegroundColor(const QColor &color)
update(); update();
} }
QColor QtMaterialAppBar::foregroundColor() const QColor AppBar::foregroundColor() const
{ {
Q_D(const QtMaterialAppBar); Q_D(const AppBar);
if (d->useThemeColors || !d->foregroundColor.isValid()) { if (d->useThemeColors || !d->foregroundColor.isValid()) {
return QtMaterialStyle::instance().themeColor("primary1"); 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; d->backgroundColor = color;
@ -127,9 +128,9 @@ void QtMaterialAppBar::setBackgroundColor(const QColor &color)
update(); update();
} }
QColor QtMaterialAppBar::backgroundColor() const QColor AppBar::backgroundColor() const
{ {
Q_D(const QtMaterialAppBar); Q_D(const AppBar);
if (d->useThemeColors || !d->backgroundColor.isValid()) { if (d->useThemeColors || !d->backgroundColor.isValid()) {
return QtMaterialStyle::instance().themeColor("primary1"); return QtMaterialStyle::instance().themeColor("primary1");
@ -137,3 +138,5 @@ QColor QtMaterialAppBar::backgroundColor() const
return d->backgroundColor; return d->backgroundColor;
} }
} }
}

View File

@ -4,9 +4,12 @@
#include <QtWidgets/QWidget> #include <QtWidgets/QWidget>
#include <QtWidgets/QHBoxLayout> #include <QtWidgets/QHBoxLayout>
class QtMaterialAppBarPrivate; namespace md
{
class QtMaterialAppBar : public QWidget class AppBarPrivate;
class AppBar : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -14,8 +17,8 @@ class QtMaterialAppBar : public QWidget
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor) Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
public: public:
explicit QtMaterialAppBar(QWidget *parent = 0); explicit AppBar(QWidget *parent = 0);
~QtMaterialAppBar(); ~AppBar();
QSize sizeHint() const Q_DECL_OVERRIDE; QSize sizeHint() const Q_DECL_OVERRIDE;
@ -33,16 +36,18 @@ public:
protected: protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
const QScopedPointer<QtMaterialAppBarPrivate> d_ptr; const QScopedPointer<AppBarPrivate> d_ptr;
private: private:
Q_DISABLE_COPY(QtMaterialAppBar) Q_DISABLE_COPY(AppBar)
Q_DECLARE_PRIVATE(QtMaterialAppBar) Q_DECLARE_PRIVATE(AppBar)
}; };
inline QHBoxLayout *QtMaterialAppBar::appBarLayout() const inline QHBoxLayout *AppBar::appBarLayout() const
{ {
return static_cast<QHBoxLayout *>(layout()); return static_cast<QHBoxLayout *>(layout());
} }
}
#endif // QTMATERIALAPPBAR_H #endif // QTMATERIALAPPBAR_H

View File

@ -4,23 +4,28 @@
#include <QtGlobal> #include <QtGlobal>
#include <QColor> #include <QColor>
class QtMaterialAppBar; namespace md
class QtMaterialAppBarPrivate
{ {
Q_DISABLE_COPY(QtMaterialAppBarPrivate)
Q_DECLARE_PUBLIC(QtMaterialAppBar) class AppBar;
class AppBarPrivate
{
Q_DISABLE_COPY(AppBarPrivate)
Q_DECLARE_PUBLIC(AppBar)
public: public:
QtMaterialAppBarPrivate(QtMaterialAppBar *q); AppBarPrivate(AppBar *q);
~QtMaterialAppBarPrivate(); ~AppBarPrivate();
void init(); void init();
QtMaterialAppBar *const q_ptr; AppBar *const q_ptr;
bool useThemeColors; bool useThemeColors;
QColor foregroundColor; QColor foregroundColor;
QColor backgroundColor; QColor backgroundColor;
}; };
}
#endif // QTMATERIALAPPBAR_P_H #endif // QTMATERIALAPPBAR_P_H