snap
This commit is contained in:
parent
aefea95267
commit
c144f850dd
|
|
@ -56,6 +56,7 @@
|
||||||
#include "yy/togglesettingseditor.h"
|
#include "yy/togglesettingseditor.h"
|
||||||
#include "components/snackbar.h"
|
#include "components/snackbar.h"
|
||||||
#include "xx/qtmaterialsnackbar.h"
|
#include "xx/qtmaterialsnackbar.h"
|
||||||
|
#include "xx/qtmaterialdialog.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
|
|
@ -210,11 +211,31 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
layout->addStretch();
|
layout->addStretch();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
{
|
||||||
|
QtMaterialDialog *mdlg = new QtMaterialDialog;
|
||||||
|
mdlg->setParent(this);
|
||||||
|
|
||||||
|
QVBoxLayout *dl = new QVBoxLayout;
|
||||||
|
dl->addWidget(new QPushButton("Hello"));
|
||||||
|
mdlg->setWindowLayout(dl);
|
||||||
|
|
||||||
|
QPushButton *b1 = new QPushButton("1");
|
||||||
|
QPushButton *b2 = new QPushButton("2");
|
||||||
|
b1->setParent(this);
|
||||||
|
b2->setParent(this);
|
||||||
|
b1->setGeometry(10, 160, 30, 20);
|
||||||
|
b2->setGeometry(10, 190, 30, 20);
|
||||||
|
|
||||||
|
connect(b1, SIGNAL(pressed()), mdlg, SLOT(showDialog()));
|
||||||
|
connect(b2, SIGNAL(pressed()), mdlg, SLOT(hideDialog()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Drawer *drwer = new Drawer;
|
Drawer *drwer = new Drawer;
|
||||||
drwer->setParent(this);
|
drwer->setParent(this);
|
||||||
|
|
||||||
Dialog *dlg = new Dialog;
|
Dialog *dlg = new Dialog;
|
||||||
//dlg->setParent(this);
|
dlg->setParent(this);
|
||||||
|
|
||||||
//dlg->windowLayout()->addWidget(new QPushButton("Hello"));
|
//dlg->windowLayout()->addWidget(new QPushButton("Hello"));
|
||||||
QVBoxLayout *dl = new QVBoxLayout;
|
QVBoxLayout *dl = new QVBoxLayout;
|
||||||
|
|
@ -224,8 +245,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
QPushButton *bbbtn = new QPushButton("Show dialog");
|
QPushButton *bbbtn = new QPushButton("Show dialog");
|
||||||
layout->addWidget(bbbtn);
|
layout->addWidget(bbbtn);
|
||||||
|
|
||||||
//connect(bbbtn, SIGNAL(pressed()), dlg, SLOT(showDialog()));
|
connect(bbbtn, SIGNAL(pressed()), dlg, SLOT(showDialog()));
|
||||||
connect(bbbtn, SIGNAL(pressed()), drwer, SLOT(openDrawer()));
|
//connect(bbbtn, SIGNAL(pressed()), drwer, SLOT(openDrawer()));
|
||||||
|
|
||||||
QtMaterialIconMenu *im = new QtMaterialIconMenu(QIcon("../qt-material-widgets/ic_star_black_24px.svg"));
|
QtMaterialIconMenu *im = new QtMaterialIconMenu(QIcon("../qt-material-widgets/ic_star_black_24px.svg"));
|
||||||
layout->addWidget(im);
|
layout->addWidget(im);
|
||||||
|
|
@ -268,6 +289,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMaterialSelectField *sfp = new QtMaterialSelectField;
|
QtMaterialSelectField *sfp = new QtMaterialSelectField;
|
||||||
|
sfp->setPlaceholderText("Favorite language");
|
||||||
//sfp->setBackgroundColor(Qt::white);
|
//sfp->setBackgroundColor(Qt::white);
|
||||||
layout->addWidget(sfp);
|
layout->addWidget(sfp);
|
||||||
layout->setAlignment(sfp, Qt::AlignCenter);
|
layout->setAlignment(sfp, Qt::AlignCenter);
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,9 @@ SOURCES += main.cpp\
|
||||||
yy/togglesettingseditor.cpp \
|
yy/togglesettingseditor.cpp \
|
||||||
xx/qtmaterialsnackbar.cpp \
|
xx/qtmaterialsnackbar.cpp \
|
||||||
xx/qtmaterialsnackbar_internal.cpp \
|
xx/qtmaterialsnackbar_internal.cpp \
|
||||||
xxlib/qtmaterialstatetransition.cpp
|
xxlib/qtmaterialstatetransition.cpp \
|
||||||
|
xx/qtmaterialdialog.cpp \
|
||||||
|
xx/qtmaterialdialog_internal.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
components/appbar.h \
|
components/appbar.h \
|
||||||
|
|
@ -311,7 +313,10 @@ HEADERS += mainwindow.h \
|
||||||
xx/qtmaterialsnackbar_p.h \
|
xx/qtmaterialsnackbar_p.h \
|
||||||
xx/qtmaterialsnackbar_internal.h \
|
xx/qtmaterialsnackbar_internal.h \
|
||||||
xxlib/qtmaterialstatetransitionevent.h \
|
xxlib/qtmaterialstatetransitionevent.h \
|
||||||
xxlib/qtmaterialstatetransition.h
|
xxlib/qtmaterialstatetransition.h \
|
||||||
|
xx/qtmaterialdialog.h \
|
||||||
|
xx/qtmaterialdialog_internal.h \
|
||||||
|
xx/qtmaterialdialog_p.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources.qrc
|
resources.qrc
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,12 @@ void QtMaterialCollapsibleMenuPrivate::init()
|
||||||
scrollArea->setWidgetResizable(true);
|
scrollArea->setWidgetResizable(true);
|
||||||
scrollArea->setWidget(mainWidget);
|
scrollArea->setWidget(mainWidget);
|
||||||
scrollArea->setVerticalScrollBar(scrollBar);
|
scrollArea->setVerticalScrollBar(scrollBar);
|
||||||
|
|
||||||
|
scrollArea->setAutoFillBackground(true);
|
||||||
|
QPalette p(scrollArea->palette());
|
||||||
|
p.setColor(QPalette::Background, Qt::white);
|
||||||
|
scrollArea->setPalette(p);
|
||||||
|
|
||||||
scrollBar->setHideOnMouseOut(false);
|
scrollBar->setHideOnMouseOut(false);
|
||||||
|
|
||||||
proxyStack->addWidget(scrollArea);
|
proxyStack->addWidget(scrollArea);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ QtMaterialCollapsibleMenuStateMachine::QtMaterialCollapsibleMenuStateMachine(
|
||||||
setInitialState(m_collapsedState);
|
setInitialState(m_collapsedState);
|
||||||
|
|
||||||
QtMaterialStateTransition *transition;
|
QtMaterialStateTransition *transition;
|
||||||
|
QPropertyAnimation *animation;
|
||||||
|
|
||||||
transition = new QtMaterialStateTransition(CollapsibleMenuExpand);
|
transition = new QtMaterialStateTransition(CollapsibleMenuExpand);
|
||||||
transition->setTargetState(m_expandedState);
|
transition->setTargetState(m_expandedState);
|
||||||
|
|
@ -43,10 +44,17 @@ QtMaterialCollapsibleMenuStateMachine::QtMaterialCollapsibleMenuStateMachine(
|
||||||
|
|
||||||
m_expandYAnimation->setTargetObject(m_proxy);
|
m_expandYAnimation->setTargetObject(m_proxy);
|
||||||
m_expandYAnimation->setPropertyName("yScale");
|
m_expandYAnimation->setPropertyName("yScale");
|
||||||
m_expandYAnimation->setDuration(500);
|
m_expandYAnimation->setDuration(600);
|
||||||
m_expandYAnimation->setEasingCurve(QEasingCurve::OutElastic);
|
m_expandYAnimation->setEasingCurve(QEasingCurve::OutElastic);
|
||||||
transition->addAnimation(m_expandYAnimation);
|
transition->addAnimation(m_expandYAnimation);
|
||||||
|
|
||||||
|
animation = new QPropertyAnimation(this);
|
||||||
|
animation->setTargetObject(m_proxy);
|
||||||
|
animation->setPropertyName("opacity");
|
||||||
|
animation->setDuration(220);
|
||||||
|
animation->setEasingCurve(QEasingCurve::OutQuad);
|
||||||
|
transition->addAnimation(animation);
|
||||||
|
|
||||||
transition = new QtMaterialStateTransition(CollapsibleMenuCollapse);
|
transition = new QtMaterialStateTransition(CollapsibleMenuCollapse);
|
||||||
transition->setTargetState(m_collapsedState);
|
transition->setTargetState(m_collapsedState);
|
||||||
m_expandedState->addTransition(transition);
|
m_expandedState->addTransition(transition);
|
||||||
|
|
@ -71,11 +79,11 @@ QtMaterialCollapsibleMenuStateMachine::QtMaterialCollapsibleMenuStateMachine(
|
||||||
m_collapsedState->assignProperty(m_proxy, "yScale", 0.05);
|
m_collapsedState->assignProperty(m_proxy, "yScale", 0.05);
|
||||||
m_collapsedState->assignProperty(m_proxy, "opacity", 0);
|
m_collapsedState->assignProperty(m_proxy, "opacity", 0);
|
||||||
|
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(this);
|
animation = new QPropertyAnimation(this);
|
||||||
animation->setTargetObject(m_proxy);
|
animation->setTargetObject(m_proxy);
|
||||||
animation->setPropertyName("opacity");
|
animation->setPropertyName("opacity");
|
||||||
animation->setDuration(160);
|
animation->setDuration(140);
|
||||||
addDefaultAnimation(animation);
|
transition->addAnimation(animation);
|
||||||
|
|
||||||
connect(m_expandedState, SIGNAL(propertiesAssigned()),
|
connect(m_expandedState, SIGNAL(propertiesAssigned()),
|
||||||
m_menu, SLOT(setOpaque()));
|
m_menu, SLOT(setOpaque()));
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,6 @@ public:
|
||||||
inline void setOpacity(qreal opacity);
|
inline void setOpacity(qreal opacity);
|
||||||
inline qreal opacity() const;
|
inline qreal opacity() const;
|
||||||
|
|
||||||
//signals:
|
|
||||||
// void expand();
|
|
||||||
// void collapse();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,166 @@
|
||||||
|
#include "xx/qtmaterialdialog.h"
|
||||||
|
#include "xx/qtmaterialdialog_p.h"
|
||||||
|
#include <QStackedLayout>
|
||||||
|
#include <QGraphicsDropShadowEffect>
|
||||||
|
#include <QStateMachine>
|
||||||
|
#include <QState>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "xx/qtmaterialdialog_internal.h"
|
||||||
|
#include "xxlib/qtmaterialstatetransition.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \class QtMaterialDialogPrivate
|
||||||
|
* \internal
|
||||||
|
*/
|
||||||
|
|
||||||
|
QtMaterialDialogPrivate::QtMaterialDialogPrivate(QtMaterialDialog *q)
|
||||||
|
: q_ptr(q)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QtMaterialDialogPrivate::~QtMaterialDialogPrivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialogPrivate::init()
|
||||||
|
{
|
||||||
|
Q_Q(QtMaterialDialog);
|
||||||
|
|
||||||
|
dialogWindow = new QtMaterialDialogWindow(q);
|
||||||
|
proxyStack = new QStackedLayout;
|
||||||
|
stateMachine = new QStateMachine(q);
|
||||||
|
proxy = new QtMaterialDialogProxy(dialogWindow, proxyStack, q);
|
||||||
|
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
q->setLayout(layout);
|
||||||
|
|
||||||
|
QWidget *widget = new QWidget;
|
||||||
|
widget->setLayout(proxyStack);
|
||||||
|
widget->setMinimumWidth(400);
|
||||||
|
|
||||||
|
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
|
||||||
|
effect->setColor(QColor(0, 0, 0, 200));
|
||||||
|
effect->setBlurRadius(64);
|
||||||
|
effect->setOffset(0, 13);
|
||||||
|
widget->setGraphicsEffect(effect);
|
||||||
|
|
||||||
|
layout->addWidget(widget);
|
||||||
|
layout->setAlignment(widget, Qt::AlignCenter);
|
||||||
|
|
||||||
|
proxyStack->addWidget(dialogWindow);
|
||||||
|
proxyStack->addWidget(proxy);
|
||||||
|
proxyStack->setCurrentIndex(1);
|
||||||
|
|
||||||
|
q->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
|
||||||
|
QState *hiddenState = new QState;
|
||||||
|
QState *visibleState = new QState;
|
||||||
|
|
||||||
|
stateMachine->addState(hiddenState);
|
||||||
|
stateMachine->addState(visibleState);
|
||||||
|
stateMachine->setInitialState(hiddenState);
|
||||||
|
|
||||||
|
QtMaterialStateTransition *transition;
|
||||||
|
|
||||||
|
transition = new QtMaterialStateTransition(DialogShowTransition);
|
||||||
|
transition->setTargetState(visibleState);
|
||||||
|
hiddenState->addTransition(transition);
|
||||||
|
|
||||||
|
transition = new QtMaterialStateTransition(DialogHideTransition);
|
||||||
|
transition->setTargetState(hiddenState);
|
||||||
|
visibleState->addTransition(transition);
|
||||||
|
|
||||||
|
visibleState->assignProperty(proxy, "opacity", 1);
|
||||||
|
visibleState->assignProperty(effect, "color", QColor(0, 0, 0, 200));
|
||||||
|
visibleState->assignProperty(dialogWindow, "offset", 0);
|
||||||
|
hiddenState->assignProperty(proxy, "opacity", 0);
|
||||||
|
hiddenState->assignProperty(effect, "color", QColor(0, 0, 0, 0));
|
||||||
|
hiddenState->assignProperty(dialogWindow, "offset", 200);
|
||||||
|
|
||||||
|
QPropertyAnimation *animation;
|
||||||
|
|
||||||
|
animation = new QPropertyAnimation(proxy, "opacity", q);
|
||||||
|
animation->setDuration(280);
|
||||||
|
stateMachine->addDefaultAnimation(animation);
|
||||||
|
|
||||||
|
animation = new QPropertyAnimation(effect, "color", q);
|
||||||
|
animation->setDuration(280);
|
||||||
|
stateMachine->addDefaultAnimation(animation);
|
||||||
|
|
||||||
|
animation = new QPropertyAnimation(dialogWindow, "offset", q);
|
||||||
|
animation->setDuration(280);
|
||||||
|
animation->setEasingCurve(QEasingCurve::OutCirc);
|
||||||
|
stateMachine->addDefaultAnimation(animation);
|
||||||
|
|
||||||
|
QObject::connect(visibleState, SIGNAL(propertiesAssigned()),
|
||||||
|
proxy, SLOT(makeOpaque()));
|
||||||
|
QObject::connect(hiddenState, SIGNAL(propertiesAssigned()),
|
||||||
|
proxy, SLOT(makeTransparent()));
|
||||||
|
|
||||||
|
stateMachine->start();
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \class QtMaterialDialog
|
||||||
|
*/
|
||||||
|
|
||||||
|
QtMaterialDialog::QtMaterialDialog(QWidget *parent)
|
||||||
|
: QtMaterialOverlayWidget(parent),
|
||||||
|
d_ptr(new QtMaterialDialogPrivate(this))
|
||||||
|
{
|
||||||
|
d_func()->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
QtMaterialDialog::~QtMaterialDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QLayout *QtMaterialDialog::windowLayout() const
|
||||||
|
{
|
||||||
|
Q_D(const QtMaterialDialog);
|
||||||
|
|
||||||
|
return d->dialogWindow->layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialog::setWindowLayout(QLayout *layout)
|
||||||
|
{
|
||||||
|
Q_D(QtMaterialDialog);
|
||||||
|
|
||||||
|
d->dialogWindow->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialog::showDialog()
|
||||||
|
{
|
||||||
|
Q_D(QtMaterialDialog);
|
||||||
|
|
||||||
|
d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(DialogShowTransition));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialog::hideDialog()
|
||||||
|
{
|
||||||
|
Q_D(QtMaterialDialog);
|
||||||
|
|
||||||
|
d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(DialogHideTransition));
|
||||||
|
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
d->proxyStack->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialog::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
Q_D(QtMaterialDialog);
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
|
QBrush brush;
|
||||||
|
brush.setStyle(Qt::SolidPattern);
|
||||||
|
brush.setColor(Qt::black);
|
||||||
|
painter.setBrush(brush);
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setOpacity(d->proxy->opacity()/2.4);
|
||||||
|
painter.drawRect(rect());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef QTMATERIALDIALOG_H
|
||||||
|
#define QTMATERIALDIALOG_H
|
||||||
|
|
||||||
|
#include <QScopedPointer>
|
||||||
|
#include "xxlib/qtmaterialoverlaywidget.h"
|
||||||
|
|
||||||
|
class QLayout;
|
||||||
|
class QtMaterialDialogPrivate;
|
||||||
|
|
||||||
|
class QtMaterialDialog : public QtMaterialOverlayWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QtMaterialDialog(QWidget *parent = 0);
|
||||||
|
~QtMaterialDialog();
|
||||||
|
|
||||||
|
QLayout *windowLayout() const;
|
||||||
|
void setWindowLayout(QLayout *layout);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void showDialog();
|
||||||
|
void hideDialog();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
const QScopedPointer<QtMaterialDialogPrivate> d_ptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(QtMaterialDialog)
|
||||||
|
Q_DECLARE_PRIVATE(QtMaterialDialog)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QTMATERIALDIALOG_H
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
#include "xx/qtmaterialdialog_internal.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QStackedLayout>
|
||||||
|
#include "xx/qtmaterialdialog.h"
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \class QtMaterialDialogProxy
|
||||||
|
* \internal
|
||||||
|
*/
|
||||||
|
|
||||||
|
QtMaterialDialogProxy::QtMaterialDialogProxy(
|
||||||
|
QtMaterialDialogWindow *source,
|
||||||
|
QStackedLayout *layout,
|
||||||
|
QtMaterialDialog *dialog,
|
||||||
|
QWidget *parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
m_source(source),
|
||||||
|
m_layout(layout),
|
||||||
|
m_dialog(dialog),
|
||||||
|
m_opacity(0),
|
||||||
|
m_mode(Transparent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QtMaterialDialogProxy::~QtMaterialDialogProxy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialogProxy::setOpacity(qreal opacity)
|
||||||
|
{
|
||||||
|
m_opacity = opacity;
|
||||||
|
m_mode = SemiTransparent;
|
||||||
|
update();
|
||||||
|
m_dialog->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QtMaterialDialogProxy::makeOpaque()
|
||||||
|
{
|
||||||
|
m_dialog->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||||
|
m_layout->setCurrentIndex(0);
|
||||||
|
m_opacity = 1.0;
|
||||||
|
m_mode = Opaque;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialogProxy::makeTransparent()
|
||||||
|
{
|
||||||
|
m_opacity = 0.0;
|
||||||
|
m_mode = Transparent;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize QtMaterialDialogProxy::sizeHint() const
|
||||||
|
{
|
||||||
|
return m_source->sizeHint();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QtMaterialDialogProxy::event(QEvent *event)
|
||||||
|
{
|
||||||
|
const QEvent::Type type = event->type();
|
||||||
|
|
||||||
|
if (QEvent::Move == type || QEvent::Resize == type) {
|
||||||
|
m_source->setGeometry(geometry());
|
||||||
|
}
|
||||||
|
return QWidget::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialogProxy::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
|
if (Transparent == m_mode) {
|
||||||
|
return;
|
||||||
|
} else if (Opaque != m_mode) {
|
||||||
|
painter.setOpacity(m_opacity);
|
||||||
|
}
|
||||||
|
QPixmap pm = m_source->grab(m_source->rect());
|
||||||
|
painter.drawPixmap(0, 0, pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \class QtMaterialDialogWindow
|
||||||
|
* \internal
|
||||||
|
*/
|
||||||
|
|
||||||
|
QtMaterialDialogWindow::QtMaterialDialogWindow(
|
||||||
|
QtMaterialDialog *dialog,
|
||||||
|
QWidget *parent)
|
||||||
|
: QWidget(parent),
|
||||||
|
m_dialog(dialog)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QtMaterialDialogWindow::~QtMaterialDialogWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialogWindow::setOffset(int offset)
|
||||||
|
{
|
||||||
|
QMargins margins = m_dialog->layout()->contentsMargins();
|
||||||
|
margins.setBottom(offset);
|
||||||
|
m_dialog->layout()->setContentsMargins(margins);
|
||||||
|
}
|
||||||
|
|
||||||
|
int QtMaterialDialogWindow::offset() const
|
||||||
|
{
|
||||||
|
return m_dialog->layout()->contentsMargins().bottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtMaterialDialogWindow::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
|
QBrush brush;
|
||||||
|
brush.setStyle(Qt::SolidPattern);
|
||||||
|
brush.setColor(Qt::white);
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(brush);
|
||||||
|
painter.drawRect(rect());
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
#ifndef QTMATERIALDIALOG_INTERNAL_H
|
||||||
|
#define QTMATERIALDIALOG_INTERNAL_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QStackedLayout;
|
||||||
|
class QtMaterialDialog;
|
||||||
|
class QtMaterialDialogWindow;
|
||||||
|
|
||||||
|
class QtMaterialDialogProxy : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
|
||||||
|
|
||||||
|
enum TransparencyMode {
|
||||||
|
Transparent,
|
||||||
|
SemiTransparent,
|
||||||
|
Opaque,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtMaterialDialogProxy(QtMaterialDialogWindow *source,
|
||||||
|
QStackedLayout *layout,
|
||||||
|
QtMaterialDialog *dialog,
|
||||||
|
QWidget *parent = 0);
|
||||||
|
~QtMaterialDialogProxy();
|
||||||
|
|
||||||
|
void setOpacity(qreal opacity);
|
||||||
|
inline qreal opacity() const;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void makeOpaque();
|
||||||
|
void makeTransparent();
|
||||||
|
|
||||||
|
QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(QtMaterialDialogProxy)
|
||||||
|
|
||||||
|
QtMaterialDialogWindow *const m_source;
|
||||||
|
QStackedLayout *const m_layout;
|
||||||
|
QtMaterialDialog *const m_dialog;
|
||||||
|
qreal m_opacity;
|
||||||
|
TransparencyMode m_mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline qreal QtMaterialDialogProxy::opacity() const
|
||||||
|
{
|
||||||
|
return m_opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
class QtMaterialDialogWindow : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(int offset WRITE setOffset READ offset)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit QtMaterialDialogWindow(QtMaterialDialog *dialog, QWidget *parent = 0);
|
||||||
|
~QtMaterialDialogWindow();
|
||||||
|
|
||||||
|
void setOffset(int offset);
|
||||||
|
int offset() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(QtMaterialDialogWindow)
|
||||||
|
|
||||||
|
QtMaterialDialog *const m_dialog;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QTMATERIALDIALOG_INTERNAL_H
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef QTMATERIALDIALOG_P_H
|
||||||
|
#define QTMATERIALDIALOG_P_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
class QStateMachine;
|
||||||
|
class QtMaterialDialog;
|
||||||
|
class QStackedLayout;
|
||||||
|
class QtMaterialDialogWindow;
|
||||||
|
class QtMaterialDialogProxy;
|
||||||
|
|
||||||
|
class QtMaterialDialogPrivate
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(QtMaterialDialogPrivate)
|
||||||
|
Q_DECLARE_PUBLIC(QtMaterialDialog)
|
||||||
|
|
||||||
|
public:
|
||||||
|
QtMaterialDialogPrivate(QtMaterialDialog *q);
|
||||||
|
~QtMaterialDialogPrivate();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
QtMaterialDialog *const q_ptr;
|
||||||
|
QtMaterialDialogWindow *dialogWindow;
|
||||||
|
QStackedLayout *proxyStack;
|
||||||
|
QStateMachine *stateMachine;
|
||||||
|
QtMaterialDialogProxy *proxy;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QTMATERIALDIALOG_P_H
|
||||||
|
|
@ -112,7 +112,7 @@ void QtMaterialIconMenu::collapseDelayed()
|
||||||
Q_D(QtMaterialIconMenu);
|
Q_D(QtMaterialIconMenu);
|
||||||
|
|
||||||
if (d->autoCollapse) {
|
if (d->autoCollapse) {
|
||||||
QTimer::singleShot(200, d->menu, SLOT(collapse()));
|
QTimer::singleShot(110, d->menu, SLOT(collapse()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ QColor QtMaterialScrollBar::canvasColor() const
|
||||||
Q_D(const QtMaterialScrollBar);
|
Q_D(const QtMaterialScrollBar);
|
||||||
|
|
||||||
if (d->useThemeColors || !d->canvasColor.isValid()) {
|
if (d->useThemeColors || !d->canvasColor.isValid()) {
|
||||||
return QtMaterialStyle::instance().themeColor("canvas");
|
return parentWidget()->palette().color(backgroundRole());
|
||||||
} else {
|
} else {
|
||||||
return d->canvasColor;
|
return d->canvasColor;
|
||||||
}
|
}
|
||||||
|
|
@ -182,7 +182,7 @@ void QtMaterialScrollBar::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
painter.drawRect(rect().marginsRemoved(margins));
|
painter.drawRect(rect().marginsRemoved(margins));
|
||||||
|
|
||||||
const qreal q = h / static_cast<qreal>(maximum() - minimum() + pageStep());
|
const qreal q = h / static_cast<qreal>(maximum()-minimum()+pageStep()-1);
|
||||||
|
|
||||||
QRect handle = Qt::Horizontal == orientation()
|
QRect handle = Qt::Horizontal == orientation()
|
||||||
? QRect(sliderPosition()*q, y, pageStep()*q, h)
|
? QRect(sliderPosition()*q, y, pageStep()*q, h)
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ void QtMaterialSelectField::collapseDelayed()
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialSelectField);
|
Q_D(QtMaterialSelectField);
|
||||||
|
|
||||||
QTimer::singleShot(200, d->menu, SLOT(collapse()));
|
QTimer::singleShot(100, d->menu, SLOT(collapse()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,10 @@ enum QtMaterialStateTransitionType {
|
||||||
SliderChangedFromMinimum,
|
SliderChangedFromMinimum,
|
||||||
SliderNoFocusMouseEnter,
|
SliderNoFocusMouseEnter,
|
||||||
SliderNoFocusMouseLeave,
|
SliderNoFocusMouseLeave,
|
||||||
|
// Dialog
|
||||||
|
DialogShowTransition,
|
||||||
|
DialogHideTransition,
|
||||||
|
//
|
||||||
MaxTransitionType = 65535
|
MaxTransitionType = 65535
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue