Subversion Repositories Code-Repo

Rev

Rev 363 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 363 Rev 364
Line 9... Line 9...
9
 
9
 
10
    // Misc button group
10
    // Misc button group
11
    groupOther = new QGroupBox("Other");
11
    groupOther = new QGroupBox("Other");
12
    btnMacro = new QPushButton("&Macros");
12
    btnMacro = new QPushButton("&Macros");
13
    btnPaste = new QPushButton("&Paste");
13
    btnPaste = new QPushButton("&Paste");
14
    QGridLayout *otherLayout = new QGridLayout();
-
 
15
    otherLayout->addWidget(btnMacro, 0, 0);
-
 
16
    otherLayout->addWidget(btnPaste, 1, 0);
-
 
17
    groupOther->setLayout(otherLayout);
14
    ToggleGroupLayout(false);
18
 
15
 
19
    // Initialize serial widget
16
    // Initialize serial widget
20
    serialWidget = new SerialWidget();
17
    serialWidget = new SerialWidget();
21
    groupSerialInit = new QGroupBox("Serial Connection");
18
    groupSerialInit = new QGroupBox("Serial Connection");
22
    QGridLayout *serialInitLayout = new QGridLayout();
19
    QGridLayout *serialInitLayout = new QGridLayout();
Line 31... Line 28...
31
    QGridLayout *serialDataLayout = new QGridLayout();
28
    QGridLayout *serialDataLayout = new QGridLayout();
32
    serialDataLayout->setContentsMargins(0, 0, 0, 0);
29
    serialDataLayout->setContentsMargins(0, 0, 0, 0);
33
    serialDataLayout->addWidget(ioWidget);
30
    serialDataLayout->addWidget(ioWidget);
34
    groupSerialData->setLayout(serialDataLayout);
31
    groupSerialData->setLayout(serialDataLayout);
35
    connect(serialWidget, SIGNAL(ReceivedByte(QByteArray)), ioWidget, SLOT(ProcessReceivedByte(QByteArray)));
32
    connect(serialWidget, SIGNAL(ReceivedByte(QByteArray)), ioWidget, SLOT(ProcessReceivedByte(QByteArray)));
36
    connect(serialWidget, SIGNAL(Connected()), ioWidget, SLOT(EnableTransmit()));
33
    connect(serialWidget, SIGNAL(Connected(bool)), ioWidget, SLOT(EnableTransmit(bool)));
37
    connect(serialWidget, SIGNAL(Disconnected()), ioWidget, SLOT(DisableTransmit()));
-
 
38
    connect(ioWidget, SIGNAL(TransmitByteArray(QByteArray)), serialWidget, SIGNAL(TransmitByteArray(QByteArray)));
34
    connect(ioWidget, SIGNAL(TransmitByteArray(QByteArray)), serialWidget, SIGNAL(TransmitByteArray(QByteArray)));
39
 
35
 
40
    // Initialize macro widget
36
    // Initialize macro widget
41
    macroDockWidget = new QDockWidget("Macro Controller", this);
37
    macroDockWidget = new QDockWidget("Macro Controller", this);
42
    macroWidget = new MacroWidget(macroDockWidget);
38
    macroWidget = new MacroWidget(macroDockWidget);
43
    macroDockWidget->setWidget(macroWidget);
39
    macroDockWidget->setWidget(macroWidget);
44
    macroDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
40
    macroDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
45
    macroDockWidget->hide();
41
    macroDockWidget->hide();
46
    addDockWidget(Qt::RightDockWidgetArea, macroDockWidget);
42
    addDockWidget(Qt::RightDockWidgetArea, macroDockWidget);
47
    connect(macroWidget, SIGNAL(TransmitText(QByteArray)), ioWidget, SLOT(PreprocessTransmit(QByteArray)));
43
    connect(macroWidget, SIGNAL(TransmitText(QByteArray)), ioWidget, SLOT(PreprocessTransmit(QByteArray)));
48
    connect(serialWidget, SIGNAL(Connected()), macroWidget, SLOT(EnableTransmit()));
44
    connect(serialWidget, SIGNAL(Connected(bool)), macroWidget, SLOT(EnableTransmit(bool)));
49
    connect(serialWidget, SIGNAL(Disconnected()), macroWidget, SLOT(DisableTransmit()));
-
 
50
 
45
 
51
    // Initialize paste controller widget
46
    // Initialize paste controller widget
52
    pasteDockWidget = new QDockWidget("Paste Controller", this);
47
    pasteDockWidget = new QDockWidget("Paste Controller", this);
53
    pasteWidget = new PasteController(pasteDockWidget);
48
    pasteWidget = new PasteController(pasteDockWidget);
54
    pasteDockWidget->setWidget(pasteWidget);
49
    pasteDockWidget->setWidget(pasteWidget);
55
    pasteDockWidget->setFloating(true);
50
    pasteDockWidget->setFloating(true);
-
 
51
    pasteDockWidget->hide();
-
 
52
    connect(serialWidget, SIGNAL(Connected(bool)), pasteWidget, SLOT(EnableTransmit(bool)));
-
 
53
    connect(pasteWidget, SIGNAL(TransmitData(QByteArray)), ioWidget, SLOT(PreprocessTransmit(QByteArray)));
56
 
54
 
57
    // Connect local widgets
55
    // Connect local widgets
58
    connect(btnMacro, SIGNAL(clicked()), macroDockWidget->toggleViewAction(), SLOT(trigger()));
56
    connect(btnMacro, SIGNAL(clicked()), macroDockWidget->toggleViewAction(), SLOT(trigger()));
59
    connect(btnPaste, SIGNAL(clicked()), pasteDockWidget->toggleViewAction(), SLOT(trigger()));
57
    connect(btnPaste, SIGNAL(clicked()), pasteDockWidget->toggleViewAction(), SLOT(trigger()));
60
 
58
 
Line 64... Line 62...
64
    mainLayout->addWidget(groupOther, 0, 1, 1, 1, Qt::AlignLeft);
62
    mainLayout->addWidget(groupOther, 0, 1, 1, 1, Qt::AlignLeft);
65
    mainLayout->addWidget(groupSerialData, 1, 0, 1, 2);
63
    mainLayout->addWidget(groupSerialData, 1, 0, 1, 2);
66
    mainLayout->setColumnStretch(0, 0);
64
    mainLayout->setColumnStretch(0, 0);
67
    mainLayout->setColumnStretch(1, 1);
65
    mainLayout->setColumnStretch(1, 1);
68
    centralWidget->setLayout(mainLayout);
66
    centralWidget->setLayout(mainLayout);
-
 
67
    connect(serialWidget, SIGNAL(Connected(bool)), this, SLOT(ToggleGroupLayout(bool)));
69
 
68
 
70
    setWindowTitle("Marlin Controller");
69
    setWindowTitle("Marlin Controller");
71
    setWindowIcon(QIcon(":/External/Resources/Icon_16.bmp"));
70
    setWindowIcon(QIcon(":/External/Resources/Icon_16.bmp"));
72
 
71
 
73
    labelSerialStatus = new QLabel("Disconnected");
72
    labelSerialStatus = new QLabel("Disconnected");
Line 86... Line 85...
86
 
85
 
87
void MainWindow::UpdateSerialStatus(QString string)
86
void MainWindow::UpdateSerialStatus(QString string)
88
{
87
{
89
    labelSerialStatus->setText(string);
88
    labelSerialStatus->setText(string);
90
}
89
}
-
 
90
 
-
 
91
void MainWindow::ToggleGroupLayout(bool toggle)
-
 
92
{
-
 
93
    QGridLayout *layout = qobject_cast<QGridLayout*>(groupOther->layout());
-
 
94
    if (layout == NULL) layout = new QGridLayout();
-
 
95
    layout->removeWidget(btnMacro);
-
 
96
    layout->removeWidget(btnPaste);
-
 
97
    if (toggle) {
-
 
98
        layout->addWidget(btnMacro, 0, 0);
-
 
99
        layout->addWidget(btnPaste, 0, 1);
-
 
100
    } else {
-
 
101
        layout->addWidget(btnMacro, 0, 0);
-
 
102
        layout->addWidget(btnPaste, 1, 0);
-
 
103
    }
-
 
104
    groupOther->setLayout(layout);
-
 
105
    groupOther->repaint();
-
 
106
}