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

This commit is contained in:
Francesco Perillo 2017-10-05 14:21:06 +02:00
commit 74bea57346
4 changed files with 284 additions and 30 deletions

247
README.md
View File

@ -4,25 +4,234 @@
I finally took the time to go through and clean up this code. The build includes an executable with a preview, and some settings to play around with for each widget. A YouTube video preview is [available here](http://www.youtube.com/watch?v=21UMeNVBPU4). I finally took the time to go through and clean up this code. The build includes an executable with a preview, and some settings to play around with for each widget. A YouTube video preview is [available here](http://www.youtube.com/watch?v=21UMeNVBPU4).
Component | Preview <table>
----------------- | ------------------------------------------------ <tbody>
Avatar | ![Avatar](gifs/avatar.gif) <tr>
Check Box | ![Check Box](gifs/checkbox.gif) <td colspan="2"></td>
Circular Progress | ![Circular Progressj](gifs/circularprogress.gif) </tr>
Dialog | ![Dialog](gifs/dialog.gif) <tr>
Drawer | ![Drawer](gifs/drawer.gif) <td>
FAB | ![FAB](gifs/fab.gif) Avatar
Flat Button | ![Flat Button](gifs/flatbutton.gif) </td>
Icon Button | ![Icon Button](gifs/iconbutton.gif) <td>
Progress | ![Progress](gifs/progress.gif) <code>QtMaterialAvatar</code>
Radio Button | ![Radio Button](gifs/radiobutton.gif) </td>
Raised Button | ![Raised Button](gifs/raisedbutton.gif) </tr>
Scroll Bar | ![Scroll Bar](gifs/scrollbar.gif) <tr>
Slider | ![Slider](gifs/slider.gif) <td colspan="2">
Snackbar | ![Snackbar](gifs/snackbar.gif) <img src="gifs/avatar.gif" />
Tabs | ![Tabs](gifs/tabs.gif) </td>
Text Field | ![Text Field](gifs/textfield.gif) </tr>
Toggle | ![checkbox](gifs/toggle.gif) <tr>
<td>
Check Box
</td>
<td>
<code>QtMaterialCheckBox</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/checkbox.gif" />
</td>
</tr>
<tr>
<td>
Circular Progress
</td>
<td>
<code>QtMaterialCircularProgress</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/circularprogress.gif" />
</td>
</tr>
<tr>
<td>
Dialog
</td>
<td>
<code>QtMaterialDialog</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/dialog.gif" />
</td>
</tr>
<tr>
<td>
Drawer
</td>
<td>
<code>QtMaterialDrawer</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/drawer.gif" />
</td>
</tr>
<tr>
<td>
FAB
</td>
<td>
<code>QtMaterialFloatingActionButton</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/fab.gif" />
</td>
</tr>
<tr>
<td>
Flat Button
</td>
<td>
<code>QtMaterialFlatButton</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/flatbutton.gif" />
</td>
</tr>
<tr>
<td>
Icon Button
</td>
<td>
<code>QtMaterialIconButton</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/iconbutton.gif" />
</td>
</tr>
<tr>
<td>
Progress
</td>
<td>
<code>QtMaterialProgress</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/progress.gif" />
</td>
</tr>
<tr>
<td>
Radio Button
</td>
<td>
<code>QtMaterialRadioButton</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/radiobutton.gif" />
</td>
</tr>
<tr>
<td>
Raised Button
</td>
<td>
<code>QtMaterialRaisedButton</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/raisedbutton.gif" />
</td>
</tr>
<tr>
<td>
Scroll Bar
</td>
<td>
<code>QtMaterialScrollBar</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/scrollbar.gif" />
</td>
</tr>
<tr>
<td>
Slider
</td>
<td>
<code>QtMaterialSlider</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/slider.gif" />
</td>
</tr>
<tr>
<td>
Snackbar
</td>
<td>
<code>QtMaterialSnackBar</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/snackbar.gif" />
</td>
</tr>
<tr>
<td>
Tabs
</td>
<td>
<code>QtMaterialTabs</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/tabs.gif" />
</td>
</tr>
<tr>
<td>
Text Field
</td>
<td>
<code>QtMaterialTextField</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/textfield.gif" />
</td>
</tr>
<tr>
<td>
Toggle
</td>
<td>
<code>QtMaterialToggle</code>
</td>
</tr>
<tr>
<td colspan="2">
<img src="gifs/toggle.gif" />
</td>
</tr>
</tbody>
</table>
#### Implemented components #### Implemented components

View File

@ -14,13 +14,34 @@
* \internal * \internal
*/ */
/*!
* \internal
*/
QtMaterialDrawerPrivate::QtMaterialDrawerPrivate(QtMaterialDrawer *q) QtMaterialDrawerPrivate::QtMaterialDrawerPrivate(QtMaterialDrawer *q)
: q_ptr(q), : q_ptr(q)
stateMachine(new QtMaterialDrawerStateMachine(q)),
window(new QWidget),
width(250),
clickToClose(false)
{ {
}
/*!
* \internal
*/
QtMaterialDrawerPrivate::~QtMaterialDrawerPrivate()
{
}
/*!
* \internal
*/
void QtMaterialDrawerPrivate::init()
{
Q_Q(QtMaterialDrawer);
stateMachine = new QtMaterialDrawerStateMachine(q);
window = new QWidget;
width = 250;
clickToClose = false;
autoRaise = true;
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(window); layout->addWidget(window);
@ -28,7 +49,6 @@ QtMaterialDrawerPrivate::QtMaterialDrawerPrivate(QtMaterialDrawer *q)
q->setFixedWidth(width+16); q->setFixedWidth(width+16);
stateMachine->start(); stateMachine->start();
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
@ -40,6 +60,7 @@ QtMaterialDrawer::QtMaterialDrawer(QWidget *parent)
: QtMaterialOverlayWidget(parent), : QtMaterialOverlayWidget(parent),
d_ptr(new QtMaterialDrawerPrivate(this)) d_ptr(new QtMaterialDrawerPrivate(this))
{ {
d_func()->init();
} }
QtMaterialDrawer::~QtMaterialDrawer() QtMaterialDrawer::~QtMaterialDrawer()
@ -90,12 +111,29 @@ bool QtMaterialDrawer::clickOutsideToClose() const
return d->clickToClose; return d->clickToClose;
} }
void QtMaterialDrawer::setAutoRaise(bool state)
{
Q_D(QtMaterialDrawer);
d->autoRaise = state;
}
bool QtMaterialDrawer::autoRaise() const
{
Q_D(const QtMaterialDrawer);
return d->autoRaise;
}
void QtMaterialDrawer::openDrawer() void QtMaterialDrawer::openDrawer()
{ {
Q_D(QtMaterialDrawer); Q_D(QtMaterialDrawer);
emit d->stateMachine->enterOpenedState(); emit d->stateMachine->enterOpenedState();
raise();
if (d->autoRaise) {
raise();
}
} }
void QtMaterialDrawer::closeDrawer() void QtMaterialDrawer::closeDrawer()

View File

@ -23,6 +23,9 @@ public:
void setClickOutsideToClose(bool state); void setClickOutsideToClose(bool state);
bool clickOutsideToClose() const; bool clickOutsideToClose() const;
void setAutoRaise(bool state);
bool autoRaise() const;
public slots: public slots:
void openDrawer(); void openDrawer();
void closeDrawer(); void closeDrawer();

View File

@ -13,12 +13,16 @@ class QtMaterialDrawerPrivate
public: public:
QtMaterialDrawerPrivate(QtMaterialDrawer *q); QtMaterialDrawerPrivate(QtMaterialDrawer *q);
~QtMaterialDrawerPrivate();
void init();
QtMaterialDrawer *const q_ptr; QtMaterialDrawer *const q_ptr;
QtMaterialDrawerStateMachine *const stateMachine; QtMaterialDrawerStateMachine *stateMachine;
QWidget *const window; QWidget *window;
int width; int width;
bool clickToClose; bool clickToClose;
bool autoRaise;
}; };
#endif // DRAWER_P_H #endif // DRAWER_P_H