Newer
Older
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
#include "OE_ui_toolbox.h"
#include <QtWidgets/QFormLayout>
#include <qtmaterialtooltabs_internal.h>
#include "ui_mainwindow.h"
OE_ui_toolBox::OE_ui_toolBox(MainWindow* window, OE_root* root)
{
this->root = root;
this->window = window;
buttonFont = QFont("Roboto", 8, QFont::Medium);
setFixedWidth(150);
setSizePolicy(QSizePolicy ::Fixed , QSizePolicy ::Expanding );
QVBoxLayout *drawerLeftLayout = new QVBoxLayout;
setLayout(drawerLeftLayout);
drawerLeftLayout->setMargin(0);
drawerLeftLayout->setContentsMargins(0,0,0,0);
QtMaterialToolTabs *tabs = new QtMaterialToolTabs;
tabs->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
drawerLeftLayout->addWidget(tabs);
tabs->setFont(buttonFont);
addFilesTools(tabs);
addGuidesTools(tabs);
addStitchTools(tabs);
addThreadTools(tabs);
addTechnicalTools(tabs);
addMachineTools(tabs);
drawerLeftLayout->setStretch(0,1);
setContentsMargins(0, 0, 0, 0);
}
QtMaterialFlatButton* OE_ui_toolBox::setButton(QString name, const char * method = NULL)
{
QtMaterialFlatButton* button = new QtMaterialFlatButton(name);
button->setFont(buttonFont);
button->setUseThemeColors(true);
button->setHaloVisible(false);
button->setTextAlignment(Qt::AlignLeft);
button->setMinimumHeight(0);
if (method)
connect(button, SIGNAL(clicked(bool)), this, method);
return button;
}
QtMaterialFlatButton* OE_ui_toolBox::setButton(QString name,QString iconFile, const char * method = NULL)
{
QtMaterialFlatButton* newButton = setButton(name, method);
QIcon icon;
icon.addFile(iconFile, QSize(), QIcon::Normal, QIcon::Off);
newButton->setIcon(icon);
//newButton->setIconPlacement(Material::ButtonIconPlacement::RightIcon);
return newButton;
}
void OE_ui_toolBox::addFilesTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Files");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("New",":/resources/new.svg", SLOT(on_actionNew_triggered())));
toolLayout->addWidget(setButton("Open",":/resources/open.svg", SLOT(on_actionOpen_triggered())));
toolLayout->addWidget(setButton("Append"));
toolLayout->addWidget(setButton("Save as",":/resources/save.svg", NULL));
toolLayout->addStretch();
}
void OE_ui_toolBox::addGuidesTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Curves");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("Close", SLOT(on_actionCloseCurve_triggered())));
toolLayout->addWidget(setButton("Reverse", SLOT(on_actionReverse_curve_R_triggered())));
QLabel* label = new QLabel("Turn: ");
label->setFont(buttonFont);
label->setAlignment(Qt::AlignCenter);
toolLayout->addWidget(label);
QHBoxLayout *turnLayout = new QHBoxLayout(curTab->content());
toolLayout->addLayout(turnLayout);
turnLayout->addWidget(setButton("Right"));
turnLayout->addWidget(setButton("Left"));
turnLayout->addWidget(setButton("360°"));
toolLayout->addWidget(setButton("Add curve"));
toolLayout->addStretch();
}
void OE_ui_toolBox::addStitchTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Stitches");
tabs->addTab(curTab);
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("New line", SLOT(on_actionLine_triggered())));
toolLayout->addWidget(setButton("New birail", SLOT(on_actionBirail_triggered())));
toolLayout->addWidget(setButton("New fill", SLOT(on_actionFill_triggered())));
//toolLayout->addWidget(setButton("Reverse selected", SLOT(on_actionReverse_curve_R_triggered())));
toolLayout->addStretch();
QLabel* label = new QLabel("-- favorite Paterns --");
label->setFont(buttonFont);
label->setAlignment(Qt::AlignCenter);
toolLayout->addWidget(label);
QGridLayout * paternLayout = new QGridLayout();
toolLayout->addLayout(paternLayout);
paternLayout->addWidget(setButton("1",SLOT(on_actionPattern1_triggered())),0,0,1,1);
paternLayout->addWidget(setButton("2",SLOT(on_actionPattern2_triggered())),0,1,1,1);
paternLayout->addWidget(setButton("3",SLOT(on_actionPattern3_triggered())),0,2,1,1);
/*paternLayout->addWidget(setButton("3",SLOT(on_actionPattern3_triggered())),0,2,1,1);
QtMaterialFlatButton* button = new QtMaterialFlatButton("3");
button->setFont(buttonFont);
button->setUseThemeColors(true);
button->setHaloVisible(false);
button->setTextAlignment(Qt::AlignLeft);
button->setMinimumHeight(0);
button->addAction(window->actionPattern3);*/
paternLayout->addWidget(setButton("4",SLOT(on_actionPattern4_triggered())),0,3,1,1);
paternLayout->addWidget(setButton("5",SLOT(on_actionPattern5_triggered())),0,4,1,1);
paternLayout->addWidget(setButton("6",SLOT(on_actionPattern6_triggered())),1,0,1,1);
paternLayout->addWidget(setButton("7",SLOT(on_actionPattern7_triggered())),1,1,1,1);
paternLayout->addWidget(setButton("8",SLOT(on_actionPattern8_triggered())),1,2,1,1);
paternLayout->addWidget(setButton("9",SLOT(on_actionPattern9_triggered())),1,3,1,1);
paternLayout->addWidget(setButton("10",SLOT(on_actionPattern9_triggered())),1,4,1,1);
}
void OE_ui_toolBox::addThreadTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Threads");
tabs->addTab(curTab);
//curTab->button()->setIcon(icon);
//curTab->button()->setIconSize(QSize(22, 22));
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("New thread from lib"));
toolLayout->addStretch();
QLabel* label = new QLabel("-- Used threads --");
label->setFont(buttonFont);
label->setAlignment(Qt::AlignCenter);
toolLayout->addWidget(label);
QGridLayout * paternLayout = new QGridLayout();
toolLayout->addLayout(paternLayout);
paternLayout->addWidget(setButton("1",SLOT(on_actionPattern1_triggered())),0,0,1,1);
paternLayout->addWidget(setButton("2",SLOT(on_actionPattern2_triggered())),0,1,1,1);
paternLayout->addWidget(setButton("3",SLOT(on_actionPattern3_triggered())),0,2,1,1);
paternLayout->addWidget(setButton("4",SLOT(on_actionPattern4_triggered())),0,3,1,1);
paternLayout->addWidget(setButton("5",SLOT(on_actionPattern5_triggered())),0,4,1,1);
paternLayout->addWidget(setButton("6",SLOT(on_actionPattern6_triggered())),1,0,1,1);
paternLayout->addWidget(setButton("+",SLOT(on_actionPattern5_triggered())),1,1,1,1);
}
void OE_ui_toolBox::addTechnicalTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Technical");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("underlay"));
toolLayout->addWidget(setButton("Push/pull"));
toolLayout->addWidget(setButton("cut link"));
toolLayout->addWidget(setButton("set speed"));
toolLayout->addStretch();
}
void OE_ui_toolBox::addMachineTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Machine control");
tabs->addTab(curTab);
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("Connect", SLOT(on_actionConnectToMachine_triggered(bool checked))));
toolLayout->addWidget(setButton("Push", SLOT(on_actionMachineLoad_triggered())));
toolLayout->addWidget(setButton("Run", SLOT(on_actionMachineRun_triggered())));
toolLayout->addStretch();
connect(window, SIGNAL(machineConnectionChanged), this, SLOT(on_machineConnectionChanged));
}
void OE_ui_toolBox::sendKeyPulse(Qt::Key key, Qt::KeyboardModifiers modifiers)
{
QKeyEvent fakeKeyPress(QKeyEvent::Type::KeyPress, key, modifiers);
root->interfaceDisplay->key(&fakeKeyPress);
QKeyEvent fakeKeyRelease(QKeyEvent::Type::KeyRelease, key, modifiers);
root->interfaceDisplay->key(&fakeKeyRelease);
}
void OE_ui_toolBox::on_actionNew_triggered()
{
window->addTab();
}
void OE_ui_toolBox::on_actionOpen_triggered()
{ // TODO real call to a load function, not a fake key event
sendKeyPulse(Qt::Key_O, Qt::KeyboardModifier::ControlModifier);
}
void OE_ui_toolBox::on_actionSave_triggered()
{ // TODO real call to a save function, not a fake key event
sendKeyPulse(Qt::Key_S, Qt::KeyboardModifier::ControlModifier);
}
void OE_ui_toolBox::on_actionLine_triggered()
{ // TODO real call to a save function, not a fake key event
sendKeyPulse(Qt::Key_L, Qt::KeyboardModifier::NoModifier);
}
void OE_ui_toolBox::on_actionBirail_triggered()
{
sendKeyPulse(Qt::Key_B, Qt::KeyboardModifier::NoModifier);
}
void OE_ui_toolBox::on_actionFill_triggered()
{
sendKeyPulse(Qt::Key_F, Qt::KeyboardModifier::NoModifier);
}
void OE_ui_toolBox::on_actionPattern1_triggered() { sendKeyPulse(Qt::Key_1, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern2_triggered() { sendKeyPulse(Qt::Key_2, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern3_triggered() { sendKeyPulse(Qt::Key_3, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern4_triggered() { sendKeyPulse(Qt::Key_4, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern5_triggered() { sendKeyPulse(Qt::Key_5, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern6_triggered() { sendKeyPulse(Qt::Key_6, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern7_triggered() { sendKeyPulse(Qt::Key_7, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern8_triggered() { sendKeyPulse(Qt::Key_8, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionPattern9_triggered() { sendKeyPulse(Qt::Key_9, Qt::KeyboardModifier::KeypadModifier); }
void OE_ui_toolBox::on_actionCloseCurve_triggered()
{
sendKeyPulse(Qt::Key_C, Qt::KeyboardModifier::NoModifier);
}
/*void OE_ui_toolBox::on_actionReverse_curve_R_triggered()
{
sendKeyPulse(Qt::Key_R, Qt::KeyboardModifier::NoModifier);
}*/
void OE_ui_toolBox::on_actionMachineRun_triggered()
{
window->machineRun();
}
void OE_ui_toolBox::on_actionMachineLoad_triggered()
{
window->machineLoad();
}
void OE_ui_toolBox::on_machineConnectionChanged(bool connected)
{
// ui->actionMachineRun->setEnabled(connected);
// ui->actionMachineLoad->setEnabled(connected);
}