Remove crappy components
This commit is contained in:
parent
fa374a515b
commit
286b1e1c10
|
@ -30,14 +30,10 @@ SOURCES = \
|
|||
qtmaterialtextfield.cpp \
|
||||
qtmaterialtabs_internal.cpp \
|
||||
qtmaterialtabs.cpp \
|
||||
qtmaterialselectfield.cpp \
|
||||
qtmaterialmenuitem_internal.cpp \
|
||||
qtmaterialmenuitem.cpp \
|
||||
qtmaterialcollapsiblemenu_internal.cpp \
|
||||
qtmaterialcollapsiblemenu.cpp \
|
||||
qtmaterialscrollbar_internal.cpp \
|
||||
qtmaterialscrollbar.cpp \
|
||||
qtmaterialiconmenu.cpp
|
||||
qtmaterialscrollbar.cpp
|
||||
HEADERS = \
|
||||
qtmaterialavatar_p.h \
|
||||
qtmaterialavatar.h \
|
||||
|
@ -86,18 +82,11 @@ HEADERS = \
|
|||
qtmaterialtabs_internal.h \
|
||||
qtmaterialtabs_p.h \
|
||||
qtmaterialtabs.h \
|
||||
qtmaterialselectfield_p.h \
|
||||
qtmaterialselectfield.h \
|
||||
qtmaterialmenuitem_internal.h \
|
||||
qtmaterialmenuitem_p.h \
|
||||
qtmaterialmenuitem.h \
|
||||
qtmaterialcollapsiblemenu_internal.h \
|
||||
qtmaterialcollapsiblemenu_p.h \
|
||||
qtmaterialcollapsiblemenu.h \
|
||||
qtmaterialscrollbar_internal.h \
|
||||
qtmaterialscrollbar_p.h \
|
||||
qtmaterialscrollbar.h \
|
||||
qtmaterialiconmenu_p.h \
|
||||
qtmaterialiconmenu.h
|
||||
qtmaterialscrollbar.h
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
|
|
@ -1,236 +0,0 @@
|
|||
#include "qtmaterialcollapsiblemenu.h"
|
||||
#include "qtmaterialcollapsiblemenu_p.h"
|
||||
#include <QtWidgets/QScrollArea>
|
||||
#include <QtWidgets/QStackedLayout>
|
||||
#include <QPropertyAnimation>
|
||||
#include "qtmaterialcollapsiblemenu_internal.h"
|
||||
#include "qtmaterialmenuitem.h"
|
||||
#include "qtmaterialscrollbar.h"
|
||||
#include "lib/qtmaterialstyle.h"
|
||||
#include "lib/qtmaterialstatetransitionevent.h"
|
||||
|
||||
/*!
|
||||
* \class QtMaterialCollapsibleMenuPrivate
|
||||
* \internal
|
||||
*/
|
||||
|
||||
QtMaterialCollapsibleMenuPrivate::QtMaterialCollapsibleMenuPrivate(QtMaterialCollapsibleMenu *q)
|
||||
: q_ptr(q)
|
||||
{
|
||||
}
|
||||
|
||||
QtMaterialCollapsibleMenuPrivate::~QtMaterialCollapsibleMenuPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenuPrivate::init()
|
||||
{
|
||||
Q_Q(QtMaterialCollapsibleMenu);
|
||||
|
||||
QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
|
||||
QtMaterialScrollBar *scrollBar = new QtMaterialScrollBar;
|
||||
|
||||
scrollArea = new QScrollArea;
|
||||
mainWidget = new QWidget;
|
||||
menuLayout = new QVBoxLayout;
|
||||
proxy = new QtMaterialCollapsibleMenuProxy(mainWidget, effect);
|
||||
stateMachine = new QtMaterialCollapsibleMenuStateMachine(proxy, q);
|
||||
proxyStack = new QStackedLayout;
|
||||
|
||||
mainWidget->setLayout(menuLayout);
|
||||
menuLayout->setSpacing(0);
|
||||
menuLayout->setMargin(0);
|
||||
|
||||
scrollArea->setLineWidth(0);
|
||||
scrollArea->setMidLineWidth(0);
|
||||
scrollArea->setFrameShape(QFrame::NoFrame);
|
||||
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setWidget(mainWidget);
|
||||
scrollArea->setVerticalScrollBar(scrollBar);
|
||||
|
||||
scrollArea->setAutoFillBackground(true);
|
||||
QPalette p(scrollArea->palette());
|
||||
p.setColor(QPalette::Background, Qt::white);
|
||||
scrollArea->setPalette(p);
|
||||
|
||||
scrollBar->setHideOnMouseOut(false);
|
||||
|
||||
proxyStack->addWidget(scrollArea);
|
||||
proxyStack->setSpacing(0);
|
||||
proxyStack->setMargin(0);
|
||||
proxyStack->addWidget(proxy);
|
||||
proxyStack->setCurrentIndex(1);
|
||||
|
||||
q->setLayout(proxyStack);
|
||||
|
||||
effect->setBlurRadius(9);
|
||||
effect->setOffset(QPoint(0, 0));
|
||||
effect->setColor(QColor(0, 0, 0, 100));
|
||||
q->setGraphicsEffect(effect);
|
||||
|
||||
stateMachine->start();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class QtMaterialCollapsibleMenu
|
||||
*/
|
||||
|
||||
QtMaterialCollapsibleMenu::QtMaterialCollapsibleMenu(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
d_ptr(new QtMaterialCollapsibleMenuPrivate(this))
|
||||
{
|
||||
d_func()->init();
|
||||
}
|
||||
|
||||
QtMaterialCollapsibleMenu::~QtMaterialCollapsibleMenu()
|
||||
{
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::addMenuItem(const QString &text)
|
||||
{
|
||||
QtMaterialMenuItem *item = new QtMaterialMenuItem;
|
||||
item->setText(text);
|
||||
addMenuItem(item);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::addMenuItem(QtMaterialMenuItem *item)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->menuLayout->addWidget(item);
|
||||
connect(item, SIGNAL(clicked(bool)), this, SLOT(menuItemClicked()));
|
||||
}
|
||||
|
||||
QtMaterialMenuItem *QtMaterialCollapsibleMenu::menuItemAt(int index) const
|
||||
{
|
||||
Q_D(const QtMaterialCollapsibleMenu);
|
||||
|
||||
QLayoutItem *item;
|
||||
|
||||
if (!(item = d->menuLayout->itemAt(index))) {
|
||||
return 0;
|
||||
}
|
||||
return static_cast<QtMaterialMenuItem *>(item->widget());
|
||||
}
|
||||
|
||||
int QtMaterialCollapsibleMenu::itemCount() const
|
||||
{
|
||||
Q_D(const QtMaterialCollapsibleMenu);
|
||||
|
||||
return d->menuLayout->count();
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::scrollTo(int dx, int dy)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->scrollArea->horizontalScrollBar()->setValue(dx);
|
||||
d->scrollArea->verticalScrollBar()->setValue(dy);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setExpandXDuration(int duration)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->expandXAnimation()->setDuration(duration);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setExpandXEasingCurve(const QEasingCurve &curve)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->expandXAnimation()->setEasingCurve(curve);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setExpandYDuration(int duration)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->expandYAnimation()->setDuration(duration);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setExpandYEasingCurve(const QEasingCurve &curve)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->expandYAnimation()->setEasingCurve(curve);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setCollapseXDuration(int duration)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->collapseXAnimation()->setDuration(duration);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setCollapseXEasingCurve(const QEasingCurve &curve)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->collapseXAnimation()->setEasingCurve(curve);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setCollapseYDuration(int duration)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->collapseYAnimation()->setDuration(duration);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setCollapseYEasingCurve(const QEasingCurve &curve)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->collapseYAnimation()->setEasingCurve(curve);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setCollapsedXScale(qreal sx)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->collapsedState()->assignProperty(d->proxy, "xScale", sx);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setCollapsedYScale(qreal sy)
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->stateMachine->collapsedState()->assignProperty(d->proxy, "xScale", sy);
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::collapse()
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->proxyStack->setCurrentIndex(1);
|
||||
d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(CollapsibleMenuCollapse));
|
||||
emit aboutToCollapse();
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::expand()
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->proxyStack->setCurrentIndex(1);
|
||||
d->stateMachine->postEvent(new QtMaterialStateTransitionEvent(CollapsibleMenuExpand));
|
||||
emit aboutToExpand();
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::menuItemClicked()
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
QWidget *widget = static_cast<QWidget *>(sender());
|
||||
if (widget) {
|
||||
int index = d->menuLayout->indexOf(widget);
|
||||
emit itemClicked(index);
|
||||
}
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenu::setOpaque()
|
||||
{
|
||||
Q_D(QtMaterialCollapsibleMenu);
|
||||
|
||||
d->proxyStack->setCurrentIndex(0);
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
#ifndef QTMATERIALCOLLAPSIBLEMENU_H
|
||||
#define QTMATERIALCOLLAPSIBLEMENU_H
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class QtMaterialCollapsibleMenuPrivate;
|
||||
class QtMaterialMenuItem;
|
||||
|
||||
class QtMaterialCollapsibleMenu : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QtMaterialCollapsibleMenu(QWidget *parent = 0);
|
||||
~QtMaterialCollapsibleMenu();
|
||||
|
||||
void addMenuItem(const QString &text);
|
||||
void addMenuItem(QtMaterialMenuItem *item);
|
||||
|
||||
QtMaterialMenuItem *menuItemAt(int index) const;
|
||||
int itemCount() const;
|
||||
|
||||
void scrollTo(int dx, int dy);
|
||||
|
||||
void setExpandXDuration(int duration);
|
||||
void setExpandXEasingCurve(const QEasingCurve &curve);
|
||||
|
||||
void setExpandYDuration(int duration);
|
||||
void setExpandYEasingCurve(const QEasingCurve &curve);
|
||||
|
||||
void setCollapseXDuration(int duration);
|
||||
void setCollapseXEasingCurve(const QEasingCurve &curve);
|
||||
|
||||
void setCollapseYDuration(int duration);
|
||||
void setCollapseYEasingCurve(const QEasingCurve &curve);
|
||||
|
||||
void setCollapsedXScale(qreal sx);
|
||||
void setCollapsedYScale(qreal sy);
|
||||
|
||||
signals:
|
||||
void aboutToExpand();
|
||||
void aboutToCollapse();
|
||||
void wasExpanded();
|
||||
void wasCollapsed();
|
||||
void itemClicked(int index);
|
||||
|
||||
public slots:
|
||||
void collapse();
|
||||
void expand();
|
||||
void menuItemClicked();
|
||||
|
||||
protected slots:
|
||||
void setOpaque();
|
||||
|
||||
protected:
|
||||
const QScopedPointer<QtMaterialCollapsibleMenuPrivate> d_ptr;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QtMaterialCollapsibleMenu)
|
||||
Q_DECLARE_PRIVATE(QtMaterialCollapsibleMenu)
|
||||
};
|
||||
|
||||
#endif // QTMATERIALCOLLAPSIBLEMENU_H
|
|
@ -1,145 +0,0 @@
|
|||
#include "qtmaterialcollapsiblemenu_internal.h"
|
||||
#include <QPropertyAnimation>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include "qtmaterialcollapsiblemenu.h"
|
||||
#include "lib/qtmaterialstatetransition.h"
|
||||
|
||||
/*!
|
||||
* \class QtMaterialCollapsibleMenuStateMachine
|
||||
* \internal
|
||||
*/
|
||||
|
||||
QtMaterialCollapsibleMenuStateMachine::QtMaterialCollapsibleMenuStateMachine(
|
||||
QtMaterialCollapsibleMenuProxy *proxy,
|
||||
QtMaterialCollapsibleMenu *parent)
|
||||
: QStateMachine(parent),
|
||||
m_menu(parent),
|
||||
m_proxy(proxy),
|
||||
m_expandedState(new QState),
|
||||
m_collapsedState(new QState),
|
||||
m_expandXAnimation(new QPropertyAnimation(this)),
|
||||
m_expandYAnimation(new QPropertyAnimation(this)),
|
||||
m_collapseXAnimation(new QPropertyAnimation(this)),
|
||||
m_collapseYAnimation(new QPropertyAnimation(this))
|
||||
{
|
||||
Q_ASSERT(parent);
|
||||
|
||||
addState(m_expandedState);
|
||||
addState(m_collapsedState);
|
||||
setInitialState(m_collapsedState);
|
||||
|
||||
QtMaterialStateTransition *transition;
|
||||
QPropertyAnimation *animation;
|
||||
|
||||
transition = new QtMaterialStateTransition(CollapsibleMenuExpand);
|
||||
transition->setTargetState(m_expandedState);
|
||||
m_collapsedState->addTransition(transition);
|
||||
|
||||
m_expandXAnimation->setTargetObject(m_proxy);
|
||||
m_expandXAnimation->setPropertyName("xScale");
|
||||
m_expandXAnimation->setDuration(200);
|
||||
m_expandXAnimation->setEasingCurve(QEasingCurve::OutQuad);
|
||||
transition->addAnimation(m_expandXAnimation);
|
||||
|
||||
m_expandYAnimation->setTargetObject(m_proxy);
|
||||
m_expandYAnimation->setPropertyName("yScale");
|
||||
m_expandYAnimation->setDuration(600);
|
||||
m_expandYAnimation->setEasingCurve(QEasingCurve::OutElastic);
|
||||
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->setTargetState(m_collapsedState);
|
||||
m_expandedState->addTransition(transition);
|
||||
|
||||
m_collapseXAnimation->setTargetObject(m_proxy);
|
||||
m_collapseXAnimation->setPropertyName("xScale");
|
||||
m_collapseXAnimation->setDuration(400);
|
||||
m_collapseXAnimation->setEasingCurve(QEasingCurve::OutQuad);
|
||||
transition->addAnimation(m_collapseXAnimation);
|
||||
|
||||
m_collapseYAnimation->setTargetObject(m_proxy);
|
||||
m_collapseYAnimation->setPropertyName("yScale");
|
||||
m_collapseYAnimation->setDuration(500);
|
||||
m_collapseYAnimation->setEasingCurve(QEasingCurve::OutQuad);
|
||||
transition->addAnimation(m_collapseYAnimation);
|
||||
|
||||
m_expandedState->assignProperty(m_proxy, "xScale", 1);
|
||||
m_expandedState->assignProperty(m_proxy, "yScale", 1);
|
||||
m_expandedState->assignProperty(m_proxy, "opacity", 1);
|
||||
|
||||
m_collapsedState->assignProperty(m_proxy, "xScale", 0.5);
|
||||
m_collapsedState->assignProperty(m_proxy, "yScale", 0.05);
|
||||
m_collapsedState->assignProperty(m_proxy, "opacity", 0);
|
||||
|
||||
animation = new QPropertyAnimation(this);
|
||||
animation->setTargetObject(m_proxy);
|
||||
animation->setPropertyName("opacity");
|
||||
animation->setDuration(140);
|
||||
transition->addAnimation(animation);
|
||||
|
||||
connect(m_expandedState, SIGNAL(propertiesAssigned()),
|
||||
m_menu, SLOT(setOpaque()));
|
||||
connect(m_expandedState, SIGNAL(propertiesAssigned()),
|
||||
m_menu, SIGNAL(wasExpanded()));
|
||||
connect(m_collapsedState, SIGNAL(propertiesAssigned()),
|
||||
m_menu, SIGNAL(wasCollapsed()));
|
||||
}
|
||||
|
||||
QtMaterialCollapsibleMenuStateMachine::~QtMaterialCollapsibleMenuStateMachine()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class QtMaterialCollapsibleMenuProxy
|
||||
* \internal
|
||||
*/
|
||||
|
||||
QtMaterialCollapsibleMenuProxy::QtMaterialCollapsibleMenuProxy(
|
||||
QWidget *source,
|
||||
QGraphicsDropShadowEffect *effect,
|
||||
QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_source(source),
|
||||
m_effect(effect),
|
||||
m_sx(0),
|
||||
m_sy(0),
|
||||
m_opacity(0)
|
||||
{
|
||||
}
|
||||
|
||||
QtMaterialCollapsibleMenuProxy::~QtMaterialCollapsibleMenuProxy()
|
||||
{
|
||||
}
|
||||
|
||||
QSize QtMaterialCollapsibleMenuProxy::sizeHint() const
|
||||
{
|
||||
if (!m_source) {
|
||||
return QWidget::sizeHint();
|
||||
}
|
||||
return m_source->sizeHint();
|
||||
}
|
||||
|
||||
void QtMaterialCollapsibleMenuProxy::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
QRect r(rect());
|
||||
QPixmap pm = m_source->grab(r.translated(-m_source->pos())).scaled(
|
||||
static_cast<qreal>(r.width())*m_sx,
|
||||
static_cast<qreal>(r.height())*m_sy,
|
||||
Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
|
||||
painter.setOpacity(m_opacity);
|
||||
painter.drawPixmap(0, 0, pm);
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
#ifndef QTMATERIALCOLLAPSIBLEMENU_INTERNAL_H
|
||||
#define QTMATERIALCOLLAPSIBLEMENU_INTERNAL_H
|
||||
|
||||
#include <QStateMachine>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtWidgets/QGraphicsDropShadowEffect>
|
||||
#include <cmath>
|
||||
|
||||
class QState;
|
||||
class QPropertyAnimation;
|
||||
class QtMaterialCollapsibleMenu;
|
||||
class QtMaterialCollapsibleMenuProxy;
|
||||
|
||||
class QtMaterialCollapsibleMenuStateMachine : public QStateMachine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtMaterialCollapsibleMenuStateMachine(QtMaterialCollapsibleMenuProxy *proxy, QtMaterialCollapsibleMenu *parent);
|
||||
~QtMaterialCollapsibleMenuStateMachine();
|
||||
|
||||
inline QState *expandedState() const;
|
||||
inline QState *collapsedState() const;
|
||||
inline QPropertyAnimation *expandXAnimation() const;
|
||||
inline QPropertyAnimation *expandYAnimation() const;
|
||||
inline QPropertyAnimation *collapseXAnimation() const;
|
||||
inline QPropertyAnimation *collapseYAnimation() const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QtMaterialCollapsibleMenuStateMachine)
|
||||
|
||||
QtMaterialCollapsibleMenu *const m_menu;
|
||||
QtMaterialCollapsibleMenuProxy *const m_proxy;
|
||||
QState *const m_expandedState;
|
||||
QState *const m_collapsedState;
|
||||
QPropertyAnimation *const m_expandXAnimation;
|
||||
QPropertyAnimation *const m_expandYAnimation;
|
||||
QPropertyAnimation *const m_collapseXAnimation;
|
||||
QPropertyAnimation *const m_collapseYAnimation;
|
||||
};
|
||||
|
||||
inline QState *QtMaterialCollapsibleMenuStateMachine::expandedState() const
|
||||
{
|
||||
return m_expandedState;
|
||||
}
|
||||
|
||||
inline QState *QtMaterialCollapsibleMenuStateMachine::collapsedState() const
|
||||
{
|
||||
return m_collapsedState;
|
||||
}
|
||||
|
||||
inline QPropertyAnimation *QtMaterialCollapsibleMenuStateMachine::expandXAnimation() const
|
||||
{
|
||||
return m_expandXAnimation;
|
||||
}
|
||||
|
||||
inline QPropertyAnimation *QtMaterialCollapsibleMenuStateMachine::expandYAnimation() const
|
||||
{
|
||||
return m_expandYAnimation;
|
||||
}
|
||||
|
||||
inline QPropertyAnimation *QtMaterialCollapsibleMenuStateMachine::collapseXAnimation() const
|
||||
{
|
||||
return m_collapseXAnimation;
|
||||
}
|
||||
|
||||
inline QPropertyAnimation *QtMaterialCollapsibleMenuStateMachine::collapseYAnimation() const
|
||||
{
|
||||
return m_collapseYAnimation;
|
||||
}
|
||||
|
||||
class QGraphicsDropShadowEffect;
|
||||
|
||||
class QtMaterialCollapsibleMenuProxy : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qreal xScale WRITE setXScale READ xScale)
|
||||
Q_PROPERTY(qreal yScale WRITE setYScale READ yScale)
|
||||
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
|
||||
|
||||
public:
|
||||
QtMaterialCollapsibleMenuProxy(QWidget *source, QGraphicsDropShadowEffect *effect, QWidget *parent = 0);
|
||||
~QtMaterialCollapsibleMenuProxy();
|
||||
|
||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
inline void setXScale(qreal sx);
|
||||
inline qreal xScale() const;
|
||||
|
||||
inline void setYScale(qreal sy);
|
||||
inline qreal yScale() const;
|
||||
|
||||
inline void setOpacity(qreal opacity);
|
||||
inline qreal opacity() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QtMaterialCollapsibleMenuProxy)
|
||||
|
||||
QWidget *const m_source;
|
||||
QGraphicsDropShadowEffect *const m_effect;
|
||||
qreal m_sx;
|
||||
qreal m_sy;
|
||||
qreal m_opacity;
|
||||
};
|
||||
|
||||
inline void QtMaterialCollapsibleMenuProxy::setXScale(qreal sx)
|
||||
{
|
||||
m_sx = sx;
|
||||
update();
|
||||
m_effect->update();
|
||||
}
|
||||
|
||||
inline qreal QtMaterialCollapsibleMenuProxy::xScale() const
|
||||
{
|
||||
return m_sx;
|
||||
}
|
||||
|
||||
inline void QtMaterialCollapsibleMenuProxy::setYScale(qreal sy)
|
||||
{
|
||||
m_sy = sy;
|
||||
update();
|
||||
m_effect->update();
|
||||
}
|
||||
|
||||
inline qreal QtMaterialCollapsibleMenuProxy::yScale() const
|
||||
{
|
||||
return m_sy;
|
||||
}
|
||||
|
||||
inline void QtMaterialCollapsibleMenuProxy::setOpacity(qreal opacity)
|
||||
{
|
||||
m_opacity = opacity;
|
||||
m_effect->setColor(QColor(0, 0, 0, 100*(pow(opacity, 5))));
|
||||
m_effect->update();
|
||||
update();
|
||||
}
|
||||
|
||||
inline qreal QtMaterialCollapsibleMenuProxy::opacity() const
|
||||
{
|
||||
return m_opacity;
|
||||
}
|
||||
|
||||
#endif // QTMATERIALCOLLAPSIBLEMENU_INTERNAL_H
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef QTMATERIALCOLLAPSIBLEMENU_P_H
|
||||
#define QTMATERIALCOLLAPSIBLEMENU_P_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
class QScrollArea;
|
||||
class QWidget;
|
||||
class QVBoxLayout;
|
||||
class QStackedLayout;
|
||||
class QtMaterialCollapsibleMenu;
|
||||
class QtMaterialCollapsibleMenuStateMachine;
|
||||
class QtMaterialCollapsibleMenuProxy;
|
||||
|
||||
class QtMaterialCollapsibleMenuPrivate
|
||||
{
|
||||
Q_DISABLE_COPY(QtMaterialCollapsibleMenuPrivate)
|
||||
Q_DECLARE_PUBLIC(QtMaterialCollapsibleMenu)
|
||||
|
||||
public:
|
||||
QtMaterialCollapsibleMenuPrivate(QtMaterialCollapsibleMenu *q);
|
||||
~QtMaterialCollapsibleMenuPrivate();
|
||||
|
||||
void init();
|
||||
|
||||
QtMaterialCollapsibleMenu *const q_ptr;
|
||||
QScrollArea *scrollArea;
|
||||
QWidget *mainWidget;
|
||||
QVBoxLayout *menuLayout;
|
||||
QtMaterialCollapsibleMenuProxy *proxy;
|
||||
QtMaterialCollapsibleMenuStateMachine *stateMachine;
|
||||
QStackedLayout *proxyStack;
|
||||
};
|
||||
|
||||
#endif // QTMATERIALCOLLAPSIBLEMENU_P_H
|
|
@ -1,169 +0,0 @@
|
|||
#include "qtmaterialiconmenu.h"
|
||||
#include "qtmaterialiconmenu_p.h"
|
||||
#include <QEvent>
|
||||
#include <QTimer>
|
||||
#include "lib/qtmaterialoverlaywidget.h"
|
||||
#include "qtmaterialcollapsiblemenu.h"
|
||||
|
||||
/*!
|
||||
* \class QtMaterialIconMenuPrivate
|
||||
* \internal
|
||||
*/
|
||||
|
||||
QtMaterialIconMenuPrivate::QtMaterialIconMenuPrivate(QtMaterialIconMenu *q)
|
||||
: QtMaterialIconButtonPrivate(q)
|
||||
{
|
||||
}
|
||||
|
||||
QtMaterialIconMenuPrivate::~QtMaterialIconMenuPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
void QtMaterialIconMenuPrivate::init()
|
||||
{
|
||||
Q_Q(QtMaterialIconMenu);
|
||||
|
||||
menuOverlay = new QtMaterialOverlayWidget(q);
|
||||
menu = new QtMaterialCollapsibleMenu;
|
||||
autoCollapse = true;
|
||||
|
||||
menuOverlay->setParent(q->parentWidget());
|
||||
menuOverlay->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
menuOverlay->installEventFilter(q);
|
||||
|
||||
menu->setParent(menuOverlay);
|
||||
menu->setMaximumHeight(300);
|
||||
menu->setMinimumWidth(200);
|
||||
|
||||
QObject::connect(menu, SIGNAL(aboutToCollapse()), q, SLOT(makeTransparent()));
|
||||
QObject::connect(menu, SIGNAL(wasExpanded()), q, SLOT(makeOpaque()));
|
||||
QObject::connect(menu, SIGNAL(aboutToExpand()), menuOverlay, SLOT(raise()));
|
||||
QObject::connect(menu, SIGNAL(itemClicked(int)), q, SIGNAL(itemSelected(int)));
|
||||
QObject::connect(menu, SIGNAL(itemClicked(int)), q, SLOT(collapseDelayed()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class QtMaterialIconMenu
|
||||
*/
|
||||
|
||||
QtMaterialIconMenu::QtMaterialIconMenu(const QIcon &icon, QWidget *parent)
|
||||
: QtMaterialIconButton(*new QtMaterialIconMenuPrivate(this), parent)
|
||||
{
|
||||
d_func()->init();
|
||||
|
||||
setIcon(icon);
|
||||
}
|
||||
|
||||
QtMaterialIconMenu::~QtMaterialIconMenu()
|
||||
{
|
||||
}
|
||||
|
||||
void QtMaterialIconMenu::addMenuItem(const QString &text)
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
d->menu->addMenuItem(text);
|
||||
}
|
||||
|
||||
void QtMaterialIconMenu::addMenuItem(QtMaterialMenuItem *item)
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
d->menu->addMenuItem(item);
|
||||
}
|
||||
|
||||
QtMaterialMenuItem *QtMaterialIconMenu::itemAt(int index) const
|
||||
{
|
||||
Q_D(const QtMaterialIconMenu);
|
||||
|
||||
return d->menu->menuItemAt(index);
|
||||
}
|
||||
|
||||
void QtMaterialIconMenu::setAutoCollapse(bool value)
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
d->autoCollapse = value;
|
||||
}
|
||||
|
||||
bool QtMaterialIconMenu::autoCollapse() const
|
||||
{
|
||||
Q_D(const QtMaterialIconMenu);
|
||||
|
||||
return d->autoCollapse;
|
||||
}
|
||||
|
||||
void QtMaterialIconMenu::makeTransparent()
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
d->menuOverlay->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||
}
|
||||
|
||||
void QtMaterialIconMenu::makeOpaque()
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
d->menuOverlay->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||
}
|
||||
|
||||
void QtMaterialIconMenu::collapseDelayed()
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
if (d->autoCollapse) {
|
||||
QTimer::singleShot(110, d->menu, SLOT(collapse()));
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \reimp
|
||||
*/
|
||||
bool QtMaterialIconMenu::event(QEvent *event)
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::Move:
|
||||
case QEvent::Resize:
|
||||
{
|
||||
const QSize sh = d->menu->sizeHint();
|
||||
QPoint p = pos();
|
||||
p += QPoint(width()/2, height()/2);
|
||||
d->menu->setGeometry(p.x(), p.y(), sh.width(), sh.height());
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonRelease:
|
||||
{
|
||||
if (isEnabled()) {
|
||||
d->menu->expand();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QEvent::ParentChange:
|
||||
{
|
||||
QWidget *widget;
|
||||
if ((widget = parentWidget())) {
|
||||
d->menuOverlay->setParent(widget);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QtMaterialIconButton::event(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \reimp
|
||||
*/
|
||||
bool QtMaterialIconMenu::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
Q_D(QtMaterialIconMenu);
|
||||
|
||||
if (QEvent::MouseButtonPress == event->type()) {
|
||||
d->menu->collapse();
|
||||
}
|
||||
return QtMaterialIconButton::eventFilter(obj, event);
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef QTMATERIALICONMENU_H
|
||||
#define QTMATERIALICONMENU_H
|
||||
|
||||
#include "qtmaterialiconbutton.h"
|
||||
|
||||
class QtMaterialIconMenuPrivate;
|
||||
class QtMaterialMenuItem;
|
||||
|
||||
class QtMaterialIconMenu : public QtMaterialIconButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QtMaterialIconMenu(const QIcon &icon, QWidget *parent = 0);
|
||||
~QtMaterialIconMenu();
|
||||
|
||||
void addMenuItem(const QString &text);
|
||||
void addMenuItem(QtMaterialMenuItem *item);
|
||||
|
||||
QtMaterialMenuItem *itemAt(int index) const;
|
||||
|
||||
void setAutoCollapse(bool value);
|
||||
bool autoCollapse() const;
|
||||
|
||||
signals:
|
||||
void itemSelected(int index);
|
||||
|
||||
protected slots:
|
||||
void makeTransparent();
|
||||
void makeOpaque();
|
||||
void collapseDelayed();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||
bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QtMaterialIconMenu)
|
||||
Q_DECLARE_PRIVATE(QtMaterialIconMenu)
|
||||
};
|
||||
|
||||
#endif // QTMATERIALICONMENU_H
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef QTMATERIALICONMENU_P_H
|
||||
#define QTMATERIALICONMENU_P_H
|
||||
|
||||
#include "qtmaterialiconbutton_p.h"
|
||||
|
||||
class QtMaterialIconMenu;
|
||||
class QtMaterialOverlayWidget;
|
||||
class QtMaterialCollapsibleMenu;
|
||||
|
||||
class QtMaterialIconMenuPrivate : public QtMaterialIconButtonPrivate
|
||||
{
|
||||
Q_DISABLE_COPY(QtMaterialIconMenuPrivate)
|
||||
Q_DECLARE_PUBLIC(QtMaterialIconMenu)
|
||||
|
||||
public:
|
||||
QtMaterialIconMenuPrivate(QtMaterialIconMenu *q);
|
||||
~QtMaterialIconMenuPrivate();
|
||||
|
||||
void init();
|
||||
|
||||
QtMaterialOverlayWidget *menuOverlay;
|
||||
QtMaterialCollapsibleMenu *menu;
|
||||
bool autoCollapse;
|
||||
};
|
||||
|
||||
#endif // QTMATERIALICONMENU_P_H
|
|
@ -1,383 +0,0 @@
|
|||
#include "qtmaterialselectfield.h"
|
||||
#include "qtmaterialselectfield_p.h"
|
||||
#include <QEvent>
|
||||
#include <QFontDatabase>
|
||||
#include <QEasingCurve>
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
#include "lib/qtmaterialstyle.h"
|
||||
#include "qtmaterialmenuitem.h"
|
||||
#include "qtmaterialcollapsiblemenu.h"
|
||||
#include "lib/qtmaterialoverlaywidget.h"
|
||||
|
||||
/*!
|
||||
* \class QtMaterialSelectFieldPrivate
|
||||
* \internal
|
||||
*/
|
||||
|
||||
QtMaterialSelectFieldPrivate::QtMaterialSelectFieldPrivate(QtMaterialSelectField *q)
|
||||
: q_ptr(q)
|
||||
{
|
||||
}
|
||||
|
||||
QtMaterialSelectFieldPrivate::~QtMaterialSelectFieldPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
void QtMaterialSelectFieldPrivate::init()
|
||||
{
|
||||
Q_Q(QtMaterialSelectField);
|
||||
|
||||
menuOverlay = new QtMaterialOverlayWidget(q);
|
||||
menu = new QtMaterialCollapsibleMenu;
|
||||
selectedIndex = -1;
|
||||
useThemeColors = true;
|
||||
|
||||
q->setStyle(&QtMaterialStyle::instance());
|
||||
|
||||
QFontDatabase db;
|
||||
QFont font(db.font("Roboto", "Regular", 11));
|
||||
q->setFont(font);
|
||||
|
||||
menuOverlay->setParent(q->parentWidget());
|
||||
menuOverlay->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
menuOverlay->installEventFilter(q);
|
||||
|
||||
menu->setParent(menuOverlay);
|
||||
menu->setMaximumHeight(300);
|
||||
menu->setCollapsedXScale(1);
|
||||
menu->setExpandYDuration(280);
|
||||
menu->setExpandYEasingCurve(QEasingCurve::OutQuad);
|
||||
|
||||
QObject::connect(menu, SIGNAL(aboutToCollapse()), q, SLOT(makeTransparent()));
|
||||
QObject::connect(menu, SIGNAL(wasExpanded()), q, SLOT(makeOpaque()));
|
||||
QObject::connect(menu, SIGNAL(aboutToExpand()), menuOverlay, SLOT(raise()));
|
||||
QObject::connect(menu, SIGNAL(itemClicked(int)), q, SLOT(setSelectedIndex(int)));
|
||||
QObject::connect(menu, SIGNAL(itemClicked(int)), q, SLOT(collapseDelayed()));
|
||||
QObject::connect(menu, SIGNAL(itemClicked(int)), q, SIGNAL(itemSelected(int)));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \class QtMaterialSelectField
|
||||
*/
|
||||
|
||||
QtMaterialSelectField::QtMaterialSelectField(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
d_ptr(new QtMaterialSelectFieldPrivate(this))
|
||||
{
|
||||
d_func()->init();
|
||||
}
|
||||
|
||||
QtMaterialSelectField::~QtMaterialSelectField()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \reimp
|
||||
*/
|
||||
QSize QtMaterialSelectField::sizeHint() const
|
||||
{
|
||||
return QSize(300, 30);
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::addItem(const QString &text)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
QtMaterialMenuItem *item = new QtMaterialMenuItem;
|
||||
item->setText(text);
|
||||
item->setHaloVisible(false);
|
||||
|
||||
d->menu->addMenuItem(item);
|
||||
}
|
||||
|
||||
QtMaterialMenuItem *QtMaterialSelectField::itemAt(int index) const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
return d->menu->menuItemAt(index);
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setPlaceholderText(const QString &text)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->placeholderText = text;
|
||||
update();
|
||||
}
|
||||
|
||||
QString QtMaterialSelectField::placeholderText() const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
return d->placeholderText;
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setUseThemeColors(bool value)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
if (d->useThemeColors == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->useThemeColors = value;
|
||||
update();
|
||||
}
|
||||
|
||||
bool QtMaterialSelectField::useThemeColors() const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
return d->useThemeColors;
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setUnderlineColor(const QColor &color)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->underlineColor = color;
|
||||
|
||||
MATERIAL_DISABLE_THEME_COLORS
|
||||
update();
|
||||
}
|
||||
|
||||
QColor QtMaterialSelectField::underlineColor() const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
if (d->useThemeColors || !d->underlineColor.isValid()) {
|
||||
return QtMaterialStyle::instance().themeColor("border");
|
||||
}
|
||||
return d->underlineColor;
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setPlaceholderColor(const QColor &color)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->placeholderColor = color;
|
||||
|
||||
MATERIAL_DISABLE_THEME_COLORS
|
||||
update();
|
||||
}
|
||||
|
||||
QColor QtMaterialSelectField::placeholderColor() const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
if (d->useThemeColors || !d->placeholderColor.isValid()) {
|
||||
return QtMaterialStyle::instance().themeColor("accent3");
|
||||
}
|
||||
return d->placeholderColor;
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setForegroundColor(const QColor &color)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->foregroundColor = color;
|
||||
|
||||
MATERIAL_DISABLE_THEME_COLORS
|
||||
update();
|
||||
}
|
||||
|
||||
QColor QtMaterialSelectField::foregroundColor() const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
if (d->useThemeColors || !d->foregroundColor.isValid()) {
|
||||
return QtMaterialStyle::instance().themeColor("text");
|
||||
}
|
||||
return d->foregroundColor;
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setHighlightedColor(const QColor &color)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->highlightedColor = color;
|
||||
|
||||
MATERIAL_DISABLE_THEME_COLORS
|
||||
update();
|
||||
}
|
||||
|
||||
QColor QtMaterialSelectField::highlightedColor() const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
if (d->useThemeColors || !d->highlightedColor.isValid()) {
|
||||
return QtMaterialStyle::instance().themeColor("primary1");
|
||||
}
|
||||
return d->highlightedColor;
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setDisabledColor(const QColor &color)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->disabledColor = color;
|
||||
|
||||
MATERIAL_DISABLE_THEME_COLORS
|
||||
update();
|
||||
}
|
||||
|
||||
QColor QtMaterialSelectField::disabledColor() const
|
||||
{
|
||||
Q_D(const QtMaterialSelectField);
|
||||
|
||||
if (d->useThemeColors || !d->disabledColor.isValid()) {
|
||||
return QtMaterialStyle::instance().themeColor("disabled");
|
||||
}
|
||||
return d->disabledColor;
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::setSelectedIndex(int index)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
QtMaterialMenuItem *menuItem;
|
||||
|
||||
if (d->selectedIndex > -1 && (menuItem = d->menu->menuItemAt(d->selectedIndex))) {
|
||||
menuItem->setHighlighted(false);
|
||||
}
|
||||
if (index > -1 && (menuItem = d->menu->menuItemAt(index))) {
|
||||
menuItem->setHighlighted(true);
|
||||
d->selectedText = menuItem->text();
|
||||
}
|
||||
d->selectedIndex = index;
|
||||
update();
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::clearSelection()
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
setSelectedIndex(-1);
|
||||
d->selectedText.clear();
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::makeTransparent()
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->menuOverlay->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::makeOpaque()
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
d->menuOverlay->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||
}
|
||||
|
||||
void QtMaterialSelectField::collapseDelayed()
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
QTimer::singleShot(100, d->menu, SLOT(collapse()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \reimp
|
||||
*/
|
||||
bool QtMaterialSelectField::event(QEvent *event)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::Move:
|
||||
case QEvent::Resize:
|
||||
{
|
||||
const QSize sh = d->menu->sizeHint();
|
||||
d->menu->setGeometry(x(), y(), width(), sh.height());
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonRelease:
|
||||
{
|
||||
if (isEnabled()) {
|
||||
QtMaterialMenuItem *item;
|
||||
for (int i = 0; i < d->menu->itemCount(); ++i) {
|
||||
item = d->menu->menuItemAt(i);
|
||||
if (item->isHighlighted()) {
|
||||
item->setForegroundColor(highlightedColor());
|
||||
} else {
|
||||
item->setForegroundColor(foregroundColor());
|
||||
}
|
||||
}
|
||||
d->menu->expand();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QEvent::ParentChange:
|
||||
{
|
||||
QWidget *widget;
|
||||
if ((widget = parentWidget())) {
|
||||
d->menuOverlay->setParent(widget);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \reimp
|
||||
*/
|
||||
bool QtMaterialSelectField::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
if (QEvent::MouseButtonPress == event->type()) {
|
||||
d->menu->collapse();
|
||||
}
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \reimp
|
||||
*/
|
||||
void QtMaterialSelectField::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
Q_D(QtMaterialSelectField);
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
const int y = height()-1;
|
||||
const int wd = width()-5;
|
||||
|
||||
if (d->selectedText.isEmpty() && !d->placeholderText.isEmpty()) {
|
||||
if (isEnabled()) {
|
||||
painter.setPen(placeholderColor());
|
||||
} else {
|
||||
painter.setPen(disabledColor());
|
||||
}
|
||||
painter.drawText(2, y-8, d->placeholderText);
|
||||
} else {
|
||||
painter.drawText(2, y-8, d->selectedText);
|
||||
}
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth(1);
|
||||
pen.setColor(underlineColor());
|
||||
painter.setPen(pen);
|
||||
painter.setOpacity(1);
|
||||
painter.drawLine(2.5, y, wd, y);
|
||||
|
||||
if (isEnabled())
|
||||
{
|
||||
static const int points[] = { wd-14, 12, wd-4, 12, wd-9, 18 };
|
||||
|
||||
QPolygon polygon;
|
||||
polygon.setPoints(3, points);
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(underlineColor());
|
||||
painter.drawPolygon(polygon);
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
#ifndef QTMATERIALSELECTFIELD_H
|
||||
#define QTMATERIALSELECTFIELD_H
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
class QtMaterialSelectFieldPrivate;
|
||||
class QtMaterialMenuItem;
|
||||
|
||||
class QtMaterialSelectField : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QtMaterialSelectField(QWidget *parent = 0);
|
||||
~QtMaterialSelectField();
|
||||
|
||||
QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
void addItem(const QString &text);
|
||||
QtMaterialMenuItem *itemAt(int index) const;
|
||||
|
||||
void setPlaceholderText(const QString &text);
|
||||
QString placeholderText() const;
|
||||
|
||||
void setUseThemeColors(bool value);
|
||||
bool useThemeColors() const;
|
||||
|
||||
void setUnderlineColor(const QColor &color);
|
||||
QColor underlineColor() const;
|
||||
|
||||
void setPlaceholderColor(const QColor &color);
|
||||
QColor placeholderColor() const;
|
||||
|
||||
void setForegroundColor(const QColor &color);
|
||||
QColor foregroundColor() const;
|
||||
|
||||
void setHighlightedColor(const QColor &color);
|
||||
QColor highlightedColor() const;
|
||||
|
||||
void setDisabledColor(const QColor &color);
|
||||
QColor disabledColor() const;
|
||||
|
||||
signals:
|
||||
void itemSelected(int index);
|
||||
|
||||
public slots:
|
||||
void setSelectedIndex(int index);
|
||||
void clearSelection();
|
||||
|
||||
protected slots:
|
||||
void makeTransparent();
|
||||
void makeOpaque();
|
||||
void collapseDelayed();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) Q_DECL_OVERRIDE;
|
||||
bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
|
||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||
|
||||
const QScopedPointer<QtMaterialSelectFieldPrivate> d_ptr;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QtMaterialSelectField)
|
||||
Q_DECLARE_PRIVATE(QtMaterialSelectField)
|
||||
};
|
||||
|
||||
#endif // QTMATERIALSELECTFIELD_H
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef QTMATERIALSELECTFIELD_P_H
|
||||
#define QTMATERIALSELECTFIELD_P_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
|
||||
class QtMaterialSelectField;
|
||||
class QtMaterialOverlayWidget;
|
||||
class QtMaterialCollapsibleMenu;
|
||||
|
||||
class QtMaterialSelectFieldPrivate
|
||||
{
|
||||
Q_DISABLE_COPY(QtMaterialSelectFieldPrivate)
|
||||
Q_DECLARE_PUBLIC(QtMaterialSelectField)
|
||||
|
||||
public:
|
||||
QtMaterialSelectFieldPrivate(QtMaterialSelectField *q);
|
||||
~QtMaterialSelectFieldPrivate();
|
||||
|
||||
void init();
|
||||
|
||||
QtMaterialSelectField *const q_ptr;
|
||||
QtMaterialOverlayWidget *menuOverlay;
|
||||
QtMaterialCollapsibleMenu *menu;
|
||||
QString selectedText;
|
||||
QString placeholderText;
|
||||
QColor underlineColor;
|
||||
QColor placeholderColor;
|
||||
QColor foregroundColor;
|
||||
QColor highlightedColor;
|
||||
QColor disabledColor;
|
||||
int selectedIndex;
|
||||
bool useThemeColors;
|
||||
};
|
||||
|
||||
#endif // QTMATERIALSELECTFIELD_P_H
|
|
@ -15,9 +15,7 @@ SOURCES = mainwindow.cpp \
|
|||
radiobuttonsettingseditor.cpp \
|
||||
togglesettingseditor.cpp \
|
||||
textfieldsettingseditor.cpp \
|
||||
tabssettingseditor.cpp \
|
||||
selectfieldsettingseditor.cpp \
|
||||
iconmenusettingseditor.cpp
|
||||
tabssettingseditor.cpp
|
||||
HEADERS = mainwindow.h \
|
||||
avatarsettingseditor.h \
|
||||
badgesettingseditor.h \
|
||||
|
@ -32,9 +30,7 @@ HEADERS = mainwindow.h \
|
|||
radiobuttonsettingseditor.h \
|
||||
togglesettingseditor.h \
|
||||
textfieldsettingseditor.h \
|
||||
tabssettingseditor.h \
|
||||
selectfieldsettingseditor.h \
|
||||
iconmenusettingseditor.h
|
||||
tabssettingseditor.h
|
||||
LIBS += ../components/libcomponents.a
|
||||
INCLUDEPATH += ../components/
|
||||
TARGET = ../examples-exe
|
||||
|
@ -54,6 +50,4 @@ FORMS += \
|
|||
slidersettingsform.ui \
|
||||
radiobuttonsettingsform.ui \
|
||||
togglesettingsform.ui \
|
||||
textfieldsettingsform.ui \
|
||||
selectfieldsettingsform.ui \
|
||||
iconmenusettingsform.ui
|
||||
textfieldsettingsform.ui
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
#include "iconmenusettingseditor.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QColorDialog>
|
||||
#include "qtmaterialiconmenu.h"
|
||||
#include "qtmaterialmenuitem.h"
|
||||
|
||||
IconMenuSettingsEditor::IconMenuSettingsEditor(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::IconMenuSettingsForm),
|
||||
m_iconMenu(new QtMaterialIconMenu(QtMaterialTheme::icon("toggle", "star")))
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
setLayout(layout);
|
||||
|
||||
QWidget *widget = new QWidget;
|
||||
layout->addWidget(widget);
|
||||
|
||||
QWidget *canvas = new QWidget;
|
||||
canvas->setStyleSheet("QWidget { background: white; }");
|
||||
layout->addWidget(canvas);
|
||||
|
||||
ui->setupUi(widget);
|
||||
layout->setContentsMargins(20, 20, 20, 20);
|
||||
|
||||
layout = new QVBoxLayout;
|
||||
canvas->setLayout(layout);
|
||||
layout->addWidget(m_iconMenu);
|
||||
layout->setAlignment(m_iconMenu, Qt::AlignCenter);
|
||||
|
||||
{
|
||||
m_iconMenu->addMenuItem("C");
|
||||
m_iconMenu->addMenuItem("C++");
|
||||
m_iconMenu->addMenuItem("PHP");
|
||||
m_iconMenu->addMenuItem("Haskell");
|
||||
m_iconMenu->addMenuItem("JavaScript");
|
||||
m_iconMenu->addMenuItem("ECMAScript");
|
||||
m_iconMenu->addMenuItem("OCaml");
|
||||
m_iconMenu->addMenuItem("Python");
|
||||
m_iconMenu->addMenuItem("F#");
|
||||
m_iconMenu->addMenuItem("Clojure");
|
||||
m_iconMenu->addMenuItem("Java");
|
||||
|
||||
m_iconMenu->itemAt(2)->setDisabled(true);
|
||||
}
|
||||
|
||||
setupForm();
|
||||
|
||||
connect(ui->disabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget()));
|
||||
connect(ui->autoCollapseCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget()));
|
||||
connect(ui->colorToolButton, SIGNAL(clicked(bool)), this, SLOT(selectColor()));
|
||||
connect(ui->disabledColorToolButton, SIGNAL(clicked(bool)), this, SLOT(selectColor()));
|
||||
}
|
||||
|
||||
IconMenuSettingsEditor::~IconMenuSettingsEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void IconMenuSettingsEditor::setupForm()
|
||||
{
|
||||
ui->disabledCheckBox->setChecked(!m_iconMenu->isEnabled());
|
||||
ui->autoCollapseCheckBox->setChecked(m_iconMenu->autoCollapse());
|
||||
}
|
||||
|
||||
void IconMenuSettingsEditor::updateWidget()
|
||||
{
|
||||
m_iconMenu->setDisabled(ui->disabledCheckBox->isChecked());
|
||||
m_iconMenu->setAutoCollapse(ui->autoCollapseCheckBox->isChecked());
|
||||
}
|
||||
|
||||
void IconMenuSettingsEditor::selectColor()
|
||||
{
|
||||
QColorDialog dialog;
|
||||
if (dialog.exec()) {
|
||||
QColor color = dialog.selectedColor();
|
||||
QString senderName = sender()->objectName();
|
||||
if ("colorToolButton" == senderName) {
|
||||
m_iconMenu->setColor(color);
|
||||
ui->colorLineEdit->setText(color.name(QColor::HexRgb));
|
||||
} else if ("disabledColorToolButton" == senderName) {
|
||||
m_iconMenu->setDisabledColor(color);
|
||||
ui->disabledColorLineEdit->setText(color.name(QColor::HexRgb));
|
||||
}
|
||||
}
|
||||
setupForm();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef ICONMENUSETTINGSEDITOR_H
|
||||
#define ICONMENUSETTINGSEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_iconmenusettingsform.h"
|
||||
|
||||
class QtMaterialIconMenu;
|
||||
|
||||
class IconMenuSettingsEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IconMenuSettingsEditor(QWidget *parent = 0);
|
||||
~IconMenuSettingsEditor();
|
||||
|
||||
protected slots:
|
||||
void setupForm();
|
||||
void updateWidget();
|
||||
void selectColor();
|
||||
|
||||
private:
|
||||
Ui::IconMenuSettingsForm *const ui;
|
||||
QtMaterialIconMenu *const m_iconMenu;
|
||||
};
|
||||
|
||||
#endif // ICONMENUSETTINGSEDITOR_H
|
|
@ -1,101 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IconMenuSettingsForm</class>
|
||||
<widget class="QWidget" name="IconMenuSettingsForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="formLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>160</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="disabledLabel">
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="disabledCheckBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="colorLabel">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="autoCollapseLabel">
|
||||
<property name="text">
|
||||
<string>Auto collapse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="autoCollapseCheckBox"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="colorLineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="colorToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="disabledColorLabel">
|
||||
<property name="text">
|
||||
<string>Disabled color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="disabledColorLineEdit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="disabledColorToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -16,8 +16,6 @@
|
|||
#include "togglesettingseditor.h"
|
||||
#include "textfieldsettingseditor.h"
|
||||
#include "tabssettingseditor.h"
|
||||
#include "selectfieldsettingseditor.h"
|
||||
#include "iconmenusettingseditor.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
|
@ -51,8 +49,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ToggleSettingsEditor *toggle = new ToggleSettingsEditor;
|
||||
TextFieldSettingsEditor *textField = new TextFieldSettingsEditor;
|
||||
TabsSettingsEditor *tabs = new TabsSettingsEditor;
|
||||
SelectFieldSettingsEditor *selectField = new SelectFieldSettingsEditor;
|
||||
IconMenuSettingsEditor *iconMenu = new IconMenuSettingsEditor;
|
||||
|
||||
stack->addWidget(avatar);
|
||||
stack->addWidget(badge);
|
||||
|
@ -61,11 +57,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
stack->addWidget(fab);
|
||||
stack->addWidget(flatButton);
|
||||
stack->addWidget(iconButton);
|
||||
stack->addWidget(iconMenu);
|
||||
stack->addWidget(progress);
|
||||
stack->addWidget(radioButton);
|
||||
stack->addWidget(raisedButton);
|
||||
stack->addWidget(selectField);
|
||||
stack->addWidget(slider);
|
||||
stack->addWidget(tabs);
|
||||
stack->addWidget(textField);
|
||||
|
@ -78,11 +72,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
list->addItem("Floating Action Button");
|
||||
list->addItem("Flat Button");
|
||||
list->addItem("Icon Button");
|
||||
list->addItem("Icon Menu");
|
||||
list->addItem("Progress");
|
||||
list->addItem("Radio Button");
|
||||
list->addItem("Raised Button");
|
||||
list->addItem("Select Field");
|
||||
list->addItem("Slider");
|
||||
list->addItem("Tabs");
|
||||
list->addItem("Text Field");
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
#include "selectfieldsettingseditor.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QColorDialog>
|
||||
#include "qtmaterialselectfield.h"
|
||||
#include "qtmaterialmenuitem.h"
|
||||
|
||||
SelectFieldSettingsEditor::SelectFieldSettingsEditor(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::SelectFieldSettingsForm),
|
||||
m_selectField(new QtMaterialSelectField)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
setLayout(layout);
|
||||
|
||||
QWidget *widget = new QWidget;
|
||||
layout->addWidget(widget);
|
||||
|
||||
QWidget *canvas = new QWidget;
|
||||
canvas->setStyleSheet("QWidget { background: white; }");
|
||||
layout->addWidget(canvas);
|
||||
|
||||
ui->setupUi(widget);
|
||||
layout->setContentsMargins(20, 20, 20, 20);
|
||||
|
||||
layout = new QVBoxLayout;
|
||||
canvas->setLayout(layout);
|
||||
layout->addWidget(m_selectField);
|
||||
layout->setAlignment(m_selectField, Qt::AlignCenter);
|
||||
|
||||
m_selectField->setPlaceholderText("Please select your favorite language");
|
||||
|
||||
{
|
||||
m_selectField->addItem("C");
|
||||
m_selectField->addItem("C++");
|
||||
m_selectField->addItem("PHP");
|
||||
m_selectField->addItem("Haskell");
|
||||
m_selectField->addItem("JavaScript");
|
||||
m_selectField->addItem("ECMAScript");
|
||||
m_selectField->addItem("OCaml");
|
||||
m_selectField->addItem("Python");
|
||||
m_selectField->addItem("F#");
|
||||
m_selectField->addItem("Clojure");
|
||||
m_selectField->addItem("Java");
|
||||
|
||||
m_selectField->itemAt(2)->setDisabled(true);
|
||||
}
|
||||
|
||||
setupForm();
|
||||
|
||||
connect(ui->disabledCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget()));
|
||||
connect(ui->useThemeColorsCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget()));
|
||||
connect(ui->foregroundColorToolButton, SIGNAL(clicked(bool)), this, SLOT(selectColor()));
|
||||
connect(ui->underlineColorToolButton, SIGNAL(clicked(bool)), this, SLOT(selectColor()));
|
||||
connect(ui->placeholderColorToolButton, SIGNAL(clicked(bool)), this, SLOT(selectColor()));
|
||||
connect(ui->highlightedColorToolButton, SIGNAL(clicked(bool)), this, SLOT(selectColor()));
|
||||
connect(ui->disabledColorToolButton, SIGNAL(clicked(bool)), this, SLOT(selectColor()));
|
||||
connect(ui->placeholderLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateWidget()));
|
||||
connect(ui->clearSelectionToolButton, SIGNAL(clicked(bool)), m_selectField, SLOT(clearSelection()));
|
||||
}
|
||||
|
||||
SelectFieldSettingsEditor::~SelectFieldSettingsEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SelectFieldSettingsEditor::setupForm()
|
||||
{
|
||||
ui->disabledCheckBox->setChecked(!m_selectField->isEnabled());
|
||||
ui->useThemeColorsCheckBox->setChecked(m_selectField->useThemeColors());
|
||||
ui->placeholderLineEdit->setText(m_selectField->placeholderText());
|
||||
}
|
||||
|
||||
void SelectFieldSettingsEditor::updateWidget()
|
||||
{
|
||||
m_selectField->setDisabled(ui->disabledCheckBox->isChecked());
|
||||
m_selectField->setUseThemeColors(ui->useThemeColorsCheckBox->isChecked());
|
||||
m_selectField->setPlaceholderText(ui->placeholderLineEdit->text());
|
||||
}
|
||||
|
||||
void SelectFieldSettingsEditor::selectColor()
|
||||
{
|
||||
QColorDialog dialog;
|
||||
if (dialog.exec()) {
|
||||
QColor color = dialog.selectedColor();
|
||||
QString senderName = sender()->objectName();
|
||||
if ("foregroundColorToolButton" == senderName) {
|
||||
m_selectField->setForegroundColor(color);
|
||||
ui->foregroundColorLineEdit->setText(color.name(QColor::HexRgb));
|
||||
} else if ("underlineColorToolButton" == senderName) {
|
||||
m_selectField->setUnderlineColor(color);
|
||||
ui->underlineColorLineEdit->setText(color.name(QColor::HexRgb));
|
||||
} else if ("placeholderColorToolButton" == senderName) {
|
||||
m_selectField->setPlaceholderColor(color);
|
||||
ui->placeholderColorLineEdit->setText(color.name(QColor::HexRgb));
|
||||
} else if ("highlightedColorToolButton" == senderName) {
|
||||
m_selectField->setHighlightedColor(color);
|
||||
ui->highlightedColorLineEdit->setText(color.name(QColor::HexRgb));
|
||||
} else if ("disabledColorToolButton" == senderName) {
|
||||
m_selectField->setDisabledColor(color);
|
||||
ui->disabledColorLineEdit->setText(color.name(QColor::HexRgb));
|
||||
}
|
||||
}
|
||||
setupForm();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
#ifndef SELECTFIELDSETTINGSEDITOR_H
|
||||
#define SELECTFIELDSETTINGSEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_selectfieldsettingsform.h"
|
||||
|
||||
class QtMaterialSelectField;
|
||||
|
||||
class SelectFieldSettingsEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SelectFieldSettingsEditor(QWidget *parent = 0);
|
||||
~SelectFieldSettingsEditor();
|
||||
|
||||
protected slots:
|
||||
void setupForm();
|
||||
void updateWidget();
|
||||
void selectColor();
|
||||
|
||||
private:
|
||||
Ui::SelectFieldSettingsForm *const ui;
|
||||
QtMaterialSelectField *const m_selectField;
|
||||
};
|
||||
|
||||
#endif // SELECTFIELDSETTINGSEDITOR_H
|
|
@ -1,182 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SelectFieldSettingsForm</class>
|
||||
<widget class="QWidget" name="SelectFieldSettingsForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>511</width>
|
||||
<height>388</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="formLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>202</width>
|
||||
<height>253</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="disabledLabel">
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="disabledCheckBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="foregroundColorLabel">
|
||||
<property name="text">
|
||||
<string>Foreground color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="underlineColorLabel">
|
||||
<property name="text">
|
||||
<string>Underline color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="highlightedColorLabel">
|
||||
<property name="text">
|
||||
<string>Highlighted color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="disabledColorLabel">
|
||||
<property name="text">
|
||||
<string>Disabled color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="placeholderTextLabel">
|
||||
<property name="text">
|
||||
<string>Placeholder text</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="clearSelectionLabel">
|
||||
<property name="text">
|
||||
<string>Clear selection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="foregroundColorLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="foregroundColorToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="underlineColorLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="underlineColorToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="highlightedColorLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="highlightedColorToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="disabledColorLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="disabledColorToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="placeholderLineEdit"/>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QToolButton" name="clearSelectionToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="useThemeColorsLabel">
|
||||
<property name="text">
|
||||
<string>Use theme colors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="useThemeColorsCheckBox"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="placeholderColorLabel">
|
||||
<property name="text">
|
||||
<string>Placeholder color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="placeholderColorLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="placeholderColorToolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<zorder>formLayoutWidget</zorder>
|
||||
<zorder>backgroundColorLabel</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue