Merge remote-tracking branch 'upstream/master' into divider

This commit is contained in:
fperillo 2017-10-05 23:06:14 +02:00
commit 403addec6d
11 changed files with 289 additions and 35 deletions

View File

@ -7,7 +7,7 @@ I finally took the time to go through and clean up this code. The build includes
<table>
<tbody>
<tr>
<td colspan="2"></td>
<td colspan="2" align="center"></td>
</tr>
<tr>
<td>
@ -18,7 +18,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/avatar.gif" />
</td>
</tr>
@ -31,7 +31,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/checkbox.gif" />
</td>
</tr>
@ -44,7 +44,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/circularprogress.gif" />
</td>
</tr>
@ -57,7 +57,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/dialog.gif" />
</td>
</tr>
@ -83,7 +83,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/fab.gif" />
</td>
</tr>
@ -96,7 +96,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/flatbutton.gif" />
</td>
</tr>
@ -109,7 +109,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/iconbutton.gif" />
</td>
</tr>
@ -122,7 +122,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/progress.gif" />
</td>
</tr>
@ -135,7 +135,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/radiobutton.gif" />
</td>
</tr>
@ -148,7 +148,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/raisedbutton.gif" />
</td>
</tr>
@ -161,7 +161,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/scrollbar.gif" />
</td>
</tr>
@ -174,7 +174,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/slider.gif" />
</td>
</tr>
@ -187,7 +187,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/snackbar.gif" />
</td>
</tr>
@ -200,7 +200,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/tabs.gif" />
</td>
</tr>
@ -213,7 +213,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/textfield.gif" />
</td>
</tr>
@ -226,7 +226,7 @@ I finally took the time to go through and clean up this code. The build includes
</td>
</tr>
<tr>
<td colspan="2">
<td colspan="2" align="center">
<img src="gifs/toggle.gif" />
</td>
</tr>

View File

@ -38,7 +38,8 @@ SOURCES = \
qtmaterialdialog_internal.cpp \
qtmaterialdialog.cpp \
qtmaterialdrawer_internal.cpp \
qtmaterialdrawer.cpp
qtmaterialdrawer.cpp \
qtmaterialappbar.cpp
HEADERS = \
qtmaterialdivider_p.h \
qtmaterialdivider.h \
@ -100,6 +101,8 @@ HEADERS = \
qtmaterialdialog.h \
qtmaterialdrawer_internal.h \
qtmaterialdrawer_p.h \
qtmaterialdrawer.h
qtmaterialdrawer.h \
qtmaterialappbar.h \
qtmaterialappbar_p.h
RESOURCES += \
resources.qrc

View File

@ -0,0 +1,139 @@
#include "qtmaterialappbar.h"
#include "qtmaterialappbar_p.h"
#include <QtWidgets/QGraphicsDropShadowEffect>
#include <QtWidgets/QHBoxLayout>
#include <QPainter>
#include "lib/qtmaterialstyle.h"
/*!
* \class QtMaterialAppBarPrivate
* \internal
*/
/*!
* \internal
*/
QtMaterialAppBarPrivate::QtMaterialAppBarPrivate(QtMaterialAppBar *q)
: q_ptr(q)
{
}
/*!
* \internal
*/
QtMaterialAppBarPrivate::~QtMaterialAppBarPrivate()
{
}
/*!
* \internal
*/
void QtMaterialAppBarPrivate::init()
{
Q_Q(QtMaterialAppBar);
useThemeColors = true;
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
effect->setBlurRadius(11);
effect->setColor(QColor(0, 0, 0, 50));
effect->setOffset(0, 3);
q->setGraphicsEffect(effect);
QHBoxLayout *layout = new QHBoxLayout;
q->setLayout(layout);
}
/*!
* \class QtMaterialAppBar
*/
QtMaterialAppBar::QtMaterialAppBar(QWidget *parent)
: QWidget(parent)
{
d_func()->init();
}
QtMaterialAppBar::~QtMaterialAppBar()
{
}
QSize QtMaterialAppBar::sizeHint() const
{
return QSize(-1, 64);
}
void QtMaterialAppBar::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QPainter painter(this);
painter.fillRect(rect(), backgroundColor());
}
void QtMaterialAppBar::setUseThemeColors(bool value)
{
Q_D(QtMaterialAppBar);
if (d->useThemeColors == value) {
return;
}
d->useThemeColors = value;
update();
}
bool QtMaterialAppBar::useThemeColors() const
{
Q_D(const QtMaterialAppBar);
return d->useThemeColors;
}
void QtMaterialAppBar::setForegroundColor(const QColor &color)
{
Q_D(QtMaterialAppBar);
d->foregroundColor = color;
if (d->useThemeColors == true) {
d->useThemeColors = false;
}
update();
}
QColor QtMaterialAppBar::foregroundColor() const
{
Q_D(const QtMaterialAppBar);
if (d->useThemeColors || !d->foregroundColor.isValid()) {
return QtMaterialStyle::instance().themeColor("primary1");
} else {
return d->foregroundColor;
}
}
void QtMaterialAppBar::setBackgroundColor(const QColor &color)
{
Q_D(QtMaterialAppBar);
d->backgroundColor = color;
if (d->useThemeColors == true) {
d->useThemeColors = false;
}
update();
}
QColor QtMaterialAppBar::backgroundColor() const
{
Q_D(const QtMaterialAppBar);
if (d->useThemeColors || !d->backgroundColor.isValid()) {
return QtMaterialStyle::instance().themeColor("primary1");
} else {
return d->backgroundColor;
}
}

View File

@ -0,0 +1,40 @@
#ifndef QTMATERIALAPPBAR_H
#define QTMATERIALAPPBAR_H
#include <QtWidgets/QWidget>
class QtMaterialAppBarPrivate;
class QtMaterialAppBar : public QWidget
{
Q_OBJECT
Q_PROPERTY(QColor foregroundColor WRITE setForegroundColor READ foregroundColor)
Q_PROPERTY(QColor backgroundColor WRITE setBackgroundColor READ backgroundColor)
public:
explicit QtMaterialAppBar(QWidget *parent = 0);
~QtMaterialAppBar();
QSize sizeHint() const Q_DECL_OVERRIDE;
void setUseThemeColors(bool value);
bool useThemeColors() const;
void setForegroundColor(const QColor &color);
QColor foregroundColor() const;
void setBackgroundColor(const QColor &color);
QColor backgroundColor() const;
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
const QScopedPointer<QtMaterialAppBarPrivate> d_ptr;
private:
Q_DISABLE_COPY(QtMaterialAppBar)
Q_DECLARE_PRIVATE(QtMaterialAppBar)
};
#endif // QTMATERIALAPPBAR_H

View File

@ -0,0 +1,26 @@
#ifndef QTMATERIALAPPBAR_P_H
#define QTMATERIALAPPBAR_P_H
#include <QtGlobal>
#include <QColor>
class QtMaterialAppBar;
class QtMaterialAppBarPrivate
{
Q_DISABLE_COPY(QtMaterialAppBarPrivate)
Q_DECLARE_PUBLIC(QtMaterialAppBar)
public:
QtMaterialAppBarPrivate(QtMaterialAppBar *q);
~QtMaterialAppBarPrivate();
void init();
QtMaterialAppBar *const q_ptr;
bool useThemeColors;
QColor foregroundColor;
QColor backgroundColor;
};
#endif // QTMATERIALAPPBAR_P_H

View File

@ -29,6 +29,7 @@ void QtMaterialTextFieldPrivate::init()
label = 0;
labelFontSize = 9.5;
showLabel = false;
showUnderline = true;
useThemeColors = true;
q->setFrame(false);
@ -231,6 +232,25 @@ QColor QtMaterialTextField::underlineColor() const
}
}
void QtMaterialTextField::setShowUnderline(bool value)
{
Q_D(QtMaterialTextField);
if (d->showUnderline == value) {
return;
}
d->showUnderline = value;
update();
}
bool QtMaterialTextField::hasUnderline() const
{
Q_D(const QtMaterialTextField);
return d->showUnderline;
}
/*!
* \reimp
*/
@ -274,22 +294,25 @@ void QtMaterialTextField::paintEvent(QPaintEvent *event)
const int y = height()-1;
const int wd = width()-5;
QPen pen;
pen.setWidth(1);
pen.setColor(underlineColor());
painter.setPen(pen);
painter.setOpacity(1);
painter.drawLine(2.5, y, wd, y);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(inkColor());
if (progress > 0)
if (d->showUnderline)
{
painter.setPen(Qt::NoPen);
painter.setBrush(brush);
const int w = (1-progress)*static_cast<qreal>(wd/2);
painter.drawRect(w+2.5, height()-2, wd-w*2, 2);
QPen pen;
pen.setWidth(1);
pen.setColor(underlineColor());
painter.setPen(pen);
painter.setOpacity(1);
painter.drawLine(2.5, y, wd, y);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(inkColor());
if (progress > 0)
{
painter.setPen(Qt::NoPen);
painter.setBrush(brush);
const int w = (1-progress)*static_cast<qreal>(wd/2);
painter.drawRect(w+2.5, height()-2, wd-w*2, 2);
}
}
}

View File

@ -42,6 +42,9 @@ public:
void setUnderlineColor(const QColor &color);
QColor underlineColor() const;
void setShowUnderline(bool value);
bool hasUnderline() const;
protected:
bool event(QEvent *event) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;

View File

@ -29,6 +29,7 @@ public:
QString labelString;
qreal labelFontSize;
bool showLabel;
bool showUnderline;
bool useThemeColors;
};

View File

@ -41,6 +41,7 @@ TextFieldSettingsEditor::TextFieldSettingsEditor(QWidget *parent)
connect(ui->inkColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
connect(ui->underlineColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
connect(ui->labelColorToolButton, SIGNAL(pressed()), this, SLOT(selectColor()));
connect(ui->underlineCheckBox, SIGNAL(toggled(bool)), this, SLOT(setShowUnderline()));
connect(m_textField, SIGNAL(textChanged(QString)), this, SLOT(setupForm()));
}
@ -58,6 +59,7 @@ void TextFieldSettingsEditor::setupForm()
ui->labelCheckBox->setChecked(m_textField->hasLabel());
ui->labelTextLineEdit->setText(m_textField->label());
ui->useThemeColorsCheckBox->setChecked(m_textField->useThemeColors());
ui->underlineCheckBox->setChecked(m_textField->hasUnderline());
}
void TextFieldSettingsEditor::updateWidget()
@ -68,6 +70,7 @@ void TextFieldSettingsEditor::updateWidget()
m_textField->setLabel(ui->labelTextLineEdit->text());
m_textField->setShowLabel(ui->labelCheckBox->isChecked());
m_textField->setUseThemeColors(ui->useThemeColorsCheckBox->isChecked());
m_textField->setShowUnderline(ui->underlineCheckBox->isChecked());
}
void TextFieldSettingsEditor::selectColor()
@ -92,3 +95,8 @@ void TextFieldSettingsEditor::selectColor()
}
setupForm();
}
void TextFieldSettingsEditor::setShowUnderline()
{
m_textField->setShowUnderline( ui->underlineCheckBox->isChecked() );
}

View File

@ -18,6 +18,7 @@ protected slots:
void setupForm();
void updateWidget();
void selectColor();
void setShowUnderline();
private:
Ui::TextFieldSettingsForm *const ui;

View File

@ -167,6 +167,16 @@
</item>
</layout>
</item>
<item row="10" column="0">
<widget class="QLabel" name="labelShowUnderline">
<property name="text">
<string>Underline</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="underlineCheckBox"/>
</item>
</layout>
</widget>
</widget>