forked from laserpants/qt-material-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawersettingseditor.cpp
77 lines (59 loc) · 2.25 KB
/
drawersettingseditor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "drawersettingseditor.h"
#include <QVBoxLayout>
#include <QColorDialog>
#include <qtmaterialdrawer.h>
DrawerSettingsEditor::DrawerSettingsEditor(QWidget *parent)
: QWidget(parent),
ui(new Ui::DrawerSettingsForm),
m_drawer(new QtMaterialDrawer)
{
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);
canvas->setMaximumHeight(300);
m_drawer->setParent(canvas);
m_drawer->setClickOutsideToClose(true);
m_drawer->setOverlayMode(true);
//
QVBoxLayout *drawerLayout = new QVBoxLayout;
m_drawer->setDrawerLayout(drawerLayout);
QVector<QString> labels = {"Motion", "Style", "Layout", "Components", "Patterns", "Growth & communications", "Usability", "Platforms", "Resources"};
QVector<QString>::iterator it;
for (it = labels.begin(); it != labels.end(); ++it) {
QLabel *label = new QLabel(*it);
label->setMinimumHeight(30);
label->setFont(QFont("Roboto", 10, QFont::Medium));
drawerLayout->addWidget(label);
}
drawerLayout->addStretch(3);
m_drawer->setContentsMargins(10, 0, 0, 0);
drawerLayout->addWidget(new QPushButton("abc"));
//
setupForm();
connect(ui->showDrawerButton, SIGNAL(pressed()), m_drawer, SLOT(openDrawer()));
connect(ui->hideDrawerButton, SIGNAL(pressed()), m_drawer, SLOT(closeDrawer()));
connect(ui->clickToCloseCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget()));
connect(ui->overlayModeCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateWidget()));
}
DrawerSettingsEditor::~DrawerSettingsEditor()
{
delete ui;
}
void DrawerSettingsEditor::setupForm()
{
ui->clickToCloseCheckBox->setChecked(m_drawer->clickOutsideToClose());
ui->overlayModeCheckBox->setChecked(m_drawer->overlayMode());
}
void DrawerSettingsEditor::updateWidget()
{
m_drawer->setClickOutsideToClose(ui->clickToCloseCheckBox->isChecked());
m_drawer->setOverlayMode(ui->overlayModeCheckBox->isChecked());
}